Decompiled source of LiminalPools v1.0.13

PooluginRooms.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LiminalPoolRoomsDunGen;
using PooluginRooms;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PooluginRooms")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PooluginRooms")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8be8e828-c018-493d-a159-15463d37bd21")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class DrakosCustomWaterPatchThingGuyDudeMcBob : MonoBehaviour
{
	public bool isWater;

	public int audioClipIndex;

	[Space(5f)]
	public bool sinkingLocalPlayer;

	public float movementHinderance = 1.6f;

	public float sinkingSpeedMultiplier = 0.15f;

	private bool hneebJ = true;

	private void OnTriggerStay(Collider other)
	{
		if (isWater)
		{
			if (!((Component)other).gameObject.CompareTag("Player"))
			{
				return;
			}
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)component != (Object)null)
			{
				hneebJ = true;
			}
			if ((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController && (Object)(object)component != (Object)null && (Object)(object)component.underwaterCollider != (Object)(object)this)
			{
				component.underwaterCollider = ((Component)this).gameObject.GetComponent<Collider>();
				return;
			}
		}
		if (!GameNetworkManager.Instance.localPlayerController.isInsideFactory || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom || (!isWater && !((Component)other).gameObject.CompareTag("Player")))
		{
			return;
		}
		PlayerControllerB component2 = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
		if ((Object)(object)component2 != (Object)(object)GameNetworkManager.Instance.localPlayerController)
		{
			return;
		}
		if (isWater && !component2.isUnderwater)
		{
			component2.underwaterCollider = ((Component)this).gameObject.GetComponent<Collider>();
			component2.isUnderwater = true;
		}
		component2.statusEffectAudioIndex = audioClipIndex;
		if (component2.isUnderwater)
		{
			component2.statusEffectAudio.volume = component2.statusEffectAudio.volume * 0.4f;
		}
		if (component2.isSinking)
		{
			return;
		}
		if (sinkingLocalPlayer)
		{
			if (!component2.CheckConditionsForSinkingInQuicksand())
			{
				StopSinkingLocalPlayer(component2);
			}
		}
		else if (component2.CheckConditionsForSinkingInQuicksand())
		{
			Debug.Log((object)"Set local player to sinking!");
			sinkingLocalPlayer = true;
			component2.sourcesCausingSinking++;
			component2.isMovementHindered++;
			component2.hinderedMultiplier *= movementHinderance;
			if (isWater)
			{
				component2.sinkingSpeedMultiplier = 0f;
			}
			else
			{
				component2.sinkingSpeedMultiplier = sinkingSpeedMultiplier;
			}
		}
	}

	public void FixedUpdate()
	{
		//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_0038: Unknown result type (might be due to invalid IL or missing references)
		if (hneebJ)
		{
			Bounds bounds = ((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<Collider>().bounds;
			if (!((Bounds)(ref bounds)).Intersects(((Component)this).gameObject.GetComponent<Collider>().bounds))
			{
				OnExit(((Component)GameNetworkManager.Instance.localPlayerController).gameObject.GetComponent<Collider>());
			}
		}
	}

	private void OnTriggerExit(Collider other)
	{
		OnExit(other);
	}

	public void OnExit(Collider other)
	{
		hneebJ = false;
		if (!sinkingLocalPlayer)
		{
			if (isWater && ((Component)other).CompareTag("Player") && !((Object)(object)((Component)other).gameObject.GetComponent<PlayerControllerB>() == (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				((Component)other).gameObject.GetComponent<PlayerControllerB>().isUnderwater = false;
			}
		}
		else if (((Component)other).CompareTag("Player"))
		{
			PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
			if (!((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				StopSinkingLocalPlayer(component);
			}
		}
	}

	public void StopSinkingLocalPlayer(PlayerControllerB playerScript)
	{
		if (sinkingLocalPlayer)
		{
			sinkingLocalPlayer = false;
			playerScript.sourcesCausingSinking = Mathf.Clamp(playerScript.sourcesCausingSinking - 1, 0, 100);
			playerScript.isMovementHindered = Mathf.Clamp(playerScript.isMovementHindered - 1, 0, 100);
			playerScript.hinderedMultiplier = Mathf.Clamp(playerScript.hinderedMultiplier / movementHinderance, 1f, 100f);
			if (playerScript.isMovementHindered == 0 && isWater)
			{
				playerScript.isUnderwater = false;
			}
		}
	}
}
namespace PooluginRooms
{
	public class AppEventListener : MonoBehaviour
	{
		public UnityEvent Event = new UnityEvent();

		internal void TriggerEvent()
		{
			Event.Invoke();
		}

		internal static void TriggerAllEvents()
		{
			AppEventListener[] array = Object.FindObjectsByType<AppEventListener>((FindObjectsSortMode)0);
			foreach (AppEventListener appEventListener in array)
			{
				appEventListener.TriggerEvent();
			}
		}
	}
	public class FartPoop : MonoBehaviour
	{
		[SerializeField]
		private List<Material> wawt;

		[SerializeField]
		private PlanarReflectionProbe prp;

		public void Update()
		{
			if (wawt == null)
			{
				Debug.Log((object)"My asshole burns and prp is nul");
				return;
			}
			foreach (Material item in wawt)
			{
				item.SetTexture("_pweej", ((HDProbe)prp).realtimeTexture, (RenderTextureSubElement)3);
			}
		}
	}
	public class FolgaWolgaImogaWomp : MonoBehaviour
	{
	}
	public class ReflectionConfig : MonoBehaviour
	{
		[SerializeField]
		private PlanarReflectionProbe whyDontIHaveApensi;

		private void OnEnable()
		{
			CheckConfigSettings();
		}

		private void CheckConfigSettings()
		{
			if (!global::LiminalPoolRoomsDunGen.LiminalPoolRoomsDunGen.configLiminalPoolRoomsReflectionFloor.Value)
			{
				((Component)whyDontIHaveApensi).gameObject.SetActive(false);
			}
			if (global::LiminalPoolRoomsDunGen.LiminalPoolRoomsDunGen.configLiminalPoolRoomsReflectionFloor.Value)
			{
				((Component)whyDontIHaveApensi).gameObject.SetActive(true);
			}
		}
	}
	public class ShadowIncrement : MonoBehaviour
	{
		private int originalMaxShadowRequests;

		public void OnEnable()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//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_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)
			RenderPipelineSettings currentPlatformRenderPipelineSettings = ((HDRenderPipelineAsset)QualitySettings.renderPipeline).currentPlatformRenderPipelineSettings;
			ref int maxShadowRequests = ref currentPlatformRenderPipelineSettings.hdShadowInitParams.maxShadowRequests;
			originalMaxShadowRequests = maxShadowRequests;
			maxShadowRequests = 256;
			((HDRenderPipelineAsset)QualitySettings.renderPipeline).currentPlatformRenderPipelineSettings = currentPlatformRenderPipelineSettings;
		}

		public void OnDisable()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//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_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)
			RenderPipelineSettings currentPlatformRenderPipelineSettings = ((HDRenderPipelineAsset)QualitySettings.renderPipeline).currentPlatformRenderPipelineSettings;
			currentPlatformRenderPipelineSettings.hdShadowInitParams.maxShadowRequests = originalMaxShadowRequests;
			((HDRenderPipelineAsset)QualitySettings.renderPipeline).currentPlatformRenderPipelineSettings = currentPlatformRenderPipelineSettings;
		}
	}
	public class WaterRefConf : MonoBehaviour
	{
		[SerializeField]
		private PlanarReflectionProbe whyDontIHaveApensi;

		private void OnEnable()
		{
			CheckConfigSettings();
		}

		private void CheckConfigSettings()
		{
			if (!global::LiminalPoolRoomsDunGen.LiminalPoolRoomsDunGen.configLiminalPoolRoomsReflectionWater.Value)
			{
				((Component)whyDontIHaveApensi).gameObject.SetActive(false);
			}
			if (global::LiminalPoolRoomsDunGen.LiminalPoolRoomsDunGen.configLiminalPoolRoomsReflectionWater.Value)
			{
				((Component)whyDontIHaveApensi).gameObject.SetActive(true);
			}
		}
	}
}
namespace LiminalPoolRoomsDunGen
{
	[BepInPlugin("LiminalPoolRooms", "LiminalPoolRooms", "1.0.9")]
	public class LiminalPoolRoomsDunGen : BaseUnityPlugin
	{
		[Flags]
		private enum RefAccept
		{
			None = 0,
			Tile = 1,
			Water = 2
		}

		[HarmonyPatch(typeof(Object))]
		private class ItemGroupPatch
		{
			[HarmonyPatch("Equals")]
			[HarmonyPrefix]
			public static bool FixItemGroupEquals(ref bool __result, object __instance, object other)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Expected O, but got Unknown
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				ItemGroup val = (ItemGroup)((__instance is ItemGroup) ? __instance : null);
				if ((Object)(object)val != (Object)null)
				{
					ItemGroup val2 = (ItemGroup)((other is ItemGroup) ? other : null);
					if ((Object)(object)val2 != (Object)null)
					{
						__result = val.itemSpawnTypeName == val2.itemSpawnTypeName;
						return false;
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(RoundManager))]
		internal class QuickWaterPatch
		{
			[HarmonyPatch("GenerateNewFloor")]
			[HarmonyPostfix]
			public static void SwitchPoolWater(ref RuntimeDungeon ___dungeonGenerator)
			{
				GameObject[] array = Object.FindObjectsOfType<GameObject>();
				GameObject[] array2 = array;
				foreach (GameObject val in array2)
				{
					if (((Object)val).name == "LiminalPoolsIdentifier")
					{
						quickWater = val;
						Instance.mls.LogInfo((object)"Found PoolWater");
						break;
					}
					quickWater = null;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB))]
		internal class PlayerControllerPatch
		{
			[HarmonyPatch("CheckConditionsForSinkingInQuicksand")]
			[HarmonyPrefix]
			private static void CheckPrefix(ref PlayerControllerB __instance)
			{
				if (GameNetworkManager.Instance.localPlayerController.isInsideFactory)
				{
					__instance.currentFootstepSurfaceIndex = 1;
				}
			}
		}

		[HarmonyPatch(typeof(LungProp))]
		internal class PatchLungProp
		{
			[HarmonyTranspiler]
			[HarmonyPatch(/*Could not decode attribute arguments.*/)]
			private static IEnumerable<CodeInstruction> DisconnectFromMachineryTranspiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Expected O, but got Unknown
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Expected O, but got Unknown
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Expected O, but got Unknown
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[4]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction insn) => CodeInstructionExtensions.IsLdloc(insn, (LocalBuilder)null)), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldfld, (object)typeof(LungProp).GetField("disconnectSFX"), (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0.7f, (string)null),
					new CodeMatch((OpCode?)OpCodes.Callvirt, (object)typeof(AudioSource).GetMethod("PlayOneShot", new Type[2]
					{
						typeof(AudioClip),
						typeof(float)
					}), (string)null)
				});
				if (val.IsInvalid)
				{
					Debug.Log((object)"Failed to patch DisconnectFromMachinery()");
					return instructions;
				}
				val.Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)typeof(AppEventListener).GetMethod("TriggerAllEvents", BindingFlags.Static | BindingFlags.NonPublic))
				});
				return val.Instructions();
			}
		}

		private readonly Harmony harmony = new Harmony("LiminalPoolRooms");

		private static LiminalPoolRoomsDunGen Instance;

		public static GameObject quickWater;

		public static QuicksandTrigger quickWater2;

		internal ManualLogSource mls;

		public static AssetBundle LiminalPoolRoomsAssets;

		[HideInInspector]
		public static ConfigEntry<bool> configLiminalPoolRoomsReflectionFloor;

		[HideInInspector]
		public static ConfigEntry<bool> configLiminalPoolRoomsReflectionWater;

		private ConfigEntry<string> configLiminalPoolRoomsMoons;

		private ConfigEntry<string> configLiminalPoolRoomsMoonsList;

		private ConfigEntry<bool> configGuaranteedLiminalPoolRooms;

		private ConfigEntry<int> configLengthOverride;

		private string[] configLiminalPoolRoomsMoonsValues = new string[6] { "vanilla", "modded", "all", "paid", "free", "list" };

		private void Awake()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			mls = Logger.CreateLogSource("LiminalPoolRoomsDunGen");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			configLiminalPoolRoomsReflectionFloor = ((BaseUnityPlugin)this).Config.Bind<bool>("Liminal Pools Interior", "Floor Reflection Enabled", false, new ConfigDescription("Whether or not reflections on the floor are active. \nDefault value is false, set false for better performance.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { false, true }), Array.Empty<object>()));
			configLiminalPoolRoomsReflectionWater = ((BaseUnityPlugin)this).Config.Bind<bool>("Liminal Pools Interior", "Water Reflection Enabled", true, new ConfigDescription("Whether or not reflections on the water are active. \nDefault value is true, set false for better performance.", (AcceptableValueBase)(object)new AcceptableValueList<bool>(new bool[2] { false, true }), Array.Empty<object>()));
			harmony.PatchAll(typeof(LiminalPoolRoomsDunGen));
			harmony.PatchAll(typeof(Object));
			harmony.PatchAll(typeof(PlayerControllerPatch));
			harmony.PatchAll(typeof(PatchLungProp));
		}
	}
}