Decompiled source of RenewableTrial v1.0.0

plugins/RenewableTrial.dll

Decompiled 13 hours ago
using System;
using System.Diagnostics;
using System.IO;
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 Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
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("RenewableTrial")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RenewableTrial")]
[assembly: AssemblyTitle("RenewableTrial")]
[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 RenewableTrial
{
	public static class Asset
	{
		public static AssetBundle mainBundle;

		public const string bundleName = "renewabletrialbundle";

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(typeof(RenewableTrialPlugin).Assembly.Location), "renewabletrialbundle".ToLower());

		public static void Init()
		{
			mainBundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Slendykray.RenewableTrial", "RenewableTrial", "1.0.0")]
	public class RenewableTrialPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Slendykray.RenewableTrial";

		public const string PluginAuthor = "Slendykray";

		public const string PluginName = "RenewableTrial";

		public const string PluginVersion = "1.0.0";

		public static DLC4TrialSelector selector;

		public static ConfigEntry<float> maxTime;

		public static ConfigEntry<float> timeAdded;

		public void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			Asset.Init();
			InitConfig();
			KarmaManager.ModifyKarma += new hook_ModifyKarma(KarmaManager_ModifyKarma);
			DLC4TrialSelector.Awake += new hook_Awake(DLC4TrialSelector_Awake);
		}

		private void InitConfig()
		{
			//IL_0065: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			Sprite modIcon = Asset.mainBundle.LoadAsset<Sprite>("icon.png");
			ModSettingsManager.SetModIcon(modIcon);
			maxTime = ((BaseUnityPlugin)this).Config.Bind<float>("RenewableTrial", "maxTime", 240f, "maximum time trials can have (in seconds)");
			timeAdded = ((BaseUnityPlugin)this).Config.Bind<float>("RenewableTrial", "timeAdded", 30f, "time added when receiving karma (in seconds)");
			ModSettingsManager.AddOption((BaseOption)new SliderOption(maxTime, new SliderConfig
			{
				min = 180f,
				max = 600f
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(timeAdded, new SliderConfig
			{
				min = 10f,
				max = 120f
			}));
		}

		private void DLC4TrialSelector_Awake(orig_Awake orig, DLC4TrialSelector self)
		{
			orig.Invoke(self);
			selector = self;
		}

		private void KarmaManager_ModifyKarma(orig_ModifyKarma orig, KarmaManager self, int amount)
		{
			orig.Invoke(self, amount);
			float network_trialTimerLeft = selector.Network_trialTimerLeft;
			float value = timeAdded.Value;
			float num = (network_trialTimerLeft += value);
			if (num > maxTime.Value)
			{
				num = maxTime.Value;
			}
			selector.SetRemainingTrialTimeServer(num);
		}
	}
}