Decompiled source of Lower Air Nodes v1.0.1

plugins/LowerAirNodes.dll

Decompiled 9 hours 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.Bootstrap;
using BepInEx.Configuration;
using CaeliImperium.Configs;
using LowerAirNodes.ModCompatibilities;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Navigation;
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("LowerAirNodes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LowerAirNodes")]
[assembly: AssemblyTitle("LowerAirNodes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 LowerAirNodes
{
	[Serializable]
	[BepInPlugin("com.brynzananas.lowerairnodes", "Lower Air Nodes", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class LowerAirNodesPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__SceneInfo_Awake;
		}

		public const string ModGuid = "com.brynzananas.lowerairnodes";

		public const string ModName = "Lower Air Nodes";

		public const string ModVer = "1.0.0";

		private static bool hooksSet;

		public static ConfigEntry<float> FlyingEnemiesAboveGround;

		public static ConfigEntry<float> FlyingEnemiesAboveGroundRaycastLength;

		public static LowerAirNodesPlugin instance { get; private set; }

		public static bool riskOfOptionsEnabled { get; private set; }

		public static bool caeliImperiumEnabled { get; private set; }

		public void Awake()
		{
			instance = this;
			riskOfOptionsEnabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
			caeliImperiumEnabled = Chainloader.PluginInfos.ContainsKey("com.brynzananas.caeliimperium");
			InitConfigs();
			SetHooks();
		}

		public void InitConfigs()
		{
			FlyingEnemiesAboveGround = CreateConfig("Main", "Node Distance", 8f, "Distance above the ground to place the air node");
			FlyingEnemiesAboveGroundRaycastLength = CreateConfig("Main", "Raycast Distance", 64f, "");
		}

		public static void SetHooks()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (!hooksSet)
			{
				hooksSet = true;
				object obj = <>O.<0>__SceneInfo_Awake;
				if (obj == null)
				{
					hook_Awake val = SceneInfo_Awake;
					<>O.<0>__SceneInfo_Awake = val;
					obj = (object)val;
				}
				SceneInfo.Awake += (hook_Awake)obj;
			}
		}

		public static void UnsetHooks()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (hooksSet)
			{
				hooksSet = false;
				object obj = <>O.<0>__SceneInfo_Awake;
				if (obj == null)
				{
					hook_Awake val = SceneInfo_Awake;
					<>O.<0>__SceneInfo_Awake = val;
					obj = (object)val;
				}
				SceneInfo.Awake -= (hook_Awake)obj;
			}
		}

		private static void SceneInfo_Awake(orig_Awake orig, SceneInfo self)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)self) || !Object.op_Implicit((Object)(object)self.airNodes) || (caeliImperiumEnabled && CaeliImperiumCompatibility.AlreadyLowering()))
			{
				return;
			}
			RaycastHit val = default(RaycastHit);
			for (int i = 0; i < self.airNodes.nodes.Length; i++)
			{
				ref Node reference = ref self.airNodes.nodes[i];
				if (Physics.Raycast(reference.position, Vector3.down, ref val, FlyingEnemiesAboveGroundRaycastLength.Value, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask)))
				{
					Vector3 val2 = ((RaycastHit)(ref val)).point + Vector3.up * FlyingEnemiesAboveGround.Value;
					if (!(val2.y >= reference.position.y))
					{
						reference.position = val2;
					}
				}
			}
		}

		public static ConfigEntry<T> CreateConfig<T>(string section, string key, T defaultValue, string description)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			ConfigDefinition val = new ConfigDefinition(section, key);
			ConfigDescription val2 = new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>());
			ConfigEntry<T> val3 = ((BaseUnityPlugin)instance).Config.Bind<T>(val, defaultValue, val2);
			if (riskOfOptionsEnabled)
			{
				RiskOfOptionsCompatability.AddConfig<ConfigEntry<T>>(val3);
			}
			return val3;
		}
	}
}
namespace LowerAirNodes.ModCompatibilities
{
	public static class CaeliImperiumCompatibility
	{
		public const string GUID = "com.brynzananas.caeliimperium";

		public static bool AlreadyLowering()
		{
			return CaeliImperiumConfigs.AlphaContent != null && CaeliImperiumConfigs.AlphaContent.Value;
		}
	}
	public static class RiskOfOptionsCompatability
	{
		public const string GUID = "com.rune580.riskofoptions";

		public static void AddConfig<T>(T config) where T : ConfigEntryBase
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			if (config is ConfigEntry<float>)
			{
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(config as ConfigEntry<float>));
			}
			else if (config is ConfigEntry<bool>)
			{
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(config as ConfigEntry<bool>));
			}
			else if (config is ConfigEntry<int>)
			{
				ModSettingsManager.AddOption((BaseOption)new IntFieldOption(config as ConfigEntry<int>));
			}
			else if (config is ConfigEntry<string>)
			{
				ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(config as ConfigEntry<string>));
			}
			else
			{
				ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)config));
			}
		}
	}
}