Decompiled source of LycansNewMaps v0.21.0
plugins/LycansNewMaps/LycansNewMaps.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using Fusion; using Fusion.Sockets; using HarmonyLib; using HarmonyLib.Tools; using Helpers.Collections; using LycansNewMaps.SpecialArchitecture; using Managers; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Localization; using UnityEngine.Localization.Components; using UnityEngine.Localization.Settings; using UnityEngine.Localization.Tables; using UnityEngine.Scripting; using UnityEngine.UI; [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: AssemblyCompany("LycansNewMaps")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7c3403b6cdd386a7633cb0b697f18316ec177982")] [assembly: AssemblyProduct("My first plugin")] [assembly: AssemblyTitle("LycansNewMaps")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LycansNewMaps { public class CustomSpawnComponent : MonoBehaviour { public string PrefabName; } public class DoorCustom : MonoBehaviour { private void Start() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown try { if ((Object)(object)GameManager.Instance == (Object)null) { return; } float? num = null; IEnumerable<GameObject> enumerable = from o in Object.FindObjectsOfType<GameObject>() where ((Object)o).name == "Doors" select o; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.y, ((Component)this).transform.position.z); Transform parent = null; foreach (GameObject item in enumerable) { for (int i = 0; i < item.transform.childCount; i++) { Transform child = item.transform.GetChild(i); float num2 = Vector3.Distance(val, ((Component)child).transform.position); if (!num.HasValue || num2 < num.Value) { num = num2; parent = child; } } } Animator component = ((Component)this).GetComponent<Animator>(); if (component.runtimeAnimatorController.animationClips[1].events.Length == 0) { component.runtimeAnimatorController.animationClips[1].AddEvent(new AnimationEvent { functionName = "PlayOpenSoundCustom" }); component.runtimeAnimatorController.animationClips[1].AddEvent(new AnimationEvent { time = component.runtimeAnimatorController.animationClips[1].length, functionName = "AnimationEndedCustom" }); } if (component.runtimeAnimatorController.animationClips[3].events.Length == 0) { component.runtimeAnimatorController.animationClips[3].AddEvent(new AnimationEvent { functionName = "PlayCloseSoundCustom" }); component.runtimeAnimatorController.animationClips[3].AddEvent(new AnimationEvent { time = component.runtimeAnimatorController.animationClips[3].length, functionName = "AnimationEndedCustom" }); } ((Component)this).gameObject.transform.parent = parent; } catch (Exception ex) { Plugin.Logger.LogError((object)("DoorCustom start error: " + ex)); } } private void PlayOpenSoundCustom() { ((Component)this).GetComponent<Door>().PlayOpenSound(); } private void PlayCloseSoundCustom() { ((Component)this).GetComponent<Door>().PlayCloseSound(); } private void AnimationEndedCustom() { ((Component)this).GetComponent<Door>().AnimationEnded(); } } public static class DungeonMap { public const string DungeonMapName = "dungeonmap"; public static Color TorchColorDaytime = new Color(1f, 0.9f, 0.8f, 1f); public static Color TorchColorMostlyDay = new Color(1f, 0.75f, 0.6f, 1f); public static Color TorchColorMostlyNight = new Color(1f, 0.6f, 0.4f, 1f); public static Color TorchColorNight = new Color(1f, 0.5f, 0.3f, 1f); public static float TorchIntensityDaytime = 1f; public static float TorchIntensityMostlyDay = 0.8f; public static float TorchIntensityMostlyNight = 0.65f; public static float TorchIntensityNight = 0.5f; public static Color CurrentTorchColor = TorchColorDaytime; public static List<Light> Lights = new List<Light>(); } [HarmonyPatch(typeof(LightingManager), "UpdateLighting")] public class UpdateTorchLightsPatch { private static void Postfix(LightingManager __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) try { if ((int)GameManager.LocalGameState != 2 || GameManager.Instance.MapID != MapManager.FindMapIdByName("dungeonmap")) { return; } float value = Traverse.Create((object)__instance).Field<float>("_localTimeOfDay").Value; Color val = DungeonMap.TorchColorDaytime; float intensity = DungeonMap.TorchIntensityDaytime; if (value >= 6f && value <= 15f) { val = DungeonMap.TorchColorDaytime; intensity = DungeonMap.TorchIntensityDaytime; } else if (value > 15f && value <= 17f) { val = DungeonMap.TorchColorMostlyDay; intensity = DungeonMap.TorchIntensityMostlyDay; } else if (value > 17f && value <= 18f) { val = DungeonMap.TorchColorMostlyNight; intensity = DungeonMap.TorchIntensityMostlyNight; } else if (value > 18f || value <= 3f) { val = DungeonMap.TorchColorNight; intensity = DungeonMap.TorchIntensityNight; } else if (value > 3f && value <= 5f) { val = DungeonMap.TorchColorMostlyNight; intensity = DungeonMap.TorchIntensityMostlyNight; } else if (value > 5f && value <= 6f) { val = DungeonMap.TorchColorMostlyDay; intensity = DungeonMap.TorchIntensityMostlyDay; } if (!(DungeonMap.CurrentTorchColor != val)) { return; } DungeonMap.CurrentTorchColor = val; foreach (Light light in DungeonMap.Lights) { light.color = val; light.intensity = intensity; } } catch (Exception ex) { Plugin.Logger.LogError((object)("UpdateTorchLightsPatch error: " + ex)); } } } public static class GlobalManager { public static string PlayerMapCustomRegistryName => "LycansNewMaps.PlayerMapCustomRegistry"; public static string PlayerMapCustomName => "LycansNewMaps.PlayerMapCustom"; public static string GetPrefabName(string baseName) { return baseName; } } [HarmonyPatch(typeof(GameManager), "Spawned")] internal class GlobalManagerGameManagerSpawnedPatch { private static void Postfix(GameManager __instance) { //IL_003a: 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_0047: Unknown result type (might be due to invalid IL or missing references) try { if (((SimulationBehaviour)__instance).Runner.SessionInfo.IsOpen && ((SimulationBehaviour)__instance).Runner.IsServer) { NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(GlobalManager.PlayerMapCustomRegistryName)); ((SimulationBehaviour)__instance).Runner.Spawn(networkObject, (Vector3?)null, (Quaternion?)null, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null); } } catch (Exception ex) { Plugin.Logger.LogError((object)("Error: " + ex)); } } } [HarmonyPatch(typeof(NetworkRunner), "Awake")] internal class GlobalManagerNetworkRunnerAwakeCreatePrefabsPatch { private static void Prefix(NetworkRunner __instance) { try { Plugin.CreatePrefabs(); } catch (Exception ex) { Plugin.Logger.LogError((object)("NetworkRunner Awake error: " + ex)); } } } [HarmonyPatch(typeof(NetworkRunner), "OnDestroy")] internal class GlobalManagerNetworkRunnerOnDestroyUnloadPrefabsPatch { private static void Prefix(NetworkRunner __instance) { try { NetworkObjectService.Instance.Clear(); NetworkProjectConfig.UnloadGlobal(); } catch (Exception ex) { Plugin.Logger.LogError((object)("GlobalManagerNetworkRunnerOnDestroyUnloadPrefabsPatch Awake error: " + ex)); } } } [HarmonyPatch(typeof(CharacterMovementHandler), "FixedUpdateNetwork")] internal class ChangeGravityPatch { private static void Postfix(CharacterMovementHandler __instance) { try { if ((Object)(object)((Component)__instance).gameObject.GetComponent<GravityComponent>() == (Object)null) { Traverse.Create((object)__instance).Field<NetworkCharacterControllerPrototypeCustom>("_networkCharacterControllerPrototypeCustom").Value.gravity = -40f; if (((SimulationBehaviour)__instance).HasStateAuthority) { ((Component)__instance).gameObject.AddComponent<GravityComponent>(); } } } catch (Exception ex) { Plugin.Logger.LogError((object)("ChangeGravityPatch error: " + ex)); } } } public class GravityComponent : MonoBehaviour { private CharacterMovementHandler _characterMovementHandler; private NetworkCharacterControllerPrototypeCustom _networkCharacterControllerPrototypeCustom; private PlayerController _playerController; private float? _initialY = null; private void Awake() { _characterMovementHandler = ((Component)this).GetComponent<CharacterMovementHandler>(); _networkCharacterControllerPrototypeCustom = Traverse.Create((object)_characterMovementHandler).Field<NetworkCharacterControllerPrototypeCustom>("_networkCharacterControllerPrototypeCustom").Value; _playerController = ((Component)this).GetComponent<PlayerController>(); } private void Update() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Invalid comparison between Unknown and I4 //IL_0103: Unknown result type (might be due to invalid IL or missing references) bool isGrounded = _networkCharacterControllerPrototypeCustom.IsGrounded; if (!isGrounded && !_initialY.HasValue) { _initialY = ((Component)_playerController).transform.position.y; } if (!isGrounded || !_initialY.HasValue) { return; } float num = _initialY.Value - ((Component)_playerController).transform.position.y; if ((int)GameManager.LocalGameState == 2 && num > 3f) { float num2 = (float)GameManager.Instance.MaxHunger * (num * 0.05f); PlayerController value = Traverse.Create((object)_characterMovementHandler).Field<PlayerController>("_playerController").Value; value.Hunger = Math.Max(value.Hunger - num2, 0f); if (value.Hunger <= 0f) { value.Rpc_Kill(PlayerRef.None); } } _initialY = null; } } public class InputManagerExtra : MonoBehaviour { public const string ShowMinimap = "SHOWMINIMAP"; private static InputManagerExtra _instance; private Dictionary<string, InputAction> _actions = new Dictionary<string, InputAction>(); public static InputManagerExtra Instance { get { if ((Object)(object)_instance == (Object)null) { _instance = ((Component)InputManager.Instance).gameObject.AddComponent<InputManagerExtra>(); } return _instance; } } public Dictionary<string, InputAction> Actions => _actions; public bool ShowMinimapJustPressed { get; private set; } public void AddAction(InputAction action) { _actions[action.name] = action; } private void Update() { ShowMinimapJustPressed = _actions["SHOWMINIMAP"].WasPerformedThisFrame(); } public InputAction GetAction(string actionName) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (_actions.ContainsKey(actionName)) { return _actions[actionName]; } return InputManager.Instance.GetInputAction(Enum.Parse<InputActionName>(actionName)); } public static void CreateAction(InputManager inputManager, string actionName, string keyboardBinding, string gamepadBinding, string keyboardBindingGuid, string gamepadBindingGuid) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00cc: 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_0043: Unknown result type (might be due to invalid IL or missing references) InputActionMap currentActionMap = ((Component)inputManager).GetComponent<PlayerInput>().currentActionMap; if (((IEnumerable<InputAction>)(object)currentActionMap.actions).Any((InputAction o) => o.name == actionName)) { Instance.AddAction(((IEnumerable<InputAction>)(object)currentActionMap.actions).First((InputAction o) => o.name == actionName)); return; } currentActionMap.Disable(); InputAction val = InputActionSetupExtensions.AddAction(currentActionMap, actionName, (InputActionType)1, (string)null, (string)null, (string)null, (string)null, (string)null); InputBinding val2 = default(InputBinding); ((InputBinding)(ref val2))..ctor(keyboardBinding, (string)null, "Keyboard", (string)null, (string)null, (string)null); ((InputBinding)(ref val2)).id = new Guid(keyboardBindingGuid); InputBinding val3 = default(InputBinding); ((InputBinding)(ref val3))..ctor(gamepadBinding, (string)null, "Gamepad", (string)null, (string)null, (string)null); ((InputBinding)(ref val3)).id = new Guid(gamepadBindingGuid); InputActionSetupExtensions.AddBinding(val, val2); InputActionSetupExtensions.AddBinding(val, val3); currentActionMap.Enable(); Instance.AddAction(val); Plugin.Logger.LogInfo((object)("Added action: " + val.name)); } public static void AddActionToUI(GameUI gameUI, string actionName) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) RebindActionUI val = Object.FindObjectOfType<RebindActionUI>(true); RebindActionUI val2 = Object.Instantiate<RebindActionUI>(val, Traverse.Create((object)gameUI).Field<GameObject>("settingsMenuKeyboard").Value.transform); InputAction val3 = Instance.Actions[actionName]; InputActionReference val4 = ScriptableObject.CreateInstance<InputActionReference>(); val4.Set(val3); val2.actionReference = val4; InputBinding val5 = val3.bindings[0]; val2.bindingId = ((InputBinding)(ref val5)).id.ToString(); CustomKeyComponent customKeyComponent = ((Component)val2).gameObject.AddComponent<CustomKeyComponent>(); customKeyComponent.TranslateKey = actionName; customKeyComponent.UpdateActionText(); RebindActionUI val6 = Object.Instantiate<RebindActionUI>(val, Traverse.Create((object)gameUI).Field<GameObject>("settingsMenuGamepad").Value.transform); val6.actionReference = val4; val5 = val3.bindings[1]; val6.bindingId = ((InputBinding)(ref val5)).id.ToString(); CustomKeyComponent customKeyComponent2 = ((Component)val6).gameObject.AddComponent<CustomKeyComponent>(); customKeyComponent2.TranslateKey = actionName; customKeyComponent2.UpdateActionText(); } } public class LadderCustom : MonoBehaviour { private void Start() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)GameManager.Instance == (Object)null) { return; } float? num = null; IEnumerable<GameObject> enumerable = from o in Object.FindObjectsOfType<GameObject>() where ((Object)o).name == "Ladders" select o; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.y, ((Component)this).transform.position.z); Transform parent = null; foreach (GameObject item in enumerable) { for (int i = 0; i < item.transform.childCount; i++) { Transform child = item.transform.GetChild(i); float num2 = Vector3.Distance(val, ((Component)child).transform.position); if (!num.HasValue || num2 < num.Value) { num = num2; parent = child; } } } ((Component)this).gameObject.transform.parent = parent; } catch (Exception ex) { Plugin.Logger.LogError((object)("LadderCustom start error: " + ex)); } } } public static class MapManager { public static Dictionary<int, CustomMap> NewMapsByIdInfo = new Dictionary<int, CustomMap>(); public static Dictionary<int, GameObject> NewMapsById = new Dictionary<int, GameObject>(); public static void UpdateMapByPlayersAmount() { try { if (GameManager.Instance.MapID <= 2) { return; } int num = PlayerRegistry.CountWhere((Predicate<PlayerController>)((PlayerController o) => !NetworkBool.op_Implicit(o.IsDead))); GameObject[] source = Resources.FindObjectsOfTypeAll<GameObject>(); foreach (GameObject item in source.Where((GameObject o) => ((Object)o).name.ToLower().Contains("minimumplayers"))) { int num2 = int.Parse(((Object)item).name.ToLower().Replace("minimumplayers", "")); item.SetActive(num >= num2); } foreach (GameObject item2 in source.Where((GameObject o) => ((Object)o).name.ToLower().Contains("maximumplayers"))) { int num3 = int.Parse(((Object)item2).name.ToLower().Replace("maximumplayers", "")); item2.SetActive(num <= num3); } } catch (Exception ex) { Plugin.Logger.LogError((object)("UpdateMapByPlayersAmount error: " + ex)); } } public static int? FindMapIdByName(string mapName) { if (NewMapsByIdInfo.Any((KeyValuePair<int, CustomMap> o) => o.Value.MapName == mapName)) { return NewMapsByIdInfo.First((KeyValuePair<int, CustomMap> o) => o.Value.MapName == mapName).Key; } return null; } } public class CustomMap { public GameObject MapPrefab; public string MapName; } [HarmonyPatch(typeof(GameState), "Spawned")] internal class GameStateSpawnedPostfix { private static void Postfix(GameState __instance) { try { StateMachine<EGameState> value = Traverse.Create((object)__instance).Field<StateMachine<EGameState>>("StateMachine").Value; StateHooks<EGameState> obj = value[(EGameState)2]; obj.onEnter = (Action<EGameState>)Delegate.Combine(obj.onEnter, (Action<EGameState>)delegate(EGameState state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)state == 1) { MapManager.UpdateMapByPlayersAmount(); } }); StateHooks<EGameState> obj2 = value[(EGameState)3]; obj2.onEnter = (Action<EGameState>)Delegate.Combine(obj2.onEnter, (Action<EGameState>)delegate(EGameState state) { //IL_0006: 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_0014: Invalid comparison between Unknown and I4 if (!NetworkBool.op_Implicit(GameManager.LightingManager.IsNight) || (int)state == 4) { MapManager.UpdateMapByPlayersAmount(); } }); StateHooks<EGameState> obj3 = value[(EGameState)2]; obj3.onEnter = (Action<EGameState>)Delegate.Combine(obj3.onEnter, (Action<EGameState>)delegate(EGameState state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)state == 4) { MapManager.UpdateMapByPlayersAmount(); } }); } catch (Exception ex) { Plugin.Logger.LogError((object)("GameManagerStartGamePatch error: " + ex)); } } } [HarmonyPatch(typeof(GameManager), "StartGame")] internal class GameManagerStartGamePatch { private static void Prefix(GameManager __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 try { if (((SimulationBehaviour)__instance).Runner.IsServer && (int)GameManager.State.Current == 1) { MapManager.UpdateMapByPlayersAmount(); } } catch (Exception ex) { Plugin.Logger.LogError((object)("GameManagerStartGamePatch error: " + ex)); } } } [HarmonyPatch(typeof(GameManager), "EndVote")] internal class GameManagerEndVotePatch { private static void Postfix(GameManager __instance) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkBool.op_Implicit(__instance.IsFinished)) { MapManager.UpdateMapByPlayersAmount(); } } catch (Exception ex) { Plugin.Logger.LogError((object)("GameManagerEndVotePatch error: " + ex)); } } } [HarmonyPatch(typeof(GameManager), "Awake")] internal class GameManagerAwakePatch { private static void Prefix(GameManager __instance) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) try { foreach (KeyValuePair<int, GameObject> item2 in MapManager.NewMapsById) { Object.Destroy((Object)(object)item2.Value); } MapManager.NewMapsById.Clear(); int num = 3000; int num2 = 3; List<GameObject> list = Traverse.Create((object)__instance).Field<GameObject[]>("maps").Value.ToList(); foreach (KeyValuePair<int, AssetBundle> item3 in Plugin.AssetBundlesByMapId) { string[] allAssetNames = item3.Value.GetAllAssetNames(); string text = allAssetNames.FirstOrDefault((string o) => o.Contains("map.prefab")); if (!MapManager.NewMapsByIdInfo.ContainsKey(item3.Key)) { GameObject val = item3.Value.LoadAsset<GameObject>(text); val.SetActive(false); MapManager.NewMapsByIdInfo[item3.Key] = new CustomMap { MapPrefab = val, MapName = ((Object)item3.Value).name }; } GameObject val2 = Object.Instantiate<GameObject>(MapManager.NewMapsByIdInfo[item3.Key].MapPrefab, new Vector3(0f, 0f, (float)num), Quaternion.identity, GameObject.Find("World").transform); val2.SetActive(true); MapManager.NewMapsById[num2] = val2; list.Add(val2); GameObject[] source = Object.FindObjectsOfType<GameObject>(true); List<GameObject> list2 = source.Where((GameObject obj) => ((Object)obj).name.ToLower() == "teleporter").ToList(); foreach (GameObject item4 in list2) { item4.gameObject.RemoveAllChildren(); Teleporter val3 = item4.gameObject.AddComponent<Teleporter>(); Traverse.Create((object)val3).Field<int>("mapID").Value = num2; } List<GameObject> list3 = source.Where((GameObject obj) => ((Object)obj).name == "ItemSpawn").ToList(); foreach (GameObject item5 in list3) { item5.gameObject.RemoveAllChildren(); ItemSpawner val4 = item5.gameObject.AddComponent<ItemSpawner>(); Traverse.Create((object)val4).Field<int>("mapID").Value = num2; } List<Transform> list4 = Traverse.Create((object)__instance).Field<Transform[]>("mapSpawns").Value.ToList(); Transform item = MapManager.NewMapsById[num2].transform.Find("MapSpawn"); list4.Add(item); Traverse.Create((object)__instance).Field<Transform[]>("mapSpawns").Value = list4.ToArray(); num += 3000; num2++; } Traverse.Create((object)__instance).Field<GameObject[]>("maps").Value = list.ToArray(); } catch (Exception ex) { Plugin.Logger.LogError((object)("GameManagerAwakePatch error: " + ex)); } } } [HarmonyPatch(typeof(GameManager), "GetAndLockRandomItemSpawn")] internal class GameManagerGetAndLockRandomItemSpawnPatch { private static bool Prefix(GameManager __instance, ref ItemSpawner __result) { try { Dictionary<ItemSpawner, bool> value = Traverse.Create((object)__instance).Field<Dictionary<ItemSpawner, bool>>("_spawnedItems").Value; List<ItemSpawner> list = value.Where(delegate(KeyValuePair<ItemSpawner, bool> sp) { KeyValuePair<ItemSpawner, bool> keyValuePair = sp; int result; if (((Component)keyValuePair.Key).gameObject.activeSelf) { keyValuePair = sp; if (!keyValuePair.Value) { keyValuePair = sp; result = ((keyValuePair.Key.MapID == __instance.MapID) ? 1 : 0); goto IL_003e; } } result = 0; goto IL_003e; IL_003e: return (byte)result != 0; }).ToDictionary((KeyValuePair<ItemSpawner, bool> sp) => sp.Key, (KeyValuePair<ItemSpawner, bool> sp) => sp.Value).Keys.ToList(); if (list.Any()) { ItemSpawner val = CollectionsUtil.Grab<ItemSpawner>(list, 1).First(); value[val] = true; __result = val; return false; } __result = null; return false; } catch (Exception ex) { Plugin.Logger.LogError((object)("GameManagerGetAndLockRandomItemSpawnPatch error: " + ex)); return true; } } } [HarmonyPatch(typeof(GameManager), "MapChanged")] internal class MapChangedPatch { private static void Postfix(Changed<GameManager> changed) { //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_0aab: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0606: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Unknown result type (might be due to invalid IL or missing references) //IL_07a4: Unknown result type (might be due to invalid IL or missing references) //IL_07ac: Unknown result type (might be due to invalid IL or missing references) //IL_07b5: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Unknown result type (might be due to invalid IL or missing references) //IL_096e: Unknown result type (might be due to invalid IL or missing references) //IL_097f: Unknown result type (might be due to invalid IL or missing references) try { GameManager behaviour = changed.Behaviour; if (((SimulationBehaviour)behaviour).Runner.IsServer) { List<Loot> list = (from o in Object.FindObjectsOfType<Loot>(true) where o.GetMapID() >= 3 select o).ToList(); for (int num = list.Count - 1; num >= 0; num--) { ((SimulationBehaviour)behaviour).Runner.Despawn(((Component)list[num]).GetComponent<NetworkObject>(), false); } List<DoorCustom> list2 = Object.FindObjectsOfType<DoorCustom>(false).ToList(); for (int num2 = list2.Count - 1; num2 >= 0; num2--) { ((SimulationBehaviour)behaviour).Runner.Despawn(((Component)list2[num2]).GetComponent<NetworkObject>(), false); } List<PortalCustom> list3 = Object.FindObjectsOfType<PortalCustom>(false).ToList(); for (int num3 = list3.Count - 1; num3 >= 0; num3--) { ((SimulationBehaviour)behaviour).Runner.Despawn(((Component)list3[num3]).GetComponent<NetworkObject>(), false); } List<LadderCustom> list4 = Object.FindObjectsOfType<LadderCustom>(false).ToList(); for (int num4 = list4.Count - 1; num4 >= 0; num4--) { ((SimulationBehaviour)behaviour).Runner.Despawn(((Component)list4[num4]).GetComponent<NetworkObject>(), false); } } if (behaviour.MapID > 2) { GameObject[] source = Object.FindObjectsOfType<GameObject>(true); GameObject val = MapManager.NewMapsById[behaviour.MapID]; List<GameObject> list5 = source.Where((GameObject obj) => ((Object)obj).name == "FoodSpawn").ToList(); foreach (GameObject item in list5) { if (!item.gameObject.activeSelf) { continue; } CustomSpawnComponent component = item.GetComponent<CustomSpawnComponent>(); string text; if ((Object)(object)component != (Object)null) { text = component.PrefabName; } else { Transform child = item.transform.GetChild(0); if ((Object)(object)child == (Object)null) { Plugin.Logger.LogError((object)("Missing food name for: " + ((Object)item).name)); } text = ((Object)((Component)child).gameObject).name; component = item.AddComponent<CustomSpawnComponent>(); component.PrefabName = text; } item.gameObject.RemoveAllChildren(); if (((SimulationBehaviour)behaviour).Runner.IsServer) { NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(text)); NetworkObject val2 = ((SimulationBehaviour)behaviour).Runner.Spawn(networkObject, (Vector3?)item.transform.position, (Quaternion?)item.transform.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null); ((Component)val2).transform.parent = item.transform.parent; Loot component2 = ((Component)val2).GetComponent<Loot>(); Traverse.Create((object)component2).Field<int>("map").Value = behaviour.MapID; } } List<GameObject> list6 = source.Where((GameObject obj) => ((Object)obj).name.Contains("DoorSpawn:")).ToList(); foreach (GameObject item2 in list6) { if (!item2.gameObject.activeSelf) { continue; } CustomSpawnComponent component3 = item2.GetComponent<CustomSpawnComponent>(); string text2; if ((Object)(object)component3 != (Object)null) { text2 = component3.PrefabName; } else { Transform child2 = item2.transform.GetChild(0); if ((Object)(object)child2 == (Object)null) { Plugin.Logger.LogError((object)("Missing door name for: " + ((Object)item2).name)); } text2 = ((Object)((Component)child2).gameObject).name; component3 = item2.AddComponent<CustomSpawnComponent>(); component3.PrefabName = text2; } item2.gameObject.RemoveAllChildren(); if (((SimulationBehaviour)behaviour).Runner.IsServer) { NetworkPrefabId networkObject2 = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(text2)); NetworkObject val3 = ((SimulationBehaviour)behaviour).Runner.Spawn(networkObject2, (Vector3?)item2.transform.position, (Quaternion?)item2.transform.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null); ((Component)val3).transform.parent = item2.transform.parent; } } List<GameObject> list7 = source.Where((GameObject obj) => ((Object)obj).name.Contains("PortalSpawn:")).ToList(); foreach (GameObject item3 in list7) { if (!item3.gameObject.activeSelf) { continue; } CustomSpawnComponent component4 = item3.GetComponent<CustomSpawnComponent>(); string text3; if ((Object)(object)component4 != (Object)null) { text3 = component4.PrefabName; } else { Transform child3 = item3.transform.GetChild(0); if ((Object)(object)child3 == (Object)null) { Plugin.Logger.LogError((object)("Missing portal name for: " + ((Object)item3).name)); } text3 = ((Object)((Component)child3).gameObject).name; component4 = item3.AddComponent<CustomSpawnComponent>(); component4.PrefabName = text3; } item3.gameObject.RemoveAllChildren(); if (((SimulationBehaviour)behaviour).Runner.IsServer) { NetworkPrefabId networkObject3 = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(text3)); NetworkObject val4 = ((SimulationBehaviour)behaviour).Runner.Spawn(networkObject3, (Vector3?)item3.transform.position, (Quaternion?)item3.transform.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null); ((Component)val4).transform.parent = item3.transform.parent; ((Component)val4).GetComponent<PortalCustom>().MapID = behaviour.MapID; } } List<GameObject> list8 = source.Where((GameObject obj) => ((Object)obj).name.Contains("LadderSpawn:")).ToList(); foreach (GameObject item4 in list8) { if (!item4.gameObject.activeSelf) { continue; } CustomSpawnComponent component5 = item4.GetComponent<CustomSpawnComponent>(); string text4; if ((Object)(object)component5 != (Object)null) { text4 = component5.PrefabName; } else { Transform child4 = item4.transform.GetChild(0); if ((Object)(object)child4 == (Object)null) { Plugin.Logger.LogError((object)("Missing ladder name for: " + ((Object)item4).name)); } text4 = ((Object)((Component)child4).gameObject).name; component5 = item4.AddComponent<CustomSpawnComponent>(); component5.PrefabName = text4; } item4.gameObject.RemoveAllChildren(); if (((SimulationBehaviour)behaviour).Runner.IsServer) { NetworkPrefabId networkObject4 = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(text4)); NetworkObject val5 = ((SimulationBehaviour)behaviour).Runner.Spawn(networkObject4, (Vector3?)item4.transform.position, (Quaternion?)item4.transform.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null); ((Component)val5).transform.parent = item4.transform.parent; } } RoomNameComponent.RoomKeyByIndex.Clear(); List<GameObject> source2 = source.Where((GameObject obj) => ((Object)obj).name.Contains("RoomKey")).ToList(); foreach (GameObject item5 in source2.OrderBy((GameObject o) => ((Object)o).name)) { RoomNameComponent roomNameComponent = item5.gameObject.AddComponent<RoomNameComponent>(); roomNameComponent.Init(((Object)item5).name.Replace("RoomKey:", "")); if (!((SimulationBehaviour)behaviour).Runner.IsServer) { Object.Destroy((Object)(object)((Component)roomNameComponent).GetComponent<Collider>()); } } Transform val6 = val.transform.Find("SpecialArchitecture"); if ((Object)(object)val6 != (Object)null) { Transform val7 = val6.Find("MovingFloors"); if ((Object)(object)val7 != (Object)null) { int childCount = val7.childCount; for (int i = 0; i < childCount; i++) { Transform child5 = val7.GetChild(i); MovingPlatform movingPlatform = ((Component)child5).gameObject.AddComponent<MovingPlatform>(); movingPlatform.Init(child5.position, child5.Find("Destination").position); ((Component)child5).gameObject.RemoveAllChildren(); } } } } ((Behaviour)Traverse.Create((object)GameManager.LightingManager).Field<Light>("directionalLight").Value).enabled = behaviour.MapID <= 2; foreach (PlayerMapCustom allPlayer in PlayerMapCustomRegistry.AllPlayers) { allPlayer.Reset(); } DungeonMap.Lights.Clear(); Light[] source3 = Resources.FindObjectsOfTypeAll<Light>(); DungeonMap.Lights.AddRange(source3.Where((Light o) => ((Object)((Component)o).gameObject).name == "RoomCenterLight")); if (behaviour.MapID == MapManager.FindMapIdByName("dungeonmap")) { foreach (Light light in DungeonMap.Lights) { ((Component)light).gameObject.SetActive(true); light.color = DungeonMap.TorchColorDaytime; light.intensity = DungeonMap.TorchIntensityDaytime; } { foreach (PlayerMapCustom allPlayer2 in PlayerMapCustomRegistry.AllPlayers) { allPlayer2.CurrentRoomIndex = RoomNameComponent.RoomKeyByIndex.First((KeyValuePair<int, string> o) => o.Value == "ROOM_CENTRAL").Key; } return; } } AudioManager.PlayMusic("DAY", 1f); foreach (Light light2 in DungeonMap.Lights) { ((Component)light2).gameObject.SetActive(false); } if (behaviour.MapID >= 3) { return; } foreach (PlayerMapCustom allPlayer3 in PlayerMapCustomRegistry.AllPlayers) { allPlayer3.CurrentRoomIndex = 0; } } catch (Exception ex) { Plugin.Logger.LogError((object)("MapChangedPatch error: " + ex)); } } } [HarmonyPatch(typeof(GameSettingsUI), "Start")] internal class GameConfigAddNewMapPatch { private static void Postfix(GameSettingsUI __instance) { try { for (int i = 0; i < Plugin.AssetBundlesByMapId.Count; i++) { Traverse.Create((object)__instance).Field<TMP_Dropdown>("mapDropdown").Value.AddOptions(new List<string> { (i + 3).ToString() }); } Traverse.Create((object)__instance).Method("FillMapDropdown", Array.Empty<object>()).GetValue(); } catch (Exception ex) { Plugin.Logger.LogError((object)("GameConfigAddNewMapPatch error: " + ex)); } } } public class MinimapComponent : MonoBehaviour { private bool _active; private GameObject _panel; private Image _image; private Image _playerIcon; private Vector3 _playerPositionBeforeMeeting; private void Start() { _panel = ((Component)((Component)this).transform.Find("Panel")).gameObject; _image = ((Component)_panel.transform.Find("MinimapImage")).GetComponent<Image>(); _playerIcon = ((Component)_panel.transform.Find("Player")).GetComponent<Image>(); Transform val = _panel.transform.Find("Texts"); for (int i = 0; i < val.childCount; i++) { Transform child = val.GetChild(i); ((TMP_Text)((Component)child).GetComponent<TextMeshProUGUI>()).text = TranslationManager.Instance.GetTranslation(((Object)child).name); } SetActive(active: false); } private void Update() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Invalid comparison between Unknown and I4 //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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) EGameState localGameState = GameManager.LocalGameState; if ((int)localGameState == 0 || (int)localGameState == 3 || (int)localGameState == 5 || GameManager.Instance.MapID < 3) { if (_active) { SetActive(active: false); } return; } if (InputManagerExtra.Instance.ShowMinimapJustPressed) { if (!_active) { SetActive(active: true); } else { SetActive(active: false); } } if (_active) { Vector3 val; if ((int)GameManager.LocalGameState == 4) { _ = _playerPositionBeforeMeeting; val = _playerPositionBeforeMeeting; } else { val = ((Component)PlayerController.Local.LocalCameraHandler.PovPlayer).transform.position; } Vector3 val2 = val; int num = -(GameManager.Instance.MapID - 2) * 3000; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f - (val2.z + (float)num), val2.x); val3 *= 8.95f; ((Component)_playerIcon).transform.localPosition = Vector2.op_Implicit(val3); } } public void SetActive(bool active) { _active = active; _panel.SetActive(active); } public void UpdatePositionBeforeMeeting(Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _playerPositionBeforeMeeting = position; } } [HarmonyPatch(typeof(GameManager), "Rpc_Transition")] internal class SavePlayerPositionBeforeMeetingPatch { private static void Postfix(NetworkRunner runner) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) try { Plugin.Minimap.UpdatePositionBeforeMeeting(((Component)PlayerController.Local.LocalCameraHandler.PovPlayer).transform.position); } catch (Exception ex) { Plugin.Logger.LogError((object)("SavePlayerPositionBeforeMeetingPatch: " + ex)); } } } [HarmonyPatch(typeof(InputManager), "Init")] internal class MoreKeysInputManagerInitPatch { private static void Prefix(InputManager __instance) { try { InputManagerExtra.CreateAction(__instance, "SHOWMINIMAP", "<Keyboard>/TAB", "<Gamepad>/select", "ed232440-9c66-4a8d-8de9-62e293701b63", "9ed81a8b-b408-4657-a43b-82bca504f723"); } catch (Exception ex) { Plugin.Logger.LogError((object)("MoreKeysInputManagerInitPatch error: " + ex)); } } } [HarmonyPatch(typeof(GameUI), "Awake")] internal class MoreKeysGameUIAwakePatch { private static void Postfix(GameUI __instance) { try { InputManagerExtra.AddActionToUI(__instance, "SHOWMINIMAP"); } catch (Exception ex) { Plugin.Logger.LogError((object)("MoreKeysGameUIAwakePatch error: " + ex)); } } } public class CustomKeyComponent : MonoBehaviour { public string TranslateKey; public void UpdateActionText() { //IL_0026: 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) try { ((LocalizedReference)((Component)((Component)this).transform.Find("ActionNameText")).gameObject.GetComponent<LocalizeStringEvent>().StringReference).SetReference(TableReference.op_Implicit("UI Text"), TableEntryReference.op_Implicit(TranslateKey)); ((Component)((Component)this).transform.Find("ActionNameText")).gameObject.GetComponent<LocalizeStringEvent>().StringReference.RefreshString(); ((TMP_Text)((Component)((Component)this).transform.Find("ActionNameText")).gameObject.GetComponent<TextMeshProUGUI>()).text = TranslationManager.Instance.GetTranslation(TranslateKey); } catch (Exception ex) { Plugin.Logger.LogError((object)("UpdateActionText error: " + ex)); } } } internal class NetworkObjectService { private static NetworkObjectService? _instance; private Dictionary<string, NetworkPrefabId> _prefabs; public static NetworkObjectService Instance { get { if (_instance == null) { _instance = new NetworkObjectService(); } return _instance; } } private NetworkObjectService() { _prefabs = new Dictionary<string, NetworkPrefabId>(); } public void RegisterNetworkObject(GameObject prefab, string uniqueKey) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (_prefabs.ContainsKey(uniqueKey)) { throw new InvalidOperationException("Key '" + uniqueKey + "' already exists"); } NetworkObject component = prefab.GetComponent<NetworkObject>(); if ((Object)(object)component == (Object)null) { throw new MissingComponentException("Prefab is missing 'NetworkObject' component!"); } component.NetworkedBehaviours = prefab.GetComponents<NetworkBehaviour>(); component.NetworkGuid = new NetworkObjectGuid(uniqueKey.ToGuid().ToString()); NetworkPrefabSourceUnityStatic val = ScriptableObject.CreateInstance<NetworkPrefabSourceUnityStatic>(); val.PrefabReference = ((Component)component).gameObject; NetworkPrefabId value = default(NetworkPrefabId); if (!NetworkProjectConfig.Global.PrefabTable.TryAdd(component.NetworkGuid, (INetworkPrefabSource)(object)val, ref value)) { throw new ApplicationException("Could not add prefab to registered prefabs, was it already present?"); } _prefabs.Add(uniqueKey, value); } public NetworkPrefabId GetNetworkObject(string uniqueKey) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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) if (_prefabs.TryGetValue(uniqueKey, out var value)) { return value; } throw new KeyNotFoundException("No prefab registered with '" + uniqueKey + "' as identifier!"); } public void Clear() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<string, NetworkPrefabId> prefab in _prefabs) { NetworkProjectConfig.Global.PrefabTable.Unload(prefab.Value); } _prefabs.Clear(); } } internal static class StringExtensions { public static Guid ToGuid(this string value) { return new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(value))); } } [NetworkBehaviourWeaved(10)] public class PlayerMapCustom : NetworkBehaviour { [Networked] [NetworkedWeaved(0, 1)] public unsafe PlayerRef Ref { get { //IL_0021: 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_0029: Unknown result type (might be due to invalid IL or missing references) if (base.Ptr == null) { throw new InvalidOperationException("Error when accessing PlayerMapCustom.Ref. Networked properties can only be accessed when Spawned() has been called."); } return (PlayerRef)(*base.Ptr); } private set { //IL_0021: 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) if (base.Ptr == null) { throw new InvalidOperationException("Error when accessing PlayerMapCustom.Ref. Networked properties can only be accessed when Spawned() has been called."); } Unsafe.Write(base.Ptr, value); } } [Networked] [NetworkedWeaved(1, 1)] public unsafe byte Index { get { if (base.Ptr == null) { throw new InvalidOperationException("Error when accessing PlayerMapCustom.Index. Networked properties can only be accessed when Spawned() has been called."); } return *(byte*)(base.Ptr + 1); } private set { if (base.Ptr == null) { throw new InvalidOperationException("Error when accessing PlayerMapCustom.Index. Networked properties can only be accessed when Spawned() has been called."); } *(byte*)(base.Ptr + 1) = value; } } [Networked(OnChanged = "CurrentRoomIndexChanged")] [NetworkedWeaved(2, 1)] public unsafe int CurrentRoomIndex { get { if (base.Ptr == null) { throw new InvalidOperationException("Error when accessing PlayerMapCustom.CurrentRoomIndex. Networked properties can only be accessed when Spawned() has been called."); } return base.Ptr[2]; } set { if (base.Ptr == null) { throw new InvalidOperationException("Error when accessing PlayerMapCustom.CurrentRoomIndex. Networked properties can only be accessed when Spawned() has been called."); } base.Ptr[2] = value; } } public void Server_Init(PlayerRef pRef, byte index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Ref = pRef; Index = index; if (GameManager.Instance.MapID == MapManager.FindMapIdByName("dungeonmap") && RoomNameComponent.RoomKeyByIndex.Any((KeyValuePair<int, string> o) => o.Value == "ROOM_CENTRAL")) { CurrentRoomIndex = RoomNameComponent.RoomKeyByIndex.First((KeyValuePair<int, string> o) => o.Value == "ROOM_CENTRAL").Key; } } public void Reset() { CurrentRoomIndex = 0; } [Preserve] public static void CurrentRoomIndexChanged(Changed<PlayerMapCustom> changed) { //IL_0022: 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) try { PlayerMapCustom behaviour = changed.Behaviour; if ((Object)(object)PlayerController.Local.LocalCameraHandler.PovPlayer != (Object)null && behaviour.Ref == PlayerController.Local.LocalCameraHandler.PovPlayer.Ref) { behaviour.RefreshCurrentRoomUI(); } } catch (Exception ex) { Plugin.Logger.LogError((object)("CurrentRoomIndexChanged error: " + ex)); } } public void RefreshCurrentRoomUI() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) try { PlayerController player = PlayerRegistry.GetPlayer(Ref); if (CurrentRoomIndex != 0) { UICurrentRoom.Instance.Show(active: true, RoomNameComponent.RoomKeyByIndex[CurrentRoomIndex]); } else { UICurrentRoom.Instance.Show(active: false, null); } } catch (Exception ex) { Plugin.Logger.LogError((object)("RefreshCurrentRoomUI error: " + ex)); } } } [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct PlayerMapCustomReaderWriter : IElementReaderWriter<PlayerRef> { public static IElementReaderWriter<PlayerRef> Instance; [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe PlayerRef Read(byte* data, int index) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return (PlayerRef)data[index * 4]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe ref PlayerRef ReadRef(byte* data, int index) { return ref *(PlayerRef*)(data + index * 4); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Write(byte* data, int index, PlayerRef val) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Unsafe.Write(data + index * 4, val); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int GetElementWordCount() { return 1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IElementReaderWriter<PlayerRef> GetInstance() { if (Instance == null) { Instance = default(PlayerMapCustomReaderWriter); } return Instance; } } [NetworkBehaviourWeaved(88)] public class PlayerMapCustomRegistry : NetworkBehaviour, INetworkRunnerCallbacks, IElementReaderWriter<PlayerMapCustom> { [DefaultForProperty("PlayersMapCustom", 0, 88)] private SerializableDictionary<PlayerRef, PlayerMapCustom> _PlayersMapCustom; public static PlayerMapCustomRegistry Instance { get; private set; } [Networked] [Capacity(15)] [NetworkedWeaved(0, 88)] private unsafe NetworkDictionary<PlayerRef, PlayerMapCustom> PlayersMapCustom { get { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) if (base.Ptr == null) { throw new InvalidOperationException("Error when accessing PlayerMapCustomManager.PlayersMapCustom. Networked properties can only be accessed when Spawned() has been called."); } return new NetworkDictionary<PlayerRef, PlayerMapCustom>(base.Ptr, 17, PlayerMapCustomReaderWriter.GetInstance(), (IElementReaderWriter<PlayerMapCustom>)this); } } public static List<PlayerMapCustom> AllPlayers => ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)Instance.PlayersMapCustom).Select((KeyValuePair<PlayerRef, PlayerMapCustom> o) => o.Value).ToList(); public override void Spawned() { ((NetworkBehaviour)this).Spawned(); Instance = this; ((SimulationBehaviour)this).Runner.AddCallbacks((INetworkRunnerCallbacks[])(object)new INetworkRunnerCallbacks[1] { this }); } public override void Despawned(NetworkRunner runner, bool hasState) { ((NetworkBehaviour)this).Despawned(runner, hasState); Instance = null; runner.RemoveCallbacks((INetworkRunnerCallbacks[])(object)new INetworkRunnerCallbacks[1] { this }); } private bool GetAvailable(out byte index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (PlayersMapCustom.Count == 0) { index = 0; return true; } if (PlayersMapCustom.Count == 15) { index = 0; return false; } byte[] array = ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)PlayersMapCustom).OrderBy(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp) { KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair2 = kvp; return keyValuePair2.Value.Index; }).Select(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp) { KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair = kvp; return keyValuePair.Value.Index; }).ToArray(); for (int i = 0; i < array.Length - 1; i++) { if (array[i + 1] > array[i] + 1) { index = (byte)(array[i] + 1); return true; } } index = (byte)(array[^1] + 1); return true; } public static void Server_Add(NetworkRunner runner, PlayerRef pRef, PlayerMapCustom pObj) { //IL_0037: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) if (Instance.GetAvailable(out var index)) { Instance.PlayersMapCustom.Add(pRef, pObj); pObj.Server_Init(pRef, index); } else { Debug.LogWarning((object)$"Unable to register player {pRef}", (Object)(object)pObj); } } public static void Server_Remove(NetworkRunner runner, PlayerRef pRef) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Instance.PlayersMapCustom.Remove(pRef)) { Debug.LogWarning((object)"Could not remove player from registry"); } } public static bool HasPlayer(PlayerRef pRef) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return Instance.PlayersMapCustom.ContainsKey(pRef); } public static PlayerMapCustom GetPlayer(int index) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)Instance.PlayersMapCustom).First((KeyValuePair<PlayerRef, PlayerMapCustom> o) => o.Value.Index == index).Value; } public static PlayerMapCustom GetPlayer(PlayerRef pRef) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (HasPlayer(pRef)) { return Instance.PlayersMapCustom.Get(pRef); } return null; } public static IEnumerable<PlayerMapCustom> Where(Predicate<PlayerMapCustom> match) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)Instance.PlayersMapCustom).Where(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp) { Predicate<PlayerMapCustom> predicate = match; KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair2 = kvp; return predicate(keyValuePair2.Value); }).Select(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp) { KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair = kvp; return keyValuePair.Value; }); } public static void ForEach(Action<PlayerMapCustom> action) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator(); try { while (enumerator.MoveNext()) { action(enumerator.Current.Value); } } finally { ((IDisposable)enumerator).Dispose(); } } public static void ForEachWhere(Predicate<PlayerMapCustom> match, Action<PlayerMapCustom> action) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair<PlayerRef, PlayerMapCustom> current = enumerator.Current; if (match(current.Value)) { action(current.Value); } } } finally { ((IDisposable)enumerator).Dispose(); } } public static int CountWhere(Predicate<PlayerMapCustom> match) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) int num = 0; Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator(); try { while (enumerator.MoveNext()) { if (match(enumerator.Current.Value)) { num++; } } } finally { ((IDisposable)enumerator).Dispose(); } return num; } public static bool Any(Predicate<PlayerMapCustom> match) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator(); try { while (enumerator.MoveNext()) { if (match(enumerator.Current.Value)) { return true; } } } finally { ((IDisposable)enumerator).Dispose(); } return false; } void INetworkRunnerCallbacks.OnPlayerLeft(NetworkRunner runner, PlayerRef player) { } void INetworkRunnerCallbacks.OnPlayerJoined(NetworkRunner runner, PlayerRef player) { } void INetworkRunnerCallbacks.OnInput(NetworkRunner runner, NetworkInput input) { } void INetworkRunnerCallbacks.OnInputMissing(NetworkRunner runner, PlayerRef player, NetworkInput input) { } void INetworkRunnerCallbacks.OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason) { } void INetworkRunnerCallbacks.OnConnectedToServer(NetworkRunner runner) { } void INetworkRunnerCallbacks.OnDisconnectedFromServer(NetworkRunner runner) { } void INetworkRunnerCallbacks.OnConnectRequest(NetworkRunner runner, ConnectRequest request, byte[] token) { } void INetworkRunnerCallbacks.OnConnectFailed(NetworkRunner runner, NetAddress remoteAddress, NetConnectFailedReason reason) { } void INetworkRunnerCallbacks.OnUserSimulationMessage(NetworkRunner runner, SimulationMessagePtr message) { } void INetworkRunnerCallbacks.OnSessionListUpdated(NetworkRunner runner, List<SessionInfo> sessionList) { } void INetworkRunnerCallbacks.OnCustomAuthenticationResponse(NetworkRunner runner, Dictionary<string, object> data) { } void INetworkRunnerCallbacks.OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment<byte> data) { } void INetworkRunnerCallbacks.OnSceneLoadDone(NetworkRunner runner) { } void INetworkRunnerCallbacks.OnSceneLoadStart(NetworkRunner runner) { } void INetworkRunnerCallbacks.OnHostMigration(NetworkRunner runner, HostMigrationToken hostMigrationToken) { } unsafe PlayerMapCustom IElementReaderWriter<PlayerMapCustom>.Read(byte* data, int index) { NetworkBehaviour val = null; ReadWriteUtilsForWeaver.VerifyRawNetworkUnwrap<PlayerMapCustom>(NetworkBehaviour.NetworkDeserialize(((SimulationBehaviour)this).Runner, data + index * 8, ref val), 8); return (PlayerMapCustom)(object)val; } public unsafe ref PlayerMapCustom ReadRef(byte* data, int index) { throw new NotSupportedException("Only supported for trivially copyable types. PlayerMapCustom is not trivially copyable."); } unsafe void IElementReaderWriter<PlayerMapCustom>.Write(byte* data, int index, PlayerMapCustom val) { ReadWriteUtilsForWeaver.VerifyRawNetworkWrap<PlayerMapCustom>(NetworkBehaviour.NetworkSerialize(((SimulationBehaviour)this).Runner, (NetworkBehaviour)(object)val, data + index * 8), 8); } public int GetElementWordCount() { return 2; } public override void CopyBackingFieldsToState(bool A_1) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) int num = _PlayersMapCustom?.Count ?? 0; if (num == 0) { return; } if (num > PlayersMapCustom.Capacity) { Log.Error((object)$"Source dictionary is too long for {((Object)this).name} with capacity of {PlayersMapCustom.Capacity}: {num}. Ignoring extra elements."); num = PlayersMapCustom.Capacity; } PlayersMapCustom.Clear(); foreach (KeyValuePair<PlayerRef, PlayerMapCustom> item in _PlayersMapCustom) { if (--num < 0) { break; } PlayersMapCustom.Add(item.Key, item.Value); } } public override void CopyStateToBackingFields() { //IL_002d: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (_PlayersMapCustom == null) { _PlayersMapCustom = new SerializableDictionary<PlayerRef, PlayerMapCustom>(); } else { _PlayersMapCustom.Clear(); } Enumerator<PlayerRef, PlayerMapCustom> enumerator = PlayersMapCustom.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair<PlayerRef, PlayerMapCustom> current = enumerator.Current; _PlayersMapCustom.Add(current.Key, current.Value); } } finally { ((IDisposable)enumerator).Dispose(); } } } [HarmonyPatch(typeof(PlayerController), "Spawned")] internal class AddPlayerAddCustomPlayerPatch { private static void Postfix(PlayerController __instance) { //IL_002b: 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_0069: 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_0081: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) try { CharacterController component = ((Component)__instance).GetComponent<CharacterController>(); component.center = new Vector3(0f, 0.8f, 0f); component.height = 1.5f; if (((SimulationBehaviour)__instance).HasStateAuthority) { NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(GlobalManager.PlayerMapCustomName)); NetworkObject val = ((SimulationBehaviour)__instance).Runner.Spawn(networkObject, (Vector3?)new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y, ((Component)__instance).transform.position.z), (Quaternion?)null, (PlayerRef?)((SimulationBehaviour)__instance).Object.InputAuthority, (OnBeforeSpawned)delegate(NetworkRunner _, NetworkObject no) { ((Component)no).transform.parent = ((Component)__instance).transform; }, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null); ((Component)val).transform.parent = ((Component)__instance).transform; PlayerMapCustomRegistry.Server_Add(((SimulationBehaviour)__instance).Runner, ((SimulationBehaviour)__instance).Object.InputAuthority, ((Component)val).GetComponent<PlayerMapCustom>()); } } catch (Exception ex) { Plugin.Logger.LogError((object)("AddPlayerAddCustomPlayerPatch error: " + ex)); } } } [HarmonyPatch(typeof(GameManager), "Rpc_DeletePlayer")] internal class DeletePlayerDeleteCustomPlayerPatch { private static void Postfix(NetworkRunner runner, PlayerRef playerRef) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_002a: 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) if ((NetworkBehaviourUtils.InvokeRpc || (int)runner.Stage != 4) && runner.IsServer) { PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(playerRef); if ((Object)(object)player != (Object)null) { PlayerMapCustomRegistry.Server_Remove(runner, playerRef); runner.Despawn(((SimulationBehaviour)player).Object, false); } } } } [BepInPlugin("LycansNewMaps", "Lycans New Maps", "0.21")] public class Plugin : BaseUnityPlugin { public static NetworkObject NetworkObject; public static MinimapComponent Minimap; internal static ManualLogSource Logger; public static string Location; public static AssetBundle CoreBundle; public static Dictionary<int, AssetBundle> AssetBundlesByMapId; public const string CoreBundleName = "lycansnewmaps"; private void Awake() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown try { Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin LycansNewMaps is loaded!"); TranslationManager.Instance.Initialize(); Harmony val = new Harmony("lycans.nalesnewmaps"); HarmonyFileLog.Enabled = true; val.PatchAll(); Logger.LogInfo((object)"Harmony patched!"); Location = ((BaseUnityPlugin)this).Info.Location; try { AssetBundlesByMapId = new Dictionary<int, AssetBundle>(); string path = Path.GetDirectoryName(Location) + "/resources/"; List<string> source = Directory.EnumerateFiles(path).ToList(); int num = 3; foreach (string item in source.Where((string o) => !o.Contains(".json"))) { string text = item.Split('/').Last(); if (text == "lycansnewmaps") { CoreBundle = AssetBundle.LoadFromFile(item); continue; } AssetBundlesByMapId[num] = AssetBundle.LoadFromFile(item); Logger.LogInfo((object)("Bundle " + text + " loaded")); num++; } } catch (Exception ex) { Logger.LogError((object)("Error loading bundle: " + ex)); } } catch (Exception ex2) { Logger.LogError((object)("Error initializing plugin: " + ex2)); } } public static void CreatePrefabs() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_067f: Unknown result type (might be due to invalid IL or missing references) try { Logger.LogInfo((object)"CreatePrefabs..."); GameObject val = new GameObject("PlayerMapCustomRegistry"); val.AddComponent<NetworkObject>(); val.AddComponent<PlayerMapCustomRegistry>(); val.SetActive(false); NetworkObjectService.Instance.RegisterNetworkObject(val, GlobalManager.PlayerMapCustomRegistryName); GameObject val2 = new GameObject("PlayerMapCustom"); val2.AddComponent<NetworkObject>(); val2.AddComponent<NetworkTransform>(); val2.AddComponent<PlayerMapCustom>(); val2.SetActive(false); NetworkObjectService.Instance.RegisterNetworkObject(val2, GlobalManager.PlayerMapCustomName); foreach (KeyValuePair<int, AssetBundle> item in AssetBundlesByMapId) { foreach (string item2 in from o in item.Value.GetAllAssetNames() where o.Contains("food_") && o.Contains(".prefab") select o) { GameObject val3 = item.Value.LoadAsset<GameObject>(item2); GameObject val4 = Object.Instantiate<GameObject>(val3); val4.AddComponent<NetworkObject>(); val4.AddComponent<NetworkTransform>(); Loot val5 = val4.AddComponent<Loot>(); Traverse.Create((object)val5).Field<NetworkBool>("_Available").Value = NetworkBool.op_Implicit(false); int value = 0; if (item2.Contains("rarity0")) { value = 0; } else if (item2.Contains("rarity1")) { value = 1; } else if (item2.Contains("rarity2")) { value = 2; } else if (item2.Contains("rarity3")) { value = 3; } Traverse.Create((object)val5).Field<int>("rarity").Value = value; if (item2.Contains("notfood")) { Traverse.Create((object)val5).Field<bool>("notFood").Value = true; } val4.SetActive(false); NetworkObjectService.Instance.RegisterNetworkObject(val4.gameObject, ((Object)val3).name); Logger.LogInfo((object)("Added loot: " + ((Object)val3).name)); } foreach (string item3 in from o in item.Value.GetAllAssetNames() where o.Contains("door_") && o.Contains(".prefab") select o) { GameObject val6 = item.Value.LoadAsset<GameObject>(item3); GameObject val7 = Object.Instantiate<GameObject>(val6); Door val8 = val7.AddComponent<Door>(); Traverse.Create((object)val8).Field<GameObject>("locks").Value = ((Component)val7.transform.Find("Lock")).gameObject; val7.AddComponent<DoorCustom>(); val7.SetActive(false); NetworkObjectService.Instance.RegisterNetworkObject(val7.gameObject, ((Object)val6).name); Logger.LogInfo((object)("Added door: " + ((Object)val6).name)); } Portal[] array = Object.FindObjectsOfType<Portal>(true); Light val9 = null; Portal[] array2 = array; foreach (Portal val10 in array2) { val9 = Traverse.Create((object)val10).Field<Light>("teleportLight").Value; if ((Object)(object)val9 != (Object)null) { break; } } foreach (string item4 in from o in item.Value.GetAllAssetNames() where o.Contains("portal_") && o.Contains(".prefab") select o) { GameObject val11 = item.Value.LoadAsset<GameObject>(item4); GameObject val12 = Object.Instantiate<GameObject>(val11); Portal val13 = val12.AddComponent<Portal>(); Light value2 = Object.Instantiate<Light>(val9, val12.transform); Traverse.Create((object)val13).Field<Light>("teleportLight").Value = value2; Transform value3 = val12.transform.Find("PortalTeleportPoint"); Traverse.Create((object)val13).Field<Transform>("teleportPoint").Value = value3; Transform val14 = val12.transform.Find("PortalEffect"); Traverse.Create((object)val13).Field<GameObject>("portalEffects").Value = ((Component)val14).gameObject; PortalCustom portalCustom = val12.AddComponent<PortalCustom>(); string[] array3 = ((Object)((Component)val11.transform.Find("Config").GetChild(0)).gameObject).name.Split(';'); portalCustom.ActiveMinimumSeconds = int.Parse(array3[0]); portalCustom.ActiveMaximumSeconds = int.Parse(array3[1]); portalCustom.InactiveMinimumSeconds = int.Parse(array3[2]); portalCustom.InactiveMaximumSeconds = int.Parse(array3[3]); val12.SetActive(false); NetworkObjectService.Instance.RegisterNetworkObject(val12.gameObject, ((Object)val11).name); Logger.LogInfo((object)("Added portal: " + ((Object)val11).name)); } foreach (string item5 in from o in item.Value.GetAllAssetNames() where o.Contains("ladder_") && o.Contains(".prefab") select o) { GameObject val15 = item.Value.LoadAsset<GameObject>(item5); GameObject val16 = Object.Instantiate<GameObject>(val15); Ladder val17 = val16.AddComponent<Ladder>(); Transform val18 = val16.transform.Find("LadderStartTrigger"); ((Component)val18).gameObject.AddComponent<LadderStartTrigger>(); Transform val19 = val16.transform.Find("LadderEndTrigger"); LadderEndTrigger val20 = ((Component)val19).gameObject.AddComponent<LadderEndTrigger>(); Transform value4 = val16.transform.Find("LadderUpClimbingPoint"); Traverse.Create((object)val20).Field<Transform>("upClimbingPoint").Value = value4; Transform value5 = val16.transform.Find("LadderStartPoint"); Traverse.Create((object)val17).Field<Transform>("startClimbingPoint").Value = value5; Transform value6 = val16.transform.Find("LadderEndPoint"); Traverse.Create((object)val17).Field<Transform>("fallingPoint").Value = value6; Traverse.Create((object)val17).Field<NetworkBool>("_CanClimb").Value = NetworkBool.op_Implicit(true); val16.AddComponent<LadderCustom>(); val16.SetActive(false); NetworkObjectService.Instance.RegisterNetworkObject(val16.gameObject, ((Object)val15).name); Logger.LogInfo((object)("Added ladder: " + ((Object)val15).name)); } } } catch (Exception ex) { Logger.LogError((object)("Error starting plugin: " + ex)); } } } [HarmonyPatch(typeof(GameUI), "Awake")] public class GameUIAwakePatch { private static void Postfix(GameUI __instance) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) try { TextMeshProUGUI value = Traverse.Create((object)__instance).Field<TextMeshProUGUI>("mmVersionText").Value; ((TMP_Text)value).text = ((TMP_Text)value).text + Environment.NewLine + "New Maps 0.21"; GameObject val = Plugin.CoreBundle.LoadAsset<GameObject>("CurrentRoom"); GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)__instance).transform.Find("Canvas").Find("Fixed")); RectTransform component = val2.GetComponent<RectTransform>(); component.pivot = new Vector2(0f, 1f); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); val2.transform.position = new Vector3(val2.transform.position.x + 128f, val2.transform.position.y, val2.transform.position.z); val2.transform.SetAsLastSibling(); UICurrentRoom instance = val2.AddComponent<UICurrentRoom>(); UICurrentRoom.Instance = instance; GameObject val3 = Plugin.CoreBundle.LoadAsset<GameObject>("minimap"); GameObject val4 = Object.Instantiate<GameObject>(val3, ((Component)__instance).transform.Find("Canvas")); Plugin.Minimap = val4.AddComponent<MinimapComponent>(); } catch (Exception ex) { Plugin.Logger.LogError((object)("GameUI Awake postfix error: " + ex)); } } } public static class PluginInfo { public const string PLUGIN_GUID = "LycansNewMaps"; public const string PLUGIN_NAME = "Lycans New Maps"; public const string PLUGIN_VERSION = "0.21"; } public class PortalCustom : MonoBehaviour { public int MapID; public float ActiveMinimumSeconds; public float ActiveMaximumSeconds; public float InactiveMinimumSeconds; public float InactiveMaximumSeconds; } [HarmonyPatch(typeof(Portal), "StartActivationTimer")] [HarmonyPriority(0)] internal class PortalCustomTimerPatch { private static bool Prefix(Portal __instance) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) try { if (((SimulationBehaviour)__instance).HasStateAuthority) { PortalCustom component = ((Component)__instance).GetComponent<PortalCustom>(); if ((Object)(object)component == (Object)null) { return true; } Traverse<NetworkBool> val = Traverse.Create((object)__instance).Field<NetworkBool>("_Active"); ((NetworkBehaviour)__instance).CopyStateToBackingFields(); if (NetworkBool.op_Implicit(val.Value)) { __instance.ActivationTimer = TickTimer.CreateFromSeconds(((SimulationBehaviour)__instance).Runner, Random.Range(component.ActiveMinimumSeconds, component.ActiveMaximumSeconds)); } else { __instance.ActivationTimer = TickTimer.CreateFromSeconds(((SimulationBehaviour)__instance).Runner, Random.Range(component.InactiveMinimumSeconds, component.InactiveMaximumSeconds)); } } return false; } catch (Exception ex) { Plugin.Logger.LogError((object)("PortalCustomTimerPatch error: " + ex)); return true; } } } [HarmonyPatch(typeof(Portal), "OnTriggerEnter")] [HarmonyAfter(new string[] { "lycans.nalesplugin" })] internal class PortalOnTriggerEnterPatch { private static bool Prefix(Collider other, Portal __instance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) try { NetworkBool value = Traverse.Create((object)__instance).Property<NetworkBool>("Active", (object[])null).Value; if (NetworkBool.op_Implicit(value)) { PlayerController component = ((Component)other).gameObject.GetComponent<PlayerController>(); if ((Object)(object)component != (Object)null && !NetworkBool.op_Implicit(component.IsDead) && ((SimulationBehaviour)__instance).HasStateAuthority) { GameObject val = GameObject.Find("NEWROLES:SABOTAGEPORTALS"); if ((Object)(object)val != (Object)null && (Object)(object)component != (Object)null && !NetworkBool.op_Implicit(component.IsWolf)) { return false; } PortalCustom portalCustomComponent = ((Component)__instance).GetComponent<PortalCustom>(); List<Portal> list = ((!((Object)(object)portalCustomComponent != (Object)null)) ? (from p in Object.FindObjectsOfType<Portal>() where (Object)(object)p != (Object)(object)__instance && (Object)(object)((Component)p).GetComponent<PortalCustom>() == (Object)null select p).ToList() : (from p in Object.FindObjectsOfType<Portal>() where (Object)(object)p != (Object)(object)__instance && (Object)(object)((Component)p).GetComponent<PortalCustom>() != (Object)null && ((Component)p).GetComponent<PortalCustom>().MapID == portalCustomComponent.MapID select p).ToList()); if (list.Any()) { __instance.ResetPortal(); Portal val2 = CollectionsUtil.Grab<Portal>(list, 1).First(); val2.ResetPortal(); Transform value2 = Traverse.Create((object)val2).Field<Transform>("teleportPoint").Value; Vector3 position = ((Component)val2).transform.position; Traverse.Create((object)__instance).Method("Rpc_DisplayLight", Array.Empty<object>()).GetValue(); Traverse.Create((object)val2).Method("Rpc_DisplayLight", Array.Empty<object>()).GetValue(); GameManager.Rpc_BroadcastFollowSound(((SimulationBehaviour)__instance).Runner, NetworkString<_16>.op_Implicit("TELEPORT_START"), ((Component)__instance).transform.position, 30f, 1f); component.CharacterMovementHandler.TeleportData = new NetworkTeleportData(value2.position, value2.rotation, true); GameManager.Rpc_BroadcastFollowSound(((SimulationBehaviour)__instance).Runner, NetworkString<_16>.op_Implicit("TELEPORT_END"), position, 30f, 1f); } } } return false; } catch (Exception ex) { Plugin.Logger.LogError((object)("PortalCustomTimerPatch error: " + ex)); return true; } } } public class RoomNameComponent : MonoBehaviour { public static Dictionary<int, string> RoomKeyByIndex = new Dictionary<int, string>(); private int _index; private string _roomKey; public void Init(string roomKey) { try { _roomKey = roomKey; _index = RoomKeyByIndex.Count + 1; RoomKeyByIndex[_index] = roomKey; } catch (Exception ex) { Plugin.Logger.LogError((object)("RoomNameComponent init error: " + ex)); } } private void OnTriggerEnter(Collider other) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) try { if ((int)GameManager.LocalGameState == 2) { PlayerController component = ((Component)other).GetComponent<PlayerController>(); if ((Object)(object)component != (Object)null) { PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(component.Ref); player.CurrentRoomIndex = _index; } } } catch (Exception ex) { Plugin.Logger.LogError((object)("OnTriggerEnter error: " + ex)); } } private void OnTriggerExit(Collider other) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) try { PlayerController component = ((Component)other).GetComponent<PlayerController>(); if ((Object)(object)component != (Object)null) { PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(component.Ref); if (player.CurrentRoomIndex == _index) { player.CurrentRoomIndex = 0; } } } catch (Exception ex) { Plugin.Logger.LogError((object)("OnTriggerEnter error: " + ex)); } } } public class UICurrentRoom : MonoBehaviour { public static UICurrentRoom Instance; private static Color ColorBackground = Color.white; private static Color ColorText = Color.black; private Image ImageBorder; private Image ImageBackground; private TextMeshProUGUI TextRoomName; private bool Active = false; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) try { ImageBorder = ((Component)((Component)this).transform.Find("Border")).GetComponent<Image>(); ImageBackground = ((Component)((Component)this).transform.Find("Background")).GetComponent<Image>(); TextRoomName = ((Component)((Component)this).transform.Find("Text")).GetComponent<TextMeshProUGUI>(); ((Graphic)ImageBackground).color = ColorBackground; ((Graphic)TextRoomName).color = ColorText; Show(active: false, null); } catch (Exception ex) { Plugin.Logger.LogError((object)("UICurrentRoom awake error: " + ex)); } } public void Show(bool active, string roomKey) { try { ((Component)ImageBorder).gameObject.SetActive(active); ((Component)ImageBackground).gameObject.SetActive(active); ((Component)TextRoomName).gameObject.SetActive(active); if (active) { ((TMP_Text)TextRoomName).text = TranslationManager.Instance.GetTranslation(roomKey); } } catch (Exception ex) { Plugin.Logger.LogError((object)("Show error: " + ex)); } } } [HarmonyPatch(typeof(LocalCameraHandler), "SwitchPov")] internal class SwitchPovPatch { private static void Postfix(LocalCameraHandler __instance, PlayerController spectatedPlayer) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance.PovPlayer != (Object)null && (int)GameManager.LocalGameState == 2) { PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(spectatedPlayer.Ref); player.RefreshCurrentRoomUI(); } } catch (Exception ex) { Plugin.Logger.LogError((object)("SwitchPovPatch error: " + ex)); } } } [HarmonyPatch(typeof(LocalCameraHandler), "Start")] internal class CameraStartPatch { private static void Postfix(LocalCameraHandler __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance.PovPlayer != (Object)null) { PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(__instance.PovPlayer.Ref); player.RefreshCurrentRoomUI(); } } catch (Exception ex) { Plugin.Logger.LogError((object)("CameraStartPatch error: " + ex)); } } } public class TranslationManager { private Dictionary<string, string> _translationsForCurrentLanguage = new Dictionary<string, string>(); private Dictionary<string, Dictionary<string, string>> _allTranslationsByLanguage = null; private static TranslationManager _instance; public static TranslationManager Instance { get { if (_instance == null) { _instance = new TranslationManager(); } return _instance; } } public TranslationManager() { LoadTranslationsFromFile(); LoadTranslationsForLanguage(GetLanguageCode()); LocalizationSettings.SelectedLocaleChanged += SelectedLocaleChanged; } public void Initialize() { } private void SelectedLocaleChanged(Locale locale) { LoadTranslationsForLanguage(GetLanguageCode()); } private string GetLanguageCode() { return (PlayerPrefs.GetInt("SETTINGS_LANGUAGE") == 0) ? "en" : "fr"; } private void LoadTranslationsFromFile() { string name = "LycansNewMaps.resources.translations.json"; Assembly executingAssembly = Assembly.GetExecutingAssembly(); try { using Stream stream = executingAssembly.GetManifestResourceStream(name); if (stream != null) { using (StreamReader streamReader = new StreamReader(stream)) { _allTranslationsByLanguage = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(streamReader.ReadToEnd()); return; } } Plugin.Logger.LogError((object)"Translations resource not found"); } catch (Exception ex) { Log.Info((object)ex.Message); } } public string GetTranslation(string key) { string value; return _translationsForCurrentLanguage.TryGetValue(key, out value) ? value : key; } private void LoadTranslationsForLanguage(string languageCode) { _translationsForCurrentLanguage = _allTranslationsByLanguage[languageCode]; PopulateStringDatabase(); } private void PopulateStringDatabase() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), (Locale)null); foreach (KeyValuePair<string, string> item in _translationsForCurrentLanguage) { ((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry(item.Key, item.Value); } } } public static class ComponentExtensions { public static T GetCopyOf<T>(this T comp, T other) where T : Component { Type type = ((object)comp).GetType(); Type type2 = ((object)other).GetType(); if (type != type2) { Plugin.Logger.LogError((object)$"The type \"{type.AssemblyQualifiedName}\" of \"{comp}\" does not match the type \"{type2.AssemblyQualifiedName}\" of \"{other}\"!"); return default(T); } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; PropertyInfo[] properties = type.GetProperties(bindingAttr); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if (propertyInfo.CanWrite) { propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null); } } FieldInfo[] fields = type.GetFields(bindingAttr); FieldInfo[] array2 = fields; foreach (FieldInfo fieldInfo in array2) { fieldInfo.SetValue(comp, fieldInfo.GetValue(other)); } return comp; } public static void ListComponentsAndChildren(this GameObject gameObject) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logger = Plugin.Logger; string name = ((Object)gameObject).name; Vector3 position = gameObject.transform.position; logger.LogInfo((object)(name + ", position: " + ((object)(Vector3)(ref position)).ToString())); Component[] components = gameObject.GetComponents<Component>(); foreach (Component val in components) { Plugin.Logger.LogInfo((object)(((Object)gameObject).name + " Component: " + (object)val)); } for (int j = 0; j < gameObject.transform.childCount; j++) { Transform child = gameObject.transform.GetChild(j); Plugin.Logger.LogInfo((object)(((Object)gameObject).name + " Child: " + ((object)child)?.ToString() + " / " + ((Object)((Component)child).gameObject).name)); Component[] components2 = ((Component)child).gameObject.GetComponents<Component>(); foreach (Component val2 in components2) { Plugin.Logger.LogInfo((object)(((Object)gameObject).name + " Child component: " + ((object)val2).ToString())); } int num = 0; for (; j < child.childCount; j++) { Transform child2 = child.GetChild(j); Plugin.Logger.LogInfo((object)(((object)child)?.ToString() + " Child: " + ((object)child2)?.ToString() + " / " + ((Object)((Component)child2).gameObject).name)); Component[] components3 = ((Component)child2).gameObject.GetComponents<Component>(); foreach (Component val3 in components3) { Plugin.Logger.LogInfo((object)("Child Child component: " + ((object)val3).ToString())); } } } } publi