Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Entrance Blocker v1.0.6
EntranceBlocker.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntranceBlocker.Compatibility.EntranceTeleportOptimizations; using EntranceBlocker.Components; using EntranceBlocker.NetcodePatcher; using EntranceBlocker.Patches; using EntranceBlocker.Utils; using EntranceTeleportOptimizations.Patches; using GameNetcodeStuff; using HarmonyLib; 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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("EntranceTeleportOptimizations")] [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.Components")] [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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EntranceBlocker")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4da56ff2ded5ef14eee4484c1ac1ec918e7cb7da")] [assembly: AssemblyProduct("EntranceBlocker")] [assembly: AssemblyTitle("EntranceBlocker")] [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.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 EntranceBlocker { internal class EBConfig { internal static ConfigEntry<float> blockChance = null; internal static ConfigEntry<string> blacklistedMoons = null; internal static ConfigEntry<string> blacklistedMoonsInside = null; internal static List<string> blacklistedMoonsList = new List<string>(); internal static List<string> blacklistedMoonsInsideList = new List<string>(); internal static ConfigEntry<bool> blockOutsideMainEntrance = null; internal static ConfigEntry<bool> blockInsideMainEntrance = null; internal static ConfigEntry<bool> blockOutsideFireExit = null; internal static ConfigEntry<bool> blockInsideFireExit = null; internal static void CreateConfig(ConfigFile cfg) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown blockChance = cfg.Bind<float>("General", "Chance", 0.6f, new ConfigDescription("...what's not clear? Why are you looking at this description?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); blacklistedMoons = cfg.Bind<string>("General", "Blacklisted moons - outside entrances and fire exits", "823 Bozoros,8 Titan,5 Embrion", (ConfigDescription)null); blacklistedMoonsInside = cfg.Bind<string>("General", "Blacklisted moons - inside entrances and fire exits", "", (ConfigDescription)null); blockOutsideMainEntrance = cfg.Bind<bool>("General", "Block outside main entrance", false, (ConfigDescription)null); blockInsideMainEntrance = cfg.Bind<bool>("General", "Block inside main entrance", false, (ConfigDescription)null); blockOutsideFireExit = cfg.Bind<bool>("General", "Block outside fire exit", true, (ConfigDescription)null); blockInsideFireExit = cfg.Bind<bool>("General", "Block inside fire exit", false, (ConfigDescription)null); blacklistedMoonsList = blacklistedMoons.Value.Split(',').ToList(); blacklistedMoonsInsideList = blacklistedMoonsInside.Value.Split(',').ToList(); if (blockInsideMainEntrance.Value && blockInsideFireExit.Value) { EntranceBlockerPlugin.mls.LogError((object)"You tried to block all exits in the interior. This is not supported. Continue at your own risk."); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("mborsh.EntranceBlocker", "EntranceBlocker", "1.0.5")] public class EntranceBlockerPlugin : BaseUnityPlugin { public const string modGUID = "mborsh.EntranceBlocker"; public const string modName = "EntranceBlocker"; public const string modVersion = "1.0.5"; public static EntranceBlockerPlugin Instance = null; internal static ManualLogSource mls = null; internal static readonly Harmony harmony = new Harmony("mborsh.EntranceBlocker"); internal static AssetBundle assetBundle = null; internal static string assemblyLocation = null; internal static GameObject networkManagerPrefab = null; internal static GameObject entranceBlockerPrefab = null; internal static EntranceBlockerNO networkManager = null; private void Awake() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = ((BaseUnityPlugin)this).Logger; ConfigFile cfg = new ConfigFile(Path.Combine(Paths.ConfigPath, "mborsh.EntranceBlocker.cfg"), true); EBConfig.CreateConfig(cfg); assemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); assetBundle = AssetBundle.LoadFromFile(Path.Combine(assemblyLocation, "entranceblockerassetbundle")); if (Chainloader.PluginInfos.ContainsKey("mattymatty.EntranceTeleportOptimizations")) { harmony.PatchAll(typeof(mattymattyEntranceTeleportPatch)); } else { harmony.PatchAll(typeof(EntranceTeleportPatch)); } harmony.PatchAll(typeof(EntranceTeleportMainPatch)); harmony.PatchAll(typeof(GameNetworkManagerPatch)); NetcodePatcher(); } private static void NetcodePatcher() { 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); } } } } } } namespace EntranceBlocker.Utils { internal class UtilsStuff { internal static Vector3 DoMath(EntranceTeleport __instance) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0062: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)__instance).transform.InverseTransformPoint(__instance.entrancePoint.position); val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Atan2(val.x, val.z) * 57.29578f; float num2 = Mathf.Round(num / 90f) * 90f; Vector3 val2 = Quaternion.Euler(0f, num2, 0f) * Vector3.forward; val2 = ((Vector3)(ref val2)).normalized * magnitude; return ((Component)__instance).transform.TransformPoint(val2); } internal static Vector3 DoRaycast(EntranceTeleport __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_0031: 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_0037: 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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) Vector3 position = __instance.entrancePoint.position; Vector3 position2 = ((Component)__instance).transform.position; position.y = position2.y; Vector3 val = position2 - position; Vector3 normalized = ((Vector3)(ref val)).normalized; float num = Vector3.Distance(position, position2); RaycastHit[] array = Physics.RaycastAll(position, normalized, num, 257); RaycastHit[] array2 = array; for (int i = 0; i < array2.Length; i++) { RaycastHit val2 = array2[i]; if (((Component)((RaycastHit)(ref val2)).transform).gameObject.layer == 0 || ((Component)((RaycastHit)(ref val2)).transform).gameObject.layer == 8) { float x = ((RaycastHit)(ref val2)).point.x; Bounds bounds = ((Collider)((Component)__instance.triggerScript).GetComponent<BoxCollider>()).bounds; return new Vector3(x, ((Bounds)(ref bounds)).center.y, ((RaycastHit)(ref val2)).point.z); } } return Vector3.Lerp(position, position2, 0.85f); } internal static void FunnyMethod() { } } } namespace EntranceBlocker.Patches { internal class EntranceTeleportMainPatch { [HarmonyPostfix] [HarmonyPatch(typeof(EntranceTeleport), "Awake")] private static void EntranceTeleportAwakePatch(EntranceTeleport __instance) { if (GameNetworkManager.Instance.isHostingGame && (!__instance.isEntranceToBuilding || __instance.entranceId != 0 || (!EBConfig.blacklistedMoonsList.Contains(StartOfRound.Instance.currentLevel.PlanetName) && EBConfig.blockOutsideMainEntrance.Value)) && (!__instance.isEntranceToBuilding || __instance.entranceId == 0 || (!EBConfig.blacklistedMoonsList.Contains(StartOfRound.Instance.currentLevel.PlanetName) && EBConfig.blockOutsideFireExit.Value)) && (__instance.isEntranceToBuilding || __instance.entranceId != 0 || (!EBConfig.blacklistedMoonsInsideList.Contains(StartOfRound.Instance.currentLevel.PlanetName) && EBConfig.blockInsideMainEntrance.Value)) && (__instance.isEntranceToBuilding || __instance.entranceId == 0 || (!EBConfig.blacklistedMoonsInsideList.Contains(StartOfRound.Instance.currentLevel.PlanetName) && EBConfig.blockInsideFireExit.Value)) && !(Random.Range(0f, 1f) > EBConfig.blockChance.Value)) { ((MonoBehaviour)EntranceBlockerPlugin.networkManager).StartCoroutine(EntranceBlockerPlugin.networkManager.WaitForNetworkSpawnServer(__instance)); } } [HarmonyPrefix] [HarmonyPatch(typeof(NetworkBehaviour), "OnDestroy")] private static void OnTeleportDestroy(NetworkBehaviour __instance) { EntranceTeleport val = (EntranceTeleport)(object)((__instance is EntranceTeleport) ? __instance : null); if (val != null) { if (EntranceBlockerPlugin.networkManager.blockersDict.TryGetValue(((NetworkBehaviour)val).NetworkObjectId, out EntranceBlocker.Components.EntranceBlocker value)) { Object.Destroy((Object)(object)((Component)value).gameObject); } EntranceBlockerPlugin.networkManager.entranceTeleportsBoolMap.Remove(val); EntranceBlockerPlugin.networkManager.entranceTeleports.Remove(val); } } [HarmonyBefore(new string[] { "mattymatty.EntranceTeleportOptimizations" })] [HarmonyTranspiler] [HarmonyPatch(typeof(EntranceTeleport), "Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(EntranceBlockerNO), "CheckEntrances", (Type[])null, (Type[])null); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(EntranceTeleport), "FindExitPoint", (Type[])null, (Type[])null), (string)null) }).RemoveInstruction().Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }) .SetInstruction(new CodeInstruction(OpCodes.Call, (object)methodInfo)); return val.InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch(typeof(EntranceTeleport), "FindExitPoint")] private static IEnumerable<CodeInstruction> FindExitPointTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); MethodInfo methodInfo = AccessTools.Method(typeof(EntranceBlockerNO), "AddEntrances", (Type[])null, (Type[])null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(EntranceTeleport), "exitPoint"), (string)null) }).Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_0, (object)null), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Ldelem_Ref, (object)null), new CodeInstruction(OpCodes.Call, (object)methodInfo) }); return val.InstructionEnumeration(); } [HarmonyPrefix] [HarmonyPatch(typeof(NetworkBehaviour), "OnNetworkSpawn")] private static void OnTeleportSpawn(NetworkBehaviour __instance) { EntranceTeleport val = (EntranceTeleport)(object)((__instance is EntranceTeleport) ? __instance : null); if (val != null) { EntranceBlockerPlugin.networkManager.entranceTeleportsBoolMap.Add(val, value: true); } } } internal class EntranceTeleportPatch { [HarmonyPostfix] [HarmonyPatch(typeof(EntranceTeleport), "FindExitPoint")] private static void FindExitPointPostfix(ref bool __result, EntranceTeleport __instance) { bool flag = __result && EntranceBlockerNO.CheckEntrances(__instance); EntranceBlockerPlugin.mls.LogInfo((object)$"__result = {__result}, value = {flag}, check = {EntranceBlockerNO.CheckEntrances(__instance)}"); __result = flag; } } internal class GameNetworkManagerPatch { [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "Start")] private static void GameNetworkManagerStartPatch() { EntranceBlockerPlugin.entranceBlockerPrefab = EntranceBlockerPlugin.assetBundle.LoadAsset<GameObject>("planks.prefab"); EntranceBlockerPlugin.networkManagerPrefab = EntranceBlockerPlugin.assetBundle.LoadAsset<GameObject>("nobject.prefab"); NetworkManager.Singleton.AddNetworkPrefab(EntranceBlockerPlugin.networkManagerPrefab); EntranceBlockerPlugin.mls.LogInfo((object)"Unloading assetbundles..."); EntranceBlockerPlugin.assetBundle.UnloadAsync(false); } [HarmonyPrefix] [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] public static void GameNetworkManagerDisconnectPatch(GameNetworkManager __instance) { if (!__instance.isHostingGame) { EntranceBlockerPlugin.networkManager = null; } else { ((NetworkBehaviour)EntranceBlockerPlugin.networkManager).NetworkObject.Despawn(true); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "SetLobbyJoinable")] public static void GameNetworkManagerSetLobbyJoinablePatch(GameNetworkManager __instance) { if (__instance.isHostingGame) { if (Object.op_Implicit((Object)(object)EntranceBlockerPlugin.networkManager) && Object.op_Implicit((Object)(object)((NetworkBehaviour)EntranceBlockerPlugin.networkManager).NetworkObject)) { EntranceBlockerPlugin.mls.LogDebug((object)"Network manager already exists! Destroying..."); ((NetworkBehaviour)EntranceBlockerPlugin.networkManager).NetworkObject.Despawn(true); } GameObject val = Object.Instantiate<GameObject>(EntranceBlockerPlugin.networkManagerPrefab); NetworkObject component = val.GetComponent<NetworkObject>(); component.Spawn(false); Object.DontDestroyOnLoad((Object)(object)val); } } } } namespace EntranceBlocker.Components { internal class EntranceBlocker : MonoBehaviour, IHittable { public List<GameObject> blockers = new List<GameObject>(); internal EntranceTeleport entranceTeleport = null; internal EntranceTeleport exitSideTeleport = null; private bool canHit = false; private bool isWaitingForSpawn = true; public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerWhoHit != (Object)null) { EntranceBlockerPlugin.mls.LogInfo((object)$"Hit! Source: {playerWhoHit.playerUsername}, canHit: {canHit}"); } else { EntranceBlockerPlugin.mls.LogInfo((object)$"Hit! Source: NOT PLAYER, canHit: {canHit}"); } if (!canHit) { return true; } NetworkBehaviourReference noRef = EntranceBlockerPlugin.networkManager.reverseBlockersDict[this]; EntranceBlockerPlugin.networkManager.OnHitServerRpc(noRef); return true; } private IEnumerator WaitForNetworkSpawn() { yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)entranceTeleport != (Object)null)); EntranceBlockerPlugin.mls.LogInfo((object)$"EntranceTeleport {((Object)((Component)entranceTeleport).gameObject).name} with id: {entranceTeleport.entranceId} is now networked and ready for block"); EntranceBlockerPlugin.networkManager.blockersDict.Add(((NetworkBehaviour)entranceTeleport).NetworkObjectId, this); EntranceBlockerPlugin.networkManager.reverseBlockersDict.Add(this, new NetworkBehaviourReference((NetworkBehaviour)(object)entranceTeleport)); EntranceBlockerPlugin.networkManager.entranceTeleportsBoolMap[entranceTeleport] = false; canHit = true; isWaitingForSpawn = false; entranceTeleport.triggerScript.interactable = false; } private void Awake() { EntranceBlockerPlugin.mls.LogInfo((object)"EntranceBlocker awake!"); ((MonoBehaviour)this).StartCoroutine(WaitForNetworkSpawn()); } private void OnDestroy() { entranceTeleport.triggerScript.interactable = true; EntranceBlockerPlugin.networkManager.blockersDict.Remove(((NetworkBehaviour)entranceTeleport).NetworkObjectId); EntranceBlockerPlugin.networkManager.reverseBlockersDict.Remove(this); EntranceBlockerPlugin.networkManager.entranceTeleportsBoolMap[entranceTeleport] = true; EntranceBlockerPlugin.mls.LogInfo((object)"Entrance blocker destroyed"); } } internal class EntranceBlockerNO : NetworkBehaviour { internal Dictionary<EntranceTeleport, EntranceTeleport> entranceTeleports = new Dictionary<EntranceTeleport, EntranceTeleport>(); internal Dictionary<EntranceTeleport, bool> entranceTeleportsBoolMap = new Dictionary<EntranceTeleport, bool>(); internal Dictionary<ulong, EntranceBlocker> blockersDict = new Dictionary<ulong, EntranceBlocker>(); internal Dictionary<EntranceBlocker, NetworkBehaviourReference> reverseBlockersDict = new Dictionary<EntranceBlocker, NetworkBehaviourReference>(); public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); EntranceBlockerPlugin.networkManager = this; } [ClientRpc] internal void SpawnBlockerClientRpc(NetworkBehaviourReference noRef) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00e4: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2498473435u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref noRef, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2498473435u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ((MonoBehaviour)this).StartCoroutine(WaitForNetworkSpawnClient(noRef)); } } } internal IEnumerator WaitForNetworkSpawnServer(EntranceTeleport entranceTeleport) { EntranceTeleport entranceTeleport2 = entranceTeleport; yield return (object)new WaitUntil((Func<bool>)(() => ((NetworkBehaviour)entranceTeleport2).NetworkObject.IsSpawned)); SpawnBlockerClientRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)entranceTeleport2)); } internal IEnumerator WaitForNetworkSpawnClient(NetworkBehaviourReference noRef) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) EntranceTeleport val = default(EntranceTeleport); yield return (object)new WaitUntil((Func<bool>)(() => ((NetworkBehaviourReference)(ref noRef)).TryGet<EntranceTeleport>(ref val, (NetworkManager)null))); EntranceTeleport __instance = default(EntranceTeleport); ((NetworkBehaviourReference)(ref noRef)).TryGet<EntranceTeleport>(ref __instance, (NetworkManager)null); GameObject gameobject = Object.Instantiate<GameObject>(EntranceBlockerPlugin.entranceBlockerPrefab); gameobject.GetComponent<EntranceBlocker>().entranceTeleport = __instance; Vector3 globalPosition = UtilsStuff.DoMath(__instance); gameobject.transform.position = ((Component)__instance).transform.position; gameobject.transform.LookAt(globalPosition); gameobject.transform.position = UtilsStuff.DoRaycast(__instance); gameobject.transform.localScale = new Vector3((__instance.entranceId == 0) ? 1.3f : 0.75f, 1f, 1f); EntranceBlockerPlugin.mls.LogDebug((object)("Spawn entranceBlocker! Entrance name: " + ((Object)((Component)__instance).gameObject).name + ";" + $" EntranceID: {__instance.entranceId}; entranceBlocker position: {gameobject.transform.position}; LookAt() position: {globalPosition}")); } [ServerRpc(RequireOwnership = false)] internal void OnHitServerRpc(NetworkBehaviourReference noRef) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0112: 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(2210784886u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref noRef, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2210784886u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; EntranceTeleport val3 = default(EntranceTeleport); ((NetworkBehaviourReference)(ref noRef)).TryGet<EntranceTeleport>(ref val3, (NetworkManager)null); EntranceBlocker entranceBlocker = blockersDict[((NetworkBehaviour)val3).NetworkObjectId]; if (entranceBlocker.blockers.Count == 1) { DestroyClientRpc(noRef); return; } int random = Random.Range(0, entranceBlocker.blockers.Count); OnHitClientRpc(random, ((NetworkBehaviour)val3).NetworkObjectId); } } [ClientRpc] private void OnHitClientRpc(int random, ulong noID) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(722915830u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, random); BytePacker.WriteValueBitPacked(val2, noID); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 722915830u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; EntranceBlocker entranceBlocker = blockersDict[noID]; entranceBlocker.blockers[random].SetActive(false); entranceBlocker.blockers.Remove(entranceBlocker.blockers[random]); } } } [ClientRpc] private void DestroyClientRpc(NetworkBehaviourReference noRef) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1269090937u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref noRef, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1269090937u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; EntranceTeleport val3 = default(EntranceTeleport); ((NetworkBehaviourReference)(ref noRef)).TryGet<EntranceTeleport>(ref val3, (NetworkManager)null); EntranceBlocker entranceBlocker = blockersDict[((NetworkBehaviour)val3).NetworkObjectId]; entranceTeleports.Remove(val3); reverseBlockersDict.Remove(entranceBlocker); blockersDict.Remove(((NetworkBehaviour)val3).NetworkObjectId); Object.Destroy((Object)(object)((Component)entranceBlocker).gameObject); } } } public static void AddEntrances(EntranceTeleport entrance, EntranceTeleport exit) { EntranceBlockerPlugin.networkManager.entranceTeleports.TryAdd(entrance, exit); } public static bool CheckEntrances(EntranceTeleport entrance) { EntranceBlockerNO networkManager = EntranceBlockerPlugin.networkManager; bool flag = true; if (!networkManager.entranceTeleports.TryGetValue(entrance, out EntranceTeleport value)) { return false; } networkManager.entranceTeleportsBoolMap.TryGetValue(entrance, out var value2); flag = flag && value2; networkManager.entranceTeleportsBoolMap.TryGetValue(value, out value2); return flag && value2; } 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 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2498473435u, new RpcReceiveHandler(__rpc_handler_2498473435), "SpawnBlockerClientRpc"); ((NetworkBehaviour)this).__registerRpc(2210784886u, new RpcReceiveHandler(__rpc_handler_2210784886), "OnHitServerRpc"); ((NetworkBehaviour)this).__registerRpc(722915830u, new RpcReceiveHandler(__rpc_handler_722915830), "OnHitClientRpc"); ((NetworkBehaviour)this).__registerRpc(1269090937u, new RpcReceiveHandler(__rpc_handler_1269090937), "DestroyClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2498473435(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference noRef = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref noRef, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((EntranceBlockerNO)(object)target).SpawnBlockerClientRpc(noRef); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2210784886(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference noRef = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref noRef, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((EntranceBlockerNO)(object)target).OnHitServerRpc(noRef); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_722915830(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int random = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref random); ulong noID = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref noID); target.__rpc_exec_stage = (__RpcExecStage)1; ((EntranceBlockerNO)(object)target).OnHitClientRpc(random, noID); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1269090937(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference noRef = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref noRef, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((EntranceBlockerNO)(object)target).DestroyClientRpc(noRef); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "EntranceBlockerNO"; } } } namespace EntranceBlocker.Compatibility.Mimics { internal class MimicPatches { } } namespace EntranceBlocker.Compatibility.EntranceTeleportOptimizations { internal class mattymattyEntranceTeleportPatch { public static bool CheckEntrances(EntranceTeleport entrance) { EntranceBlockerNO networkManager = EntranceBlockerPlugin.networkManager; bool flag = true; networkManager.entranceTeleports = EntranceTeleportPatches.TeleportMap; if (!networkManager.entranceTeleports.TryGetValue(entrance, out EntranceTeleport value)) { return false; } networkManager.entranceTeleportsBoolMap.TryGetValue(entrance, out var value2); flag = flag && value2; networkManager.entranceTeleportsBoolMap.TryGetValue(value, out value2); return flag && value2; } [HarmonyPostfix] [HarmonyPatch(typeof(EntranceTeleport), "FindExitPoint")] private static void FindExitPointPostfix(ref bool __result, EntranceTeleport __instance) { bool flag = __result && CheckEntrances(__instance); EntranceBlockerPlugin.mls.LogInfo((object)$"mattymatty__result = {__result}, value = {flag}, check = {EntranceBlockerNO.CheckEntrances(__instance)}"); __result = flag; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace EntranceBlocker.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }