Пример #1
0
 public void AddActiveComponent(EntityComponent component)
 {
     activeComponents.Add(component);
     isActiveComponentChanged = true;
 }
Пример #2
0
 public void RemoveActiveComponent(EntityComponent component)
 {
     activeComponents.Remove(component);
     isActiveComponentChanged = true;
 }
Пример #3
0
        private bool RefreshActiveHierarchy()
        {
            bool localActiveHierarchy = activeHierarchy;

            if (activeSelf)
            {
                if (HasParent())
                {
                    if (parent.activeHierarchy == true)
                    {
                        localActiveHierarchy = true;
                    }
                    else
                    {
                        localActiveHierarchy = false;
                    }
                }
                else
                {
                    localActiveHierarchy = true;
                }
            }
            else
            {
                localActiveHierarchy = false;
            }

            if (localActiveHierarchy != activeHierarchy)
            {
                activeHierarchy = localActiveHierarchy;

                if (this.parent != null)
                {
                    if (localActiveHierarchy)
                    {
                        this.parent.AddActivedChild(this);
                        if (!IsStarted)
                        {
                            this.parent.AddWaitStart(this);
                        }
                    }
                    else
                    {
                        this.parent.RemoveActivedChild(this);
                    }
                }

                List <EntityComponent> subComponents = new List <EntityComponent>(this.components);
                for (int i = 0; i < subComponents.Count; ++i)
                {
                    EntityComponent component = subComponents[i];
                    if (component != null)
                    {
                        //递归调用可能的OnEnable
                        component.RefreshActiveHierarchy();
                    }
                }

                return(true);
            }
            return(false);
        }