/// <summary> /// Fired when the entity is despawned. /// </summary> public override void OnDespawn() { if (Entity.Engine is GameEngine2D eng) { eng.Lights.Remove(ActualLight); ActualLight.Destroy(); ActualLight = null; Entity.OnPositionChanged -= FixPosition; } else { SysConsole.Output(OutputType.WARNING, "2D light despawned from a non-2D-engine-based game!"); } }