Exemple #1
0
 public virtual void RemoveComponent(BaseMgr component)
 {
     if (component != null)
     {
         component.OnBeRemoved();
         if (component is IOnAnimTrigger)
         {
             triggersComponets.Remove(component as IOnAnimTrigger);
         }
         if (component.NeedUpdate)
         {
             updateComponets.Remove(component);
         }
         if (component.NeedLateUpdate)
         {
             lateUpdateComponets.Remove(component);
         }
         if (component.NeedFixedUpdate)
         {
             fixedUpdateComponets.Remove(component);
         }
         if (component.NeedGUI)
         {
             guiComponets.Remove(component);
         }
         componets.Remove(component);
     }
 }
Exemple #2
0
        //检测组件和Mono是否有冲突
        public static bool IsFit(BaseCoreMono main, BaseMgr com)
        {
            if (main.MonoType == MonoType.None ||
                main.MonoType == MonoType.Normal)
            {
                return(false);
            }

            if (com.MgrType == MgrType.All)
            {
                return(true);
            }

            if (main.MonoType == MonoType.Global ||
                main.MonoType == MonoType.View)
            {
                if (com.MgrType == MgrType.Global)
                {
                    return(true);
                }
                return(false);
            }

            if (main.MonoType == MonoType.Unit)
            {
                if (com.MgrType == MgrType.Unit)
                {
                    return(true);
                }
                return(false);
            }

            return(false);
        }
Exemple #3
0
 // 组建被关联到伏组件的时候
 protected virtual void OnBeAttachedToParentComponet(BaseMgr parentComponet)
 {
     if (parentComponet.SelfMono != null)
     {
         OnBeAdded(parentComponet.SelfMono);
     }
 }
Exemple #4
0
 //检测组件和子组件是否有冲突
 public static bool IsFit(BaseMgr main, BaseMgr sub)
 {
     if (main.MgrType == MgrType.All || sub.MgrType == MgrType.All)
     {
         return(true);
     }
     return(main.MgrType == sub.MgrType);
 }
Exemple #5
0
        public T AddSubComponent <T>() where T : BaseMgr, new()
        {
            BaseMgr component = Create <T>();

            if (!Util.IsFit(this, component))
            {
                CLog.Error("AddSubComponent {0},{1}:{2}", ToString(), component.ToString(), "组件类型不一致");
            }
            subComponets.Add(component);
            component.IsSubComponent    = true;
            component.parentComponet    = this;
            component.NeedGameLogicTurn = true;
            component.OnBeAttachedToParentComponet(this);
            return((T)component);
        }
Exemple #6
0
        public virtual T AddComponent <T>() where T : BaseMgr, new()
        {
            var component = BaseMgr.Create <T>();

            if (!Util.IsFit(this, component))
            {
                CLog.Error("AddComponent=>{0},{1}:{2}", GOName, component.ToString(), "组件类型不一致");
            }
            componets.Add(component);
            if (component is IOnAnimTrigger)
            {
                triggersComponets.Add(component as IOnAnimTrigger);
            }
            if (component.NeedUpdate)
            {
                updateComponets.Add(component);
            }
            if (component.NeedLateUpdate)
            {
                lateUpdateComponets.Add(component);
            }
            if (component.NeedFixedUpdate)
            {
                fixedUpdateComponets.Add(component);
            }
            if (component.NeedGUI)
            {
                guiComponets.Add(component);
            }
            if (component.NeedGameLogicTurn)
            {
                needGameLogicTurnComponets.Add(component);
            }
            component.OnBeAdded(this);
            return(component);
        }