コード例 #1
0
ファイル: Region.cs プロジェクト: BlackCoyote/Voxalia
 /// <summary>
 /// Spawns an entity in the world.
 /// </summary>
 /// <param name="e">The entity to spawn.</param>
 public void SpawnEntity(Entity e)
 {
     Entities.Add(e);
     if (e.Ticks)
     {
         Tickers.Add(e);
     }
     if (e.CastShadows)
     {
         ShadowCasters.Add(e);
     }
     if (e is PhysicsEntity)
     {
         PhysicsEntity pe = e as PhysicsEntity;
         pe.SpawnBody();
         if (pe.GenBlockShadows)
         {
             // TODO: Effic?
             PhysicsEntity[] neo = new PhysicsEntity[GenShadowCasters.Length + 1];
             Array.Copy(GenShadowCasters, neo, GenShadowCasters.Length);
             neo[neo.Length - 1] = pe;
             GenShadowCasters    = neo;
             Chunk ch = TheClient.TheRegion.GetChunk(TheClient.TheRegion.ChunkLocFor(e.GetPosition()));
             if (ch != null)
             {
                 ch.CreateVBO(); // TODO: nearby / all affected chunks!
             }
         }
     }
     else if (e is PrimitiveEntity)
     {
         ((PrimitiveEntity)e).Spawn();
     }
 }