コード例 #1
0
 void UnregisterComponent(IComponentOld component)
 {
     component.Entity = null;
     UnregisterComponentFromGroups(component);
     UnregisterComponentFromMessageGroups(component);
     UnregisterComponentFromUpdateCallbacks(component);
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 public void TryAddComponent(IComponentOld component)
 {
     if (type.IsAssignableFrom(component.GetType()))
     {
         AddComponent(component);
     }
 }
コード例 #4
0
 public void RemoveComponent(IComponentOld component)
 {
     if (components.Remove(component))
     {
         genericComponents.Remove(component);
     }
 }
コード例 #5
0
 void RegisterComponent(IComponentOld component)
 {
     component.Entity = this;
     RegisterComponentToGroups(component);
     RegisterComponentToMessageGroups(component);
     RegisterComponentToUpdateCallbacks(component);
 }
コード例 #6
0
        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;
        }
コード例 #7
0
 void AddComponent(IComponentOld component)
 {
     if (!components.Contains(component))
     {
         components.Add(component);
         genericComponents.Add(component);
     }
 }
コード例 #8
0
        protected virtual void RaiseOnComponentRemovedEvent(IComponentOld component)
        {
            if (OnComponentRemoved != null)
            {
                OnComponentRemoved(this, component);
            }

            EntityManagerOld.UpdateEntity(this);
        }
コード例 #9
0
        void AddComponent(IComponentOld component, bool raiseEvent)
        {
            allComponents.Add(component);
            RegisterComponent(component);

            // Raise event
            if (raiseEvent)
            {
                RaiseOnComponentAddedEvent(component);
            }
        }
コード例 #10
0
        void UnregisterComponentFromGroups(IComponentOld component)
        {
            if (componentGroups.Count > 0)
            {
                var enumerator = componentGroups.GetEnumerator();

                while (enumerator.MoveNext())
                    enumerator.Current.Value.RemoveComponent(component);

                enumerator.Dispose();
            }
        }
コード例 #11
0
        void RegisterComponentToGroups(IComponentOld component)
        {
            if (componentGroups.Count > 0)
            {
                var enumerator = componentGroups.GetEnumerator();

                while (enumerator.MoveNext())
                    enumerator.Current.Value.TryAddComponent(component);

                enumerator.Dispose();
            }
        }
コード例 #12
0
        void RegisterComponentToGroups(IComponentOld component)
        {
            if (componentGroups.Count > 0)
            {
                var enumerator = componentGroups.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    enumerator.Current.Value.TryAddComponent(component);
                }

                enumerator.Dispose();
            }
        }
コード例 #13
0
        void UnregisterComponentFromGroups(IComponentOld component)
        {
            if (componentGroups.Count > 0)
            {
                var enumerator = componentGroups.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    enumerator.Current.Value.RemoveComponent(component);
                }

                enumerator.Dispose();
            }
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        void RemoveComponent(IComponentOld component, bool raiseEvent)
        {
            if (allComponents.Remove(component))
            {
                UnregisterComponent(component);

                // Raise event
                if (raiseEvent)
                {
                    RaiseOnComponentRemovedEvent(component);
                }

                TypePoolManager.Recycle(component);
            }
        }
コード例 #16
0
        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();
        }
コード例 #17
0
        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();
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
 ErrorData(ComponentCategory category, IComponentOld component, ErrorTypes errorType)
 {
     Category = category;
     Component = component;
     ErrorType = errorType;
 }
コード例 #20
0
 public ErrorData(ComponentCategory category, IComponentOld component, ErrorTypes errorType, Type missingComponentType) : this(category, component, errorType)
 {
     MissingComponentType = missingComponentType;
 }
コード例 #21
0
 ErrorData(ComponentCategory category, IComponentOld component, ErrorTypes errorType)
 {
     Category  = category;
     Component = component;
     ErrorType = errorType;
 }
コード例 #22
0
        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;
        }
コード例 #23
0
 public void RemoveComponent(IComponentOld component)
 {
     RemoveComponent(component, true);
 }
コード例 #24
0
 public void AddComponent(IComponentOld component)
 {
     AddComponent(component, true);
 }
コード例 #25
0
 public void AddComponent(IComponentOld component, int index)
 {
     Components.Add(component);
     ComponentIndices.Add(index);
     DummyValue.Add(component.GetTypeName());
 }
コード例 #26
0
 public ErrorData(ComponentCategory category, IComponentOld component, ErrorTypes errorType, Type missingComponentType)
     : this(category, component, errorType)
 {
     MissingComponentType = missingComponentType;
 }
コード例 #27
0
 public void AddComponent(IComponentOld component, int index)
 {
     Components.Add(component);
     ComponentIndices.Add(index);
     DummyValue.Add(component.GetTypeName());
 }
コード例 #28
0
        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);
        }
コード例 #29
0
        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);
        }
コード例 #30
0
 public bool HasComponent(IComponentOld component)
 {
     return(allComponents.Contains(component));
 }