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 AutoPickupAnzeige v1.6.1
schastar-AutoPickupAnzeige.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace AutoPickupAnzeige; [BepInPlugin("schastar.autopickupanzeige", "AutoPickupAnzeige", "1.6.1")] public class Plugin : BaseUnityPlugin { public enum Anker { ObenLinks, ObenRechts, UntenLinks, UntenRechts } public const string ModGuid = "schastar.autopickupanzeige"; public const string ModName = "AutoPickupAnzeige"; public const string ModVersion = "1.6.1"; private static FieldInfo _autoPickupFeld; private bool _autoPickupAn; private float _gewicht; private float _maxGewicht; private bool _gewichtGueltig; private int _slotsBelegt; private int _slotsGesamt; private FileSystemWatcher _watcher; private volatile bool _configGeaendert; private float _neuladenAb; private ConfigEntry<bool> _aktiv; private ConfigEntry<bool> _nurWennAus; private ConfigEntry<bool> _inMenuesAusblenden; private ConfigEntry<string> _textAn; private ConfigEntry<string> _textAus; private ConfigEntry<Color> _farbeAn; private ConfigEntry<Color> _farbeAus; private ConfigEntry<int> _schriftgroesse; private ConfigEntry<bool> _gewichtAnzeigen; private ConfigEntry<string> _textGewicht; private ConfigEntry<Color> _farbeGewicht; private ConfigEntry<Color> _farbeGewichtWarnung; private ConfigEntry<Color> _farbeUeberladen; private ConfigEntry<int> _warnSchwelle; private ConfigEntry<bool> _slotsAnzeigen; private ConfigEntry<string> _textSlots; private ConfigEntry<Color> _farbeSlots; private ConfigEntry<Color> _farbeSlotsWarnung; private ConfigEntry<Color> _farbeSlotsVoll; private ConfigEntry<int> _warnFreieSlots; private ConfigEntry<Anker> _anker; private ConfigEntry<string> _abstandX; private ConfigEntry<string> _abstandY; private string _letzteWarnung; private GUIStyle _style; private GUIStyle _schattenStyle; private int _styleGroesse = -1; private readonly List<KeyValuePair<string, Color>> _zeilen = new List<KeyValuePair<string, Color>>(); private void AlteConfigUebernehmen() { try { string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath; string text = Path.Combine(Path.GetDirectoryName(configFilePath), "marcus.autopickupanzeige.cfg"); if (!File.Exists(configFilePath) && File.Exists(text)) { File.Copy(text, configFilePath); ((BaseUnityPlugin)this).Config.Reload(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Einstellungen aus marcus.autopickupanzeige.cfg uebernommen."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Alte Config konnte nicht uebernommen werden: " + ex.Message)); } } private void Awake() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_0279: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown AlteConfigUebernehmen(); _aktiv = ((BaseUnityPlugin)this).Config.Bind<bool>("Allgemein", "Aktiv", true, "Anzeige ein- oder ausschalten."); _nurWennAus = ((BaseUnityPlugin)this).Config.Bind<bool>("Allgemein", "NurAnzeigenWennAus", false, "Nur anzeigen, wenn das automatische Aufheben AUS ist."); _inMenuesAusblenden = ((BaseUnityPlugin)this).Config.Bind<bool>("Allgemein", "InMenuesAusblenden", true, "Anzeige ausblenden, wenn Menue, Inventar oder grosse Karte offen sind."); _textAn = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "TextAn", "Auto-Aufheben: AN", "Text, wenn aktiv."); _textAus = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "TextAus", "Auto-Aufheben: AUS", "Text, wenn inaktiv."); _farbeAn = ((BaseUnityPlugin)this).Config.Bind<Color>("Text", "FarbeAn", new Color(0.45f, 1f, 0.45f, 1f), "Farbe, wenn aktiv. Format RRGGBBAA in Hex, z.B. 73FF73FF."); _farbeAus = ((BaseUnityPlugin)this).Config.Bind<Color>("Text", "FarbeAus", new Color(1f, 0.4f, 0.4f, 1f), "Farbe, wenn inaktiv. Format RRGGBBAA in Hex, z.B. FF6666FF."); _schriftgroesse = ((BaseUnityPlugin)this).Config.Bind<int>("Text", "Schriftgroesse", 20, new ConfigDescription("Schriftgroesse in Pixeln.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 72), Array.Empty<object>())); _gewichtAnzeigen = ((BaseUnityPlugin)this).Config.Bind<bool>("Gewicht", "GewichtAnzeigen", true, "Aktuelles Inventargewicht / maximales Tragegewicht anzeigen."); _textGewicht = ((BaseUnityPlugin)this).Config.Bind<string>("Gewicht", "TextGewicht", "Gewicht: {0} / {1}", "Text fuer die Gewichtszeile. {0} = aktuelles Gewicht, {1} = maximales Gewicht, {2} = Prozent."); _farbeGewicht = ((BaseUnityPlugin)this).Config.Bind<Color>("Gewicht", "FarbeNormal", new Color(1f, 1f, 1f, 1f), "Farbe bei normalem Gewicht. Format RRGGBBAA in Hex."); _farbeGewichtWarnung = ((BaseUnityPlugin)this).Config.Bind<Color>("Gewicht", "FarbeWarnung", new Color(1f, 0.85f, 0.3f, 1f), "Farbe ab der Warnschwelle. Format RRGGBBAA in Hex."); _farbeUeberladen = ((BaseUnityPlugin)this).Config.Bind<Color>("Gewicht", "FarbeUeberladen", new Color(1f, 0.4f, 0.4f, 1f), "Farbe, wenn ueberladen (Gewicht groesser als Maximum). Format RRGGBBAA in Hex."); _warnSchwelle = ((BaseUnityPlugin)this).Config.Bind<int>("Gewicht", "WarnSchwelleProzent", 90, new ConfigDescription("Ab wie viel Prozent des Maximalgewichts die Warnfarbe greift.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); _slotsAnzeigen = ((BaseUnityPlugin)this).Config.Bind<bool>("Slots", "SlotsAnzeigen", true, "Belegte / gesamte Inventarplaetze anzeigen."); _textSlots = ((BaseUnityPlugin)this).Config.Bind<string>("Slots", "TextSlots", "Slots: {0} / {1}", "Text fuer die Slotzeile. {0} = belegt, {1} = gesamt, {2} = frei."); _farbeSlots = ((BaseUnityPlugin)this).Config.Bind<Color>("Slots", "FarbeNormal", new Color(1f, 1f, 1f, 1f), "Farbe bei genug freien Plaetzen. Format RRGGBBAA in Hex."); _farbeSlotsWarnung = ((BaseUnityPlugin)this).Config.Bind<Color>("Slots", "FarbeWarnung", new Color(1f, 0.85f, 0.3f, 1f), "Farbe, wenn nur noch wenige Plaetze frei sind. Format RRGGBBAA in Hex."); _farbeSlotsVoll = ((BaseUnityPlugin)this).Config.Bind<Color>("Slots", "FarbeVoll", new Color(1f, 0.4f, 0.4f, 1f), "Farbe, wenn das Inventar voll ist. Format RRGGBBAA in Hex."); _warnFreieSlots = ((BaseUnityPlugin)this).Config.Bind<int>("Slots", "WarnAbFreienSlots", 3, new ConfigDescription("Warnfarbe, wenn hoechstens so viele Plaetze frei sind.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>())); _anker = ((BaseUnityPlugin)this).Config.Bind<Anker>("Position", "Anker", Anker.UntenLinks, "Bildschirmecke, an der die Anzeige sitzt."); _abstandX = ((BaseUnityPlugin)this).Config.Bind<string>("Position", "AbstandX", "20", "Horizontaler Abstand zur Ecke. Nur Zahl = Pixel (z.B. 20), Zahl mit % = Prozent der Bildschirmbreite (z.B. 2%)."); _abstandY = ((BaseUnityPlugin)this).Config.Bind<string>("Position", "AbstandY", "260", "Vertikaler Abstand zur Ecke. Nur Zahl = Pixel (z.B. 260), Zahl mit % = Prozent der Bildschirmhoehe (z.B. 24%)."); ConfigUeberwachen(); _autoPickupFeld = typeof(Player).GetField("m_enableAutoPickup", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (_autoPickupFeld == null || _autoPickupFeld.FieldType != typeof(bool)) { _autoPickupFeld = null; ((BaseUnityPlugin)this).Logger.LogError((object)"Feld Player.m_enableAutoPickup nicht gefunden – Mod inaktiv."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"AutoPickupAnzeige 1.6.1 geladen."); } private void ConfigUeberwachen() { try { string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath; _watcher = new FileSystemWatcher(Path.GetDirectoryName(configFilePath), Path.GetFileName(configFilePath)); _watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite; _watcher.Changed += delegate { _configGeaendert = true; }; _watcher.Created += delegate { _configGeaendert = true; }; _watcher.Renamed += delegate { _configGeaendert = true; }; _watcher.IncludeSubdirectories = false; _watcher.EnableRaisingEvents = true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Config-Ueberwachung nicht moeglich: " + ex.Message)); } } private void OnDestroy() { if (_watcher != null) { _watcher.EnableRaisingEvents = false; _watcher.Dispose(); _watcher = null; } } private void Update() { if (_configGeaendert) { _configGeaendert = false; _neuladenAb = Time.unscaledTime + 0.5f; } if (_neuladenAb > 0f && Time.unscaledTime >= _neuladenAb) { _neuladenAb = 0f; try { ((BaseUnityPlugin)this).Config.Reload(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Config neu geladen."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Config konnte nicht neu geladen werden: " + ex.Message)); } } Player localPlayer = Player.m_localPlayer; _gewichtGueltig = false; if ((Object)(object)localPlayer != (Object)null) { Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (inventory != null) { _gewicht = inventory.GetTotalWeight(); _maxGewicht = localPlayer.GetMaxCarryWeight(); _slotsGesamt = inventory.GetWidth() * inventory.GetHeight(); _slotsBelegt = Mathf.Clamp(_slotsGesamt - inventory.GetEmptySlots(), 0, _slotsGesamt); _gewichtGueltig = true; } } if (!(_autoPickupFeld == null)) { object obj = (_autoPickupFeld.IsStatic ? null : Player.m_localPlayer); if (_autoPickupFeld.IsStatic || obj != null) { _autoPickupAn = (bool)_autoPickupFeld.GetValue(obj); } } } private bool SollAnzeigen(Player spieler) { if (!_aktiv.Value || (Object)(object)spieler == (Object)null) { return false; } if ((Object)(object)Hud.instance != (Object)null && Hud.instance.m_userHidden) { return false; } if (((Character)spieler).InBed() || spieler.IsSleeping() || ((Character)spieler).IsTeleporting()) { return false; } if (_inMenuesAusblenden.Value && (Menu.IsVisible() || InventoryGui.IsVisible() || Minimap.IsOpen())) { return false; } return true; } private void StylesAktualisieren() { //IL_0038: 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_0049: 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_005c: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (_style == null || _styleGroesse != _schriftgroesse.Value) { _styleGroesse = _schriftgroesse.Value; _style = new GUIStyle(GUI.skin.label) { fontSize = _styleGroesse, fontStyle = (FontStyle)1, wordWrap = false }; _schattenStyle = new GUIStyle(_style); _schattenStyle.normal.textColor = new Color(0f, 0f, 0f, 0.85f); } } private float Abstand(ConfigEntry<string> eintrag, float bezug) { string text = (eintrag.Value ?? "").Trim(); bool flag = text.EndsWith("%"); if (float.TryParse((flag ? text.Substring(0, text.Length - 1) : text).Trim().Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && result >= 0f) { if (!flag) { return result; } return bezug * result / 100f; } string text2 = ((ConfigEntryBase)eintrag).Definition.Key + "=" + text; if (_letzteWarnung != text2) { _letzteWarnung = text2; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Ungueltiger Wert " + text2 + " - verwende Standard " + ((ConfigEntryBase)eintrag).DefaultValue)); } float.TryParse((string)((ConfigEntryBase)eintrag).DefaultValue, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2); return result2; } private static string Zahl(float wert) { return Mathf.RoundToInt(wert).ToString(CultureInfo.InvariantCulture); } private string GewichtText() { float wert = ((_maxGewicht > 0f) ? (_gewicht / _maxGewicht * 100f) : 0f); try { return string.Format(CultureInfo.InvariantCulture, _textGewicht.Value, Mathf.CeilToInt(_gewicht), Zahl(_maxGewicht), Zahl(wert)); } catch (FormatException) { return "Gewicht: " + Mathf.CeilToInt(_gewicht) + " / " + Zahl(_maxGewicht); } } private Color GewichtFarbe() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (_gewicht > _maxGewicht) { return _farbeUeberladen.Value; } if (_maxGewicht > 0f && _gewicht / _maxGewicht * 100f >= (float)_warnSchwelle.Value) { return _farbeGewichtWarnung.Value; } return _farbeGewicht.Value; } private string SlotsText() { int num = _slotsGesamt - _slotsBelegt; try { return string.Format(CultureInfo.InvariantCulture, _textSlots.Value, _slotsBelegt, _slotsGesamt, num); } catch (FormatException) { return "Slots: " + _slotsBelegt + " / " + _slotsGesamt; } } private Color SlotsFarbe() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) int num = _slotsGesamt - _slotsBelegt; if (num <= 0) { return _farbeSlotsVoll.Value; } if (num <= _warnFreieSlots.Value) { return _farbeSlotsWarnung.Value; } return _farbeSlots.Value; } private void OnGUI() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!SollAnzeigen(localPlayer)) { return; } _zeilen.Clear(); if (_autoPickupFeld != null && (!_nurWennAus.Value || !_autoPickupAn)) { _zeilen.Add(new KeyValuePair<string, Color>(_autoPickupAn ? _textAn.Value : _textAus.Value, _autoPickupAn ? _farbeAn.Value : _farbeAus.Value)); } if (_gewichtAnzeigen.Value && _gewichtGueltig) { _zeilen.Add(new KeyValuePair<string, Color>(GewichtText(), GewichtFarbe())); } if (_slotsAnzeigen.Value && _gewichtGueltig && _slotsGesamt > 0) { _zeilen.Add(new KeyValuePair<string, Color>(SlotsText(), SlotsFarbe())); } if (_zeilen.Count != 0) { StylesAktualisieren(); float num = 0f; float num2 = 0f; Vector2[] array = (Vector2[])(object)new Vector2[_zeilen.Count]; for (int i = 0; i < _zeilen.Count; i++) { array[i] = _style.CalcSize(new GUIContent(_zeilen[i].Key)); num = Mathf.Max(num, array[i].x); num2 += array[i].y; } bool flag = _anker.Value == Anker.ObenRechts || _anker.Value == Anker.UntenRechts; bool num3 = _anker.Value == Anker.UntenLinks || _anker.Value == Anker.UntenRechts; float num4 = Abstand(_abstandX, Screen.width); float num5 = Abstand(_abstandY, Screen.height); float num6 = (flag ? ((float)Screen.width - num - num4) : num4); float num7 = (num3 ? ((float)Screen.height - num2 - num5) : num5); Rect val = default(Rect); for (int j = 0; j < _zeilen.Count; j++) { float num8 = (flag ? (num6 + num - array[j].x) : num6); ((Rect)(ref val))..ctor(num8, num7, array[j].x, array[j].y); _style.normal.textColor = _zeilen[j].Value; GUI.Label(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _zeilen[j].Key, _schattenStyle); GUI.Label(val, _zeilen[j].Key, _style); num7 += array[j].y; } } } }