private void RemoveComponentImmediate(Component component) { if (component == null) { throw new ArgumentNullException(nameof(component)); } if (component.Deleted) { return; } // these two components are required on all entities and cannot be removed. if (component is ITransformComponent || component is IMetaDataComponent) { DebugTools.Assert("Tried to remove a protected component."); return; } component.Running = false; component.OnRemove(); ComponentRemoved?.Invoke(this, new ComponentEventArgs(component)); DeleteComponent(component); }
private void RemoveComponentDeferred(Component component) { if (component == null) { throw new ArgumentNullException(nameof(component)); } if (component.Deleted) { return; } _deleteList.Add(component); if (component.Running) { component.Shutdown(); } component.OnRemove(); ComponentRemoved?.Invoke(this, new ComponentEventArgs(component)); }
private void RemoveComponentImmediate(Component component) { if (component == null) { throw new ArgumentNullException(nameof(component)); } if (component.Deleted) { return; } if (component.Running) { component.Shutdown(); } component.OnRemove(); ComponentRemoved?.Invoke(this, new ComponentEventArgs(component)); DeleteComponent(component); }
private void RemoveComponentDeferred(Component component, bool removeProtected) { if (component == null) { throw new ArgumentNullException(nameof(component)); } if (component.Deleted) { return; } #if EXCEPTION_TOLERANCE try { #endif // these two components are required on all entities and cannot be removed normally. if (!removeProtected && (component is ITransformComponent || component is IMetaDataComponent)) { DebugTools.Assert("Tried to remove a protected component."); return; } _deleteList.Add(component); component.Running = false; component.OnRemove(); ComponentRemoved?.Invoke(this, new ComponentEventArgs(component)); #if EXCEPTION_TOLERANCE } catch (Exception e) { _runtimeLog.LogException(e, $"RemoveComponentDeferred, owner={component.Owner}, type={component.GetType()}"); } #endif }