Decompiled source of DorsthTweaks v1.5.1
BepInEx/plugins/DorsthTweaks/DorsthTweaks.dll
Decompiled 12 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ComputerysModdingUtilities; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using DorsthTweaks; using FishNet; using FishNet.Component.Utility; using FishNet.Connection; using FishNet.Managing; using FishNet.Object; using HarmonyLib; using HeathenEngineering.DEMO; using HeathenEngineering.PhysKit; using HeathenEngineering.SteamworksIntegration; using ModMenu.Api; using TMPro; using UltimateTweaks; using Unity.Collections; using Unity.Jobs.LowLevel.Unsafe; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.InputSystem; using UnityEngine.LowLevel; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; using UnityEngine.Scripting; using UnityEngine.UI; using UnityStandardAssets.Effects; using UnityStandardAssets.Water; using VLB; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("DorsthTweaks")] [assembly: AssemblyDescription("Small client-side tweaks for STRAFTAT: bullet trails, HUD, prompts, menus and performance.")] [assembly: AssemblyFileVersion("1.3.7.0")] [assembly: StraftatMod(true)] [assembly: AssemblyVersion("1.5.1.0")] namespace UltimateTweaks { internal static class InputCallbacks { private static FieldInfo[] lists; private static PropertyInfo length; private static PropertyInfo item; private static bool looked; private static bool ok; private static readonly List<KeyValuePair<int, Delegate>> dead = new List<KeyValuePair<int, Delegate>>(); private static bool Ready() { if (looked) { return ok; } looked = true; try { Type typeFromHandle = typeof(InputAction); lists = new FieldInfo[3] { typeFromHandle.GetField("m_OnStarted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), typeFromHandle.GetField("m_OnPerformed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), typeFromHandle.GetField("m_OnCanceled", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) }; if (lists[0] == null || lists[1] == null || lists[2] == null) { return false; } length = lists[0].FieldType.GetProperty("length", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); item = lists[0].FieldType.GetProperty("Item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); ok = length != null && item != null; } catch { ok = false; } return ok; } public static void Scan(bool remove, out int total, out int gone) { total = 0; gone = 0; PlayerControls inputActions = InputManager.inputActions; if (inputActions == null || !Ready()) { return; } object[] array = new object[1]; foreach (InputAction item in inputActions.asset) { dead.Clear(); for (int i = 0; i < 3; i++) { object value = lists[i].GetValue(item); int num = (int)length.GetValue(value, null); for (int j = 0; j < num; j++) { array[0] = j; if (!(InputCallbacks.item.GetValue(value, array) is Delegate obj)) { continue; } total++; object? target = obj.Target; Object val = (Object)((target is Object) ? target : null); if (val != null && val == (Object)null) { gone++; if (remove) { dead.Add(new KeyValuePair<int, Delegate>(i, obj)); } } } } foreach (KeyValuePair<int, Delegate> item2 in dead) { if (item2.Value is Action<CallbackContext> action) { if (item2.Key == 0) { item.started -= action; } else if (item2.Key == 1) { item.performed -= action; } else { item.canceled -= action; } } } } dead.Clear(); } } internal static class Fullbright { private struct Dulled { public Material M; public bool Keyword; public bool IsColor; public int Id; public float F; public Color C; } private struct Prop { public int Id; public string Name; public bool IsColor; } private const float FillBrightness = 0.1f; public const string FillName = "UT_FullbrightFillLight"; private static string applied = "Off"; private static string appliedShine = ""; private static float appliedB = -1f; private static int sceneHandle = -1; private static GameObject fill; private const string SpecOff = "_SPECULARHIGHLIGHTS_OFF"; private static readonly int SpecFlag = Shader.PropertyToID("_SpecularHighlights"); private static readonly List<Dulled> dulled = new List<Dulled>(); private static readonly Dictionary<Shader, List<Prop>> glossProps = new Dictionary<Shader, List<Prop>>(); private static readonly HashSet<int> dullScenes = new HashSet<int>(); private static readonly HashSet<int> dullSeen = new HashSet<int>(); private static readonly List<MeshRenderer> pending = new List<MeshRenderer>(); private static int pendingAt; private static readonly Dictionary<string, string> touched = new Dictionary<string, string>(); private static readonly List<Material> matBuf = new List<Material>(); private static string dullMap; private static readonly HashSet<int> liveScenes = new HashSet<int>(); private static readonly HashSet<int> sunScenes = new HashSet<int>(); private static readonly List<Light> lightBuf = new List<Light>(); private static readonly List<DetachableObject> chunkBuf = new List<DetachableObject>(); private static string sunSaid; public static void Refresh() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) string text = (TweaksPlugin.Plain ? "FillLight" : "Off"); if (TweaksPlugin.InMenu) { text = "Off"; } float num = 0.1f; Scene activeScene = SceneManager.GetActiveScene(); int handle = ((Scene)(ref activeScene)).handle; bool flag = handle != sceneHandle; string text2 = ((text == "FillLight") ? "Matte" : ""); if (text == "FillLight") { flag = false; } if (text == applied && text2 == appliedShine && Mathf.Approximately(appliedB, num) && !flag && StillOurs()) { if (text == "FillLight") { SunCheck(); if (text2 != "Keep") { QueueNewScenes(); } } return; } try { Undo(); sceneHandle = handle; applied = text; appliedB = num; appliedShine = text2; sunSaid = null; if (text == "FillLight") { Fill(num); sunScenes.Clear(); SunCheck(); if (text2 != "Keep") { QueueNewScenes(); } } } catch (Exception ex) { TweaksPlugin.L.LogWarning((object)("Fullbright could not be applied: " + ex.Message)); } } private static bool StillOurs() { if (applied == "FillLight") { return (Object)(object)fill != (Object)null; } return true; } private static void Undo() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)fill != (Object)null) { Object.Destroy((Object)(object)fill); fill = null; } foreach (Dulled item in dulled) { if (Object.op_Implicit((Object)(object)item.M)) { if (item.Keyword) { item.M.DisableKeyword("_SPECULARHIGHLIGHTS_OFF"); } else if (item.IsColor) { item.M.SetColor(item.Id, item.C); } else { item.M.SetFloat(item.Id, item.F); } } } dulled.Clear(); dullScenes.Clear(); dullSeen.Clear(); pending.Clear(); pendingAt = 0; touched.Clear(); } private static bool Has(string n, params string[] words) { foreach (string value in words) { if (n.Contains(value)) { return true; } } return false; } private static List<Prop> GlossProps(Shader sh) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (glossProps.TryGetValue(sh, out var value)) { return value; } value = new List<Prop>(); for (int i = 0; i < sh.GetPropertyCount(); i++) { string propertyName = sh.GetPropertyName(i); string text = propertyName.ToLowerInvariant(); ShaderPropertyType propertyType = sh.GetPropertyType(i); bool flag = (int)propertyType == 2 || (int)propertyType == 3; if (flag && Has(text, "smooth", "gloss") && !Has(text, "min", "max", "remap", "channel", "use")) { value.Add(new Prop { Id = Shader.PropertyToID(propertyName), Name = propertyName }); } else if (flag && text.Contains("spec") && Has(text, "intensity", "strength", "amount", "scale", "mult")) { value.Add(new Prop { Id = Shader.PropertyToID(propertyName), Name = propertyName }); } else if ((int)propertyType == 0 && text.Contains("spec")) { value.Add(new Prop { Id = Shader.PropertyToID(propertyName), Name = propertyName, IsColor = true }); } } glossProps[sh] = value; return value; } private static void QueueNewScenes() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < SceneManager.sceneCount; i++) { Scene sceneAt = SceneManager.GetSceneAt(i); if (!((Scene)(ref sceneAt)).isLoaded || ((Scene)(ref sceneAt)).name == "MainMenu" || !dullScenes.Add(((Scene)(ref sceneAt)).handle)) { continue; } string name = ((Scene)(ref sceneAt)).name; if (name != "EmptyScene" && name != "VictoryScene" && name != "MovedObjectsHolder" && name != "DontDestroyOnLoad" && name != dullMap) { if (dullMap != null) { foreach (Dulled item in dulled) { if (Object.op_Implicit((Object)(object)item.M)) { if (item.Keyword) { item.M.DisableKeyword("_SPECULARHIGHLIGHTS_OFF"); } else if (item.IsColor) { item.M.SetColor(item.Id, item.C); } else { item.M.SetFloat(item.Id, item.F); } } } dulled.Clear(); dullSeen.Clear(); touched.Clear(); liveScenes.Clear(); for (int j = 0; j < SceneManager.sceneCount; j++) { HashSet<int> hashSet = liveScenes; Scene sceneAt2 = SceneManager.GetSceneAt(j); hashSet.Add(((Scene)(ref sceneAt2)).handle); } dullScenes.RemoveWhere((int h) => !liveScenes.Contains(h)); } dullMap = name; } GameObject[] rootGameObjects = ((Scene)(ref sceneAt)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (val.layer != 5) { pending.AddRange(val.GetComponentsInChildren<MeshRenderer>(true)); } } } } public static void Tick() { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01e9: Unknown result type (might be due to invalid IL or missing references) if (pendingAt >= pending.Count) { return; } int num = Math.Min(pending.Count, pendingAt + 24); while (pendingAt < num) { MeshRenderer val = pending[pendingAt]; if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.layer != 5) { ((Renderer)val).GetSharedMaterials(matBuf); foreach (Material item in matBuf) { if ((Object)(object)item == (Object)null || (Object)(object)item.shader == (Object)null || !dullSeen.Add(((Object)item).GetInstanceID())) { continue; } string text = ""; if (item.HasProperty(SpecFlag)) { if (!item.IsKeywordEnabled("_SPECULARHIGHLIGHTS_OFF")) { item.EnableKeyword("_SPECULARHIGHLIGHTS_OFF"); dulled.Add(new Dulled { M = item, Keyword = true }); } dulled.Add(new Dulled { M = item, Id = SpecFlag, F = item.GetFloat(SpecFlag) }); item.SetFloat(SpecFlag, 0f); text = "highlight switch"; } foreach (Prop item2 in GlossProps(item.shader)) { if (item2.IsColor) { Color color = item.GetColor(item2.Id); dulled.Add(new Dulled { M = item, Id = item2.Id, IsColor = true, C = color }); item.SetColor(item2.Id, new Color(0f, 0f, 0f, color.a)); text = text + ((text.Length > 0) ? ", " : "") + item2.Name; } else { float f = item.GetFloat(item2.Id); dulled.Add(new Dulled { M = item, Id = item2.Id, F = f }); item.SetFloat(item2.Id, 0f); text = text + ((text.Length > 0) ? ", " : "") + item2.Name; } } if (text.Length > 0 && !touched.ContainsKey(((Object)item.shader).name)) { touched[((Object)item.shader).name] = text; } } } pendingAt++; } if (pendingAt < pending.Count) { return; } int count = pending.Count; pending.Clear(); pendingAt = 0; if (dulled.Count > 4000) { dulled.RemoveAll((Dulled d) => !Object.op_Implicit((Object)(object)d.M)); } StringBuilder stringBuilder = new StringBuilder("Fullbright fill light, shine Matte: " + count + " meshes looked at, gloss taken out on"); foreach (KeyValuePair<string, string> item3 in touched) { stringBuilder.Append(" [" + item3.Key + ": " + item3.Value + "]"); } DorsthTweaksPlugin.Note(stringBuilder.ToString()); touched.Clear(); } private static void SunCheck() { //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) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Invalid comparison between Unknown and I4 //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Invalid comparison between Unknown and I4 if ((Object)(object)fill == (Object)null) { return; } bool flag = false; bool flag2 = false; string text = null; for (int i = 0; i < SceneManager.sceneCount; i++) { Scene sceneAt = SceneManager.GetSceneAt(i); string name = ((Scene)(ref sceneAt)).name; if (!((Scene)(ref sceneAt)).isLoaded) { continue; } switch (name) { case "MainMenu": case "EmptyScene": case "VictoryScene": case "MovedObjectsHolder": case "DontDestroyOnLoad": continue; } if (sunScenes.Add(((Scene)(ref sceneAt)).handle)) { flag = true; } text = name; } if (!flag) { return; } if (sunScenes.Count > 64) { sunScenes.Clear(); } int num = 0; string text2 = "none"; for (int j = 0; j < SceneManager.sceneCount; j++) { Scene sceneAt2 = SceneManager.GetSceneAt(j); string name2 = ((Scene)(ref sceneAt2)).name; if (!((Scene)(ref sceneAt2)).isLoaded) { continue; } switch (name2) { case "MainMenu": case "EmptyScene": case "VictoryScene": case "MovedObjectsHolder": case "DontDestroyOnLoad": continue; } GameObject[] rootGameObjects = ((Scene)(ref sceneAt2)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { val.GetComponentsInChildren<Light>(false, lightBuf); foreach (Light item in lightBuf) { if (((Behaviour)item).enabled && (int)item.type == 1 && (item.cullingMask & 1) != 0 && item.intensity > 0f && (!item.bakingOutput.isBaked || (int)item.bakingOutput.lightmapBakeType != 2)) { flag2 = true; text2 = (item.bakingOutput.isBaked ? "mixed" : "realtime") + " " + item.intensity.ToString("0.##", CultureInfo.InvariantCulture); break; } } lightBuf.Clear(); val.GetComponentsInChildren<DetachableObject>(false, chunkBuf); num += chunkBuf.Count; chunkBuf.Clear(); } } int num2 = LightmapSettings.lightmaps.Length; bool flag3 = flag2 && (num2 == 0 || num >= 50); Light component = fill.GetComponent<Light>(); if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled == flag3) { ((Behaviour)component).enabled = !flag3; } if (text != null && text != sunSaid) { sunSaid = text; DorsthTweaksPlugin.Note("Fullbright fill light: " + (flag3 ? "off" : "on") + " on " + text + " (sun of its own: " + text2 + ", lightmaps: " + num2 + ", chunks that can be shot off: " + num + (flag3 ? "; a second sun-type light would draw every object twice" : (flag2 ? "; kept for the dark parts, every object is drawn twice" : "")) + ")"); } } private static void Fill(float b) { //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_0017: Expected O, but got Unknown //IL_003a: 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) fill = new GameObject("UT_FullbrightFillLight") { hideFlags = (HideFlags)52 }; Object.DontDestroyOnLoad((Object)(object)fill); fill.transform.rotation = Quaternion.Euler(55f, -35f, 0f); Light obj = fill.AddComponent<Light>(); obj.type = (LightType)1; obj.color = Color.white; obj.intensity = b; obj.shadows = (LightShadows)0; obj.renderMode = (LightRenderMode)1; obj.cullingMask = -1; } } internal sealed class TweaksPlugin : MonoBehaviour { public const string Guid = "dorsth.straftat.ultimatetweaks"; internal static ManualLogSource L; internal static TweaksPlugin I; internal static ConfigEntry<bool> Master; internal static string Solo = ""; private static readonly Dictionary<string, string> tierOf = new Dictionary<string, string>(); internal static ulong GcStepNs = 250000uL; internal static bool FadedLines; internal static bool KillCamText; internal static bool LineMatOne; internal static bool ArcPath; internal static bool WeaponLayer; internal static bool GuiNoLayout; internal static bool FovReuse; internal static bool SvNoSearch; internal static bool OtherArcs; internal static bool FovPile; internal static bool MycPoll; internal static bool ItemNameOn; internal static bool SceneNameOn; internal static bool HudText; internal static bool LobbyRowsLate; internal static bool DecalSmall; internal static bool MouseEventsOff; internal static bool CrosshairFix; internal static bool LobbyThrottle; internal static bool SteamCheckThrottle; internal static bool PreviewDollIdle; internal static bool Plain; internal static bool Forward; internal static bool OwnTagCanvasOff; internal static bool KillCamLean; internal static bool WeaponInputCopyOff; internal static bool DeadInputOff; internal static bool DeadNetOff; internal static bool GcSteps; internal static bool VoiceOffThread; internal static bool PreCompileOn; internal static bool JobLimit; internal static bool TrickLine; internal static bool GunScan; internal static int JobCount = 2; internal static float LobbyInterval = 0.2f; internal static bool InMenu = true; private Harmony lateHarmony; internal static void Create(GameObject host, ConfigEntry<bool> master, ManualLogSource log) { Master = master; L = log; host.AddComponent<TweaksPlugin>(); } public static string Test(string key, string value) { string text = (key ?? "").ToLowerInvariant(); if (!(text == "solo")) { if (!(text == "jobworkers")) { return "unknown key " + key; } if (!int.TryParse(value, out var result)) { return "jobworkers needs a number"; } JobCount = result; } else { Solo = value ?? ""; } if ((Object)(object)I != (Object)null) { I.Refresh(); } return null; } private void Start() { try { if (lateHarmony != null) { Patches.ApplyLate(lateHarmony); } } catch (Exception ex) { L.LogWarning((object)("Late patching failed: " + ex.Message)); } Patches.PreInitOnMainThread(); Refresh(); } private void Awake() { //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown I = this; string[] array = new string[29] { "FadedLinesEndEarly", "NoMouseEvents", "CrosshairFix", "LobbyListThrottle", "SteamRunningCheckThrottle", "PreviewDollIdle", "OwnNameTagCanvasOff", "KillCamLean", "WeaponNoInputCopy", "DeadInputCallbacks", "TrickShotLineNoGarbage", "GunSoundsNoScanInPlay", "DecalSmallBuffers", "ItemNameNoGarbage", "SceneNameNoGarbage", "HudNumbersNoGarbage", "LobbyRowsNotInPlay", "MyceliumPollRate", "OtherArcsAtScreenRate", "FovTweensNoPileUp", "SpawnViewerNoSearch", "WeaponLayerNoGarbage", "OnGuiNoLayout", "FovTweensReuse", "ArcPathNoGarbage", "ExplosionLinesOneMaterial", "KillCamNoGarbage", "DeadNetworkObjects", "GcSmallSteps" }; foreach (string key in array) { tierOf[key] = "Safe"; } array = new string[3] { "PreCompile", "VoiceKeyOffThread", "JobWorkerLimit" }; foreach (string key2 in array) { tierOf[key2] = "Experimental"; } Master.SettingChanged += delegate { Refresh(); }; DorsthTweaksPlugin.NoPostProcessing.SettingChanged += delegate { Refresh(); }; SceneManager.sceneLoaded += delegate(Scene sc, LoadSceneMode m) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Keeper.SceneLoaded(sc); Keeper.Dirty = true; }; SceneManager.sceneUnloaded += delegate(Scene sc) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Keeper.SceneUnloaded(sc); }; try { Patches.Apply(new Harmony("dorsth.straftat.ultimatetweaks")); } catch (Exception ex) { L.LogError((object)("Patching failed: " + ex)); } lateHarmony = new Harmony("dorsth.straftat.ultimatetweaks.late"); GameObject val = new GameObject("UltimateTweaks") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); val.AddComponent<Keeper>(); SceneManager.activeSceneChanged += delegate(Scene a, Scene b) { InMenu = ((Scene)(ref b)).name == "MainMenu"; Keeper.Dirty = true; }; Scene activeScene = SceneManager.GetActiveScene(); InMenu = ((Scene)(ref activeScene)).name == "MainMenu"; Refresh(); DorsthTweaksPlugin.Note("Ultimate Tweaks " + (Master.Value ? ("on: " + string.Join(", ", tierOf.Keys.Where(Active).ToArray())) : "off")); } private bool Active(string name) { string text = (Solo ?? "").Trim(); string value = tierOf[name]; if (text.Length == 0) { return Master.Value; } if (text.Equals("none", StringComparison.OrdinalIgnoreCase)) { return false; } string[] array = text.Split('+'); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.StartsWith("tier:", StringComparison.OrdinalIgnoreCase)) { string text3 = text2.Substring(5); if (text3.Equals("All", StringComparison.OrdinalIgnoreCase) || text3.Equals(value, StringComparison.OrdinalIgnoreCase)) { return true; } } else if (text2.Equals(name, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } internal void Refresh() { Forward = (Plain = DorsthTweaksPlugin.NoPostProcessing.Value); MouseEventsOff = Active("NoMouseEvents"); CrosshairFix = Active("CrosshairFix"); LobbyThrottle = Active("LobbyListThrottle"); SteamCheckThrottle = Active("SteamRunningCheckThrottle"); PreviewDollIdle = Active("PreviewDollIdle"); OwnTagCanvasOff = Active("OwnNameTagCanvasOff"); JobLimit = Active("JobWorkerLimit"); KillCamLean = Active("KillCamLean"); WeaponInputCopyOff = Active("WeaponNoInputCopy"); DeadInputOff = Active("DeadInputCallbacks"); DeadNetOff = Active("DeadNetworkObjects"); TrickLine = Active("TrickShotLineNoGarbage"); GunScan = Active("GunSoundsNoScanInPlay"); DecalSmall = Active("DecalSmallBuffers"); MycPoll = Active("MyceliumPollRate"); OtherArcs = Active("OtherArcsAtScreenRate"); FovPile = Active("FovTweensNoPileUp"); SvNoSearch = Active("SpawnViewerNoSearch"); WeaponLayer = Active("WeaponLayerNoGarbage"); ArcPath = Active("ArcPathNoGarbage"); LineMatOne = Active("ExplosionLinesOneMaterial"); FadedLines = Active("FadedLinesEndEarly"); KillCamText = Active("KillCamNoGarbage"); GuiNoLayout = Active("OnGuiNoLayout"); FovReuse = Active("FovTweensReuse") && FovPile; Patches.GuiLayoutRefresh(); ItemNameOn = Active("ItemNameNoGarbage"); SceneNameOn = Active("SceneNameNoGarbage"); HudText = Active("HudNumbersNoGarbage"); LobbyRowsLate = Active("LobbyRowsNotInPlay"); GcSteps = Active("GcSmallSteps"); VoiceOffThread = Active("VoiceKeyOffThread"); PreCompileOn = Active("PreCompile"); Patches.PreCompile(); Keeper.Dirty = true; } } [DefaultExecutionOrder(-31000)] internal sealed class Keeper : MonoBehaviour { public static bool Dirty = true; private float next; private int lastCamCount = -1; private Camera[] dollCams; private static bool mouseRemoved; private static PlayerLoopSystem mouseSys; private static Type mousePhase; private static int mouseIndex; private static Type[] mouseHandlerTypes; private readonly List<Behaviour> dollAnim = new List<Behaviour>(); private readonly List<KeyValuePair<Camera, RenderingPath>> camPaths = new List<KeyValuePair<Camera, RenderingPath>>(); private readonly List<Camera> camDepth = new List<Camera>(); private readonly List<SkinnedMeshRenderer> dollSkin = new List<SkinnedMeshRenderer>(); private GameObject dollRoot; private bool dollIdle; private static ulong gcOrig; private static bool gcSet; private static int jobOrig = -1; private Canvas ownTag; private FirstPersonController ownTagOwner; private static readonly Dictionary<int, bool> sceneHasHandlers = new Dictionary<int, bool>(); private static bool searchDoll = true; private static bool ownSceneChecked; private static float deadAgainAt; private static int deadNetLogged; private static int deadNetRemoved; private static MethodInfo setFirst; private static readonly Predicate<NetworkObject> isGone = (NetworkObject o) => (Object)(object)o == (Object)null; private static FieldInfo pendingField; private static readonly List<int> goneIds = new List<int>(); private static readonly Dictionary<Type, FieldInfo[]> eventsOf = new Dictionary<Type, FieldInfo[]>(); private static readonly Dictionary<Type, FieldInfo[]> listsOf = new Dictionary<Type, FieldInfo[]>(); private static int deadInputLogged; internal void Depth() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_003b: Unknown result type (might be due to invalid IL or missing references) if (TweaksPlugin.Forward) { for (int i = 0; i < camPaths.Count; i++) { Camera key = camPaths[i].Key; if ((Object)(object)key != (Object)null && (key.depthTextureMode & 1) == 0) { key.depthTextureMode = (DepthTextureMode)(key.depthTextureMode | 1); camDepth.Add(key); } } } else if (camDepth.Count > 0) { for (int j = 0; j < camDepth.Count; j++) { if ((Object)(object)camDepth[j] != (Object)null) { Camera obj = camDepth[j]; obj.depthTextureMode = (DepthTextureMode)(obj.depthTextureMode & -2); } } camDepth.Clear(); } if (camDepth.Count > 32) { camDepth.RemoveAll((Camera c) => (Object)(object)c == (Object)null); } } internal static bool WorldCamera(Camera c) { if ((Object)(object)c.targetTexture != (Object)null) { return false; } if ((c.cullingMask & 1) == 0 && (Object)(object)((Component)c).GetComponentInParent<FirstPersonController>() == (Object)null) { return false; } if ((Object)(object)((Component)c).GetComponentInParent<Canvas>() != (Object)null) { return false; } return true; } private void Update() { float unscaledTime = Time.unscaledTime; Fullbright.Tick(); if (deadAgainAt > 0f && unscaledTime >= deadAgainAt) { deadAgainAt = 0f; DeadInput(); DeadNet(); } if (Dirty || unscaledTime >= next || Camera.allCamerasCount != lastCamCount) { lastCamCount = Camera.allCamerasCount; bool dirty = Dirty; Dirty = false; next = unscaledTime + 0.5f; try { Housekeeping(dirty); } catch (Exception ex) { TweaksPlugin.L.LogWarning((object)("Housekeeping: " + ex.Message)); next = unscaledTime + 5f; } } } private void LateUpdate() { Patches.FlushEnabled(); } private void Housekeeping(bool full) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (full) { MouseEvents(); JobWorkers(); GcSteps(); Fullbright.Refresh(); camPaths.RemoveAll((KeyValuePair<Camera, RenderingPath> kv) => !Object.op_Implicit((Object)(object)kv.Key)); } if (TweaksPlugin.Forward) { Camera[] allCameras = Camera.allCameras; foreach (Camera val in allCameras) { if (WorldCamera(val) && (int)val.actualRenderingPath == 3) { camPaths.Add(new KeyValuePair<Camera, RenderingPath>(val, val.renderingPath)); val.renderingPath = (RenderingPath)1; } } } else if (camPaths.Count > 0) { foreach (KeyValuePair<Camera, RenderingPath> camPath in camPaths) { if (Object.op_Implicit((Object)(object)camPath.Key)) { camPath.Key.renderingPath = camPath.Value; } } camPaths.Clear(); } if (camPaths.Count > 32) { camPaths.RemoveAll((KeyValuePair<Camera, RenderingPath> kv) => (Object)(object)kv.Key == (Object)null); } Depth(); Doll(full); OwnTag(); } private void GcSteps() { if (TweaksPlugin.GcSteps && GarbageCollector.isIncremental) { if (!gcSet) { gcOrig = GarbageCollector.incrementalTimeSliceNanoseconds; gcSet = true; DorsthTweaksPlugin.Note("GcSmallSteps: the game allows the garbage collector " + ((double)gcOrig / 1000000.0).ToString("0.##") + " ms per frame; now " + ((double)TweaksPlugin.GcStepNs / 1000000.0).ToString("0.##") + " ms"); } if (GarbageCollector.incrementalTimeSliceNanoseconds != TweaksPlugin.GcStepNs) { GarbageCollector.incrementalTimeSliceNanoseconds = TweaksPlugin.GcStepNs; } } else if (gcSet) { GarbageCollector.incrementalTimeSliceNanoseconds = gcOrig; gcSet = false; } } private void JobWorkers() { if (TweaksPlugin.JobLimit) { int jobWorkerMaximumCount = JobsUtility.JobWorkerMaximumCount; int num = Mathf.Clamp(TweaksPlugin.JobCount, 0, jobWorkerMaximumCount); int jobWorkerCount = JobsUtility.JobWorkerCount; if (jobOrig < 0) { jobOrig = jobWorkerCount; DorsthTweaksPlugin.Note("JobWorkerLimit: the game runs " + jobWorkerCount + " job worker threads (maximum " + jobWorkerMaximumCount + ")"); } if (jobWorkerCount != num) { JobsUtility.JobWorkerCount = num; DorsthTweaksPlugin.Note("JobWorkerLimit: now " + num); } } else if (jobOrig >= 0) { JobsUtility.JobWorkerCount = jobOrig; DorsthTweaksPlugin.Note("JobWorkerLimit: back to " + jobOrig); jobOrig = -1; } } private void OwnTag() { FirstPersonController val = (((Object)(object)Settings.Instance != (Object)null) ? Settings.Instance.localPlayer : null); if (!TweaksPlugin.OwnTagCanvasOff || (Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)ownTagOwner) { if (Object.op_Implicit((Object)(object)ownTag)) { ((Behaviour)ownTag).enabled = true; } ownTag = null; ownTagOwner = null; if (!TweaksPlugin.OwnTagCanvasOff || (Object)(object)val == (Object)null) { return; } } if ((Object)(object)ownTagOwner == (Object)(object)val) { return; } ownTagOwner = val; VisualInfo componentInChildren = ((Component)((Component)val).transform.root).GetComponentInChildren<VisualInfo>(true); if (!((Object)(object)componentInChildren == (Object)null) && ((NetworkBehaviour)componentInChildren).IsOwner) { Canvas componentInParent = ((Component)componentInChildren).GetComponentInParent<Canvas>(); if ((Object)(object)componentInParent != (Object)null && ((Behaviour)componentInParent).enabled && ((Component)componentInParent).transform.IsChildOf(((Component)val).transform.root)) { ((Behaviour)componentInParent).enabled = false; ownTag = componentInParent; } } } private void Doll(bool full) { if ((Object)(object)dollRoot == (Object)null && full && searchDoll) { searchDoll = false; GameObject val = GameObject.Find("HostGameCamera"); if ((Object)(object)val != (Object)null) { Transform val2 = val.transform.Find("Preview"); dollRoot = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null); dollCams = (((Object)(object)dollRoot != (Object)null) ? ((Component)val.transform.root).GetComponentsInChildren<Camera>(true) : null); } } if ((Object)(object)dollRoot == (Object)null) { return; } bool flag = false; if (TweaksPlugin.InMenu || dollCams == null) { flag = true; } else { Camera[] array = dollCams; foreach (Camera val3 in array) { if (Object.op_Implicit((Object)(object)val3) && ((Behaviour)val3).isActiveAndEnabled) { flag = true; break; } } } bool flag2 = TweaksPlugin.PreviewDollIdle && !flag; if (flag2 && !dollIdle) { Animator[] componentsInChildren = dollRoot.GetComponentsInChildren<Animator>(true); foreach (Animator val4 in componentsInChildren) { if (((Behaviour)val4).enabled) { ((Behaviour)val4).enabled = false; dollAnim.Add((Behaviour)(object)val4); } } SkinnedMeshRenderer[] componentsInChildren2 = dollRoot.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val5 in componentsInChildren2) { if (val5.updateWhenOffscreen) { val5.updateWhenOffscreen = false; dollSkin.Add(val5); } } dollIdle = true; } else { if (flag2 || !dollIdle) { return; } foreach (Behaviour item in dollAnim) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = true; } } dollAnim.Clear(); foreach (SkinnedMeshRenderer item2 in dollSkin) { if (Object.op_Implicit((Object)(object)item2)) { item2.updateWhenOffscreen = true; } } dollSkin.Clear(); dollIdle = false; } } private void MouseEvents() { //IL_001d: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) bool flag = TweaksPlugin.MouseEventsOff && !LiveMouseHandlers(); if (flag == mouseRemoved) { return; } PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); PlayerLoopSystem[] array = (PlayerLoopSystem[])currentPlayerLoop.subSystemList.Clone(); if (flag) { for (int i = 0; i < array.Length; i++) { PlayerLoopSystem[] subSystemList = array[i].subSystemList; if (subSystemList != null) { int num = Array.FindIndex(subSystemList, (PlayerLoopSystem s) => s.type != null && s.type.Name == "SendMouseEvents"); if (num >= 0) { mouseSys = subSystemList[num]; mousePhase = array[i].type; mouseIndex = num; List<PlayerLoopSystem> list = subSystemList.ToList(); list.RemoveAt(num); array[i].subSystemList = list.ToArray(); mouseRemoved = true; break; } } } } else { for (int num2 = 0; num2 < array.Length; num2++) { if (!(array[num2].type != mousePhase) && array[num2].subSystemList != null) { List<PlayerLoopSystem> list2 = array[num2].subSystemList.ToList(); if (list2.Any((PlayerLoopSystem s) => s.type == mouseSys.type)) { mouseRemoved = false; return; } list2.Insert(Math.Min(mouseIndex, list2.Count), mouseSys); array[num2].subSystemList = list2.ToArray(); mouseRemoved = false; break; } } } currentPlayerLoop.subSystemList = array; PlayerLoop.SetPlayerLoop(currentPlayerLoop); } private static Type[] MouseTypes() { if (mouseHandlerTypes == null) { List<Type> list = new List<Type>(); string[] array = new string[7] { "OnMouseDown", "OnMouseUp", "OnMouseEnter", "OnMouseExit", "OnMouseOver", "OnMouseDrag", "OnMouseUpAsButton" }; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { string name = assembly.GetName().Name; if (name.StartsWith("System") || name == "mscorlib" || name == "netstandard" || name.StartsWith("UnityEngine") || name.StartsWith("Mono") || name.StartsWith("BepInEx") || name == "0Harmony" || (name.StartsWith("Unity.") && !name.StartsWith("Unity.VisualScripting"))) { continue; } Type[] array2; try { array2 = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { array2 = ex.Types.Where((Type t) => t != null).ToArray(); } catch { continue; } Type[] array3 = array2; foreach (Type type in array3) { if (type.IsAbstract || !typeof(MonoBehaviour).IsAssignableFrom(type)) { continue; } string[] array4 = array; foreach (string name2 in array4) { if (type.GetMethod(name2, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null) != null) { list.Add(type); break; } } } } mouseHandlerTypes = list.ToArray(); } return mouseHandlerTypes; } private static bool HasHandlers(Scene sc) { Type[] array = MouseTypes(); if (array.Length == 0 || !((Scene)(ref sc)).IsValid() || !((Scene)(ref sc)).isLoaded) { return false; } GameObject[] rootGameObjects = ((Scene)(ref sc)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { Type[] array2 = array; foreach (Type type in array2) { try { if ((Object)(object)val.GetComponentInChildren(type, true) != (Object)null) { return true; } } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "HasHandlers", 324); } } } return false; } public static void SceneLoaded(Scene sc) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) searchDoll = true; try { sceneHasHandlers[((Scene)(ref sc)).handle] = HasHandlers(sc); } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "SceneLoaded", 327); } DeadInput(); DeadNet(); deadAgainAt = Time.unscaledTime + 4f; } private static void PruneOwned(NetworkConnection c) { if (c == (NetworkConnection)null || c.Objects == null || c.Objects.Count == 0) { return; } int num = c.Objects.RemoveWhere(isGone); if (num == 0) { return; } deadNetRemoved += num; NetworkObject firstObject = c.FirstObject; if (firstObject != null && (Object)(object)firstObject == (Object)null) { if (setFirst == null) { setFirst = AccessTools.Method(typeof(NetworkConnection), "SetFirstObject", Type.EmptyTypes, (Type[])null); } if (setFirst != null && setFirst.GetParameters().Length == 0) { setFirst.Invoke(c, null); } } } private static void PruneLists(object objects) { if (objects == null) { return; } Type type = objects.GetType(); FieldInfo[] fields; if (!listsOf.TryGetValue(type, out var value)) { List<FieldInfo> list = new List<FieldInfo>(); Type type2 = type; while (type2 != null && type2 != typeof(object)) { fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(List<NetworkObject>) || fieldInfo.FieldType == typeof(HashSet<NetworkObject>) || fieldInfo.FieldType == typeof(Dictionary<int, NetworkObject>)) { list.Add(fieldInfo); } } type2 = type2.BaseType; } value = (listsOf[type] = list.ToArray()); } fields = value; for (int i = 0; i < fields.Length; i++) { object value2 = fields[i].GetValue(objects); if (value2 == null) { continue; } if (value2 is List<NetworkObject> list2) { if (list2.Count > 0) { deadNetRemoved += list2.RemoveAll(isGone); } } else if (value2 is HashSet<NetworkObject> hashSet) { if (hashSet.Count > 0) { deadNetRemoved += hashSet.RemoveWhere(isGone); } } else { if (!(value2 is Dictionary<int, NetworkObject> { Count: not 0 } dictionary)) { continue; } goneIds.Clear(); foreach (KeyValuePair<int, NetworkObject> item in dictionary) { if ((Object)(object)item.Value == (Object)null) { goneIds.Add(item.Key); } } foreach (int goneId in goneIds) { dictionary.Remove(goneId); } deadNetRemoved += goneIds.Count; goneIds.Clear(); } } } private static bool OwnerGone(Delegate d) { object target = d.Target; if (target == null) { return false; } Object val = (Object)((target is Object) ? target : null); if (val != null) { return val == (Object)null; } Type type = target.GetType(); if (type.Name.IndexOf("DisplayClass", StringComparison.Ordinal) < 0) { return false; } FieldInfo field = type.GetField("<>4__this", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return false; } object? value = field.GetValue(target); Object val2 = (Object)((value is Object) ? value : null); if (val2 != null) { return val2 == (Object)null; } return false; } private static void PruneEvents(object manager) { if (manager == null) { return; } Type type = manager.GetType(); FieldInfo[] fields; if (!eventsOf.TryGetValue(type, out var value)) { List<FieldInfo> list = new List<FieldInfo>(); Type type2 = type; while (type2 != null && type2 != typeof(MonoBehaviour) && type2 != typeof(object)) { fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (typeof(Delegate).IsAssignableFrom(fieldInfo.FieldType)) { list.Add(fieldInfo); } } type2 = type2.BaseType; } value = (eventsOf[type] = list.ToArray()); } fields = value; foreach (FieldInfo fieldInfo2 in fields) { if (!(fieldInfo2.GetValue(manager) is Delegate obj)) { continue; } Delegate obj2 = obj; int num = 0; Delegate[] invocationList = obj.GetInvocationList(); foreach (Delegate obj3 in invocationList) { if (OwnerGone(obj3)) { obj2 = Delegate.Remove(obj2, obj3); num++; } } if (num > 0) { fieldInfo2.SetValue(manager, obj2); deadNetRemoved += num; } } } private static void DeadNet() { if (!TweaksPlugin.DeadNetOff) { return; } try { NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager == (Object)null) { return; } deadNetRemoved = 0; if ((Object)(object)networkManager.ClientManager != (Object)null) { PruneOwned(networkManager.ClientManager.Connection); foreach (KeyValuePair<int, NetworkConnection> client in networkManager.ClientManager.Clients) { PruneOwned(client.Value); } } if ((Object)(object)networkManager.ServerManager != (Object)null) { foreach (KeyValuePair<int, NetworkConnection> client2 in networkManager.ServerManager.Clients) { PruneOwned(client2.Value); } } if ((Object)(object)networkManager.ServerManager != (Object)null && networkManager.ServerManager.Objects != null) { if (pendingField == null) { pendingField = AccessTools.Field(((object)networkManager.ServerManager.Objects).GetType(), "_pendingDestroy"); } Dictionary<int, NetworkObject> dictionary = ((pendingField != null) ? (pendingField.GetValue(networkManager.ServerManager.Objects) as Dictionary<int, NetworkObject>) : null); if (dictionary != null && dictionary.Count > 0) { goneIds.Clear(); foreach (KeyValuePair<int, NetworkObject> item in dictionary) { if ((Object)(object)item.Value == (Object)null) { goneIds.Add(item.Key); } } foreach (int goneId in goneIds) { dictionary.Remove(goneId); } deadNetRemoved += goneIds.Count; goneIds.Clear(); } } if ((Object)(object)networkManager.ClientManager != (Object)null) { PruneLists(networkManager.ClientManager.Objects); } if ((Object)(object)networkManager.ServerManager != (Object)null) { PruneLists(networkManager.ServerManager.Objects); } PruneEvents(networkManager.SceneManager); PruneEvents(networkManager.TimeManager); PruneEvents(networkManager.ClientManager); PruneEvents(networkManager.ServerManager); GameManager instance = GameManager.Instance; if ((Object)(object)instance != (Object)null) { foreach (NetworkConnection item2 in instance.ConnectionsToStartGame) { PruneOwned(item2); } foreach (NetworkConnection item3 in instance.NetworkConnectionsReady) { PruneOwned(item3); } } if (deadNetRemoved > 0 && deadNetLogged < 3) { deadNetLogged++; DorsthTweaksPlugin.Note("DeadNetworkObjects: " + deadNetRemoved + " destroyed objects and dead subscribers taken off the network library's lists (owned, spawned, pending destroy, events)" + ((deadNetLogged == 3) ? " (not logged again)" : "")); } } catch (Exception ex) { if (deadNetLogged < 3) { deadNetLogged = 3; TweaksPlugin.L.LogWarning((object)("DeadNetworkObjects: could not read the lists (" + ex.Message + "); nothing changed")); } } } private static void DeadInput() { if (!TweaksPlugin.DeadInputOff) { return; } try { InputCallbacks.Scan(remove: true, out var total, out var gone); if (gone > 0 && deadInputLogged < 3) { deadInputLogged++; DorsthTweaksPlugin.Note("DeadInputCallbacks: " + gone + " of " + total + " input callbacks belonged to destroyed objects and were taken off" + ((deadInputLogged == 3) ? " (not logged again)" : "")); } } catch (Exception ex) { if (deadInputLogged < 3) { deadInputLogged = 3; TweaksPlugin.L.LogWarning((object)("DeadInputCallbacks: could not read the input callbacks (" + ex.Message + "); nothing changed")); } } } public static void SceneUnloaded(Scene sc) { sceneHasHandlers.Remove(((Scene)(ref sc)).handle); } private bool LiveMouseHandlers() { //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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!ownSceneChecked) { ownSceneChecked = true; try { Dictionary<int, bool> dictionary = sceneHasHandlers; Scene scene = ((Component)this).gameObject.scene; dictionary[((Scene)(ref scene)).handle] = HasHandlers(((Component)this).gameObject.scene); for (int i = 0; i < SceneManager.sceneCount; i++) { Scene sceneAt = SceneManager.GetSceneAt(i); if (!sceneHasHandlers.ContainsKey(((Scene)(ref sceneAt)).handle)) { sceneHasHandlers[((Scene)(ref sceneAt)).handle] = HasHandlers(sceneAt); } } } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "LiveMouseHandlers", 445); } } foreach (KeyValuePair<int, bool> sceneHasHandler in sceneHasHandlers) { if (sceneHasHandler.Value) { return true; } } return false; } } internal static class Patches { private sealed class RefCmp : IEqualityComparer<string> { public bool Equals(string a, string b) { return (object)a == b; } public int GetHashCode(string s) { return RuntimeHelpers.GetHashCode(s); } } private struct K3 { public string A; public string B; public string C; } private sealed class K3Cmp : IEqualityComparer<K3> { public bool Equals(K3 x, K3 y) { if ((object)x.A == y.A && (object)x.B == y.B) { return (object)x.C == y.C; } return false; } public int GetHashCode(K3 k) { int num = RuntimeHelpers.GetHashCode(k.A) * 31 + RuntimeHelpers.GetHashCode(k.B); if (k.C != null) { return num * 31 + RuntimeHelpers.GetHashCode(k.C); } return num; } } private struct FovT { public Tween T; public float End; } private static Behaviour pendB; private static bool pendV; private static bool pend; private static float lobbyNext; private static float steamCheckNext; private static FieldInfo gsLast; private static Action gsScan; private static bool gsOwn; internal static int decalHits; internal static int fadeHits; internal static int lineHits; private static Material lineMat; internal static int arcHits; private static readonly List<(Vector3, Vector3, float)> arcPathBuf = new List<(Vector3, Vector3, float)>(512); internal static int nameHits; internal static int sceneHits; internal static int textHits; internal static readonly Dictionary<int, string> itemNames = new Dictionary<int, string>(); internal static int snHandle = int.MinValue; private static string snName; private static readonly string[] wholeI = new string[4097]; private static readonly string[] wholeF = new string[4097]; private static readonly HashSet<string> kept = new HashSet<string>(new RefCmp()); private static readonly Dictionary<K3, string> joined = new Dictionary<K3, string>(new K3Cmp()); private static readonly long[] bigKey = new long[64]; private static readonly string[] bigText = new string[64]; private static FieldRef<LobbyController, Transform> lobbyTab; private static FieldRef<LobbyController, Dictionary<int, PlayerListItems>> rowsById; private static readonly List<int> staleRows = new List<int>(); private static float mycNext; private const BindingFlags AnyMember = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static object svPlugin; private static FieldInfo svFlag; private static FieldInfo svUnlock; private static readonly List<Transform> layerBuf = new List<Transform>(64); private static object svGui; private static FieldRef<object, bool> svVisible; private static bool svLayoutOff; private static readonly Dictionary<int, Weapon> arcWeapon = new Dictionary<int, Weapon>(); private static readonly Dictionary<int, float> arcNext = new Dictionary<int, float>(); private static float arcStep = 0.004166667f; private static readonly Dictionary<int, List<FovT>> fovTweens = new Dictionary<int, List<FovT>>(); private const int FovMark = 1179604529; internal static int fovStopped; private static bool gsDoneThisTake; private static Vector3[] tsPts = (Vector3[])(object)new Vector3[256]; private static FieldRef<TrickShotLine, TrickShot> tsShot; private static FieldRef<TrickShotLine, LineRenderer> tsLine; private static readonly GameObject[] noObjects = (GameObject[])(object)new GameObject[0]; internal static int kcHits; private static string kc3a; private static string kc3b; private static string kc3c; private static string kc3r; private static string kc2a; private static string kc2b; private static string kc2r; private static string kcFf; private static string kcFr; private static float kcFv = float.NaN; private static Action voiceStart; private static Action voiceStop; private static readonly Queue<Action> voiceQ = new Queue<Action>(); private static Thread voiceThread; private static readonly string[] PreAssemblies = new string[12] { "Assembly-CSharp", "Assembly-CSharp-firstpass", "FishNet.Runtime", "Heathen.Steamworks", "Heathen.Core", "DOTween", "ch.sycoforge.Decal", "LambdaTheDev.NetworkAudioSync", "LambdaTheDev.NetworkAudioSync.FishNet", "Heathen.PhysKit", "GameKit.Dependencies", "GameKit.Utilities" }; private static bool preStarted; private static OpCode[] op1; private static OpCode[] op2; private static bool[] has1; private static bool[] has2; private static readonly string[] MainThreadInit = new string[2] { "ch.sycoforge.Decal.MeshUtil", "ch.sycoforge.Decal.EasyDecalManager" }; private static readonly HashSet<Type> preInited = new HashSet<Type>(); private static volatile bool preInitReady; private static readonly HashSet<string> UnityNumbers = new HashSet<string> { "UnityEngine.Vector2", "UnityEngine.Vector3", "UnityEngine.Vector4", "UnityEngine.Color", "UnityEngine.Color32", "UnityEngine.Mathf", "UnityEngine.Vector2Int", "UnityEngine.Vector3Int" }; public static void Apply(Harmony h) { //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) Type self = typeof(Patches); Func<string, HarmonyMethod> M = (string n) => new HarmonyMethod(self.GetMethod(n, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)); Try("CrosshairFix (Crosshair)", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(Crosshair), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("EnabledTr"), (HarmonyMethod)null, (HarmonyMethod)null); }); Try("CrosshairFix (PauseManager)", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(PauseManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("EnabledTr"), (HarmonyMethod)null, (HarmonyMethod)null); }); Try("LobbyListThrottle", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(LobbyController), "Update", (Type[])null, (Type[])null), M("LobbyPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("SteamRunningCheckThrottle", delegate { Type type = Type.GetType("HeathenEngineering.SteamworksIntegration.API.Api, Heathen.Steamworks", throwOnError: true); h.Patch((MethodBase)AccessTools.Method(type, "LateUpdate", (Type[])null, (Type[])null), M("SteamCheckPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("TrickShotLineNoGarbage", delegate { tsShot = AccessTools.FieldRefAccess<TrickShotLine, TrickShot>("trickShot"); tsLine = AccessTools.FieldRefAccess<TrickShotLine, LineRenderer>("lineRenderer"); h.Patch((MethodBase)AccessTools.Method(typeof(TrickShotLine), "LateUpdate", (Type[])null, (Type[])null), M("TrickLinePre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("GunSoundsNoScanInPlay", delegate { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { type = assemblies[i].GetType("GunSounds.Registry", throwOnError: false); if (type != null) { break; } } if (!(type == null)) { MethodInfo methodInfo = AccessTools.Method(type, "Scan", Type.EmptyTypes, (Type[])null); gsLast = AccessTools.Field(type, "lastScan"); if (methodInfo == null || gsLast == null || gsLast.FieldType != typeof(float)) { throw new Exception("GunSounds is not the version this was written for (2.2.0)"); } gsScan = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo); h.Patch((MethodBase)methodInfo, M("GunScanPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); PauseManager.OnRoundStarted += new StartRoundAction(GunScanAtCountdown); DorsthTweaksPlugin.Note("GunSoundsNoScanInPlay: GunSounds found, its weapon search is kept out of play time"); } }); Try("DecalSmallBuffers", delegate { Type type = AccessTools.TypeByName("ch.sycoforge.Decal.Projectors.Geometry.DynamicMesh"); if (type == null) { throw new Exception("the decal library was not found"); } decalHits = 0; foreach (ConstructorInfo declaredConstructor in AccessTools.GetDeclaredConstructors(type, (bool?)null)) { if (!declaredConstructor.IsStatic) { h.Patch((MethodBase)declaredConstructor, (HarmonyMethod)null, (HarmonyMethod)null, M("DecalCapTr"), (HarmonyMethod)null, (HarmonyMethod)null); } } if (decalHits == 0) { throw new Exception("no list of 4048 found in the decal library (changed?)"); } DorsthTweaksPlugin.Note("DecalSmallBuffers: " + decalHits + " lists in the decal library start small"); }); Try("ItemNameNoGarbage", delegate { nameHits = 0; h.Patch((MethodBase)AccessTools.Method(typeof(ItemBehaviour), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("ItemNameTr"), (HarmonyMethod)null, (HarmonyMethod)null); if (nameHits != 1) { throw new Exception(nameHits + " name reads found in ItemBehaviour.Update, expected 1"); } }); sceneHits = 0; KeyValuePair<Type, string>[] array = new KeyValuePair<Type, string>[6] { new KeyValuePair<Type, string>(typeof(PauseManager), "Update"), new KeyValuePair<Type, string>(typeof(SetMenuMusicVolume), "UpdateMusic"), new KeyValuePair<Type, string>(typeof(Settings), "Update"), new KeyValuePair<Type, string>(typeof(Crosshair), "Update"), new KeyValuePair<Type, string>(typeof(SceneLoader), "Update"), new KeyValuePair<Type, string>(typeof(TabScreen), "Update") }; foreach (KeyValuePair<Type, string> keyValuePair in array) { KeyValuePair<Type, string> x = keyValuePair; Try("SceneNameNoGarbage (" + x.Key.Name + ")", delegate { h.Patch((MethodBase)AccessTools.Method(x.Key, x.Value, (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("SceneNameTr"), (HarmonyMethod)null, (HarmonyMethod)null); }); } DorsthTweaksPlugin.Note("SceneNameNoGarbage: " + sceneHits + " reads of the map name are remembered (14 expected)"); SceneManager.sceneLoaded += delegate { snHandle = int.MinValue; }; SceneManager.sceneUnloaded += delegate { snHandle = int.MinValue; itemNames.Clear(); }; SceneManager.activeSceneChanged += delegate { snHandle = int.MinValue; }; textHits = 0; array = new KeyValuePair<Type, string>[4] { new KeyValuePair<Type, string>(typeof(PlayerHealth), "Update"), new KeyValuePair<Type, string>(typeof(ProgressManager), "HandleUIUpdate"), new KeyValuePair<Type, string>(typeof(Weapon), "WeaponUpdate"), new KeyValuePair<Type, string>(typeof(PauseManager), "ChangeAmmoText") }; foreach (KeyValuePair<Type, string> keyValuePair2 in array) { KeyValuePair<Type, string> x2 = keyValuePair2; Try("HudNumbersNoGarbage (" + x2.Key.Name + ")", delegate { h.Patch((MethodBase)AccessTools.Method(x2.Key, x2.Value, (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("HudTextTr"), (HarmonyMethod)null, (HarmonyMethod)null); }); } DorsthTweaksPlugin.Note("HudNumbersNoGarbage: " + textHits + " places where a number is turned into text use a remembered text (14 expected)"); Try("LobbyRowsNotInPlay", delegate { lobbyTab = AccessTools.FieldRefAccess<LobbyController, Transform>("tabScreen"); h.Patch((MethodBase)AccessTools.Method(typeof(LobbyController), "CreateNewObjects", (Type[])null, (Type[])null), M("LobbyRowPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("LobbyLeaveFix", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(ClientInstance), "OnDisable", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, M("LeaveFin"), (HarmonyMethod)null); }); Try("LobbyStaleIds", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(ClientInstance), "RpcLogic___AddNewPlayer_2166193949", (Type[])null, (Type[])null), M("AddNewPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("LobbyStaleRows", delegate { rowsById = AccessTools.FieldRefAccess<LobbyController, Dictionary<int, PlayerListItems>>("PlayerIdToListItem"); h.Patch((MethodBase)AccessTools.Method(typeof(LobbyController), "UpdatePlayerList", (Type[])null, (Type[])null), M("StaleRowsPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("FovTweensNoPileUp", delegate { MethodInfo methodInfo = AccessTools.Method(typeof(ShortcutExtensions), "DOFieldOfView", new Type[3] { typeof(Camera), typeof(float), typeof(float) }, (Type[])null); if (methodInfo == null) { throw new Exception("DOFieldOfView not found"); } h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, M("FovTweenPost"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Resolution currentResolution = Screen.currentResolution; int num2 = ((Resolution)(ref currentResolution)).refreshRate; if (num2 < 120) { num2 = 120; } arcStep = 1f / (float)num2; DorsthTweaksPlugin.Note("OtherArcsAtScreenRate: other players' launcher arcs are worked out " + num2 + " times a second"); SceneManager.sceneUnloaded += delegate { arcWeapon.Clear(); arcNext.Clear(); fovTweens.Clear(); }; Try("KillCamLean", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(KillCam), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("KillCamTr"), (HarmonyMethod)null, (HarmonyMethod)null); }); Try("KillCamNoGarbage", delegate { kcHits = 0; h.Patch((MethodBase)AccessTools.Method(typeof(KillCam), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("KillCamTextTr"), (HarmonyMethod)null, (HarmonyMethod)null); if (kcHits != 10) { TweaksPlugin.L.LogWarning((object)("KillCamNoGarbage: " + kcHits + " of 10 places found in KillCam.Update (game update?); the ones found are handled")); } else { DorsthTweaksPlugin.Note("KillCamNoGarbage: 10 places in the kill camera no longer make garbage every frame"); } }); Try("FadedLinesEndEarly", delegate { fadeHits = 0; Type[] array2 = new Type[2] { typeof(ShrapnelBallistic), typeof(PhysicsGrenade) }; foreach (Type type in array2) { MethodInfo methodInfo = AccessTools.Method(type, "RenderObject", new Type[2] { typeof(Vector3), typeof(float) }, (Type[])null); if (methodInfo == null) { throw new Exception(type.Name + ".RenderObject not found"); } h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, M("LineLifeTr"), (HarmonyMethod)null, (HarmonyMethod)null); } if (fadeHits != 2) { TweaksPlugin.L.LogWarning((object)("FadedLinesEndEarly: " + fadeHits + " of 2 places found (game update?); the others keep the game's 2.5 seconds")); } else { DorsthTweaksPlugin.Note("FadedLinesEndEarly: the fragment lines of 2 explosion scripts are removed when they have faded out"); } }); Try("ExplosionLinesOneMaterial", delegate { lineHits = 0; Type[] array2 = new Type[3] { typeof(ShrapnelBallistic), typeof(PhysicsGrenade), typeof(Claymore) }; foreach (Type type in array2) { MethodInfo methodInfo = AccessTools.Method(type, "RenderObject", new Type[2] { typeof(Vector3), typeof(float) }, (Type[])null); if (methodInfo == null) { throw new Exception(type.Name + ".RenderObject not found"); } h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, M("LineMatTr"), (HarmonyMethod)null, (HarmonyMethod)null); } if (lineHits != 3) { throw new Exception(lineHits + " of 3 material creations found"); } LineMat(); DorsthTweaksPlugin.Note("ExplosionLinesOneMaterial: the fragment lines of 3 explosion scripts share one material"); }); Try("ArcPathNoGarbage", delegate { Type type = AccessTools.TypeByName("HeathenEngineering.PhysKit.API.Ballistics"); if (type == null) { throw new Exception("Ballistics not found"); } arcHits = 0; int num3 = 0; foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (!(declaredMethod.Name != "SphereCast")) { bool flag = false; ParameterInfo[] parameters = declaredMethod.GetParameters(); for (int i = 0; i < parameters.Length; i++) { if (parameters[i].ParameterType == typeof(List<(Vector3, Vector3, float)>).MakeByRefType()) { flag = true; } } if (flag) { h.Patch((MethodBase)declaredMethod, (HarmonyMethod)null, (HarmonyMethod)null, M("ArcPathTr"), (HarmonyMethod)null, (HarmonyMethod)null); num3++; } } } if (arcHits != num3 || num3 == 0) { throw new Exception(arcHits + " list creations found in " + num3 + " path methods (library changed?)"); } DorsthTweaksPlugin.Note("ArcPathNoGarbage: " + arcHits + " path builders of the arc library use one reused point list"); }); Try("GunSoundsNoScanInPlay (countdown)", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(PlayerManager), "WaitForRoundStartCoroutineStart", (Type[])null, (Type[])null), (HarmonyMethod)null, M("CountdownPost"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("WeaponLayerNoGarbage", delegate { MethodInfo methodInfo = AccessTools.Method(typeof(Weapon), "SetLayerAllChildren", new Type[2] { typeof(Transform), typeof(int) }, (Type[])null); if (methodInfo == null) { throw new Exception("Weapon.SetLayerAllChildren not found"); } h.Patch((MethodBase)methodInfo, M("WeaponLayerPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); Try("OnGuiNoLayout", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(FirstPersonController), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, M("FpcGuiPost"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); SceneManager.sceneLoaded += delegate { GuiLayoutRefresh(); }; DorsthTweaksPlugin.Note("OnGuiNoLayout: no GUI layout pass for the player script, the ping script and the FPS counter"); }); Try("WeaponNoInputCopy", delegate { h.Patch((MethodBase)AccessTools.Method(typeof(Weapon), "Awake___UserLogic", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, M("WeaponControlsTr"), (HarmonyMethod)null, (HarmonyMethod)null); }); Try("VoiceKeyOffThread", delegate { Type? type = Type.GetType("Steamworks.SteamUser, com.rlabrecque.steamworks.net", throwOnError: true); MethodInfo methodInfo = AccessTools.Method(type, "StartVoiceRecording", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "StopVoiceRecording", (Type[])null, (Type[])null); voiceStart = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo); voiceStop = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo2); h.Patch((MethodBase)methodInfo, M("VoiceStartPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)methodInfo2, M("VoiceStopPre"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); }); } public static int DecalCap() { if (!TweaksPlugin.DecalSmall) { return 4048; } return 256; } private static float LineLife(float game, LineRenderer line) { if (!TweaksPlugin.FadedLines || (Object)(object)line == (Object)null) { return game; } LineFade component = ((Component)line).GetComponent<LineFade>(); if ((Object)(object)component == (Object)null) { return game; } float speed = component.speed; if (!(speed > 0.5f)) { return game; } float num = 6.5f / speed; if (!(num < game)) { return game; } return num; } private static IEnumerable<CodeInstruction> LineLifeTr(IEnumerable<CodeInstruction> ins) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(ins); MethodInfo methodInfo = AccessTools.Method(typeof(Patches), "LineLife", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Object), "Destroy", new Type[2] { typeof(Object), typeof(float) }, (Type[])null); CodeInstruction val = null; for (int i = 0; i + 1 < list.Count; i++) { MethodInfo methodInfo3 = list[i].operand as MethodInfo; if (!(methodInfo3 == null) && !(methodInfo3.Name != "AddComponent") && methodInfo3.IsGenericMethod && !(methodInfo3.GetGenericArguments()[0] != typeof(LineRenderer))) { CodeInstruction val2 = list[i + 1]; if (val2.opcode == OpCodes.Stloc_0) { val = new CodeInstruction(OpCodes.Ldloc_0, (object)null); } else if (val2.opcode == OpCodes.Stloc_1) { val = new CodeInstruction(OpCodes.Ldloc_1, (object)null); } else if (val2.opcode == OpCodes.Stloc_2) { val = new CodeInstruction(OpCodes.Ldloc_2, (object)null); } else if (val2.opcode == OpCodes.Stloc_3) { val = new CodeInstruction(OpCodes.Ldloc_3, (object)null); } else if (val2.opcode == OpCodes.Stloc_S || val2.opcode == OpCodes.Stloc) { val = new CodeInstruction((val2.opcode == OpCodes.Stloc_S) ? OpCodes.Ldloc_S : OpCodes.Ldloc, val2.operand); } break; } } if (val == null) { return list; } for (int j = 0; j + 1 < list.Count; j++) { if (list[j].opcode == OpCodes.Ldc_R4 && CodeInstructionExtensions.Calls(list[j + 1], methodInfo2) && list[j + 1].labels.Count == 0) { list.Insert(j + 1, val); list.Insert(j + 2, new CodeInstruction(OpCodes.Call, (object)methodInfo)); fadeHits++; break; } } return list; } private static Material LineMat() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (!TweaksPlugin.LineMatOne) { return new Material(Shader.Find("Sprites/Default")); } if ((Object)(object)lineMat == (Object)null) { lineMat = new Material(Shader.Find("Sprites/Default")); ((Object)lineMat).name = "UltimateTweaks shared line material"; ((Object)lineMat).hideFlags = (HideFlags)61; } return lineMat; } private static IEnumerable<CodeInstruction> LineMatTr(IEnumerable<CodeInstruction> ins) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(ins); MethodInfo methodInfo = AccessTools.Method(typeof(Patches), "LineMat", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Shader), "Find", new Type[1] { typeof(string) }, (Type[])null); ConstructorInfo constructorInfo = AccessTools.Constructor(typeof(Material), new Type[1] { typeof(Shader) }, false); for (int i = 0; i + 2 < list.Count; i++) { if (list[i].opcode == OpCodes.Ldstr && list[i].operand as string == "Sprites/Default" && CodeInstructionExtensions.Calls(list[i + 1], methodInfo2) && list[i + 2].opcode == OpCodes.Newobj && list[i + 2].operand as ConstructorInfo == constructorInfo && list[i + 1].labels.Count == 0 && list[i + 2].labels.Count == 0) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)methodInfo); val.labels.AddRange(list[i].labels); val.blocks.AddRange(list[i].blocks); list[i] = val; list.RemoveRange(i + 1, 2); lineHits++; } } return list; } private static List<(Vector3, Vector3, float)> ArcPathList() { if (!TweaksPlugin.ArcPath) { return new List<(Vector3, Vector3, float)>(); } arcPathBuf.Clear(); return arcPathBuf; } private static IEnumerable<CodeInstruction> ArcPathTr(IEnumerable<CodeInstruction> ins) { MethodInfo get = AccessTools.Method(typeof(Patches), "ArcPathList", (Type[])null, (Type[])null); ConstructorInfo ctor = typeof(List<(Vector3, Vector3, float)>).GetConstructor(Type.EmptyTypes); foreach (CodeInstruction @in in ins) { if (@in.opcode == OpCodes.Newobj && @in.operand is ConstructorInfo && (ConstructorInfo)@in.operand == ctor) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)get); val.labels.AddRange(@in.labels); val.blocks.AddRange(@in.blocks); arcHits++; yield return val; } else { yield return @in; } } } private static IEnumerable<CodeInstruction> DecalCapTr(IEnumerable<CodeInstruction> ins) { MethodInfo cap = AccessTools.Method(typeof(Patches), "DecalCap", (Type[])null, (Type[])null); foreach (CodeInstruction @in in ins) { if (@in.opcode == OpCodes.Ldc_I4 && @in.operand is int && (int)@in.operand == 4048) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)cap); val.labels.AddRange(@in.labels); val.blocks.AddRange(@in.blocks); decalHits++; yield return val; } else { yield return @in; } } } public static string ItemNameOf(Object o) { if (!TweaksPlugin.ItemNameOn) { return o.name; } return CachedName(o); } private static string CachedName(Object o) { int instanceID = o.GetInstanceID(); if (itemNames.TryGetValue(instanceID, out var value)) { return value; } value = o.name; if (itemNames.Count > 4096) { itemNames.Clear(); } itemNames[instanceID] = value; return value; } private static IEnumerable<CodeInstruction> ItemNameTr(IEnumerable<CodeInstruction> ins) { MethodInfo get = AccessTools.PropertyGetter(typeof(Object), "name"); MethodInfo rep = AccessTools.Method(typeof(Patches), "ItemNameOf", (Type[])null, (Type[])null); foreach (CodeInstruction @in in ins) { if (CodeInstructionExtensions.Calls(@in, get)) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)rep); val.labels.AddRange(@in.labels); val.blocks.AddRange(@in.blocks); nameHits++; yield return val; } else { yield return @in; } } } public static string SceneNameOf(ref Scene s) { if (!TweaksPlugin.SceneNameOn) { return ((Scene)(ref s)).name; } int handle = ((Scene)(ref s)).handle; if (handle == snHandle && snName != null) { return snName; } snName = ((Scene)(ref s)).name; snHandle = handle; return snName; } private static IEnumerable<CodeInstruction> SceneNameTr(IEnumerable<CodeInstruction> ins) { MethodInfo get = AccessTools.PropertyGetter(typeof(Scene), "name"); MethodInfo rep = AccessTools.Method(typeof(Patches), "SceneNameOf", (Type[])null, (Type[])null); foreach (CodeInstruction @in in ins) { if (CodeInstructionExtensions.Calls(@in, get)) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)rep); val.labels.AddRange(@in.labels); val.blocks.AddRange(@in.blocks); sceneHits++; yield return val; } else { yield return @in; } } } public static string FloatText(ref float v) { float num = v; if (TweaksPlugin.HudText && num >= 0f && num <= 4096f) { int num2 = (int)num; if ((float)num2 == num && (num2 != 0 || 1f / num > 0f)) { string text = wholeF[num2]; if (text == null) { text = num.ToString(); wholeF[num2] = text; kept.Add(text); } return text; } } return v.ToString(); } public static string IntText(ref int v) { int num = v; if (TweaksPlugin.HudText && (uint)num <= 4096u) { string text = wholeI[num]; if (text == null) { text = num.ToString(); wholeI[num] = text; kept.Add(text); } return text; } if (TweaksPlugin.HudText) { return BigText(num); } return v.ToString(); } public static string LongText(ref long v) { long num = v; if (TweaksPlugin.HudText && num >= 0 && num <= 4096) { string text = wholeI[(int)num]; if (text == null) { text = num.ToString(); wholeI[(int)num] = text; kept.Add(text); } return text; } if (TweaksPlugin.HudText) { return BigText(num); } return v.ToString(); } private static string BigText(long v) { int num = (int)((ulong)v % 64uL); string text = bigText[num]; if (text != null && bigKey[num] == v) { return text; } text = v.ToString(); if (kept.Count > 20000) { kept.Clear(); joined.Clear(); string[] array = wholeI; foreach (string text2 in array) { if (text2 != null) { kept.Add(text2); } } array = wholeF; foreach (string text3 in array) { if (text3 != null) { kept.Add(text3); } } Array.Clear(bigText, 0, 64); } bigKey[num] = v; bigText[num] = text; kept.Add(text); return text; } private static bool Kept(string t) { if (!kept.Contains(t)) { return (object)string.IsInterned(t) == t; } return true; } private static void Keep(K3 k, string r) { if (joined.Count > 8192) { joined.Clear(); kept.Clear(); string[] array = wholeI; foreach (string text in array) { if (text != null) { kept.Add(text); } } array = wholeF; foreach (string text2 in array) { if (text2 != null) { kept.Add(text2); } } } joined[k] = r; kept.Add(r); } public static string Join2(string a, string b) { if (!TweaksPlugin.HudText || a == null || b == null || a.Length == 0 || b.Length == 0) { return a + b; } K3 k = new K3 { A = a, B = b }; if (joined.TryGetValue(k, out var value)) { return value; } value = a + b; if (Kept(a) && Kept(b)) { Keep(k, value); } return value; } public static string Join3(string a, string b, string c) { if (!TweaksPlugin.HudText || a == null || b == null || c == null || a.Length == 0 || b.Length == 0 || c.Length == 0) { return a + b + c; } K3 k = new K3 { A = a, B = b, C = c }; if (joined.TryGetValue(k, out var value)) { return value; } value = a + b + c; if (Kept(a) && Kept(b) && Kept(c)) { Keep(k, value); } return value; } private static IEnumerable<CodeInstruction> HudTextTr(IEnumerable<CodeInstruction> ins) { Type typeFromHandle = typeof(Patches); Dictionary<MethodInfo, MethodInfo> map = new Dictionary<MethodInfo, MethodInfo> { { AccessTools.Method(typeof(float), "ToString", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeFromHandle, "FloatText", (Type[])null, (Type[])null) }, { AccessTools.Method(typeof(int), "ToString", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeFromHandle, "IntText", (Type[])null, (Type[])null) }, { AccessTools.Method(typeof(long), "ToString", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeFromHandle, "LongText", (Type[])null, (Type[])null) }, { AccessTools.Method(typeof(string), "Concat", new Type[2] { typeof(string), typeof(string) }, (Type[])null), AccessTools.Method(typeFromHandle, "Join2", (Type[])null, (Type[])null) }, { AccessTools.Method(typeof(string), "Concat", new Type[3] { typeof(string), typeof(string), typeof(string) }, (Type[])null), AccessTools.Method(typeFromHandle, "Join3", (Type[])null, (Type[])null) } }; foreach (CodeInstruction @in in ins) { if (@in.opcode == OpCodes.Call && @in.operand is MethodInfo && map.TryGetValue((MethodInfo)@in.operand, out var value)) { CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)value); val.labels.AddRange(@in.labels); val.blocks.AddRange(@in.blocks); textHits++; yield return val; } else { yield return @in; } } } private static bool LobbyRowPre(LobbyController __instance) { if (!TweaksPlugin.LobbyRowsLate) { return true; } try { if (!LocalCanMove()) { return true; } Transform val = lobbyTab.Invoke(__instance); if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy) { return true; } PauseManager instance = PauseManager.Instance; if ((Object)(object)instance == (Object)null || instance.pause || instance.inMainMenu || instance.inVictoryMenu) { return true; } return false; } catch { return true; } } private static Exception LeaveFin(ClientInstance __instance, Exception __exception) { if (__exception == null) { return null; } try { if (ClientInstance.playerInstances.TryGetValue(__instance.PlayerId, out var value) && (Object)(object)value == (Object)(object)__instance) { ClientInstance.playerInstances.Remove(__instance.PlayerId); } LobbyController instance = LobbyController.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.LocalPlayerController == (Object)null || (Object)(object)instance.LocalPlayerController == (Object)(object)__instance) { ClientInstance.playerInstances.Clear(); } } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "LeaveFin", 916); } return null; } private static void AddNewPre(int id) { if (ClientInstance.playerInstances.TryGetValue(id, out var value) && (Object)(object)value == (Object)null) { ClientInstance.playerInstances.Remove(id); } } private static void StaleRowsPre(LobbyController __instance) { try { Dictionary<int, PlayerListItems> dictionary = rowsById.Invoke(__instance); if (dictionary == null || dictionary.Count == 0) { return; } foreach (KeyValuePair<int, PlayerListItems> item in dictionary) { PlayerListItems value = item.Value; if (value == null || (Object)(object)value.PlayerListItem == (Object)null || (Object)(object)value.PlayerListItemTab == (Object)null || (ClientInstance.playerInstances.TryGetValue(item.Key, out var value2) && (Object)(object)value2 != (Object)null && value2.PlayerSteamID != value.PlayerListItem.PlayerSteamID)) { staleRows.Add(item.Key); } } if (staleRows.Count == 0) { return; } foreach (int staleRow in staleRows) { PlayerListItems val = dictionary[staleRow]; dictionary.Remove(staleRow); if (val != null) { if ((Object)(object)val.PlayerListItem != (Object)null) { Object.Destroy((Object)(object)((Component)val.PlayerListItem).gameObject); } if ((Object)(object)val.PlayerListItemTab != (Object)null) { Object.Destroy((Object)(object)((Component)val.PlayerListItemTab).gameObject); } } } staleRows.Clear(); } catch { staleRows.Clear(); } } public static void ApplyLate(Harmony h) { Type self = typeof(Patches); Try("MyceliumPollRate", delegate { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown Type type = AccessTools.TypeByName("MyceliumNetworking.MyceliumNetwork"); if (!(type == null)) { MethodInfo methodInfo = AccessTools.Method(type, "ReceiveMessages", Type.EmptyTypes, (Type[])null); if (methodInfo == null) { throw new Exception("Mycelium is not the version this was written for (1.1.17)"); } h.Patch((MethodBase)methodInfo, new HarmonyMethod(self.GetMethod("MycPre", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); DorsthTweaksPlugin.Note("MyceliumPollRate: Mycelium found, it asks Steam for mod messages 60 times a second"); } }); Try("SpawnViewerNoSearch", delegate { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown if (Chainloader.PluginInfos.TryGetValue("suvilba.straftat.spawnviewer", out var value) && !((Object)(object)value.Instance == (Object)null)) { Type type = ((object)value.Instance).GetType(); MethodInfo methodInfo = AccessTools.Method(type, "RefreshPostfix", Type.EmptyTypes, (Type[])null); FieldInfo fieldInfo = type.GetField("_refreshRequested", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetField("_rescan", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo fieldInfo2 = ((fieldInfo != null && fieldInfo.Name == "_rescan") ? type.GetField("_spawnsLocked", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) : null); if (methodInfo == null || fieldInfo == null || fieldInfo.FieldType != typeof(bool) || (fieldInfo.Name == "_rescan" && (fieldInfo2 == null || fieldInfo2.FieldType != typeof(bool)))) { throw new Exception("SpawnViewer " + value.Metadata.Version?.ToString() + " is not a version this was written for (1.6, 2.1)"); } svPlugin = value.Instance; svFlag = fieldInfo; svUnlock = fieldInfo2; h.Patch((MethodBase)methodInfo, new HarmonyMethod(self.GetMethod("SvRefreshPre", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); DorsthTweaksPlugin.Note("SpawnViewerNoSearch: SpawnViewer found, its refresh no longer searches every loaded object"); } }); Try("OnGuiNoLayout (SpawnViewer)", delegate { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown if (Chainloader.PluginInfos.TryGetValue("suvilba.straftat.spawnviewer", out var value) && !((Object)(object)value.Instance == (Object)null)) { Type type = ((object)value.Instance).GetType(); if (!(type.GetMethod("OnGUI", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null) == null)) { MethodInfo methodInfo = AccessTools.Method(type, "Update", Type.EmptyTypes, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(type, "_uiVisible"); if (methodInfo == null || fieldInfo == null || fieldInfo.FieldType != typeof(bool) || fieldInfo.IsStatic) { throw new Exception("SpawnViewer is not the version this was written for (1.6.0)"); } svGui = value.Instance; svVisible = AccessTools.FieldRefAccess<object, bool>(fieldInfo); h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(self.GetMethod("SvGuiPost", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); DorsthTweaksPlugin.Note("OnGuiNoLayout: SpawnViewer found, no GUI layout pass for it while its panel is hidden"); } } }); } private static bool SvRefreshPre() { if (!TweaksPlugin.SvNoSearch || svFlag == null) { return true; } try { object obj = svPlugin; if ((Object)((obj is Object) ? obj : null) == (Object)null) { return true; } if (svUnlock != null) { svUnlock.SetValue(svPlugin, false); } svFlag.SetValue(svPlugin, true); return false; } catch { return true; } } private static bool WeaponLayerPre(Transform root, int layer) { if (!TweaksPlugin.WeaponLayer || (Object)(object)root == (Object)null) { return true; } try { ((Component)root).GetComponentsInChildren<Transform>(true, layerBuf); for (int i = 0; i < layerBuf.Count; i++) { GameObject gameObject = ((Component)layerBuf[i]).gameObject; if (gameObject.layer != layer) { gameObject.layer = layer; } } layerBuf.Clear(); return false; } catch { layerBuf.Clear(); return true; } } private static void FpcGuiPost(FirstPersonController __instance) { if (TweaksPlugin.GuiNoLayout) { ((MonoBehaviour)__instance).useGUILayout = false; } } internal static void GuiLayoutRefresh() { try { bool guiNoLayout = TweaksPlugin.GuiNoLayout; FpsCounter[] array = Object.FindObjectsOfType<FpsCounter>(true); foreach (FpsCounter val in array) { if (((MonoBehaviour)val).useGUILayout == guiNoLayout) { ((MonoBehaviour)val).useGUILayout = !guiNoLayout; } } FirstPersonController[] array2 = Object.FindObjectsOfType<FirstPersonController>(true); foreach (FirstPersonController val2 in array2) { if (((MonoBehaviour)val2).useGUILayout == guiNoLayout) { ((MonoBehaviour)val2).useGUILayout = !guiNoLayout; } } PingDisplay[] array3 = Object.FindObjectsOfType<PingDisplay>(true); foreach (PingDisplay val3 in array3) { if (((MonoBehaviour)val3).useGUILayout == guiNoLayout) { ((MonoBehaviour)val3).useGUILayout = !guiNoLayout; } } if (!guiNoLayout && svLayoutOff) { object obj = svGui; MonoBehaviour val4 = (MonoBehaviour)((obj is MonoBehaviour) ? obj : null); if ((Object)(object)val4 != (Object)null) { val4.useGUILayout = true; } svLayoutOff = false; } } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "GuiLayoutRefresh", 1063); } } private static void SvGuiPost(MonoBehaviour __instance) { if (svVisible == null) { return; } try { bool flag = TweaksPlugin.GuiNoLayout && !svVisible.Invoke((object)__instance); if (flag != svLayoutOff) { __instance.useGUILayout = !flag; svLayoutOff = flag; } } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "SvGuiPost", 1074); } } private static bool MycPre() { if (!TweaksPlugin.MycPoll) { return true; } float unscaledTime = Time.unscaledTime; if (unscaledTime < mycNext) { return false; } mycNext = unscaledTime + 1f / 60f; return true; } private static bool PlainTween(Tween t) { if (t.onComplete == null && t.onKill == null && t.onUpdate == null && t.onStepComplete == null && t.onPlay == null && t.onPause == null && t.onRewind == null) { return TweenExtensions.Loops(t) == 1; } return false; } private static void FovTweenPost(Camera target, float duration, Tween __result) { if (!TweaksPlugin.FovPile || __result == null || (Object)(object)target == (Object)null) { return; } try { int instanceID = ((Object)target).GetInstanceID(); if (!fovTweens.TryGetValue(instanceID, out var value)) { value = new List<FovT>(8); fovTweens[instanceID] = value; } float time = Time.time; float num = time + duration; for (int num2 = value.Count - 1; num2 >= 0; num2--) { FovT fovT = value[num2]; if (time >= fovT.End || fovT.T == __result || fovT.T == null || !fovT.T.active || fovT.T.intId != 1179604529 || fovT.T.target != target) { value.RemoveAt(num2); } } __result.intId = 1179604529; if (TweaksPlugin.FovReuse) { TweenSettingsExtensions.SetRecyclable<Tween>(__result, true); } int num3 = value.Count - 1; float num4 = num; for (int num5 = num3; num5 >= 0; num5--) { FovT fovT2 = value[num5]; if (num5 != num3 && fovT2.End <= num4 && PlainTween(fovT2.T)) { TweenExtensions.Kill(fovT2.T, false); value.RemoveAt(num5); fovStopped++; } else if (fovT2.End > num4) { num4 = fovT2.End; } } value.Add(new FovT { T = __result, End = num }); } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "FovTweenPost", 1135); } } private static bool GunScanPre() { if (!TweaksPlugin.GunScan || gsOwn) { return true; } float num; try { num = (float)gsLast.GetValue(null); } catch { return true; } if (Time.realtimeSinceStartup - num > 0.005f) { return true; } return !LocalCanMove(); } private static void CountdownPost(PlayerManager __instance) { if (!TweaksPlugin.GunScan || gsScan == null) { return; } try { if ((Object)(object)__instance != (Object)null && ((NetworkBehaviour)__instance).IsOwner && (Object)(object)TweaksPlugin.I != (Object)null) { gsDoneThisTake = false; ((MonoBehaviour)TweaksPlugin.I).StartCoroutine(GunScanInCountdown()); } } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "CountdownPost", 1152); } } private static IEnumerator GunScanInCountdown() { yield return (object)new WaitForSecondsRealtime(0.6f); if (!TweaksPlugin.GunScan || gsScan == null || gsDoneThisTake || LocalCanMove()) { yield break; } gsOwn = true; try { gsScan(); gsDoneThisTake = true; } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "GunScanInCountdown", 1159); } finally { gsOwn = false; } } private static void GunScanAtCountdown() { if (!TweaksPlugin.GunScan || gsScan == null) { return; } if (gsDoneThisTake) { gsDoneThisTake = false; return; } gsOwn = true; try { gsScan(); } catch (Exception e) { DorsthTweaksPlugin.LogErrorOnce(e, "GunScanAtCountdown", 1166); } finally { gsOwn = false; } } private static bool LocalCanMove() { try { ClientInstance instance = ClientInstance.Instance; FirstPersonController val = (((Object)(object)instance != (Object)null && (Object)(object)instance.PlayerSpawner != (Object)null) ? instance.PlayerSpawner.player : null); return (Object)(object)val != (Object)null && val.canMove && ((Behaviour)val).isActiveAndEnabled && ((NetworkBehaviour)val).IsOwner; } catch { return false; } } private static bool HeldByAnother(Weapon w) { try { ItemBehaviour behaviour = w.behaviour; if (behaviour == null) { return false; } if (behaviour.rootObject == null) { return false; } FirstPersonController playerController = behaviour.playerController; if (playerController == null || (Object)(object)playerController == (Object)null) { return false; } return !((NetworkBehaviour)playerController).IsOwner; } catch { return false; } } private static bool TrickLinePre(TrickShotLine __instance) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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) if (TweaksPlugin.OtherArcs) { int instanceID = ((Object)__instance).GetInstanceID(); if (!arcWeapon.TryGetValue(instanceID, out var value)) { value = ((Component)__instance).GetComponentInParent<Weapon>(); arcWeapon[instanceID] = value; } if ((Object)(object)value != (Object)null && !((NetworkBehaviour)value).IsOwner && HeldByAnother(value)) { float unscaledTime = Time.unscaledTime; if (arcNext.TryGetValue(instanceID, out var value2) && unscaledTime < value2) { return false; } arcNext[instanceI