private void RemoveEntityComponent(EntityComponent component, bool clean) { if (component != null) { if (_components.Contains(component) && !_removingComponents.Contains(component)) { _removingComponents.Add(component); SetEntityComponentEnabledState(component, false); RemovedComponentEvent?.Invoke(this, component); component.Deinitialize(); } if (clean) { for (int i = _removingComponents.Count - 1; i >= 0; i--) { _components.Remove(_removingComponents[i]); _disabledComponents.Remove(_removingComponents[i]); } } } }
private void OnRemovedComponentEvent(EntityComponent entityComponent) { RemovedComponentEvent?.Invoke(entityComponent); }