Example #1
0
        public void Update()
        {
            randomUpdateTime += Time.deltaTime;
            if (randomUpdateTime >= chunk.world.config.randomUpdateFrequency)
            {
                randomUpdateTime = 0;

                Vector3Int randomVector3Int = new Vector3Int(
                    Voxelmetric.resources.random.Next(0, Env.ChunkSize),
                    Voxelmetric.resources.random.Next(0, Env.ChunkSize),
                    Voxelmetric.resources.random.Next(0, Env.ChunkSize)
                    );

                chunk.blocks.GetBlock(randomVector3Int).RandomUpdate(chunk, randomVector3Int);

                // Process Scheduled Updates
                for (int i = 0; i < scheduledUpdates.Count; i++)
                {
                    scheduledUpdates[i] = new BlockAndTimer(
                        scheduledUpdates[i].pos,
                        scheduledUpdates[i].time - chunk.world.config.randomUpdateFrequency
                        );

                    if (scheduledUpdates[i].time <= 0)
                    {
                        Block block = chunk.blocks.GetBlock(scheduledUpdates[i].pos);
                        block.ScheduledUpdate(chunk, scheduledUpdates[i].pos);
                        scheduledUpdates.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
Example #2
0
 void ProcessScheduledUpdates()
 {
     for (int i = 0; i < scheduledUpdates.Count; i++)
     {
         scheduledUpdates[i] = new BlockAndTimer(scheduledUpdates[i].pos, scheduledUpdates[i].time - Config.Env.UpdateFrequency);
         if (scheduledUpdates[i].time <= 0)
         {
             Block block = GetBlock(scheduledUpdates[i].pos);
             block.controller.ScheduledUpdate(this, scheduledUpdates[i].pos, block);
             scheduledUpdates.RemoveAt(i);
             i--;
         }
     }
 }