Version 1.1.0
This commit is contained in:
15
Plugin.cs
15
Plugin.cs
@@ -18,31 +18,36 @@ public class Plugin : BasePlugin
|
||||
{
|
||||
public const string PLUGIN_GUID = "de.mpburgmann.AutoPriceUpdater";
|
||||
public const string PLUGIN_NAME = "Auto Price Updater";
|
||||
public const string PLUGIN_VERSION = "1.0.0";
|
||||
public const string PLUGIN_VERSION = "1.1.0";
|
||||
public static new ManualLogSource Log;
|
||||
private static ConfigEntry<bool> EnableAutoUpdate;
|
||||
private static ConfigEntry<float> AmountToAdd;
|
||||
public static ConfigEntry<KeyCode> UpdateKey;
|
||||
private static List<DisplaySlot> m_CachedDisplaySlots = new List<DisplaySlot>(250);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
Log = base.Log;
|
||||
Log.LogInfo($"Loading {PLUGIN_NAME} v{PLUGIN_VERSION}");
|
||||
|
||||
Harmony harmony = new(PLUGIN_GUID);
|
||||
harmony.PatchAll();
|
||||
|
||||
UpdateKey = Config.Bind("Settings", "UpdateKey", KeyCode.F9);
|
||||
EnableAutoUpdate = Config.Bind("Settings", "Enabled", true, "If enabled, prices will be automatically updated at the start of each day.");
|
||||
UpdateKey = Config.Bind("Settings", "UpdateKey", KeyCode.F9, "Key to manually update prices. Not working when Enabled is false.");
|
||||
AmountToAdd = Config.Bind("Price Settings", "Amount To Add", 0.1f, "Amount to add to market price. Can be negative.");
|
||||
|
||||
SceneManager.sceneLoaded += (UnityAction<Scene, LoadSceneMode>) OnSceneLoaded;
|
||||
|
||||
Log.LogInfo($"Plugin {PLUGIN_GUID} is loaded!");
|
||||
Log.LogInfo($"{PLUGIN_NAME} loaded successfully");
|
||||
}
|
||||
|
||||
public static void UpdatePrice()
|
||||
{
|
||||
if(!EnableAutoUpdate.Value) return;
|
||||
List<Pricing> pricesSetByPlayer = Singleton<SaveManager>.Instance.Price.PricesSetByPlayer;
|
||||
foreach (Pricing pricing in pricesSetByPlayer)
|
||||
{
|
||||
pricing.Price = pricing.MarketPrice - 0.1f;
|
||||
pricing.Price = pricing.MarketPrice + AmountToAdd.Value;
|
||||
Log.LogInfo($"Updated price for product ID {pricing.ProductID} to {pricing.Price}");
|
||||
if(Singleton<DisplayManager>.Instance.GetDisplaySlots(pricing.ProductID, false, m_CachedDisplaySlots) > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user