Exemplo n.º 1
0
        internal C Component <C>(Entity.Id id) where C : class, IComponent, new()
        {
            AssertValidID(id);
            int family = ComponentIndexer.GetFamily <C>();

            if (family >= m_ComponentPools.Count)
            {
                return(default(C));
            }
            BaseComponentPool pool = m_ComponentPools[family];

            if (pool == null || !m_EntityComponentMasks[(int)id.Index][1 << family])
            {
                return(default(C));
            }
            return(((ComponentPool <C>)pool).Get((int)id.Index));
        }
Exemplo n.º 2
0
        internal bool HasComponent <C>(Entity.Id id)
        {
            AssertValidID(id);
            int family = ComponentIndexer.GetFamily <C>();

            // We don't bother checking the component mask, as we return a nullptr anyway.
            if (family >= m_ComponentPools.Count)
            {
                return(false);
            }
            BaseComponentPool pool = m_ComponentPools[family];

            if (pool == null || !m_EntityComponentMasks[(int)id.Index][family])
            {
                return(false);
            }
            return(true);
        }