using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MelMPocketLib.NetcodePatcher;
using MelaniePocketRoom;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MelaniePocketRoom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MelanieMelicious")]
[assembly: AssemblyProduct("MelaniePocketRoom")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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;
}
}
}
public class HarmonyPatches
{
internal static HashSet<EnemyType> blacklist = new HashSet<EnemyType>();
internal static bool walkWarp;
private static GameObject shipBound0;
private static GameObject shipBound1;
[HarmonyPrefix]
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyBefore(new string[] { "MelanieMelicious.2StoryShip" })]
private static void PreStart(StartOfRound __instance)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
shipBound0 = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelMPocketLib/ShipBound.prefab"), Vector3.zero, Quaternion.identity, ((Component)__instance.shipBounds).transform);
shipBound1 = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelMPocketLib/ShipBound.prefab"), Vector3.zero, Quaternion.identity, ((Component)__instance.shipInnerRoomBounds).transform);
shipBound0.transform.localPosition = Vector3.zero;
shipBound0.transform.localRotation = Quaternion.identity;
shipBound0.transform.localScale = Vector3.one;
shipBound1.transform.localPosition = Vector3.zero;
shipBound1.transform.localRotation = Quaternion.identity;
shipBound1.transform.localScale = Vector3.one;
__instance.shipBounds = (Collider)(object)shipBound0.GetComponent<MeshCollider>();
__instance.shipInnerRoomBounds = (Collider)(object)shipBound1.GetComponent<MeshCollider>();
__instance.shipStrictInnerRoomBounds = (Collider)(object)shipBound1.GetComponent<MeshCollider>();
walkWarp = PocketRoomCfg.walkWarp.Value;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Start")]
[HarmonyAfter(new string[] { "MelanieMelicious.2StoryShip", "mborsh.WiderShipMod" })]
private static void PostStart(StartOfRound __instance)
{
EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>();
foreach (EnemyType val in array)
{
string[] array2 = PocketRoomCfg.warpBlacklist.Value.Split(new char[1] { ',' });
foreach (string text in array2)
{
if (val.enemyName == text)
{
blacklist.Add(val);
Plugin.mls.LogInfo((object)$"Found and added {val} to door teleport blacklist.");
}
}
}
__instance.shipBounds = (Collider)(object)shipBound0.GetComponent<MeshCollider>();
__instance.shipInnerRoomBounds = (Collider)(object)shipBound1.GetComponent<MeshCollider>();
__instance.shipStrictInnerRoomBounds = (Collider)(object)shipBound1.GetComponent<MeshCollider>();
}
}
internal static class PocketRoomCfg
{
internal static ConfigEntry<bool> walkWarp;
internal static ConfigEntry<string> warpBlacklist;
internal static ConfigEntry<int> enterTime;
internal static ConfigEntry<int> exitTime;
internal static void SetupConfig(ConfigFile config)
{
walkWarp = config.Bind<bool>("Customization", "Walk-In Teleport", true, "Toggle walk-in teleports when not in build mode.");
warpBlacklist = config.Bind<string>("Customization", "Enemy Door Warp Blacklist", "SandWorm,ForestGiant,RadMech,Tornado,Guardsman,Cactus Budling,Driftwood Menace,Redwood Titan,Carnivorous Plant,Elder,Ogopogo,T-rex,Stegosaurus", "Prevent most listed enemies from using doors to pocket rooms.");
enterTime = config.Bind<int>("Customization", "Enemy Entrance Teleport Time", 2, "How long enemies need to stand by entrances to teleport.");
exitTime = config.Bind<int>("Customization", "Enemy Exit Teleport Time", 2, "How long enemies need to stand by exits to teleport.");
}
}
public class RoomTeleport : NetworkBehaviour
{
[CompilerGenerated]
private sealed class <TeleportTrigger>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public NavMeshAgent agent;
public RoomTeleport <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TeleportTrigger>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds((float)<>4__this.teleportTime);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (<>4__this.teleport || agent.isOnOffMeshLink)
{
agent.Warp(<>4__this.exitPoint.position);
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public Transform entrancePoint;
public Transform exitPoint;
public StartOfRound playersManager;
public bool isExit;
private bool teleport = false;
private int teleportTime;
private void Awake()
{
playersManager = Object.FindObjectOfType<StartOfRound>();
if (isExit)
{
teleportTime = PocketRoomCfg.exitTime.Value;
}
else
{
teleportTime = PocketRoomCfg.enterTime.Value;
}
}
private void OnTriggerEnter(Collider other)
{
EnemyAICollisionDetect val = default(EnemyAICollisionDetect);
NavMeshAgent agent = default(NavMeshAgent);
if (((Component)other).gameObject.CompareTag("Player") && Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<PlayerControllerB>()) && (HarmonyPatches.walkWarp || ShipBuildModeManager.Instance.InBuildMode))
{
TeleportPlayer();
}
else if (((Component)other).gameObject.layer == 19 && ((Component)other).TryGetComponent<EnemyAICollisionDetect>(ref val) && !HarmonyPatches.blacklist.Contains(val.mainScript.enemyType) && ((Component)val.mainScript).TryGetComponent<NavMeshAgent>(ref agent))
{
((MonoBehaviour)this).StartCoroutine(TeleportTrigger(agent));
}
}
private void OnTriggerStay(Collider other)
{
if (((Component)other).gameObject.layer == 19)
{
teleport = true;
}
}
private void OnTriggerExit(Collider other)
{
if (((Component)other).gameObject.layer == 19)
{
teleport = false;
}
}
[IteratorStateMachine(typeof(<TeleportTrigger>d__10))]
private IEnumerator TeleportTrigger(NavMeshAgent agent)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TeleportTrigger>d__10(0)
{
<>4__this = this,
agent = agent
};
}
public void TeleportPlayer()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_005b: Unknown result type (might be due to invalid IL or missing references)
Transform thisPlayerBody = GameNetworkManager.Instance.localPlayerController.thisPlayerBody;
GameNetworkManager.Instance.localPlayerController.TeleportPlayer(exitPoint.position, false, 0f, false, true);
thisPlayerBody.eulerAngles = new Vector3(thisPlayerBody.eulerAngles.x, exitPoint.eulerAngles.y, thisPlayerBody.eulerAngles.z);
TeleportPlayerServerRpc((int)GameNetworkManager.Instance.localPlayerController.playerClientId);
}
[ServerRpc(RequireOwnership = false)]
public void TeleportPlayerServerRpc(int playerObj)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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)
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(685105481u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerObj);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 685105481u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
TeleportPlayerClientRpc(playerObj);
}
}
}
[ClientRpc]
public void TeleportPlayerClientRpc(int playerObj)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: 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.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(784327969u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, playerObj);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 784327969u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
{
base.__rpc_exec_stage = (__RpcExecStage)0;
if (!((Object)(object)playersManager.allPlayerScripts[playerObj] == (Object)(object)GameNetworkManager.Instance.localPlayerController))
{
playersManager.allPlayerScripts[playerObj].TeleportPlayer(exitPoint.position, true, exitPoint.eulerAngles.y, false, true);
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected override void __initializeRpcs()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
((NetworkBehaviour)this).__registerRpc(685105481u, new RpcReceiveHandler(__rpc_handler_685105481), "TeleportPlayerServerRpc");
((NetworkBehaviour)this).__registerRpc(784327969u, new RpcReceiveHandler(__rpc_handler_784327969), "TeleportPlayerClientRpc");
((NetworkBehaviour)this).__initializeRpcs();
}
private static void __rpc_handler_685105481(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int playerObj = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
target.__rpc_exec_stage = (__RpcExecStage)1;
((RoomTeleport)(object)target).TeleportPlayerServerRpc(playerObj);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_784327969(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int playerObj = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref playerObj);
target.__rpc_exec_stage = (__RpcExecStage)1;
((RoomTeleport)(object)target).TeleportPlayerClientRpc(playerObj);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "RoomTeleport";
}
}
namespace MelaniePocketRoom
{
[BepInPlugin("MelanieMelicious.pocketRoomLib", "Melanie Melicious - Pocket Room Library", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "MelanieMelicious.pocketRoomLib";
private const string NAME = "Melanie Melicious - Pocket Room Library";
private const string VERSION = "1.0.1";
private readonly Harmony harmony = new Harmony("MelanieMelicious.pocketRoomLib");
public static ManualLogSource mls;
public static AssetBundle bundle;
public static Plugin instance;
private void Awake()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
instance = this;
PocketRoomCfg.SetupConfig(((BaseUnityPlugin)this).Config);
mls = Logger.CreateLogSource("MelanieMelicious - Pocket Room Library");
mls = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll(typeof(HarmonyPatches));
string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "melmpocketlib");
bundle = AssetBundle.LoadFromFile(text);
}
}
}
namespace __GEN
{
internal class NetworkVariableSerializationHelper
{
[RuntimeInitializeOnLoadMethod]
internal static void InitializeSerialization()
{
}
}
}
namespace MelMPocketLib.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}