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 RepoLevelMVP v0.2.1
Matsu.RepoMvp.dll
Decompiled a day 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.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Matsu.RepoMvp")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.1.0")] [assembly: AssemblyInformationalVersion("0.2.1")] [assembly: AssemblyProduct("Matsu.RepoMvp")] [assembly: AssemblyTitle("Matsu.RepoMvp")] [assembly: AssemblyVersion("0.2.1.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 Matsu.RepoMvp { internal sealed class MvpFallbackUi : MonoBehaviour { private sealed class PlayerRow { internal RectTransform Root; internal Text Name; internal Text Points; internal Text Details; } private const float UiPollSeconds = 0.5f; private const int PlayersPerPage = 5; private const float RowHeight = 66f; private const float PanelWidth = 566f; private static readonly Color SoftText = new Color(0.72f, 0.84f, 0.83f); private static readonly Color Gold = new Color(1f, 0.86f, 0.53f); private static readonly KeyboardShortcut PreviousPage = new KeyboardShortcut((KeyCode)280, Array.Empty<KeyCode>()); private static readonly KeyboardShortcut NextPage = new KeyboardShortcut((KeyCode)281, Array.Empty<KeyCode>()); private Canvas? canvas; private RectTransform panel; private Text header; private Text mvp; private Text status; private Text oops; private Text pageHint; private readonly PlayerRow[] rows = new PlayerRow[5]; private Font? font; private bool ownsFont; private Texture2D? pixel; private Sprite? sprite; private MethodInfo? deathCounterBridge; private bool bridgeResolved; private bool hotkeyVisible = true; private bool sharedDetailsVisible; private bool inTruck; private float pollAt; private float gameOverShowUntil; private int shownRevision = -1; private bool shownJapanese; private int page; private AwardDisplay? localizedDisplay; private AwardDisplay? renderedDisplay; private int renderedPage = -1; private void Update() { //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) ReadInput(); if (Time.unscaledTime < pollAt) { return; } pollAt = Time.unscaledTime + 0.5f; try { ResolveBridge(); bool flag = MvpLocalization.IsJapanese(); AwardDisplay lastDisplay = MvpRuntime.LastDisplay; if (shownRevision != MvpRuntime.DisplayRevision) { page = 0; sharedDetailsVisible = false; gameOverShowUntil = ((lastDisplay != null && lastDisplay.GameOver) ? (Time.unscaledTime + 15f) : 0f); } if (shownRevision != MvpRuntime.DisplayRevision || shownJapanese != flag) { localizedDisplay = ((lastDisplay == null) ? null : MvpLocalization.Localize(lastDisplay, flag)); SendCompactSummary(localizedDisplay); shownRevision = MvpRuntime.DisplayRevision; shownJapanese = flag; } inTruck = IsTruck(); if (!inTruck) { sharedDetailsVisible = false; } bool flag2 = lastDisplay != null && lastDisplay.GameOver && Time.unscaledTime < gameOverShowUntil && !Plugin.IsGameplayLevel() && (deathCounterBridge == null || !inTruck); bool flag3 = localizedDisplay != null && hotkeyVisible && ((inTruck && (deathCounterBridge == null || sharedDetailsVisible)) || flag2); if (flag3 && localizedDisplay != null && (renderedDisplay != localizedDisplay || renderedPage != page)) { Render(localizedDisplay, flag); renderedDisplay = localizedDisplay; renderedPage = page; } if ((Object)(object)canvas != (Object)null) { if (flag3) { bool flag4 = inTruck && deathCounterBridge != null; RectTransform obj = panel; RectTransform obj2 = panel; Vector2 val = (panel.pivot = new Vector2((float)((!flag4) ? 1 : 0), 1f)); Vector2 anchorMin = (obj2.anchorMax = val); obj.anchorMin = anchorMin; panel.anchoredPosition = (flag4 ? new Vector2(22f, -145f) : new Vector2(-22f, -90f)); } ((Behaviour)canvas).enabled = flag3; } } catch (Exception ex) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogError((object)("[MVP] Results UI: " + ex)); } if ((Object)(object)canvas != (Object)null) { ((Behaviour)canvas).enabled = false; } pollAt = Time.unscaledTime + 3f; } } private void ReadInput() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (!bridgeResolved) { return; } KeyboardShortcut val; if (deathCounterBridge == null) { val = Plugin.toggleKey.Value; if (((KeyboardShortcut)(ref val)).IsDown()) { hotkeyVisible = !hotkeyVisible; pollAt = 0f; } } if (deathCounterBridge != null && inTruck && MvpRuntime.LastDisplay != null) { val = Plugin.detailsKey.Value; if (((KeyboardShortcut)(ref val)).IsDown()) { sharedDetailsVisible = !sharedDetailsVisible; pollAt = 0f; } } if (!((Object)(object)canvas == (Object)null) && ((Behaviour)canvas).enabled && localizedDisplay != null) { val = PreviousPage; int num; if (!((KeyboardShortcut)(ref val)).IsDown()) { val = NextPage; num = (((KeyboardShortcut)(ref val)).IsDown() ? 1 : 0); } else { num = -1; } int num2 = num; int val2 = Math.Max(0, (localizedDisplay.Players.Length - 1) / 5); int num3 = Math.Max(0, Math.Min(val2, page + num2)); if (num3 != page) { page = num3; pollAt = 0f; } } } private void ResolveBridge() { if (!bridgeResolved) { Type type = AccessTools.TypeByName("Matsu.RepoDeathCounter.Plugin"); deathCounterBridge = ((type == null) ? null : (AccessTools.Method(type, "SetLastLevelAwardsDetailed", (Type[])null, (Type[])null) ?? AccessTools.Method(type, "SetLastLevelAwards", (Type[])null, (Type[])null))); bridgeResolved = true; } } private void SendCompactSummary(AwardDisplay? result) { MethodInfo methodInfo = deathCounterBridge; if (!(methodInfo == null)) { object[] array = new object[3] { result?.Level ?? "", result?.Mvp ?? "", result?.Reverse ?? "" }; methodInfo.Invoke(null, (methodInfo.GetParameters().Length != 5) ? array : new object[5] { array[0], array[1], array[2], result?.ScoreDetails ?? "", result?.Rankings ?? "" }); } } private static bool IsTruck() { try { return (Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobby; } catch { return false; } } private void Render(AwardDisplay result, bool japanese) { //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)canvas == (Object)null) { Build(); } header.text = MvpLocalization.HeaderPrefix(japanese) + result.Level; bool flag = result.Players.Length == 1; mvp.text = ((!flag) ? result.Mvp : (japanese ? "ソロ成績" : "Solo result")); int num = page * 5; int num2 = Math.Max(0, Math.Min(5, result.Players.Length - num)); ((Component)status).gameObject.SetActive(num2 == 0 && !string.IsNullOrEmpty(result.ScoreDetails)); status.text = result.ScoreDetails; for (int i = 0; i < rows.Length; i++) { PlayerRow playerRow = rows[i]; ((Component)playerRow.Root).gameObject.SetActive(i < num2); if (i < num2) { AwardPlayerRow awardPlayerRow = result.Players[num + i]; int place = awardPlayerRow.Place; playerRow.Name.text = (flag ? awardPlayerRow.Name : $"#{place} {awardPlayerRow.Name}"); playerRow.Points.text = (japanese ? $"{awardPlayerRow.Total:0.#}点" : $"{awardPlayerRow.Total:0.#} PTS"); ((Graphic)playerRow.Points).color = ((place == 1 && awardPlayerRow.Total > 0f) ? Gold : Color.white); playerRow.Details.text = ((!string.IsNullOrEmpty(awardPlayerRow.PointsByCategory)) ? FormatCategoryLines(awardPlayerRow.PointsByCategory) : (japanese ? "得点対象の行動なし" : "No scoring activity")); } } float num3 = 82f + ((num2 > 0) ? ((float)num2 * 66f) : (((Component)status).gameObject.activeSelf ? 42f : 4f)); ((Graphic)oops).rectTransform.anchoredPosition = new Vector2(15f, 0f - num3 - 8f); oops.text = result.Reverse; ((Component)oops).gameObject.SetActive(!flag); int num4 = (result.Players.Length + 5 - 1) / 5; ((Graphic)pageHint).rectTransform.anchoredPosition = new Vector2(15f, 0f - num3 - 47f); pageHint.text = ((num4 > 1) ? $"{page + 1}/{num4} PGUP / PGDN" : ""); ((Component)pageHint).gameObject.SetActive(num4 > 1); panel.sizeDelta = new Vector2(566f, num3 + ((num4 > 1) ? 70f : (flag ? 10f : 52f))); } private static string FormatCategoryLines(string details) { string[] array = details.Split(new string[1] { " " }, StringSplitOptions.RemoveEmptyEntries); if (array.Length > 4) { return string.Join(" ", array, 0, 4) + "\n" + string.Join(" ", array, 4, array.Length - 4); } return details; } private void Build() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) font = Font.CreateDynamicFontFromOSFont(new string[4] { "Arial", "Yu Gothic UI", "Meiryo", "Liberation Sans" }, 20); ownsFont = (Object)(object)font != (Object)null; if ((Object)(object)font == (Object)null) { font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf") ?? Resources.GetBuiltinResource<Font>("Arial.ttf"); } if ((Object)(object)font == (Object)null) { throw new InvalidOperationException("Unity built-in font missing"); } pixel = new Texture2D(1, 1, (TextureFormat)4, false); pixel.SetPixel(0, 0, Color.white); pixel.Apply(false, true); sprite = Sprite.Create(pixel, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f)); GameObject val = new GameObject("REPO MVP Results Canvas", new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler) }); val.transform.SetParent(((Component)this).transform, false); canvas = val.GetComponent<Canvas>(); canvas.renderMode = (RenderMode)0; canvas.sortingOrder = 32001; ((Behaviour)canvas).enabled = false; CanvasScaler component = val.GetComponent<CanvasScaler>(); component.uiScaleMode = (ScaleMode)1; component.referenceResolution = new Vector2(1280f, 720f); component.matchWidthOrHeight = 0.5f; panel = Block(val.transform, "MVP panel", new Color(0.025f, 0.055f, 0.06f, 0.96f), Vector2.zero, new Vector2(566f, 140f)); Block((Transform)(object)panel, "Top accent", new Color(0.55f, 0.87f, 0.73f), Vector2.zero, new Vector2(566f, 3f)); header = Label((Transform)(object)panel, "Level", 14, SoftText, new Vector2(15f, -12f), new Vector2(536f, 22f), (TextAnchor)0); mvp = Label((Transform)(object)panel, "MVP", 21, Gold, new Vector2(15f, -37f), new Vector2(536f, 44f), (TextAnchor)0); status = Label((Transform)(object)panel, "Result status", 14, SoftText, new Vector2(15f, -82f), new Vector2(536f, 40f), (TextAnchor)0); for (int i = 0; i < rows.Length; i++) { RectTransform val2 = Block((Transform)(object)panel, "Player result " + (i + 1), new Color(0.09f, 0.16f, 0.17f, (i % 2 == 0) ? 0.94f : 0.6f), new Vector2(12f, -82f - (float)i * 66f), new Vector2(542f, 63f)); rows[i] = new PlayerRow { Root = val2, Name = Label((Transform)(object)val2, "Player name", 16, Color.white, new Vector2(10f, -5f), new Vector2(410f, 22f), (TextAnchor)0), Points = Label((Transform)(object)val2, "Total points", 17, Color.white, new Vector2(426f, -4f), new Vector2(105f, 24f), (TextAnchor)2), Details = Label((Transform)(object)val2, "Points by category", 13, SoftText, new Vector2(10f, -28f), new Vector2(520f, 34f), (TextAnchor)0) }; } oops = Label((Transform)(object)panel, "OOPS CHAMP", 15, new Color(1f, 0.68f, 0.61f), Vector2.zero, new Vector2(536f, 40f), (TextAnchor)0); pageHint = Label((Transform)(object)panel, "Pagination", 13, SoftText, Vector2.zero, new Vector2(536f, 19f), (TextAnchor)2); } private RectTransform Block(Transform parent, string name, Color color, Vector2 position, Vector2 size) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val.transform.SetParent(parent, false); Image component = val.GetComponent<Image>(); component.sprite = sprite; ((Graphic)component).color = color; ((Graphic)component).raycastTarget = false; Place(((Graphic)component).rectTransform, position, size); return ((Graphic)component).rectTransform; } private Text Label(Transform parent, string name, int size, Color color, Vector2 position, Vector2 dimensions, TextAnchor alignment = (TextAnchor)0) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Text) }); val.transform.SetParent(parent, false); Text component = val.GetComponent<Text>(); component.font = font; component.fontSize = size; component.fontStyle = (FontStyle)1; ((Graphic)component).color = color; component.alignment = alignment; component.horizontalOverflow = (HorizontalWrapMode)0; component.verticalOverflow = (VerticalWrapMode)0; component.supportRichText = false; ((Graphic)component).raycastTarget = false; Place(((Graphic)component).rectTransform, position, dimensions); return component; } private static void Place(RectTransform rect, Vector2 position, Vector2 dimensions) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rect.anchorMax = val; rect.anchorMin = val; rect.pivot = new Vector2(0f, 1f); rect.anchoredPosition = position; rect.sizeDelta = dimensions; } private void OnDestroy() { if ((Object)(object)sprite != (Object)null) { Object.Destroy((Object)(object)sprite); } if ((Object)(object)pixel != (Object)null) { Object.Destroy((Object)(object)pixel); } if (ownsFont && (Object)(object)font != (Object)null) { Object.Destroy((Object)(object)font); } } } internal sealed class AwardDisplay { internal string Level = ""; internal string Mvp = ""; internal string Reverse = ""; internal string ScoreDetails = ""; internal string Rankings = ""; internal string RoundToken = ""; internal bool GameOver; internal int Sequence; internal AwardPlayerRow[] Players = Array.Empty<AwardPlayerRow>(); } internal sealed class AwardPlayerRow { internal readonly int Place; internal readonly string Name; internal readonly float Total; internal readonly string PointsByCategory; internal AwardPlayerRow(int place, string name, float total, string pointsByCategory) { Place = place; Name = name; Total = total; PointsByCategory = pointsByCategory; } } internal static class MvpLocalization { private static readonly Dictionary<string, string> CategoryNamesJa = new Dictionary<string, string>(StringComparer.Ordinal) { ["HAUL"] = "納品", ["ROOMS"] = "部屋", ["VALUABLES"] = "貴重品", ["RESCUE"] = "救助", ["COMBAT"] = "戦闘", ["CONTROL"] = "スタン", ["SURVIVAL"] = "生存", ["VERSATILE"] = "役割ボーナス" }; private static bool reflectionResolved; private static MethodInfo? localeGetCodeMethod; private static FieldInfo? runManagerInstanceField; private static FieldInfo? previousRunLevelField; private static FieldInfo? levelPreviousField; private static FieldInfo? levelCurrentField; private static FieldInfo? levelsField; private static FieldInfo? levelArenaField; private static PropertyInfo? unityObjectNameProperty; private static FieldInfo? levelNarrativeNameField; private static FieldInfo? levelNarrativeLocalizedField; private static MethodInfo? getLocalizedStringMethod; internal static bool IsJapanese() { try { EnsureReflection(); return IsJapaneseLocaleCode(localeGetCodeMethod?.Invoke(null, null) as string); } catch { return false; } } internal static bool IsJapaneseLocaleCode(string? code) { if (!string.IsNullOrWhiteSpace(code)) { return code.Trim().StartsWith("ja", StringComparison.OrdinalIgnoreCase); } return false; } internal static string HeaderPrefix(bool japanese) { if (!japanese) { return "LAST LEVEL / "; } return "前回レベル / "; } internal static AwardDisplay Localize(AwardDisplay source, bool japanese, Func<string, string, string?>? levelNameResolver = null) { if (!japanese) { return source; } return new AwardDisplay { Level = LocalizeLevelName(source.Level, source.RoundToken, levelNameResolver), Mvp = LocalizeMvpLine(source.Mvp), Reverse = LocalizeReverseLine(source.Reverse), ScoreDetails = LocalizeScoreDetails(source.ScoreDetails), Rankings = LocalizeRankings(source.Rankings), Players = source.Players.Select((AwardPlayerRow player) => new AwardPlayerRow(player.Place, LocalizePlayerName(player.Name), player.Total, LocalizeScoreDetails(player.PointsByCategory))).ToArray(), GameOver = source.GameOver, RoundToken = source.RoundToken, Sequence = source.Sequence }; } internal static string LocalizeLevelName(string level, string roundToken, Func<string, string, string?>? customResolver = null) { string text = ((customResolver != null) ? customResolver(level, roundToken) : TryResolveGameLevelName(level, roundToken)); if (!string.IsNullOrWhiteSpace(text)) { return text; } if (string.IsNullOrWhiteSpace(level) || string.Equals(level, "LEVEL", StringComparison.OrdinalIgnoreCase)) { return "レベル"; } return level; } internal static string LocalizeMvpLine(string mvp) { if (string.IsNullOrEmpty(mvp)) { return ""; } if (mvp == "MVP DATA INCOMPLETE") { return "MVP データ不完全"; } if (mvp == "MVP NO ACTIVITY") { return "MVP 行動記録なし"; } if (TryParsePtsAward(mvp, "SOLO ", out string points, out string playerName)) { return "ソロ " + points + "点 " + LocalizePlayerName(playerName); } if (TryParsePtsAward(mvp, "MVP ", out string points2, out string playerName2)) { return "MVP " + points2 + "点 " + LocalizePlayerName(playerName2); } if (TryParsePtsAward(mvp, "CO-MVP ", out points2, out playerName2)) { return "共同MVP " + points2 + "点 " + LocalizePlayerName(playerName2); } return mvp; } internal static string LocalizeScoreDetails(string details) { if (string.IsNullOrEmpty(details)) { return ""; } if (details == "Missing round data or host change. Ranking unavailable.") { return "記録の不足またはホスト交代のため順位を表示できません"; } if (details == "NO ACTIVITY") { return "行動記録なし"; } string[] array = details.Split(new string[1] { " " }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { return details; } string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); int num = text.LastIndexOf(' '); if (num > 0) { string key = text.Substring(0, num); string text2 = text.Substring(num + 1); if (CategoryNamesJa.TryGetValue(key, out string value)) { array2[i] = value + " " + text2; continue; } } array2[i] = text; } return string.Join(" ", array2); } internal static string LocalizeRankings(string rankings) { if (string.IsNullOrEmpty(rankings)) { return ""; } int num = rankings.LastIndexOf(" #", StringComparison.Ordinal); if (num >= 0) { string text = LocalizeSingleRanking(rankings.Substring(0, num)); string text2 = LocalizeSingleRanking(rankings.Substring(num + 3)); return text + " " + text2; } return LocalizeSingleRanking(rankings); } private static string LocalizeSingleRanking(string entry) { if (!entry.StartsWith("#", StringComparison.Ordinal) || !entry.EndsWith(" PTS", StringComparison.Ordinal)) { return entry; } int num = entry.IndexOf(' '); if (num <= 1 || num + 5 >= entry.Length || !int.TryParse(entry.Substring(1, num - 1), out var result)) { return entry; } string text = entry.Substring(num + 1, entry.Length - num - 5); int num2 = text.LastIndexOf(' '); if (num2 <= 0) { return entry; } string arg = LocalizePlayerName(text.Substring(0, num2)); string arg2 = text.Substring(num2 + 1); return $"{result}位 {arg} {arg2}点"; } internal static string LocalizeReverseLine(string reverse) { if (string.IsNullOrEmpty(reverse)) { return ""; } switch (reverse) { case "OOPS CHAMP DATA INCOMPLETE": return "やらかし王 データ不完全"; case "OOPS CHAMP N/A (SOLO)": return "やらかし王 対象外 (ソロ)"; case "OOPS CHAMP NONE": return "やらかし王 該当なし"; default: { if (!reverse.StartsWith("OOPS CHAMP ", StringComparison.Ordinal)) { return reverse; } int num = reverse.IndexOf(" SETBACK ", "OOPS CHAMP ".Length, StringComparison.Ordinal); if (num <= "OOPS CHAMP ".Length) { return reverse; } string text = reverse.Substring("OOPS CHAMP ".Length, num - "OOPS CHAMP ".Length); int num2 = num + " SETBACK ".Length; int num3 = reverse.LastIndexOf(" / ", StringComparison.Ordinal); if (num3 < num2) { return reverse; } string text2 = LocalizePlayerName(reverse.Substring(num2, num3 - num2)); string text3 = LocalizeOopsReasons(reverse.Substring(num3 + 3)); if (!string.IsNullOrEmpty(text3)) { return "やらかし王 " + text + "点 " + text2 + " / " + text3; } return "やらかし王 " + text + "点 " + text2; } } } internal static string LocalizeOopsReasons(string reasonsRaw) { if (string.IsNullOrWhiteSpace(reasonsRaw)) { return ""; } string[] array = reasonsRaw.Split(new string[1] { ", " }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = LocalizeSingleOopsReason(array[i].Trim()); } return string.Join(", ", array2); } private static string LocalizeSingleOopsReason(string reason) { if (reason == "ENDED DOWN") { return "終了時ダウン"; } if (reason.EndsWith(" KOs", StringComparison.Ordinal)) { return "死亡" + reason.Substring(0, reason.Length - " KOs".Length) + "回"; } if (reason.EndsWith(" DMG", StringComparison.Ordinal)) { return "被ダメ" + reason.Substring(0, reason.Length - " DMG".Length); } if (reason.EndsWith(" HARD HITS", StringComparison.Ordinal)) { return "大ダメ" + reason.Substring(0, reason.Length - " HARD HITS".Length) + "回"; } if (reason.EndsWith(" HITS", StringComparison.Ordinal)) { return "被弾" + reason.Substring(0, reason.Length - " HITS".Length) + "回"; } if (reason.EndsWith(" LOW-HP", StringComparison.Ordinal)) { return "瀕死" + reason.Substring(0, reason.Length - " LOW-HP".Length) + "回"; } if (reason.EndsWith("s DOWN", StringComparison.Ordinal)) { return "ダウン" + reason.Substring(0, reason.Length - "s DOWN".Length) + "秒"; } return reason; } private static bool TryParsePtsAward(string line, string prefix, out string points, out string playerName) { points = ""; playerName = ""; if (!line.StartsWith(prefix, StringComparison.Ordinal)) { return false; } int num = line.IndexOf(" PTS ", prefix.Length, StringComparison.Ordinal); if (num <= prefix.Length) { return false; } points = line.Substring(prefix.Length, num - prefix.Length); playerName = line.Substring(num + " PTS ".Length); return true; } private static string LocalizePlayerName(string name) { if (!(name == "UNKNOWN PLAYER")) { return name; } return "不明なプレイヤー"; } private static void EnsureReflection() { if (reflectionResolved) { return; } reflectionResolved = true; try { localeGetCodeMethod = Type.GetType("SemiFunc, Assembly-CSharp")?.GetMethod("LocaleGetCode", BindingFlags.Static | BindingFlags.Public); Type type = Type.GetType("RunManager, Assembly-CSharp"); if (type != null) { runManagerInstanceField = type.GetField("instance", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); previousRunLevelField = type.GetField("previousRunLevel", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); levelPreviousField = type.GetField("levelPrevious", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); levelCurrentField = type.GetField("levelCurrent", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); levelsField = type.GetField("levels", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); levelArenaField = type.GetField("levelArena", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } Type type2 = Type.GetType("Level, Assembly-CSharp"); if (type2 != null) { unityObjectNameProperty = type2.GetProperty("name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); levelNarrativeNameField = type2.GetField("NarrativeName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); levelNarrativeLocalizedField = type2.GetField("NarrativeNameLocalized", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } Type type3 = Type.GetType("LocalizedAsset, Assembly-CSharp"); if (type3 != null) { getLocalizedStringMethod = type3.GetMethods(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "GetLocalizedString" && m.GetParameters().Length == 1); } } catch { } } private static string? TryResolveGameLevelName(string rawLevel, string roundToken) { try { EnsureReflection(); object obj = runManagerInstanceField?.GetValue(null); if (obj == null || levelNarrativeLocalizedField == null || getLocalizedStringMethod == null) { return null; } string text = ""; if (!string.IsNullOrEmpty(roundToken)) { int num = roundToken.IndexOf(':'); text = ((num >= 0 && num + 1 < roundToken.Length) ? roundToken.Substring(num + 1) : roundToken); } foreach (object item in EnumerateCandidateLevels(obj)) { if (item == null) { continue; } string a = unityObjectNameProperty?.GetValue(item, null) as string; string a2 = levelNarrativeNameField?.GetValue(item) as string; if ((string.IsNullOrEmpty(text) || (!string.Equals(a, text, StringComparison.Ordinal) && !string.Equals(a2, text, StringComparison.Ordinal))) && (string.IsNullOrEmpty(rawLevel) || (!string.Equals(a2, rawLevel, StringComparison.Ordinal) && !string.Equals(a, rawLevel, StringComparison.Ordinal)))) { continue; } object value = levelNarrativeLocalizedField.GetValue(item); if (value != null) { string text2 = getLocalizedStringMethod.Invoke(value, new object[1]) as string; if (!string.IsNullOrWhiteSpace(text2)) { return text2; } } } } catch { } return null; } private static IEnumerable<object?> EnumerateCandidateLevels(object runManager) { yield return previousRunLevelField?.GetValue(runManager); yield return levelPreviousField?.GetValue(runManager); yield return levelCurrentField?.GetValue(runManager); if (levelsField?.GetValue(runManager) is IEnumerable enumerable) { foreach (object item in enumerable) { yield return item; } } if (!(levelArenaField?.GetValue(runManager) is IEnumerable enumerable2)) { yield break; } foreach (object item2 in enumerable2) { yield return item2; } } } internal sealed class MvpMeasurements { private const float MaxItemValue = 100000f; internal const float MaxDeliveryUnits = 20f; internal const int MaxDeliveryReceipts = 4096; private readonly Dictionary<int, float> deliveryReceipts = new Dictionary<int, float>(); private readonly Dictionary<int, (float Budget, bool Rescue)> committedDeliveries = new Dictionary<int, (float, bool)>(); private readonly Dictionary<int, HashSet<int>> expectedByActor = new Dictionary<int, HashSet<int>>(); internal bool CommitDelivery(int itemId, float value, bool rescue) { if (itemId == 0 || !PositiveFinite(value) || committedDeliveries.ContainsKey(itemId)) { return false; } committedDeliveries.Add(itemId, (rescue ? 1f : Math.Min(100000f, value), rescue)); return true; } internal bool RecordReceipt(int itemId, float units) { if (itemId == 0 || !ValidUnits(units)) { return false; } if (deliveryReceipts.ContainsKey(itemId)) { return true; } if (deliveryReceipts.Count >= 4096) { return false; } deliveryReceipts.Add(itemId, Math.Min(20f, units)); return true; } internal IReadOnlyDictionary<int, float> SnapshotReceipts() { return new Dictionary<int, float>(deliveryReceipts); } internal void ExpectReceipts(int itemId, IEnumerable<int> actors) { foreach (int actor in actors) { if (!expectedByActor.TryGetValue(actor, out HashSet<int> value)) { expectedByActor.Add(actor, value = new HashSet<int>()); } value.Add(itemId); } } internal bool TryVerifyReceipts(IEnumerable<PlayerRoundStats> reports, out string reason) { HashSet<int> hashSet = new HashSet<int>(); foreach (PlayerRoundStats report in reports) { int actorNumber = report.ActorNumber; if (actorNumber <= 0 || !hashSet.Add(actorNumber)) { reason = "the report roster contains a missing or duplicate actor"; return false; } IReadOnlyDictionary<int, float> readOnlyDictionary = report.DeliveryReceipts; if (expectedByActor.TryGetValue(actorNumber, out HashSet<int> value)) { if (readOnlyDictionary == null || !value.SetEquals(readOnlyDictionary.Keys) || readOnlyDictionary.Values.Any((float units) => !ValidUnits(units))) { reason = $"actor {actorNumber} did not confirm the expected delivered items"; return false; } } else if (readOnlyDictionary != null && readOnlyDictionary.Count > 0) { reason = $"actor {actorNumber} confirmed items from outside their roster"; return false; } } foreach (int key in expectedByActor.Keys) { if (!hashSet.Contains(key)) { reason = $"actor {key} did not report after a delivery"; return false; } } reason = ""; return true; } internal void AllocateDeliveries(IEnumerable<PlayerRoundStats> reports) { PlayerRoundStats[] array = reports.ToArray(); PlayerRoundStats[] array2 = array; foreach (PlayerRoundStats obj in array2) { obj.Hauling = (obj.Rescue = 0f); } foreach (KeyValuePair<int, (float, bool)> item in committedDeliveries) { double num = ((IEnumerable<PlayerRoundStats>)array).Sum((Func<PlayerRoundStats, double>)((PlayerRoundStats player) => Claim(player, item.Key))); if (num <= 0.0) { continue; } double num2 = Math.Max(1.0, num); array2 = array; foreach (PlayerRoundStats playerRoundStats in array2) { float num3 = (float)((double)item.Value.Item1 * ((double)Claim(playerRoundStats, item.Key) / num2)); if (item.Value.Item2) { playerRoundStats.Rescue += num3; } else { playerRoundStats.Hauling += num3; } } } } private static float Claim(PlayerRoundStats player, int itemId) { if (player.DeliveryReceipts == null || !player.DeliveryReceipts.TryGetValue(itemId, out var value) || !PositiveFinite(value)) { return 0f; } return Math.Min(20f, value); } internal void Reset() { deliveryReceipts.Clear(); committedDeliveries.Clear(); expectedByActor.Clear(); } private static bool PositiveFinite(float value) { if (value > 0f) { return ValidUnits(value); } return false; } internal static bool ValidUnits(float units) { if (!float.IsNaN(units) && !float.IsInfinity(units)) { return units >= 0f; } return false; } } internal sealed class MvpRuntime : MonoBehaviour, IOnEventCallback, IInRoomCallbacks { private sealed class Participant { internal string SteamId = ""; internal string Name = ""; internal int ActorNumber; } private const byte ReportEvent = 79; private const byte AwardEvent = 80; private const float CloseoutSeconds = 3f; internal static MvpRuntime? Active; internal static AwardDisplay? LastDisplay; internal static int DisplayRevision; private readonly Dictionary<string, PlayerRoundStats> reports = new Dictionary<string, PlayerRoundStats>(StringComparer.Ordinal); private readonly Dictionary<string, float> combat = new Dictionary<string, float>(StringComparer.Ordinal); private readonly Dictionary<string, float> control = new Dictionary<string, float>(StringComparer.Ordinal); private readonly Dictionary<string, float> lastControlByTarget = new Dictionary<string, float>(StringComparer.Ordinal); private readonly MvpMeasurements measurements = new MvpMeasurements(); private readonly Dictionary<int, Participant> participantsByView = new Dictionary<int, Participant>(); private bool registered; private bool scopeInitialized; private Room? observedRoom; private bool sessionActive; private bool closing; private bool gameOver; private float sessionStart; private float closeoutDeadline; private float pollAt; private float roundSeconds; private int haulGoal; private int expectedPlayers; private int deaths; private int damage; private int damagingHits; private int heavyHits; private int criticalEpisodes; private float roomScouting; private float valuableDiscovery; private float downedSeconds; private float lastDownedPoll; private float lastDeathAt = -1000f; private int sequence; private int lastClosedSceneHandle = -1; private string levelName = ""; private string roundToken = ""; private bool authorityChanged; private bool deliveryDataMissing; private bool participantDeparted; private static bool Online { get { if (PhotonNetwork.InRoom) { return !PhotonNetwork.OfflineMode; } return false; } } private void Awake() { Active = this; } private void OnDestroy() { if (registered) { PhotonNetwork.RemoveCallbackTarget((object)this); } registered = false; if ((Object)(object)Active == (Object)(object)this) { Active = null; } } private void Update() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < pollAt) { return; } pollAt = Time.unscaledTime + 0.25f; try { RefreshSessionScope(); bool flag = PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode; if (flag && !registered) { PhotonNetwork.AddCallbackTarget((object)this); registered = true; } else if (!flag && registered) { PhotonNetwork.RemoveCallbackTarget((object)this); registered = false; } bool flag2 = Plugin.IsGameplayLevel() && ((object)SceneManager.GetActiveScene()/*cast due to .constrained prefix*/).GetHashCode() != lastClosedSceneHandle && (Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated && (Object)(object)PlayerAvatar.instance != (Object)null; if (closing && !Plugin.IsHost() && flag2) { closing = false; } if (!sessionActive && !closing && flag2) { StartRound(); } if (sessionActive && Plugin.IsGameplayLevel()) { CaptureParticipants(); float realtimeSinceStartup = Time.realtimeSinceStartup; PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null && (bool)Plugin.AvatarDead.GetValue(instance)) { downedSeconds += Mathf.Clamp(realtimeSinceStartup - lastDownedPoll, 0f, 1f); } lastDownedPoll = realtimeSinceStartup; } if (closing && Plugin.IsHost() && Time.realtimeSinceStartup >= closeoutDeadline) { FinalizeRound(); } } catch (Exception ex) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogError((object)("[MVP] Runtime update: " + ex)); } } } private void RefreshSessionScope() { Room val = ((PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode) ? PhotonNetwork.CurrentRoom : null); if (scopeInitialized && observedRoom != val) { ResetSession(); } observedRoom = val; scopeInitialized = true; } internal void ResetSession() { sessionActive = (closing = (authorityChanged = (deliveryDataMissing = (participantDeparted = (gameOver = false))))); deaths = (damage = (damagingHits = (heavyHits = (criticalEpisodes = 0)))); roomScouting = (valuableDiscovery = (downedSeconds = (roundSeconds = 0f))); measurements.Reset(); combat.Clear(); control.Clear(); lastControlByTarget.Clear(); reports.Clear(); participantsByView.Clear(); expectedPlayers = (sequence = (haulGoal = 0)); lastClosedSceneHandle = -1; levelName = (roundToken = ""); LastDisplay = null; DisplayRevision++; } private void StartRound() { sessionActive = true; closing = false; lastClosedSceneHandle = -1; deaths = (damage = (damagingHits = (heavyHits = (criticalEpisodes = 0)))); roomScouting = (valuableDiscovery = (downedSeconds = 0f)); haulGoal = 0; lastDeathAt = -1000f; combat.Clear(); control.Clear(); lastControlByTarget.Clear(); measurements.Reset(); reports.Clear(); participantsByView.Clear(); authorityChanged = (deliveryDataMissing = (participantDeparted = false)); sessionStart = Time.realtimeSinceStartup; lastDownedPoll = sessionStart; CaptureParticipants(); levelName = RunManager.instance.levelCurrent?.NarrativeName ?? "LEVEL"; if (LastDisplay != null) { LastDisplay = null; DisplayRevision++; } ManualLogSource? log = Plugin.Log; if (log != null) { log.LogInfo((object)("[MVP] Collecting " + levelName)); } } internal void RecordDamage(int amount, bool enteredCritical) { if (sessionActive && !closing && amount > 0) { damage = Math.Min(10000, damage + amount); damagingHits = Math.Min(100, damagingHits + 1); if (amount >= 25) { heavyHits = Math.Min(100, heavyHits + 1); } if (enteredCritical) { criticalEpisodes = Math.Min(20, criticalEpisodes + 1); } } } internal void RecordDeath() { if (sessionActive && !closing && !(Time.unscaledTime - lastDeathAt < 0.5f)) { lastDeathAt = Time.unscaledTime; deaths = Math.Min(100, deaths + 1); } } internal void RecordCombat(string steamId, int actualHpLoss) { if (sessionActive && !closing && Plugin.IsHost() && !string.IsNullOrEmpty(steamId)) { combat.TryGetValue(steamId, out var value); combat[steamId] = Math.Min(10000f, value + (float)Math.Max(0, actualHpLoss)); } } internal void RecordRoomDiscovery(float points) { if (sessionActive && !closing && points > 0f) { roomScouting = Math.Min(100000f, roomScouting + points); } } internal void RecordValuableDiscovery(float points) { if (sessionActive && !closing && points > 0f) { valuableDiscovery = Math.Min(100000f, valuableDiscovery + points); } } internal void RecordExtractedValuable(ExtractionPoint point, ValuableObject valuable) { if (!CanRecordDelivery(point) || (Object)(object)valuable == (Object)null) { return; } int num; if (!Online) { num = ((Object)valuable).GetInstanceID(); } else { object? value = Plugin.ValuableView.GetValue(valuable); object? obj = ((value is PhotonView) ? value : null); num = ((obj != null) ? ((PhotonView)obj).ViewID : 0); } int num2 = num; if (num2 == 0 || (Online && num2 < 0)) { FlagDeliveryDataMissing("an extracted valuable had no view ID"); return; } float num3 = (float)Plugin.ValuableDollarValue.GetValue(valuable); if (!MvpMeasurements.ValidUnits(num3)) { FlagDeliveryDataMissing("an extracted valuable had an invalid price"); } else if (measurements.CommitDelivery(num2, num3, rescue: false)) { RecordReceipt(num2, Plugin.TryReadDeliveryUnits(valuable, ((Component)point).gameObject, out var units), units); BroadcastDelivery(point, num2, rescue: false); } } internal void RecordExtractedRescue(ExtractionPoint point, PlayerDeathHead head) { if (CanRecordDelivery(point) && !((Object)(object)head == (Object)null)) { int num; if (!Online) { num = ((Object)head).GetInstanceID(); } else { object? value = Plugin.HeadView.GetValue(head); object? obj = ((value is PhotonView) ? value : null); num = ((obj != null) ? ((PhotonView)obj).ViewID : 0); } int num2 = num; if (num2 == 0 || (Online && num2 < 0)) { FlagDeliveryDataMissing("a revived death head had no view ID"); } else if (measurements.CommitDelivery(num2, 1f, rescue: true)) { RecordRescueReceipt(point, head, num2); BroadcastDelivery(point, num2, rescue: true); } } } private bool CanRecordDelivery(ExtractionPoint point) { if (sessionActive && !closing && Plugin.IsHost() && (Object)(object)point != (Object)null) { object value = Plugin.ExtractionIsShop.GetValue(point); if (value is bool) { return !(bool)value; } return false; } return false; } private static string CurrentRoundToken() { if (!((Object)(object)RunManager.instance == (Object)null)) { string text = RunManager.instance.levelsCompleted.ToString(); Level levelCurrent = RunManager.instance.levelCurrent; return text + ":" + ((levelCurrent != null) ? ((Object)levelCurrent).name : null); } return ""; } private void BroadcastDelivery(ExtractionPoint point, int itemId, bool rescue) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown if (!Online) { return; } Player localPlayer = PhotonNetwork.LocalPlayer; int hostActor = ((localPlayer != null) ? localPlayer.ActorNumber : 0); Room currentRoom = PhotonNetwork.CurrentRoom; int[] array = ((currentRoom != null) ? currentRoom.Players.Keys.Where((int actor) => actor > 0).ToArray() : null); if (hostActor <= 0 || array == null || !Extensions.Contains(array, hostActor)) { FlagDeliveryDataMissing("could not identify the players present at delivery"); return; } measurements.ExpectReceipts(itemId, array); int[] array2 = array.Where((int actor) => actor != hostActor).ToArray(); if (array2.Length != 0) { object? value = Plugin.ExtractionView.GetValue(point); PhotonView val = (PhotonView)((value is PhotonView) ? value : null); if (val == null || (Object)(object)val == (Object)null || val.ViewID <= 0) { FlagDeliveryDataMissing("an extraction point had no view ID"); } else if (!PhotonNetwork.RaiseEvent((byte)81, (object)MvpWire.CreateDelivery(CurrentRoundToken(), val.ViewID, itemId, rescue), new RaiseEventOptions { TargetActors = array2 }, SendOptions.SendReliable)) { FlagDeliveryDataMissing("could not announce extracted item " + itemId); } } } private void RecordReceipt(int itemId, bool hasTracking, float units) { if (!hasTracking || !measurements.RecordReceipt(itemId, units)) { FlagDeliveryDataMissing("no valid tracking record for extracted item " + itemId); } } private void RecordRescueReceipt(ExtractionPoint point, PlayerDeathHead head, int itemId) { float units = 0f; bool hasTracking = (Object)(object)head.playerAvatar != (Object)null && ((Object)(object)head.playerAvatar == (Object)(object)PlayerAvatar.instance || Plugin.TryReadDeliveryUnits(head, ((Component)point).gameObject, out units)); RecordReceipt(itemId, hasTracking, units); } internal void FlagDeliveryDataMissing(string reason) { if (sessionActive && !closing && !deliveryDataMissing) { deliveryDataMissing = true; ManualLogSource? log = Plugin.Log; if (log != null) { log.LogWarning((object)("[MVP] Delivery data incomplete: " + reason)); } } } internal void RecordControl(string steamId, int enemyId, float seconds) { if (sessionActive && !closing && Plugin.IsHost() && !string.IsNullOrEmpty(steamId) && !(seconds < 0.5f)) { string key = steamId + ":" + enemyId; float realtimeSinceStartup = Time.realtimeSinceStartup; if (!lastControlByTarget.TryGetValue(key, out var value) || !(realtimeSinceStartup - value < 5f)) { lastControlByTarget[key] = realtimeSinceStartup; control.TryGetValue(steamId, out var value2); control[steamId] = Math.Min(1000f, value2 + Math.Min(seconds, 5f)); } } } internal void CloseRound(bool isGameOver) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown RefreshSessionScope(); if (!sessionActive || closing) { return; } try { roundSeconds = Mathf.Max(0f, Time.realtimeSinceStartup - sessionStart); lastClosedSceneHandle = ((object)SceneManager.GetActiveScene()/*cast due to .constrained prefix*/).GetHashCode(); roundToken = CurrentRoundToken(); haulGoal = (((Object)(object)RoundDirector.instance != (Object)null) ? ((int)Plugin.RoundHaulGoal.GetValue(RoundDirector.instance)) : 0); gameOver = isGameOver; PlayerAvatar instance = PlayerAvatar.instance; PlayerRoundStats obj = new PlayerRoundStats { SteamId = Plugin.Id(instance), Name = Plugin.PlayerName(instance) }; int actorNumber; if (!Online) { actorNumber = 0; } else { Player localPlayer = PhotonNetwork.LocalPlayer; actorNumber = ((localPlayer != null) ? localPlayer.ActorNumber : 0); } obj.ActorNumber = actorNumber; obj.RoomScouting = roomScouting; obj.ValuableDiscovery = valuableDiscovery; obj.Deaths = deaths; obj.DamageTaken = damage; obj.DamagingHits = damagingHits; obj.HeavyHits = heavyHits; obj.CriticalEpisodes = criticalEpisodes; obj.DownedSeconds = downedSeconds; obj.ParticipationSeconds = roundSeconds; obj.AliveAtEnd = (Object)(object)instance != (Object)null && !(bool)Plugin.AvatarDead.GetValue(instance); obj.DeliveryReceipts = measurements.SnapshotReceipts(); obj.DeliveryDataMissing = deliveryDataMissing; PlayerRoundStats playerRoundStats = obj; sessionActive = false; closing = true; CaptureParticipants(); if (!string.IsNullOrEmpty(playerRoundStats.SteamId) && playerRoundStats.ParticipationSeconds > 0f) { reports[playerRoundStats.SteamId] = playerRoundStats; } expectedPlayers = Math.Max(reports.Count, participantsByView.Values.Select((Participant participant) => participant.SteamId).Distinct<string>(StringComparer.Ordinal).Count()); closeoutDeadline = Time.realtimeSinceStartup + 3f; if (!Plugin.IsHost() && (Object)(object)instance != (Object)null && (Object)(object)instance.photonView != (Object)null && instance.photonView.ViewID > 0 && PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode && !PhotonNetwork.RaiseEvent((byte)79, (object)MvpWire.CreateReport(roundToken, instance.photonView.ViewID, playerRoundStats), new RaiseEventOptions { Receivers = (ReceiverGroup)2 }, SendOptions.SendReliable)) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogWarning((object)("[MVP] Guest report could not be sent for " + levelName)); } } ManualLogSource? log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)$"[MVP] Closed {levelName}: quota={haulGoal}, delivery receipts={playerRoundStats.DeliveryReceipts.Count}, rooms={playerRoundStats.RoomScouting:0}, valuables={playerRoundStats.ValuableDiscovery:0}, deaths={playerRoundStats.Deaths}, damage={playerRoundStats.DamageTaken}, hits={playerRoundStats.DamagingHits}, heavy={playerRoundStats.HeavyHits}, critical={playerRoundStats.CriticalEpisodes}"); } } catch (Exception ex) { sessionActive = (closing = false); ManualLogSource? log3 = Plugin.Log; if (log3 != null) { log3.LogError((object)("[MVP] Level closeout failed: " + ex)); } } } private void CaptureParticipants() { try { if ((Object)(object)GameDirector.instance == (Object)null) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && !((Object)(object)player.photonView == (Object)null) && player.photonView.ViewID > 0 && player.photonView.Owner != null) { string text = Plugin.Id(player); if (!string.IsNullOrEmpty(text)) { participantsByView[player.photonView.ViewID] = new Participant { SteamId = text, Name = Plugin.PlayerName(player), ActorNumber = player.photonView.Owner.ActorNumber }; } } } } catch (Exception ex) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogWarning((object)("[MVP] Could not snapshot all closeout participants: " + ex.Message)); } } } public void OnEvent(EventData photonEvent) { try { RefreshSessionScope(); if (photonEvent.Code == 79 && Plugin.IsHost()) { ReceiveReport(photonEvent); } else if (photonEvent.Code == 80 && !Plugin.IsHost()) { ReceiveAward(photonEvent); } else if (photonEvent.Code == 81 && !Plugin.IsHost()) { ReceiveDelivery(photonEvent); } } catch (Exception ex) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogError((object)("[MVP] Photon event: " + ex)); } } } private void ReceiveDelivery(EventData photonEvent) { if (!sessionActive || closing || PhotonNetwork.MasterClient == null || photonEvent.Sender != PhotonNetwork.MasterClient.ActorNumber || !MvpWire.TryReadDelivery(photonEvent.CustomData, CurrentRoundToken(), out var pointViewId, out var itemViewId, out var rescue)) { return; } try { PhotonView val = PhotonView.Find(pointViewId); PhotonView val2 = PhotonView.Find(itemViewId); ExtractionPoint val3 = default(ExtractionPoint); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && ((Component)val).gameObject.TryGetComponent<ExtractionPoint>(ref val3)) { PlayerDeathHead head = default(PlayerDeathHead); if (rescue && ((Component)val2).gameObject.TryGetComponent<PlayerDeathHead>(ref head)) { RecordRescueReceipt(val3, head, itemViewId); return; } ValuableObject valuable = default(ValuableObject); if (!rescue && ((Component)val2).gameObject.TryGetComponent<ValuableObject>(ref valuable)) { RecordReceipt(itemViewId, Plugin.TryReadDeliveryUnits(valuable, ((Component)val3).gameObject, out var units), units); return; } } FlagDeliveryDataMissing("could not resolve extracted item " + itemViewId); } catch (Exception ex) { FlagDeliveryDataMissing("could not measure extracted item " + itemViewId + ": " + ex.Message); } } private void ReceiveReport(EventData photonEvent) { if (!closing || Time.realtimeSinceStartup > closeoutDeadline + 1f || !MvpWire.TryReadReport(photonEvent.CustomData, roundToken, roundSeconds, out int viewId, out PlayerRoundStats report) || !participantsByView.TryGetValue(viewId, out Participant value) || value.ActorNumber != photonEvent.Sender) { return; } string steamId = value.SteamId; if (!string.IsNullOrEmpty(steamId) && !reports.ContainsKey(steamId)) { report.SteamId = steamId; report.Name = value.Name; report.ActorNumber = value.ActorNumber; reports[steamId] = report; ManualLogSource? log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[MVP] Accepted level report from actor {photonEvent.Sender} ({reports.Count}/{expectedPlayers})"); } } } private void FinalizeRound() { closing = false; bool flag = reports.Count < expectedPlayers; if (flag) { string text = string.Join(", ", from actor in (from participant in participantsByView.Values where !reports.ContainsKey(participant.SteamId) select participant.ActorNumber).Distinct() orderby actor select actor); ManualLogSource? log = Plugin.Log; if (log != null) { log.LogWarning((object)("[MVP] Missing level reports from actor(s) " + text + ". Every player needs the same RepoLevelMVP build for complete results.")); } } bool flag2 = deliveryDataMissing || reports.Values.Any((PlayerRoundStats report) => report.DeliveryDataMissing); if (flag2) { ManualLogSource? log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[MVP] At least one participant could not measure all deliveries."); } } if (Online && !flag2 && !measurements.TryVerifyReceipts(reports.Values, out string reason)) { flag2 = true; ManualLogSource? log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)("[MVP] Delivery reconciliation failed: " + reason)); } } bool flag3 = participantDeparted || participantsByView.Values.GroupBy<Participant, string>((Participant participant) => participant.SteamId, StringComparer.Ordinal).Any((IGrouping<string, Participant> group) => group.Select((Participant participant) => participant.ActorNumber).Distinct().Skip(1) .Any()); if (flag3) { ManualLogSource? log4 = Plugin.Log; if (log4 != null) { log4.LogWarning((object)"[MVP] A player left or rejoined during the level."); } } LevelAwards levelAwards = new LevelAwards { Incomplete = (authorityChanged || flag || flag2 || flag3) }; if (!levelAwards.Incomplete) { measurements.AllocateDeliveries(reports.Values); foreach (PlayerRoundStats value3 in reports.Values) { if (combat.TryGetValue(value3.SteamId, out var value)) { value3.CombatDamage = value; } if (control.TryGetValue(value3.SteamId, out var value2)) { value3.CrowdControl = value2; } } levelAwards = MvpScoring.Evaluate(reports.Values, roundSeconds, incomplete: false, haulGoal); LogScores(levelAwards); } AwardDisplay awardDisplay = FormatAwards(levelAwards); awardDisplay.Level = levelName; awardDisplay.GameOver = gameOver; awardDisplay.RoundToken = roundToken; awardDisplay.Sequence = ++sequence; ApplyDisplay(awardDisplay); BroadcastAward(); ManualLogSource? log5 = Plugin.Log; if (log5 != null) { log5.LogInfo((object)$"[MVP] Result: {awardDisplay.Mvp}; {awardDisplay.Reverse}; reports={reports.Count}/{expectedPlayers}"); } } private void LogScores(LevelAwards awards) { foreach (PlayerAwardScore item in awards.Ranked) { PlayerRoundStats player = item.Player; int actorNumber = player.ActorNumber; int num; if (PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode) { Player masterClient = PhotonNetwork.MasterClient; num = ((masterClient != null && masterClient.ActorNumber == actorNumber) ? 1 : 0); } else { num = 1; } bool flag = (byte)num != 0; ManualLogSource? log = Plugin.Log; if (log != null) { log.LogInfo((object)($"[MVP] Score actor={actorNumber}, host={flag}, name={SafeName(player.Name, 32)}: " + $"raw(haul={player.Hauling:0.##}, rooms={player.RoomScouting:0.##}, valuables={player.ValuableDiscovery:0.##}, " + $"rescue={player.Rescue:0.##}, " + $"combat={player.CombatDamage:0.##}, control={player.CrowdControl:0.##}, deaths={player.Deaths}, " + $"damage={player.DamageTaken}, hits={player.DamagingHits}, heavy={player.HeavyHits}, " + $"critical={player.CriticalEpisodes}, downed={player.DownedSeconds:0.##}); " + $"points(total={item.Total:0.##}, haul={item.Hauling:0.##}, rooms={item.Rooms:0.##}, " + $"valuables={item.Valuables:0.##}, rescue={item.Rescue:0.##}, combat={item.Combat:0.##}, " + $"control={item.Control:0.##}, survival={item.Survival:0.##}, versatile={item.Versatility:0.##}, " + $"oops={item.Mishap:0.##})")); } } } private static AwardDisplay FormatAwards(LevelAwards awards) { AwardDisplay awardDisplay = new AwardDisplay(); if (awards.Incomplete) { awardDisplay.Mvp = "MVP DATA INCOMPLETE"; awardDisplay.Reverse = "OOPS CHAMP DATA INCOMPLETE"; awardDisplay.ScoreDetails = "Missing round data or host change. Ranking unavailable."; return awardDisplay; } awardDisplay.Players = new AwardPlayerRow[awards.Ranked.Count]; int place = 0; float num = -1f; for (int i = 0; i < awards.Ranked.Count; i++) { PlayerAwardScore playerAwardScore = awards.Ranked[i]; if (playerAwardScore.Total != num) { place = i + 1; } num = playerAwardScore.Total; awardDisplay.Players[i] = new AwardPlayerRow(place, SafeName(playerAwardScore.Player.Name, 32), playerAwardScore.Total, ScoreDetails(playerAwardScore, int.MaxValue)); } if (awards.Ranked.Count == 1) { PlayerAwardScore playerAwardScore2 = awards.Ranked[0]; awardDisplay.Mvp = $"SOLO {playerAwardScore2.Total:0.#} PTS {SafeName(playerAwardScore2.Player.Name, 24)}"; awardDisplay.ScoreDetails = (awards.HasActivity ? ScoreDetails(playerAwardScore2) : "NO ACTIVITY"); awardDisplay.Reverse = "OOPS CHAMP N/A (SOLO)"; return awardDisplay; } PlayerAwardScore mvp = awards.Mvp; awardDisplay.Mvp = "MVP NO ACTIVITY"; if (mvp != null) { int count = awards.MvpWinners.Count; if (count > 1) { string text = string.Join(" + ", from score in awards.MvpWinners.Take(2) select SafeName(score.Player.Name, 16)); if (count > 2) { text += $" +{count - 2}"; } awardDisplay.Mvp = $"CO-MVP {mvp.Total:0.#} PTS {text}"; } else { awardDisplay.Mvp = $"MVP {mvp.Total:0.#} PTS {SafeName(mvp.Player.Name, 24)}"; awardDisplay.ScoreDetails = ScoreDetails(mvp); } awardDisplay.Rankings = string.Join(" ", from row in awardDisplay.Players.Where((AwardPlayerRow row) => row.Place > 1 && row.Total > 0f).Take(2) select $"#{row.Place} {SafeName(row.Name, 11)} {row.Total:0.#} PTS"); } PlayerAwardScore reverseMvp = awards.ReverseMvp; awardDisplay.Reverse = ((reverseMvp == null) ? "OOPS CHAMP NONE" : $"OOPS CHAMP {reverseMvp.Mishap:0} SETBACK {SafeName(reverseMvp.Player.Name, 16)} / {OopsReason(reverseMvp)}"); return awardDisplay; } private static string ScoreDetails(PlayerAwardScore score, int limit = 3) { return string.Join(" ", from category in (from category in score.Categories() where category.Points > 0f orderby category.Points descending select category).Take(limit) select $"{category.Name} {category.Points:0.#}"); } private static string SafeName(string name, int maximum) { name = (name ?? "UNKNOWN PLAYER").Replace('<', '‹').Replace('>', '›').Replace('\r', ' ') .Replace('\n', ' '); if (name.Length > maximum) { return name.Substring(0, maximum - 1) + "…"; } return name; } private static string OopsReason(PlayerAwardScore score) { PlayerRoundStats player = score.Player; List<(float, string)> list = new List<(float, string)>(); if (player.Deaths > 0) { list.Add(((float)Math.Min(3, player.Deaths) * 85f, $"{player.Deaths} KOs")); } if (player.DamageTaken > 0) { list.Add(((float)Math.Min(300, player.DamageTaken) * 0.25f, $"{player.DamageTaken} DMG")); } if (player.DamagingHits > 0) { list.Add(((float)Math.Min(12, player.DamagingHits) * 3f, $"{player.DamagingHits} HITS")); } if (player.HeavyHits > 0) { list.Add(((float)Math.Min(6, player.HeavyHits) * 6f, $"{player.HeavyHits} HARD HITS")); } if (player.CriticalEpisodes > 0) { list.Add(((float)Math.Min(4, player.CriticalEpisodes) * 12f, $"{player.CriticalEpisodes} LOW-HP")); } if (player.DownedSeconds >= 1f) { list.Add((Math.Min(90f, player.DownedSeconds) * 0.45f, $"{player.DownedSeconds:0}s DOWN")); } if (!player.AliveAtEnd && (player.Deaths > 0 || player.DownedSeconds > 0f)) { list.Add((20f, "ENDED DOWN")); } return string.Join(", ", (from item in list.OrderByDescending<(float, string), float>(((float Weight, string Label) item) => item.Weight).Take(2) select item.Label).ToArray()); } private static void ApplyDisplay(AwardDisplay display) { if (LastDisplay == null || display.Sequence > LastDisplay.Sequence) { if ((Object)(object)Active != (Object)null) { Active.sequence = Math.Max(Active.sequence, display.Sequence); } LastDisplay = display; DisplayRevision++; } } private void BroadcastAward(int[]? targets = null) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (LastDisplay == null || !PhotonNetwork.InRoom || PhotonNetwork.OfflineMode) { return; } RaiseEventOptions val = ((targets == null) ? new RaiseEventOptions { Receivers = (ReceiverGroup)0 } : new RaiseEventOptions { TargetActors = targets }); if (!PhotonNetwork.RaiseEvent((byte)80, (object)MvpWire.CreateAward(LastDisplay), val, SendOptions.SendReliable)) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogWarning((object)"[MVP] Award result could not be broadcast"); } } } private void ReceiveAward(EventData photonEvent) { if (!sessionActive && PhotonNetwork.MasterClient != null && photonEvent.Sender == PhotonNetwork.MasterClient.ActorNumber && MvpWire.TryReadAward(photonEvent.CustomData, roundToken, out AwardDisplay display)) { ApplyDisplay(display); closing = false; } } public void OnPlayerEnteredRoom(Player newPlayer) { if (Plugin.IsHost() && LastDisplay != null) { BroadcastAward(new int[1] { newPlayer.ActorNumber }); } } public void OnPlayerLeftRoom(Player otherPlayer) { if (sessionActive) { participantDeparted = true; } } public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged) { } public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps) { } public void OnMasterClientSwitched(Player newMasterClient) { if (sessionActive || closing) { authorityChanged = true; } if (closing && Plugin.IsHost()) { closeoutDeadline = Time.realtimeSinceStartup + 3f; ManualLogSource? log = Plugin.Log; if (log != null) { log.LogWarning((object)"[MVP] Host changed during closeout; ranking will be incomplete."); } } if (Plugin.IsHost() && LastDisplay != null) { BroadcastAward(); } } } public sealed class PlayerRoundStats { public string SteamId = ""; public string Name = ""; public float Hauling; public float RoomScouting; public float ValuableDiscovery; public float Rescue; public float CombatDamage; public float CrowdControl; public int Deaths; public int DamageTaken; public int DamagingHits; public int HeavyHits; public int CriticalEpisodes; public float DownedSeconds; public float ParticipationSeconds; public bool AliveAtEnd; internal IReadOnlyDictionary<int, float>? DeliveryReceipts; internal int ActorNumber; internal bool DeliveryDataMissing; } public sealed class PlayerAwardScore { public PlayerRoundStats Player; public float Total; public float Hauling; public float Rooms; public float Valuables; public float Rescue; public float Combat; public float Control; public float Versatility; public float Survival; public float Mishap; public string LeadingCategory => (from entry in Categories() orderby entry.Points descending select entry).First().Name; internal (string Name, float Points)[] Categories() { return new(string, float)[8] { ("HAUL", Hauling), ("ROOMS", Rooms), ("VALUABLES", Valuables), ("RESCUE", Rescue), ("COMBAT", Combat), ("CONTROL", Control), ("SURVIVAL", Survival), ("VERSATILE", Versatility) }; } } public sealed class LevelAwards { public IReadOnlyList<PlayerAwardScore> Ranked = Array.Empty<PlayerAwardScore>(); public PlayerAwardScore? Mvp; public IReadOnlyList<PlayerAwardScore> MvpWinners = Array.Empty<PlayerAwardScore>(); public PlayerAwardScore? ReverseMvp; public bool HasActivity; public bool Incomplete; } public static class MvpScoring { private const float HaulingBudget = 30f; private const float RoomBudget = 10f; private const float DiscoveryBudget = 10f; private const float RescueBudget = 14f; private const float CombatBudget = 14f; private const float ControlBudget = 6f; private const float MinimumOopsScore = 15f; public static LevelAwards Evaluate(IEnumerable<PlayerRoundStats> reports, float levelSeconds, bool incomplete = false, int haulGoal = 0) { if (reports == null) { throw new ArgumentNullException("reports"); } levelSeconds = Valid(levelSeconds, float.MaxValue); float target = ((haulGoal > 0) ? ((float)Math.Max(8000, haulGoal)) : 12000f); List<PlayerRoundStats> list = (from @group in reports.Where((PlayerRoundStats player) => player != null && !string.IsNullOrWhiteSpace(player.SteamId) && player.ParticipationSeconds > 0f && !float.IsInfinity(player.ParticipationSeconds)).GroupBy<PlayerRoundStats, string>((PlayerRoundStats player) => player.SteamId, StringComparer.Ordinal) select @group.OrderByDescending((PlayerRoundStats player) => player.ParticipationSeconds).First()).ToList(); LevelAwards awards = new LevelAwards { Incomplete = incomplete }; List<PlayerAwardScore> list2 = new List<PlayerAwardScore>(list.Count); foreach (PlayerRoundStats item in list) { PlayerAwardScore playerAwardScore = new PlayerAwardScore { Player = item, Hauling = Category(item.Hauling, target, 30f), Rooms = Category(item.RoomScouting, 400f, 10f), Valuables = Category(item.ValuableDiscovery, 1000f, 10f), Rescue = Category(item.Rescue, 2f, 14f), Combat = Category(item.CombatDamage, 250f, 14f), Control = Category(item.CrowdControl, 12f, 6f) }; float num = Contribution(playerAwardScore); playerAwardScore.Versatility = 1.5f * (float)Math.Max(0, CountRoles(playerAwardScore) - 1); int num2 = Math.Max(0, Math.Min(20, item.Deaths)); int num3 = Math.Max(0, Math.Min(2000, item.DamageTaken)); int val = Math.Max(0, Math.Min(20, item.DamagingHits)); int val2 = Math.Max(0, Math.Min(20, item.HeavyHits)); int val3 = Math.Max(0, Math.Min(10, item.CriticalEpisodes)); float num4 = Valid(item.DownedSeconds, levelSeconds); float num5 = Math.Max(0f, 1f - (float)num2 * 0.35f - (float)num3 / 500f - ((levelSeconds > 0f) ? (num4 / levelSeconds * 0.2f) : 0f)); if (!item.AliveAtEnd) { num5 *= 0.5f; } playerAwardScore.Survival = RoundPoints(Math.Min(10f, num * 0.25f) * num5); playerAwardScore.Total = RoundPoints(num + playerAwardScore.Survival + playerAwardScore.Versatility); awards.HasActivity |= playerAwardScore.Total > 0f; playerAwardScore.Mishap = (float)Math.Min(3, num2) * 85f + (float)Math.Min(300, num3) * 0.25f + (float)Math.Min(12, val) * 3f + (float)Math.Min(6, val2) * 6f + (float)Math.Min(4, val3) * 12f + Math.Min(90f, num4) * 0.45f + ((!item.AliveAtEnd && (num2 > 0 || num4 > 0f)) ? 20f : 0f); list2.Add(playerAwardScore); } awards.Ranked = list2.OrderByDescending((PlayerAwardScore score) => score.Total).ThenBy<PlayerAwardScore, string>((PlayerAwardScore score) => score.Player.SteamId, StringComparer.Ordinal).ToArray(); if (list.Count > 1 && awards.HasActivity) { awards.Mvp = awards.Ranked[0]; awards.MvpWinners = awards.Ranked.TakeWhile((PlayerAwardScore score) => score.Total == awards.Mvp.Total).ToArray(); } if (list.Count > 1) { awards.ReverseMvp = (from score in list2 where score.Mishap >= 15f && !awards.MvpWinners.Contains(score) orderby score.Mishap descending, score.Player.Deaths descending select score).ThenBy<PlayerAwardScore, string>((PlayerAwardScore score) => score.Player.SteamId, StringComparer.Ordinal).FirstOrDefault(); } return awards; } private static float Valid(float value, float maximum) { if (!float.IsNaN(value) && !float.IsInfinity(value)) { return Math.Max(0f, Math.Min(maximum, value)); } return 0f; } private static float Category(float value, float target, float weight) { return RoundPoints(weight * (Valid(value, target) / target)); } private static float RoundPoints(float value) { return (float)Math.Round((double)value * 10.0, MidpointRounding.AwayFromZero) / 10f; } private static int CountRoles(PlayerAwardScore score) { int num = 0; if (score.Hauling >= 7.5f) { num++; } if (score.Rooms + score.Valuables >= 5f) { num++; } if (score.Rescue >= 3.5f) { num++; } if (score.Combat >= 3.5f) { num++; } if (score.Control >= 1.5f) { num++; } return num; } private static float Contribution(PlayerAwardScore score) { return score.Hauling + score.Rooms + score.Valuables + score.Rescue + score.Combat + score.Control; } } internal static class MvpWire { internal const byte ReportEventCode = 79; internal const byte AwardEventCode = 80; internal const byte DeliveryEventCode = 81; internal const string Protocol = "matsu.repo.mvp/11"; internal const int MaxAwardPlayers = 255; internal static object[] CreateReport(string token, int viewId, PlayerRoundStats stats) { int[] array = stats.DeliveryReceipts?.Keys.Take(4096).ToArray() ?? Array.Empty<int>(); float[] array2 = array.Select((int id) => stats.DeliveryReceipts[id]).ToArray(); return new object[16] { "matsu.repo.mvp/11", token, viewId, stats.RoomScouting, stats.ValuableDiscovery, stats.DownedSeconds, stats.Deaths, stats.DamageTaken, stats.DamagingHits, stats.HeavyHits, stats.CriticalEpisodes, stats.ParticipationSeconds, stats.AliveAtEnd, array, array2, stats.DeliveryDataMissing }; } internal static bool TryReadReport(object? packet, string roundToken, float roundSeconds, out int viewId, out PlayerRoundStats report) { viewId = 0; report = null; if (!(packet is object[] array) || array.Length != 16 || !(array[0] is string text) || text != "matsu.repo.mvp/11" || !(array[1] is string text2) || text2 != roundToken || !(array[2] is int num) || num <= 0 || !(array[3] is float value) || !(array[4] is float value2) || !(array[5] is float value3) || !(array[6] is int val) || !(array[7] is int val2) || !(array[8] is int val3) || !(array[9] is int val4) || !(array[10] is int val5) || !(array[11] is float num2) || !(array[12] is bool aliveAtEnd) || !(array[13] is int[] array2) || !(array[14] is float[] array3) || !(array[15] is bool deliveryDataMissing) || array2.Length != array3.Length || array2.Length > 4096 || !Finite(value) || !Finite(value2) || !Finite(value3) || !Finite(num2) || num2 <= 0f || !Finite(roundSeconds) || roundSeconds < 0f) { return false; } Dictionary<int, float> dictionary = new Dictionary<int, float>(array2.Length); for (int i = 0; i < array2.Length; i++) { int num3 = array2[i]; float num4 = array3[i]; if (num3 <= 0 || !MvpMeasurements.ValidUnits(num4) || dictionary.ContainsKey(num3)) { return false; } dictionary.Add(num3, Math.Min(20f, num4)); } float maximum = roundSeconds + 5f; viewId = num; report = new PlayerRoundStats { RoomScouting = Clamp(value, 100000f), ValuableDiscovery = Clamp(value2, 100000f), DownedSeconds = Clamp(value3, maximum), Deaths = Math.Max(0, Math.Min(20, val)), DamageTaken = Math.Max(0, Math.Min(2000, val2)), DamagingHits = Math.Max(0, Math.Min(20, val3)), HeavyHits = Math.Max(0, Math.Min(20, val4)), CriticalEpisodes = Math.Max(0, Math.Min(10, val5)), ParticipationSeconds = Clamp(num2, maximum), AliveAtEnd = aliveAtEnd, DeliveryReceipts = dictionary, DeliveryDataMissing = deliveryDataMissing }; return true; } internal static object[] CreateDelivery(string token, int pointViewId, int itemViewId, bool rescue) { return new object[5] { "matsu.repo.mvp/11", token, pointViewId, itemViewId, rescue }; } internal static bool TryReadDelivery(object? packet, string expectedToken, out int pointViewId, out int itemViewId, out bool rescue) { pointViewId = (itemViewId = 0); rescue = false; if (!(packet is object[] array) || array.Length != 5 || !(array[0] is string text) || text != "matsu.repo.mvp/11" || !(array[1] is string text2) || string.IsNullOrEmpty(expectedToken) || text2 != expectedToken || !(array[2] is int num) || num <= 0 || !(array[3] is int num2) || num2 <= 0 || num2 == num || !(array[4] is bool flag)) { return false; } pointViewId = num; itemViewId = num2; rescue = flag; return true; } internal static object[] CreateAward(AwardDisplay display) { int num = Math.Min(255, display.Players.Length); object[] array = new object[num]; for (int i = 0; i < num; i++) { AwardPlayerRow awardPlayerRow = display.Players[i]; array[i] = new object[4] { awardPlayerRow.Place, awardPlayerRow.Name, awardPlayerRow.Total, awardPlayerRow.PointsByCategory }; } return new object[10] { "matsu.repo.mvp/11", display.Level, display.Mvp, display.Reverse, display.ScoreDetails, display.Rankings, display.GameOver, display.Sequence, display.RoundToken, array }; } internal static bool TryReadAward(object? packet, string expectedToken, out AwardDisplay display) { display = null; if (!(packet is object[] array) || array.Length != 10 || !(array[0] is string text) || text != "matsu.repo.mvp/11" || !(array[1] is string value) || !(array[2] is string value2) || !(array[3] is string value3) || !(array[4] is string value4) || !(array[5] is string value5) || !(array[6] is bool gameOver) || !(array[7] is int num) || num <= 0 || !(array[8] is string text2) || string.IsNullOrEmpty(text2) || text2.Length > 160 || (!string.IsNullOrEmpty(expectedToken) && text2 != expectedToken) || !(array[9] is object[] array2) || array2.Length > 255) { return false; } AwardPlayerRow[] array3 = new AwardPlayerRow[array2.Length]; float num2 = 101f; for (int i = 0; i < array2.Length; i++) { if (!(array2[i] is object[] array4) || array4.Length != 4 || !(array4[0] is int num3) || num3 < 1 || num3 > i + 1 || !(array4[1] is string value6) || !(array4[2] is float num4) || !Finite(num4) || num4 < 0f || num4 > 100.001f || !(array4[3] is string value7)) { return false; } int num5 = ((i > 0 && num4 == num2) ? array3[i - 1].Place : (i + 1)); if (num4 > num2 || num3 != num5) { return false; } array3[i] = new AwardPlayerRow(num3, Shorten(value6, 48), num4, Shorten(value7, 240)); num2 = num4; } display = new AwardDisplay { Level = Shorten(value, 80), Mvp = Shorten(value2, 160), Reverse = Shorten(value3, 160), ScoreDetails = Shorten(value4, 160), Rankings = Shorten(value5, 160), GameOver = gameOver, RoundToken = text2, Sequence = num, Players = array3 }; return true; } private static string Shorten(string value, int length) { if (value.Length <= length) { return value; } return value.Substring(0, length); } private static bool Finite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static float Clamp(float value, float maximum) { return Math.Max(0f, Math.Min(maximum, value)); } } [BepInPlugin("matsu.repo.mvp", "REPO Level MVP", "0.2.1")] public sealed class Plugin : BaseUnityPlugin { private readonly struct HealthBeforeHit { internal readonly int Health; internal readonly int Maximum; internal HealthBeforeHit(int health, int maximum) { Health = health; Maximum = maximum; } } private sealed class ExtractionTracking { private readonly FieldInfo? records; private readonly FieldInfo? extractionPoint; internal ExtractionTracking(Type itemType) { records = AccessTools.Field(itemType, "extractionPointTrackings"); Type nestedType = itemType.GetNestedType("ExtractionPointTracking", BindingFlags.Public | BindingFlags.NonPublic); extractionPoint = ((nestedType == null) ? null : AccessTools.Field(nestedType, "extractionPoint")); } internal bool HasRecord(Component item, GameObject point) { if ((Object)(object)point == (Object)null || extractionPoint == null || !(records?.GetValue(item) is IEnumerable enumerable)) { return false; } foreach (object item2 in enumerable) { if (item2 != null && (Object)/*isinst with value type is only supported in some contexts*/ == (Object)(object)point) { return true; } } return false; } } private readonly struct CombatHit { internal readonly string Actor; internal readonly Enemy? Enemy; internal readonly EnemyHealth? Health; internal readonly int Before; internal readonly float StunBefore; internal CombatHit(string actor, Enemy enemy, EnemyHealth? health, int before, float stunBefore) { Actor = actor; Enemy = enemy; Health = health; Before = before; StunBefore = stunBefore; } } public const string Guid = "matsu.repo.mvp"; public const string Name = "REPO Level MVP"; public const string Version = "0.2.1"; internal static ManualLogSource? Log; internal static ConfigEntry<KeyboardShortcut> toggleKey = null; internal static ConfigEntry<KeyboardShortcut> detailsKey = null; private static GameObject? runtimeRoot; private Harmony harmony; internal static readonly FieldInfo AvatarSteamId = AccessTools.Field(typeof(PlayerAvatar), "steamID"); internal static readonly FieldInfo AvatarName = AccessTools.Field(typeof(PlayerAvatar), "playerName"); internal static readonly FieldInfo AvatarDead = AccessTools.Field(typeof(PlayerAvatar), "deadSet"); internal static readonly FieldInfo HealthValue = AccessTools.Field(typeof(PlayerHealth), "health"); internal static readonly FieldInfo HealthMaximum = AccessTools.Field(typeof(PlayerHealth), "maxHealth"); internal static readonly FieldInfo EnemyHealthField = AccessTools.Field(typeof(Enemy), "Health"); internal static readonly FieldInfo EnemyHealthValue = AccessTools.Field(typeof(EnemyHealth), "healthCurrent"); internal static readonly FieldInfo ColliderCauser = AccessTools.Field(typeof(HurtCollider), "playerCausingHurt"); internal static readonly FieldInfo RoomPlayer = AccessTools.Field(typeof(RoomVolumeCheck), "player"); internal static readonly FieldInfo ValuableDollarValue = AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent"); internal static readonly FieldInfo ValuableView = AccessTools.Field(typeof(ValuableObject), "photonView"); internal static readonly FieldInfo HeadView = AccessTools.Field(typeof(PlayerDeathHead), "photonView"); private static readonly ExtractionTracking ValuableTracking = new ExtractionTracking(typeof(ValuableObject)); private static readonly ExtractionTracking HeadTracking = new ExtractionTracking(typeof(PlayerDeathHead)); internal static readonly FieldInfo ExtractionView = AccessTools.Field(typeof(ExtractionPoint), "photonView"); internal static readonly FieldInfo ExtractionIsShop = AccessTools.Field(typeof(ExtractionPoint), "isShop"); internal static readonly FieldInfo RoundHaulGoal = AccessTools.Field(typeof(RoundDirector), "haulGoal"); private static readonly FieldInfo RoundExtractionPoint = AccessTools.Field(typeof(RoundDirector), "extractionPointCurrent"); private static readonly FieldInfo HeadTriggered = AccessTools.Field(typeof(PlayerDeathHead), "triggered"); internal static readonly FieldInfo ValuableImpactDetector = AccessTools.Field(typeof(ValuableObject), "impactDetector"); internal static readonly FieldInfo ValuablePhysGrabObject = AccessTools.Field(typeof(ValuableObject), "physGrabObject"); internal static readonly FieldInfo ValuablePlayerGrabbedTime = AccessTools.Field(typeof(ValuableObject), "playerGrabbedTime"); internal static readonly FieldInfo ValuableCartSnapshots = AccessTools.Field(typeof(ValuableObject), "cartSnapshots"); internal static readonly FieldInfo DetectorCurrentCart = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "currentCart"); internal static readonly FieldInfo DetectorCurrentCartPrev = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "currentCartPrev"); internal static readonly FieldInfo DetectorPhysGrabObject = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "physGrabObject"); internal static readonly FieldInfo PhysObjectLastGrabber = AccessTools.Field(typeof(PhysGrabObject), "lastPlayerGrabbing"); private static readonly FieldInfo PhysObjectGrabbedTimer = AccessTools.Field(typeof(PhysGrabObject), "grabbedTimer"); internal static readonly FieldInfo CartItemsInCart = AccessTools.Field(typeof(PhysGrabCart), "itemsInCart"); internal static readonly FieldInfo CartInCartTransform = AccessTools.Field(typeof(PhysGrabCart), "inCart"); private static readonly FieldInfo HeadInExtraction = AccessTools.Field(typeof(PlayerDeathHead), "inExtractionPoint"); internal static readonly FieldInfo EnemyStunned = AccessTools.Field(typeof(Enemy), "StateStunned"); private void Awake() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01b1: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Expected O, but got Unknown //IL_023b: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02c5: Expected O, but got Unknown //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Expected O, but got Unknown //IL_0314: Expected O, but got Unknown //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Expected O, but got Unknown //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Expected O, but got Unknown //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Expected O, but got Unknown //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Expected O, but got Unknown //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Display", "ToggleKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Show or hide the standalone MVP results panel. When DeathCounter is installed, its shared panel key takes precedence."); detailsKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Display", "DetailsKey", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), "Open or close the full MVP results in the truck when DeathCounter shows the compact summary."); harmony = new Harmony("matsu.repo.mvp"); try { harmony.Patch((MethodBase)AccessTools.Method(typeof(RunManager), "ChangeLevel", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "ChangeLevelPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(RunManager), "UpdateLevel", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "UpdateLevelPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(RunManager), "ResetProgress", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "ResetProgressPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(SemiFunc), "OnSceneSwitch", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "SceneSwitchPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerHealth), "Hurt", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "HurtPrefix", (Type[])null), new HarmonyMethod(typeof(Plugin), "HurtPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "PlayerDeath", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "DeathPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(HurtCollider), "EnemyHurt", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "EnemyHurtPrefix", (Type[])null), new HarmonyMethod(typeof(Plugin), "EnemyHurtPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(PhysGrabObjectImpactDetector), "OnCollisionStay", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "PhysicsCombatTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(RoomVolumeCheck), "CheckSet", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "RoomCheckPrefix", (Type[])null), new HarmonyMethod(typeof(Plugin), "RoomCheckPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(PhysGrabber), "DiscoverLogic", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "DiscoveryPrefix", (Type[])null), new HarmonyMethod(typeof(Plugin), "DiscoveryPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ExtractionPoint), "SpawnExtractingVisuals", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "CargoDeliveredPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerDeathHead), "Revive", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "HeadRevivedPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(PhysGrabObjectImpactDetector), "InCartRPC", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "InCartRpcPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ValuableObject), "GetCurrentCart", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "GetCurrentCartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(ValuableObject), "UpdateCartSnapshots", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "UpdateCartSnapshotsPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); SceneManager.sceneLoaded += OnInitialSceneLoaded; Log.LogInfo((object)"REPO Level MVP 0.2.1 loaded. Waiting for game scene."); } catch (Exception ex) { Log.LogError((object)("[MVP] Required native hook missing: " + ex)); harmony.UnpatchSelf(); } } private static void OnInitialSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown SceneManager.sceneLoaded -= OnInitialSceneLoaded; if (!((Object)(object)runtimeRoot != (Object)null)) { runtimeRoot = new GameObject("REPO MVP Runtime"); Object.DontDestroyOnLoad((Object)(object)runtimeRoot); runtimeRoot.AddComponent<MvpRuntime>(); runtimeRoot.AddComponent<MvpFallbackUi>(); } } internal static bool IsGameplayLevel() { try { return (Object)(object)RunManager.instance != (Object)null && (SemiFunc.RunIsLevel() || SemiFunc.RunIsArena()); } catch { return false; } } internal static bool IsHost() { try { return PhotonNetwork.OfflineMode || !PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient; } catch { return true; } } internal static string Id(PlayerAvatar? avatar) { if ((Object)(object)avatar == (Object)null) { return ""; } string text = (AvatarSteamId.GetValue(avatar) as string) ?? ""; if (!string.IsNullOrWhiteSpace(text) && text != "0") { return text; } if (PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode) { return "view-" + avatar.photonView.ViewID; } return "solo-local"; } internal static string PlayerName(PlayerAvatar? avatar) { if ((Object)(object)avatar == (Object)null) { return "UNKNOWN PLAYER"; } string text = AvatarName.GetValue(avatar) as string; if (string.IsNullOrWhiteSpace(text)) { text = "UNKNOWN PLAYER"; } if (text.Length <= 48) { return text; } return text.Substring(0, 48); } private static bool Owns(PlayerAvatar? avatar) { if ((Object)(object)avatar != (Object)null) { if (!PhotonNetwork.OfflineMode && PhotonNetwork.InRoom) { if ((Object)(object)avatar.photonView != (Object)null) { return avatar.photonView.IsMine; } return false; } return true; } return false; } private static void ChangeLevelPrefix(bool _levelFailed) { if (IsHost() && IsGameplayLevel()) { MvpRuntime.Active?.CloseRound(_levelFailed && SemiFun