using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LigersPatch.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LigersPatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LigersPatch")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dcf6fe35-7b96-45c3-ba39-a5d433759fef")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LigersPatch
{
[Serializable]
public class ConfigMaker
{
private ConfigEntry<bool> buyRateEnableCfg;
private ConfigEntry<float> buyRateCfg;
private ConfigEntry<float> offRateCfg;
private ConfigEntry<float> timeSpeedCfg;
internal bool buyRateEnable
{
get
{
if (buyRateEnableCfg == null)
{
return (bool)((ConfigEntryBase)buyRateEnableCfg).DefaultValue;
}
return buyRateEnableCfg.Value;
}
set
{
buyRateEnableCfg.Value = value;
}
}
internal float buyRate
{
get
{
if (buyRateCfg == null)
{
return (float)((ConfigEntryBase)buyRateCfg).DefaultValue;
}
return buyRateCfg.Value;
}
set
{
buyRateCfg.Value = value;
}
}
internal float offRate
{
get
{
if (offRateCfg == null)
{
return (float)((ConfigEntryBase)offRateCfg).DefaultValue;
}
return offRateCfg.Value;
}
set
{
offRateCfg.Value = value;
}
}
internal float timeSpeed
{
get
{
if (timeSpeedCfg == null)
{
return (float)((ConfigEntryBase)timeSpeedCfg).DefaultValue;
}
return timeSpeedCfg.Value;
}
set
{
timeSpeedCfg.Value = value;
}
}
public ConfigMaker(ConfigFile Config)
{
buyRateEnableCfg = Config.Bind<bool>("Main", "Enable Override", true, "Enables the buy rate override");
buyRateCfg = Config.Bind<float>("Main", "Company Buy Rate: Deadline Day", 1f, "Sets the buy % of the Company on deadline day");
offRateCfg = Config.Bind<float>("Main", "Company Buy Rate: Off Day", 1f, "Sets the buy % of the Company on non-deadline days");
timeSpeedCfg = Config.Bind<float>("Main", "Passage of Time Speed", 0.7f, "< 1 for longer days. > 1 for shorter");
}
}
[BepInPlugin("Liger500.LigersPatchMod", "Liger's Patch", "1.0.0")]
public class LazyCompany : BaseUnityPlugin
{
private const string modGUID = "Liger500.LigersPatchMod";
private const string modName = "Liger's Patch";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Liger500.LigersPatchMod");
public static LazyCompany Instance;
internal ConfigMaker ConfigManager;
public ManualLogSource snitch;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
snitch = Logger.CreateLogSource("Liger500.LigersPatchMod");
ConfigManager = new ConfigMaker(((BaseUnityPlugin)this).Config);
snitch.LogInfo((object)"Liger's Patch totally started");
harmony.PatchAll(typeof(LazyCompany));
harmony.PatchAll(typeof(FlexibleBuyRatePatch));
snitch.LogInfo((object)"Company loves buying stuff");
harmony.PatchAll(typeof(LongerDaysPatch));
snitch.LogInfo((object)"You SHOULD have more time to look for stuff");
harmony.PatchAll(typeof(ConfigMaker));
snitch.LogInfo((object)"And the config thing should be good ~Liger");
}
}
}
namespace LigersPatch.Patches
{
[HarmonyPatch(typeof(StartOfRound))]
internal class CompanyBuyRatePatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void BuyRatePatch(ref float ___companyBuyingRate)
{
if (LazyCompany.Instance.ConfigManager.buyRateEnable)
{
___companyBuyingRate = LazyCompany.Instance.ConfigManager.buyRate;
}
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal class LongerDaysPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void LongerDays(ref float ___globalTimeSpeedMultiplier)
{
___globalTimeSpeedMultiplier = LazyCompany.Instance.ConfigManager.timeSpeed;
}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal class FlexibleBuyRatePatch
{
[HarmonyPatch("SetBuyingRateForDay")]
[HarmonyPostfix]
private static void BiggerGainsPatch(ref int ___daysUntilDeadline)
{
if (LazyCompany.Instance.ConfigManager.buyRateEnable)
{
if (___daysUntilDeadline == 0)
{
StartOfRound.Instance.companyBuyingRate = LazyCompany.Instance.ConfigManager.buyRate;
}
else
{
StartOfRound.Instance.companyBuyingRate = LazyCompany.Instance.ConfigManager.offRate;
}
}
}
}
}