Decompiled source of Wesleys Moons v5.0.21

WesleyMoons.dll

Decompiled 5 days 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.Logging;
using HarmonyLib;
using JLL;
using LethalModDataLib.Base;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using WesleyMoons.NetcodePatcher;
using WesleyMoons.Patches;
using WesleyMoons.Save;

[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("")]
[assembly: AssemblyCompany("WesleyMoons")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WesleyMoons")]
[assembly: AssemblyTitle("WesleyMoons")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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;
		}
	}
}
namespace WesleyMoons
{
	[BepInPlugin("JacobG5.WesleyMoons", "WesleyMoons", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WesleyPlugin : BaseUnityPlugin
	{
		private const string modGUID = "JacobG5.WesleyMoons";

		private const string modName = "WesleyMoons";

		private const string modVersion = "1.0.0";

		internal static readonly Harmony Harmony = new Harmony("JacobG5.WesleyMoons");

		internal static ManualLogSource mls { get; private set; }

		public static WesleySaveFile CurrentFile { get; internal set; }

		private void Awake()
		{
			mls = Logger.CreateLogSource("JacobG5.WesleyMoons");
			JLL.HarmonyPatch(Harmony, mls, new Type[1] { typeof(SavePatches) });
			JLL.NetcodePatch(mls, Assembly.GetExecutingAssembly().GetTypes());
		}
	}
}
namespace WesleyMoons.Save
{
	public class WesleySaveFile : ModDataContainer
	{
		public enum Apparatus
		{
			Cosmic,
			Bloody,
			Royal
		}

		public bool HasCosmic = false;

		public bool HasBloody = false;

		public bool HasRoyal = false;

		public bool HasAllAppy = false;

		public void Reset()
		{
			HasCosmic = false;
			HasBloody = false;
			HasRoyal = false;
			((ModDataContainer)this).Save();
		}

		public void Collect(Apparatus apparatus)
		{
			switch (apparatus)
			{
			case Apparatus.Cosmic:
				HasCosmic = true;
				break;
			case Apparatus.Bloody:
				HasBloody = true;
				break;
			case Apparatus.Royal:
				HasRoyal = true;
				break;
			}
		}

		public bool Get(Apparatus apparatus)
		{
			if (1 == 0)
			{
			}
			bool result = apparatus switch
			{
				Apparatus.Cosmic => HasCosmic, 
				Apparatus.Bloody => HasBloody, 
				Apparatus.Royal => HasRoyal, 
				_ => false, 
			};
			if (1 == 0)
			{
			}
			return result;
		}
	}
}
namespace WesleyMoons.Patches
{
	internal class SavePatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPrefix]
		internal static void LoadFile(StartOfRound __instance)
		{
			if (((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer)
			{
				WesleyPlugin.CurrentFile = new WesleySaveFile();
				WesleyPlugin.mls.LogInfo((object)"Loading Wesley Data.");
				((ModDataContainer)WesleyPlugin.CurrentFile).Load();
			}
			else
			{
				WesleyPlugin.mls.LogInfo((object)"Not loading Wesley Data.");
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
		[HarmonyPrefix]
		internal static void SaveFile(GameNetworkManager __instance)
		{
			if (__instance.isHostingGame && WesleyPlugin.CurrentFile != null)
			{
				WesleyPlugin.mls.LogInfo((object)"Saving Wesley Data.");
				((ModDataContainer)WesleyPlugin.CurrentFile).Save();
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")]
		[HarmonyPrefix]
		internal static void ResetFile(GameNetworkManager __instance)
		{
			if (__instance.isHostingGame && WesleyPlugin.CurrentFile != null)
			{
				WesleyPlugin.mls.LogInfo((object)"Resetting Wesley Data.");
				WesleyPlugin.CurrentFile.Reset();
			}
		}
	}
}
namespace WesleyMoons.Component
{
	public class AppyInsert : NetworkBehaviour
	{
		public WesleySaveFile.Apparatus apparatus;

		public UnityEvent OnInsert = new UnityEvent();

		public AudioClip InsertSound;

		public AudioSource AudioSource;

		public Collider InteractTrigger;

		private void Start()
		{
			if ((((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) && WesleyPlugin.CurrentFile != null && WesleyPlugin.CurrentFile.Get(apparatus))
			{
				Insert();
			}
		}

		public void Insert()
		{
			InsertServerRpc();
		}

		[ServerRpc(RequireOwnership = false)]
		private void InsertServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4100196675u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4100196675u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					WesleyPlugin.CurrentFile?.Collect(apparatus);
					InsertClientRpc();
				}
			}
		}

		[ClientRpc]
		private void InsertClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1843247666u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1843247666u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				OnInsert.Invoke();
				if ((Object)(object)InteractTrigger != (Object)null)
				{
					InteractTrigger.enabled = false;
				}
				AudioSource.PlayOneShot(InsertSound);
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_AppyInsert()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(4100196675u, new RpcReceiveHandler(__rpc_handler_4100196675));
			NetworkManager.__rpc_func_table.Add(1843247666u, new RpcReceiveHandler(__rpc_handler_1843247666));
		}

		private static void __rpc_handler_4100196675(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((AppyInsert)(object)target).InsertServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1843247666(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((AppyInsert)(object)target).InsertClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "AppyInsert";
		}
	}
	public class BackDoor : NetworkBehaviour
	{
		private bool opened = false;

		public Animator? animator;

		public string animTrigger = "OpenDoor";

		public UnityEvent OpenEvent = new UnityEvent();

		private void Start()
		{
			if ((((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) && WesleyPlugin.CurrentFile != null && WesleyPlugin.CurrentFile.HasAllAppy)
			{
				Open();
			}
		}

		public void CheckSave()
		{
			CheckSaveServerRpc();
		}

		[ServerRpc(RequireOwnership = false)]
		private void CheckSaveServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4218537141u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4218537141u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost) || WesleyPlugin.CurrentFile == null)
			{
				return;
			}
			foreach (WesleySaveFile.Apparatus value in Enum.GetValues(typeof(WesleySaveFile.Apparatus)))
			{
				if (!WesleyPlugin.CurrentFile.Get(value))
				{
					return;
				}
			}
			WesleyPlugin.CurrentFile.HasAllAppy = true;
			OpenClientRpc();
		}

		[ClientRpc]
		private void OpenClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2079988097u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2079988097u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Open();
				}
			}
		}

		private void Open()
		{
			if (!opened)
			{
				opened = true;
				Animator? obj = animator;
				if (obj != null)
				{
					obj.SetTrigger(animTrigger);
				}
				OpenEvent.Invoke();
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BackDoor()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(4218537141u, new RpcReceiveHandler(__rpc_handler_4218537141));
			NetworkManager.__rpc_func_table.Add(2079988097u, new RpcReceiveHandler(__rpc_handler_2079988097));
		}

		private static void __rpc_handler_4218537141(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BackDoor)(object)target).CheckSaveServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2079988097(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BackDoor)(object)target).OpenClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "BackDoor";
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace WesleyMoons.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}