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 NM Bounty REPO v0.3.0
BepInEx/plugins/NM_Bounty_REPO/NM_Bounty_REPO.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Nightmare.REPO.Core; using Nightmare.REPO.Localization; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; 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("Nightmare Community / NM")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2026 Nick1Z2 (Nightmare Community / NM).")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0")] [assembly: AssemblyProduct("NM_Bounty_REPO")] [assembly: AssemblyTitle("NM_Bounty_REPO")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Nightmare.REPO.Localization { internal static class L { internal static readonly Dictionary<string, string> Translations = new Dictionary<string, string>(StringComparer.Ordinal) { { "Unbekannt", "Unknown" }, { "Größe", "Size" }, { "Abstand oben", "Top margin" }, { "Ungültige Prämie.", "Invalid bounty reward." }, { "Weitere Gegnertypen", "Other enemy types" }, { "Weitere Gegner", "Other enemies" }, { "Bounty Hunt läuft", "Bounty Hunt active" }, { "Bounty Hunt · Limit erreicht", "Bounty Hunt · limit reached" }, { "Bounty Hunt · deaktiviert", "Bounty Hunt · disabled" }, { "Bounty Hunt · Auszahlung angehalten", "Bounty Hunt · payout stopped" }, { "Bounty Hunt · Mod-Konflikt", "Bounty Hunt · mod conflict" }, { "Bounty Hunt · wartet auf Extraktionen", "Bounty Hunt · waiting for extractions" }, { " erlegt · $", " defeated · $" }, { " verdient", " earned" }, { "\nNächster Kill: ", "\nNext kill: " }, { " % Prämie", " % reward" }, { "\nWeitere: ", "\nOthers: " }, { "Ungültige Bounty-Grenzen.", "Invalid bounty limits." }, { "Ungültiger Basiswert.", "Invalid base value." }, { "Ungültiger Orb-Wertebereich.", "Invalid orb value range." }, { "Ungültiger Geldbetrag.", "Invalid money amount." }, { "Noch keine Belohnung.", "No reward yet." }, { "Nur der Host vergibt nach Abschluss aller Extraktionen Geld.", "Only the host awards money after all extractions are completed." }, { "Wert aus dem Orb-Prefab mal Faktor.", "Orb prefab value multiplied by this factor." }, { "Fehlender Orb-Wertebereich: 0 = keine Belohnung. Explizit deaktivierte Orb-Drops bleiben ohne Belohnung.", "Missing orb value range: 0 = no reward. Explicitly disabled orb drops remain unrewarded." }, { "Zweite Grenze: Ab diesem verdienten Bounty-Betrag gibt es keine Prämie mehr. 0 = beide Grenzen aus, unbegrenzt.", "Second threshold: no further rewards once this earned bounty amount is reached. 0 = both thresholds disabled, unlimited." }, { "Erste Grenze: Bis zu diesem bereits verdienten Betrag volle Prämie. Danach linear weniger bis MaximumDollarProLevel. Gleiche Grenzen = bisheriges hartes Limit.", "First threshold: full reward up to this earned amount, then a linear decrease until MaximumDollarProLevel. Equal thresholds retain the previous hard cap." }, { "Bounty-Übersicht oben mittig während der Jagd. Gäste benötigen für die Übersicht einen Host mit NM-Bounty ab 0.2.0.", "Bounty overview at the top center during the hunt. Guests need a host with NM Bounty 0.2.0 or later for the overview." }, { "Größe der Übersicht.", "Overview size." }, { "Abstand vom oberen Rand bei 1920x1080.", "Distance from the top edge at 1920x1080." }, { "Letzte 1–5 Gegnertypen; weitere werden zusammengefasst.", "Latest 1–5 enemy types; additional types are grouped." }, { "Jagd nach der letzten Extraktion: Belohnung aus dem Orb-Wertebereich.", "Hunt after the final extraction: rewards based on the orb value range." }, { ": $0 (kein Orb-Wert / Limit erreicht).", ": $0 (no orb value / limit reached)." }, { "Gutschrift lokal nicht bestätigt.", "Credit not confirmed locally." }, { "Gesamtbeute lokal nicht bestätigt.", "Total haul not confirmed locally." }, { "Restbetrag lokal nicht bestätigt.", "Remainder not confirmed locally." }, { " · Rest bis zum nächsten $1.000: $", " · remainder toward the next $1,000: $" }, { "Vergabe angehalten; keine automatische Wiederholung: ", "Distribution stopped; no automatic retry: " }, { "Original Bounty Hunters ist geladen: NM-Auszahlung pausiert. Original und Fix entfernen.", "Original Bounty Hunters is loaded: NM payouts are paused. Remove the original and its fix." }, { "Nur der Host vergibt Geld. Deine Einstellungen gelten, wenn du selbst hostest.", "Only the host awards money. Your settings apply when you host a game." }, { "Jagdphase aktiv", "Hunt phase active" }, { "Wartet auf Abschluss aller Extraktionen.", "Waiting for all extractions to be completed." }, { "Eigene Host-Belohnungen dieses Levels: $", "Your host rewards in this level: $" }, { "Orb-Wertebereich des Spiels, pro Tod neu gewürfelt. Mod-eigene Sonderdrops sind nicht automatisch auslesbar. Normale Drops bleiben unverändert. Restbeträge unter $1.000 werden angespart und mit dem Spielstand gespeichert.", "The game's orb value range is rolled again for each death. Special drops from mods cannot be read automatically. Normal drops remain unchanged. Remainders below $1,000 accumulate and are stored with the save." }, { "Bounty aktiv", "Bounty enabled" }, { "Orb-Multiplikator (0–20)", "Orb multiplier (0–20)" }, { "Ersatzwert in Dollar (0 = keine Belohnung)", "Fallback value in dollars (0 = no reward)" }, { "Grenze 1: volle Prämie bis zu diesem verdienten Bounty-Betrag ($)", "Threshold 1: full reward up to this earned bounty amount ($)" }, { "Grenze 2: ab diesem Betrag keine Prämie ($; 0 = unbegrenzt)", "Threshold 2: no reward from this amount ($; 0 = unlimited)" }, { "Pro Kill zählt der Bounty-Stand vor der Vergabe. Dazwischen sinkt der Anteil linear. Beispiel: 10.000 / 20.000 → bei 15.000 gibt der nächste Kill 50 %. Gleiche Grenzen behalten das alte harte Limit.", "Each kill uses the bounty total before the payout. Between thresholds, the percentage decreases linearly. Example: 10,000 / 20,000 → at 15,000 the next kill awards 50%. Equal thresholds retain the old hard cap." }, { "Einstellungen speichern", "Save settings" }, { "Einstellungen gespeichert. Bereits verdientes Geld bleibt erhalten.", "Settings saved. Previously earned money is retained." }, { "Ungültige Werte: Grenze 1 darf nicht über Grenze 2 liegen (außer Grenze 2 = 0).", "Invalid values: threshold 1 must not exceed threshold 2 (unless threshold 2 = 0)." }, { "ANZEIGE (nur für dich)", "DISPLAY (only for you)" }, { "Bounty-Overlay anzeigen", "Show bounty overlay" }, { "Gegnerzeilen: ", "Enemy rows: " }, { "Summen beziehen sich auf die Jagd nach der letzten Extraktion. Weitere Gegnertypen werden zusammengefasst; $0-Kills zählen mit. Gespeicherte Restbeträge zählen als verdiente Prämie, auch wenn die nächste $1.000-Gutschrift noch aussteht.", "Totals cover the hunt after the final extraction. Additional enemy types are grouped; $0 kills count too. Saved remainders count as earned rewards even before the next $1,000 credit." } }; [ThreadStatic] private static string? captureLanguage; internal static string Language => captureLanguage ?? CoreApi.Language; internal static string T(string german) { if (!(Language == "de")) { return English(german); } return german; } internal static string English(string german) { if (!Translations.TryGetValue(german, out string value) || value == null) { return german; } return value; } internal static string Help(string german) { return "DE: " + german + "\nEN: " + English(german); } internal static LocalText Capture(Func<string> render) { string text = captureLanguage; try { captureLanguage = "de"; string german = render(); captureLanguage = "en"; return new LocalText(german, render()); } finally { captureLanguage = text; } } internal static AddonDefinition Describe(AddonDefinition definition, string name, string description) { definition.NameProvider = () => T(name); definition.DescriptionProvider = () => T(description); return definition; } } internal sealed class LocalText { private readonly string de; private readonly string en; internal int Length => ToString().Length; internal LocalText(string german, string english) { de = german; en = english; } public override string ToString() { if (!(L.Language == "de")) { return en; } return de; } public static implicit operator string(LocalText value) { return value.ToString(); } public static implicit operator LocalText(string value) { return new LocalText(value, value); } } } namespace Nightmare.REPO.Bounty { internal sealed class BountyDisplayLink : IDisposable { private object? room; private string? published; private bool wrote; internal BountySnapshot? Exchange(BountySnapshot local, bool host, bool inLevel) { //IL_0068: 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_0082: Expected O, but got Unknown if (room != PhotonNetwork.CurrentRoom) { room = PhotonNetwork.CurrentRoom; published = null; wrote = false; } if (!PhotonNetwork.InRoom) { if (!(host && inLevel)) { return null; } return local; } if (host && PhotonNetwork.IsMasterClient) { string text = (inLevel ? local.Encode() : null); if (text != published || !wrote) { PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"nm.bounty.hud.v1"] = text }, (Hashtable)null, (WebFlags)null); CoreTraffic.Record("Bounty-Overlay", (text == null) ? 32 : (Encoding.UTF8.GetByteCount(text) + 32)); published = text; wrote = true; } if (!inLevel) { return null; } return local; } if (!inLevel) { return null; } Player masterClient = PhotonNetwork.MasterClient; return BountySnapshot.Decode(((masterClient != null) ? masterClient.CustomProperties[(object)"nm.bounty.hud.v1"] : null) as string, local.Scene, local.Level); } public void Dispose() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (wrote && PhotonNetwork.InRoom) { PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"nm.bounty.hud.v1"] = null }, (Hashtable)null, (WebFlags)null); } published = null; room = null; wrote = false; } } internal sealed class BountyHud : IDisposable { private GameObject? canvas; private TextMeshProUGUI? label; private RectTransform? panel; private float nextCreate; internal void Show(BountySnapshot? snapshot, bool enabled, float scale, float top, int rows) { //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03be: 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_00f3: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: 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_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) if (!enabled || snapshot == null || snapshot.State == 0 || snapshot.State == 3) { if (Object.op_Implicit((Object)(object)canvas)) { canvas.SetActive(false); } return; } if (!Object.op_Implicit((Object)(object)canvas)) { if (Time.unscaledTime < nextCreate) { return; } nextCreate = Time.unscaledTime + 1f; GameObject val = GameObject.Find("Tax Haul"); TMP_Text val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<TMP_Text>() : null); TMP_FontAsset val3 = (((Object)(object)val2 != (Object)null && Object.op_Implicit((Object)(object)val2)) ? val2.font : TMP_Settings.defaultFontAsset); if (!Object.op_Implicit((Object)(object)val3)) { return; } canvas = new GameObject("NM Bounty HUD", new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler) }); Canvas component = canvas.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 79; CanvasScaler component2 = canvas.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.matchWidthOrHeight = 0.5f; GameObject val4 = new GameObject("Bounty Hintergrund", new Type[2] { typeof(RectTransform), typeof(Image) }); val4.transform.SetParent(canvas.transform, false); Image component3 = val4.GetComponent<Image>(); ((Graphic)component3).color = new Color(0.025f, 0.035f, 0.045f, 0.78f); ((Graphic)component3).raycastTarget = false; panel = val4.GetComponent<RectTransform>(); RectTransform? obj = panel; RectTransform? obj2 = panel; RectTransform? obj3 = panel; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0.5f, 1f); obj3.pivot = val5; Vector2 anchorMin = (obj2.anchorMax = val5); obj.anchorMin = anchorMin; GameObject val7 = new GameObject("Bounty Text", new Type[1] { typeof(RectTransform) }); val7.transform.SetParent(val4.transform, false); label = val7.AddComponent<TextMeshProUGUI>(); ((TMP_Text)label).font = val3; ((TMP_Text)label).richText = false; ((Graphic)label).raycastTarget = false; ((TMP_Text)label).alignment = (TextAlignmentOptions)258; ((TMP_Text)label).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)label).overflowMode = (TextOverflowModes)1; ((Graphic)label).color = new Color(1f, 0.85f, 0.35f); RectTransform rectTransform = ((TMP_Text)label).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(14f, 10f); rectTransform.offsetMax = new Vector2(-14f, -10f); } if (Object.op_Implicit((Object)(object)canvas) && Object.op_Implicit((Object)(object)label) && Object.op_Implicit((Object)(object)panel)) { canvas.SetActive(true); string text = snapshot.Text(rows); if (((TMP_Text)label).text != text) { ((TMP_Text)label).text = text; } if (!Mathf.Approximately(((TMP_Text)label).fontSize, 22f * scale)) { ((TMP_Text)label).fontSize = 22f * scale; } int num = text.Split('\n').Length; Vector2 val8 = default(Vector2); ((Vector2)(ref val8))..ctor(560f * scale, (float)(num * 29 + 20) * scale); Vector2 val9 = default(Vector2); ((Vector2)(ref val9))..ctor(0f, 0f - top); if (panel.sizeDelta != val8) { panel.sizeDelta = val8; } if (panel.anchoredPosition != val9) { panel.anchoredPosition = val9; } } } public void Dispose() { if (Object.op_Implicit((Object)(object)canvas)) { Object.Destroy((Object)(object)canvas); } canvas = null; label = null; panel = null; nextCreate = 0f; } } internal sealed class BountyRow { internal string Name = ""; internal long Kills; internal long Dollars; } internal sealed class BountyLedger { internal readonly List<BountyRow> Rows = new List<BountyRow>(); internal long Kills { get; private set; } internal long Dollars { get; private set; } internal void Clear() { long kills = (Dollars = 0L); Kills = kills; Rows.Clear(); } internal void Add(string name, int dollars) { if (dollars < 0 || dollars > 1000000) { throw new ArgumentException(L.T("Ungültige Prämie.")); } name = Clean(name); BountyRow bountyRow = Rows.FirstOrDefault((BountyRow r) => r.Name == name); if (bountyRow == null && Rows.Count >= 32) { name = "Weitere Gegnertypen"; bountyRow = Rows.FirstOrDefault((BountyRow r) => r.Name == name); } if (bountyRow == null) { bountyRow = new BountyRow { Name = name }; Rows.Add(bountyRow); } checked { bountyRow.Kills++; bountyRow.Dollars += dollars; Kills++; Dollars += dollars; Rows.Remove(bountyRow); Rows.Insert(0, bountyRow); } } internal static string Clean(string value) { StringBuilder stringBuilder = new StringBuilder(); foreach (char c in value) { if (!char.IsControl(c) && c != '<' && c != '>' && c != '|') { stringBuilder.Append(c); if (stringBuilder.Length == 48) { break; } } } string text = stringBuilder.ToString().Trim(); if (text.Length != 0) { return text; } return "Unbekannt"; } internal BountySnapshot Snapshot(string scene, int level, int state, double rate) { List<BountyRow> list = (from r in Rows.Take(5) select new BountyRow { Name = r.Name, Kills = r.Kills, Dollars = r.Dollars }).ToList(); long num = Kills - list.Sum((BountyRow r) => r.Kills); long dollars = Dollars - list.Sum((BountyRow r) => r.Dollars); if (num > 0) { list.Add(new BountyRow { Name = "Weitere Gegner", Kills = num, Dollars = dollars }); } return new BountySnapshot(scene, level, state, Kills, Dollars, (int)Math.Round(rate * 10000.0), list); } } internal sealed class BountySnapshot { internal const string Property = "nm.bounty.hud.v1"; internal readonly string Scene; internal readonly int Level; internal readonly int State; internal readonly int BasisPoints; internal readonly long Kills; internal readonly long Dollars; internal readonly List<BountyRow> Rows; internal string Header { get { if (State != 1) { if (State != 2) { if (State != 3) { if (State != 4) { if (State != 5) { return L.T("Bounty Hunt · wartet auf Extraktionen"); } return L.T("Bounty Hunt · Mod-Konflikt"); } return L.T("Bounty Hunt · Auszahlung angehalten"); } return L.T("Bounty Hunt · deaktiviert"); } return L.T("Bounty Hunt · Limit erreicht"); } return L.T("Bounty Hunt läuft"); } } internal BountySnapshot(string scene, int level, int state, long kills, long dollars, int basisPoints, List<BountyRow> rows) { Scene = scene; Level = level; State = state; Kills = kills; Dollars = dollars; BasisPoints = basisPoints; Rows = rows; } internal string Text(int maxRows) { StringBuilder stringBuilder = new StringBuilder(Header).Append('\n').Append(Kills.ToString("N0")).Append(L.T(" erlegt · $")) .Append(Dollars.ToString("N0")) .Append(L.T(" verdient")); stringBuilder.Append(L.T("\nNächster Kill: ")).Append(((double)BasisPoints / 100.0).ToString("0.##")).Append(L.T(" % Prämie")); long num = 0L; long num2 = 0L; foreach (BountyRow item in Rows.Take(maxRows)) { string text = ((item.Name == "Weitere Gegner" || item.Name == "Weitere Gegnertypen" || item.Name == "Unbekannt") ? L.T(item.Name) : item.Name); string value = ((text.Length > 24) ? (text.Substring(0, 23) + "…") : text); stringBuilder.Append('\n').Append(value).Append(" ×") .Append(item.Kills.ToString("N0")) .Append(" · +$") .Append(item.Dollars.ToString("N0")); num += item.Kills; num2 += item.Dollars; } if (Kills > num) { stringBuilder.Append(L.T("\nWeitere: ")).Append((Kills - num).ToString("N0")).Append(" · +$") .Append((Dollars - num2).ToString("N0")); } return stringBuilder.ToString(); } internal string Encode() { StringBuilder stringBuilder = new StringBuilder("1\n").Append(Scene).Append('\n').Append(Level) .Append('\n') .Append(State) .Append('\n') .Append(Kills) .Append('\n') .Append(Dollars) .Append('\n') .Append(BasisPoints); foreach (BountyRow row in Rows) { stringBuilder.Append('\n').Append(row.Name).Append('|') .Append(row.Kills) .Append('|') .Append(row.Dollars); } return stringBuilder.ToString(); } internal static BountySnapshot? Decode(string? value, string scene, int level) { if (value == null || value.Length > 1600) { return null; } string[] array = value.Split('\n'); if (array.Length < 7 || array.Length > 13 || array[0] != "1" || array[1] != scene || !Number(array[2], out var n) || n != level || !Number(array[3], out var n2) || n2 > 5 || !Number(array[4], out var n3) || !Number(array[5], out var n4) || !Number(array[6], out var n5) || n5 > 10000) { return null; } List<BountyRow> list = new List<BountyRow>(); long num = 0L; long num2 = 0L; foreach (string item in array.Skip(7)) { string[] array2 = item.Split('|'); if (array2.Length != 3 || array2[0].Length == 0 || array2[0] != BountyLedger.Clean(array2[0]) || !Number(array2[1], out var n6) || n6 == 0L || !Number(array2[2], out var n7)) { return null; } num += n6; num2 += n7; list.Add(new BountyRow { Name = array2[0], Kills = n6, Dollars = n7 }); } if (num != n3 || num2 != n4) { return null; } return new BountySnapshot(scene, level, (int)n2, n3, n4, (int)n5, list); } private static bool Number(string s, out long n) { if (long.TryParse(s, NumberStyles.None, CultureInfo.InvariantCulture, out n) && n >= 0) { return n <= 1000000000000L; } return false; } } internal static class BountyMath { internal static bool ValidLimits(int full, int maximum) { if (full >= 0 && maximum >= 0 && full <= 10000000 && maximum <= 10000000) { if (maximum != 0) { return full <= maximum; } return true; } return false; } internal static double Rate(long earned, int full, int maximum) { if (earned < 0 || !ValidLimits(full, maximum)) { throw new ArgumentException(L.T("Ungültige Bounty-Grenzen.")); } if (maximum == 0) { return 1.0; } if (earned >= maximum) { return 0.0; } if (earned <= full) { return 1.0; } return (double)(maximum - earned) / (double)(maximum - full); } internal static int Reward(int basis, long earned, int full, int maximum) { if (basis < 0 || basis > 1000000) { throw new ArgumentException(L.T("Ungültiger Basiswert.")); } double num = Rate(earned, full, maximum); if (basis == 0 || num == 0.0) { return 0; } int num2 = Math.Max(1, (int)Math.Round((double)basis * num, MidpointRounding.AwayFromZero)); if (maximum != 0) { return (int)Math.Min(num2, maximum - earned); } return num2; } internal static int Dollars(double minimum, double maximum, double roll, double multiplier) { if (double.IsNaN(minimum) || double.IsInfinity(minimum) || double.IsNaN(maximum) || double.IsInfinity(maximum) || minimum < 0.0 || maximum < minimum || roll < 0.0 || roll > 1.0 || double.IsNaN(roll) || double.IsNaN(multiplier) || double.IsInfinity(multiplier) || multiplier < 0.0) { throw new ArgumentException(L.T("Ungültiger Orb-Wertebereich.")); } double num = Math.Round(Math.Round(minimum + (maximum - minimum) * roll) / 100.0, MidpointRounding.ToEven) * 100.0; return (int)Math.Min(1000000.0, Math.Max(0.0, Math.Round(num * multiplier))); } internal static (int Units, int Remainder) Split(int dollars, int remainder) { if (dollars < 0 || dollars > 1000000 || remainder < 0 || remainder >= 1000) { throw new ArgumentException(L.T("Ungültiger Geldbetrag.")); } return (Units: (dollars + remainder) / 1000, Remainder: (dollars + remainder) % 1000); } } [BepInPlugin("nightmare.repo.bounty", "NM_Bounty_REPO", "0.3.0")] [BepInProcess("REPO.exe")] [BepInDependency("nightmare.repo.core", "2.10.1")] public sealed class Plugin : BaseUnityPlugin { public const string Id = "nightmare.repo.bounty"; public const string Version = "0.3.0"; private const string RemainderKey = "nm.bounty.remainder.v1"; private AddonHandle page; private IDisposable? subscription; private ConfigEntry<bool> active; private ConfigEntry<bool> overlay; private ConfigEntry<float> multiplier; private ConfigEntry<float> scale; private ConfigEntry<float> top; private ConfigEntry<int> fallback; private ConfigEntry<int> cap; private ConfigEntry<int> full; private ConfigEntry<int> rows; private readonly Random random = new Random(); private readonly HashSet<string> awarded = new HashSet<string>(); private readonly BountyLedger ledger = new BountyLedger(); private readonly BountyHud hud = new BountyHud(); private readonly BountyDisplayLink displayLink = new BountyDisplayLink(); private BountySnapshot? display; private object? room; private int scene = -1; private int level = -1; private float nextDisplay; private LocalText fault = ""; private LocalText last = L.Capture(() => L.T("Noch keine Belohnung.")); private object? stats; private string factorText = ""; private string fallbackText = ""; private string capText = ""; private string fullText = ""; private Action? tick; private static bool Host { get { if (Object.op_Implicit((Object)(object)GameManager.instance)) { return SemiFunc.IsMasterClientOrSingleplayer(); } return false; } } private static bool InLevel { get { if (Object.op_Implicit((Object)(object)RunManager.instance)) { return SemiFunc.RunIsLevel(); } return false; } } private static bool FinalPhase { get { if (InLevel && Object.op_Implicit((Object)(object)RoundDirector.instance)) { object obj = Read(RoundDirector.instance, "allExtractionPointsCompleted"); if (obj is bool) { return (bool)obj; } return false; } return false; } } private static bool Conflict => Chainloader.PluginInfos.ContainsKey("denis.repo.bountyhuntersui"); private void Awake() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown active = ((BaseUnityPlugin)this).Config.Bind<bool>("Bounty", "Aktiv", true, L.Help("Nur der Host vergibt nach Abschluss aller Extraktionen Geld.")); multiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Bounty", "OrbMultiplikator", 1f, new ConfigDescription(L.Help("Wert aus dem Orb-Prefab mal Faktor."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>())); fallback = ((BaseUnityPlugin)this).Config.Bind<int>("Bounty", "ErsatzwertDollar", 0, new ConfigDescription(L.Help("Fehlender Orb-Wertebereich: 0 = keine Belohnung. Explizit deaktivierte Orb-Drops bleiben ohne Belohnung."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000000), Array.Empty<object>())); cap = ((BaseUnityPlugin)this).Config.Bind<int>("Bounty", "MaximumDollarProLevel", 0, new ConfigDescription(L.Help("Zweite Grenze: Ab diesem verdienten Bounty-Betrag gibt es keine Prämie mehr. 0 = beide Grenzen aus, unbegrenzt."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000000), Array.Empty<object>())); full = ((BaseUnityPlugin)this).Config.Bind<int>("Bounty", "VollePraemieBisDollar", cap.Value, new ConfigDescription(L.Help("Erste Grenze: Bis zu diesem bereits verdienten Betrag volle Prämie. Danach linear weniger bis MaximumDollarProLevel. Gleiche Grenzen = bisheriges hartes Limit."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000000), Array.Empty<object>())); overlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Anzeige", "Overlay", true, L.Help("Bounty-Übersicht oben mittig während der Jagd. Gäste benötigen für die Übersicht einen Host mit NM-Bounty ab 0.2.0.")); scale = ((BaseUnityPlugin)this).Config.Bind<float>("Anzeige", "Skalierung", 1f, new ConfigDescription(L.Help("Größe der Übersicht."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 1.5f), Array.Empty<object>())); top = ((BaseUnityPlugin)this).Config.Bind<float>("Anzeige", "AbstandOben", 30f, new ConfigDescription(L.Help("Abstand vom oberen Rand bei 1920x1080."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 800f), Array.Empty<object>())); rows = ((BaseUnityPlugin)this).Config.Bind<int>("Anzeige", "Gegnerzeilen", 4, new ConfigDescription(L.Help("Letzte 1–5 Gegnertypen; weitere werden zusammengefasst."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>())); page = CoreApi.Register(L.Describe(new AddonDefinition("nightmare.repo.bounty", "Bounty", "0.3.0", "Jagd nach der letzten Extraktion: Belohnung aus dem Orb-Wertebereich.", (Action<AddonUi>)Draw, 1), "Bounty", "Jagd nach der letzten Extraktion: Belohnung aus dem Orb-Wertebereich.")); subscription = CombatEvents.Subscribe(page, (Action<CombatEvent>)OnCombat); factorText = multiplier.Value.ToString(CultureInfo.InvariantCulture); fallbackText = fallback.Value.ToString(); capText = cap.Value.ToString(); fullText = full.Value.ToString(); } private static object? Read(object value, string field) { return CoreReflection.Field(value.GetType(), field)?.GetValue(value); } private void EnsureContext() { int num = CoreApi.Context.Scene; int num2 = (Object.op_Implicit((Object)(object)RunManager.instance) ? RunManager.instance.levelsCompleted : (-1)); object obj = (Object.op_Implicit((Object)(object)StatsManager.instance) ? StatsManager.instance.runStats : null); if (scene != num || level != num2 || room != PhotonNetwork.CurrentRoom || stats != obj) { scene = num; level = num2; room = PhotonNetwork.CurrentRoom; stats = obj; awarded.Clear(); ledger.Clear(); fault = ""; last = L.Capture(() => L.T("Noch keine Belohnung.")); display = null; hud.Dispose(); nextDisplay = 0f; } } private void Update() { if (!CoreRuntime.Run("nightmare.repo.bounty", (Action)Tick)) { HideFaultedDisplay(); } } private void Tick() { EnsureContext(); if (!(Time.unscaledTime < nextDisplay)) { nextDisplay = Time.unscaledTime + 0.5f; bool flag = BountyMath.ValidLimits(full.Value, cap.Value); double num = (flag ? BountyMath.Rate(ledger.Dollars, full.Value, cap.Value) : 0.0); int state = (Conflict ? 5 : ((fault.Length > 0 || !flag) ? 4 : ((!active.Value) ? 3 : (FinalPhase ? ((num != 0.0) ? 1 : 2) : 0)))); BountySnapshot local = ledger.Snapshot(CoreApi.Context.SceneName, Math.Max(0, level), state, num); display = displayLink.Exchange(local, Host, InLevel); hud.Show(display, overlay.Value, scale.Value, top.Value, rows.Value); } } private void HideFaultedDisplay() { hud.Dispose(); display = null; } private void OnCombat(CombatEvent e) { CoreRuntime.Run("nightmare.repo.bounty", (Action)delegate { HandleCombat(e); }); } private void HandleCombat(CombatEvent e) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if ((int)e.Kind != 0 || !active.Value || !Host || !FinalPhase || Conflict || !Object.op_Implicit((Object)(object)StatsManager.instance) || !Object.op_Implicit((Object)(object)PunManager.instance)) { return; } EnsureContext(); if (fault.Length > 0 || !awarded.Add(e.Id)) { return; } checked { try { if ((Object)(object)e.Health == (Object)null || (Object)(object)e.Enemy == (Object)null || !Object.op_Implicit((Object)(object)e.Health) || !Object.op_Implicit((Object)(object)e.Enemy)) { return; } int dollars = BountyMath.Reward(e.Health.spawnValuable ? OrbDollars(e.Enemy) : 0, ledger.Dollars, full.Value, cap.Value); if (dollars <= 0) { ledger.Add(e.Name, 0); last = L.Capture(() => e.Name + L.T(": $0 (kein Orb-Wert / Limit erreicht).")); return; } Dictionary<string, int> runStats = StatsManager.instance.runStats; int value; (int Units, int Remainder) money = BountyMath.Split(remainder: runStats.TryGetValue("nm.bounty.remainder.v1", out value) ? value : 0, dollars: dollars); int num = SemiFunc.StatGetRunCurrency() + money.Units; int num2 = SemiFunc.StatGetRunTotalHaul() + money.Units; if (money.Units > 0) { SemiFunc.StatSetRunCurrency(num); if (SemiFunc.StatGetRunCurrency() != num) { throw new InvalidOperationException(L.T("Gutschrift lokal nicht bestätigt.")); } SemiFunc.StatSetRunTotalHaul(num2); if (SemiFunc.StatGetRunTotalHaul() != num2) { throw new InvalidOperationException(L.T("Gesamtbeute lokal nicht bestätigt.")); } } PunManager.instance.SetRunStatSet("nm.bounty.remainder.v1", money.Remainder); if (!runStats.TryGetValue("nm.bounty.remainder.v1", out var value2) || value2 != money.Remainder) { throw new InvalidOperationException(L.T("Restbetrag lokal nicht bestätigt.")); } ledger.Add(e.Name, dollars); last = L.Capture(() => e.Name + " · +$" + dollars.ToString("N0") + L.T(" · Rest bis zum nächsten $1.000: $") + money.Remainder); ((BaseUnityPlugin)this).Logger.LogInfo((object)last); CombatEvents.PublishBounty(page, e, dollars); if (Object.op_Implicit((Object)(object)CurrencyUI.instance)) { CurrencyUI.instance.FetchCurrency(); } } catch (Exception ex) { Exception ex2 = ex; Exception ex3 = ex2; fault = L.Capture(() => L.T("Vergabe angehalten; keine automatische Wiederholung: ") + ex3.Message); ((BaseUnityPlugin)this).Logger.LogError((object)ex3); } } } private int OrbDollars(EnemyParent enemy) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown GameObject val = null; if (Object.op_Implicit((Object)(object)AssetManager.instance)) { val = (GameObject)((int)enemy.difficulty switch { 0 => AssetManager.instance.enemyValuableSmall, 2 => AssetManager.instance.enemyValuableBig, 1 => AssetManager.instance.enemyValuableMedium, _ => null, }); } ValuableObject val2 = (((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val)) ? val.GetComponent<ValuableObject>() : null); if ((Object)(object)val2 == (Object)null || !Object.op_Implicit((Object)(object)val2)) { return (int)Math.Min(1000000.0, (double)fallback.Value * (double)multiplier.Value); } if (Read(val2, "dollarValueOverride") is int num && num > 0) { return (int)Math.Min(1000000.0, (double)num * (double)multiplier.Value); } if (!Object.op_Implicit((Object)(object)val2.valuePreset)) { return (int)Math.Min(1000000.0, (double)fallback.Value * (double)multiplier.Value); } return BountyMath.Dollars(val2.valuePreset.valueMin, val2.valuePreset.valueMax, random.NextDouble(), multiplier.Value); } private void Draw(AddonUi ui) { GUILayout.Label("BOUNTY", ui.Heading, Array.Empty<GUILayoutOption>()); GUILayout.Label(Conflict ? L.T("Original Bounty Hunters ist geladen: NM-Auszahlung pausiert. Original und Fix entfernen.") : ((!Host) ? L.T("Nur der Host vergibt Geld. Deine Einstellungen gelten, wenn du selbst hostest.") : (FinalPhase ? L.T("Jagdphase aktiv") : L.T("Wartet auf Abschluss aller Extraktionen."))), ui.Notice, Array.Empty<GUILayoutOption>()); if (fault.Length > 0) { GUILayout.Label((string)fault, ui.Danger, Array.Empty<GUILayoutOption>()); } GUILayout.Label((string)last, ui.Body, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Eigene Host-Belohnungen dieses Levels: $") + ledger.Dollars.ToString("N0"), ui.Body, Array.Empty<GUILayoutOption>()); if (display != null) { GUILayout.Label(display.Text(5), ui.Body, Array.Empty<GUILayoutOption>()); } GUILayout.Label(L.T("Orb-Wertebereich des Spiels, pro Tod neu gewürfelt. Mod-eigene Sonderdrops sind nicht automatisch auslesbar. Normale Drops bleiben unverändert. Restbeträge unter $1.000 werden angespart und mit dem Spielstand gespeichert."), ui.Small, Array.Empty<GUILayoutOption>()); if (GUILayout.Button((active.Value ? "✓ " : "○ ") + L.T("Bounty aktiv"), ui.Button, Array.Empty<GUILayoutOption>())) { active.Value = !active.Value; } GUILayout.Label(L.T("Orb-Multiplikator (0–20)"), ui.Small, Array.Empty<GUILayoutOption>()); factorText = GUILayout.TextField(factorText, 12, ui.TextField, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Ersatzwert in Dollar (0 = keine Belohnung)"), ui.Small, Array.Empty<GUILayoutOption>()); fallbackText = GUILayout.TextField(fallbackText, 8, ui.TextField, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Grenze 1: volle Prämie bis zu diesem verdienten Bounty-Betrag ($)"), ui.Small, Array.Empty<GUILayoutOption>()); fullText = GUILayout.TextField(fullText, 8, ui.TextField, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Grenze 2: ab diesem Betrag keine Prämie ($; 0 = unbegrenzt)"), ui.Small, Array.Empty<GUILayoutOption>()); capText = GUILayout.TextField(capText, 8, ui.TextField, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Pro Kill zählt der Bounty-Stand vor der Vergabe. Dazwischen sinkt der Anteil linear. Beispiel: 10.000 / 20.000 → bei 15.000 gibt der nächste Kill 50 %. Gleiche Grenzen behalten das alte harte Limit."), ui.Small, Array.Empty<GUILayoutOption>()); if (GUILayout.Button(L.T("Einstellungen speichern"), ui.Button, Array.Empty<GUILayoutOption>())) { if (float.TryParse(factorText.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && !float.IsNaN(result) && result >= 0f && result <= 20f && int.TryParse(fallbackText, out var result2) && result2 >= 0 && result2 <= 1000000 && int.TryParse(fullText, out var result3) && int.TryParse(capText, out var result4) && BountyMath.ValidLimits(result3, result4)) { multiplier.Value = result; fallback.Value = result2; cap.Value = result4; full.Value = result3; last = L.Capture(() => L.T("Einstellungen gespeichert. Bereits verdientes Geld bleibt erhalten.")); } else { last = L.Capture(() => L.T("Ungültige Werte: Grenze 1 darf nicht über Grenze 2 liegen (außer Grenze 2 = 0).")); } } GUILayout.Label(L.T("ANZEIGE (nur für dich)"), ui.Heading, Array.Empty<GUILayoutOption>()); if (GUILayout.Button((overlay.Value ? "✓ " : "○ ") + L.T("Bounty-Overlay anzeigen"), ui.Button, Array.Empty<GUILayoutOption>())) { overlay.Value = !overlay.Value; } Slider(ui, L.T("Größe"), scale, 0.5f, 1.5f); Slider(ui, L.T("Abstand oben"), top, 0f, 800f); GUILayout.Label(L.T("Gegnerzeilen: ") + rows.Value, ui.Small, Array.Empty<GUILayoutOption>()); rows.Value = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)rows.Value, 1f, 5f, Array.Empty<GUILayoutOption>())); GUILayout.Label(L.T("Summen beziehen sich auf die Jagd nach der letzten Extraktion. Weitere Gegnertypen werden zusammengefasst; $0-Kills zählen mit. Gespeicherte Restbeträge zählen als verdiente Prämie, auch wenn die nächste $1.000-Gutschrift noch aussteht."), ui.Small, Array.Empty<GUILayoutOption>()); } private static void Slider(AddonUi ui, string title, ConfigEntry<float> entry, float min, float max) { GUILayout.Label(title + ": " + entry.Value.ToString("0.0"), ui.Small, Array.Empty<GUILayoutOption>()); float num = GUILayout.HorizontalSlider(entry.Value, min, max, Array.Empty<GUILayoutOption>()); if (Math.Abs(num - entry.Value) > 0.001f) { entry.Value = num; } } private void OnDestroy() { subscription?.Dispose(); AddonHandle obj = page; if (obj != null) { obj.Dispose(); } hud.Dispose(); displayLink.Dispose(); } } }