コード例 #1
0
 public void Playback()
 {
     DebugHelper.AssertThrow <ThreadAccessException>(ECSWorld.CheckThreadIsMainThread());
     if (threadBuffersCache == null)
     {
         threadBuffersCache = threadBuffers.Values as List <EntityCommandBuffer>;
     }
     world.SyncPoint();
     foreach (EntityCommandBuffer buffer in threadBuffersCache)
     {
         buffer.Playback();
     }
 }
コード例 #2
0
 public Entity CreateEntity(EntityArchetype archetype = null)
 {
     DebugHelper.AssertThrow <ThreadAccessException>(ECSWorld.CheckThreadIsMainThread());
     world.SyncPoint();
     if (archetype == null)
     {
         archetype = EntityArchetype.Empty;
     }
     if (freeEntities.TryPop(out Entity result))
     {
         result = new Entity(result.id, result.version + 1);
         componentManager.AddEntity(result, archetype);
         new EntityCreatedEvent(result).Fire(world);
         return(result);
     }
     else
     {
         Entity e = new Entity(NextIndex(), 0);
         componentManager.AddEntity(e, archetype);
         new EntityCreatedEvent(e).Fire(world);
         return(e);
     }
 }