public void DestroyEntity(SimulationEntity entity) { if (!initialized) { throw new InvalidOperationException("Can't remove entities from simulations that haven't been initialized"); } if (entity.Destroyed) { throw new InvalidOperationException("Can't remove a destroyed entity"); } if (simulationListener != null) { simulationListener.EntityRemoved(entity); } for (int i = 0; i < entity.components.Count; i++) { for (int j = 0; j < componentManagers.Count; j++) { componentManagers[j].ComponentRemoved(entity.components[i]); } } entity.Destroy(); entities.Remove(entity); }