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

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...