Decompiled source of OopsAllFloodedFixed v0.1.5

NoteBoxz.OopsAllFloodedFixed.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("NoteBoxz.OopsAllFloodedFixed")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.5.0")]
[assembly: AssemblyInformationalVersion("0.1.5")]
[assembly: AssemblyProduct("OopsAllFloodedFixed")]
[assembly: AssemblyTitle("NoteBoxz.OopsAllFloodedFixed")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.5.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 OopsAllFloodedFixed
{
	[BepInPlugin("NoteBoxz.OopsAllFloodedFixed", "OopsAllFloodedFixed", "0.1.5")]
	public class OopsAllFloodedFixed : BaseUnityPlugin
	{
		public static OopsAllFloodedFixed Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "oxymod");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/OxyMod/OxyItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
			val3.clearPreviousText = true;
			val3.displayText = "Limited air supply, useful for flooded facilities.";
			Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, val3, 25);
			Logger.LogInfo((object)"Watch out for floods.");
			Logger.LogInfo((object)"NoteBoxz.OopsAllFloodedFixed v0.1.5 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("NoteBoxz.OopsAllFloodedFixed");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoteBoxz.OopsAllFloodedFixed";

		public const string PLUGIN_NAME = "OopsAllFloodedFixed";

		public const string PLUGIN_VERSION = "0.1.5";
	}
}
namespace OopsAllFloodedFixed.Patches
{
	[HarmonyPatch(typeof(FloodWeather))]
	internal class FloodPatch
	{
		public static float baseFlood;

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool FloodLevelPatch(ref FloodWeather __instance)
		{
			//IL_0059: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00e4: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)(object)RoundPatch.facilityFlood)
			{
				float num = Mathf.Clamp(__instance.floodLevelOffset, 2f, 5f);
				float num2 = baseFlood + num * 4f;
				num2 = Mathf.Clamp(num2, -225f, -212f);
				((Component)__instance).transform.position = Vector3.MoveTowards(((Component)__instance).transform.position, new Vector3(0f, num2, 0f), 0.5f * Time.deltaTime);
				if ((Object)(object)__instance.waterAudio != (Object)null)
				{
					((Component)__instance.waterAudio).transform.position = new Vector3(((Component)GameNetworkManager.Instance.localPlayerController).transform.position.x, ((Component)__instance).transform.position.y + 1f, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position.z);
					float num3 = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)__instance.waterAudio).transform.position);
					__instance.waterAudio.volume = Mathf.Lerp(__instance.waterAudio.volume, (5f - num3) / 20f, 0.1f);
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void FloodLevelStart(ref FloodWeather __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)(object)RoundPatch.facilityFlood)
			{
				((Component)__instance).transform.position = new Vector3(0f, baseFlood, 0f);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class RoundPatch
	{
		public static FloodWeather facilityFlood;

		public static QuicksandTrigger facilityTrigger;

		[HarmonyPatch("OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		private static void FloodSpawnPatch()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Invalid comparison between Unknown and I4
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Invalid comparison between Unknown and I4
			OopsAllFloodedFixed.Logger.LogInfo((object)"StartOfRound injection successful.");
			FloodWeather val = Object.FindObjectOfType<FloodWeather>(true);
			LevelWeatherType currentLevelWeather = TimeOfDay.Instance.currentLevelWeather;
			int randomMapSeed = StartOfRound.Instance.randomMapSeed;
			OopsAllFloodedFixed.Logger.LogInfo((object)("Seed = " + randomMapSeed));
			Vector3 val2 = RoundManager.FindMainEntrancePosition(true, false);
			FloodPatch.baseFlood = -225f;
			bool flag = true;
			OopsAllFloodedFixed.Logger.LogInfo((object)("Found the main entrance at y = " + val2.y));
			float num = val2.y - 6f;
			if (num < FloodPatch.baseFlood)
			{
				FloodPatch.baseFlood = num;
			}
			FloodPatch.baseFlood += Mathf.Clamp(TimeOfDay.Instance.currentWeatherVariable, -10f, -3f);
			if ((Object)(object)val != (Object)null)
			{
				GameObject gameObject = ((Component)val).gameObject;
				GameObject val3 = Object.Instantiate<GameObject>(gameObject);
				((Object)val3).name = "Flooding (Facility)";
				facilityFlood = val3.GetComponent<FloodWeather>();
				((Component)facilityFlood).transform.parent = ((Component)val).transform.parent;
				((Component)facilityFlood).transform.position = new Vector3(0f, FloodPatch.baseFlood, 0f);
				OopsAllFloodedFixed.Logger.LogInfo((object)((Component)facilityFlood).transform.position);
				facilityTrigger = ((Component)facilityFlood).GetComponentInChildren<QuicksandTrigger>();
				facilityTrigger.isInsideWater = true;
				if (((int)currentLevelWeather == 1 || (int)currentLevelWeather == 2) && randomMapSeed % 5 == 0)
				{
					OopsAllFloodedFixed.Logger.LogInfo((object)"Randomly flooding the interior!");
					((Component)facilityFlood).gameObject.SetActive(true);
				}
			}
			else
			{
				OopsAllFloodedFixed.Logger.LogInfo((object)"Flood hasn't spawned yet :(");
			}
		}

		[HarmonyPatch("ShipHasLeft")]
		[HarmonyPrefix]
		private static void FloodDisable()
		{
			if ((Object)(object)facilityFlood != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)facilityFlood).gameObject);
			}
		}
	}
}
namespace OopsAllFlooded.Patches
{
	internal class OxyCanisterItem : TetraChemicalItem
	{
		public IEnumerator UseTZPAnimation()
		{
			base.thisAudioSource.PlayOneShot(base.holdCanSFX);
			WalkieTalkie.TransmitOneShotAudio(base.previousPlayerHeldBy.itemAudio, base.holdCanSFX, 1f);
			yield return (object)new WaitForSeconds(0.75f);
			base.emittingGas = true;
			if (((NetworkBehaviour)this).IsOwner)
			{
				base.localHelmetSFX.Play();
				base.localHelmetSFX.PlayOneShot(base.twistCanSFX);
			}
			else
			{
				base.thisAudioSource.clip = base.releaseGasSFX;
				base.thisAudioSource.Play();
				base.thisAudioSource.PlayOneShot(base.twistCanSFX);
			}
		}

		public override void Update()
		{
			if ((Object)(object)base.previousPlayerHeldBy != (Object)null)
			{
				float drunknessInertia = base.previousPlayerHeldBy.drunknessInertia;
				((TetraChemicalItem)this).Update();
				base.previousPlayerHeldBy.drunknessInertia = drunknessInertia;
				base.previousPlayerHeldBy.increasingDrunknessThisFrame = false;
			}
			else
			{
				((TetraChemicalItem)this).Update();
			}
			if (!base.emittingGas || !((Object)(object)base.previousPlayerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				return;
			}
			float drowningTimer = StartOfRound.Instance.drowningTimer;
			StartOfRound.Instance.drowningTimer = Mathf.Clamp(StartOfRound.Instance.drowningTimer + Time.deltaTime / 2f, 0f, 1f);
			if (drowningTimer <= 0.3f && StartOfRound.Instance.drowningTimer > 0.3f)
			{
				StartOfRound.Instance.playedDrowningSFX = false;
			}
			if (base.previousPlayerHeldBy.isUnderwater)
			{
				base.previousPlayerHeldBy.sprintMeter = Mathf.Clamp(base.previousPlayerHeldBy.sprintMeter + Time.deltaTime * 0.1f, 0f, 1.25f);
				if (base.previousPlayerHeldBy.sprintMeter > 0.2f)
				{
					base.previousPlayerHeldBy.isExhausted = false;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}