Decompiled source of AdditionalSeerStations v1.0.0

AdditionalSeerStations.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.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AdditionalSeerStations")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AdditionalSeerStations")]
[assembly: AssemblyTitle("AdditionalSeerStations")]
[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 AdditionalSeerStations
{
	[BepInPlugin("acanthi.AdditionalSeerStations", "AdditionalSeerStations", "1.0.0")]
	public class AdditionalSeerStations : BaseUnityPlugin
	{
		public const string PluginGUID = "acanthi.AdditionalSeerStations";

		public const string PluginAuthor = "acanthi";

		public const string PluginName = "AdditionalSeerStations";

		public const string PluginVersion = "1.0.0";

		public ConfigEntry<int> extraSeers;

		private GameObject cachedPrefab;

		public void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			InitConfig();
			BazaarController.SetUpSeerStations += new hook_SetUpSeerStations(AddNewSeer);
		}

		private void AddNewSeer(orig_SetUpSeerStations orig, BazaarController self)
		{
			//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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			SceneExitController explicitTargetSceneExitController = ((Component)self.seerStations[0]).GetComponent<SeerStationController>().explicitTargetSceneExitController;
			Vector3[] array = (Vector3[])(object)new Vector3[2]
			{
				new Vector3(-135.5876f, -25.3888f, -17.5357f),
				new Vector3(-134.7071f, -25.3888f, -24.2924f)
			};
			Quaternion[] array2 = (Quaternion[])(object)new Quaternion[2]
			{
				Quaternion.Euler(0f, 88.5628f, 0f),
				Quaternion.Euler(0f, 75f, 0f)
			};
			for (int i = 0; i < extraSeers.Value && i < 2; i++)
			{
				GameObject val = AddNewSeer(array[i], array2[i]);
				SeerStationController component = val.GetComponent<SeerStationController>();
				component.explicitTargetSceneExitController = explicitTargetSceneExitController;
				NetworkServer.Spawn(val);
				Array.Resize(ref self.seerStations, self.seerStations.Length + 1);
				self.seerStations[self.seerStations.Length - 1] = component;
			}
			orig.Invoke(self);
		}

		private GameObject AddNewSeer(Vector3 location, Quaternion rotation)
		{
			//IL_0029: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			string seerStation_prefab = RoR2_Base_bazaar.SeerStation_prefab;
			if (cachedPrefab == null)
			{
				cachedPrefab = Addressables.LoadAssetAsync<GameObject>((object)seerStation_prefab).WaitForCompletion();
			}
			return Object.Instantiate<GameObject>(cachedPrefab, location, rotation);
		}

		private void InitConfig()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			extraSeers = ((BaseUnityPlugin)this).Config.Bind<int>("AdditionalSeerStations", "How Many Extra Seers", 2, new ConfigDescription("The amount of extra seers to add to the Bazaar.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), Array.Empty<object>()));
		}
	}
	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);
		}
	}
}