Detecting when cargoship starts to egress?

Hi,

I want to detect when the cargoship starts to egress.

So far the only way I can think of is by setting a repeat timer to check on a set interval for when CargoShip.radiation.activeSelf turns true on the cargoship entity, because as soon as the alarm sounds and the ship begins to egress its radiation turns on.

Does anyone have any better ideas? 

OnCargoShipEgress hook

You may need to subscribe to this hook manually as it may be undocumented.

There is also OnCargoShipSpawnCrate hook

private void Loaded()
{

Subscribe("OnCargoShipEgress");
Subscribe("OnCargoShipSpawnCrate");

}

private void Unloaded()
{

Unsubscribe("OnCargoShipEgress");
Unsubscribe("OnCargoShipSpawnCrate");

}


private object OnCargoShipEgress(CargoShip cargoship) {

Puts("OnCargoShipEgress Works!");
return null;

}

private object OnCargoShipSpawnCrate(CargoShip cargoship) {

Puts("OnCargoShipSpawnCrate Works!");
return null;

}

 

Dude thanks! That's perfect. Didn't have to manually subscribe.

How did you read that code? When I did peek definition in Visual Studio while searching for something like this myself, all I got was this (p is CargoShip):



I then tried finding CargoShip in Assembly-CSharp.dll with dotPeek and I couldn't.