Exemple #1
0
        internal override void Receive()
        {
            if (!Config.IsSinglePlayer)
            {
                lock (TcpClient)
                {
                    base.Receive();
                    var bytes = ReadStream(DataLength);
                    Position      = new Position(bytes, 0);
                    StructureType = (StructureType)BitConverter.ToUInt16(bytes, Position.SIZE);
                    FrontFace     = (Facing)BitConverter.ToUInt16(bytes, Position.SIZE + sizeof(ushort));
                }
            }

            switch (StructureType)
            {
            case StructureType.Tree:
                StructureBuilder.BuildTree(Position);
                break;

            case StructureType.Tower:
                StructureBuilder.BuildCastle(Position, Radius, 6, Block.BlockType.Cobble, FrontFace);
                break;

            case StructureType.SmallKeep:
                StructureBuilder.BuildCastle(Position, Radius, 8, Block.BlockType.Cobble, FrontFace);
                break;

            case StructureType.LargeKeep:
                StructureBuilder.BuildCastle(Position, Radius, 10, Block.BlockType.SteelPlate, FrontFace);
                break;
            }

            if (Config.IsServer)
            {
                foreach (var player in Controller.Players.Values)
                {
                    new AddStructure(Position, StructureType, FrontFace)
                    {
                        ConnectedPlayer = player
                    }.Send();
                }
            }
            else
            {
                //determine the corner coords for this structure; pass them for light calc and chunk queueing (note: the Y doesnt matter so use 0 for both)
                WorldData.ModifyLightAndQueueChunksForCuboidChange(new Position(Position.X - Radius, 0, Position.Z - Radius), new Position(Position.X + Radius, 0, Position.Z + Radius));
                Sounds.Audio.PlaySound(Sounds.SoundType.AddBlock);
            }
        }