Exemplo n.º 1
0
        public int AddEntity(Entity entity, EntityTypeData movedFrom)
        {
            var index = count;

            entityArray.SetAt(index, entity);
            for (var i = 0; i < componentTypeIndices.Length; i++)
            {
                componentArrays[componentTypeIndices[i]].SetDefault(index);
            }
            count += 1;

            if (addedListeners.Count > 0)
            {
                try
                {
                    for (int i = 0; i < addedListeners.Count; i++)
                    {
                        addedListeners[i].OnEntityAdded(entityArray[index], movedFrom);
                    }
                }
                catch
                {
                    //
                }
            }
            return(index);
        }
Exemplo n.º 2
0
 public (int entityId, int newIndexInChunk) RemoveEntity(int index, EntityTypeData movingTo)
 {
     --count;
     if (removingListeners.Count > 0)
     {
         try
         {
             for (int i = 0; i < removingListeners.Count; i++)
             {
                 removingListeners[i].OnEntityRemoving(entityArray[index], movingTo);
             }
         }
         catch
         {
             //
         }
     }
     entityArray.UnorderedRemoveAt(index);
     for (var i = 0; i < componentTypeIndices.Length; i++)
     {
         componentArrays[componentTypeIndices[i]].UnorderedRemoveAt(index);
     }
     return(index != count ? entityArray[index].Id : -1, index);
 }