Currently, if a player ship tied to a lose condition dies during a battle that kills a enemy ship that is part of the win condition, the level will be completed but the save file will be corrupted. This happens because we run the script for dead ships in (random) sequence so if we processed the dead enemy ship before the dead player ship the script will emit a LevelWon event.
We need to either make sure the dead player ships are processed first OR processed all dead ships and queue up the events to fire "together".
Also, the triggered LevelWon event will bypass dead player ship removal so the saved will contain a player ship with zero HP (which violates the contract for the world).
Currently, if a player ship tied to a lose condition dies during a battle that kills a enemy ship that is part of the win condition, the level will be completed but the save file will be corrupted. This happens because we run the script for dead ships in (random) sequence so if we processed the dead enemy ship before the dead player ship the script will emit a LevelWon event.
We need to either make sure the dead player ships are processed first OR processed all dead ships and queue up the events to fire "together".
Also, the triggered LevelWon event will bypass dead player ship removal so the saved will contain a player ship with zero HP (which violates the contract for the world).