Jump to content

[RESOLVED] How to Add Callback for onEditorShipModified


Recommended Posts

I want to add a callback to fire whenever onEditorShipModified occurs. I've searched and Googled and tried various solutions. No joy.


public override void OnStart()
{
GameEvents.onEditorShipModified.Add(myFunction);
}

private void myFunction(EventReport e)
{
}

When I hover over the error, I get:

The best overloaded method match for 'EventData<ShipConstruct>.Add(EventData<ShipConstruct>.OnEvent)' has some invalid arguments

When I hover over the Add, it displays this tooltip for the parameter.

EventData<ShipConstruct>.OnEvent evt)

I tried this as a definition for myFunction():

private EventData<ShipConstruct> myFunction(EventReport e)

this also failed:


public override void OnStart()
{
GameEvents.onEditorShipModified.Add(onEditorShipModified);
}

private void onEditorShipModified(EventReport e)
{
return;
}

I see callbacks for other events when I Googled them. However, this event must be special. In another thread, I saw how this person added a callback for onCrewKilled:


GameEvents.onCrewKilled.Add(onCrewKilled);

private void onCrewKilled(EventReport e)
{
Debug.Log("KSN onCrewKilled!");
}

What am I missing? How should my statements appear?

Is there any good documentation on GameEvents?

thanks

Edited by Apollo13
Link to comment
Share on other sites

myFunction needs to take a ShipConstruct:

private void myFunction(ShipConstruct sc)
{
}

If an argument needs an EventData<T>.OnEvent, what it needs is a function that takes a T and returns void. See the declaration of the EventData<T>.OnEvent delegate type here.

See here for some documentation on GameEvents.

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