Jump to content

How to track crew assignments in editor? ~Answered~


Recommended Posts

I'm trying to track changes that the player makes in the "Crew" tab of the vessel editor (e.g. assigning or unassigning kerbals to crew slots).  My requirement is that if the player makes a change, I need to find out about it before the vessel is saved.

Therefore, any of the following would work for me:

  • A way to be notified when a change is made on the Crew tab
  • A way of asking "what are the currently assigned kerbals in the crew tab"

I've been rummaging around for hours but haven't been able to find anything that works.  The ShipConstruction class has a static VesselCrewManifest property that's almost what I need.  It works before entering the crew tab, or after exiting the crew tab. So, for example, I can trap the "editor screen changed" event and see what changed when they exit the crew tab.

However, I've found that changes that the player makes inside the crew tab don't take effect on the ShipConstruction property until the player exits the tab, which is too late for me: e.g. if the player makes a change inside the crew tab and then hits the "save" button before exiting the tab.

Any suggestions much appreciated!

Edited by Snark
Link to comment
Share on other sites

  • 2 weeks later...

(Well I come here because you link this in another thread) If the motivation is what's described there just to disable auto assignment - why not just try to hack to bypass the first automatic assignment logic? If there's at least one conditional branch, there's hope. In that way you don't need to track anything.

Of course - I haven't checked IL and don't know if it's possible at all, but that would be my first thing to try before going into this nasty tracking/saving/whatever business.

Link to comment
Share on other sites

25 minutes ago, FancyMouse said:

(Well I come here because you link this in another thread) If the motivation is what's described there just to disable auto assignment - why not just try to hack to bypass the first automatic assignment logic? If there's at least one conditional branch, there's hope. In that way you don't need to track anything.

Of course - I haven't checked IL and don't know if it's possible at all, but that would be my first thing to try before going into this nasty tracking/saving/whatever business.

I can certainly do that, I've figured out how to tinker with the crew assignments before entering the crew tab.  If the player alters assignments in the crew tab, I can also see what they did after they leave the crew tab.

However, for the purposes of my mod, I also need to be able to trap events in the crew tab, at the time that they happen.  And I haven't been able to figure out any way to do that.  Whatever code is running the crew tab appears not to update the vessel crew manifest until you either launch the ship or leave the crew tab.

What I need is some way of seeing what the actual state of those crew slots inside the crew tab are, as they're assigned.  grrrr. :huh:

Link to comment
Share on other sites

2 hours ago, sarbian said:

CMAssignmentDialog.Instance.GetManifest()  should give you the current state of the dialog.

THANK YOU! thankyouthankyouthankyou... This is what had me wedged for more than a week.  It's exactly what I need, and completely undiscoverable since it doesn't have "crew" in the name.

<rant>
Advice from a professional software engineer, to any current or prospective future software engineers:  This, friends, is why you never use abbreviations in class names.  It causes confusion and grief, and (thanks to auto-complete in every modern IDE) doesn't actually save anybody any typing.  It's a bad idea. Don't do it.
</rant>

Anyway, you're a lifesaver.  Heartfelt gratitude!

Link to comment
Share on other sites

1 hour ago, Snark said:

THANK YOU! thankyouthankyouthankyou... This is what had me wedged for more than a week.  It's exactly what I need, and completely undiscoverable since it doesn't have "crew" in the name.

<rant>
Advice from a professional software engineer, to any current or prospective future software engineers:  This, friends, is why you never use abbreviations in class names.  It causes confusion and grief, and (thanks to auto-complete in every modern IDE) doesn't actually save anybody any typing.  It's a bad idea. Don't do it.
</rant>

Anyway, you're a lifesaver.  Heartfelt gratitude!

I agree with your rant.  Especially with autocomplete.

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