Example #1
0
        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]);
                    }
                }
            }
        }
Example #2
0
 private void OnRemovedComponentEvent(EntityComponent entityComponent)
 {
     RemovedComponentEvent?.Invoke(entityComponent);
 }