Exemplo n.º 1
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            PlayerLook look = ((UnturnedPlayer)caller).Player.look;

            if (PhysicsUtility.raycast(new Ray(look.aim.position, look.aim.forward), out RaycastHit hit, Mathf.Infinity, RayMasks.BARRICADE_INTERACT))
            {
                InteractableDoorHinge hinge = hit.transform.GetComponent <InteractableDoorHinge>();

                if (hinge != null)
                {
                    InteractableDoor door = hinge.door;
                    bool             open = !door.isOpen;

                    BarricadeManager.tryGetInfo(door.transform, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region);

                    door.updateToggle(open);

                    BarricadeManager.instance.channel.send("tellToggleDoor", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                    {
                        x,
                        y,
                        plant,
                        index,
                        open
                    });

                    UnturnedChat.Say(caller, Util.Translate("door_toggle", open ? "opened" : "closed"));
                }
                else
                {
                    UnturnedChat.Say(caller, Util.Translate("invalid_door"));
                }
            }
Exemplo n.º 2
0
        public static void ToggleDoor(InteractableDoor door, bool open)
        {
            BarricadeManager.tryGetInfo(door.transform, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region);
            door.updateToggle(open);

            BarricadeManager.instance.channel.send("tellToggleDoor", ESteamCall.ALL,
                                                   ESteamPacket.UPDATE_RELIABLE_BUFFER, x, y, plant, index, open);
        }
Exemplo n.º 3
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            var PlayerCaller = (UnturnedPlayer)caller;

            InteractableDoorHinge component = raycastdoor.Getdoor(PlayerCaller);

            if (component != null)
            {
                bool             isregistered = false;
                InteractableDoor door         = component.door;
                bool             flag         = !door.isOpen;
                byte             x;
                byte             y;
                ushort           plant;
                ushort           index;
                BarricadeRegion  barricadeRegion;
                BarricadeManager.tryGetInfo(door.transform, out x, out y, out plant, out index, out barricadeRegion);
                BarricadeDrop barricadedrop = barricadeRegion.drops[index];
                var           ID            = barricadedrop.instanceID;
                foreach (Registereddoortype doorinfo in miscstuff.Instance.Configuration.Instance.listofregistereddoors)
                {
                    if (doorinfo.ID == ID)
                    {
                        isregistered = true;
                        if (caller.HasPermission(doorinfo.permission))

                        {
                            //OPEN THE DOOOOOOOR
                            Rocket.Core.Logging.Logger.Log("Player has perm: " + doorinfo.permission);
                            SteamCaller steamCaller = (BarricadeManager)typeof(BarricadeManager).GetField("manager", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
                            door.updateToggle(flag);
                            steamCaller.channel.send("tellToggleDoor", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                            {
                                x,
                                y,
                                plant,
                                index,
                                flag
                            });
                            Rocket.Core.Logging.Logger.Log("Player toggled door " + doorinfo.ID);
                            UnturnedChat.Say(caller, doorinfo.name + " door toggled", Color.yellow);
                        }
                        else
                        {
                            UnturnedChat.Say(caller, "You do not have the right permissions to open this door", Color.red);
                        }
                    }
                }
                if (isregistered == false)
                {
                    UnturnedChat.Say(caller, "Door is not registered!", Color.red);
                }
            }
        }
Exemplo n.º 4
0
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            var player = src.ToPlayer();
            var look   = player.Look;

            if (PhysicsUtility.raycast(new Ray(look.aim.position, look.aim.forward), out RaycastHit hit, Mathf.Infinity, RayMasks.BARRICADE))
            {
                InteractableDoorHinge hinge = hit.transform.GetComponent <InteractableDoorHinge>();

                if (hinge != null)
                {
                    InteractableDoor door = hinge.door;
                    bool             open = !door.isOpen;

                    BarricadeManager.tryGetInfo(door.transform, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region);

                    BarricadeManager manager = (BarricadeManager)typeof(BarricadeManager).GetField("manager", BindingFlags.NonPublic |
                                                                                                   BindingFlags.Static).GetValue(null);

                    door.updateToggle(open);

                    manager.channel.send("tellToggleDoor", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                    {
                        x,
                        y,
                        plant,
                        index,
                        open
                    });

                    EssLang.Send(src, "DOOR_TOGGLED", open ? "opened" : "closed");
                    return(CommandResult.Success());
                }
                else
                {
                    return(CommandResult.LangError("DOOR_INVALID"));
                }
            }