Beispiel #1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player   = (UnturnedPlayer)caller;
            string         homeName = command.ElementAtOrDefault(0);

            if (homeName == null)
            {
                UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeFormat"), pluginInstance.MessageColor);
                return;
            }

            PlayerHome home = HomesHelper.GetPlayerHome(player.CSteamID, homeName);

            if (home == null)
            {
                UnturnedChat.Say(caller, pluginInstance.Translate("HomeNotFound", home.Name), pluginInstance.MessageColor);
                return;
            }

            if (!HomesHelper.TryRemoveHome(player.CSteamID, home.InteractableBed) || home.InteractableBed == null)
            {
                return;
            }



            BarricadeManager.tryGetInfo(home.InteractableBed.transform, out var x, out var y, out var plant, out var index, out var region);
            if (home.InteractableBed != null)
            {
                BarricadeManager.destroyBarricade(region, x, y, plant, index);
            }

            UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeSuccess", home.Name), pluginInstance.MessageColor);
        }
Beispiel #2
0
 public static void TellTakeBarricade_Prefix(BarricadeManager __instance, CSteamID steamID, byte x, byte y, ushort plant, ushort index)
 {
     if (BarricadeManager.tryGetRegion(x, y, plant, out BarricadeRegion barricadeRegion))
     {
         InteractableBed interactableBed = barricadeRegion.drops[index].interactable as InteractableBed;
         if (interactableBed != null)
         {
             HomesHelper.TryRemoveHome(interactableBed.owner, interactableBed);
         }
     }
 }
        public static bool AskClaimBed_Prefix(BarricadeManager __instance, CSteamID steamID, byte x, byte y, ushort plant, ushort index)
        {
            BarricadeRegion barricadeRegion;

            if (Provider.isServer && BarricadeManager.tryGetRegion(x, y, plant, out barricadeRegion))
            {
                Player player = PlayerTool.getPlayer(steamID);
                if (player == null)
                {
                    return(false);
                }
                if (player.life.isDead)
                {
                    return(false);
                }
                if (index >= barricadeRegion.drops.Count)
                {
                    return(false);
                }
                if ((barricadeRegion.drops[index].model.transform.position - player.transform.position).sqrMagnitude > 400f)
                {
                    return(false);
                }
                InteractableBed interactableBed = barricadeRegion.drops[index].interactable as InteractableBed;
                if (interactableBed != null && interactableBed.isClaimable && interactableBed.checkClaim(player.channel.owner.playerID.steamID))
                {
                    if (interactableBed.isClaimed)
                    {
                        #region RemoveHome

                        HomesHelper.TryRemoveHome(steamID, interactableBed);

                        #endregion

                        if (plant == 65535)
                        {
                            BarricadeManager.instance.channel.send("tellClaimBed", ESteamCall.ALL, x, y, BarricadeManager.BARRICADE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                            {
                                x,
                                y,
                                plant,
                                index,
                                CSteamID.Nil
                            });
                        }
                        else
                        {
                            BarricadeManager.instance.channel.send("tellClaimBed", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                            {
                                x,
                                y,
                                plant,
                                index,
                                CSteamID.Nil
                            });
                        }
                    }
                    else
                    {
                        #region AddHome

                        if (!HomesHelper.TryClaimHome(steamID, interactableBed))
                        {
                            return(false);
                        }

                        #endregion

                        // THIS HAS TO BE COMMENT OUT
                        //BarricadeManager.unclaimBeds(player.channel.owner.playerID.steamID);
                        if (plant == 65535)
                        {
                            BarricadeManager.instance.channel.send("tellClaimBed", ESteamCall.ALL, x, y, BarricadeManager.BARRICADE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                            {
                                x,
                                y,
                                plant,
                                index,
                                player.channel.owner.playerID.steamID
                            });
                        }
                        else
                        {
                            BarricadeManager.instance.channel.send("tellClaimBed", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                            {
                                x,
                                y,
                                plant,
                                index,
                                player.channel.owner.playerID.steamID
                            });
                        }
                    }
                    BitConverter.GetBytes(interactableBed.owner.m_SteamID).CopyTo(barricadeRegion.barricades[index].barricade.state, 0);
                }
            }
            return(true);
        }