using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using HarmonyLib; using HarmonyLib.Public.Patching; using InjectionLibrary.Attributes; using JetBrains.Annotations; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLevelLoader; using LethalLib.Modules; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using MattyFixes.Dependency; using MattyFixes.Interfaces; using MattyFixes.Utils; using MattyFixes.Utils.IL; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.RuntimeDetour; using MonoMod.Utils; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Animations; using UnityEngine.Bindings; using UnityEngine.Rendering; using VertexLibrary; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RequiresInjections] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: AssemblyCompany("mattymatty")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.41")] [assembly: AssemblyInformationalVersion("1.1.41+af0c96d3eb8842c9c3dfa4ce0b6ec3fd335988f2")] [assembly: AssemblyProduct("Matty's Fixes")] [assembly: AssemblyTitle("Matty's Fixes - Plugin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.41.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] internal sealed class IsUnmanagedAttribute : Attribute { } [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 MattyFixes { [BepInPlugin("mattymatty.MattyFixes", "Matty's Fixes", "1.1.41")] [BepInDependency("com.github.lethalcompanymodding.vertexlibrary", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class MattyFixes : BaseUnityPlugin { internal static class PluginConfig { internal static class ReadableMeshes { internal static ConfigEntry Enabled; } internal static class Particles { internal enum LightningType { Vanilla, Shape, Alternate } internal static ConfigEntry Lightning; internal static ConfigEntry Flies; } internal static class BadgeFixes { internal static ConfigEntry Enabled; } internal static class CupBoard { internal static ConfigEntry Enabled; internal static ConfigEntry Tolerance; internal static ConfigEntry Shift; } internal static class Radar { internal static ConfigEntry Enabled; internal static ConfigEntry RemoveDeleted; internal static ConfigEntry RemoveOnShip; } internal static class ItemClipping { internal static ConfigEntry Enabled; internal static ConfigEntry RotateOnSpawn; internal static ConfigEntry VerticalOffset; internal static ConfigEntry ManualOffsets; internal static readonly Dictionary ManualOffsetMap = new Dictionary(StringComparer.InvariantCultureIgnoreCase); internal static readonly Dictionary ItemRotations = new Dictionary(); } internal static class OutOfBounds { internal static ConfigEntry Enabled; internal static ConfigEntry VerticalOffset; internal static ConfigEntry SpawnInFurniture; } internal static class AlternateLightingParticle { } internal static class Debug { internal static ConfigEntry VerboseMeshes; internal static ConfigEntry VerboseCupboard; internal static ConfigEntry VerboseItems; } internal static void Init() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Expected O, but got Unknown ConfigFile config = ((BaseUnityPlugin)Instance).Config; ReadableMeshes.Enabled = config.Bind("ReadableMeshes", "enabled", true, "convert all meshes to readable at runtime"); Particles.Lightning = config.Bind("Particles", "lightning", Particles.LightningType.Shape, "change rendering of the Lightning particles:\r\n- Vanilla : no changes!\r\n- Shape : show lightning particles as dev intended! (in the shape of the object) \r\n- Alternate : particles will show in a sphere around the item"); Particles.Flies = config.Bind("Particles", "flies", true, "show crawling bugs particles as dev intended! ( affects Ear, Hand and Thigh )"); BadgeFixes.Enabled = config.Bind("BadgeFixes", "enabled", true, "show correct level tag"); CupBoard.Enabled = config.Bind("CupBoard", "enabled", true, "prevent items inside or above the Storage Closet from falling to the ground"); CupBoard.Tolerance = config.Bind("CupBoard", "tolerance", 0.05f, new ConfigDescription("how loosely \"close\" the items have to be to the top of the closet for them to count X/Z", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.5f), Array.Empty())); CupBoard.Shift = config.Bind("CupBoard", "shift", 0.1f, new ConfigDescription("how much move the items inside the closet on load ( only if ItemClippingFix disabled )", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 0.5f), Array.Empty())); Radar.Enabled = config.Bind("Radar", "enabled", true, "remove orphan radar icons from deleted/collected scrap"); Radar.RemoveDeleted = config.Bind("Radar", "deleted_scrap", true, "remove orphan radar icons from deleted scrap ( company building )"); Radar.RemoveOnShip = config.Bind("Radar", "ship_loot", true, "remove orphan radar icons from scrap on the ship in a recently created game"); ItemClipping.Enabled = config.Bind("ItemClipping", "enabled", true, "fix rotation and height of various items when on the Ground"); ItemClipping.RotateOnSpawn = config.Bind("ItemClipping", "rotate_on_spawn", true, "fix rotation of newly spawned items"); ItemClipping.VerticalOffset = config.Bind("ItemClipping", "vertical_offset", 0f, new ConfigDescription("additional y offset for items on the ground", (AcceptableValueBase)(object)new AcceptableValueRange(-0.5f, 0.5f), Array.Empty())); ItemClipping.ManualOffsets = config.Bind("ItemClipping", "manual_offsets", "", "y offset for items on the ground\nDictionary Format: '[key]:[value],[key2]:[value2]'\neg: `Vanilla/Ammo:0.0`"); OutOfBounds.Enabled = config.Bind("OutOfBounds", "enabled", true, "prevent items from falling below the ship"); OutOfBounds.VerticalOffset = config.Bind("OutOfBounds", "vertical_offset", 0.01f, new ConfigDescription("vertical offset to apply to objects on load to prevent them from clipping into the floor", (AcceptableValueBase)(object)new AcceptableValueRange(0.001f, 1f), Array.Empty())); OutOfBounds.SpawnInFurniture = config.Bind("OutOfBounds", "spawn_in_furniture", true, "Fix items generating inside furniture ( eg: lamps inside the kitchen counter )"); Debug.VerboseMeshes = config.Bind("Debug", "Mesh Verbosity Level", (LogLevel)0, "Print A LOT more logs about Meshes"); Debug.VerboseCupboard = config.Bind("Debug", "Cupboard Verbosity Level", (LogLevel)0, "Print A LOT more logs about Cupboard detection"); Debug.VerboseItems = config.Bind("Debug", "Item Verbosity Level", (LogLevel)0, "Print A LOT more logs about Cupboard detection"); string value = ItemClipping.ManualOffsets.Value; string[] array = value.Split(','); foreach (string text in array) { string[] array2 = text.Split(':'); if (array2.Length > 1) { string key = array2[0].Trim(); if (float.TryParse(array2[1], NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.InvariantInfo, out var result)) { ItemClipping.ManualOffsetMap.Add(key, result); } } } if (LethalConfigProxy.Enabled) { LethalConfigProxy.AddButton("Cleanup", "Clear old entries", "remove unused entries in the config file\n(IF RUN FROM MENU WILL DELETE ALL ITEM OFFSETS!!)", "Clean&Save", RemoveOrphans); LethalConfigProxy.AddConfig(ReadableMeshes.Enabled, requiresRestart: true); LethalConfigProxy.AddConfig(Particles.Lightning, requiresRestart: true); LethalConfigProxy.AddConfig(Particles.Flies, requiresRestart: true); LethalConfigProxy.AddConfig(BadgeFixes.Enabled, requiresRestart: true); LethalConfigProxy.AddConfig(CupBoard.Enabled); LethalConfigProxy.AddConfig(CupBoard.Tolerance); LethalConfigProxy.AddConfig(CupBoard.Shift); LethalConfigProxy.AddConfig(Radar.Enabled); LethalConfigProxy.AddConfig(Radar.RemoveDeleted); LethalConfigProxy.AddConfig(Radar.RemoveOnShip); LethalConfigProxy.AddConfig(ItemClipping.Enabled); LethalConfigProxy.AddConfig(ItemClipping.RotateOnSpawn); LethalConfigProxy.AddConfig(ItemClipping.VerticalOffset); LethalConfigProxy.AddConfig(ItemClipping.ManualOffsets, requiresRestart: true); LethalConfigProxy.AddConfig(OutOfBounds.Enabled, requiresRestart: true); LethalConfigProxy.AddConfig(OutOfBounds.VerticalOffset); LethalConfigProxy.AddConfig(OutOfBounds.SpawnInFurniture, requiresRestart: true); LethalConfigProxy.AddConfig(Debug.VerboseMeshes, requiresRestart: false); LethalConfigProxy.AddConfig(Debug.VerboseCupboard, requiresRestart: false); LethalConfigProxy.AddConfig(Debug.VerboseItems, requiresRestart: false); } } internal static void RemoveOrphans() { ConfigFile config = ((BaseUnityPlugin)Instance).Config; PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary dictionary = (Dictionary)property.GetValue(config, null); dictionary.Clear(); config.Save(); } } internal readonly struct ItemRotationConfig { public Vector3 Original { get; } public ConfigEntry Config { get; } public ItemRotationConfig(Vector3 original, ConfigEntry config) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Original = original; Config = config; } } public const string GUID = "mattymatty.MattyFixes"; public const string NAME = "Matty's Fixes"; public const string VERSION = "1.1.41"; internal static ManualLogSource Log; private static int? _visibleLayerMask; internal static Harmony Harmony { get; private set; } internal static HashSet Hooks { get; } = new HashSet(); internal static MattyFixes Instance { get; private set; } public static int VisibleLayerMask { get { int valueOrDefault = _visibleLayerMask.GetValueOrDefault(); if (!_visibleLayerMask.HasValue) { valueOrDefault = LayerMask.GetMask(new string[13] { "Default", "Player", "Water", "Props", "Room", "InteractableObject", "Foliage", "PhysicsObject", "Enemies", "PlayerRagdoll", "MapHazards", "MiscLevelGeometry", "Terrain" }); _visibleLayerMask = valueOrDefault; } return _visibleLayerMask.Value; } } private void Awake() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } Log = ((BaseUnityPlugin)this).Logger; try { if (LobbyCompatibilityChecker.Enabled) { LobbyCompatibilityChecker.Init(); } Log.LogInfo((object)"Initializing Configs"); PluginConfig.Init(); Log.LogInfo((object)"Patching Methods"); Harmony = new Harmony("mattymatty.MattyFixes"); Harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"Matty's Fixes v1.1.41 Loaded!"); } catch (Exception ex) { Log.LogError((object)("Exception while initializing: \n" + ex)); } } internal static void VerboseMeshLog(LogType logLevel, Func message) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_009e: 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_0087: Invalid comparison between Unknown and I4 //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0090: 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_0016: Invalid comparison between Unknown and I4 //IL_00a3: 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_00a7: Unknown result type (might be due to invalid IL or missing references) LogLevel val; if ((int)logLevel <= 128) { if ((int)logLevel <= 8) { if ((int)logLevel != 2) { if ((int)logLevel != 4) { if ((int)logLevel != 8) { goto IL_00a6; } val = (LogLevel)4; } else { val = (LogLevel)2; } } else { val = (LogLevel)1; } goto IL_00a8; } if ((int)logLevel <= 32) { if ((int)logLevel == 16 || (int)logLevel == 32) { goto IL_0097; } } else if ((int)logLevel == 64 || (int)logLevel == 128) { goto IL_0097; } } else if ((int)logLevel <= 512) { if ((int)logLevel == 240) { goto IL_0097; } if ((int)logLevel == 256 || (int)logLevel == 512) { goto IL_009c; } } else if ((int)logLevel <= 2048) { if ((int)logLevel == 1024 || (int)logLevel == 2048) { goto IL_009c; } } else { if ((int)logLevel == 3840) { goto IL_009c; } if ((int)logLevel == 4094) { val = (LogLevel)63; goto IL_00a8; } } goto IL_00a6; IL_0097: val = (LogLevel)16; goto IL_00a8; IL_00a6: val = (LogLevel)0; goto IL_00a8; IL_009c: val = (LogLevel)32; goto IL_00a8; IL_00a8: LogLevel logLevel2 = val; VerboseMeshLog(logLevel2, message); } internal static void VerboseMeshLog(LogLevel logLevel, Func message) { //IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((PluginConfig.Debug.VerboseMeshes.Value & logLevel) != 0) { Log.Log(logLevel, (object)message()); } } internal static void VerboseCupboardLog(LogLevel logLevel, Func message) { //IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((PluginConfig.Debug.VerboseCupboard.Value & logLevel) != 0) { Log.Log(logLevel, (object)message()); } } internal static void VerboseItemsLog(LogLevel logLevel, Func message) { //IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((PluginConfig.Debug.VerboseItems.Value & logLevel) != 0) { Log.Log(logLevel, (object)message()); } } } internal static class PluginResources { internal static readonly Dictionary> ItemClippingFixRotations = new Dictionary> { { "Vanilla/Flashlight", new List(3) { 90f, 0f, 90f } }, { "Vanilla/Jetpack", new List(3) { 45f, 0f, 0f } }, { "Vanilla/Key", new List(3) { 180f, 0f, 90f } }, { "Vanilla/Apparatus", new List(3) { 0f, 0f, 135f } }, { "Vanilla/Pro-flashlight", new List(3) { 90f, 0f, 90f } }, { "Vanilla/Shovel", new List(3) { 0f, 0f, -90f } }, { "Vanilla/Stun grenade", new List(3) { 0f, 0f, 90f } }, { "Vanilla/Extension ladder", new List(3) { 0f, 90f, 0f } }, { "Vanilla/TZP-Inhalant", new List(3) { 0f, 0f, -90f } }, { "Vanilla/Zap gun", new List(3) { 95f, 0f, 90f } }, { "Vanilla/Magic 7 ball", new List(3) { 0f, 0f, 0f } }, { "Vanilla/Airhorn", new List(3) { 0f, -90f, 270f } }, { "Vanilla/Big bolt", new List(3) { -21f, 0f, 0f } }, { "Vanilla/Bottles", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Brush", new List(3) { 90f, 180f, 0f } }, { "Vanilla/Candy", new List(3) { 90f, -135f, 0f } }, { "Vanilla/Cash register", new List(3) { -90f, -90f, 40f } }, { "Vanilla/Chemical jug", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Clown horn", new List(3) { -90f, -30f, 0f } }, { "Vanilla/Large axle", new List(3) { 7f, 180f, 0f } }, { "Vanilla/Teeth", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Dust pan", new List(3) { -90f, 180f, 0f } }, { "Vanilla/Egg beater", new List(3) { 90f, 180f, 0f } }, { "Vanilla/V-type engine", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Plastic fish", new List(3) { -45f, 0f, 90f } }, { "Vanilla/Laser pointer", new List(3) { 0f, 0f, 0f } }, { "Vanilla/Gold bar", new List(3) { -90f, 0f, -90f } }, { "Vanilla/Hairdryer", new List(3) { 0f, -90f, -90f } }, { "Vanilla/Magnifying glass", new List(3) { 0f, -45f, -90f } }, { "Vanilla/Cookie mold pan", new List(3) { -90f, 0f, 90f } }, { "Vanilla/Mug", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Perfume bottle", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Old phone", new List(3) { -90f, 180f, -90f } }, { "Vanilla/Jar of pickles", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Pill bottle", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Remote", new List(3) { -90f, 180f, 0f } }, { "Vanilla/Ring", new List(3) { 0f, -90f, 90f } }, { "Vanilla/Toy robot", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Rubber Ducky", new List(3) { -90f, 0f, 90f } }, { "Vanilla/Steering wheel", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Toothpaste", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Hive", new List(3) { 7f, 0f, 0f } }, { "Vanilla/Radar-booster", new List(3) { 0f, 0f, 0f } }, { "Vanilla/Shotgun", new List(3) { 180f, 90f, -5f } }, { "Vanilla/Ammo", new List(3) { 0f, 0f, 90f } }, { "Vanilla/Spray paint", new List(3) { 0f, 0f, 195f } }, { "Vanilla/Homemade flashbang", new List(3) { 0f, 0f, 90f } }, { "Vanilla/Gift", new List(3) { -90f, 0f, 0f } }, { "Vanilla/Flask", new List(3) { 25f, 0f, 0f } }, { "Vanilla/Tragedy", new List(3) { -90f, 90f, 0f } }, { "Vanilla/Comedy", new List(3) { -90f, 90f, 0f } }, { "Vanilla/Whoopie cushion", new List(3) { -90f, 180f, 0f } }, { "Vanilla/Zed Dog", new List(3) { 0f, -90f, 0f } } }; } public static class MyPluginInfo { public const string PLUGIN_GUID = "mattymatty.MattyFixes"; public const string PLUGIN_NAME = "Matty's Fixes"; public const string PLUGIN_VERSION = "1.1.41"; } } namespace MattyFixes.Utils { public static class ItemCategory { public enum ItemType { Unknown, Vanilla, Modded } private static readonly Regex ConfigFilterRegex = new Regex("[\\n\\t\\\\\\'\\[\\]]"); [NotNull] public static string GetPath(this Item item) { string mattyFixes_Path = ((IInjectedItem)item).MattyFixes_Path; if (mattyFixes_Path != null) { return mattyFixes_Path; } ItemType itemType = ItemType.Unknown; mattyFixes_Path = item.ComputePath("Unknown"); if (DawnLibProxy.Enabled) { string path; ItemType itemType2 = DawnLibProxy.DefineItem(item, out path); if (itemType <= itemType2) { itemType = itemType2; mattyFixes_Path = path; } } ((IInjectedItem)item).MattyFixes_ItemType = itemType; ((IInjectedItem)item).MattyFixes_Path = mattyFixes_Path; return mattyFixes_Path; } public static string ComputePath(this Item item, [NotNull] string library, [NotNull] params string[] path) { List list = new List(2 + path.Length); list.Add(library); list.AddRange(path); list.Add(item.itemName ?? ((Object)item).name); return string.Join('/', list.Select((string p) => string.Join("_", p.Split(Path.GetInvalidPathChars(), StringSplitOptions.RemoveEmptyEntries)).TrimEnd('.')).ToArray()).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } public static string SanitizeForConfig(string input) { return ConfigFilterRegex.Replace(input, "").Trim(); } } public static class NgoUtils { private static readonly MethodInfo BeginSendClientRpc = AccessTools.Method(typeof(NetworkBehaviour), "__beginSendClientRpc", (Type[])null, (Type[])null); private static readonly MethodInfo BeginSendServerRpc = AccessTools.Method(typeof(NetworkBehaviour), "__beginSendServerRpc", (Type[])null, (Type[])null); private static readonly __RpcExecStage ClientRpcStage; private static readonly __RpcExecStage ServerRpcStage; public static bool IsRPCClientStage(this NetworkBehaviour self) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = self.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (self.__rpc_exec_stage != ClientRpcStage || (!networkManager.IsClient && !networkManager.IsHost)) { return false; } return true; } public static bool IsRPCServerStage(this NetworkBehaviour self) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = self.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (self.__rpc_exec_stage != ServerRpcStage || (!networkManager.IsServer && !networkManager.IsHost)) { return false; } return true; } internal static bool TryGetRpcID(this MethodInfo methodInfo, out uint rpcID) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Collection instructions = PatchManager.GetMethodPatcher((MethodBase)methodInfo).CopyOriginal().Definition.Body.Instructions; rpcID = 0u; for (int i = 0; i < instructions.Count; i++) { if (instructions[i].OpCode == OpCodes.Ldc_I4 && instructions[i - 1].OpCode == OpCodes.Ldarg_0) { rpcID = (uint)(int)instructions[i].Operand; } if (!(instructions[i].OpCode != OpCodes.Call)) { object operand = instructions[i].Operand; MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null); if (val != null && (Extensions.Is((MemberReference)(object)val, (MemberInfo)BeginSendClientRpc) || Extensions.Is((MemberReference)(object)val, (MemberInfo)BeginSendServerRpc))) { MattyFixes.Log.LogDebug((object)$"Rpc Id found for {methodInfo.Name}: {rpcID}U"); return true; } } } MattyFixes.Log.LogFatal((object)("Cannot find Rpc ID for " + methodInfo.Name)); return false; } static NgoUtils() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0050: 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_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_006f: Unknown result type (might be due to invalid IL or missing references) string unityVersion = Application.unityVersion; __RpcExecStage clientRpcStage = ((!(unityVersion == "2022.3.9f1")) ? ((__RpcExecStage)1) : ((__RpcExecStage)2)); ClientRpcStage = clientRpcStage; string unityVersion2 = Application.unityVersion; clientRpcStage = ((!(unityVersion2 == "2022.3.9f1")) ? ((__RpcExecStage)1) : ((__RpcExecStage)1)); ServerRpcStage = clientRpcStage; } } public static class ReflectionUtils { internal static Delegate FastGetter([NotNull("ArgumentNullException")] this FieldInfo field) { if ((object)field == null) { throw new ArgumentNullException("field"); } string name = field.ReflectedType.FullName + ".get_" + field.Name; DynamicMethod dynamicMethod = new DynamicMethod(name, field.FieldType, new Type[1] { field.DeclaringType }, restrictedSkipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); if (field.IsStatic) { iLGenerator.Emit(OpCodes.Ldsfld, field); } else { iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Ldfld, field); } iLGenerator.Emit(OpCodes.Ret); if (field.IsStatic) { return dynamicMethod.CreateDelegate(Expression.GetFuncType(field.FieldType)); } return dynamicMethod.CreateDelegate(Expression.GetFuncType(field.DeclaringType, field.FieldType)); } internal static Delegate FastSetter([NotNull("ArgumentNullException")] this FieldInfo field) { if ((object)field == null) { throw new ArgumentNullException("field"); } string name = field.ReflectedType.FullName + ".get_" + field.Name; DynamicMethod dynamicMethod = new DynamicMethod(name, field.FieldType, new Type[2] { field.DeclaringType, field.FieldType }, restrictedSkipVisibility: true); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); if (field.IsStatic) { iLGenerator.Emit(OpCodes.Ldarg_1); iLGenerator.Emit(OpCodes.Stsfld, field); } else { iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Ldarg_1); iLGenerator.Emit(OpCodes.Stfld, field); } iLGenerator.Emit(OpCodes.Ldarg_1); iLGenerator.Emit(OpCodes.Ret); if (field.IsStatic) { return dynamicMethod.CreateDelegate(Expression.GetFuncType(field.FieldType, field.FieldType)); } return dynamicMethod.CreateDelegate(Expression.GetFuncType(field.DeclaringType, field.FieldType, field.FieldType)); } } } namespace MattyFixes.Utils.IL { internal class ILInjector { [CompilerGenerated] private sealed class d__34 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; public ILInjector <>4__this; private int offset; public int <>3__offset; private int size; public int <>3__size; private int 5__2; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__34(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; ILInjector iLInjector = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < size) { <>2__current = iLInjector.instructions[iLInjector.index + offset + 5__2]; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__34 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__34(0) { <>4__this = <>4__this }; } d__.offset = <>3__offset; d__.size = <>3__size; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private const string INVALID = "Injector is invalid"; private List instructions = instructions.ToList(); private ILGenerator generator; private int index; private int matchEnd; public int Index { get { return index; } set { index = value; } } public bool IsValid { get { if (instructions != null) { return IsIndexValid(index); } return false; } } public CodeInstruction Instruction { get { if (!IsIndexInRange(index)) { return null; } return instructions[index]; } set { if (!IsIndexInRange(index)) { throw new InvalidOperationException($"Current index {index} is out of range of instruction count {instructions.Count}"); } instructions[index] = value; } } public CodeInstruction LastMatchedInstruction { get { int num = matchEnd - 1; if (!IsIndexInRange(num)) { return null; } return instructions[num]; } set { int num = matchEnd - 1; if (!IsIndexInRange(num)) { throw new InvalidOperationException($"Last matched index {index} is out of range of instruction count {instructions.Count}"); } instructions[num] = value; } } public ICollection Instructions => instructions.AsReadOnly(); public ILInjector(IEnumerable instructions, ILGenerator generator = null) { this.generator = generator; matchEnd = -1; base..ctor(); } public ILInjector GoToStart() { matchEnd = index; index = 0; return this; } public ILInjector GoToEnd() { matchEnd = index; index = instructions.Count; return this; } public ILInjector Forward(int offset) { if (!IsValid) { return this; } matchEnd = index; index = Math.Clamp(index + offset, -1, instructions.Count); return this; } public ILInjector Back(int offset) { return Forward(-offset); } private void MarkInvalid() { index = -1; matchEnd = -1; } private void Search(bool forward, ILMatcher[] predicates) { if (!IsValid) { return; } int num = 1; if (!forward) { num = -1; index--; } while (forward ? (index < instructions.Count) : (index >= 0)) { if (forward && index + predicates.Length > instructions.Count) { index = instructions.Count; break; } int i; for (i = 0; i < predicates.Length && predicates[i].Matches(instructions[index + i]); i++) { } if (i == predicates.Length) { matchEnd = index + i; return; } index += num; } MarkInvalid(); } public ILInjector Find(params ILMatcher[] predicates) { Search(forward: true, predicates); return this; } public ILInjector ReverseFind(params ILMatcher[] predicates) { Search(forward: false, predicates); return this; } public ILInjector GoToPush(int popIndex) { if (!IsValid) { return this; } matchEnd = index; index--; int num = 0; while (index >= 0) { CodeInstruction instruction = instructions[index]; num += instruction.PushCount(); num -= instruction.PopCount(); if (num >= popIndex) { return this; } index--; } return this; } public ILInjector SkipBranch() { if (Instruction == null) { return this; } if (!(Instruction.operand is Label label)) { throw new InvalidOperationException($"Current instruction is not a branch: {Instruction}"); } return FindLabel(label); } public ILInjector FindLabel(Label label) { if (label == default(Label)) { return this; } matchEnd = index; for (index = 0; index < instructions.Count; index++) { if (instructions[index].labels.Contains(label)) { return this; } } MarkInvalid(); return this; } public ILInjector GoToMatchEnd() { index = matchEnd; return this; } public ILInjector GoToLastMatchedInstruction() { if (!IsIndexValid(matchEnd)) { return this; } index = matchEnd - 1; return this; } private bool IsIndexValid(int index) { return index != -1; } private bool IsIndexInRange(int index) { if (index >= 0) { return index < instructions.Count; } return false; } public CodeInstruction GetRelativeInstruction(int offset) { if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } int num = index + offset; if (!IsIndexInRange(num)) { throw new IndexOutOfRangeException($"Offset {offset} would read out of bounds at index {num}"); } return instructions[num]; } public ILInjector SetRelativeInstruction(int offset, CodeInstruction instruction) { if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } int num = index + offset; if (!IsIndexInRange(num)) { throw new IndexOutOfRangeException($"Offset {offset} would write out of bounds at index {num}"); } instructions[num] = instruction; return this; } [IteratorStateMachine(typeof(d__34))] public IEnumerable GetRelativeInstructions(int offset, int size) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__34(-2) { <>4__this = this, <>3__offset = offset, <>3__size = size }; } public IEnumerable GetRelativeInstructions(int size) { return GetRelativeInstructions(0, size); } private void GetLastMatchRangeAbsolute(out int start, out int end) { start = index; end = matchEnd; if (start > end) { int num = end; int num2 = start; start = num; end = num2; } } private void GetLastMatchRange(out int start, out int size) { GetLastMatchRangeAbsolute(out start, out var end); if (start < 0 || start >= instructions.Count) { throw new InvalidOperationException($"Last match range starts at invalid index {start}"); } if (end < 0 || end > instructions.Count) { throw new InvalidOperationException($"Last match range ends at invalid index {end}"); } size = end - start; } public List GetLastMatch() { GetLastMatchRange(out var start, out var size); return instructions.GetRange(start, size); } public ILInjector DefineLabel(out Label label) { if (generator == null) { throw new InvalidOperationException("No ILGenerator was provided"); } label = generator.DefineLabel(); return this; } public ILInjector AddLabel(out Label label) { DefineLabel(out label); return AddLabel(label); } public ILInjector AddLabel(Label label) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Instruction = new CodeInstruction(Instruction); Instruction.labels.Add(label); return this; } public ILInjector InsertInPlace(params CodeInstruction[] instructions) { if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } this.instructions.InsertRange(index, instructions); if (matchEnd >= index) { matchEnd += instructions.Length; } return this; } public ILInjector Insert(params CodeInstruction[] instructions) { InsertInPlace(instructions); index += instructions.Length; return this; } public ILInjector InsertInPlaceAfterBranch(params CodeInstruction[] instructions) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (!IsValid) { throw new InvalidOperationException("Injector is invalid"); } List