Esempio n. 1
0
 /// <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();
     }
 }
Esempio n. 2
0
 public void EasyUpdateChunk(Chunk ch)
 {
     ch.AddToWorld();
     if (!ch.CreateVBO())
     {
         return;
     }
 }
Esempio n. 3
0
 public void LightForChunks(Chunk ch, Chunk above)
 {
     ch.CalcSkyLight(above);
     TheClient.Schedule.ScheduleSyncTask(() =>
     {
         CalcingLights.Remove(ch.WorldPosition);
         ch.AddToWorld();
         ch.CreateVBO();
     });
 }
Esempio n. 4
0
 public void LightForChunks(Chunk ch, Chunk above)
 {
     // TODO: Prevent double-skylight-recalc
     ch.CalcSkyLight(above);
     TheClient.Schedule.ScheduleSyncTask(() =>
     {
         ch.AddToWorld();
         ch.CreateVBO();
         Chunk below = GetChunk(ch.WorldPosition + new Vector3i(0, 0, -1));
         if (below != null)
         {
             TheClient.Schedule.StartASyncTask(() =>
             {
                 LightForChunks(below, ch);
             });
         }
     });
 }
Esempio n. 5
0
 public void LightForChunks(Chunk ch, Chunk above)
 {
     ch.CalcSkyLight(above);
     TheClient.Schedule.ScheduleSyncTask(() =>
     {
         ch.AddToWorld();
         if (!ch.CreateVBO())
         {
             return;
         }
         Chunk below = GetChunk(ch.WorldPosition + new Vector3i(0, 0, -1));
         if (below != null)
         {
             TheClient.Schedule.StartAsyncTask(() =>
             {
                 LightForChunks(below, ch);
             });
         }
     });
 }
Esempio n. 6
0
 public void LightForChunks(Chunk ch, Chunk above)
 {
     // TODO: Prevent double-skylight-recalc
     ch.CalcSkyLight(above);
     TheClient.Schedule.ScheduleSyncTask(() =>
     {
         ch.AddToWorld();
         ch.CreateVBO();
         Chunk below = GetChunk(ch.WorldPosition + new Vector3i(0, 0, -1));
         if (below != null)
         {
             TheClient.Schedule.StartASyncTask(() =>
             {
                 LightForChunks(below, ch);
             });
         }
     });
 }