Example #1
0
        void OnPlaceWater(int index, BlockRaw b)
        {
            int x = index % width;
            int y = index / oneY;             // posIndex / (width * length)
            int z = (index / width) % length;

            //int nextWaterTick = (int)(Math.Ceiling((double)physics.tickCount / 5.0) * 5.0);
            //int nextWaterTick = ((physics.tickCount - 1) / 5 + 1) * 5;
            //int nextWaterTick = ((physics.tickCount + 5 - 1) / 5) * 5;
            if (!nextWaterTick.HasValue)
            {
                if (physics.tickCount % 5 == 0)
                {
                    nextWaterTick = physics.tickCount + 5;
                }
                else
                {
                    nextWaterTick = (5 - physics.tickCount % 5) + physics.tickCount;
                }
            }
            //if (nextWaterTick == physics.tickCount)
            //	nextWaterTick += 5;
            PhysicsTick newTick = new PhysicsTick(new Vector3I(x, y, z), b, (int)nextWaterTick);

            physics.tickList2.Add(newTick);
        }
Example #2
0
        //void OnPlaceLava(int index, BlockRaw b) { Lava.Enqueue(defLavaTick | (uint)index); }
        //void OnPlaceWater(int index, BlockRaw b) { Water.Enqueue(defWaterTick | (uint)index); }
        void OnPlaceLava(int index, BlockRaw b)
        {
            int x = index % width;
            int y = index / oneY;             // posIndex / (width * length)
            int z = (index / width) % length;
            //int nextLavaTick = (int)(Math.Ceiling((double)physics.tickCount / 30.0) * 30.0);
            int nextLavaTick = ((physics.tickCount - 1) / 30 + 1) * 30;

            if (nextLavaTick == physics.tickCount)
            {
                nextLavaTick += 30;
            }
            PhysicsTick newTick = new PhysicsTick(new Vector3I(x, y, z), b, nextLavaTick);

            physics.tickList2.Add(newTick);
        }
Example #3
0
        public void Tick()
        {
            if (!Enabled || game.World.blocks1 == null)
            {
                return;
            }
            liquid.nextWaterTick = null;
            liquid.nextLavaTick  = null;

            PhysicsTickComparer TickComparer = new PhysicsTickComparer();

            /*foreach (PhysicsTick i in tickList2) {
             *      PhysicsTick tick = (PhysicsTick)i;
             *      tickList.Add(tick);
             * }*/
            tickList.AddRange(tickList2);
            tickList2.Clear();
            tickList.Sort(TickComparer);


            foreach (PhysicsTick i in tickList)
            {
                PhysicsTick tick   = (PhysicsTick)i;
                bool        doTick = true;
                if (tick.TickTime > tickCount)
                {
                    doTick = false;
                }
                if (!doTick)
                {
                    break;
                }
                int index = (tick.Position.Y * length + tick.Position.Z) * width + tick.Position.X;
                if (tick.BlockRaw == Block.Lava || tick.BlockRaw == Block.StillLava)
                {
                    liquid.ActivateLava(index, tick.BlockRaw);
                }
                else if (tick.BlockRaw == Block.Water || tick.BlockRaw == Block.StillWater)
                {
                    liquid.ActivateWater(index, tick.BlockRaw);
                }
            }

            tickList.RemoveAll(TickIsDone);

            tickList.AddRange(tickList2);
            tickList2.Clear();
            tickList.Sort(TickComparer);

            if (tickList.Count == 0 && tickList2.Count == 0)
            {
                tickList  = new List <PhysicsTick>();
                tickList2 = new List <PhysicsTick>();
            }

            /*foreach (PhysicsTick i in tickList2) {
             *      PhysicsTick tick = (PhysicsTick)i;
             *      tickList.Add(tick);
             * }
             * tickList2.Clear();
             * tickList.Sort(TickComparer);*/

            TickRandomBlocks();
            tickCount++;
            liquid.nextWaterTick = null;
            liquid.nextLavaTick  = null;
        }
Example #4
0
 private bool TickIsDone(PhysicsTick tick)
 {
     return(tick.TickTime <= this.tickCount);
 }