Lamp00 at 0 health doesn't get removed when calling IObject.Remove()
Posted: Sun Feb 20, 2022 3:14 pm
When you damage the lamp (object name Lamp00), it can never be removed using ScriptAPI:
Expected result: The lamp get removed regardless of its health
Code: Select all
foreach (var o in Game.GetObjects<IObject>().Where(o => o.Name == "Lamp00"))
{
// If you comment this line, the code that runs in the next 5 seconds will work
o.DealDamage(o.GetHealth());
}
// Run after 5 seconds
ScriptHelper.Timeout(() =>
{
foreach (var o in Game.GetObjects<IObject>().Where(o => o.Name == "Lamp00"))
{
o.Remove();
}
}, 5000);