ObjectCreatedCallback does not work without ObjectTerminatedCallback
Posted: Thu Aug 08, 2019 3:03 pm
Code: Select all
public void OnStartup()
{
Events.ObjectCreatedCallback.Start(OnObjectCreated);
// Uncomment the line below and it will work again
// Events.ObjectTerminatedCallback.Start(OnObjectTerminated);
}
public void OnObjectCreated(IObject[] objs)
{
foreach (IObject obj in objs)
{
Game.WriteToConsole(string.Format("Object {0} ({1}) created", obj.UniqueID, obj.Name));
}
}
public void OnObjectTerminated(IObject[] objs)
{
// objects terminated. Note: This is run just before the object is about to be destroyed or removed. To see if it was destroyed, check the IObject.DestructionInitiated property.
foreach (IObject obj in objs)
{
Game.WriteToConsole(string.Format("Object {0} was {1}", obj.UniqueID, (obj.DestructionInitiated ? "destroyed" : "removed")));
}
}