Decompiled source of ReactiveCartel v1.0.1

ReactiveCartel.dll

Decompiled 9 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using FishNet;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using ReactiveCartel;
using ReactiveCartel.Patches;
using S1API.Leveling;
using ScheduleOne.Cartel;
using ScheduleOne.DevUtilities;
using ScheduleOne.Map;
using ScheduleOne.Persistence;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "ReactiveCartel", "1.0.0", "Lumahex", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ReactiveCartel")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ReactiveCartel")]
[assembly: AssemblyTitle("ReactiveCartel")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 ReactiveCartel
{
	public class Core : MelonMod
	{
		private bool _initialized = false;

		public override void OnInitializeMelon()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((MelonBase)this).LoggerInstance.Msg("Reactive Cartel Initialized.");
			Harmony val = new Harmony("ReactiveCartel");
			val.PatchAll();
			MelonLogger.Msg("Harmony Patches Applied");
		}

		public override void OnUpdate()
		{
			if (!_initialized && ReactiveCartelState.TryInitialize())
			{
				_initialized = true;
			}
		}
	}
}
namespace ReactiveCartel.Systems
{
	public class RankScaling
	{
	}
}
namespace ReactiveCartel.Patches
{
	public static class ReactiveCartelState
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OnLoadComplete;
		}

		public static bool GameLoaded;

		public static bool TryInitialize()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if ((Object)(object)Singleton<LoadManager>.Instance == (Object)null)
			{
				return false;
			}
			UnityEvent onLoadComplete = Singleton<LoadManager>.Instance.onLoadComplete;
			object obj = <>O.<0>__OnLoadComplete;
			if (obj == null)
			{
				UnityAction val = OnLoadComplete;
				<>O.<0>__OnLoadComplete = val;
				obj = (object)val;
			}
			onLoadComplete.AddListener((UnityAction)obj);
			MelonLogger.Msg("[ReactiveCartel] Hooked LoadManager");
			return true;
		}

		private static void OnLoadComplete()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			GameLoaded = true;
			MelonLogger.Msg("[ReactiveCartel] Game fully loaded");
			if (InstanceFinder.IsServer)
			{
				CartelRegionActivities[] array = Object.FindObjectsOfType<CartelRegionActivities>();
				CartelRegionActivities[] array2 = array;
				foreach (CartelRegionActivities val in array2)
				{
					val.HoursUntilNextActivity = CartelRegionActivities.GetNewCooldown(val.Region);
					MelonLogger.Msg($"Recalculated {val.Region}: {val.HoursUntilNextActivity} hours");
				}
			}
		}
	}
	[HarmonyPatch(typeof(CartelRegionActivities), "GetNewCooldown")]
	public static class RegionalCooldownPatch
	{
		private static bool Prefix(EMapRegion region, ref int __result)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!ReactiveCartelState.GameLoaded)
			{
				return true;
			}
			if (!LevelManager.Exists)
			{
				return true;
			}
			FullRank currentRank = LevelManager.CurrentRank;
			int rankIndex = ((FullRank)(ref currentRank)).GetRankIndex();
			float num = 40f;
			float num2 = Mathf.Clamp01((float)rankIndex + 1f / num);
			float num3 = Mathf.Lerp(24f, 6f, num2);
			float num4 = Mathf.Lerp(48f, 12f, num2);
			__result = Mathf.RoundToInt(Random.Range(num3, num4));
			MelonLogger.Msg($"[ReactiveCartel] Region: {region} | RankIndex: {rankIndex} | Progress: {num2:F2} | Cooldown: {__result}h");
			return false;
		}
	}
	[HarmonyPatch(typeof(CartelRegionActivities), "GetNewCooldown")]
	public static class CooldownLoggingPatch
	{
		[HarmonyPostfix]
		public static void Postfix(int __result)
		{
			MelonLogger.Msg("[ReactiveCartel] COOLDOWN PATCH FIRED");
			MelonLogger.Msg("[ReactiveCartel] Regional cooldown: " + __result);
		}
	}
	[HarmonyPatch(typeof(CartelActivity), "Activate")]
	public static class ActivityLoggingPatch
	{
		[HarmonyPostfix]
		public unsafe static void Postfix(CartelActivity __instance, EMapRegion region)
		{
			MelonLogger.Msg("[ReactiveCartel] ACTIVITY PATCH FIRED");
			MelonLogger.Msg("[ReactiveCartel] Region + Activity selected: " + ((object)__instance)?.ToString() + ((object)(*(EMapRegion*)(&region))/*cast due to .constrained prefix*/).ToString());
		}
	}
}