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); }
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) { var home = HomesHelper.GetPlayerHome(steamID, interactableBed); HomesHelper.RemoveHome(steamID, home); home.Unclaim(); } else { var playerData = HomesHelper.GetOrCreatePlayer(steamID); int maxHomes = VipHelper.GetPlayerMaxHomes(steamID.ToString()); if (maxHomes == 1 && playerData.Homes.Count == 1) { foreach (var home in playerData.Homes.ToArray()) { HomesHelper.RemoveHome(steamID, home); home.Unclaim(); } } else if (maxHomes <= playerData.Homes.Count) { UnturnedChat.Say(steamID, MoreHomesPlugin.Instance.Translate("MaxHomesWarn"), MoreHomesPlugin.Instance.MessageColor); return(false); } var playerHome = new PlayerHome(playerData.GetUniqueHomeName(), interactableBed); playerData.Homes.Add(playerHome); playerHome.Claim(steamID); UnturnedChat.Say(steamID, MoreHomesPlugin.Instance.Translate("HomeClaimed", playerHome.Name), MoreHomesPlugin.Instance.MessageColor); } } } return(false); }
float timer; // Timer for counting up to the next attack. void Awake() { // Setting up the references. homeBase = GameObject.FindGameObjectWithTag("Base"); homeBaseHealth = homeBase.GetComponent <PlayerHome> (); enemyHealth = GetComponent <EnemyHealth>(); anim = GetComponent <Animator> (); }
NavMeshAgent nav; // Reference to the nav mesh agent. void Awake() { // Set up the references. homeBase = GameObject.FindGameObjectWithTag("Base").transform; homeHealth = homeBase.GetComponent <PlayerHome> (); enemyHealth = GetComponent <EnemyHealth> (); nav = GetComponent <NavMeshAgent> (); }
public static bool TryClaimHome(CSteamID steamID, InteractableBed interactableBed) { var player = GetOrCreatePlayer(steamID); if (player.Homes.Count >= VipHelper.GetPlayerMaxHomes(steamID.ToString())) { UnturnedChat.Say(steamID, pluginInstance.Translate("MaxHomesWarn"), pluginInstance.MessageColor); return(false); } var home = new PlayerHome(player.GetUniqueHomeName(), interactableBed); player.Homes.Add(home); UnturnedChat.Say(steamID, pluginInstance.Translate("HomeClaimed", home.Name), pluginInstance.MessageColor); return(true); }
public bool TryGetHome(UnturnedPlayer player, string name, out PlayerHome home) { if (HomeIndex.Homes.ContainsKey(player.CSteamID.m_SteamID)) { var res = HomeIndex.Homes[player.CSteamID.m_SteamID] .Where(x => x.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)) .ToList(); if (res.Count > 0) { home = res[0]; return(true); } } home = PlayerHome.Nil; return(false); }
public PlayerHome CreatePlayerHome(UnturnedPlayer player, Vector3 position, string name) { PlayerHome home = new PlayerHome(name, new SVector(position)); if (!HomeIndex.Homes.ContainsKey(player.CSteamID.m_SteamID)) { HomeIndex.Homes.Add(player.CSteamID.m_SteamID, new List <PlayerHome>() { home }); } else { HomeIndex.Homes[player.CSteamID.m_SteamID].Add(home); } Save(); return(home); }
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) { var player = HomesHelper.GetOrCreatePlayer(interactableBed.owner); var playerHome = new PlayerHome(player.GetUniqueHomeName(), interactableBed); player.Homes.Add(playerHome); num++; } } } pluginInstance.DataService.SaveData(); UnturnedChat.Say(caller, pluginInstance.Translate("RestoreHomesSuccess", num), pluginInstance.MessageColor); }
private bool ValidateTeleportation(UnturnedPlayer player, PlayerHome home) { if (home.InteractableBed == null) { UnturnedChat.Say(player, pluginInstance.Translate("BedDestroyed"), pluginInstance.MessageColor); return(false); } if (player.Stance == EPlayerStance.DRIVING) { UnturnedChat.Say(player, pluginInstance.Translate("WhileDriving"), pluginInstance.MessageColor); return(false); } if (pluginInstance.TeleportationPlugin != null) { if (!ValitedateRaidAndCombat(player)) { return(false); } } return(true); }
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; } HomesHelper.RemoveHome(player.CSteamID, home); home.Destroy(); UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeSuccess", home.Name), pluginInstance.MessageColor); }
public static bool RemoveHome(CSteamID steamID, PlayerHome playerHome) { var player = GetOrCreatePlayer(steamID); return(player.Homes.Remove(playerHome)); }