예제 #1
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 | RayMasks.STRUCTURE))
            {
                Interactable2SalvageBarricade barri = hit.transform.GetComponent <Interactable2SalvageBarricade>();
                Interactable2SalvageStructure struc = hit.transform.GetComponent <Interactable2SalvageStructure>();

                if (barri != null)
                {
                    BarricadeManager.tryGetInfo(barri.root, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region);

                    region.barricades.RemoveAt(index);

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

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

                    EssLang.Send(src, "BARRICADE_REMOVED");
                    return(CommandResult.Success());
                }
                else if (struc != null)
                {
                    StructureManager.tryGetInfo(struc.transform, out byte x, out byte y, out ushort index, out StructureRegion region);

                    region.structures.RemoveAt(index);

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

                    manager.channel.send("tellTakeStructure", ESteamCall.ALL, x, y, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                    {
                        x,
                        y,
                        index,
                        (region.drops[index].model.position - player.UnturnedPlayer.transform.position).normalized * 100f
                    });

                    EssLang.Send(src, "STRUCTURE_REMOVED");
                    return(CommandResult.Success());
                }
                else
                {
                    return(CommandResult.LangError("DESTROY_INVALID"));
                }
            }
예제 #2
0
        public void Execute(IRocketPlayer caller, string[] args)
        {
            Player     player = ((UnturnedPlayer)caller).Player;
            PlayerLook look   = player.look;

            if (PhysicsUtility.raycast(new Ray(look.aim.position, look.aim.forward), out RaycastHit hit, Mathf.Infinity, RayMasks.BARRICADE | RayMasks.STRUCTURE))
            {
                Interactable2SalvageBarricade barri = hit.transform.GetComponent <Interactable2SalvageBarricade>();
                Interactable2SalvageStructure struc = hit.transform.GetComponent <Interactable2SalvageStructure>();

                if (barri != null)
                {
                    BarricadeManager.tryGetInfo(barri.root, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region);

                    region.barricades.RemoveAt(index);

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

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

                    UnturnedChat.Say(caller, Util.Translate("barricade_removed"));
                }
                else if (struc != null)
                {
                    StructureManager.tryGetInfo(struc.transform, out byte x, out byte y, out ushort index, out StructureRegion region);

                    region.structures.RemoveAt(index);

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

                    manager.channel.send("tellTakeStructure", ESteamCall.ALL, x, y, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                    {
                        x,
                        y,
                        index,
                        (region.drops[index].model.position - player.transform.position).normalized * 100f
                    });

                    UnturnedChat.Say(caller, Util.Translate("structure_removed"));
                }
                else
                {
                    UnturnedChat.Say(caller, Util.Translate("invalid_destroy"));
                }
            }
예제 #3
0
        public bool Heal(Transform transform, ushort amout)
        {
            Interactable2SalvageBarricade bar  = transform.GetComponent <Interactable2SalvageBarricade>();
            Interactable2SalvageStructure strc = transform.GetComponent <Interactable2SalvageStructure>();

            if (bar != null)
            {
                BarricadeManager.tryGetInfo(bar.root, out byte x, out byte y, out ushort plant, out ushort index, out BarricadeRegion region);
                region.barricades[index].barricade.askRepair(amout);
                return(true);
            }
            else if (strc != null)
            {
                StructureManager.tryGetInfo(strc.transform, out byte x, out byte y, out ushort index, out StructureRegion region);
                region.structures[index].structure.askRepair(amout);
                return(true);
            }
            return(false);
        }