Decompiled source of LocationsOfPrecipitation v1.2.1

LocationsOfPrecipitation.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using HG.Reflection;
using RoR2;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LOP;

[ExecuteAlways]
public class AddressableInjector : MonoBehaviour
{
	[Tooltip("The address used for injecting")]
	public string address;

	[NonSerialized]
	private Object _asset;

	[Tooltip("The component that will be injected")]
	[SerializeField]
	private Component targetComponent;

	[Tooltip("The member info that'll be injected")]
	[SerializeField]
	private string targetMemberInfoName;

	private MemberInfo cachedMemberInfo;

	public Object Asset
	{
		get
		{
			return _asset;
		}
		private set
		{
			_asset = value;
		}
	}

	private void OnEnable()
	{
		Refresh();
	}

	public void Refresh()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrWhiteSpace(address) || string.IsNullOrEmpty(address) || !Object.op_Implicit((Object)(object)targetComponent) || string.IsNullOrEmpty(targetMemberInfoName) || string.IsNullOrWhiteSpace(targetMemberInfoName))
		{
			return;
		}
		MemberInfo memberInfo = GetMemberInfo();
		if (!(memberInfo == null))
		{
			Object val = Addressables.LoadAssetAsync<Object>((object)address).WaitForCompletion();
			if (Object.op_Implicit(val))
			{
				Asset = val;
				Asset.hideFlags = (HideFlags)28;
				Inject(memberInfo);
			}
		}
	}

	private void Inject(MemberInfo memberInfo)
	{
		if (!(memberInfo is PropertyInfo propertyInfo2))
		{
			if (memberInfo is FieldInfo fieldInfo2)
			{
				InjectFieldInfo(fieldInfo2);
			}
		}
		else
		{
			InjectPropertyInfo(propertyInfo2);
		}
		void InjectFieldInfo(FieldInfo fieldInfo)
		{
			try
			{
				fieldInfo.SetValue(targetComponent, Asset);
			}
			catch (Exception data2)
			{
				LOPLog.Error(data2);
			}
		}
		void InjectPropertyInfo(PropertyInfo propertyInfo)
		{
			try
			{
				propertyInfo.SetValue(targetComponent, Asset);
			}
			catch (Exception data)
			{
				LOPLog.Error(data);
			}
		}
	}

	private MemberInfo GetMemberInfo()
	{
		if ((cachedMemberInfo == null || "(" + cachedMemberInfo.DeclaringType.Name + ") " + cachedMemberInfo.Name != targetMemberInfoName) && Object.op_Implicit((Object)(object)targetComponent))
		{
			cachedMemberInfo = ((object)targetComponent).GetType().GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).Where(delegate(MemberInfo m)
			{
				string name = m.GetType().Name;
				return name.Contains("Property") || name.Contains("Field");
			})
				.FirstOrDefault((MemberInfo m) => "(" + m.DeclaringType.Name + ") " + m.Name == targetMemberInfoName);
		}
		return cachedMemberInfo;
	}
}
[ExecuteAlways]
public class CameraInstantiator : MonoBehaviour
{
	public const string CAMERA_ADDRESS = "RoR2/Base/Core/Main Camera.prefab";

	[NonSerialized]
	private GameObject _cameraInstance;

	public GameObject CameraInstance
	{
		get
		{
			return _cameraInstance;
		}
		private set
		{
			_cameraInstance = value;
		}
	}

	private void OnEnable()
	{
		Refresh();
	}

	private void OnDisable()
	{
		LOPUtil.DestroyImmediateSafe((Object)(object)CameraInstance, allowDestroyingAssets: true);
	}

	public void Refresh()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		if (Application.isPlaying && !Application.isEditor)
		{
			LOPLog.Fatal($"Lingering camera injector in {((Component)this).gameObject}, Ensure that these scripts are NOT present on finalized builds!!!");
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		if (Object.op_Implicit((Object)(object)CameraInstance))
		{
			LOPUtil.DestroyImmediateSafe((Object)(object)CameraInstance, allowDestroyingAssets: true);
		}
		GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Core/Main Camera.prefab").WaitForCompletion();
		CameraInstance = Object.Instantiate<GameObject>(val, ((Component)this).transform);
		((Object)CameraInstance).name = "[EDITOR ONLY] " + ((Object)CameraInstance).name;
		GameObject cameraInstance = CameraInstance;
		((Object)cameraInstance).hideFlags = (HideFlags)(((Object)cameraInstance).hideFlags | 0x1C);
		Transform[] componentsInChildren = CameraInstance.GetComponentsInChildren<Transform>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Object)((Component)componentsInChildren[i]).gameObject).hideFlags = (HideFlags)(((Object)CameraInstance).hideFlags | 1);
		}
		GameObject cameraInstance2 = CameraInstance;
		((Object)cameraInstance2).hideFlags = (HideFlags)(((Object)cameraInstance2).hideFlags & -2);
	}
}
public static class Constants
{
	public static class AssetGUIDS
	{
		public enum Expansion
		{
			DLC1 = 1,
			DLC2,
			DLC3
		}

		public static string accessNodeGUID = "383d1a1eefe41db4eb8708719f86fc03";

		public static string iscHardwareProgPortalGUID = "c4e7a9ed6153edf488cf434d843311f5";

		public static string iscHardwareProgPortalHauntGUID = "7c01731f4ba8cb548af2a35bce9105d3";

		public static string iscSolusShopPortalGUID = "07fc379a8d5d3c44c9211730bf4e1572";

		public static string cscSolusAmalgamator = "14bf22df446f37549aa65eb724c1ddda";

		public static string dlc1ExpansionGUID = "d4f30c23b971a9b428e2796dc04ae099";

		public static string dlc2ExpansionGUID = "851f234056d389b42822523d1be6a167";

		public static string dlc3ExpansionGUID = "234e83997deed274291470be69e7662e";

		public static string GetVanillaExpansion(Expansion expansion)
		{
			switch (expansion)
			{
			case Expansion.DLC1:
				return dlc1ExpansionGUID;
			case Expansion.DLC2:
				return dlc1ExpansionGUID;
			case Expansion.DLC3:
				return dlc3ExpansionGUID;
			default:
				LOPLog.Error("Invalid Expansion provided.");
				return null;
			}
		}
	}
}
[ExecuteAlways]
public class InjectExpansion : MonoBehaviour
{
}
[ExecuteAlways]
public class InstantiateAddressablePrefab : MonoBehaviour
{
	[Tooltip("The address to use to load the prefab")]
	[SerializeField]
	private string address;

	[Tooltip("When the prefab is instantiated, and this is true, the prefab's position and rotation will be set to 0")]
	[SerializeField]
	private bool setPositionAndRotationToZero = true;

	[Tooltip("setPositionAndRotationToZero would work relative to it's parent")]
	[SerializeField]
	private bool useLocalPositionAndRotation = true;

	[Tooltip("Wether the Refresh method will be called in the editor")]
	[SerializeField]
	private bool refreshInEditor = true;

	[SerializeField]
	[HideInInspector]
	private bool hasNetworkIdentity;

	[NonSerialized]
	private GameObject instance;

	public GameObject Instance => instance;

	private void OnEnable()
	{
		Refresh();
	}

	private void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)instance))
		{
			LOPUtil.DestroyImmediateSafe((Object)(object)instance, allowDestroyingAssets: true);
		}
	}

	public void Refresh()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		if (Application.isEditor && !refreshInEditor)
		{
			return;
		}
		if (Object.op_Implicit((Object)(object)instance))
		{
			LOPUtil.DestroyImmediateSafe((Object)(object)instance, allowDestroyingAssets: true);
		}
		if (string.IsNullOrWhiteSpace(address) || string.IsNullOrEmpty(address))
		{
			LOPLog.Warning($"Invalid address in {this}, address is null, empty, or white space");
			return;
		}
		GameObject val = Addressables.LoadAssetAsync<GameObject>((object)address).WaitForCompletion();
		hasNetworkIdentity = Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>());
		if (hasNetworkIdentity && !Application.isEditor)
		{
			if (NetworkServer.active)
			{
				instance = Object.Instantiate<GameObject>(val, ((Component)this).transform);
				NetworkServer.Spawn(instance);
			}
		}
		else
		{
			instance = Object.Instantiate<GameObject>(val, ((Component)this).transform);
		}
		if (!Object.op_Implicit((Object)(object)instance))
		{
			return;
		}
		GameObject obj = instance;
		((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x1C);
		Transform[] componentsInChildren = instance.GetComponentsInChildren<Transform>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Object)((Component)componentsInChildren[i]).gameObject).hideFlags = ((Object)instance).hideFlags;
		}
		if (setPositionAndRotationToZero)
		{
			Transform transform = instance.transform;
			if (useLocalPositionAndRotation)
			{
				transform.localPosition = Vector3.zero;
				transform.localRotation = Quaternion.identity;
			}
			else
			{
				transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
			}
		}
	}
}
[ExecuteAlways]
[RequireComponent(typeof(JumpVolume))]
public class InstantiateGeyserPrefab : MonoBehaviour
{
	public enum GeyserType
	{
		Default,
		Ambry,
		Moon,
		Aphelian,
		Siphoned,
		Void,
		Fan,
		Shroom,
		Meridian
	}

	[Tooltip("The prefab used for the geyser")]
	[SerializeField]
	public GeyserType geyserType;

	[Tooltip("When the prefab is instantiated, and this is true, the prefab's position and rotation will be set to 0")]
	[SerializeField]
	private bool setPositionAndRotationToZero = true;

	[Tooltip("setPositionAndRotationToZero would work relative to it's parent")]
	[SerializeField]
	private bool useLocalPositionAndRotation = true;

	[Tooltip("Wether the Refresh method will be called in the editor")]
	[SerializeField]
	private bool refreshInEditor = true;

	[Tooltip("Wether the sound string remains the same as the original instance")]
	[SerializeField]
	private bool conserveSoundString;

	[HideInInspector]
	public bool gateToggleOnPurchase;

	[HideInInspector]
	public string gateToEnableWhenPurchased;

	[HideInInspector]
	public string gateToDisableWhenPurchased;

	[SerializeField]
	[HideInInspector]
	private bool hasNetworkIdentity;

	private string address;

	[NonSerialized]
	private GameObject instance;

	public GameObject Instance => instance;

	private void OnEnable()
	{
		Refresh();
	}

	private void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)instance))
		{
			LOPUtil.DestroyImmediateSafe((Object)(object)instance);
		}
	}

	public void Refresh()
	{
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		if (Application.isEditor && !refreshInEditor)
		{
			return;
		}
		if (Object.op_Implicit((Object)(object)instance))
		{
			LOPUtil.DestroyImmediateSafe((Object)(object)instance);
		}
		switch ((int)geyserType)
		{
		case 0:
			address = "RoR2/Base/Common/Props/Geyser.prefab";
			break;
		case 1:
			address = "RoR2/Base/artifactworld/AWGeyser.prefab";
			break;
		case 2:
			address = "RoR2/Base/moon/MoonGeyser.prefab";
			break;
		case 3:
			address = "RoR2/DLC1/ancientloft/AL_Geyser.prefab";
			break;
		case 4:
			address = "RoR2/DLC1/snowyforest/SFGeyser.prefab";
			break;
		case 5:
			address = "RoR2/DLC1/voidstage/mdlVoidGravityGeyser.prefab";
			break;
		case 6:
			address = "RoR2/Base/frozenwall/FW_HumanFan.prefab";
			break;
		case 7:
			address = "RoR2/Base/rootjungle/RJ_BounceShroom.prefab";
			break;
		case 8:
			address = "RoR2/DLC2/meridian/PMLaunchPad.prefab";
			break;
		case 9:
			address = "RoR2/DLC2/lakes/Assets/TLJumpPad.prefab";
			break;
		case 10:
			address = "RoR2/DLC2/helminthroost/Assets/HRLaunchPad.prefab";
			break;
		default:
			LOPLog.Error($"This isn't supposed to print in {this}. Geyser Type is invalid.");
			return;
		}
		GameObject val = Addressables.LoadAssetAsync<GameObject>((object)address).WaitForCompletion();
		instance = Object.Instantiate<GameObject>(val, ((Component)this).transform);
		JumpVolume component = ((Component)this).gameObject.GetComponent<JumpVolume>();
		JumpVolume componentInChildren = instance.GetComponentInChildren<JumpVolume>(true);
		if (Object.op_Implicit((Object)(object)component.targetElevationTransform))
		{
			componentInChildren.targetElevationTransform = component.targetElevationTransform;
		}
		else
		{
			LOPLog.Warning($"Target elevation transform on {this} is invalid.");
		}
		componentInChildren.jumpVelocity = component.jumpVelocity;
		componentInChildren.time = component.time;
		if (!conserveSoundString)
		{
			if (string.IsNullOrEmpty(component.jumpSoundString))
			{
				LOPLog.Warning($"Jump sound string is empty on {this}. This will result in silence for your geyser.");
			}
			componentInChildren.jumpSoundString = component.jumpSoundString;
		}
		componentInChildren.onJump = component.onJump;
		if (geyserType == GeyserType.Fan && gateToggleOnPurchase)
		{
			GateStateSetter obj = ((Component)componentInChildren).gameObject.AddComponent<GateStateSetter>();
			obj.gateToEnableWhenEnabled = gateToEnableWhenPurchased;
			obj.gateToDisableWhenEnabled = gateToDisableWhenPurchased;
		}
		((Behaviour)component).enabled = false;
		GameObject obj2 = instance;
		((Object)obj2).hideFlags = (HideFlags)(((Object)obj2).hideFlags | 0x1C);
		Transform[] componentsInChildren = instance.GetComponentsInChildren<Transform>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Object)((Component)componentsInChildren[i]).gameObject).hideFlags = ((Object)instance).hideFlags;
		}
		if (setPositionAndRotationToZero)
		{
			Transform transform = instance.transform;
			if (useLocalPositionAndRotation)
			{
				transform.localPosition = Vector3.zero;
				transform.localRotation = Quaternion.identity;
			}
			else
			{
				transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
			}
		}
	}
}
[RequireComponent(typeof(VelocityRandomOnStart))]
public class InstantiateLogbookPrefab : MonoBehaviour
{
	[Tooltip("The unlock that triggers when the prefab is picked up.")]
	[SerializeField]
	private UnlockableDef unlockableDef;

	[Tooltip("The token for the text that appears when the prefab is picked up.")]
	[SerializeField]
	private string displayNameToken;

	[Tooltip("Turns on gravity for the pickup.")]
	[SerializeField]
	private bool enableGravity;

	private static Mesh cubeMesh;

	[NonSerialized]
	private GameObject instance;

	public GameObject Instance => instance;

	private void OnEnable()
	{
		Refresh();
	}

	private void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)instance))
		{
			Object.Destroy((Object)(object)instance);
		}
	}

	public void OnDrawGizmos()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		cubeMesh = Resources.GetBuiltinResource<Mesh>("Cube.fbx");
		Transform transform = ((Component)this).gameObject.transform;
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(1.16f, 0.43f, 1.39f);
		Color color = (Gizmos.color = new Color(0.7255f, 0.4314f, 1f));
		Gizmos.DrawWireMesh(cubeMesh, transform.position, transform.rotation, val);
		GUI.color = color;
	}

	public void Refresh()
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)instance))
		{
			Object.Destroy((Object)(object)instance);
		}
		if (!Object.op_Implicit((Object)(object)unlockableDef))
		{
			LOPLog.Warning($"No unlockableDef in {this}. Cancelling instantiation.");
			return;
		}
		if (string.IsNullOrEmpty(displayNameToken) || string.IsNullOrWhiteSpace(displayNameToken))
		{
			LOPLog.Warning($"Invalid displayNameToken in {this}, displayNameToken is null, empty, or white space. Cancelling instantiation.");
			return;
		}
		GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/LogPickup.prefab").WaitForCompletion();
		if (NetworkServer.active)
		{
			instance = Object.Instantiate<GameObject>(val, ((Component)this).transform);
			NetworkServer.Spawn(instance);
		}
		Transform transform = instance.transform;
		transform.localPosition = Vector3.zero;
		transform.localRotation = Quaternion.identity;
		VelocityRandomOnStart component = ((Component)this).gameObject.GetComponent<VelocityRandomOnStart>();
		VelocityRandomOnStart component2 = instance.GetComponent<VelocityRandomOnStart>();
		component2.minSpeed = component.minSpeed;
		component2.maxSpeed = component.maxSpeed;
		component2.baseDirection = component.baseDirection;
		component2.localDirection = component.localDirection;
		component2.directionMode = component.directionMode;
		component2.coneAngle = component.coneAngle;
		component2.minAngularSpeed = component.minAngularSpeed;
		component2.maxAngularSpeed = component.maxAngularSpeed;
		((Behaviour)component).enabled = false;
		instance.GetComponent<Rigidbody>().useGravity = enableGravity;
		UnlockPickup componentInChildren = instance.GetComponentInChildren<UnlockPickup>();
		componentInChildren.displayNameToken = displayNameToken;
		componentInChildren.unlockableDef = unlockableDef;
	}
}
[BepInPlugin("JaceDaDorito.LocationsOfPrecipitation", "LocationsOfPrecipitation", "1.1.2")]
public class LocationsOfPrecipitation : BaseUnityPlugin
{
	public const string Author = "JaceDaDorito";

	public const string Name = "LocationsOfPrecipitation";

	public const string Version = "1.1.2";

	public const string GUID = "JaceDaDorito.LocationsOfPrecipitation";

	public static LocationsOfPrecipitation Instance { get; private set; }

	public static PluginInfo PluginInfo { get; private set; }

	internal static ManualLogSource Logger { get; set; }

	private static string AssemblyDir => Path.GetDirectoryName(PluginInfo.Location);

	public static AssetBundle lopAssetBundle { get; private set; }

	private void Awake()
	{
		Instance = this;
		PluginInfo = ((BaseUnityPlugin)this).Info;
		Logger = ((BaseUnityPlugin)this).Logger;
		new LOPLog(Logger);
		lopAssetBundle = AssetBundle.LoadFromFile(Path.Combine(AssemblyDir, "runtimelopassetbundle"));
	}
}
internal class LOPLog
{
	private static ManualLogSource logger;

	internal LOPLog(ManualLogSource logger_)
	{
		logger = logger_;
	}

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

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

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

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

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

	internal static void Warning(object data)
	{
		logger.LogWarning(data);
	}
}
public static class LOPUtil
{
	public static void DestroyImmediateSafe(Object obj, bool allowDestroyingAssets = false)
	{
		Object.Destroy(obj);
	}

	public static void Shuffle<T>(this Xoroshiro128Plus rng, T[] array)
	{
		int num = array.Length;
		while (num > 1)
		{
			int num2 = rng.RangeInt(0, num--);
			T val = array[num];
			array[num] = array[num2];
			array[num2] = val;
		}
	}
}
public class PlayerSpawnPointController : MonoBehaviour
{
	public enum SpawnPointMode
	{
		WithinRange,
		NearestNode,
		Static
	}

	public enum SpawnPointOrder
	{
		LinearWrap,
		PingPong,
		ClusterOnFirstValidPOI,
		Random
	}

	[Tooltip("List of referenced Transforms to create player spawn points.")]
	[SerializeField]
	public Transform[] spawnPointPOIs;

	[Tooltip("Mode of creating player spawn points. WithinRange creates spawn points at ground nodes around a POI within a range between minDistance and maxDistance. NearestNode creates a spawn point at the nearest ground node to the POI. Static creates a spawn point at the POI.")]
	[SerializeField]
	public SpawnPointMode spawnPointMode;

	[SerializeField]
	public float minDistance = 10f;

	[SerializeField]
	public float maxDistance = 40f;

	[Tooltip("Shuffle the POIs at the start of creating spawn points")]
	[SerializeField]
	public bool initialRandomization = true;

	[SerializeField]
	public bool createPointPerPlayer;

	[SerializeField]
	public SpawnPointOrder order;

	private NodeGraph groundNodes;

	private void OnEnable()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		SceneDirector.onPreGeneratePlayerSpawnPointsServer += new GenerateSpawnPointsDelegate(SceneDirector_onPreGeneratePlayerSpawnPointsServer);
	}

	private void OnDisable()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		SceneDirector.onPreGeneratePlayerSpawnPointsServer -= new GenerateSpawnPointsDelegate(SceneDirector_onPreGeneratePlayerSpawnPointsServer);
	}

	private void SceneDirector_onPreGeneratePlayerSpawnPointsServer(SceneDirector sceneDirector, ref Action generationMethod)
	{
		generationMethod = GeneratePlayerSpawnPointsServer;
	}

	private void GeneratePlayerSpawnPointsServer()
	{
		if (!Object.op_Implicit((Object)(object)SceneInfo.instance))
		{
			LOPLog.Error("There is no SceneInfo instance, spawn points cannot be generated.");
			return;
		}
		if (spawnPointPOIs.Length == 0)
		{
			LOPLog.Error($"No spawn point POIs populated in {this}, spawn points cannot be generated.");
			return;
		}
		groundNodes = SceneInfo.instance.groundNodes;
		if (!Object.op_Implicit((Object)(object)groundNodes) && spawnPointMode != SpawnPointMode.Static)
		{
			LOPLog.Error("There are no ground nodes in this scene. Make sure there is a ground node asset or spawnPointMode is set to Static.");
			return;
		}
		if (initialRandomization)
		{
			RoR2Application.rng.Shuffle(spawnPointPOIs);
		}
		if (createPointPerPlayer)
		{
			if (spawnPointMode != 0)
			{
				LOPLog.Warning("Creating Spawn points per player is incompatible with any SpawnPointMode that isn't WithinRange. This is to prevent players from spawning on top of each other.");
				GenerateSpawnPointsPerTransform();
			}
			GenerateSpawnPointsPerPlayer();
		}
		else
		{
			GenerateSpawnPointsPerTransform();
		}
	}

	private void GenerateSpawnPointsPerTransform()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val2 = default(Vector3);
		for (int i = 0; i < spawnPointPOIs.Length && ((Component)spawnPointPOIs[i]).gameObject.activeSelf; i++)
		{
			if (spawnPointMode == SpawnPointMode.Static)
			{
				SpawnPoint.AddSpawnPoint(spawnPointPOIs[i].position, spawnPointPOIs[i].rotation);
				continue;
			}
			NodeIndex val = NodeIndex.invalid;
			if (spawnPointMode == SpawnPointMode.NearestNode)
			{
				val = groundNodes.FindClosestNode(spawnPointPOIs[i].position, (HullClassification)0, float.PositiveInfinity);
			}
			else
			{
				List<NodeIndex> list = groundNodes.FindNodesInRange(spawnPointPOIs[i].position, minDistance, maxDistance, (HullMask)1);
				if (list.Count > 0)
				{
					val = list[Random.Range(0, list.Count)];
				}
			}
			if (!(val == NodeIndex.invalid) && groundNodes.GetNodePosition(val, ref val2))
			{
				SpawnPoint.AddSpawnPoint(val2, spawnPointPOIs[i].rotation);
			}
		}
	}

	private void GenerateSpawnPointsPerPlayer()
	{
		if (order == SpawnPointOrder.ClusterOnFirstValidPOI)
		{
			GenerateSpawnPointCluster();
		}
		else
		{
			GeneratePlayerSpawnPointsInteration();
		}
	}

	private void GenerateSpawnPointCluster()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: 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)
		int participatingPlayerCount = Run.instance.participatingPlayerCount;
		NodeIndex invalid = NodeIndex.invalid;
		int num = 0;
		List<NodeIndex> list = new List<NodeIndex>();
		for (num = 0; num < spawnPointPOIs.Length; num++)
		{
			list = groundNodes.FindNodesInRange(spawnPointPOIs[num].position, minDistance, maxDistance, (HullMask)1);
			if (list.Count >= 1)
			{
				break;
			}
			LOPLog.Warning("Cannot find a valid node to create a spawn point cluster around POI: " + ((Object)spawnPointPOIs[num]).name);
		}
		if (list.Count < 1)
		{
			LOPLog.Error("Cannot create any valid spawn point clusters. No spawn points generated.");
			return;
		}
		Vector3 val = default(Vector3);
		for (int i = 0; i < participatingPlayerCount; i++)
		{
			invalid = list[Random.Range(0, list.Count)];
			if (!(invalid == NodeIndex.invalid) && groundNodes.GetNodePosition(invalid, ref val))
			{
				SpawnPoint.AddSpawnPoint(val, spawnPointPOIs[num].rotation);
			}
		}
	}

	private void GeneratePlayerSpawnPointsInteration()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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)
		int participatingPlayerCount = Run.instance.participatingPlayerCount;
		NodeIndex val = NodeIndex.invalid;
		int num = 0;
		int num2 = 1;
		Vector3 val2 = default(Vector3);
		for (int i = 0; i < participatingPlayerCount; i++)
		{
			List<NodeIndex> list = groundNodes.FindNodesInRange(spawnPointPOIs[num].position, minDistance, maxDistance, (HullMask)1);
			if (list.Count > 0)
			{
				val = list[Run.instance.stageRng.RangeInt(0, list.Count)];
			}
			if (val == NodeIndex.invalid)
			{
				LOPLog.Warning("Cannot find a valid node to create a spawn point around POI: " + ((Object)spawnPointPOIs[num]).name);
				continue;
			}
			if (groundNodes.GetNodePosition(val, ref val2))
			{
				SpawnPoint.AddSpawnPoint(val2, spawnPointPOIs[num].rotation);
			}
			switch (order)
			{
			case SpawnPointOrder.LinearWrap:
				num++;
				num %= spawnPointPOIs.Length;
				break;
			case SpawnPointOrder.PingPong:
			{
				int num3 = num + num2;
				if (num3 == -1 || num3 == spawnPointPOIs.Length)
				{
					num2 *= -1;
				}
				num += num2;
				break;
			}
			case SpawnPointOrder.Random:
				num = Run.instance.stageRng.RangeInt(0, list.Count);
				break;
			}
		}
	}
}
public class SetupDLC3AccessNode : MonoBehaviour
{
	public static GameObject accessNodeMissionController;

	[SerializeField]
	[Tooltip("Allows boss fight override. Solus Amalgamator by default.")]
	private bool overrideBossFight;

	[SerializeField]
	[Tooltip("Overrides the spawn card of the Access Node encounter.")]
	private DirectorCard spawnCard;

	[SerializeField]
	[Tooltip("Ignore Solus Wing defeat.")]
	private bool ignoreSolusWing;

	[SystemInitializer(new Type[] { })]
	private static IEnumerator SystemInit()
	{
		LOPLog.Info("Initializing DLC3 Access Node Assets...");
		AssetBundleRequest request = LocationsOfPrecipitation.lopAssetBundle.LoadAssetAsync<GameObject>("AccessNodeMissionController");
		while (!((AsyncOperation)request).isDone)
		{
			yield return null;
		}
		Object asset = request.asset;
		accessNodeMissionController = (GameObject)(object)((asset is GameObject) ? asset : null);
		AccessCodesMissionController acMissionControllerComp = accessNodeMissionController.GetComponent<AccessCodesMissionController>();
		SolusFight solusFight = accessNodeMissionController.GetComponent<SolusFight>();
		PortalSpawner ccPortalSpawner = solusFight.conduitCanyonPortalSpawner;
		PortalSpawner cePortalSpawner = solusFight.computationalExchangePortalSpawner;
		PortalSpawner shPortalSpawner = solusFight.solutionalHauntPortalSpawner;
		AsyncOperationHandle<ExpansionDef> dlc3Request = Addressables.LoadAssetAsync<ExpansionDef>((object)Constants.AssetGUIDS.dlc3ExpansionGUID);
		while (!dlc3Request.IsDone)
		{
			yield return null;
		}
		acMissionControllerComp.requiredExpansion = dlc3Request.Result;
		solusFight.requiredExpansion = dlc3Request.Result;
		ccPortalSpawner.requiredExpansion = dlc3Request.Result;
		cePortalSpawner.requiredExpansion = dlc3Request.Result;
		shPortalSpawner.requiredExpansion = dlc3Request.Result;
		AsyncOperationHandle<InteractableSpawnCard> ccPortalCardRequest = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)Constants.AssetGUIDS.iscHardwareProgPortalGUID);
		while (!ccPortalCardRequest.IsDone)
		{
			yield return null;
		}
		ccPortalSpawner.portalSpawnCard = ccPortalCardRequest.Result;
		AsyncOperationHandle<InteractableSpawnCard> cePortalCardRequest = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)Constants.AssetGUIDS.iscSolusShopPortalGUID);
		while (!cePortalCardRequest.IsDone)
		{
			yield return null;
		}
		cePortalSpawner.portalSpawnCard = cePortalCardRequest.Result;
		AsyncOperationHandle<InteractableSpawnCard> shPortalCardRequest = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)Constants.AssetGUIDS.iscHardwareProgPortalHauntGUID);
		while (!shPortalCardRequest.IsDone)
		{
			yield return null;
		}
		shPortalSpawner.portalSpawnCard = shPortalCardRequest.Result;
	}

	public void Start()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)Constants.AssetGUIDS.accessNodeGUID).WaitForCompletion(), ((Component)this).transform);
		NetworkServer.Spawn(val);
		GameObject val2 = Object.Instantiate<GameObject>(accessNodeMissionController);
		AccessCodesMissionController component = val2.GetComponent<AccessCodesMissionController>();
		component.ignoreSolusWingDeath = ignoreSolusWing;
		SolusFight component2 = val2.GetComponent<SolusFight>();
		if (overrideBossFight)
		{
			component2.ForcedBossFight = spawnCard;
		}
		component.nodes = (AccessCodesNodeData[])(object)new AccessCodesNodeData[1]
		{
			new AccessCodesNodeData
			{
				node = val,
				id = 0
			}
		};
		NetworkServer.Spawn(val2);
	}
}
public static class ShaderSwap
{
	public static List<Material> MaterialsWithSwappedShaders { get; } = new List<Material>();


	public static async Task ConvertShader(Material material)
	{
		if (!((Object)material.shader).name.StartsWith("Stubbed"))
		{
			LOPLog.Warning($"The material {material} has a shader which's name doesnt start with \"Stubbed\". Skipping material.");
			return;
		}
		try
		{
			material.shader = await Addressables.LoadAssetAsync<Shader>((object)(((Object)material.shader).name.Substring(7) + ".shader")).Task;
			MaterialsWithSwappedShaders.Add(material);
		}
		catch (Exception arg)
		{
			LOPLog.Error($"Failed to swap shader of material {material}: {arg}");
		}
	}
}
[ExecuteAlways]
public class SurfaceDefInjector : MonoBehaviour
{
	[Tooltip("The surfaceDef address to load")]
	public string surfaceDefAddress;

	[NonSerialized]
	private SurfaceDef loadedSurfaceDef;

	private void OnEnable()
	{
		Refresh();
	}

	private void OnDisable()
	{
		RemoveReferencesEditor();
	}

	public void Refresh()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrWhiteSpace(surfaceDefAddress) || string.IsNullOrEmpty(surfaceDefAddress))
		{
			LOPLog.Warning($"Invalid address in {this}, address is null, empty, or white space");
			return;
		}
		loadedSurfaceDef = Addressables.LoadAssetAsync<SurfaceDef>((object)surfaceDefAddress).WaitForCompletion();
		if (Object.op_Implicit((Object)(object)loadedSurfaceDef))
		{
			SurfaceDef obj = loadedSurfaceDef;
			((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x1C);
			SurfaceDefProvider[] componentsInChildren = ((Component)this).GetComponentsInChildren<SurfaceDefProvider>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].surfaceDef = loadedSurfaceDef;
			}
		}
	}

	private void RemoveReferencesEditor()
	{
		if (Application.isEditor)
		{
			SurfaceDefProvider[] componentsInChildren = ((Component)this).GetComponentsInChildren<SurfaceDefProvider>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].surfaceDef = null;
			}
		}
	}
}