示例#1
0
文件: IECS.cs 项目: TableBreaker/NECS
    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;
        }
    }
示例#2
0
文件: IECS.cs 项目: TableBreaker/NECS
    public T GetSingletonEntityComponent <T>() where T : ComponentBase
    {
        ComponentBase comp = null;

        if (SingletonComponentDic.TryGetValue(typeof(T), out comp))
        {
            return(comp as T);
        }

        return(null);
    }
示例#3
0
文件: IECS.cs 项目: TableBreaker/NECS
    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);
    }