Decompiled source of Exchange Changes v1.1.1

ExchangeChanges.dll

Decompiled 3 months ago
using System;
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.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Duplicator;
using EntityStates.Scrapper;
using On.EntityStates.Duplicator;
using On.RoR2;
using On.RoR2.EntityLogic;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.Components.Panel;
using RiskOfOptions.Options;
using RoR2;
using RoR2.EntityLogic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;

[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 = "")]
[assembly: AssemblyCompany("ExchangeChanges")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExchangeChanges")]
[assembly: AssemblyTitle("ExchangeChanges")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ExchangeChanges;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("FlyingComputer.ExchangeChanges", "ExchangeChanges", "1.1.1")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class ExchangeChanges : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_DropDroplet <>9__29_2;

		public static hook_CallDelayed <>9__29_4;

		internal void <Awake>b__29_2(orig_DropDroplet orig, Duplicating self)
		{
			orig.Invoke(self);
			if (NetworkServer.active && self.hasDroppedDroplet)
			{
				((EntityState)self).GetComponent<PurchaseInteraction>().Networkavailable = true;
			}
		}

		internal void <Awake>b__29_4(orig_CallDelayed orig, DelayedEvent self, float timer)
		{
			if (!((object)self).ToString().Contains("Duplicator"))
			{
				orig.Invoke(self, timer);
			}
		}
	}

	public const string PluginGUID = "FlyingComputer.ExchangeChanges";

	public const string PluginAuthor = "FlyingComputer";

	public const string PluginName = "ExchangeChanges";

	public const string PluginVersion = "1.1.1";

	private UnityAction ResetToDefault;

	public static ConfigEntry<float> printerDelay { get; set; }

	public static ConfigEntry<float> scrapperDelay { get; set; }

	public static ConfigEntry<float> chanceDelay { get; set; }

	public static ConfigEntry<float> mountainDelay { get; set; }

	public static ConfigEntry<float> bazaarDelay { get; set; }

	public static ConfigEntry<float> cleanseDelay { get; set; }

	public void Awake()
	{
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Expected O, but got Unknown
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Expected O, but got Unknown
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Expected O, but got Unknown
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Expected O, but got Unknown
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Expected O, but got Unknown
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Expected O, but got Unknown
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Expected O, but got Unknown
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Expected O, but got Unknown
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Expected O, but got Unknown
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Expected O, but got Unknown
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Expected O, but got Unknown
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Expected O, but got Unknown
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Expected O, but got Unknown
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Expected O, but got Unknown
		ConfigEntry<float> printerDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Delay Settings", "Printer Delay", 0.6f, "Printer delay in seconds");
		ConfigEntry<float> scrapperDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Delay Settings", "Scrapper Delay", 0.3f, "Scrapper startup delay in seconds");
		ConfigEntry<float> scrapperItemDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Delay Settings", "Scrapper Item Delay", 0.3f, "Scrapper delay between item drops in seconds");
		ConfigEntry<float> chanceDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Delay Settings", "Shrine of Chance Delay", 0.4f, "Shrine of Chance delay in seconds");
		ConfigEntry<float> mountainDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Delay Settings", "Shrine of the Mountain Delay", 0.4f, "Shrine of the Mountain delay in seconds, for those with mods enabling more than one use");
		ConfigEntry<float> bazaarDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Delay Settings", "Bazaar trade Delay", 0.5f, "Bazaar item trade delay in seconds");
		ConfigEntry<float> cleanseDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Delay Settings", "Cleansing Pool Delay", 0.5f, "Cleansing Pool delay in seconds");
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(printerDelay));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(scrapperDelay));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(scrapperItemDelay));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(chanceDelay));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(mountainDelay));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(bazaarDelay));
		ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(cleanseDelay));
		ResetToDefault = (UnityAction)Delegate.Combine((Delegate?)(object)ResetToDefault, (Delegate?)(UnityAction)delegate
		{
			ModOptionPanelController val3 = Object.FindObjectOfType<ModOptionPanelController>();
			printerDelay.Value = 0.6f;
			scrapperDelay.Value = 0.3f;
			scrapperItemDelay.Value = 0.3f;
			chanceDelay.Value = 0.4f;
			mountainDelay.Value = 0.4f;
			bazaarDelay.Value = 0.5f;
			cleanseDelay.Value = 0.5f;
			val3.RevertChanges();
		});
		ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Reset delay settings to default:", "Delay Settings", "", "RESET", ResetToDefault));
		ModSettingsManager.SetModDescription("Adjust the speed of repeatable interactions");
		Stage.Start += (hook_Start)delegate(orig_Start orig, Stage self)
		{
			Reflection.SetFieldValue<float>(typeof(Duplicating), "initialDelayDuration", printerDelay.Value / 2f);
			Reflection.SetFieldValue<float>(typeof(Duplicating), "timeBetweenStartAndDropDroplet", printerDelay.Value / 2f);
			Reflection.SetFieldValue<float>(typeof(WaitToBeginScrapping), "duration", scrapperDelay.Value / 2f);
			Reflection.SetFieldValue<float>(typeof(Scrapping), "duration", scrapperDelay.Value / 2f);
			Reflection.SetFieldValue<float>(typeof(ScrappingToIdle), "duration", scrapperItemDelay.Value * 2f);
			return orig.Invoke(self);
		};
		object obj = <>c.<>9__29_2;
		if (obj == null)
		{
			hook_DropDroplet val = delegate(orig_DropDroplet orig, Duplicating self)
			{
				orig.Invoke(self);
				if (NetworkServer.active && self.hasDroppedDroplet)
				{
					((EntityState)self).GetComponent<PurchaseInteraction>().Networkavailable = true;
				}
			};
			<>c.<>9__29_2 = val;
			obj = (object)val;
		}
		Duplicating.DropDroplet += (hook_DropDroplet)obj;
		PurchaseInteraction.OnInteractionBegin += (hook_OnInteractionBegin)delegate(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor interactor)
		{
			orig.Invoke(self, interactor);
			if (self.displayNameToken == "SHRINE_BOSS_NAME")
			{
				((Component)self).GetComponent<ShrineBossBehavior>().refreshTimer = mountainDelay.Value;
			}
			if (self.displayNameToken == "SHRINE_CHANCE_NAME")
			{
				((Component)self).GetComponent<ShrineChanceBehavior>().refreshTimer = chanceDelay.Value;
			}
		};
		object obj2 = <>c.<>9__29_4;
		if (obj2 == null)
		{
			hook_CallDelayed val2 = delegate(orig_CallDelayed orig, DelayedEvent self, float timer)
			{
				if (!((object)self).ToString().Contains("Duplicator"))
				{
					orig.Invoke(self, timer);
				}
			};
			<>c.<>9__29_4 = val2;
			obj2 = (object)val2;
		}
		DelayedEvent.CallDelayed += (hook_CallDelayed)obj2;
		TimerQueue.CreateTimer += (hook_CreateTimer)delegate(orig_CreateTimer orig, TimerQueue self, float time, Action action)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (action.Target.ToString().Contains("LunarCauldron"))
			{
				return orig.Invoke(self, bazaarDelay.Value, action);
			}
			return action.Target.ToString().Contains("ShrineCleanse") ? orig.Invoke(self, cleanseDelay.Value, action) : orig.Invoke(self, time, action);
		};
	}
}
internal static class Log
{
	internal static ManualLogSource _logSource;

	internal static void Init(ManualLogSource logSource)
	{
		_logSource = logSource;
	}

	internal static void LogDebug(object data)
	{
		_logSource.LogDebug(data);
	}

	internal static void LogError(object data)
	{
		_logSource.LogError(data);
	}

	internal static void LogFatal(object data)
	{
		_logSource.LogFatal(data);
	}

	internal static void LogInfo(object data)
	{
		_logSource.LogInfo(data);
	}

	internal static void LogMessage(object data)
	{
		_logSource.LogMessage(data);
	}

	internal static void LogWarning(object data)
	{
		_logSource.LogWarning(data);
	}
}