Jump to content

Can I subscribe to a stock module's KSPEvent?


Recommended Posts

Like it says.  I don't want to inherit the module class, or stop the original function..i want to piggyback it.  I'd like to get a callback event when the Module gets theirs from a right click UI.  Is that possible?

 

I'd like to listen for ModuleScienceContainer::CollectDataExternalEvent, so I get notified when an EVA kerb takes the data from a container.  Afaik no GameEvent goes off during that action.  If I did subclass ModuleScienceContainer, and hid CollectDataExternalEvent with a wrapper implementation...the lack of virtual makes me fear it'll get called wrong from places I don't know about - and it seems like overkill just to observe.

 

If someone knows a game event that _does_ go off during an EVA "take data", I'd love to hear it...

Edited by SixHourDays
Link to comment
Share on other sites

I'm not sure.

This feels like something that should be possible, but looking at the Object Brower, the BaseEvent.onEvent delegate is tagged as 'protected' so I'm not sure how to access it.

The only other option is to directly hook into the button on the GUI somehow, but that would be tricky.

I think RemoteTech's done something similar? But that might have been replacing BaseEvent with their own custom Event class.

D.

Link to comment
Share on other sites

My suggestion would be to try out creating a new method with the KSPEvent attribute set up the same way and remove the other one during OnStart from the EventList. I don't think it is called from anywhere other than when the UI button is clicked.  It'll just require some testing to make sure that it works.

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