Jump to content

AddValueChangedDelegate & IPartCostModifier errors when reviving old code


Recommended Posts

Ok, this is two questions in one post.  I'm trying to revive an old and dead mod.  I've gone through most of the code and I'm down to 3 errors and 2 warnings and these are the ones Google is not giving me a solid answer on.

First one

 public class ShipCost : PartModule, IPartCostModifier

I get this error:

'ShipCost' does not implement interface member 'IPartCostModifier.GetModuleCost(float, ModifierStagingSituation)'  

and this error:

'ShipCost' does not implement interface member 'IPartCostModifier.GetModuleCostChangeWhen()'
 

I'm not sure if I'm doing this right but, I changed this line

public float GetModuleCost(float stdCost)

to this

        public float GetModuleCost(float stdCost, ModifierStagingSituation sit)

and added in this

        public ModifierChangeWhen GetModuleCostChangeWhen()
        {
            throw new NotImplementedException();
        }

and it quit complaining.

Did I get that right?

 

 

Next one is a good bit more complex.

The original modder appeared to be hijacking the Center of Lift marker in the editor in order to have it show Center of Buoyancy?.

vesselOverlays = (EditorVesselOverlays)GameObject.FindObjectOfType(
               typeof(EditorVesselOverlays));

	    if (vesselOverlays == null)
                Log.post("Error. No vesselOverlays found", LogLevel.LOG_ERROR);

I run into problems here:

vesselOverlays.toggleCoLbtn.AddValueChangedDelegate(this.CoLButtonClick);

I'm guessing that the modder was adding this delegate to detect when the Center of Lift button in the Editor was clicked.

But, I get this error in the code:

 'Button' does not contain a definition for 'AddValueChangedDelegate' and no extension method 'AddValueChangedDelegate' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?) 

From what I gather this is part of the EZGui. and is referenced in either Assembly-CSharp or Assembly-CSharp-firstpass.  I have both of those reference in my code but, AddValueChangedDelegate is simply not there.  Nothing I've found says this has been removed.  Apparently the OLD version of EZGui used SetValueChangedDelegate, but that's not there either.

Any ideas???

Edited by Fengist
Link to comment
Share on other sites

7 hours ago, Fengist said:

 

I'm guessing that the modder was adding this delegate to detect when the Center of Lift button in the Editor was clicked.

But, I get this error in the code:

 'Button' does not contain a definition for 'AddValueChangedDelegate' and no extension method 'AddValueChangedDelegate' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?) 

 

IPartCostModifier was changed. Some details can be found in the link. The other problem is that all EzGUI stuff was migrated over to the Unity UI. EzGUI is present in the assemblies but I don't believe it's used at all anywhere anymore. toggleCoLbtn is now a UnityEngine.UI.Button so you'll want to change AddValueChangedDelegate into .onClick.AddListener

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...