Decompiled source of AILevelMultiplier v1.0.0

AILevelMultiplier.dll

Decompiled 4 days 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.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UI;
using UnityEngine;
using WildSkies.Gameplay.AI;
using WildSkies.IslandExport;
using WildSkies.Service;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("AILevelMultiplier")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AILevelMultiplier")]
[assembly: AssemblyTitle("AILevelMultiplier")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AILevelMultiplier
{
	[BepInPlugin("AILevelMultiplier", "AILevelMultiplier", "1.0.0")]
	public class Plugin : BasePlugin
	{
		private class AILevelMultiplierSimpleChatCommands
		{
			public static string SetMultiplier(float value)
			{
				if (value <= 0f)
				{
					AILevelMultiplier_LevelMultiplier.Value = (float)((ConfigEntryBase)AILevelMultiplier_LevelMultiplier).DefaultValue;
				}
				else
				{
					AILevelMultiplier_LevelMultiplier.Value = value;
				}
				return $"AI Level Multiplier now set to {value}.";
			}
		}

		internal static ManualLogSource Log;

		internal static Harmony harmonyInstance;

		private static ConfigEntry<float> AILevelMultiplier_LevelMultiplier;

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("AILevelMultiplier");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			AILevelMultiplier_LevelMultiplier = ((BasePlugin)this).Config.Bind<float>("AILevelMultiplier", "LevelMultiplier", 0f, "AILevelMultiplier.LevelMultiplier");
			harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		public override bool Unload()
		{
			Harmony obj = harmonyInstance;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return true;
		}

		[HarmonyPatch(typeof(AILevelsService), "GetLevel", new Type[]
		{
			typeof(AIDefinition),
			typeof(int),
			typeof(Region),
			typeof(IslandDifficulty)
		})]
		[HarmonyPostfix]
		public static void AILevelsService_GetLevel(AILevelsService __instance, Region region, ref int __result)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (AILevelMultiplier_LevelMultiplier.Value <= 0f)
			{
				__result = __instance._regionInfoLookUp[region].RegionMin;
			}
			else
			{
				__result = (int)Math.Round((float)__result * AILevelMultiplier_LevelMultiplier.Value);
			}
		}

		[HarmonyPatch(typeof(HealthBar), "SetEnemyLevel")]
		[HarmonyPostfix]
		public static void HealthBar_SetEnemyLevel(HealthBar __instance, int level)
		{
			((TMP_Text)__instance._level).text = __instance.DisplayHealth.GetEntityLevel().ToString();
			((TMP_Text)__instance._level).autoSizeTextContainer = false;
			((TMP_Text)__instance._level).autoSizeTextContainer = true;
			((Component)((TMP_Text)__instance._level).transform).gameObject.SetActive(true);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AILevelMultiplier";

		public const string PLUGIN_NAME = "AILevelMultiplier";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}