Exemple #1
0
        private void OnComponentRemoving(Component cmp)
        {
            // Notify Components
            ICmpInitializable cmpInit = cmp as ICmpInitializable;

            if (cmpInit != null)
            {
                cmpInit.OnShutdown(Component.ShutdownContext.RemovingFromGameObject);
            }
            foreach (Component c in this.compList)
            {
                if (!c.Active || c == cmp)
                {
                    continue;
                }
                ICmpComponentListener cTemp = c as ICmpComponentListener;
                if (cTemp != null)
                {
                    cTemp.OnComponentRemoving(cmp);
                }
            }

            // Public event
            if (this.eventComponentRemoving != null)
            {
                this.eventComponentRemoving(this, new ComponentEventArgs(cmp));
            }
        }
Exemple #2
0
        /// <summary>
        /// Gathers a list of components that would be affected if this <see cref="GameObject"/>
        /// changed its activation state. This excludes components and child objects that
        /// are inactive in their own right.
        /// </summary>
        /// <param name="initList"></param>
        /// <param name="deep"></param>
        internal void GatherInitComponents(List <ICmpInitializable> initList, bool deep)
        {
            for (int i = 0; i < this.compList.Count; i++)
            {
                Component         component = this.compList[i];
                ICmpInitializable init      = component as ICmpInitializable;

                if (init == null)
                {
                    continue;
                }
                if (!component.ActiveSingle)
                {
                    continue;
                }

                initList.Add(init);
            }

            if (deep && this.children != null)
            {
                for (int i = 0; i < this.children.Count; i++)
                {
                    GameObject child = this.children[i];
                    if (!child.ActiveSingle && !child.Disposed)
                    {
                        continue;
                    }
                    child.GatherInitComponents(initList, deep);
                }
            }
        }
Exemple #3
0
        private void OnComponentAdded(Component cmp)
        {
            // Notify Components
            ICmpInitializable cmpInit = cmp as ICmpInitializable;

            if (cmpInit != null)
            {
                cmpInit.OnInit(Component.InitContext.AddToGameObject);
            }
            foreach (Component c in this.compList)
            {
                if (!c.Active || c == cmp)
                {
                    continue;
                }
                ICmpComponentListener cTemp = c as ICmpComponentListener;
                if (cTemp != null)
                {
                    cTemp.OnComponentAdded(cmp);
                }
            }

            // Public event
            if (this.eventComponentAdded != null)
            {
                this.eventComponentAdded(this, new ComponentEventArgs(cmp));
            }
        }
Exemple #4
0
 private static void OnComponentRemoving(ComponentEventArgs args)
 {
     if (args.Component.Active)
     {
         ICmpInitializable cInit = args.Component as ICmpInitializable;
         if (cInit != null)
         {
             cInit.OnShutdown(Component.ShutdownContext.Deactivate);
         }
     }
     ComponentRemoving?.Invoke(current, args);
 }
Exemple #5
0
 private static void OnComponentAdded(ComponentEventArgs args)
 {
     if (args.Component.Active)
     {
         ICmpInitializable cInit = args.Component as ICmpInitializable;
         if (cInit != null)
         {
             cInit.OnInit(Component.InitContext.Activate);
         }
     }
     ComponentAdded?.Invoke(current, args);
 }
Exemple #6
0
        private void OnComponentRemoving(Component cmp)
        {
            // Notify Components
            ICmpInitializable cmpInit = cmp as ICmpInitializable;

            if (cmpInit != null)
            {
                cmpInit.OnShutdown(Component.ShutdownContext.RemovingFromGameObject);
            }

            // Public event
            this.eventComponentRemoving?.Invoke(this, new ComponentEventArgs(cmp));
        }
Exemple #7
0
        private void OnComponentAdded(Component cmp)
        {
            // Notify Components
            ICmpInitializable cmpInit = cmp as ICmpInitializable;

            if (cmpInit != null)
            {
                cmpInit.OnInit(Component.InitContext.AddToGameObject);
            }

            // Public event
            this.eventComponentAdded?.Invoke(this, new ComponentEventArgs(cmp));
        }
Exemple #8
0
 private static void OnComponentRemoving(ComponentEventArgs args)
 {
     if (args.Component.Active)
     {
         ICmpInitializable cInit = args.Component as ICmpInitializable;
         if (cInit != null)
         {
             cInit.OnDeactivate();
         }
     }
     if (ComponentRemoving != null)
     {
         ComponentRemoving(current, args);
     }
 }
Exemple #9
0
 internal void OnDeactivate()
 {
     // Notify Components
     foreach (Component c in this.compList)
     {
         if (!c.ActiveSingle)
         {
             continue;
         }
         ICmpInitializable cInit = c as ICmpInitializable;
         if (cInit != null)
         {
             cInit.OnShutdown(Component.ShutdownContext.Deactivate);
         }
     }
 }
Exemple #10
0
        internal void OnSaved(bool deep = false)
        {
            // Notify Components
            foreach (Component c in this.compList)
            {
                ICmpInitializable cInit = c as ICmpInitializable;
                if (cInit != null)
                {
                    cInit.OnInit(Component.InitContext.Saved);
                }
            }

            if (deep && this.children != null)
            {
                foreach (GameObject c in this.children)
                {
                    c.OnSaved(deep);
                }
            }
        }
Exemple #11
0
        private void objectManager_ComponentRemoving(object sender, ComponentEventArgs e)
        {
            this.RemoveFromManagers(e.Component);

            // If the scene is active, deactivate any removed components
            if (this.active && e.Component.Active)
            {
                ICmpInitializable cInit = e.Component as ICmpInitializable;
                if (cInit != null)
                {
                    cInit.OnDeactivate();
                }
            }

            // Fire global event for current main scene
            if (this.IsCurrent && ComponentRemoving != null)
            {
                ComponentRemoving(current, e);
            }
        }
Exemple #12
0
        private void objectManager_ComponentAdded(object sender, ComponentEventArgs e)
        {
            this.AddToManagers(e.Component);

            // If the scene is active, activate any added components
            if (this.active && e.Component.Active)
            {
                ICmpInitializable cInit = e.Component as ICmpInitializable;
                if (cInit != null)
                {
                    cInit.OnActivate();
                }
            }

            // Fire global event for current main scene
            if (this.IsCurrent && ComponentAdded != null)
            {
                ComponentAdded(current, e);
            }
        }