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 Upgrade Share REPO v0.6.0
BepInEx/plugins/NM_Upgrade_Share_REPO/NM_Upgrade_Share_REPO.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Nightmare.REPO.Core; using Nightmare.REPO.Localization; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; [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.6.0.0")] [assembly: AssemblyInformationalVersion("0.6.0")] [assembly: AssemblyProduct("NM_Upgrade_Share_REPO")] [assembly: AssemblyTitle("NM_Upgrade_Share_REPO")] [assembly: AssemblyVersion("0.2.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) { { "Charakter wird geladen.", "Character is loading." }, { "Wartet auf abgeschlossene Ladeanimation.", "Waiting for the loading animation to finish." }, { "Spielerverbindung noch nicht bereit.", "Player connection is not ready yet." }, { "Erkannt / getrackt; noch keine geprüfte Vergabe-Anbindung.", "Detected / tracked; no verified grant integration yet." }, { "REPOLib SetLevel fehlt.", "REPOLib SetLevel is missing." }, { "More Upgrades: eigene Team-/Host-Synchronisierung ausschalten, damit NM verteilen kann.", "More Upgrades: disable its team/host synchronization so NM can distribute upgrades." }, { "Upgrade-Vergabe nicht verfügbar.", "Upgrade distribution is unavailable." }, { "Spiel-Netzwerk nicht bereit.", "Game network is not ready." }, { "Unbekannte Upgrade-Routine.", "Unknown upgrade routine." }, { "Vergabe lokal nicht bestätigt; keine automatische Wiederholung.", "Grant not confirmed locally; no automatic retry." }, { "Zu viele Upgrade-Typen für die Statistikübertragung (max. 128).", "Too many upgrade types for statistics transfer (max. 128)." }, { "Statistik zu groß für die Übertragung.", "Statistics are too large to transmit." }, { "Statistiktext zu lang.", "Statistics text is too long." }, { "Vom aktuellen Host · Erfassung seit NM-Statistikbeginn", "From the current host · recorded since NM statistics started" }, { "Host-Meldung vor ", "Host report received " }, { " s · seit NM-Statistikbeginn", " s ago · since NM statistics started" }, { "Late-Join-Status nicht lesbar; Vergabe wartet.", "Cannot read late-join status; distribution is waiting." }, { "Unbekannt", "Unknown" }, { "Late-Join-Status vorübergehend nicht verfügbar.", "Late-join status is temporarily unavailable." }, { "Ungültige alte Offset-Datei.", "Invalid legacy offset file." }, { "Ganze Zahl von 0–10000 benötigt: ", "An integer from 0–10000 is required: " }, { "STATISTIK & REGELN", "STATISTICS & RULES" }, { "Vorab-Konfiguration für deine eigenen Host-Runden. Speichern verändert keine fremde Lobby und vergibt jetzt keine Upgrades.", "Preconfigure your own hosted games. Saving does not change someone else's lobby or grant upgrades now." }, { "Erhaltene Upgrades kurz einblenden", "Briefly show received upgrades" }, { "Der Host erfasst und verteilt. Hier siehst du deine eigenen Herkunftsdaten und seine Regeln.", "The host tracks and distributes upgrades. Your own upgrade history and the host's rules appear here." }, { "Statistik: ", "Statistics: " }, { "VERTEILUNG VERWALTEN", "MANAGE DISTRIBUTION" }, { "Nach Korrektur erneut prüfen (keine Wiederholung alter Vergaben)", "Check again after correcting the issue (do not repeat previous grants)" }, { "Verteilung aktiv", "Distribution enabled" }, { "NM-Vorgaben: 33 individuell festgelegte Upgrade-Regeln. Neue Config-Einträge nutzen diese Werte automatisch. Bestehende Einstellungen bleiben erhalten; der folgende Knopf ersetzt bewusst die 33 bekannten Regeln. Unbekannte Mod-Typen bleiben unverändert.", "NM defaults: 33 individually configured upgrade rules. New config entries use these values automatically. Existing settings are retained; the button below explicitly replaces the 33 known rules. Unknown mod types remain unchanged." }, { "33 NM-Vorgaben übernehmen (bestehende Regeln ersetzen)", "Apply 33 NM defaults (replace existing rules)" }, { "NM-Vorgaben gespeichert. Gilt für neue Verteilungen und künftiges Nachholen. Vorherige Config: .before-nm-defaults.bak", "NM defaults saved. Applies to new distributions and future catch-up. Previous config: .before-nm-defaults.bak" }, { "Übernahme nicht vollständig abgeschlossen: ", "Could not finish applying defaults: " }, { "Käufer: Original garantiert. Andere: je ein Upgrade bei Erfolg. Chancen und Limits zählen reguläre Stufen ohne bekannte persönliche Offsets. REPOLib-Mod-Upgrades benötigen ihre Originalmods auch beim Empfänger.", "Buyer: original upgrade guaranteed. Others: one upgrade per successful roll. Chances and limits count regular levels, excluding known personal offsets. Recipients need the original mods for REPOLib mod upgrades." }, { "Alte Spielstände: Frühere Käufe sind unbekannt. Bei fehlender Historie kannst du unten den Late-Join-Nachholstand pro Upgrade und Spielstand korrigieren. Durchschnitt nutzt vorhandene reguläre Stände. Unbekannte Änderungen fremder Mods können nicht automatisch als private Offsets erkannt werden.", "Old saves: previous purchases are unknown. If history is missing, correct the late-join catch-up total for each upgrade and save below. Average uses existing regular levels. Changes from other mods cannot automatically be identified as private offsets." }, { "Suche nach Upgrade", "Search upgrades" }, { "Spiel", "Game" }, { "Fremdmod / nur Tracking", "Other mod / tracking only" }, { " · Hinweis", " · Notice" }, { "Ungültige gespeicherte Regel: ", "Invalid saved rule: " }, { " Neue gültige Werte speichern.", " Save new valid values." }, { "Standard-Upgrades sind vorab einstellbar. Mod-Upgrades erscheinen nach Registrierung oder aus bereits gespeicherten Regeln.", "Standard upgrades can be configured in advance. Mod upgrades appear after registration or from previously saved rules." }, { "Vergabe unterstützt · ", "Grant supported · " }, { "Spiel-Upgrade", "Game upgrade" }, { "REPOLib; Verwendung wird am registrierten Gegenstand und der bestätigten Stufenänderung erkannt.", "REPOLib; use is detected from the registered item and confirmed level change." }, { "NM-Standard für dieses Upgrade in den Entwurf laden", "Load the NM default for this upgrade into the draft" }, { "Vorgabe geladen. Zum Übernehmen die Regel unten speichern.", "Default loaded. Save the rule below to apply it." }, { "Dieses Upgrade teilen", "Share this upgrade" }, { "Garantiert bis reguläre Stufe", "Guaranteed up to regular level" }, { "Teilungs-Maximum (0 = unbegrenzt)", "Sharing maximum (0 = unlimited)" }, { "Chancenmodus: ", "Chance mode: " }, { "Startchance in %", "Starting chance in %" }, { "Abnahme in Prozentpunkten pro Stufe", "Decrease in percentage points per level" }, { "Mindestchance in %", "Minimum chance in %" }, { "Nächste Stufe=Chance; z. B. 21=90;31=50;41=0", "Next level=chance; e.g. 21=90;31=50;41=0" }, { " (klicken zum Wechseln)", " (click to change)" }, { "Aus · Garantie · Garantie plus individuelle Zufallswürfe · Durchschnitt vorhandener Spieler (abgerundet). Wiederbeitritt würfelt bereits abgearbeitete Ereignisse nicht erneut.", "Off · Guarantee · Guarantee plus individual random rolls · Average of existing players (rounded down). Rejoining does not reroll processed events." }, { "Regel für dieses Upgrade speichern", "Save rule for this upgrade" }, { "Gespeichert. Gilt für neue Verteilungen und künftiges Nachholen.", "Saved. Applies to new distributions and future catch-up." }, { "Spieler · regulär + Offset = Gesamt · nächste Chance", "Players · regular + offset = total · next chance" }, { "Offset-Anbindung noch nicht bereit.", "Offset integration is not ready yet." }, { " Verteilung wartet: ", " Distribution waiting: " }, { "Seit NM-Tracking verwendete Gegenstände dieses Typs: ", "Items of this type used since NM tracking started: " }, { "Letzte Verteilungen / Käufe", "Recent distributions / purchases" }, { "LATE-JOIN-NACHHOLSTAND · DIESER SPIELSTAND", "LATE-JOIN CATCH-UP TOTAL · THIS SAVE" }, { "Aktuell: ", "Current: " }, { " · manuell korrigierte Basis", " · manually corrected baseline" }, { " · automatische Zählung", " · automatic count" }, { "Gesamtzahl der Nachholversuche, keine zusätzlichen garantierten Stufen. Beispiel: Nachholstand 15 und Garantie 10 ergeben bei einem neuen Spieler mit 0 regulären Stufen 10 sichere Stufen und 5 weitere Chancen. Dafür Late Join auf GarantieUndZufall stellen und die Regel speichern. Chance, Teilungs-Maximum und persönliche Offsets gelten weiter.", "Total number of catch-up attempts, not additional guaranteed levels. Example: a catch-up total of 15 and a guarantee of 10 give a new player with 0 regular levels 10 guaranteed levels and 5 additional chances. Set Late Join to GuaranteeAndRandom and save the rule. Chance, sharing maximum and personal offsets still apply." }, { "Korrektur erst als Host bei fertig geladenem Spielstand und fehlerfreier Verteilung möglich.", "Correction requires you to host a fully loaded save with error-free distribution." }, { "Nachholstand gesamt (0–10000)", "Total catch-up attempts (0–10000)" }, { "Nachholstand für diesen Spielstand übernehmen", "Apply catch-up total to this save" }, { "Bitte eine ganze Zahl von 0–10000 eingeben.", "Enter an integer from 0–10000." }, { "Übernommen. Gilt für kommende Nachholvorgänge; wird mit der nächsten Spielspeicherung dauerhaft gespeichert.", "Applied to future catch-up; persisted with the next game save." }, { "Wieder nur tatsächlich erfasste Käufe zählen", "Return to counting only recorded purchases" }, { "Automatische Zählung aktiv. Bereits erledigte Chancen bleiben erledigt; keine Stufen werden entzogen.", "Automatic counting enabled. Processed chances stay processed; no levels are removed." }, { "Echte Käufe erhöhen den Nachholstand danach automatisch. Bereits fertig beigetretene Spieler bekommen durch die Korrektur nichts erneut. Laden neue Spieler noch, nutzen sie den korrigierten Stand nach der Wartezeit. Erledigte Chancen werden beim Wiederbeitritt oder erneuten Ändern nicht wiederholt. Kaufzähler und vorhandene Upgrade-Stufen bleiben unverändert.", "Actual purchases automatically increase the catch-up total afterwards. Established players receive nothing again because of this correction. Players still loading use the corrected total after the waiting period. Processed chances are not repeated on rejoin or further edits. Purchase counters and existing upgrade levels remain unchanged." }, { "Warte auf einen Spielstand.", "Waiting for a save." }, { "Vorhandene Upgrade-Typen konnten nicht vorab gelesen werden: ", "Could not read existing upgrade types in advance: " }, { "Upgrade-Verteilung als Host. Selbst benutzte Upgrades bleiben unverändert.", "Host upgrade distribution. Personally used upgrades remain unchanged." }, { "Zusätzliche Sekunden nach vollständig bereitem Charakter und abgeschlossener Late-Join-Synchronisierung (1–30).", "Additional seconds after the character is fully ready and late-join synchronization has finished (1–30)." }, { "Individuelle Chancen, Late-Join-Ausgleich und getrennte persönliche Offsets.", "Individual chances, late-join catch-up and separate personal offsets." }, { "Nachholstand kann nur als Host im fertig geladenen aktuellen Spielstand gesetzt werden.", "The catch-up total can only be set by the host in the fully loaded current save." }, { ": Late-Join-Nachholstand ", ": late-join catch-up total " }, { " (manuell korrigiert).", " (manually corrected)." }, { " (automatische Zählung).", " (automatic count)." }, { "Vorgaben können nur im Hauptmenü oder als Host übernommen werden.", "Defaults can only be applied in the main menu or as host." }, { "Vorab-Konfiguration; Vergabe-Anbindung wird in der Runde geprüft.", "Preconfiguration; grant integration will be checked in the game." }, { "Wartet auf fertig geladenen Spielstand.", "Waiting for the save to finish loading." }, { "Nur der Host verteilt Upgrades.", "Only the host distributes upgrades." }, { "Wartet auf Spieler-Identitäten.", "Waiting for player identities." }, { "Charakter bereit · noch ", "Character ready · " }, { " s Wartezeit", " s remaining" }, { "Wartet auf Offset-Anbindung / Ausgleich.", "Waiting for offset integration / catch-up." }, { "SharedUpgradesPlus ist noch geladen. NM-Verteilung pausiert; alten Sharing-Mod entfernen.", "SharedUpgradesPlus is still loaded. NM distribution is paused; remove the old sharing mod." }, { "Host aktiv · ", "Host active · " }, { " Upgrade-Typen erkannt. ", " upgrade types detected. " }, { "Host-Tools verbunden.", "Host Tools connected." }, { "Ohne Host-Tools; gespeicherte bekannte Offsets bleiben geschützt.", "Without Host Tools; saved known offsets remain protected." }, { "Verteilung aus; Käufe werden weiter gezählt.", "Distribution disabled; purchases are still counted." }, { ": Gegenstand verbraucht, aber keine passende Mod-Vergabe bestätigt; nicht geteilt.", ": item consumed, but no matching mod grant was confirmed; not shared." }, { "Geteilt", "Shared" }, { ": benutzt von ", ": used by " }, { "; Ereignis ", "; event " }, { "Statistikbasis noch nicht bereit.", "Statistics baseline is not ready yet." }, { "Verteilung angehalten: ", "Distribution stopped: " }, { "Prüfung wird wiederholt. Bereits abgearbeitete Vergaben bleiben abgeschlossen.", "Checking again. Previously processed grants remain completed." }, { "Jeder andere Spieler erhält bei Erfolg genau eine Stufe. Käufer bekommt das Original immer.", "Each other player receives exactly one level on success. The buyer always receives the original." }, { "Regulärer eigener Stand ohne private Offsets.", "Own regular level without private offsets." }, { "Maximaler regulärer Stand durch Teilen; 0 = unbegrenzt. Selbst benutzte Upgrades bleiben frei.", "Maximum regular level from sharing; 0 = unlimited. Personally used upgrades remain unrestricted." }, { "Chance für die erste Stufe nach Garantie.", "Chance for the first level after the guarantee." }, { "Prozentpunkte je erfolgreich erreichter regulärer Stufe; Fehlschläge senken die Chance nicht.", "Percentage points per successfully reached regular level; failures do not reduce the chance." }, { "Untergrenze für lineare Abnahme.", "Lower bound for the linear decrease." }, { "Linear oder feste Bereiche.", "Linear or fixed bands." }, { "Aus / Garantie / GarantieUndZufall / Durchschnitt.", "Aus = Off / Garantie = Guarantee / GarantieUndZufall = GuaranteeAndRandom / Durchschnitt = Average." }, { "Nächste Stufe=Chance in Prozent. Vor dem ersten Bereich gilt Startchance. Garantie hat Vorrang.", "Next level=chance in percent. Starting chance applies before the first band. Guarantee takes priority." }, { "Nachholstand: 0–10000.", "Catch-up total: 0–10000." }, { "Grenzen: 0–10000; Maximum 0 = unbegrenzt, sonst mindestens Garantiegrenze.", "Limits: 0–10000; maximum 0 = unlimited, otherwise at least the guarantee threshold." }, { "Chancen: 0–100 %, Mindestchance höchstens Startchance.", "Chances: 0–100%; minimum chance must not exceed starting chance." }, { "Bereiche z. B. 21=90;31=50;41=0. Zahlen links sind die nächsten Upgrade-Stufen.", "Bands, e.g. 21=90;31=50;41=0. Numbers on the left are the next upgrade levels." }, { "Kurze Meldung über neue geteilte / Late-Join-Upgrades für dich. Keine Meldung für bereits vorhandene Zähler.", "Brief notification of new shared / late-join upgrades for you. No notification for pre-existing counters." }, { "Teilen an", "Sharing enabled" }, { "Teilen pausiert/aus", "Sharing paused/disabled" }, { " · Garantie bis ", " · Guaranteed up to " }, { " · Maximum ", " · Maximum " }, { "unbegrenzt", "unlimited" }, { "Start ", "Start " }, { " Prozentpunkte/Stufe, mindestens ", " percentage points/level, minimum " }, { "Bereiche ", "Bands " }, { "Vom Host erfasst · seit NM-Statistikbeginn", "Recorded by the host · since NM statistics started" }, { " durch Teilen", " from sharing" }, { " durch Late Join", " from late join" }, { " · weitere in deiner Statistik", " · more in your statistics" }, { "Statistikübertragung vorübergehend nicht verfügbar: ", "Statistics transfer is temporarily unavailable: " }, { "Upgrade-Konfiguration ist unerwartet groß.", "Upgrade configuration is unexpectedly large." }, { "Bereiche", "Bands" }, { "Aus", "Off" }, { "Garantie", "Guarantee" }, { "GarantieUndZufall", "GuaranteeAndRandom" }, { "Durchschnitt", "Average" } }; [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.UpgradeShare { internal static class DefaultRules { private static readonly Dictionary<string, ShareRules> presets = new Dictionary<string, ShareRules>(StringComparer.Ordinal) { ["playerUpgradeHealth"] = new ShareRules { Enabled = true, Guaranteed = 20, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeStamina"] = new ShareRules { Enabled = true, Guaranteed = 20, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeStrength"] = new ShareRules { Enabled = true, Guaranteed = 10, Maximum = 0, Start = 90.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeSpeed"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 80.0, Drop = 20.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeRange"] = new ShareRules { Enabled = true, Guaranteed = 10, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeThrow"] = new ShareRules { Enabled = true, Guaranteed = 10, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeExtraJump"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeLaunch"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeTumbleClimb"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeTumbleWings"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeCrouchRest"] = new ShareRules { Enabled = true, Guaranteed = 10, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeDeathHeadBattery"] = new ShareRules { Enabled = true, Guaranteed = 10, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeMapPlayerCount"] = new ShareRules { Enabled = true, Guaranteed = 1, Maximum = 1, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeArmor"] = new ShareRules { Enabled = true, Guaranteed = 10, Maximum = 0, Start = 90.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeAutoscan"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeExtra Life"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeExtraInventorySlot"] = new ShareRules { Enabled = true, Guaranteed = 1, Maximum = 3, Start = 75.0, Drop = 25.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeExtraLife"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeHeartOfGold"] = new ShareRules { Enabled = true, Guaranteed = 1, Maximum = 0, Start = 90.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeInventorySlot"] = new ShareRules { Enabled = true, Guaranteed = 1, Maximum = 3, Start = 75.0, Drop = 25.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeItem Resist"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 80.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeItem Value"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 80.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeMap Cosmetics Tracker"] = new ShareRules { Enabled = false, Guaranteed = 1, Maximum = 1, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeMap Enemy Tracker"] = new ShareRules { Enabled = false, Guaranteed = 1, Maximum = 1, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeMap Player Tracker"] = new ShareRules { Enabled = false, Guaranteed = 1, Maximum = 1, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeMap Zoom"] = new ShareRules { Enabled = false, Guaranteed = 20, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeObjectDurability"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 80.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeObjectValue"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 80.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeOvercharge"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 80.0, Drop = 10.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeRegeneration"] = new ShareRules { Enabled = true, Guaranteed = 1, Maximum = 5, Start = 80.0, Drop = 20.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.Garantie, Bands = "21=90;31=50;41=0" }, ["playerUpgradeSprint Usage"] = new ShareRules { Enabled = true, Guaranteed = 5, Maximum = 0, Start = 90.0, Drop = 5.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeValuable Count"] = new ShareRules { Enabled = true, Guaranteed = 3, Maximum = 0, Start = 80.0, Drop = 20.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" }, ["playerUpgradeValuableDensity"] = new ShareRules { Enabled = true, Guaranteed = 3, Maximum = 0, Start = 80.0, Drop = 20.0, Minimum = 0.0, Mode = ChanceMode.Linear, Join = JoinMode.GarantieUndZufall, Bands = "21=90;31=50;41=0" } }; internal static IEnumerable<string> Keys => presets.Keys; internal static ShareRules For(string key) { if (!presets.TryGetValue(key, out ShareRules value)) { return new ShareRules(); } return value.Copy(); } } internal sealed class UpgradeType { internal string Key = ""; internal string Name = ""; internal string Problem = ""; internal bool Native; internal object? RepoObject; internal Item? SourceItem; internal MethodInfo? SetLevel; internal Dictionary<string, int> Counts; internal int Count(string id) { if (!Counts.TryGetValue(id, out var value)) { return 0; } return value; } } internal static class GameBridge { internal static readonly string[] Native = new string[13] { "Health", "Stamina", "ExtraJump", "Launch", "TumbleClimb", "TumbleWings", "DeathHeadBattery", "MapPlayerCount", "Speed", "Strength", "Range", "Throw", "CrouchRest" }; internal static bool Host { get { if (Object.op_Implicit((Object)(object)GameManager.instance)) { return SemiFunc.IsMasterClientOrSingleplayer(); } return false; } } internal static bool Ready { get { bool flag = default(bool); int num; if (Host && Object.op_Implicit((Object)(object)StatsManager.instance) && StatsManager.instance.statsSynced && Object.op_Implicit((Object)(object)RunManager.instance) && !SemiFunc.MenuLevel()) { object obj = Read(StatsManager.instance, "saveFileReady"); if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } } else { num = 0; } if (((uint)num & (flag ? 1u : 0u)) != 0 && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated) { return Object.op_Implicit((Object)(object)PunManager.instance); } return false; } } internal static string Save { get { if (!Object.op_Implicit((Object)(object)StatsManager.instance)) { return ""; } return (Read(StatsManager.instance, "saveFileCurrent") as string) ?? ""; } } internal static SortedDictionary<string, Dictionary<string, int>> Dictionaries => (SortedDictionary<string, Dictionary<string, int>>)Read(StatsManager.instance, "dictionaryOfDictionaries"); internal static string LocalId { get { if (!Object.op_Implicit((Object)(object)PlayerAvatar.instance)) { return ""; } return SemiFunc.PlayerGetSteamID(PlayerAvatar.instance); } } internal static bool LocalReady { get { string reason; if (Object.op_Implicit((Object)(object)GameManager.instance) && Object.op_Implicit((Object)(object)StatsManager.instance) && StatsManager.instance.statsSynced && Object.op_Implicit((Object)(object)RunManager.instance) && !SemiFunc.MenuLevel() && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated) { return PlayerReady(PlayerAvatar.instance, out reason); } return false; } } internal static object? Read(object obj, string field) { return CoreReflection.Field(obj.GetType(), field)?.GetValue(obj); } internal static Dictionary<string, PlayerAvatar> Players() { return (from p in SemiFunc.PlayerGetAll() where Object.op_Implicit((Object)(object)p) && !string.IsNullOrWhiteSpace(SemiFunc.PlayerGetSteamID(p)) select p).GroupBy((Func<PlayerAvatar, string>)SemiFunc.PlayerGetSteamID).ToDictionary((IGrouping<string, PlayerAvatar> g) => g.Key, (IGrouping<string, PlayerAvatar> g) => g.First()); } internal static int ConnectionId(PlayerAvatar player) { if (!Object.op_Implicit((Object)(object)player.photonView)) { return 0; } return player.photonView.OwnerActorNr; } internal static bool PlayerReady(PlayerAvatar player, out string reason) { reason = L.T("Charakter wird geladen."); if (!Object.op_Implicit((Object)(object)player) || !((Component)player).gameObject.activeInHierarchy || !Object.op_Implicit((Object)(object)player.playerHealth) || !Object.op_Implicit((Object)(object)player.physGrabber) || !Object.op_Implicit((Object)(object)player.playerAvatarVisuals)) { return false; } object obj = Read(player, "spawned"); int expected; if (obj is bool && (bool)obj) { obj = Read(player, "spawnDoneImpulse"); if (obj is bool && !(bool)obj) { if (Object.op_Implicit((Object)(object)RunManager.instance)) { obj = Read(RunManager.instance, "skipLoadingUI"); if (!(obj is bool) || !(bool)obj) { expected = ((SemiFunc.RunIsLevel() || SemiFunc.RunIsShop() || SemiFunc.RunIsArena()) ? 1 : 0); goto IL_00c9; } } expected = 0; goto IL_00c9; } } return false; IL_00c9: obj = Read(player, "levelAnimationCompleted"); if (!LoadingReadiness.AnimationReady((byte)expected != 0, obj is bool && (bool)obj)) { reason = L.T("Wartet auf abgeschlossene Ladeanimation."); return false; } if (GameManager.Multiplayer()) { PhotonView photonView = player.photonView; if (!Object.op_Implicit((Object)(object)photonView) || photonView.ViewID == 0 || photonView.Owner == null || photonView.Owner.IsInactive || PhotonNetwork.CurrentRoom == null || !PhotonNetwork.CurrentRoom.Players.ContainsKey(photonView.OwnerActorNr)) { reason = L.T("Spielerverbindung noch nicht bereit."); return false; } if (Chainloader.PluginInfos.TryGetValue("zichen.latejoinnow", out var value) && !LateJoinReadiness.Ready(((object)value.Instance).GetType(), photonView.OwnerActorNr, out reason)) { return false; } } reason = ""; return true; } internal static Dictionary<string, UpgradeType> Discover() { Dictionary<string, UpgradeType> dictionary = new Dictionary<string, UpgradeType>(); foreach (KeyValuePair<string, Dictionary<string, int>> item in Dictionaries.Where<KeyValuePair<string, Dictionary<string, int>>>((KeyValuePair<string, Dictionary<string, int>> p) => p.Key.StartsWith("playerUpgrade", StringComparison.Ordinal))) { string text = item.Key.Substring(13); dictionary[item.Key] = new UpgradeType { Key = item.Key, Name = text, Counts = item.Value, Native = Native.Contains(text), Problem = (Native.Contains(text) ? "" : "Erkannt / getrackt; noch keine geprüfte Vergabe-Anbindung.") }; } Type type = AccessTools.TypeByName("REPOLib.Modules.Upgrades"); if (type != null && AccessTools.Field(type, "_playerUpgrades")?.GetValue(null) is IDictionary dictionary2) { foreach (DictionaryEntry item2 in dictionary2) { if (item2.Value == null) { continue; } string text2 = "playerUpgrade" + item2.Key; Dictionary<string, int> dictionary3 = Read(item2.Value, "PlayerDictionary") as Dictionary<string, int>; if (dictionary3 != null) { if (Dictionaries.TryGetValue(text2, out Dictionary<string, int> value) && dictionary3 != value) { AccessTools.Field(item2.Value.GetType(), "PlayerDictionary").SetValue(item2.Value, value); dictionary3 = value; } MethodInfo methodInfo = AccessTools.Method(item2.Value.GetType(), "SetLevel", new Type[2] { typeof(string), typeof(int) }, (Type[])null); if (!dictionary.TryGetValue(text2, out var value2)) { UpgradeType obj = new UpgradeType { Key = text2, Name = (item2.Key.ToString() ?? text2) }; value2 = obj; dictionary[text2] = obj; } value2.RepoObject = item2.Value; value2.SetLevel = methodInfo; value2.Counts = dictionary3; ref Item? sourceItem = ref value2.SourceItem; object? obj2 = Read(item2.Value, "Item"); sourceItem = (Item?)((obj2 is Item) ? obj2 : null); if (!value2.Native) { value2.Problem = ((methodInfo == null) ? "REPOLib SetLevel fehlt." : ""); } } } } if (Chainloader.PluginInfos.TryGetValue("bulletbot.moreupgrades", out var value3) && ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)value3.Instance.Config).Any(delegate(KeyValuePair<ConfigDefinition, ConfigEntryBase> c) { bool flag = default(bool); int num; if (c.Key.Key == "Allow Team Upgrades" || c.Key.Key == "Sync Host Upgrades") { object boxedValue = c.Value.BoxedValue; if (boxedValue is bool) { flag = (bool)boxedValue; num = 1; } else { num = 0; } } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; })) { foreach (UpgradeType item3 in dictionary.Values.Where((UpgradeType t) => !t.Native)) { item3.Problem = "More Upgrades: eigene Team-/Host-Synchronisierung ausschalten, damit NM verteilen kann."; } } return dictionary; } internal static string ItemKey(ItemUpgrade item, IEnumerable<UpgradeType> types) { ItemAttributes component = ((Component)item).GetComponent<ItemAttributes>(); Item source = (Item)(Object.op_Implicit((Object)(object)component) ? /*isinst with value type is only supported in some contexts*/: null); if (!Object.op_Implicit((Object)(object)source)) { return ""; } UpgradeType[] array = types.Where((UpgradeType t) => Object.op_Implicit((Object)(object)t.SourceItem) && (Object)(object)t.SourceItem == (Object)(object)source).Take(2).ToArray(); if (array.Length != 1) { return ""; } return array[0].Key; } internal static void Grant(UpgradeType type, string player, int amount) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (!Host || amount <= 0 || type.Problem.Length > 0) { throw new InvalidOperationException(L.T("Upgrade-Vergabe nicht verfügbar.")); } int num = checked(type.Count(player) + amount); if (type.Native) { if (GameManager.Multiplayer()) { PhotonView component = ((Component)PunManager.instance).GetComponent<PhotonView>(); if (!PhotonNetwork.InRoom || !Object.op_Implicit((Object)(object)component) || component.ViewID == 0) { throw new InvalidOperationException(L.T("Spiel-Netzwerk nicht bereit.")); } component.RPC("TesterUpgradeCommandRPC", (RpcTarget)0, new object[3] { player, type.Key.Substring(13), amount }); } else { PunManager.instance.TesterUpgradeCommandRPC(player, type.Key.Substring(13), amount, default(PhotonMessageInfo)); } } else { if (!(type.SetLevel != null) || type.RepoObject == null) { throw new InvalidOperationException(L.T("Unbekannte Upgrade-Routine.")); } type.SetLevel.Invoke(type.RepoObject, new object[2] { player, num }); } if (type.Count(player) != num) { throw new InvalidOperationException(L.T("Vergabe lokal nicht bestätigt; keine automatische Wiederholung.")); } } } internal enum HistorySend { None, Full, Heartbeat } internal sealed class HistoryDelivery { internal UpgradeHistorySnapshot? Last; internal int Sequence; private float fullAt; private float sentAt; internal HistorySend Due(UpgradeHistorySnapshot value, float now, bool modern) { if (Last == null || now < sentAt || now - fullAt >= (float)(modern ? 60 : 4) || !Same(Last, value)) { return HistorySend.Full; } if (!modern || !(now - sentAt >= 10f)) { return HistorySend.None; } return HistorySend.Heartbeat; } internal void Sent(UpgradeHistorySnapshot value, int sequence, float now, HistorySend kind) { sentAt = now; if (kind == HistorySend.Full) { Last = value; Sequence = sequence; fullAt = now; } } internal static bool Same(UpgradeHistorySnapshot a, UpgradeHistorySnapshot b) { if (a.Session != b.Session || a.Rows.Count != b.Rows.Count) { return false; } for (int i = 0; i < a.Rows.Count; i++) { UpgradeHistoryRow val = a.Rows[i]; UpgradeHistoryRow val2 = b.Rows[i]; if (val.Key != val2.Key || val.Name != val2.Name || val.Initial != val2.Initial || val.Collected != val2.Collected || val.Shared != val2.Shared || val.LateJoin != val2.LateJoin || val.Offset != val2.Offset || val.OffsetKnown != val2.OffsetKnown || val.Total != val2.Total || val.ChancePercent != val2.ChancePercent || val.Rule != val2.Rule) { return false; } } return true; } } internal static class HistoryPresentation { private static readonly string[] RuleWords = new string[11] { "Teilen pausiert/aus", "Teilen an", " · Garantie bis ", " · Maximum ", "unbegrenzt", " Prozentpunkte/Stufe, mindestens ", "GarantieUndZufall", "Durchschnitt", "Garantie", "Aus", "Bereiche " }; internal static UpgradeHistorySnapshot? Localize(UpgradeHistorySnapshot? snapshot) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (snapshot == null || L.Language == "de") { return snapshot; } return new UpgradeHistorySnapshot(snapshot.Session, L.T(snapshot.Source), ((IEnumerable<UpgradeHistoryRow>)snapshot.Rows).Select((Func<UpgradeHistoryRow, UpgradeHistoryRow>)((UpgradeHistoryRow row) => new UpgradeHistoryRow(row.Key, row.Name, row.Initial, row.Collected, row.Shared, row.LateJoin, row.Offset, row.OffsetKnown, row.Total, row.ChancePercent, Rule(row.Rule))))); } private static string Rule(string rule) { if (!rule.StartsWith("Teilen an · ", StringComparison.Ordinal) && !rule.StartsWith("Teilen pausiert/aus · ", StringComparison.Ordinal)) { return rule; } foreach (KeyValuePair<string, string> translation in L.Translations) { if (translation.Key.Length > 35 && rule.EndsWith(" · " + translation.Key, StringComparison.Ordinal)) { rule = rule.Substring(0, rule.Length - translation.Key.Length) + translation.Value; break; } } string[] ruleWords = RuleWords; foreach (string text in ruleWords) { rule = rule.Replace(text, L.T(text)); } return rule; } } internal static class HistoryProtocol { internal const int MaxBytes = 60000; internal const int MaxRows = 128; internal static byte[] Encode(UpgradeHistorySnapshot snapshot) { if (snapshot.Rows.Count > 128) { throw new InvalidDataException(L.T("Zu viele Upgrade-Typen für die Statistikübertragung (max. 128).")); } using MemoryStream memoryStream = new MemoryStream(); using BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true); binaryWriter.Write(1); Text(binaryWriter, snapshot.Session, 64); binaryWriter.Write(snapshot.Rows.Count); foreach (UpgradeHistoryRow row in snapshot.Rows) { Text(binaryWriter, row.Key, 180); Text(binaryWriter, row.Name, 180); binaryWriter.Write(row.Initial); binaryWriter.Write(row.Collected); binaryWriter.Write(row.Shared); binaryWriter.Write(row.LateJoin); binaryWriter.Write(row.Offset); binaryWriter.Write(row.OffsetKnown); binaryWriter.Write(row.Total); binaryWriter.Write(row.ChancePercent); Text(binaryWriter, row.Rule, 1200); } if (memoryStream.Length > 60000) { throw new InvalidDataException(L.T("Statistik zu groß für die Übertragung.")); } return memoryStream.ToArray(); } private static void Text(BinaryWriter writer, string text, int max) { byte[] bytes = Encoding.UTF8.GetBytes(text); if (bytes.Length > max) { throw new InvalidDataException(L.T("Statistiktext zu lang.")); } writer.Write(bytes.Length); writer.Write(bytes); } private static string Text(BinaryReader reader, int max) { int num = reader.ReadInt32(); if (num < 0 || num > max) { throw new InvalidDataException(); } byte[] array = reader.ReadBytes(num); if (array.Length != num) { throw new EndOfStreamException(); } return new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true).GetString(array); } internal static UpgradeHistorySnapshot? Decode(byte[] bytes) { //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown if (bytes.Length > 60000) { return null; } try { using MemoryStream memoryStream = new MemoryStream(bytes, writable: false); using BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8, leaveOpen: true); if (binaryReader.ReadInt32() != 1) { return null; } string text = Text(binaryReader, 64); int num = binaryReader.ReadInt32(); if (text.Length == 0 || num < 0 || num > 128) { return null; } List<UpgradeHistoryRow> list = new List<UpgradeHistoryRow>(); HashSet<string> hashSet = new HashSet<string>(); for (int i = 0; i < num; i++) { string text2 = Text(binaryReader, 180); string text3 = Text(binaryReader, 180); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); int num4 = binaryReader.ReadInt32(); int num5 = binaryReader.ReadInt32(); int num6 = binaryReader.ReadInt32(); bool flag = binaryReader.ReadBoolean(); int num7 = binaryReader.ReadInt32(); double num8 = binaryReader.ReadDouble(); string text4 = Text(binaryReader, 1200); if (!text2.StartsWith("playerUpgrade", StringComparison.Ordinal) || !hashSet.Add(text2) || num2 < 0 || num3 < 0 || num4 < 0 || num5 < 0 || num7 < 0 || double.IsNaN(num8) || double.IsInfinity(num8) || num8 < 0.0 || num8 > 100.0) { return null; } list.Add(new UpgradeHistoryRow(text2, text3, num2, num3, num4, num5, num6, flag, num7, num8, text4)); } if (memoryStream.Position != memoryStream.Length) { return null; } return new UpgradeHistorySnapshot(text, L.T("Vom aktuellen Host · Erfassung seit NM-Statistikbeginn"), (IEnumerable<UpgradeHistoryRow>)list); } catch (Exception ex) when (ex is IOException || ex is ArgumentException || ex is OverflowException) { return null; } } } internal sealed class HistoryInbox { internal UpgradeHistorySnapshot? Snapshot; private int sequence = -1; private float received; internal void Clear() { Snapshot = null; sequence = -1; received = 0f; } internal bool Touch(int sender, int master, string token, string expectedToken, int next, float now) { if (Snapshot == null || master <= 0 || sender != master || expectedToken.Length == 0 || token != expectedToken || next != sequence) { return false; } received = now; return true; } internal bool Accept(int sender, int master, string token, string expectedToken, int next, byte[] bytes, float now) { if (master <= 0 || sender != master || expectedToken.Length == 0 || token != expectedToken || next <= sequence) { return false; } UpgradeHistorySnapshot val = HistoryProtocol.Decode(bytes); if (val == null) { return false; } Snapshot = val; sequence = next; received = now; return true; } internal UpgradeHistorySnapshot? Current(float now) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if (Snapshot == null || !(now >= received) || !(now - received <= 15f)) { return null; } return new UpgradeHistorySnapshot(Snapshot.Session, L.T("Host-Meldung vor ") + (int)(now - received) + L.T(" s · seit NM-Statistikbeginn"), (IEnumerable<UpgradeHistoryRow>)Snapshot.Rows); } } internal sealed class JoinReadiness { private sealed class Entry { internal object Avatar; internal int Connection; internal float Since = float.NaN; internal float Delay; internal bool Pending = true; internal bool Ready; } private readonly Dictionary<string, Entry> entries = new Dictionary<string, Entry>(); internal void Observe(string id, object avatar, int connection, bool ready, float now, float delay) { if (!entries.TryGetValue(id, out Entry value) || value.Avatar != avatar || value.Connection != connection) { Dictionary<string, Entry> dictionary = entries; Entry obj = new Entry { Avatar = avatar, Connection = connection }; value = obj; dictionary[id] = obj; } value.Delay = ((float.IsNaN(delay) || float.IsInfinity(delay)) ? 3f : Math.Max(1f, Math.Min(30f, delay))); value.Ready = ready; if (!ready) { value.Since = float.NaN; value.Pending = true; } else if (float.IsNaN(value.Since) || now < value.Since) { value.Since = now; } } internal bool Pending(string id) { if (entries.TryGetValue(id, out Entry value)) { return value.Pending; } return true; } internal bool Settled(string id, float now) { if (entries.TryGetValue(id, out Entry value) && value.Ready && !float.IsNaN(value.Since)) { return now - value.Since >= value.Delay; } return false; } internal bool CanCatchUp(string id, float now) { if (Pending(id)) { return Settled(id, now); } return false; } internal float Remaining(string id, float now) { if (!entries.TryGetValue(id, out Entry value) || !value.Ready) { return -1f; } return Math.Max(0f, value.Delay - (now - value.Since)); } internal void Complete(string id) { if (entries.TryGetValue(id, out Entry value)) { value.Pending = false; } } internal void Keep(IEnumerable<string> ids) { HashSet<string> current = new HashSet<string>(ids); string[] array = entries.Keys.Where((string id) => !current.Contains(id)).ToArray(); foreach (string key in array) { entries.Remove(key); } } internal void Clear() { entries.Clear(); } } internal static class LateJoinReadiness { internal static bool Ready(Type pluginType, int actor, out string reason) { reason = ""; try { MethodInfo method = pluginType.GetMethod("IsStaticModEnabled", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); if (method != null) { object obj = method.Invoke(null, null); if (obj is bool && !(bool)obj) { return true; } } if (!(pluginType.GetField("_lateJoinEntries", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) is IDictionary dictionary)) { reason = L.T("Late-Join-Status nicht lesbar; Vergabe wartet."); return false; } if (!dictionary.Contains(actor)) { return true; } object obj2 = dictionary[actor]; string text = obj2?.GetType().GetField("State", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj2)?.ToString() ?? L.T("Unbekannt"); if (text == "Done") { return true; } reason = "Late Join Now: " + text; return false; } catch { reason = L.T("Late-Join-Status vorübergehend nicht verfügbar."); return false; } } } internal static class LoadingReadiness { internal static bool AnimationReady(bool expected, bool completed) { return !expected || completed; } } internal sealed class OffsetFallback { [DataContract] private sealed class Entry { [DataMember] public string SteamId = ""; [DataMember] public string Stat = ""; [DataMember] public int Offset; [DataMember] public int ActualAtSave; } [DataContract] private sealed class Revision { [DataMember] public string SaveSha256 = ""; [DataMember] public List<Entry> Stats = new List<Entry>(); } [DataContract] private sealed class Document { [DataMember] public int Format; [DataMember] public string SaveId = ""; [DataMember] public List<Revision> Revisions = new List<Revision>(); } private List<Entry> entries = new List<Entry>(); internal void Load(string save) { entries.Clear(); if (string.IsNullOrEmpty(save) || Path.GetFileName(save) != save) { return; } string path = Path.Combine(Paths.ConfigPath, "NM_Host_Tools_REPO", "Spielstaende", Hash(Encoding.UTF8.GetBytes(save)) + ".json"); string path2 = Path.Combine(Application.persistentDataPath, "saves", save, save + ".es3"); if (!File.Exists(path) || !File.Exists(path2)) { return; } using FileStream stream = File.OpenRead(path); Document document = (Document)new DataContractJsonSerializer(typeof(Document)).ReadObject(stream); if (document == null || document.Format != 1 || document.SaveId != save) { throw new InvalidDataException(L.T("Ungültige alte Offset-Datei.")); } string hash; using (SHA256 sHA = SHA256.Create()) { using FileStream inputStream = File.OpenRead(path2); hash = Hex(sHA.ComputeHash(inputStream)); } entries = document.Revisions.LastOrDefault((Revision r) => r.SaveSha256 == hash)?.Stats ?? new List<Entry>(); } internal bool Try(string id, string key, int actual, out int offset) { Entry entry = entries.LastOrDefault((Entry e) => e.SteamId == id && e.Stat == key && e.ActualAtSave == actual); offset = entry?.Offset ?? 0; return entry != null; } private static string Hash(byte[] bytes) { using SHA256 sHA = SHA256.Create(); return Hex(sHA.ComputeHash(bytes)); } private static string Hex(byte[] bytes) { return BitConverter.ToString(bytes).Replace("-", "").ToLowerInvariant(); } } internal sealed class Panel { private readonly Plugin plugin; private Vector2 scroll; private Vector2 typeScroll; private string search = ""; private string selected = ""; private string historyPlayer = ""; private LocalText message = ""; private LocalText presetMessage = ""; private ShareLedger? catchUpLedger; private string catchUpType = ""; private string catchUpInput = ""; private LocalText catchUpMessage = ""; private ShareRules? draft; private readonly Dictionary<string, string> numbers = new Dictionary<string, string>(); internal Panel(Plugin plugin) { this.plugin = plugin; } private string Number(AddonUi ui, string label, double initial) { if (!numbers.ContainsKey(label)) { numbers[label] = initial.ToString(CultureInfo.InvariantCulture); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T(label), ui.Body, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(370f) }); numbers[label] = GUILayout.TextField(numbers[label], 12, ui.TextField, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); return numbers[label]; } private double Read(string label) { return double.Parse(numbers[label].Replace(',', '.'), CultureInfo.InvariantCulture); } private int Integer(string label) { double num = Read(label); if (double.IsNaN(num) || num != Math.Truncate(num) || num < 0.0 || num > 10000.0) { throw new ArgumentException("Ganze Zahl von 0–10000 benötigt: " + label); } return (int)num; } internal void Draw(AddonUi ui) { //IL_0002: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Unknown result type (might be due to invalid IL or missing references) scroll = GUILayout.BeginScrollView(scroll, Array.Empty<GUILayoutOption>()); try { GUILayout.Label("UPGRADE SHARE", ui.Title, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("STATISTIK & REGELN"), ui.Heading, Array.Empty<GUILayoutOption>()); if (!GameBridge.Ready) { GUILayout.Label(L.T("Vorab-Konfiguration für deine eigenen Host-Runden. Speichern verändert keine fremde Lobby und vergibt jetzt keine Upgrades."), ui.Notice, Array.Empty<GUILayoutOption>()); } if (GUILayout.Button((plugin.HistoryToasts.Value ? "✓ " : "○ ") + L.T("Erhaltene Upgrades kurz einblenden"), ui.Button, Array.Empty<GUILayoutOption>())) { plugin.HistoryToasts.Value = !plugin.HistoryToasts.Value; } if (plugin.HistoryConnection.Length > 0) { GUILayout.Label(plugin.HistoryConnection, ui.Notice, Array.Empty<GUILayoutOption>()); } if (PhotonNetwork.InRoom && !GameBridge.Host) { GUILayout.Label(L.T("Der Host erfasst und verteilt. Hier siehst du deine eigenen Herkunftsdaten und seine Regeln."), ui.Small, Array.Empty<GUILayoutOption>()); UpgradeHistoryView.Draw(ui, GameBridge.LocalId, true); return; } object obj = (GameBridge.Ready ? ((object)GameBridge.Players()) : ((object)new Dictionary<string, PlayerAvatar>())); if (!((Dictionary<string, PlayerAvatar>)obj).ContainsKey(historyPlayer)) { historyPlayer = GameBridge.LocalId; } foreach (KeyValuePair<string, PlayerAvatar> item in (Dictionary<string, PlayerAvatar>)obj) { if (GUILayout.Button(L.T("Statistik: ") + SemiFunc.PlayerGetName(item.Value), (historyPlayer == item.Key) ? ui.Selected : ui.Button, Array.Empty<GUILayoutOption>())) { historyPlayer = item.Key; } } UpgradeHistoryView.Draw(ui, historyPlayer, false); GUILayout.Space(15f); GUILayout.Label(L.T("VERTEILUNG VERWALTEN"), ui.Heading, Array.Empty<GUILayoutOption>()); GUILayout.Label((string)plugin.Status, (plugin.Fault.Length == 0) ? ui.Notice : ui.Danger, Array.Empty<GUILayoutOption>()); foreach (KeyValuePair<string, string> item2 in plugin.JoinStatus) { PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(item2.Key); GUILayout.Label((Object.op_Implicit((Object)(object)val) ? SemiFunc.PlayerGetName(val) : item2.Key) + ": " + item2.Value, ui.Small, Array.Empty<GUILayoutOption>()); } if (plugin.Fault.Length > 0 && GUILayout.Button(L.T("Nach Korrektur erneut prüfen (keine Wiederholung alter Vergaben)"), ui.Button, Array.Empty<GUILayoutOption>())) { plugin.RetryAfterCorrection(); } if (GUILayout.Button((plugin.Active.Value ? "✓ " : "○ ") + L.T("Verteilung aktiv"), ui.Button, Array.Empty<GUILayoutOption>())) { plugin.Active.Value = !plugin.Active.Value; } GUILayout.Label(L.T("NM-Vorgaben: 33 individuell festgelegte Upgrade-Regeln. Neue Config-Einträge nutzen diese Werte automatisch. Bestehende Einstellungen bleiben erhalten; der folgende Knopf ersetzt bewusst die 33 bekannten Regeln. Unbekannte Mod-Typen bleiben unverändert."), ui.Small, Array.Empty<GUILayoutOption>()); if (GUILayout.Button(L.T("33 NM-Vorgaben übernehmen (bestehende Regeln ersetzen)"), ui.Button, Array.Empty<GUILayoutOption>())) { try { plugin.ApplyNmDefaults(); numbers.Clear(); if (selected.Length > 0 && plugin.Rules.TryGetValue(selected, out RuleConfig value)) { draft = value.Read(); } presetMessage = L.Capture(() => L.T("NM-Vorgaben gespeichert. Gilt für neue Verteilungen und künftiges Nachholen. Vorherige Config: .before-nm-defaults.bak")); } catch (Exception ex) { Exception ex2 = ex; Exception ex3 = ex2; presetMessage = L.Capture(() => L.T("Übernahme nicht vollständig abgeschlossen: ") + ex3.Message); } } if (presetMessage.Length > 0) { GUILayout.Label((string)presetMessage, ui.Notice, Array.Empty<GUILayoutOption>()); } GUILayout.Label(L.T("Käufer: Original garantiert. Andere: je ein Upgrade bei Erfolg. Chancen und Limits zählen reguläre Stufen ohne bekannte persönliche Offsets. REPOLib-Mod-Upgrades benötigen ihre Originalmods auch beim Empfänger."), ui.Body, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Alte Spielstände: Frühere Käufe sind unbekannt. Bei fehlender Historie kannst du unten den Late-Join-Nachholstand pro Upgrade und Spielstand korrigieren. Durchschnitt nutzt vorhandene reguläre Stände. Unbekannte Änderungen fremder Mods können nicht automatisch als private Offsets erkannt werden."), ui.Small, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Suche nach Upgrade"), ui.Small, Array.Empty<GUILayoutOption>()); search = GUILayout.TextField(search, 100, ui.TextField, Array.Empty<GUILayoutOption>()); typeScroll = GUILayout.BeginScrollView(typeScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(185f) }); foreach (UpgradeType item3 in from t in plugin.Types.Values.OrderBy<UpgradeType, string>((UpgradeType t) => t.Name, StringComparer.OrdinalIgnoreCase) where (t.Name + t.Key).IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 select t) { string text = item3.Name + " · " + (item3.Native ? L.T("Spiel") : ((item3.RepoObject != null) ? "REPOLib" : L.T("Fremdmod / nur Tracking"))); if (item3.Problem.Length > 0) { text += L.T(" · Hinweis"); } if (!GUILayout.Button(text, (selected == item3.Key) ? ui.Selected : ui.Button, Array.Empty<GUILayoutOption>())) { continue; } selected = item3.Key; numbers.Clear(); try { draft = plugin.Rules[selected].Read(); message = ""; } catch (Exception ex4) { Exception ex2 = ex4; Exception ex5 = ex2; draft = new ShareRules(); message = L.Capture(() => L.T("Ungültige gespeicherte Regel: ") + ex5.Message + L.T(" Neue gültige Werte speichern.")); } } GUILayout.EndScrollView(); if (plugin.Types.Count == 0) { GUILayout.Label(L.T("Standard-Upgrades sind vorab einstellbar. Mod-Upgrades erscheinen nach Registrierung oder aus bereits gespeicherten Regeln."), ui.Small, Array.Empty<GUILayoutOption>()); } if (draft != null && plugin.Types.TryGetValue(selected, out UpgradeType value2)) { GUILayout.Space(15f); GUILayout.Label(value2.Name, ui.Heading, Array.Empty<GUILayoutOption>()); GUILayout.Label(value2.Key, ui.Small, Array.Empty<GUILayoutOption>()); if (value2.Problem.Length > 0) { GUILayout.Label(L.T(value2.Problem), ui.Notice, Array.Empty<GUILayoutOption>()); } else { GUILayout.Label(L.T("Vergabe unterstützt · ") + (value2.Native ? L.T("Spiel-Upgrade") : L.T("REPOLib; Verwendung wird am registrierten Gegenstand und der bestätigten Stufenänderung erkannt.")), ui.Small, Array.Empty<GUILayoutOption>()); } if (GUILayout.Button(L.T("NM-Standard für dieses Upgrade in den Entwurf laden"), ui.Button, Array.Empty<GUILayoutOption>())) { draft = DefaultRules.For(selected); numbers.Clear(); message = L.Capture(() => L.T("Vorgabe geladen. Zum Übernehmen die Regel unten speichern.")); } if (GUILayout.Button((draft.Enabled ? "✓ " : "○ ") + L.T("Dieses Upgrade teilen"), ui.Button, Array.Empty<GUILayoutOption>())) { draft.Enabled = !draft.Enabled; } Number(ui, "Garantiert bis reguläre Stufe", draft.Guaranteed); Number(ui, "Teilungs-Maximum (0 = unbegrenzt)", draft.Maximum); if (GUILayout.Button(L.T("Chancenmodus: ") + L.T(draft.Mode.ToString()), ui.Button, Array.Empty<GUILayoutOption>())) { draft.Mode = ((draft.Mode == ChanceMode.Linear) ? ChanceMode.Bereiche : ChanceMode.Linear); } Number(ui, "Startchance in %", draft.Start); Number(ui, "Abnahme in Prozentpunkten pro Stufe", draft.Drop); Number(ui, "Mindestchance in %", draft.Minimum); if (draft.Mode == ChanceMode.Bereiche) { GUILayout.Label(L.T("Nächste Stufe=Chance; z. B. 21=90;31=50;41=0"), ui.Small, Array.Empty<GUILayoutOption>()); draft.Bands = GUILayout.TextField(draft.Bands, 500, ui.TextField, Array.Empty<GUILayoutOption>()); } if (GUILayout.Button("Late Join: " + L.T(draft.Join.ToString()) + L.T(" (klicken zum Wechseln)"), ui.Button, Array.Empty<GUILayoutOption>())) { draft.Join = (JoinMode)((int)(draft.Join + 1) % 4); } GUILayout.Label(L.T("Aus · Garantie · Garantie plus individuelle Zufallswürfe · Durchschnitt vorhandener Spieler (abgerundet). Wiederbeitritt würfelt bereits abgearbeitete Ereignisse nicht erneut."), ui.Small, Array.Empty<GUILayoutOption>()); if (GUILayout.Button(L.T("Regel für dieses Upgrade speichern"), ui.Button, Array.Empty<GUILayoutOption>())) { try { draft.Guaranteed = Integer("Garantiert bis reguläre Stufe"); draft.Maximum = Integer("Teilungs-Maximum (0 = unbegrenzt)"); draft.Start = Read("Startchance in %"); draft.Drop = Read("Abnahme in Prozentpunkten pro Stufe"); draft.Minimum = Read("Mindestchance in %"); draft.Validate(); plugin.Rules[selected].Write(draft); ((BaseUnityPlugin)plugin).Config.Save(); message = L.Capture(() => L.T("Gespeichert. Gilt für neue Verteilungen und künftiges Nachholen.")); } catch (Exception ex6) { message = ex6.Message; } } GUILayout.Label((string)message, ui.Notice, Array.Empty<GUILayoutOption>()); if (GameBridge.Ready && plugin.Ledger != null) { GUILayout.Label(L.T("Spieler · regulär + Offset = Gesamt · nächste Chance"), ui.Heading, Array.Empty<GUILayoutOption>()); ShareRules shareRules = null; try { shareRules = plugin.Rules[selected].Read(); } catch { } foreach (KeyValuePair<string, PlayerAvatar> item4 in GameBridge.Players()) { int normal; bool personal; bool flag = plugin.Normal(value2, item4.Key, out normal, out personal); GUILayout.Label(string.Concat(SemiFunc.PlayerGetName(item4.Value) + ": ", (flag && shareRules != null) ? (normal + " + (" + plugin.Ledger.Get(selected, item4.Key, "offset") + ") = " + value2.Count(item4.Key) + " · " + (shareRules.Chance(normal) * 100.0).ToString("0.#") + " %") : L.T("Offset-Anbindung noch nicht bereit.")), ui.Body, Array.Empty<GUILayoutOption>()); if (plugin.JoinStatus.TryGetValue(item4.Key, out string value3)) { GUILayout.Label(L.T(" Verteilung wartet: ") + value3, ui.Notice, Array.Empty<GUILayoutOption>()); } } GUILayout.Label(L.T("Seit NM-Tracking verwendete Gegenstände dieses Typs: ") + plugin.Ledger.Events(selected), ui.Small, Array.Empty<GUILayoutOption>()); DrawCatchUp(ui); } } GUILayout.Space(15f); GUILayout.Label(L.T("Letzte Verteilungen / Käufe"), ui.Heading, Array.Empty<GUILayoutOption>()); foreach (LocalText item5 in plugin.History.Reverse().Take(12)) { GUILayout.Label((string)item5, ui.Small, Array.Empty<GUILayoutOption>()); } } finally { GUILayout.EndScrollView(); } } private void DrawCatchUp(AddonUi ui) { ShareLedger ledger = plugin.Ledger; if (ledger == null) { return; } if (catchUpLedger != ledger || catchUpType != selected) { catchUpLedger = ledger; catchUpType = selected; catchUpInput = ledger.CatchUpTotal(selected).ToString(CultureInfo.InvariantCulture); catchUpMessage = ""; } GUILayout.Space(12f); GUILayout.Label(L.T("LATE-JOIN-NACHHOLSTAND · DIESER SPIELSTAND"), ui.Heading, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Aktuell: ") + ledger.CatchUpTotal(selected) + (ledger.HasCatchUpCorrection(selected) ? L.T(" · manuell korrigierte Basis") : L.T(" · automatische Zählung")), ui.Body, Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Gesamtzahl der Nachholversuche, keine zusätzlichen garantierten Stufen. Beispiel: Nachholstand 15 und Garantie 10 ergeben bei einem neuen Spieler mit 0 regulären Stufen 10 sichere Stufen und 5 weitere Chancen. Dafür Late Join auf GarantieUndZufall stellen und die Regel speichern. Chance, Teilungs-Maximum und persönliche Offsets gelten weiter."), ui.Small, Array.Empty<GUILayoutOption>()); if (!plugin.CanCorrectCatchUp) { GUILayout.Label(L.T("Korrektur erst als Host bei fertig geladenem Spielstand und fehlerfreier Verteilung möglich."), ui.Notice, Array.Empty<GUILayoutOption>()); return; } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(L.T("Nachholstand gesamt (0–10000)"), ui.Body, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(370f) }); catchUpInput = GUILayout.TextField(catchUpInput, 12, ui.TextField, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); if (GUILayout.Button(L.T("Nachholstand für diesen Spielstand übernehmen"), ui.Button, Array.Empty<GUILayoutOption>())) { try { if (!int.TryParse(catchUpInput, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || result < 0 || result > 10000) { throw new ArgumentException(L.T("Bitte eine ganze Zahl von 0–10000 eingeben.")); } plugin.CorrectCatchUp(selected, ledger, result); catchUpMessage = L.Capture(() => L.T("Übernommen. Gilt für kommende Nachholvorgänge; wird mit der nächsten Spielspeicherung dauerhaft gespeichert.")); } catch (Exception ex) { catchUpMessage = ex.Message; } } if (ledger.HasCatchUpCorrection(selected) && GUILayout.Button(L.T("Wieder nur tatsächlich erfasste Käufe zählen"), ui.Button, Array.Empty<GUILayoutOption>())) { try { plugin.CorrectCatchUp(selected, ledger, null); catchUpInput = ledger.CatchUpTotal(selected).ToString(CultureInfo.InvariantCulture); catchUpMessage = L.Capture(() => L.T("Automatische Zählung aktiv. Bereits erledigte Chancen bleiben erledigt; keine Stufen werden entzogen.")); } catch (Exception ex2) { catchUpMessage = ex2.Message; } } GUILayout.Label(L.T("Echte Käufe erhöhen den Nachholstand danach automatisch. Bereits fertig beigetretene Spieler bekommen durch die Korrektur nichts erneut. Laden neue Spieler noch, nutzen sie den korrigierten Stand nach der Wartezeit. Erledigte Chancen werden beim Wiederbeitritt oder erneuten Ändern nicht wiederholt. Kaufzähler und vorhandene Upgrade-Stufen bleiben unverändert."), ui.Small, Array.Empty<GUILayoutOption>()); if (catchUpMessage.Length > 0) { GUILayout.Label((string)catchUpMessage, ui.Notice, Array.Empty<GUILayoutOption>()); } } } [BepInPlugin("nightmare.repo.upgradeshare", "NM_Upgrade_Share_REPO", "0.6.0")] [BepInProcess("REPO.exe")] [BepInDependency("nightmare.repo.core", "2.10.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private sealed class Observation { internal string Player = ""; internal string Key = ""; internal int Before; internal int After; internal float Time; } internal sealed class Consumption { internal string Player = ""; internal string RepoKey = ""; internal int ObjectId; internal float Time; internal readonly Dictionary<string, int> Before = new Dictionary<string, int>(); internal readonly HashSet<string> Personal = new HashSet<string>(); internal readonly HashSet<string> Confirmed = new HashSet<string>(); internal readonly Dictionary<string, int> Amounts = new Dictionary<string, int>(); } internal const string Id = "nightmare.repo.upgradeshare"; internal static Plugin? Instance; private readonly Harmony harmony = new Harmony("nightmare.repo.upgradeshare"); internal AddonHandle? Page; internal Dictionary<string, UpgradeType> Types = new Dictionary<string, UpgradeType>(); internal readonly Dictionary<string, RuleConfig> Rules = new Dictionary<string, RuleConfig>(); internal ConfigEntry<bool> Active; internal ConfigEntry<float> JoinDelay; internal readonly Dictionary<string, string> JoinStatus = new Dictionary<string, string>(); internal ShareLedger? Ledger; internal LocalText Status = L.Capture(() => L.T("Warte auf einen Spielstand.")); internal string SaveId = ""; internal string Fault = ""; internal readonly Queue<LocalText> History = new Queue<LocalText>(); private readonly OffsetFallback fallback = new OffsetFallback(); private readonly List<Consumption> pending = new List<Consumption>(); private readonly List<Observation> observations = new List<Observation>(); private readonly HashSet<int> consumed = new HashSet<int>(); private readonly JoinReadiness joinReadiness = new JoinReadiness(); private readonly HashSet<string> present = new HashSet<string>(); private float nextTick; private float discoverAt; private bool initialized; private bool granting; private bool repoPatched; private Panel panel; private int loadGeneration; private int loadedGeneration = -1; private Dictionary<string, int>? runStats; private float nextConfigDiscovery; private string[] storedUpgradeKeys = Array.Empty<string>(); private ShareLink? historyLink; internal ConfigEntry<bool> HistoryToasts; internal string HistoryConnection = ""; internal string historySession = ""; private string noticeSession = ""; private UpgradeHistorySnapshot? previousHistory; private readonly Dictionary<string, UpgradeHistorySnapshot> historyCache = new Dictionary<string, UpgradeHistorySnapshot>(); internal bool CanCorrectCatchUp { get { if (GameBridge.Ready && GameBridge.Host && initialized && Ledger != null && Fault.Length == 0 && SaveId == GameBridge.Save && loadedGeneration == loadGeneration) { return runStats == StatsManager.instance.runStats; } return false; } } private void Awake() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0173: Expected O, but got Unknown //IL_0173: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown Instance = this; try { storedUpgradeKeys = StoredUpgradeKeys.Read(((BaseUnityPlugin)this).Config.ConfigFilePath); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)(L.T("Vorhandene Upgrade-Typen konnten nicht vorab gelesen werden: ") + ex.Message)); } Active = ((BaseUnityPlugin)this).Config.Bind<bool>("Allgemein", "Aktiv", true, L.Help("Upgrade-Verteilung als Host. Selbst benutzte Upgrades bleiben unverändert.")); JoinDelay = ((BaseUnityPlugin)this).Config.Bind<float>("LateJoin", "WartezeitNachCharakterBereit", 3f, new ConfigDescription(L.Help("Zusätzliche Sekunden nach vollständig bereitem Charakter und abgeschlossener Late-Join-Synchronisierung (1–30)."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>())); PrepareConfiguration(); panel = new Panel(this); Page = CoreApi.Register(L.Describe(new AddonDefinition("nightmare.repo.upgradeshare", "Upgrade Share", "0.6.0", "Individuelle Chancen, Late-Join-Ausgleich und getrennte persönliche Offsets.", (Action<AddonUi>)panel.Draw, 1), "Upgrade Share", "Individuelle Chancen, Late-Join-Ausgleich und getrennte persönliche Offsets.")); CoreServices.RegisterLobbyPrefix(Page, "[Upgrade Share]"); StartHistory(); harmony.Patch((MethodBase)AccessTools.Method(typeof(ItemUpgrade), "PlayerUpgrade", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "BeforeItem", (Type[])null) { priority = 0 }, new HarmonyMethod(typeof(Plugin), "AfterItem", (Type[])null) { priority = 0 }, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); string[] array = new string[3] { "LoadGame", "SaveFileCreate", "RunStartStats" }; foreach (string text in array) { harmony.Patch((MethodBase)AccessTools.Method(typeof(StatsManager), text, (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "ResetLoaded", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } harmony.Patch((MethodBase)AccessTools.Method(typeof(StatsManager), "SaveGame", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "BeforeSave", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void BeforeSave() { Plugin instance = Instance; if ((Object)(object)instance == (Object)null || !GameBridge.Host || instance.Ledger == null || instance.SaveId != GameBridge.Save) { return; } try { foreach (UpgradeType value in instance.Types.Values) { string[] array = value.Counts.Keys.ToArray(); foreach (string id in array) { instance.Normal(value, id, out var _, out var _); } } } catch (Exception ex) { instance.Stop(ex); } } private static void ResetLoaded() { if ((Object)(object)Instance != (Object)null) { Instance.loadGeneration++; } } private void InstallRepo() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_008e: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00f3: Expected O, but got Unknown if (repoPatched) { return; } Type type = AccessTools.TypeByName("REPOLib.Modules.PlayerUpgrade"); if (!(type == null)) { MethodInfo methodInfo = AccessTools.Method(type, "ApplyUpgrade", new Type[2] { typeof(string), typeof(int) }, (Type[])null); if (!(methodInfo == null)) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "BeforeRepo", (Type[])null), new HarmonyMethod(typeof(Plugin), "AfterRepo", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(type, "SetLevel", new Type[2] { typeof(string), typeof(int) }, (Type[])null), new HarmonyMethod(typeof(Plugin), "BeforeRepo", (Type[])null), new HarmonyMethod(typeof(Plugin), "AfterRepo", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); repoPatched = true; } } } private static void BeforeRepo(object __instance, string __0, out int __state) { __state = -1; if (!((Object)(object)Instance == (Object)null) && !Instance.granting && GameBridge.Host && GameBridge.Read(__instance, "PlayerDictionary") is Dictionary<string, int> dictionary) { __state = (dictionary.TryGetValue(__0, out var value) ? value : 0); } } private static void AfterRepo(object __instance, string __0, int __state) { Plugin instance = Instance; if ((Object)(object)instance == (Object)null || __state < 0 || instance.granting || !GameBridge.Host) { return; } try { if (GameBridge.Read(__instance, "PlayerDictionary") is Dictionary<string, int> dictionary && dictionary.TryGetValue(__0, out var value) && value > __state) { string key = "playerUpgrade" + GameBridge.Read(__instance, "UpgradeId"); instance.observations.Add(new Observation { Player = __0, Key = key, Before = __state, After = value, Time = Time.unscaledTime }); } } catch (Exception ex) { instance.Stop(ex); } } private static void BeforeItem(ItemUpgrade __instance, out Consumption? __state) { __state = null; Plugin instance = Instance; if ((Object)(object)instance == (Object)null || !instance.initialized || instance.granting || !GameBridge.Ready || instance.Fault.Length > 0) { return; } object obj = GameBridge.Read(__instance, "upgradeDone"); if ((obj is bool && (bool)obj) || !__instance.isPlayerUpgrade) { return; } try { ItemToggle component = ((Component)__instance).GetComponent<ItemToggle>(); if (!Object.op_Implicit((Object)(object)component) || !component.toggleState || instance.consumed.Contains(((Object)__instance).GetInstanceID())) { return; } PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID((int)(GameBridge.Read(component, "playerTogglePhotonID") ?? ((object)(-1)))); if (!Object.op_Implicit((Object)(object)val)) { return; } Consumption consumption = new Consumption { Player = SemiFunc.PlayerGetSteamID(val), ObjectId = ((Object)__instance).GetInstanceID(), Time = Time.unscaledTime }; Type type = AccessTools.TypeByName("REPOLib.Modules.REPOLibItemUpgrade"); if (type != null) { Component component2 = ((Component)__instance).GetComponent(type); if (component2 != null) { consumption.RepoKey = "playerUpgrade" + AccessTools.Property(type, "UpgradeId").GetValue(component2); } } if (consumption.RepoKey.Length == 0) { consumption.RepoKey = GameBridge.ItemKey(__instance, instance.Types.Values); } foreach (UpgradeType value in instance.Types.Values) { if (instance.Normal(value, consumption.Player, out var normal, out var personal)) { consumption.Before[value.Key] = normal; instance.Ledger.BeginOrigin(value.Key, consumption.Player, normal); } if (personal) { consumption.Personal.Add(value.Key); } } __state = consumption; } catch (Exception ex) { instance.Stop(ex); } } private static void AfterItem(ItemUpgrade __instance, Consumption? __state) { Plugin instance = Instance; if ((Object)(object)instance == (Object)null || __state == null) { return; } object obj = GameBridge.Read(__instance, "upgradeDone"); if (!(obj is bool) || !(bool)obj) { return; } try { string[] array = __state.Before.Keys.ToArray(); foreach (string text in array) { if (!(text == __state.RepoKey)) { if (instance.Types.TryGetValue(text, out UpgradeType value) && instance.Normal(value, __state.Player, out var normal, out var personal) && normal > __state.Before[text] && !personal) { __state.Confirmed.Add(text); __state.Amounts[text] = normal - __state.Before[text]; } else { __state.Before.Remove(text); } } } if (instance.consumed.Add(__state.ObjectId)) { instance.pending.Add(__state); } } catch (Exception ex) { instance.Stop(ex); } } internal bool Normal(UpgradeType type, string id, out int normal, out bool personal) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown normal = 0; personal = false; if (Ledger == null) { return false; } int num = type.Count(id); OffsetResult offset = CoreServices.GetOffset(new OffsetRequest(SaveId, id, type.Key, num)); if (!offset.Ready) { return false; } int offset2; if (offset.Known) { Ledger.Offset(type.Key, id, offset.Offset); personal = offset.PersonalChange; } else if (Ledger.Get(type.Key, id, "offsetKnown") == 0 && fallback.Try(id, type.Key, num, out offset2)) { Ledger.Offset(type.Key, id, offset2); } normal = Ledger.Normal(type.Key, id, num); return true; } internal void CorrectCatchUp(string key, ShareLedger expectedLedger, int? total) { if (!CanCorrectCatchUp || Ledger != expectedLedger || !Types.ContainsKey(key)) { throw new InvalidOperationException(L.T("Nachholstand kann nur als Host im fertig geladenen aktuellen Spielstand gesetzt werden.")); } expectedLedger.SetCatchUpTotal(key, total); foreach (string key2 in GameBridge.Players().Keys) { if (!joinReadiness.Pending(key2) && joinReadiness.Settled(key2, Time.unscaledTime)) { expectedLedger.AckCorrection(key, key2); } } historyCache.Clear(); Note(L.Capture(() => Types[key].Name + L.T(": Late-Join-Nachholstand ") + expectedLedger.CatchUpTotal(key) + (total.HasValue ? L.T(" (manuell korrigiert).") : L.T(" (automatische Zählung).")))); } internal void ApplyNmDefaults() { if (PhotonNetwork.InRoom && !GameBridge.Host) { throw new InvalidOperationException(L.T("Vorgaben können nur im Hauptmenü oder als Host übernommen werden.")); } bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; try { if (File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { File.Copy(((BaseUnityPlugin)this).Config.ConfigFilePath, ((BaseUnityPlugin)this).Config.ConfigFilePath + ".before-nm-defaults.bak", overwrite: true); } foreach (string key in DefaultRules.Keys) { if (!Rules.ContainsKey(key)) { Rules[key] = new RuleConfig(((BaseUnityPlugin)this).Config, key); } if (!GameBridge.Ready) { AddConfigType(key); } Rules[key].Write(DefaultRules.For(key)); } ((BaseUnityPlugin)this).Config.Save(); historyCache.Clear(); } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; } } internal void PrepareConfiguration() { if (Time.unscaledTime < nextConfigDiscovery) { return; } nextConfigDiscovery = Time.unscaledTime + 3f; bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; int count = Rules.Count; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; try { string[] native = GameBridge.Native; foreach (string text in native) { AddConfigType("playerUpgrade" + text); } native = storedUpgradeKeys; foreach (string key in native) { AddConfigType(key); } KeyValuePair<ConfigDefinition, ConfigEntryBase>[] array = ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)((BaseUnityPlugin)this).Config).ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair<ConfigDefinition, ConfigEntryBase> keyValuePair = array[i]; if (keyValuePair.Key.Section.StartsWith("Upgrade playerUpgrade", StringComparison.Ordinal)) { AddConfigType(keyValuePair.Key.Section.Substring(8)); } } if (!Object.op_Implicit((Object)(object)StatsManager.instance) || !(GameBridge.Read(StatsManager.instance, "dictionaryOfDictionaries") is SortedDictionary<string, Dictionary<string, int>> sortedDictionary)) { return; } foreach (KeyValuePair<string, Dictionary<string, int>> item in sortedDictionary) { if (item.Key.StartsWith("playerUpgrade", StringComparison.Ordinal)) { AddConfigType(item.Key); } } } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; if (saveOnConfigSet && Rules.Count != count) { ((BaseUnityPlugin)this).Config.Save(); } } } private void AddConfigType(string key) { if (!Rules.ContainsKey(key)) { Rules[key] = new RuleConfig(((BaseUnityPlugin)this).Config, key); } if (!Types.ContainsKey(key)) { Types[key] = new UpgradeType { Key = key, Name = key.Substring(13), Counts = new Dictionary<string, int>(), Native = GameBridge.Native.Contains(key.Substring(13)), Problem = "Vorab-Konfiguration; Vergabe-Anbindung wird in der Runde geprüft." }; } } private void Update() { if (Time.unscaledTime < nextTick) { return; } nextTick = Time.unscaledTime + 0.5f; historyCache.Clear(); try { if (!GameBridge.Ready) { PrepareConfiguration(); initialized = false; present.Clear(); joinReadiness.Clear(); JoinStatus.Clear(); pending.Clear(); observations.Clear(); Status = L.Capture(() => (!GameBridge.Host) ? L.T("Nur der Host verteilt Upgrades.") : L.T("Wartet auf fertig geladenen Spielstand.")); return; } InstallRepo(); if (SaveId != GameBridge.Save || loadedGeneration != loadGeneration || runStats != StatsManager.instance.runStats) { SaveId = GameBridge.Save; loadedGeneration = loadGeneration; runStats = StatsManager.instance.runStats; Ledger = new ShareLedger(runStats, SaveId); fallback.Load(SaveId); pending.Clear(); observations.Clear(); consumed.Clear(); present.Clear(); joinReadiness.Clear(); JoinStatus.Clear(); initialized = false; Fault = ""; discoverAt = 0f; historySession = Guid.NewGuid().ToString("N"); } if (Time.unscaledTime >= discoverAt) { Types = GameBridge.Discover(); discoverAt = Time.unscaledTime + 3f; foreach (UpgradeType value in Types.Values) { if (!Rules.ContainsKey(value.Key)) { Rules[value.Key] = new RuleConfig(((BaseUnityPlugin)this).Config, value.Key); } } } if (Fault.Length > 0 || Ledger == null) { return; } Dictionary<string, PlayerAvatar> players = GameBridge.Players(); if (players.Count == 0) { Status = L.Capture(() => L.T("Wartet auf Spieler-Identitäten.")); return; } bool personal; foreach (UpgradeType value2 in Types.Values) { foreach (string key in players.Keys) { Normal(value2, key, out var _, out personal); } } if (!initialized) { foreach (string key2 in players.Keys) { present.Add(key2); } if (Ledger.Get("", "", "started") == 0) { foreach (UpgradeType value3 in Types.Values) { foreach (string key3 in players.Keys) { Ledger.Ack(value3.Key, key3, Ledger.Events(value3.Key)); } } Ledger.Put("", "", "started", 1); } initialized = true; } string[] array = present.Where((string key) => !players.ContainsKey(key)).ToArray(); foreach (string item in array) { present.Remove(item); } joinReadiness.Keep(players.Keys); JoinStatus.Clear(); foreach (KeyValuePair<string, PlayerAvatar> item2 in players) { present.Add(item2.Key); string reason; bool ready = GameBridge.PlayerReady(item2.Value, out reason); joinReadiness.Observe(item2.Key, item2.Value, GameBridge.ConnectionId(item2.Value), ready, Time.unscaledTime, JoinDelay.Value); if (joinReadiness.Pending(item2.Key)) { float num = joinReadiness.Remaining(item2.Key, Time.unscaledTime); JoinStatus[item2.Key] = ((num < 0f) ? reason : ((num > 0f) ? (L.T("Charakter bereit · noch ") + num.ToString("0.0") + L.T(" s Wartezeit")) : L.T("Wartet auf Offset-Anbindung / Ausgleich."))); } } bool flag = Chainloader.PluginInfos.ContainsKey("Vippy.SharedUpgradesPlus"); bool flag2 = Active.Value && !flag; if (flag) { Status = L.Capture(() => L.T("SharedUpgradesPlus ist noch geladen. NM-Verteilung pausiert; alten Sharing-Mod entfernen.")); } else { Status = L.Capture(() => (!Active.Value) ? L.T("Verteilung aus; Käufe werden weiter gezählt.") : (L.T("Host aktiv · ") + Types.Count + L.T(" Upgrade-Typen erkannt. ") + (CoreServices.HasOffsetProvider ? L.T("Host-Tools verbunden.") : L.T("Ohne Host-Tools; gespeicherte bekannte Offsets bleiben geschützt.")))); } foreach (UpgradeType value4 in Types.Values) { foreach (string key4 in players.Keys) { if (joinReadiness.Settled(key4, Time.unscaledTime) && Normal(value4, key4, out var normal2, out personal)) { Ledger.BeginOrigin(value4.Key, key4, normal2); } } } ProcessPending(players, flag2); string[] array2 = players.Keys.Where((string id2) => joinReadiness.CanCatchUp(id2, Time.unscaledTime)).ToArray(); if (array2.Length != 0) { int normal4; bool personal2; Dictionary<string, Dictionary<string, int>> dictionary = Types.Values.ToDictionary((UpgradeType upgradeType) => upgradeType.Key, (UpgradeType type) => players.Keys.Where((string id2) => joinReadiness.Settled(id2, Time.unscaledTime) && Normal(type, id2, out normal4, out personal2)).ToDictionary((string result) => result, delegate(string id2) { Normal(type, id2, out normal4, out personal2); return normal4; })); Dictionary<string, HashSet<string>> established = Types.Values.ToDictionary((UpgradeType upgradeType) => upgradeType.Key, (UpgradeType upgradeType) => new HashSet<string>(players.Keys.Where((string player) => Ledger.Seen(upgradeType.Key, player)))); array = array2; foreach (string id in array) { bool flag3 = true; foreach (UpgradeType t in Types.Values) { if (t.Problem.Length > 0) { continue; } if (!Normal(t, id, out var normal3, out personal)) { flag3 = false; continue; } ShareRules shareRules = Rules[t.Key].Read(); if (!flag2) { shareRules.Enabled = false; } int[] peers = (from p in dictionary[t.Key] where p.Key != id && established[t.Key].Contains(p.Key) select p.Value).ToArray(); int num2 = Ledger.CatchUp(t.Key, id, normal3, shareRules, peers); if (num2 > 0) { Send(t, id, num2, "Late Join"); } } if (flag3) { joinReadiness.Complete(id); JoinStatus.Remove(id); } } } observations.RemoveAll((Observation o) => Time.unscaledTime - o.Time > 8f); } catch (Exception ex) { Stop(ex); } finally { TickHistory(); } } private void ProcessPending(Dictionary<string, PlayerAvatar> players, bool canShare) { if (Ledger == null) { return; } Consumption[] array = pending.ToArray(); foreach (Consumption c in array) { bool flag = false; foreach (UpgradeType type in Types.Values) { if (!c.Before.TryGetValue(type.Key, out var value) || c.Personal.Contains(type.Key)) { continue; } if (!Normal(type, c.Player, out var _, out var personal)) { flag = true; } else { if (personal) { continue; } bool flag2 = c.Confirmed.Contains(type.Key); if (type.Key == c.RepoKey) { Observation observation = observations.FirstOrDefault((Observation o) => o.Key == type.Key && o.Player == c.Player && Math.Abs(o.Time - c.Time) <= 4f && o.After > o.Before); flag2 = observation != null; if (observation != null) { observations.Remove(observation); c.Amounts[type.Key] = observation.After - observation.Before; } if (!flag2 && Time.unscaledTime - c.Time < 4f) { flag = true; continue; } if (!flag2) { Note(L.Capture(() => type.Name + L.T(": Gegenstand verbraucht, aber keine passende Mod-Vergabe bestätigt; nicht geteilt."))); } } if (!flag2) { continue; } c.Before.Remove(type.Key); Ledger.BeginOrigin(type.Key, c.Player, value); Ledger.Record(type.Key, c.Player, "collected", c.Amounts[type.Key]); int sequence = Ledger.Next(type.Key); ShareRules shareRules = Rules[type.Key].Read(); Ledger.Ack(type.Key, c.Player, sequence); foreach (string item in players.Keys.Where((string id) => id != c.Player)) { if (Normal(type, item, out var normal2, out var _) && !joinReadiness.Pending(item)) { Ledger.Ack(type.Key, item, sequence); if (canShare && type.Problem.Length == 0 && shareRules.Enabled && Ledger.Roll(type.Key, item, sequence) < shareRules.Chance(normal2)) { Send(type, item, 1, "Geteilt"); } } } Note(L.Capture(() => type.Name + L.T(": benutzt von ") + Name(c.Player) + L.T("; Ereignis ") + sequence + ".")); } } if (!flag || Time.unscaledTime - c.Time > 5f) { pending.Remove(c); } } } private void Send(UpgradeType type, string id, int amount, string reason) { granting = true; try { if (Ledger == null || !Normal(type, id, out var normal, out var _)) { throw new InvalidOperationException(L.T("Statistikbasis noch nicht bereit.")); } Ledger.BeginOrigin(type.Key, id, normal); GameBridge.Grant(type, id, amount); Ledger.Record(type.Key, id, (reason == "Late Join") ? "late" : "shared", amount); Note(L.Capture(() => L.T(reason) + ": " + Name(id) + " · " + type.Name + " +" + amount)); } finally { granting = false; } } private static string Name(string id) { PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(id); if (!Object.op_Implicit((Object)(object)val)) { return id; } return SemiFunc.PlayerGetName(val); } private void Note(LocalText text) { History.Enqueue(text); while (History.Count > 30) { History.Dequeue(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)text); } private void Stop(Exception ex) { if (Fault.Length == 0) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); } Fault = ex.Message; Status = L.Capture(() => L.T("Verteilung angehalten: ") + Fault); pending.Clear(); } internal void RetryAfterCorrection() { Fault = ""; discoverAt = 0f; Status = L.Capture(() => L.T("Prüfung wird wiederholt. Bereits abgearbeitete Vergaben bleiben abgeschlossen.")); } private void OnDestroy() { historyLink?.Dispose(); AddonHandle? page = Page; if (page != null) { page.Dispose(); } harmony.UnpatchSelf(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void StartHistory() { HistoryToasts = ((BaseUnityPlugin)this).Config.Bind<bool>("Statistik", "ErhalteneUpgradesEinblenden", true, L.Help("Kurze Meldung über neue geteilte / Late-Join-Upgrades für dich. Keine Meldung für bereits vorhandene Zähler.")); CoreServices.RegisterUpgradeHistory(Page, (Func<string, UpgradeHistorySnapshot>)ReadHistory); historyLink = new ShareLink(this); } internal UpgradeHistorySnapshot? ReadHistory(string player) { return HistoryPresentation.Localize(ReadWireHistory(player)); } internal UpgradeHistorySnapshot? ReadWireHistory(string player) { //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Expected O, but got Unknown //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Expected O, but got Unknown if (!GameBridge.Host) { return historyLink?.Read(player); } if (!GameBridge.Ready || Ledger == null || !initialized || Fault.Length > 0 || SaveId != GameBridge.Save || loadedGeneration != loadGeneration || runStats != StatsManager.instance.runStats || !joinReadiness.Settled(player, Time.unscaledTime) || !present.Contains(player)) { return null; } if (historyCache.TryGetValue(player, out UpgradeHistorySnapshot value)) { return value; } List<UpgradeHistoryRow> list = new List<UpgradeHistoryRow>(); bool flag = Active.Value && !Chainloader.PluginInfos.ContainsKey("Vippy.SharedUpgradesPlus"); foreach (UpgradeType item in Types.Values.OrderBy<UpgradeType, string>((UpgradeType t) => t.Name, StringComparer.OrdinalIgnoreCase)) { if (Ledger.HasOrigin(it