Esempio n. 1
0
    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;
        }
    }
Esempio n. 2
0
    public HashSet <T> AllEntityComponents <T>() where T : ComponentBase
    {
        HashSet <ComponentBase> coll = null;

        if (ComponentDic.TryGetValue(typeof(T), out coll))
        {
            return(new HashSet <T>(coll.Cast <T>()));
        }

        return(null);
    }
Esempio n. 3
0
    public T AnyEntityComponent <T>() where T : ComponentBase
    {
        HashSet <ComponentBase> coll = null;

        if (ComponentDic.TryGetValue(typeof(T), out coll))
        {
            return(coll.First() as T);
        }

        return(null);
    }
Esempio n. 4
0
    public void OnEntityAddComponent(ComponentBase component)
    {
        if (component == null)
        {
            return;
        }

        HashSet <ComponentBase> coll = null;

        if (ComponentDic.TryGetValue(component.GetType(), out coll))
        {
            coll.Add(component);
        }
        else
        {
            coll = new HashSet <ComponentBase> {
                component
            };
            ComponentDic[component.GetType()] = coll;
        }
    }
Esempio n. 5
0
    public void OnEntityRemoveComponent(ComponentBase component)
    {
        if (!component)
        {
            return;
        }

        HashSet <ComponentBase> coll = null;

        if (ComponentDic.TryGetValue(component.GetType(), out coll))
        {
            try
            {
                coll.Remove(component);
            }
            catch (System.Exception e)
            {
                Debug.LogError(e);
            }
        }
    }