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 StoryBar v1.0.1
StoryBar.dll
Decompiled a day agousing System; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ProgressionTaskBar; [BepInPlugin("yuri.StoryBar", "Story Bar", "1.0.0")] public class Plugin : BaseUnityPlugin { private class Etapa { public string chave; public string bioma; public string chefe; public string matar; public string itemId; public string itemNome; public int precisa; public string abre; public Etapa(string chave, string bioma, string chefe, string matar, string itemId, string itemNome, int precisa, string abre) { this.chave = chave; this.bioma = bioma; this.chefe = chefe; this.matar = matar; this.itemId = itemId; this.itemNome = itemNome; this.precisa = precisa; this.abre = abre; } } public static bool Aberta; private ConfigEntry<bool> ligado; private ConfigEntry<KeyboardShortcut> tecla; private bool aberto; private bool escolhendo; private Rect janela; private Vector2 rolagem; private bool posicionado; private Texture2D branco; private GUIStyle texto; private GUIStyle titulo; private GUIStyle miudo; private bool avisou; private static readonly Etapa[] etapas = new Etapa[8] { new Etapa("defeated_eikthyr", "Meadows", "Eikthyr", "Deer in the meadows.", "TrophyDeer", "deer trophy", 2, "Antler pickaxe. The Black Forest truly opens."), new Etapa("defeated_gdking", "Black Forest", "The Elder", "Greydwarfs, brutes and shamans. Break the nests.", "AncientSeed", "ancient seed", 3, "Swamp key. The sunken crypts open."), new Etapa("defeated_bonemass", "Swamp", "Bonemass", "Draugr, skeletons, leeches and blobs in the crypts.", "WitheredBone", "withered bone", 10, "Wishbone. Mountain silver can be found."), new Etapa("defeated_dragon", "Mountain", "Moder", "Wolves, drakes and golems. The eggs sit in drake nests and do not go through portals.", "DragonEgg", "dragon egg", 3, "Dragon tear and the artisan table."), new Etapa("defeated_goblinking", "Plains", "Yagluth", "Fulings, berserkers and shamans in the villages.", "GoblinTotem", "fuling totem", 5, "Torn spirit and the wisp fountain."), new Etapa("defeated_queen", "Mistlands", "The Queen", "Seekers and seeker soldiers in the infested mines.", "TrophySeekerBrute", "seeker soldier trophy", 3, "Majestic carapace. The Ashlands come next."), new Etapa("defeated_fader", "Ashlands", "Fader", "The creatures and the ash fortresses, where the bells are.", "Bell", "bell", 3, "The way to the Deep North."), new Etapa("defeated_frozenking_p3", "Deep North", "Kall Fimbulbringer", "Open Morkhalla with the intricate key, break the hateful ice and win the jotun raid. Do this three times. Kall has three phases.", "HatefulBlood", "hateful blood", 3, "Clears the game.") }; private void Awake() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) ligado = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Turns the window on in this game. While it is closed, it does not take the mouse. Only your own game needs this mod."); tecla = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Key", new KeyboardShortcut((KeyCode)287, (KeyCode[])(object)new KeyCode[0]), "Click this option and press a key. The Choose key button inside the window does the same."); janela = new Rect(80f, 60f, 680f, 680f); branco = new Texture2D(1, 1); branco.SetPixel(0, 0, Color.white); branco.Apply(); ((Object)branco).hideFlags = (HideFlags)61; LigarMouse(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Progress window ready. Key: " + tecla.Value)); } private void Update() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) Aberta = ligado.Value && aberto; if (!ligado.Value) { return; } if (aberto) { AplicarRoda(); } if (escolhendo) { return; } if (aberto && Input.GetKeyDown((KeyCode)27)) { aberto = false; Aberta = false; return; } KeyboardShortcut value = tecla.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { aberto = !aberto; Aberta = aberto; } } private void OnGUI() { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_00b9: 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_00d4: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if (!ligado.Value || !aberto) { return; } Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; GUI.matrix = Matrix4x4.identity; try { if (escolhendo) { CapturarTecla(); } GarantirEstilo(); if (!posicionado) { ((Rect)(ref janela)).x = ((float)Screen.width - ((Rect)(ref janela)).width) * 0.5f; ((Rect)(ref janela)).y = ((float)Screen.height - ((Rect)(ref janela)).height) * 0.5f; posicionado = true; } janela = GUI.Window(48189, janela, new WindowFunction(Desenhar), "Story Bar"); } catch (Exception ex) { if (!avisou) { avisou = true; ((BaseUnityPlugin)this).Logger.LogError((object)("Window failed: " + ex.Message)); } } finally { GUI.color = color; GUI.matrix = matrix; } } private void AplicarRoda() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current == null) { return; } float num = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y; if (num > -0.01f && num < 0.01f) { return; } if (num > 10f || num < -10f) { num /= 120f; } Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(); val.y = (float)Screen.height - val.y; if (((Rect)(ref janela)).Contains(val)) { ref Vector2 reference = ref rolagem; reference.y -= num * 56f; if (rolagem.y < 0f) { rolagem.y = 0f; } } } private void LigarMouse() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown Harmony val = new Harmony("yuri.StoryBar"); BindingFlags bindingAttr = BindingFlags.Static | BindingFlags.NonPublic; val.Patch((MethodBase)AccessTools.Method(typeof(GameCamera), "UpdateMouseCapture", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("SoltaCursor", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("SemJogo", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseDelta", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaDelta", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaRoda", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseButton", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaBool", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseButtonDown", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaBool", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(ZInput), "GetMouseButtonUp", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin).GetMethod("BloqueiaBool", bindingAttr)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void SoltaCursor() { if (Aberta) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } } private static void SemJogo(ref bool __result) { if (Aberta) { __result = false; } } private static bool BloqueiaBool(ref bool __result) { if (!Aberta) { return true; } __result = false; return false; } private static bool BloqueiaRoda(ref float __result) { if (!Aberta) { return true; } __result = 0f; return false; } private static bool BloqueiaDelta(ref Vector2 __result) { //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) if (!Aberta) { return true; } __result = Vector2.zero; return false; } private void Desenhar(int id) { //IL_0102: 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_016f: 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_03a9: 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) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) ContarProgresso(out var feitos, out var atual); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Valheim story. " + feitos + " of " + etapas.Length + " bosses.", titulo, (GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button(escolhendo ? "Press the key" : "Choose key", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { escolhendo = true; } if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { aberto = false; } GUILayout.EndHorizontal(); Barra((float)feitos / (float)etapas.Length, new Color(0.9f, 0.62f, 0.18f)); if (escolhendo) { GUILayout.Label("Press the new key now. Esc cancels. Shift, Ctrl or Alt can go with it.", titulo, (GUILayoutOption[])(object)new GUILayoutOption[0]); } else { GUILayout.Label(NomeTecla() + " opens and closes. Esc also closes. Outside the window the game works as usual. Choose key saves the next key you press.", miudo, (GUILayoutOption[])(object)new GUILayoutOption[0]); } GUILayout.Space(6f); rolagem = GUILayout.BeginScrollView(rolagem, (GUILayoutOption[])(object)new GUILayoutOption[0]); for (int i = 0; i < etapas.Length; i++) { bool flag = ChefeMorto(etapas[i].chave); int num = Contar(etapas[i].itemId); float fator = Fator(flag, num, etapas[i].precisa); string text = (flag ? "Done" : ((i == atual) ? "Now" : "Later")); Color cor = (flag ? new Color(0.35f, 0.72f, 0.4f) : ((i == atual) ? new Color(0.9f, 0.72f, 0.28f) : new Color(0.45f, 0.42f, 0.38f))); GUILayout.Label(i + 1 + ". " + etapas[i].bioma + " - " + etapas[i].chefe + " [" + text + "]", titulo, (GUILayoutOption[])(object)new GUILayoutOption[0]); Barra(fator, cor); GUILayout.Label("Kill: " + etapas[i].matar, texto, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Collect: " + num + " / " + etapas[i].precisa + " " + etapas[i].itemNome + ". Offer them at the altar and kill the boss.", texto, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Opens: " + etapas[i].abre, texto, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Space(8f); } GUILayout.EndScrollView(); GUI.DragWindow(new Rect(0f, 0f, 10000f, 28f)); } private static void ContarProgresso(out int feitos, out int atual) { feitos = 0; atual = -1; for (int i = 0; i < etapas.Length; i++) { if (ChefeMorto(etapas[i].chave)) { feitos++; } else if (atual < 0) { atual = i; } } } private static float Fator(bool morto, int tem, int precisa) { if (morto) { return 1f; } if (precisa <= 0) { return 0f; } float num = (float)tem / (float)precisa; if (num < 0f) { num = 0f; } if (num > 1f) { num = 1f; } return num * 0.7f; } private void Barra(float fator, Color cor) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0057: 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_006f: 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_00a5: Unknown result type (might be due to invalid IL or missing references) if (fator < 0f) { fator = 0f; } if (fator > 1f) { fator = 1f; } Rect rect = GUILayoutUtility.GetRect(18f, 16f); Color color = GUI.color; GUI.color = new Color(0.12f, 0.1f, 0.08f, 0.95f); GUI.DrawTexture(rect, (Texture)(object)branco); GUI.color = cor; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width * fator, ((Rect)(ref rect)).height), (Texture)(object)branco); GUI.color = color; } private void CapturarTecla() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) Event current = Event.current; if (current == null || (int)current.type != 4 || (int)current.keyCode == 0) { return; } if ((int)current.keyCode == 27) { escolhendo = false; current.Use(); } else if (!EhModificador(current.keyCode)) { if (current.shift) { tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }); } else if (current.control) { tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }); } else if (current.alt) { tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }); } else { tecla.Value = new KeyboardShortcut(current.keyCode, (KeyCode[])(object)new KeyCode[0]); } escolhendo = false; current.Use(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("New key: " + tecla.Value)); } } private static bool EhModificador(KeyCode codigo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 return (int)codigo == 304 || (int)codigo == 303 || (int)codigo == 306 || (int)codigo == 305 || (int)codigo == 308 || (int)codigo == 307; } private unsafe string NomeTecla() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = tecla.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey == 0) { return "no key"; } value = tecla.Value; return ((object)(*(KeyboardShortcut*)(&value))/*cast due to .constrained prefix*/).ToString(); } private void GarantirEstilo() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0076: 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_0096: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (texto == null) { texto = new GUIStyle(GUI.skin.label); Pintar(texto, 14, new Color(0.93f, 0.88f, 0.78f)); titulo = new GUIStyle(GUI.skin.label); Pintar(titulo, 16, new Color(0.96f, 0.84f, 0.55f)); miudo = new GUIStyle(GUI.skin.label); Pintar(miudo, 12, new Color(0.75f, 0.7f, 0.62f)); } } private static void Pintar(GUIStyle estilo, int tamanho, Color cor) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) estilo.wordWrap = true; estilo.fontSize = tamanho; estilo.normal.textColor = cor; } private static bool ChefeMorto(string chave) { if ((Object)(object)ZoneSystem.instance == (Object)null || chave == null) { return false; } return ZoneSystem.instance.GetGlobalKey(chave); } private static int Contar(string item) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || item == null) { return 0; } Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory == null) { return 0; } return inventory.CountItems(item, -1, true); } }