Esempio n. 1
0
        public Entity CreateFromCopy(Entity original)
        {
            Debug.Assert((bool)original);
            Entity        clone = Create();
            ComponentMask mask  = original.ComponentMask();

            for (int i = 0; i < m_ComponentHelpers.Count; i++)
            {
                BaseComponentHelper helper = m_ComponentHelpers[i];
                if (helper != null && mask[i])
                {
                    helper.CopyComponentTo(original, clone);
                }
            }
            return(clone);
        }
Esempio n. 2
0
        public void Destroy(Entity.Id entity)
        {
            AssertValidID(entity);
            int           index = (int)entity.Index;
            ComponentMask mask  = m_EntityComponentMasks[index];

            for (int i = 0; i < m_ComponentHelpers.Count; i++)
            {
                BaseComponentHelper helper = m_ComponentHelpers[i];
                if (helper != null && mask[i])
                {
                    helper.RemoveComponent(new Entity(this, entity));
                }
            }
            m_EntityComponentMasks[index].Reset();
            m_EntityVersions[index]++;
            m_FreeList.Add((uint)index);
        }