示例#1
0
        /// <summary>
        /// Causes a block change for the level
        /// </summary>
        /// <param name="x">Location of x</param>
        /// <param name="z">Location of z</param>
        /// <param name="y">Location of y</param>
        /// <param name="block">Block to set</param>
        /// <param name="p">A player who doesn't need the update.</param>
        /// <param name="blockqueue">Should this blockchange be queued by BlockQueue?</param>
        public void BlockChange(ushort x, ushort z, ushort y, byte block, Player p = null, bool blockqueue = false)
        {
            if (blockqueue)
            {
                BlockQueue.Addblock(p, x, y, z, block);
            }
            if (!IsInBounds(x, z, y) || y == CWMap.Size.z)
            {
                Logger.Log("Blockchange((ushort) " + x + ", (ushort)" + z + ", (ushort) " + y + ", (byte) " + block + ", (Player) " + p + ") is outside of level");
                return;
            }
            byte currentType = GetBlock(x, z, y);
            if (block == 0)
            {
                pblocks.ForEach(pb =>
                {
                    if (pb.X == x && pb.Y == y && pb.Z == z)
                    {
                        pblocks.Remove(pb);
                        return;
                    }
                });
            }
            if (block == currentType) return;
            if (p != null)
            {
                byte blockFrom = GetBlock(x, z, y);
                BlockChangeHistory.Add(p.Level.Name, (uint)p.UID, x, z, y, block);
            }

            SetBlock(x, z, y, block);
            if (p == null)
                Player.GlobalBlockchange(this, x, z, y, block);
            else
            {
                p.SendBlockchangeToOthers(this, x, z, y, block);
                p.SendBlockChange(x, z, y, block);
            }

            if ((Block)block is PhysicsBlock)
            {
                PhysicsBlock pb = (PhysicsBlock)((PhysicsBlock)block).Clone();
                pb.X = x;
                pb.Y = y;
                pb.Z = z;
                pblocks.Add(pb);
            }

            //TODO Special stuff for block changing
        }
示例#2
0
        /// <summary>
        /// Causes a block change for the level
        /// </summary>
        /// <param name="x">Location of x</param>
        /// <param name="z">Location of z</param>
        /// <param name="y">Location of y</param>
        /// <param name="block">Block to set</param>
        /// <param name="p">A player who doesn't need the update.</param>
        public void BlockChange(ushort x, ushort z, ushort y, byte block, Player p = null)
        {
            if (y == Size.y) return;
            byte currentType = GetBlock(x, z, y);

            if (block == currentType) return;

            SetBlock(x, z, y, block);
            if (p == null)
                Player.GlobalBlockchange(this, x, z, y, block);
            else p.SendBlockchangeToOthers(this, x, z, y, block);

            //TODO Special stuff for block changing
        }