public string Get_String(string key) { byte[] buf = Upgrades.Read_Upgrade_Data_Value(pid, upgradeName, key); if (buf == null) { return(null); } return(UTF8Encoding.UTF8.GetString(buf)); }
public static bool CanBuyUpgrade(string ID) { PlayerUpgrade up = (PlayerUpgrade)Upgrades.Get_Upgrade(Upgrade_Type.PLAYER_UPGRADE, ID); if (up == null) { return(false); } return(CanBuyUpgrade(up)); }
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); } } }
private static Sisco_Return onLevelLoaded(ref object sender, ref object[] args, ref object return_value) { // Each time we load the main menu we want to clear any and all upgrade related data to ensure nothing freaky happens when the player loads a new file. int lvl = (int)args[0]; if (lvl == 0 || Levels.isSpecial()) { System.Threading.Timer timer = null; timer = new System.Threading.Timer((object o) => { SLog.Debug("[Upgrades] Flushing custom upgrades..."); Upgrades.setup = false; Upgrades.Setup(); timer.Dispose(); }, null, 0, System.Threading.Timeout.Infinite); } return(null); }
/// <summary> /// Removes the upgrades effects from the LandPlot /// </summary> public void Remove(bool ignore_tracker, LandPlot plot) { PlotID pID = new PlotID(plot); // Clear any save data this upgrade might have set for this plot. Upgrades.Clear_Upgrade_Data(pID, this.ID); if (!ignore_tracker) { // Remove the upgrade from this plot's tracker. PlotUpgradeTracker tracker = plot.GetComponent <PlotUpgradeTracker>(); if (tracker == null) { SLog.Warn("Failed to remove upgrade from plot {0}. Cannot find PlotUpgradeTracker!", pID); } else { tracker.Remove_Upgrade(this); } } // Call the upgrades cleanup logic. removal_function?.Invoke(plot); }
public override bool Purchase(GameObject sender) { return(Upgrades.TryPurchase(sender.GetComponent <LandPlotUI>(), this)); }
/// <summary> /// /// </summary> /// <param name="parent">A reference to your plugin, also used to uniquely identify the upgrade in save files</param> /// <param name="id">A string that will be used to uniquely identify this upgrade in save files</param> /// <param name="cost">How many credits the upgrade costs</param> /// <param name="name">The title text for the upgrade when shown in the upgrade kiosk</param> /// <param name="desc">The description text for the upgrade when shown in the upgrade kiosk</param> /// <param name="function">Function that applies the upgrade's effects.</param> /// <param name="icon">An icon used to represent the plugin when shown in the upgrade kiosk</param> /// <param name="preview">The preview image to show in the upgrade kiosk</param> public PlayerUpgrade(Plugin parent, string id, int cost, string name, string desc, Action <GameObject> function, Texture2D icon, Texture2D preview) : base(parent, id, cost, name, desc, function, icon, preview) { Upgrades.Register(this); }
public double Get_Double(string key) { return(BitConverter.ToDouble(Upgrades.Read_Upgrade_Data_Value(pid, upgradeName, key), 0)); }
public int Get_Int(string key) { return(BitConverter.ToInt32(Upgrades.Read_Upgrade_Data_Value(pid, upgradeName, key), 0)); }
public bool Get_Bool(string key) { return(BitConverter.ToBoolean(Upgrades.Read_Upgrade_Data_Value(pid, upgradeName, key), 0)); }
public void Set_String(string key, string str) { Upgrades.Write_Upgrade_Data_Value(pid, upgradeName, key, UTF8Encoding.UTF8.GetBytes(str)); }
public void Set_Double(string key, double v) { Upgrades.Write_Upgrade_Data_Value(pid, upgradeName, key, BitConverter.GetBytes(v)); }
public void Set_Float(string key, float v) { Upgrades.Write_Upgrade_Data_Value(pid, upgradeName, key, BitConverter.GetBytes(v)); }
public bool HasValue(string key) { return(Upgrades.Has_Upgrade_Data_Value(pid, upgradeName, key)); }
/// <summary> /// /// </summary> /// <param name="parent">A reference to your plugin, also used to uniquely identify the upgrade in save files</param> /// <param name="kind">What kind of plot item this upgrade is for; Coop, Silo, Corral, Pond, Garden, etc.</param> /// <param name="id">A string that will be used to uniquely identify this upgrade in save files</param> /// <param name="cost">How many credits the upgrade costs</param> /// <param name="name">The title text for the upgrade when shown in the kiosk</param> /// <param name="desc">The description text for the upgrade when shown in the kiosk</param> /// <param name="function">Function that applies the upgrade's effects.</param> /// <param name="remove_func">Function to remove the upgrade's effects.</param> /// <param name="icon">An icon used to represent the upgrade when shown in the kiosk</param> /// <param name="preview">The preview image to show in the upgrade kiosk</param> public PlotUpgrade(Plugin parent, LandPlot.Id kind, string id, int cost, string name, string desc, Action <GameObject> function, Action <LandPlot> remove_func, Texture2D icon, Texture2D preview) : base(parent, id, cost, name, desc, function, icon, preview) { Kind = kind; removal_function = remove_func; Upgrades.Register(this); }
public static void init(string hash) { lock (locker) { if (Loader.Config != null) { return; } //Application.stackTraceLogType = StackTraceLogType.Full; Logging.Logger.Begin(Path.Combine(Application.dataPath, "plugins.log")); Stopwatch timer = new Stopwatch(); timer.Start(); if (!Loader.Load_Config_Stream()) { return; } try { DebugHud.Init(); TextureHelper.Setup(); MaterialHelper.Setup(); SiscosHooks.Setup(); PluginLoader_Watermark.Setup(); MainMenu.Setup(); DebugUI.Setup(); Setup_Update_Helper(); bool ok = Verify_PluginLoader_Hash(hash); if (!ok) { return; } IN_LOADING_PHASE = true; Setup_Plugin_Dir(); Check_For_Updates(); Setup_Assembly_Resolver(); Upgrades.Setup(); Assemble_Plugin_List(); Load_Config(); IN_LOADING_PHASE = false; ResourceExt.map_SR_Icons(); plugin_updater = uiControl.Create <Plugin_Update_Viewer>();// This control manages itself and is only able to become visible under certain conditions which it will control. Therefore it needs no var to track it. plugin_updater.Show(); dev_tools = uiControl.Create <DevMenu>(); //dev_tools.Show(); //dev_tools.onShown += (uiWindow w) => { GameTime.Pause(); }; //dev_tools.onHidden += (uiWindow w) => { GameTime.Unpause(); }; //Misc_Experiments.Find_Common_Classes_For_Idents(new HashSet<Identifiable.Id> { Identifiable.Id.PINK_RAD_LARGO }); } catch (Exception ex) { SLog.Error("Exception during PluginLoader initialization!"); SLog.Error(ex); } finally { timer.Stop(); SLog.Debug("Plugin Loader initialized! Took: {0}ms", timer.ElapsedMilliseconds); } } }
public float Get_Float(string key) { return(BitConverter.ToSingle(Upgrades.Read_Upgrade_Data_Value(pid, upgradeName, key), 0)); }