There’s a race in the code as provided - it’s possible for the ServerOnGameOver event to occur after the ServerOnDie event, resulting in ResourceGenerator
attempting to call enabled = false
on an instance that was just destroyed and throwing an exception.
I’m not convinced that the subscription to GameOverHandler.ServerOnGameOver
is required - the other buildings don’t need it, and the object’s Update
won’t get called after it’s destroyed anyway.