using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GoodCompany.Patches;
using HarmonyLib;
using Unity.Netcode;
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("GoodCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GoodCompany")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c30a00d2-7917-4309-be99-7fafc934f83d")]
[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 GoodCompany
{
[BepInPlugin("NoOneOutPizzasTheHut.GoodCompany", "GoodCompany", "1.0.0.0")]
public class GoodCompanyBase : BaseUnityPlugin
{
private const string modGUID = "NoOneOutPizzasTheHut.GoodCompany";
private const string modName = "GoodCompany";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("NoOneOutPizzasTheHut.GoodCompany");
private string configFilePath = Path.Combine(Paths.ConfigPath, "GoodCompany.cfg");
private static GoodCompanyBase Instance;
internal static ManualLogSource logger;
public static ConfigEntry<int> creditStart { get; private set; }
public static ConfigEntry<int> quotaStart { get; private set; }
public static ConfigEntry<int> quotaBaseIncrease { get; private set; }
public static ConfigEntry<int> daysTillQuota { get; private set; }
public static ConfigEntry<int> minScrapCount { get; private set; }
public static ConfigEntry<int> maxScrapCount { get; private set; }
public static ConfigEntry<int> minTotalScrapValue { get; private set; }
public static ConfigEntry<int> maxTotalScrapValue { get; private set; }
private void Awake()
{
InitializeGoodCompany();
applyGoodCompanyPatches();
logger.LogInfo((object)"GoodCompany has been awaken!");
}
public void InitializeGoodCompany()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = new GoodCompanyBase();
}
logger = Logger.CreateLogSource("NoOneOutPizzasTheHut.GoodCompany");
creditStart = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.QuotaAndCredits", "Starting Credits", 200, "Set the desired amount of starting credits");
quotaStart = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.QuotaAndCredits", "Starting Quota", 200, "Set the desired starting quota");
quotaBaseIncrease = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.QuotaAndCredits", "Quota Base Increase", 200, "Set the desired quota base increase");
daysTillQuota = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.QuotaAndCredits", "Days till quota deadline", 3, "Set the desired amount of days to reach quota");
minScrapCount = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.Scrap", "Min Scrap Count", 6, "Set the desired min amount of scrap that will spawn on level");
maxScrapCount = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.Scrap", "Max Scrap Count", 24, "Set the desired max amount of scrap that will spawn on level");
minTotalScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.Scrap", "Min Scraps Total Value", 600, "Set the desired min value of scrap that will spawn on level");
maxTotalScrapValue = ((BaseUnityPlugin)this).Config.Bind<int>("GoodCompany.Scrap", "Max Scraps Total Value", 1800, "Set the desired max value of scrap that will spawn on level");
}
public void applyGoodCompanyPatches()
{
harmony.PatchAll(typeof(GoodCompanyBase));
logger.LogInfo((object)"GoodCompanyBase has been patched in!");
harmony.PatchAll(typeof(QuotaAndCreditPatch));
logger.LogInfo((object)"GoodCompany.QuoteAndCredits has been patched in!");
harmony.PatchAll(typeof(ScrapSettingsPatch));
logger.LogInfo((object)"GoodCompany.Scrap has been patched in!");
}
}
}
namespace GoodCompany.Patches
{
[HarmonyPatch(typeof(TimeOfDay))]
public static class QuotaAndCreditPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void ModifyTimeOfDay(TimeOfDay __instance)
{
__instance.quotaVariables.startingCredits = GoodCompanyBase.creditStart.Value;
__instance.quotaVariables.startingQuota = GoodCompanyBase.quotaStart.Value;
__instance.quotaVariables.baseIncrease = GoodCompanyBase.quotaBaseIncrease.Value;
__instance.quotaVariables.deadlineDaysAmount = GoodCompanyBase.daysTillQuota.Value;
}
}
[HarmonyPatch(typeof(RoundManager))]
public static class ScrapSettingsPatch
{
[HarmonyPatch("LoadNewLevel")]
[HarmonyPrefix]
private static bool ModifyLoadNewLevel(ref SelectableLevel newLevel)
{
if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
{
return true;
}
newLevel.minScrap = GoodCompanyBase.minScrapCount.Value;
newLevel.maxScrap = GoodCompanyBase.maxScrapCount.Value;
newLevel.minTotalScrapValue = GoodCompanyBase.minTotalScrapValue.Value;
newLevel.maxTotalScrapValue = GoodCompanyBase.maxTotalScrapValue.Value;
return true;
}
}
}