public static bool TryPurchase(LandPlotUI kiosk, PlotUpgrade upgrade) { #if !SR_VANILLA LandPlot plot = kiosk.Get_LandPlot(); PlotUpgradeTracker tracker = plot.GetComponent <PlotUpgradeTracker>(); if (tracker.HasUpgrade(upgrade)) { kiosk.Error("e.already_has_upgrade"); } else if (Player.Currency >= upgrade.Cost) { Sound.Play(SoundId.PURCHASED_PLOT_UPGRADE); Player.SpendCurrency(upgrade.Cost, false); tracker.Add(upgrade); kiosk.Close(); return(true); } else { Sound.Play(SoundId.ERROR); kiosk.Error("e.insuf_coins"); } #endif return(false); }
public void Remove_Upgrade(PlotUpgrade upgrade) { bool b = upgrades.Remove(upgrade); if (!b) { SLog.Warn("Failed to remove custom plot upgrade from tracker. Upgrade: {0}", upgrade); } }
internal void Load(LandPlot pl, Plot_Upgrades up) { this.plot = pl; this.ID = new PlotID(plot); foreach (string upgradeName in up.upgrades) { PlotUpgrade upgrade = (PlotUpgrade)Upgrades.Get_Upgrade(Upgrade_Type.PLOT_UPGRADE, upgradeName); if (upgrade != null) { this.upgrades.Add(upgrade); } else { upgrades_missing.Add(upgradeName); } } }
public bool HasUpgrade(PlotUpgrade upgrade) { return(allUpgrades.Contains(upgrade.ID)); }
public void Remove(PlotUpgrade upgrade) { upgrades.Remove(upgrade); upgrade.Remove(plot); }
public void Add(PlotUpgrade upgrade) { upgrades.Add(upgrade); upgrade.Apply(plot.gameObject); }
public static void Write_Upgrade_Data_Value(PlotID pid, PlotUpgrade upgrade, string key, byte[] value) { Write_Upgrade_Data_Value(pid, upgrade.ID, key, value); }