示例#1
0
        static void Sponge(Level level, int pos)
        {
            BlockPos blockPos = level.IntToPos(pos);

            for (int _x = -1; _x < 2; ++_x)
            {
                for (int _y = -1; _y < 2; ++_y)
                {
                    for (int _z = -1; _z < 2; ++_z)
                    {
                        BlockPos currentBlockPos = blockPos.diff(_x, _y, _z);
                        int currentPos = level.PosToInt(currentBlockPos);

                        if (level.NotInBounds(currentBlockPos)) continue;

                        Blocks type = (Blocks)level.blocks[currentPos];

                        if (type == Blocks.Water || type == Blocks.WaterStill || type == Blocks.Lava || type == Blocks.LavaStill)
                        {
                            level.PhysicsBlockChange(currentBlockPos, Blocks.Air);
                        }
                    }
                }
            }
        }
示例#2
0
        static void Water(Level level, int pos)
        {
            BlockPos blockPos = level.IntToPos(pos);
            BlockPos belowBlockPos = blockPos.diff(0, -1, 0);

            int belowPos = level.PosToInt(belowBlockPos);
            byte type = level.blocks[belowPos];

            if (type == (byte)Blocks.WaterStill)
            {
                level.physics.OtherData.Remove(belowPos);
                level.physics.OtherData.Add(belowPos, level.physics.waterCurrent);
            }
            else if (Block.crushable.Contains(type))
            {
                level.physics.OtherData.Remove(belowPos);
                level.physics.OtherData.Add(belowPos, level.physics.waterCurrent);
                level.PhysicsBlockChange(belowBlockPos, Blocks.WaterStill);
            }
            else
            {
                for (int _X = -1; _X < 2; ++_X)
                    for (int _Z = -1; _Z < 2; ++_Z)
                    {
                        if (Math.Abs(_X) == 1 && Math.Abs(_Z) == 1) continue;
                        if (blockPos.x + _X < 0 || blockPos.z + _Z < 0) continue;

                        BlockPos aroundPos = blockPos.diff(_X, 0, _Z);

                        if (level.NotInBounds(aroundPos)) continue;

                        int newPos = level.PosToInt(aroundPos);

                        if (level.blocks[newPos] == (byte)Blocks.WaterStill)
                        {
                            level.physics.OtherData.Remove(newPos);
                            level.physics.OtherData.Add(newPos, level.physics.waterCurrent);
                        }
                        else if (Block.crushable.Contains(level.blocks[newPos]))
                        {
                            level.physics.OtherData.Remove(newPos);
                            level.physics.OtherData.Add(newPos, level.physics.waterCurrent);
                            level.PhysicsBlockChange(aroundPos, Blocks.WaterStill);
                            //if (level.physics.PhysicsUpdates.Contains(level.PosToInt(aroundBelowPos))) return;
                            //level.physics.PhysicsUpdates.Add(level.PosToInt(aroundBelowPos));
                            return;
                        }
                        else
                        {
                            continue;
                        }
                    }
            }
        }
示例#3
0
        static void Sand(Level level, int pos)
        {
            BlockPos blockPos = level.IntToPos(pos);
            BlockPos belowBlockPos = blockPos.diff(0, -1, 0);

            Blocks below = level.GetTile(belowBlockPos);

            if (below == Blocks.Zero)
            {
                return;
            }
            else if (Block.crushable.Contains((byte)below))
            {
                level.PhysicsBlockChange(belowBlockPos, Blocks.Sand);
                level.PhysicsBlockChange(blockPos, Blocks.Air);
                //if(level.physics.PhysicsUpdates.Contains(level.PosToInt(belowPos))) return;
                //level.physics.PhysicsUpdates.Add(level.PosToInt(belowPos));
            }
            else if (level.physics.realistic)
            {
                for(int _X = -1;_X<2;++_X)
                    for (int _Z = -1; _Z < 2; ++_Z)
                    {
                        if (Math.Abs(_X) == 1 && Math.Abs(_Z) == 1) continue;
                        if (belowBlockPos.x + _X < 0 || belowBlockPos.z + _Z < 0) continue;
                        BlockPos aroundPos = blockPos.diff(_X, 0, _Z);
                        BlockPos aroundBelowPos = belowBlockPos.diff(_X, 0, _Z);
                        if (level.NotInBounds(aroundBelowPos)) continue;

                        int testPos = level.PosToInt(aroundPos);
                        int newPos = level.PosToInt(aroundBelowPos);
                        if (Block.crushable.Contains(level.blocks[newPos]) && level.blocks[testPos] == 0)
                        {
                            level.PhysicsBlockChange(aroundBelowPos, Blocks.Sand);
                            level.PhysicsBlockChange(blockPos, Blocks.Air);
                            //if (level.physics.PhysicsUpdates.Contains(level.PosToInt(aroundBelowPos))) return;
                            //level.physics.PhysicsUpdates.Add(level.PosToInt(aroundBelowPos));
                            return;
                        }
                        else
                        {
                            continue;
                        }
                    }
            }
        }