Jump to content

Is it o.k to extend a pre-existing partmodule?


Recommended Posts

I am trying to write some code for the heating management mod. My initial approach was to extend the ModuleDeployableSolarPanel Module and adjust it so that it rotates itself parralell to the sun instead of perpendicular. After looking in the assembly browser I found a field called sunAOA, so I thought perfect, I'll just write a property for this that modifies it's value so that it rotates away from the sun. However, when I tried this nothing happened. the debug statements don't even show up. So now I'm stuck and have no idea what i'm doing wrong. any suggestions.

Here is my code:

using System;
using UnityEngine;

namespace HeatManagement
{
public class ModuleDeployableRadiator : ModuleDeployableSolarPanel
{
// public override void OnStart (StartState state)
// {
// print("TESTING");
//
// }
private float modSunAOA = 0;
public new float sunAOA
{
get
{
print ("TESTING");
return modSunAOA;
}
set
{
print("[HEATMANAGER] sunAOA: " + sunAOA);
modSunAOA = Math.Abs(value - 1);
print("[HEATMANAGER] value: " + value);
}
}
}
}

- - - Updated - - -

New Development (pun intended)! I tried adding a kspField to the start of my property, just to see what would happen. I changed the GUI name so I could see if it worked and when I opened the right click menu It was still "Sun Exposure", the old GUI name.

new code:

using System;
using UnityEngine;

namespace HeatManagement
{
public class ModuleDeployableRadiator : ModuleDeployableSolarPanel
{
// public override void OnStart (StartState state)
// {
// print("TESTING");
//
// }
private float _sunAOA;

[KSPField (guiName = "radiator occlusion", guiUnits = " ", guiFormat = "F2", guiActive = true)]
public new float sunAOA
{
get
{
print ("TESTING");
return _sunAOA;
}
set
{
print("[HEATMANAGER] sunAOA: " + sunAOA);
_sunAOA = Math.Abs(value - 1);
print("[HEATMANAGER] value: " + value);
}
}

}
}

Link to comment
Share on other sites

1) Rename the module to your own name PartModule in the part cfg and add a RadiatorAoA entry

2) something like this should work

[KSPField]
public float RadiatorAoA;

public override void OnStart(StartState state)
{
SunAOA = RadiatorAoA;
}

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...