Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TimerMod v0.4.2
TimerMod.dll
Decompiled 4 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GlobalEnums; using Microsoft.CodeAnalysis; using TimerMod.Triggers; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TimerMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.2.0")] [assembly: AssemblyInformationalVersion("0.4.2+28abc987dc1daea07da7c97412ce4131a70c76cf")] [assembly: AssemblyProduct("TimerMod")] [assembly: AssemblyTitle("TimerMod")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/hk-speedrunning/Silksong.TimerMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class LoadRemover { private const string MENU_TITLE = "Menu_Title"; private const string QUIT_TO_MENU = "Quit_To_Menu"; private static GameState prevGameState = (GameState)4; private static bool lookForTele = false; public static bool shouldTick() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Invalid comparison between Unknown and I4 //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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Invalid comparison between Unknown and I4 //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Invalid comparison between Unknown and I4 //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Invalid comparison between Unknown and I4 //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Invalid comparison between Unknown and I4 //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Invalid comparison between Unknown and I4 //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Invalid comparison between Unknown and I4 //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Invalid comparison between Unknown and I4 //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Invalid comparison between Unknown and I4 UIState uiState = GameManager.instance.ui.uiState; string sceneNameString = GameManager.instance.GetSceneNameString(); string nextSceneName = GameManager.instance.nextSceneName; bool flag = (sceneNameString != "Menu_Title" && nextSceneName == "") || (sceneNameString != "Menu_Title" && nextSceneName == "Menu_Title") || sceneNameString == "Quit_To_Menu"; GameState gameState = GameManager.instance.GameState; if ((int)gameState == 4 && (int)prevGameState == 1) { lookForTele = true; } if (lookForTele && (int)gameState != 4 && (int)gameState != 3) { lookForTele = false; } bool acceptingInput = GameManager.instance.inputHandler.acceptingInput; HeroTransitionState val; try { val = GameManager.instance.hero_ctrl.transitionState; } catch { val = (HeroTransitionState)0; } bool flag2 = false; if (GameManager.instance.sceneLoad != null) { flag2 = GameManager.instance.sceneLoad.IsActivationAllowed; } bool num = lookForTele; bool flag3 = ((int)gameState == 4 || (int)gameState == 3) && (int)uiState != 4; bool flag4 = (int)gameState != 4 && (int)gameState != 7 && !acceptingInput; bool flag5 = ((int)gameState == 6 && flag2) || (int)gameState == 2; bool flag6 = (int)val == 2; bool flag7 = (int)uiState != 4 && (flag || ((int)uiState != 5 && (int)uiState != 3 && !(nextSceneName == ""))) && nextSceneName != sceneNameString; bool num2 = num || flag3 || flag4 || flag5 || flag6 || flag7; prevGameState = gameState; return !num2; } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace TimerMod { public class TimerDisplay { private GameObject canvas; private Text? text; private Text? pbText; private Font? theFont; private bool timerVisible = true; private ConfigEntry<int> timerTextSize; private ConfigEntry<int> pbTextSize; private ConfigEntry<Vector2> timerTextPos; private ConfigEntry<Vector2> pbTextPos; public TimerDisplay() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown ConfigFile config = TimerMod.config; timerTextSize = config.Bind<int>("UI", "Timer Text Size", 50, ""); pbTextSize = config.Bind<int>("UI", "Pb Text Size", 25, ""); timerTextPos = config.Bind<Vector2>("UI", "Timer Text Position", new Vector2(0.03f, 0.04f), ""); pbTextPos = config.Bind<Vector2>("UI", "Pb Text Position", new Vector2(0.03f, 0.09f), ""); timerTextSize.SettingChanged += delegate { setAllConfigs(); }; pbTextSize.SettingChanged += delegate { setAllConfigs(); }; timerTextPos.SettingChanged += delegate { setAllConfigs(); }; pbTextPos.SettingChanged += delegate { setAllConfigs(); }; canvas = new GameObject("TimerModCanvas"); Object.DontDestroyOnLoad((Object)(object)canvas); } public void setup() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Font[] source = Resources.FindObjectsOfTypeAll<Font>(); theFont = ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font x) => ((Object)x).name == "TrajanPro-Regular")); setupCanvas(); text = createText("TimerText", "0:00.00", timerTextSize.Value, timerTextPos.Value); pbText = createText("TimerPBText", "PB: 0:00.00", pbTextSize.Value, pbTextPos.Value); } private void setAllConfigs() { //IL_0056: 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) if (!((Object)(object)text == (Object)null) && !((Object)(object)pbText == (Object)null)) { text.fontSize = timerTextSize.Value; pbText.fontSize = pbTextSize.Value; updateTextPos(text, timerTextPos.Value); updateTextPos(pbText, pbTextPos.Value); } } private void setupCanvas() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) Canvas obj = canvas.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.planeDistance = 20f; canvas.layer = LayerMask.NameToLayer("UI"); CanvasScaler obj2 = canvas.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); canvas.AddComponent<GraphicRaycaster>(); RectTransform component = canvas.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.sizeDelta = new Vector2(0f, 0f); } public Text createText(string name, string defaultText, int fontSize, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = LayerMask.NameToLayer("UI") }; val.AddComponent<CanvasRenderer>(); ((Transform)val.AddComponent<RectTransform>()).localPosition = Vector3.zero; CanvasGroup obj = val.AddComponent<CanvasGroup>(); obj.interactable = false; obj.blocksRaycasts = false; Text val2 = val.AddComponent<Text>(); val2.text = defaultText; val2.font = theFont; val2.fontSize = fontSize; val2.fontStyle = (FontStyle)0; val.transform.SetParent(canvas.transform, false); updateTextPos(val2, position); return val2; } private void updateTextPos(Text t, Vector2 position) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) RectTransform component = ((Component)t).gameObject.GetComponent<RectTransform>(); if (position.y > 0.5f) { if (position.x > 0.5f) { t.alignment = (TextAnchor)2; component.anchorMin = new Vector2(0f, 0f); component.anchorMax = position; } else { t.alignment = (TextAnchor)0; component.anchorMin = new Vector2(position.x, 0f); component.anchorMax = new Vector2(1f, position.y); } } else if (position.x > 0.5f) { t.alignment = (TextAnchor)8; component.anchorMin = new Vector2(0f, position.y); component.anchorMax = new Vector2(position.x, 1f); } else { t.alignment = (TextAnchor)6; component.anchorMin = position; component.anchorMax = new Vector2(1f, 1f); } } public void toggleVisibility() { canvas.SetActive(timerVisible); timerVisible = !timerVisible; } public void setTime(string time) { if (!((Object)(object)text == (Object)null)) { text.text = time; } } public void setPbTime(string time) { if (!((Object)(object)pbText == (Object)null)) { pbText.text = "PB: " + time; } } } public class Keybinds { public ConfigEntry<KeyboardShortcut> SetStart; public ConfigEntry<KeyboardShortcut> SetEnd; public ConfigEntry<KeyboardShortcut> ToggleTriggerMethod; public ConfigEntry<KeyboardShortcut> CancelTimer; public ConfigEntry<KeyboardShortcut> StartTimer; public ConfigEntry<KeyboardShortcut> EndTimer; public ConfigEntry<KeyboardShortcut> ResetPb; public ConfigEntry<KeyboardShortcut> ToggleTimerVisibility; public Keybinds(ConfigFile Config) { //IL_001c: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) SetStart = Config.Bind<KeyboardShortcut>("Shortcuts", "SetStart", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), ""); SetEnd = Config.Bind<KeyboardShortcut>("Shortcuts", "SetEnd", new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>()), ""); ToggleTriggerMethod = Config.Bind<KeyboardShortcut>("Shortcuts", "ToggleTriggerMethod", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), ""); CancelTimer = Config.Bind<KeyboardShortcut>("Shortcuts", "CancelTimer", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "Cancel the timer (does not affect pb)"); StartTimer = Config.Bind<KeyboardShortcut>("Shortcuts", "StartTimer", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), ""); EndTimer = Config.Bind<KeyboardShortcut>("Shortcuts", "EndTimer", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), ""); ResetPb = Config.Bind<KeyboardShortcut>("Shortcuts", "ResetPb", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), ""); ToggleTimerVisibility = Config.Bind<KeyboardShortcut>("Shortcuts", "ToggleTimerVisibility", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), ""); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("io.github.hk-speedrunning.timermod", "TimerMod", "0.4.2")] public class TimerMod : BaseUnityPlugin { public static ConfigFile config; private TimerDisplay timerDisplay; private Trigger startTrigger = new SceneTrigger(""); private Trigger endTrigger = new SceneTrigger(""); private Keybinds keybinds; private bool usingSceneTriggers; private double time; private bool timerPaused = true; private double[] history = new double[5]; private int history_num; private double pb; private int funSceneCount; private ConfigEntry<bool> showSpeed; private Vector2 startPos; private ConfigEntry<Vector2> startTriggerSize; private ConfigEntry<Vector2> endTriggerSize; public const string Id = "io.github.hk-speedrunning.timermod"; public static string Name => "TimerMod"; public static string Version => "0.4.2"; private void resetPb() { pb = 0.0; timerDisplay.setPbTime(getTimeText(pb)); } private void endTimer() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector2 val = Vector2.op_Implicit(((Component)HeroController.instance).gameObject.transform.position); double num = (double)Math.Abs(startPos.x - val.x) / time; double num2 = (double)Math.Abs(startPos.y - val.y) / time; history[history_num] = time; history_num++; history_num %= 5; timerPaused = true; if (pb == 0.0 || time < pb) { pb = time; timerDisplay.setPbTime(getTimeText(pb)); if (showSpeed.Value) { timerDisplay.setPbTime($"{getTimeText(pb)}\n{num:0.00} u/s, {num2:0.00} u/s"); } } } private void startTimer() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) time = 0.0; timerPaused = false; startPos = Vector2.op_Implicit(((Component)HeroController.instance).gameObject.transform.position); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Started timer"); } private void LateUpdate() { //IL_004b: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) if (funSceneCount != 4) { return; } if (startTrigger.active() && timerPaused) { startTimer(); } if (endTrigger.active() && !timerPaused) { endTimer(); } KeyboardShortcut value = keybinds.ToggleTriggerMethod.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { usingSceneTriggers = !usingSceneTriggers; } value = keybinds.CancelTimer.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Canceled"); time = 0.0; timerPaused = true; } value = keybinds.ResetPb.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { resetPb(); } value = keybinds.StartTimer.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { startTimer(); } value = keybinds.EndTimer.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { endTimer(); } value = keybinds.ToggleTimerVisibility.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { timerDisplay.toggleVisibility(); } value = keybinds.SetStart.Value; Scene activeScene; if (((KeyboardShortcut)(ref value)).IsDown()) { startTrigger.destroy(); resetPb(); if (usingSceneTriggers) { activeScene = SceneManager.GetActiveScene(); startTrigger = new SceneTrigger(((Scene)(ref activeScene)).name); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Set start scene"); } else { startTrigger = new CollisionTrigger(Vector2.op_Implicit(GameManager.instance.hero_ctrl.transform.position), startTriggerSize.Value, new Color(0.1f, 0.4f, 0.1f)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Set start pos"); } } value = keybinds.SetEnd.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { endTrigger.destroy(); resetPb(); if (usingSceneTriggers) { activeScene = SceneManager.GetActiveScene(); endTrigger = new SceneTrigger(((Scene)(ref activeScene)).name); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Set end scene"); } else { endTrigger = new CollisionTrigger(Vector2.op_Implicit(GameManager.instance.hero_ctrl.transform.position), endTriggerSize.Value, new Color(0.4f, 0.1f, 0.1f)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Set end pos"); } } if (!timerPaused && LoadRemover.shouldTick()) { time += Time.unscaledDeltaTime; timerDisplay.setTime(getTimeText(time)); } } public void onActiveSceneChanged(Scene from, Scene to) { funSceneCount++; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Start2 aaa timermod is going a {funSceneCount}"); if (funSceneCount == 4) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Setting up timer display"); timerDisplay.setup(); SceneManager.activeSceneChanged -= onActiveSceneChanged; } } private string getTimeText(double t) { int num = (int)(t * 100.0) % 100; int num2 = (int)t % 60; int num3 = (int)t / 60; return $"{num3}:{num2:00}.{num:00}"; } private void Awake() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) config = ((BaseUnityPlugin)this).Config; SceneManager.activeSceneChanged += onActiveSceneChanged; keybinds = new Keybinds(((BaseUnityPlugin)this).Config); timerDisplay = new TimerDisplay(); showSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "Show Speed", false, ""); startTriggerSize = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Triggers", "Start (collision) trigger size", new Vector2(0.35f, 0.35f), ""); endTriggerSize = ((BaseUnityPlugin)this).Config.Bind<Vector2>("Triggers", "End (collision) trigger size", new Vector2(0.35f, 0.35f), ""); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.hk-speedrunning.timermod) has loaded!")); } } } namespace TimerMod.Triggers { public class CollisionTrigger : Trigger { private bool shouldActivate; private string scene; private GameObject? triggerObject; private Vector2 pos; private Vector2 size; private Color colour; public CollisionTrigger(Vector2 pos, Vector2 size, Color colour) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) this.pos = pos; this.size = size; this.colour = colour; scene = GameManager.instance.GetSceneNameString(); createSelf(); } private void onActiveSceneChanged(Scene from, Scene to) { if (((Scene)(ref to)).name == scene) { destroy(); createSelf(); } } private void createSelf() { //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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) SceneManager.activeSceneChanged += onActiveSceneChanged; Vector3[] vertices = (Vector3[])(object)new Vector3[4] { new Vector3(pos.x, pos.y), new Vector3(pos.x, pos.y + size.y), new Vector3(pos.x + size.x, pos.y), new Vector3(pos.x + size.x, pos.y + size.y) }; Mesh val = new Mesh(); val.vertices = vertices; val.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(1f, 0f) }; val.triangles = new int[6] { 0, 1, 2, 2, 1, 3 }; val.RecalculateNormals(); triggerObject = new GameObject("TimerModTrigger"); triggerObject.AddComponent<MeshFilter>().mesh = val; Texture2D val2 = new Texture2D(1, 1); val2.SetPixel(0, 0, colour); val2.Apply(); MeshRenderer obj = triggerObject.AddComponent<MeshRenderer>(); Console.WriteLine(Object.op_Implicit((Object)(object)((Renderer)obj).material.shader)); ((Renderer)obj).material.mainTexture = (Texture)(object)val2; ((Renderer)obj).material.color = colour; triggerObject.AddComponent<TriggerCollider>().callback = setPlayerIn; ((Collider2D)triggerObject.AddComponent<BoxCollider2D>()).isTrigger = true; triggerObject.SetActive(true); } public void setPlayerIn() { shouldActivate = true; } public bool active() { if (shouldActivate) { shouldActivate = false; return true; } return false; } public void destroy() { Object.Destroy((Object)(object)triggerObject); SceneManager.activeSceneChanged -= onActiveSceneChanged; } } internal class TriggerCollider : MonoBehaviour { public Action? callback; private void OnTriggerEnter2D(Collider2D other) { if ((Object)(object)((Component)other).gameObject == (Object)(object)((Component)HeroController.instance).gameObject && callback != null) { callback(); } } } public class SceneTrigger : Trigger { private string targetSceneName; private string prevSceneName; public SceneTrigger(string scene) { targetSceneName = scene; prevSceneName = ""; } public bool active() { if (!Object.op_Implicit((Object)(object)GameManager.instance)) { return false; } if (GameManager.instance.GetSceneNameString() == targetSceneName && targetSceneName != prevSceneName) { return true; } prevSceneName = GameManager.instance.GetSceneNameString(); return false; } public void destroy() { } } public interface Trigger { bool active(); void destroy(); } }