public virtual void Shutdown() { if (SystemDic != null) { SystemDic.Clear(); SystemDic = null; } if (SingletonComponentDic != null) { SingletonComponentDic.Clear(); SingletonComponentDic = null; } if (ComponentDic != null) { ComponentDic.Clear(); ComponentDic = null; } if (EntityDic != null) { foreach (var v in EntityDic) { if (v.Value != null) { v.Value.Dispose(); } } EntityDic.Clear(); EntityDic = null; } }
public T GetSingletonEntityComponent <T>() where T : ComponentBase { ComponentBase comp = null; if (SingletonComponentDic.TryGetValue(typeof(T), out comp)) { return(comp as T); } return(null); }
public T CreateSingletonComponent <T>() where T : ComponentBase, new() { ComponentBase singleton; if (!SingletonComponentDic.TryGetValue(typeof(T), out singleton)) { singleton = new T(); SingletonComponentDic[typeof(T)] = singleton; } return(singleton as T); }