Ejemplo n.º 1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            int num = 0;

            HomesHelper.ClearHomes();
            foreach (BarricadeRegion region in BarricadeManager.regions)
            {
                foreach (BarricadeDrop drop in region.drops)
                {
                    InteractableBed interactableBed = drop.interactable as InteractableBed;
                    if (interactableBed != null && interactableBed.isClaimed)
                    {
                        HomesHelper.TryClaimHome(interactableBed.owner, interactableBed);
                        num++;
                    }
                }
            }
            pluginInstance.DataService.SaveData();
            UnturnedChat.Say(caller, pluginInstance.Translate("RestoreHomesSuccess", num), pluginInstance.MessageColor);
        }
        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);
        }