Exemple #1
0
    private Vector3i  displaceEntity(int _x, int _y, int _z)
    {
        Vector3i displaceAmount = new Vector3i(_x, _y, _z);

        return(entityPlayer.GetBlockPosition() + displaceAmount);
    }
Exemple #2
0
        public static bool Execute(ClientInfo sender, List <string> arguments)
        {
            World        world         = GameManager.Instance.World;
            EntityPlayer entityPlayer  = world.Players.dict[sender.entityId];
            Vector3i     blockPosition = entityPlayer.GetBlockPosition();
            Chunk        chunk         = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(blockPosition);

            // Just show current state
            if (arguments.Count == 0)
            {
                if (chunk.IsAnyTraderArea())
                {
                    ChatManager.Message(sender, string.Format(
                                            "[F012BE]Pos [FFDC00]X:[F012BE] {0}, [FFDC00]Z:[F012BE] {1}, [01FF70]Protected",
                                            blockPosition.x,
                                            blockPosition.z
                                            ));
                }
                else
                {
                    ChatManager.Message(sender, string.Format(
                                            "[F012BE]Pos [FFDC00]X:[F012BE] {0}, [FFDC00]Z:[F012BE] {1}, [FF4136]Unprotected",
                                            blockPosition.x,
                                            blockPosition.z
                                            ));
                }
                return(false);
            }

            bool enable = true;

            try
            {
                enable = bool.Parse(arguments[1]);
            }
            catch (Exception) { }

            //int x = l.x & 0xF;
            //int z = l.z & 0xF;

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    chunk.SetTraderArea(x, z, enable);
                }
            }

            if (enable)
            {
                ChatManager.Message(sender, string.Format(
                                        "[F012BE]Pos [FFDC00]X:[F012BE] {0}, [FFDC00]Z:[F012BE] {1}, [01FF70]Enabled",
                                        blockPosition.x,
                                        blockPosition.z
                                        ));
            }
            else
            {
                ChatManager.Message(sender, string.Format(
                                        "[F012BE]Pos [FFDC00]X:[F012BE] {0}, [FFDC00]Z:[F012BE] {1}, [FF4136]Disabled",
                                        blockPosition.x,
                                        blockPosition.z
                                        ));
            }

            foreach (ClientInfo clientInfo in ConnectionManager.Instance.Clients.List)
            {
                clientInfo.SendPackage(NetPackageManager.GetPackage <NetPackageChunk>().Setup(chunk, true));
            }

            return(false);
        }
Exemple #3
0
    public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
    {
        if (_params.Count == 2)
        {
            bool isValid = int.TryParse(_params[0], out dx);
            if (isValid)
            {
                isValid = int.TryParse(_params[1], out dz);
            }
        }
        else
        {
            var rand = new Random();
            dx = rand.Next(10, 30);
            dz = rand.Next(10, 30);
        }

        if (!_senderInfo.IsLocalGame && _senderInfo.RemoteClientInfo == null)
        {
            SingletonMonoBehaviour <SdtdConsole> .Instance.Output("Command can only be used on clients.");

            return;
        }


        if (_senderInfo.IsLocalGame)
        {
            entityPlayer   = GameManager.Instance.World.GetPrimaryPlayer();
            newLocationV3i = displaceEntity(dx, 0, dz);
            chatOutput(string.Format("Current Player Coordinates: {0},{1}  -> New Coordinates {2}, {3}", entityPlayer.GetBlockPosition().x, entityPlayer.GetBlockPosition().z, newLocationV3i.x, newLocationV3i.z));
            if (!SingletonMonoBehaviour <ConnectionManager> .Instance.IsClient)
            {
                teleport(newLocationV3i);
            }
            else
            {
                //SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageConsoleCmdServer>().Setup(GameManager.Instance.World.GetPrimaryPlayerId(), "your command"), false);
            }
        }
        else
        {
            entityPlayer = GameManager.Instance.World.Players.dict[_senderInfo.RemoteClientInfo.entityId];
        }
    }