コード例 #1
0
        internal void Remove <C>(Entity.Id id) where C : class, IComponent, new()
        {
            int entityId = (int)id.Index;
            int family   = ComponentIndexer.GetFamily <C>();

            ComponentMask mask = m_EntityComponentMasks[entityId];

            mask[1 << family] = false;
            m_EntityComponentMasks[entityId] = mask;

            ComponentPool <C> pool = (ComponentPool <C>)m_ComponentPools[family];

            pool.Destroy(entityId);
        }
コード例 #2
0
        internal C Assign <C>(Entity.Id id, C c) where C : class, IComponent, new()
        {
            AssertValidID(id);
            int           family   = ComponentIndexer.GetFamily <C>();
            int           entityId = (int)id.Index;
            ComponentMask mask     = m_EntityComponentMasks[entityId];

            Debug.Assert(!mask[1 << family]);

            ComponentPool <C> pool = AccommodateComponent <C>();

            pool.Put(c, entityId);

            mask[1 << family] = true;
            m_EntityComponentMasks[entityId] = mask;

            return(c);
        }