Ejemplo n.º 1
0
 public T Transition <T>(ISCModule data) where T : class
 {
     if ((data as T) == null)
     {
         throw new ArgumentException(String.Format("Invalid type: {0} passed to event expecting {1}", data.GetType(), typeof(T)));
     }
     return(data as T);
 }
Ejemplo n.º 2
0
        public void RemoveModule(ISCModule Module)
        {
            if (Module == null)
            {
                return;
            }

            DebugMy.Log("[HashCode: " + GetHashCode() + "] " + "Module '" + Module.GetType() + "' [HashCode: " + Module.GetHashCode() + "] Remove From Module '" + GetType(), this);
            lock (subModuleList) {
                subModuleList.Remove(Module);
            }

            Module.ModuleDestroy();
            Module.FatherModule = null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ModuleDestroy ===================================
        /// </summary>



        public void AddModule(ISCModule Module, bool isEffectGameObject = true, SCModulePriority priority = SCModulePriority.Middle)
        {
            if (Module == null)
            {
                return;
            }

            Module.FatherModule = this;
            Module.ModuleInit(isEffectGameObject, priority);

            DebugMy.Log("[HashCode: " + GetHashCode() + "] " + "Module '" + Module.GetType() + "' [HashCode: " + Module.GetHashCode() + "] Add To Module '" + GetType(), this);
            lock (subModuleList) {
                subModuleList.Add(Module);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 返回直接父
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public virtual T GetFatherModule <T>() where T : ISCModule
        {
            ISCModule father = FatherModule;

            while (father != null)
            {
                if (father.ModuleName == typeof(T).ToString())
                {
                    DebugMy.Log("[HashCode: " + GetHashCode() + "] FatherModule" + father.ModuleName + " Found ", this);
                    return((T)father);
                }
                father = father.FatherModule;
            }
            DebugMy.Log("[HashCode: " + GetHashCode() + "] FatherModule" + typeof(T).ToString() + " Found ", this);
            return(default(T));
        }