void UnregisterComponent(IComponentOld component) { component.Entity = null; UnregisterComponentFromGroups(component); UnregisterComponentFromMessageGroups(component); UnregisterComponentFromUpdateCallbacks(component); }
void RegisterComponentToUpdateCallbacks(IComponentOld component) { var startable = component as IStartable; if (startable != null) { startables.Add(startable); } var updateable = component as IUpdateable; if (updateable != null && !updateables.Contains(updateable)) { updateables.Add(updateable); updateCounters.Add(0f); } var lateUpdateable = component as ILateUpdateable; if (lateUpdateable != null && !lateUpdateables.Contains(lateUpdateable)) { lateUpdateables.Add(lateUpdateable); lateUpdateCounters.Add(0f); } var fixedUpdateable = component as IFixedUpdateable; if (fixedUpdateable != null && !fixedUpdateables.Contains(fixedUpdateable)) { fixedUpdateables.Add(fixedUpdateable); } }
public void TryAddComponent(IComponentOld component) { if (type.IsAssignableFrom(component.GetType())) { AddComponent(component); } }
public void RemoveComponent(IComponentOld component) { if (components.Remove(component)) { genericComponents.Remove(component); } }
void RegisterComponent(IComponentOld component) { component.Entity = this; RegisterComponentToGroups(component); RegisterComponentToMessageGroups(component); RegisterComponentToUpdateCallbacks(component); }
void OnPreComponent(SerializedProperty arrayProperty, int index, SerializedProperty property) { currentComponent = currentCategory.Components[index]; BeginBox(); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var rect = EditorGUILayout.BeginVertical(); rect.x += rect.width - 34f; rect.width = 16f; rect.height = 16f; if (currentComponent is IUpdateable) { ((IUpdateable)currentComponent).Active = GUI.Toggle(rect, ((IUpdateable)currentComponent).Active, ""); } else if (currentComponent is IFixedUpdateable) { ((IFixedUpdateable)currentComponent).Active = GUI.Toggle(rect, ((IFixedUpdateable)currentComponent).Active, ""); } else if (currentComponent is ILateUpdateable) { ((ILateUpdateable)currentComponent).Active = GUI.Toggle(rect, ((ILateUpdateable)currentComponent).Active, ""); } ShowComponentErrors(rect); EditorGUI.indentLevel = indent; }
void AddComponent(IComponentOld component) { if (!components.Contains(component)) { components.Add(component); genericComponents.Add(component); } }
protected virtual void RaiseOnComponentRemovedEvent(IComponentOld component) { if (OnComponentRemoved != null) { OnComponentRemoved(this, component); } EntityManagerOld.UpdateEntity(this); }
void AddComponent(IComponentOld component, bool raiseEvent) { allComponents.Add(component); RegisterComponent(component); // Raise event if (raiseEvent) { RaiseOnComponentAddedEvent(component); } }
void UnregisterComponentFromGroups(IComponentOld component) { if (componentGroups.Count > 0) { var enumerator = componentGroups.GetEnumerator(); while (enumerator.MoveNext()) enumerator.Current.Value.RemoveComponent(component); enumerator.Dispose(); } }
void RegisterComponentToGroups(IComponentOld component) { if (componentGroups.Count > 0) { var enumerator = componentGroups.GetEnumerator(); while (enumerator.MoveNext()) enumerator.Current.Value.TryAddComponent(component); enumerator.Dispose(); } }
void RegisterComponentToGroups(IComponentOld component) { if (componentGroups.Count > 0) { var enumerator = componentGroups.GetEnumerator(); while (enumerator.MoveNext()) { enumerator.Current.Value.TryAddComponent(component); } enumerator.Dispose(); } }
void UnregisterComponentFromGroups(IComponentOld component) { if (componentGroups.Count > 0) { var enumerator = componentGroups.GetEnumerator(); while (enumerator.MoveNext()) { enumerator.Current.Value.RemoveComponent(component); } enumerator.Dispose(); } }
public bool TryGetComponent(Type type, out IComponentOld component) { var components = GetComponents(type); if (components.Count > 0) { component = components[0]; return(true); } else { component = null; return(false); } }
void RemoveComponent(IComponentOld component, bool raiseEvent) { if (allComponents.Remove(component)) { UnregisterComponent(component); // Raise event if (raiseEvent) { RaiseOnComponentRemovedEvent(component); } TypePoolManager.Recycle(component); } }
void UnregisterComponentFromMessageGroups(IComponentOld component) { if (component is IMessageable) { messageables.Remove((IMessageable)component); } var messageEnumerator = messageGroups.GetEnumerator(); while (messageEnumerator.MoveNext()) { messageEnumerator.Current.Value.Remove(component); } messageEnumerator.Dispose(); }
void RegisterComponentToMessageGroups(IComponentOld component) { if (component is IMessageable) { messageables.Add((IMessageable)component); } if (messageGroups.Count > 0) { var enumerator = messageGroups.GetEnumerator(); while (enumerator.MoveNext()) { enumerator.Current.Value.TryAdd(component); } enumerator.Dispose(); } }
void UnregisterComponentFromUpdateCallbacks(IComponentOld component) { var startable = component as IStartable; if (startable != null) { startables.Remove(startable); } var updateable = component as IUpdateable; if (updateable != null) { int index = updateables.IndexOf(updateable); if (index >= 0) { updateables.RemoveAt(index); updateCounters.RemoveAt(index); } } var lateUpdateable = component as ILateUpdateable; if (lateUpdateable != null) { int index = lateUpdateables.IndexOf(lateUpdateable); if (index >= 0) { lateUpdateables.RemoveAt(index); lateUpdateCounters.RemoveAt(index); } } var fixedUpdateable = component as IFixedUpdateable; if (fixedUpdateable != null) { fixedUpdateables.Remove(fixedUpdateable); } }
ErrorData(ComponentCategory category, IComponentOld component, ErrorTypes errorType) { Category = category; Component = component; ErrorType = errorType; }
public ErrorData(ComponentCategory category, IComponentOld component, ErrorTypes errorType, Type missingComponentType) : this(category, component, errorType) { MissingComponentType = missingComponentType; }
void OnPreComponent(SerializedProperty arrayProperty, int index, SerializedProperty property) { currentComponent = currentCategory.Components[index]; BeginBox(); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var rect = EditorGUILayout.BeginVertical(); rect.x += rect.width - 34f; rect.width = 16f; rect.height = 16f; if (currentComponent is IUpdateable) ((IUpdateable)currentComponent).Active = GUI.Toggle(rect, ((IUpdateable)currentComponent).Active, ""); else if (currentComponent is IFixedUpdateable) ((IFixedUpdateable)currentComponent).Active = GUI.Toggle(rect, ((IFixedUpdateable)currentComponent).Active, ""); else if (currentComponent is ILateUpdateable) ((ILateUpdateable)currentComponent).Active = GUI.Toggle(rect, ((ILateUpdateable)currentComponent).Active, ""); ShowComponentErrors(rect); EditorGUI.indentLevel = indent; }
public void RemoveComponent(IComponentOld component) { RemoveComponent(component, true); }
public void AddComponent(IComponentOld component) { AddComponent(component, true); }
public void AddComponent(IComponentOld component, int index) { Components.Add(component); ComponentIndices.Add(index); DummyValue.Add(component.GetTypeName()); }
void UnregisterComponentFromUpdateCallbacks(IComponentOld component) { var startable = component as IStartable; if (startable != null) startables.Remove(startable); var updateable = component as IUpdateable; if (updateable != null) { int index = updateables.IndexOf(updateable); if (index >= 0) { updateables.RemoveAt(index); updateCounters.RemoveAt(index); } } var lateUpdateable = component as ILateUpdateable; if (lateUpdateable != null) { int index = lateUpdateables.IndexOf(lateUpdateable); if (index >= 0) { lateUpdateables.RemoveAt(index); lateUpdateCounters.RemoveAt(index); } } var fixedUpdateable = component as IFixedUpdateable; if (fixedUpdateable != null) fixedUpdateables.Remove(fixedUpdateable); }
void RegisterComponentToUpdateCallbacks(IComponentOld component) { var startable = component as IStartable; if (startable != null) startables.Add(startable); var updateable = component as IUpdateable; if (updateable != null && !updateables.Contains(updateable)) { updateables.Add(updateable); updateCounters.Add(0f); } var lateUpdateable = component as ILateUpdateable; if (lateUpdateable != null && !lateUpdateables.Contains(lateUpdateable)) { lateUpdateables.Add(lateUpdateable); lateUpdateCounters.Add(0f); } var fixedUpdateable = component as IFixedUpdateable; if (fixedUpdateable != null && !fixedUpdateables.Contains(fixedUpdateable)) fixedUpdateables.Add(fixedUpdateable); }
public bool HasComponent(IComponentOld component) { return(allComponents.Contains(component)); }