Decompiled source of YetAnotherQuotaSettingsMod v1.0.0

Tomatobird.YetAnotherQuotaSettingsMod.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.YetAnotherQuotaSettingsMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c7b6ef32248f65d2044b7bb06247a4dbf5a13a0e")]
[assembly: AssemblyProduct("YetAnotherQuotaSettingsMod")]
[assembly: AssemblyTitle("Tomatobird.YetAnotherQuotaSettingsMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace YetAnotherQuotaSettingsMod
{
	[BepInPlugin("Tomatobird.YetAnotherQuotaSettingsMod", "YetAnotherQuotaSettingsMod", "1.0.0")]
	public class YetAnotherQuotaSettingsMod : BaseUnityPlugin
	{
		public static float baseIncrease;

		public static int deadlineDaysAmount;

		public static float increaseSteepness;

		public static string randomizerCurve = "";

		public static float randomizerMultiplier;

		public static int startingCredits;

		public static int startingQuota;

		public static bool onlyChangeCurve;

		public static YetAnotherQuotaSettingsMod Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			baseIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Base Increase", 100f, "The base increase for quota calculation.").Value;
			deadlineDaysAmount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Days Until Deadline", 3, "The amount of days until deadline of the quota.").Value;
			increaseSteepness = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Increase Steepness", 16f, "The increase steepness for quota calculation.").Value;
			randomizerCurve = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Randomizer Curve", "", "The randomizer curve used to randomize the next quota roll. LC by default evaluates the curve from 0 to 1. Default LC curve min/max values are -0.503/0.503. You can use values beyond vanilla if desired so. Ex: 0,-0.5 ; 0.5,-0.5 ; 1,0.6 for a curve with first half flat at value -0.5 then linear increase to value 0.6 on other half. You can type in a single constant value as well. Ex: -0.1 Leave empty to use vanilla curve. You can also define in/out tangets and weights for each key like so: 0.4,0.2,1.1,2,0.4,0.6 (Check Keyframe declaration in unity documentation!)").Value;
			startingCredits = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Starting Credits", 60, "The amount of credits in the terminal at the start.").Value;
			startingQuota = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Starting Quota", 130, "The value of the first quota.").Value;
			onlyChangeCurve = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Only Change Curve", false, "Only change the randomizer curve and skip applying any other settings. You may want to toggle this if you have another mod changing these settings.").Value;
			Patch();
			Logger.LogInfo((object)"Tomatobird.YetAnotherQuotaSettingsMod v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Tomatobird.YetAnotherQuotaSettingsMod");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.YetAnotherQuotaSettingsMod";

		public const string PLUGIN_NAME = "YetAnotherQuotaSettingsMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace YetAnotherQuotaSettingsMod.Patches
{
	[HarmonyPatch(typeof(TimeOfDay))]
	public class TimeOfDayPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePostfix(TimeOfDay __instance)
		{
			if (!YetAnotherQuotaSettingsMod.onlyChangeCurve)
			{
				__instance.quotaVariables.startingQuota = YetAnotherQuotaSettingsMod.startingQuota;
				__instance.quotaVariables.deadlineDaysAmount = YetAnotherQuotaSettingsMod.deadlineDaysAmount;
				__instance.quotaVariables.increaseSteepness = YetAnotherQuotaSettingsMod.increaseSteepness;
				__instance.quotaVariables.startingCredits = YetAnotherQuotaSettingsMod.startingCredits;
				__instance.quotaVariables.startingQuota = YetAnotherQuotaSettingsMod.startingQuota;
			}
			if (!string.IsNullOrWhiteSpace(YetAnotherQuotaSettingsMod.randomizerCurve))
			{
				__instance.quotaVariables.randomizerCurve = CreateCurve(YetAnotherQuotaSettingsMod.randomizerCurve);
			}
		}

		private static AnimationCurve CreateCurve(string s)
		{
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			string[] array = s.Split(';');
			if (array.Length == 1 && float.TryParse(array[0], out var result))
			{
				return AnimationCurve.Constant(0f, 1f, result);
			}
			List<Keyframe> list = new List<Keyframe>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(",");
				if (array3.Length == 2)
				{
					string s2 = array3[0].Trim();
					string s3 = array3[1].Trim();
					if (float.TryParse(s2, out var result2) && float.TryParse(s3, out var result3))
					{
						list.Add(new Keyframe(result2, result3));
					}
				}
				else if (array3.Length == 6)
				{
					string s4 = array3[0].Trim();
					string s5 = array3[1].Trim();
					string s6 = array3[2].Trim();
					string s7 = array3[3].Trim();
					string s8 = array3[4].Trim();
					string s9 = array3[5].Trim();
					if (float.TryParse(s4, out var result4) && float.TryParse(s5, out var result5) && float.TryParse(s6, out var result6) && float.TryParse(s7, out var result7) && float.TryParse(s8, out var result8) && float.TryParse(s9, out var result9))
					{
						list.Add(new Keyframe(result4, result5, result6, result7, result8, result9));
					}
				}
			}
			return new AnimationCurve(list.ToArray());
		}
	}
}