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); }
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; }
/// <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); } }
/// <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)); }