Decompiled source of SafeTravelsInSkybox v2.0.1

SafeTravelsInSkybox.dll

Decompiled 2 weeks 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 UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[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("SafeTravelsInSkybox")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+23ea7e10894255552568fa9c678395df455738b0")]
[assembly: AssemblyProduct("SafeTravelsInSkybox")]
[assembly: AssemblyTitle("SafeTravelsInSkybox")]
[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 SafeTravelsInSkybox
{
	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);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("swuff.SafeTravelsInSkybox", "SafeTravelsInSkybox", "2.0.1")]
	public class SafeTravelsInSkyboxPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "swuff.SafeTravelsInSkybox";

		public const string PluginAuthor = "swuff";

		public const string PluginName = "SafeTravelsInSkybox";

		public const string PluginVersion = "2.0.1";

		public static GameObject newCaptainAirstrikeAimPrefab;

		public static GameObject currentShipPrefab;

		public static ConfigEntry<bool> UES { get; set; }

		public static ConfigEntry<bool> All { get; set; }

		public static ConfigEntry<bool> UseContactLightEverywhere { get; set; }

		[ClientRpc]
		public void RpcSpawnShip(string currScene, bool isUES, bool captainPresent)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0729: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0872: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_083d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0842: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0902: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0969: Unknown result type (might be due to invalid IL or missing references)
			//IL_096e: Unknown result type (might be due to invalid IL or missing references)
			//IL_096f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0975: Unknown result type (might be due to invalid IL or missing references)
			//IL_097a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0add: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be6: Unknown result type (might be due to invalid IL or missing references)
			//IL_080d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Unknown result type (might be due to invalid IL or missing references)
			//IL_092d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0932: Unknown result type (might be due to invalid IL or missing references)
			//IL_0933: Unknown result type (might be due to invalid IL or missing references)
			//IL_0939: Unknown result type (might be due to invalid IL or missing references)
			//IL_093e: Unknown result type (might be due to invalid IL or missing references)
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_076b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			if (!captainPresent && (!isUES || !UES.Value) && !All.Value)
			{
				return;
			}
			Vector3 zero = Vector3.zero;
			Quaternion val = Quaternion.Euler(-90f, 0f, 0f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(300f, 300f, 300f);
			bool flag = true;
			switch (currScene)
			{
			case "golemplains":
				((Vector3)(ref zero))..ctor(1093f, 2348f, 1487f);
				val = Quaternion.Euler(354.442f, 98.19998f, 78.091f);
				break;
			case "golemplains2":
				((Vector3)(ref zero))..ctor(1093f, 2348f, 1487f);
				val = Quaternion.Euler(354.442f, 98.19998f, 78.091f);
				break;
			case "blackbeach":
				((Vector3)(ref zero))..ctor(1093f, 1748f, 887f);
				val = Quaternion.Euler(0f, 90f, 90f);
				break;
			case "blackbeach2":
				((Vector3)(ref zero))..ctor(500f, 1848f, 1287f);
				val = Quaternion.Euler(354.442f, 98.19998f, 78.091f);
				break;
			case "goolake":
				((Vector3)(ref zero))..ctor(2093f, 2348f, 1487f);
				val = Quaternion.Euler(354.442f, 98.19998f, 78.091f);
				val2 *= 1.5f;
				break;
			case "foggyswamp":
				((Vector3)(ref zero))..ctor(1000f, 1300f, -900f);
				val = Quaternion.Euler(354.442f, 115f, 90f);
				break;
			case "frozenwall":
				((Vector3)(ref zero))..ctor(-2000f, 1800f, -400f);
				val = Quaternion.Euler(354.442f, 200f, 90f);
				break;
			case "wispgraveyard":
				((Vector3)(ref zero))..ctor(1293f, 1648f, -1487f);
				val = Quaternion.Euler(354.442f, 80f, 78.091f);
				break;
			case "shipgraveyard":
				((Vector3)(ref zero))..ctor(0f, 1000f, -900f);
				val = Quaternion.Euler(354.442f, 120f, 78.091f);
				val2 *= 0.6f;
				break;
			case "rootjungle":
				((Vector3)(ref zero))..ctor(400f, 2348f, 0f);
				val = Quaternion.Euler(354.442f, 98.19998f, 78.091f);
				val2 *= 0.6f;
				break;
			case "skymeadow":
				((Vector3)(ref zero))..ctor(1600f, 1800f, 0f);
				val = Quaternion.Euler(354.442f, 140f, 78.091f);
				val2 *= 0.6f;
				break;
			case "snowyforest":
				((Vector3)(ref zero))..ctor(1300f, 1100f, 300f);
				val = Quaternion.Euler(0f, 90f, 90f);
				val2 *= 0.7f;
				break;
			case "ancientloft":
				((Vector3)(ref zero))..ctor(600f, 1800f, 1487f);
				val = Quaternion.Euler(354.442f, 98.19998f, 78.091f);
				val2 *= 0.6f;
				break;
			case "sulfurpools":
				((Vector3)(ref zero))..ctor(2093f, 2348f, 1487f);
				val = Quaternion.Euler(354.442f, 330f, 290f);
				break;
			case "moon2":
				((Vector3)(ref zero))..ctor(2093f, 2348f, 1487f);
				val = Quaternion.Euler(354.442f, -4.2f, 290f);
				break;
			case "FBLScene":
				((Vector3)(ref zero))..ctor(300f, 2348f, 2400f);
				val = Quaternion.Euler(354.442f, 240f, 70f);
				break;
			case "slumberingsatellite":
				((Vector3)(ref zero))..ctor(2093f, 2348f, 1487f);
				val = Quaternion.Euler(354.442f, 310f, 290f);
				break;
			case "drybasin":
				((Vector3)(ref zero))..ctor(600f, 1400f, 800f);
				val = Quaternion.Euler(354.442f, 355f, 290f);
				break;
			case "lakes":
				((Vector3)(ref zero))..ctor(0f, 2048f, -2000f);
				val = Quaternion.Euler(354.442f, 90f, 270f);
				break;
			case "lakesnight":
				((Vector3)(ref zero))..ctor(0f, 2048f, -2000f);
				val = Quaternion.Euler(354.442f, 90f, 270f);
				break;
			case "habitat":
				((Vector3)(ref zero))..ctor(-800f, 320f, 600f);
				val = Quaternion.Euler(354f, 20f, 270f);
				val2 *= 0.5f;
				break;
			case "habitatfall":
				((Vector3)(ref zero))..ctor(-800f, 320f, 600f);
				val = Quaternion.Euler(354f, 20f, 270f);
				val2 *= 0.5f;
				break;
			case "village":
				((Vector3)(ref zero))..ctor(1200f, 2000f, 500f);
				val = Quaternion.Euler(354.442f, 330f, 290f);
				val2 *= 0.66667f;
				break;
			case "villagenight":
				((Vector3)(ref zero))..ctor(1200f, 2000f, 500f);
				val = Quaternion.Euler(354.442f, 330f, 290f);
				val2 *= 0.66667f;
				break;
			case "helminthroost":
				((Vector3)(ref zero))..ctor(-180f, 3200f, 900f);
				val = Quaternion.Euler(3f, 4.27f, 240f);
				break;
			case "meridian":
				((Vector3)(ref zero))..ctor(1000f, 1200f, -800f);
				val = Quaternion.Euler(0f, 180f, 90f);
				break;
			case "conduitcanyon":
				((Vector3)(ref zero))..ctor(2000f, 1500f, -400f);
				val = Quaternion.Euler(354.442f, 40f, 290f);
				break;
			case "ironalluvium":
				((Vector3)(ref zero))..ctor(2000f, 2000f, 2487f);
				val = Quaternion.Euler(354.442f, 30f, 240f);
				break;
			case "ironalluvium2":
				((Vector3)(ref zero))..ctor(2000f, 2000f, 2487f);
				val = Quaternion.Euler(354.442f, 30f, 240f);
				break;
			case "nest":
				((Vector3)(ref zero))..ctor(0f, 1248f, 2000f);
				val = Quaternion.Euler(354.442f, 40f, 240f);
				break;
			case "repurposedcrater":
				((Vector3)(ref zero))..ctor(0f, 2348f, 1487f);
				val = Quaternion.Euler(354.442f, 330f, 290f);
				break;
			default:
				val2 = Vector3.zero;
				flag = false;
				break;
			}
			if (flag)
			{
				if (UseContactLightEverywhere.Value)
				{
					val2 *= 0.5f;
					val = Quaternion.Euler(val.x - 90f, val.y - 90f, val.z - 90f);
				}
				GameObject val3 = (UseContactLightEverywhere.Value ? Addressables.LoadAssetAsync<GameObject>((object)"1b803559c64dc3643ab7b625b9d5ca29").WaitForCompletion() : Addressables.LoadAssetAsync<GameObject>((object)"72a1f55518991ff45977f5157c6ebe03").WaitForCompletion());
				GameObject val4 = Object.Instantiate<GameObject>(val3, zero, val);
				val4.transform.localScale = val2;
				currentShipPrefab = val4;
			}
			else
			{
				currentShipPrefab = null;
			}
		}

		public void Awake()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			UES = ((BaseUnityPlugin)this).Config.Bind<bool>("UES Safe Travels", "Enable for all UES-oriented survivors?", false, "Deploys the UES Safe Travels to support any survivors which deploy from a drop pod or shipping container.");
			All = ((BaseUnityPlugin)this).Config.Bind<bool>("UES Safe Travels", "Enable for all survivors?", false, "Deploys the UES Safe Travels to support every survivor unconditionally.");
			UseContactLightEverywhere = ((BaseUnityPlugin)this).Config.Bind<bool>("UES Safe Travels : Replacement", "Use UES Contact Light replacement?", false, "Replaces the UES Safe Travels's model with that of the UES Contact Light from Risk of Rain 1/Returns.");
			SceneDirector.Start += new hook_Start(SceneDirector_Start);
		}

		private void SceneDirector_Start(orig_Start orig, SceneDirector self)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			bool isUES = false;
			bool captainPresent = false;
			foreach (NetworkUser instances in NetworkUser.instancesList)
			{
				if (instances.bodyIndexPreference == BodyCatalog.FindBodyIndex(Survivors.Captain.bodyPrefab))
				{
					captainPresent = true;
				}
				if ((Object)(object)BodyCatalog.GetBodyPrefab(instances.bodyIndexPreference).GetComponent<CharacterBody>().preferredPodPrefab == (Object)(object)Survivors.Commando.bodyPrefab.GetComponent<CharacterBody>().preferredPodPrefab || (Object)(object)BodyCatalog.GetBodyPrefab(instances.bodyIndexPreference).GetComponent<CharacterBody>().preferredPodPrefab == (Object)(object)Survivors.Toolbot.bodyPrefab.GetComponent<CharacterBody>().preferredPodPrefab)
				{
					isUES = true;
				}
			}
			Scene activeScene = SceneManager.GetActiveScene();
			RpcSpawnShip(((Scene)(ref activeScene)).name, isUES, captainPresent);
			orig.Invoke(self);
		}
	}
}