Beispiel #1
0
        // -------- -------- -------- -------- -------- -------- -------- -------- -------- /.
        // Methods
        // -------- -------- -------- -------- -------- -------- -------- -------- -------- /.
        public EntityGroup CreateGroup()
        {
            EntityGroup componentValue;

            // If we have some data left in the queue, dequeue it.
            if (m_PooledGroups.Count > 0)
            {
                componentValue = m_PooledGroups.Dequeue();
            }
            else
            {
                componentValue = new EntityGroup
                {
                    ReferenceId = m_Groups.Count
                }
            };

            componentValue.IsCreated = true;

            m_Groups[componentValue.ReferenceId] = componentValue;

            if (m_Groups.Count > m_MaxId)
            {
                m_MaxId = m_Groups.Count;
            }

            return(componentValue);
        }
Beispiel #2
0
        public void AttachTo(Entity entity, EntityGroup entityGroup)
        {
            if (!entityGroup.IsCreated)
            {
                throw new Exception($"The group({entityGroup.ReferenceId}, {entityGroup.Version}) doesn't exist anymore.");
            }

            entity.SetOrCreateComponentData(entityGroup);
        }