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 RepoMapSuite v1.0.0
RepoMapSuite.dll
Decompiled 4 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("cat7street")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("RepoMapSuite —— R.E.P.O. 地图增强三合一:Tab 地图队友/敌人图标 + 可缩放小地图 + 地图剩余价值 HUD")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RepoMapSuite")] [assembly: AssemblyTitle("RepoMapSuite")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 RepoMapSuite { internal static class MapIcons { internal static void ShowPlayers() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.ShowTeammates.Value || GameDirector.instance?.PlayerList == null) { return; } foreach (PlayerAvatar item in GameDirector.instance.PlayerList.Where((PlayerAvatar p) => (Object)(object)p != (Object)null && (Object)(object)((Component)p).gameObject != (Object)null)) { MapCustom component = ((Component)item).GetComponent<MapCustom>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MapCustom obj = ((Component)item).gameObject.AddComponent<MapCustom>(); obj.sprite = RepoMapSuite.SpriteCircle; obj.color = Util.ParseColor(Cfg.TeammateColor.Value); obj.Add(); } PlayerDeathHead[] array = Object.FindObjectsOfType<PlayerDeathHead>(); foreach (PlayerDeathHead val in array) { if ((Object)(object)val != (Object)null && (Object)(object)val.mapCustom != (Object)null) { val.mapCustom.color = Util.ParseColor(Cfg.DeadTeammateColor.Value); } } } internal static void ShowEnemies() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Invalid comparison between Unknown and I4 //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.ShowEnemies.Value || EnemyDirector.instance?.enemiesSpawned == null) { return; } foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned) { if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).gameObject == (Object)null || (Object)(object)item.Enemy == (Object)null) { continue; } bool num = ((Behaviour)item).isActiveAndEnabled && ((Object)(object)item.Enemy.Health == (Object)null || !item.Enemy.Health.dead) && (int)item.Enemy.CurrentState != 11 && (int)item.Enemy.CurrentState > 0; MapCustom component = ((Component)item.Enemy).GetComponent<MapCustom>(); if (num) { if ((Object)(object)component == (Object)null) { component = ((Component)item.Enemy).gameObject.AddComponent<MapCustom>(); component.autoAdd = false; component.sprite = Util.CreateCircleSprite((int)(Util.EnemyScale(item.Enemy.Type) * 10f)); component.color = Util.ParseColor(Cfg.EnemyColor.Value); component.Add(); } } else if ((Object)(object)component != (Object)null) { if ((Object)(object)component.mapCustomEntity != (Object)null && (Object)(object)component.mapCustomEntity.spriteRenderer != (Object)null) { component.mapCustomEntity.spriteRenderer.sprite = null; } component.Hide(); Object.Destroy((Object)(object)component); } } } internal static void ShowItems() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.ShowItems.Value || (Object)(object)Map.Instance == (Object)null) { return; } ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>(); foreach (ValuableObject val in array) { if (!((Object)(object)val == (Object)null)) { val.discovered = true; val.Discover((State)0); Map.Instance.AddValuable(val); } } MapValuable[] array2 = Object.FindObjectsOfType<MapValuable>(); foreach (MapValuable val2 in array2) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.spriteRenderer != (Object)null) { val2.spriteRenderer.color = Util.ParseColor(Cfg.ItemColor.Value); } } ValuableDiscoverCustom[] array3 = Object.FindObjectsOfType<ValuableDiscoverCustom>(); foreach (ValuableDiscoverCustom obj in array3) { if (obj != null) { obj.Discover(); } } } internal static void ExploreAllRooms() { if (Cfg.ExploreAllRooms.Value) { RoomVolume[] array = Object.FindObjectsOfType<RoomVolume>(); for (int i = 0; i < array.Length; i++) { array[i].SetExplored(); } } } internal static void RefreshAll() { ShowPlayers(); ShowEnemies(); } } [HarmonyPatch(typeof(LevelGenerator), "GenerateDone")] internal static class LevelGenerator_GenerateDone_Patch { private static void Postfix() { Safe.Run(delegate { if (Util.IsInLevel()) { MapIcons.ShowPlayers(); MapIcons.ShowItems(); MapIcons.ShowEnemies(); MapIcons.ExploreAllRooms(); } }, "GenerateDone"); } } [HarmonyPatch(typeof(LevelGenerator), "StartRoomGeneration")] internal static class LevelGenerator_StartRoomGeneration_Patch { private static void Prefix() { Safe.Run(ValueTracker.ResetValues, "StartRoomGeneration"); } } [HarmonyPatch(typeof(EnemyParent), "SpawnRPC")] internal static class EnemyParent_SpawnRPC_Patch { private static void Postfix() { Safe.Run(MapIcons.ShowEnemies, "EnemySpawnRPC"); } } [HarmonyPatch(typeof(EnemyParent), "DespawnRPC")] internal static class EnemyParent_DespawnRPC_Patch { private static void Postfix() { Safe.Run(MapIcons.ShowEnemies, "EnemyDespawnRPC"); } } [HarmonyPatch(typeof(EnemyHealth), "DeathRPC")] internal static class EnemyHealth_DeathRPC_Patch { private static void Postfix() { Safe.Run(MapIcons.ShowEnemies, "EnemyDeathRPC"); } } [HarmonyPatch(typeof(PlayerAvatar))] internal static class PlayerAvatar_Patches { [HarmonyPostfix] [HarmonyPatch("ReviveRPC")] private static void ReviveRPC_Postfix() { Safe.Run(MapIcons.ShowPlayers, "ReviveRPC"); } [HarmonyPostfix] [HarmonyPatch("PlayerDeathRPC")] private static void PlayerDeathRPC_Postfix() { Safe.Run(MapIcons.ShowPlayers, "PlayerDeathRPC"); } [HarmonyPostfix] [HarmonyPatch("PlayerDeathDone")] private static void PlayerDeathDone_Postfix() { Safe.Run(delegate { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (GameDirector.instance?.PlayerList != null && GameDirector.instance.PlayerList.Any((PlayerAvatar p) => (Object)(object)p != (Object)null && (Object)(object)((Component)p).gameObject != (Object)null)) { PlayerDeathHead[] array = Object.FindObjectsOfType<PlayerDeathHead>(); foreach (PlayerDeathHead obj in array) { if (obj != null) { obj.SeenSetRPC(true, default(PhotonMessageInfo)); } } } }, "PlayerDeathDone"); } } internal static class Safe { private static string _lastError; internal static void Run(Action action, string where) { try { action(); } catch (Exception ex) { string text = where + ":" + ex.GetType().Name + ":" + ex.Message; if (text != _lastError) { _lastError = text; RepoMapSuite.Logger.LogWarning((object)$"[{where}] {ex}"); } } } } [BepInPlugin("cat7street.RepoMapSuite", "RepoMapSuite", "1.0.0")] public class RepoMapSuite : BaseUnityPlugin { public const string GUID = "cat7street.RepoMapSuite"; public const string NAME = "RepoMapSuite"; public const string VERSION = "1.0.0"; internal static ManualLogSource Logger; internal static Harmony HarmonyInstance; private const string MAP_CAMERA_NAME = "Dirt Finder Map Camera"; private Camera _mapCamera; private RenderTexture _renderTexture; private float _defaultCameraZoom = -1f; internal static Sprite SpriteCircle; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Cfg.Init(((BaseUnityPlugin)this).Config); SpriteCircle = Util.CreateCircleSprite(10); HarmonyInstance = new Harmony("cat7street.RepoMapSuite"); HarmonyInstance.PatchAll(); Logger.LogInfo((object)"RepoMapSuite v1.0.0 已加载(三合一:地图图标 + 小地图 + 价值 HUD)"); } private void Update() { //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Invalid comparison between Unknown and I4 //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) try { HandleZoomKeys(); if (!Util.IsInLevel()) { if ((Object)(object)_mapCamera != (Object)null || (Object)(object)_renderTexture != (Object)null) { _mapCamera = null; _renderTexture = null; _defaultCameraZoom = -1f; } return; } if ((Object)(object)_mapCamera == (Object)null) { _mapCamera = ((IEnumerable<Camera>)Object.FindObjectsOfType<Camera>(true)).FirstOrDefault((Func<Camera, bool>)((Camera cam) => (Object)(object)cam != (Object)null && ((Object)cam).name == "Dirt Finder Map Camera")); } if ((Object)(object)Map.Instance != (Object)null && !Map.Instance.Active) { Map.Instance.ActiveSet(true); } if ((Object)(object)_mapCamera != (Object)null && ((Object)(object)_renderTexture == (Object)null || ((Object)(object)_mapCamera.activeTexture != (Object)null && (Object)(object)_mapCamera.activeTexture != (Object)(object)_renderTexture))) { _renderTexture = _mapCamera.activeTexture; } if ((Object)(object)_mapCamera != (Object)null) { if (_defaultCameraZoom < 0f) { _defaultCameraZoom = _mapCamera.orthographicSize; } float num = (Util.HasLocalMapToolActive() ? _defaultCameraZoom : Cfg.MinimapZoom.Value); if (!Mathf.Approximately(_mapCamera.orthographicSize, num)) { _mapCamera.orthographicSize = num; } } if ((Object)(object)PlayerAvatar.instance != (Object)null && PlayerAvatar.instance.spectating && (Object)(object)SpectateCamera.instance != (Object)null && (int)SpectateCamera.instance.currentState == 1) { Transform val = (((Object)(object)SpectateCamera.instance.player != (Object)null) ? ((Component)SpectateCamera.instance.player).transform : ((Component)SpectateCamera.instance).transform); if ((Object)(object)val != (Object)null && (Object)(object)DirtFinderMapPlayer.Instance != (Object)null && (Object)(object)DirtFinderMapPlayer.Instance.PlayerTransform != (Object)null) { DirtFinderMapPlayer.Instance.PlayerTransform.position = val.position; Quaternion rotation = val.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; DirtFinderMapPlayer.Instance.PlayerTransform.rotation = Quaternion.Euler(0f, eulerAngles.y, eulerAngles.z); } } } catch (Exception ex) { Logger.LogWarning((object)("小地图 Update 异常(已忽略):" + ex.Message)); } } private void HandleZoomKeys() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (Util.IsInLevel() && !Util.IsChatActive()) { if (Input.GetKeyDown(Cfg.ZoomInKey.Value)) { Cfg.MinimapZoom.Value = Mathf.Max(Cfg.MinimapZoom.Value - 0.5f, 1.5f); } if (Input.GetKeyDown(Cfg.ZoomOutKey.Value)) { Cfg.MinimapZoom.Value = Mathf.Min(Cfg.MinimapZoom.Value + 0.5f, 10f); } } } private void OnGUI() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_013a: Unknown result type (might be due to invalid IL or missing references) if (Cfg.MinimapEnabled.Value && Util.IsInLevel() && !((Object)(object)_renderTexture == (Object)null) && !Util.HasLocalMapToolActive()) { int value = Cfg.MinimapSize.Value; int value2 = Cfg.MinimapBuffer.Value; int num; int num2; switch (Cfg.MinimapPreset.Value) { case MinimapPosition.TopLeft: num = value2; num2 = value2 * 2; break; case MinimapPosition.TopRight: num = Screen.width - value - value2; num2 = value2 * 2; break; case MinimapPosition.BottomRight: num = Screen.width - value - value2; num2 = Screen.height - value - value2; break; case MinimapPosition.MiddleLeft: num = value2; num2 = (Screen.height - value) / 2; break; case MinimapPosition.MiddleRight: num = Screen.width - value - value2; num2 = (Screen.height - value) / 2; break; default: num = value2; num2 = Screen.height - value - value2; break; } Color color = GUI.color; if (!Mathf.Approximately(Cfg.MinimapOpacity.Value, 1f)) { GUI.color = new Color(1f, 1f, 1f, Cfg.MinimapOpacity.Value); } GUI.DrawTexture(new Rect((float)num, (float)num2, (float)value, (float)value), (Texture)(object)_renderTexture, (ScaleMode)0, false); if (!Mathf.Approximately(Cfg.MinimapOpacity.Value, 1f)) { GUI.color = color; } } } } internal enum MinimapPosition { BottomLeft, BottomRight, TopLeft, TopRight, MiddleLeft, MiddleRight } internal static class Cfg { internal enum ValueHudPos { Default, LowerRight, BottomRight, Custom } internal static ConfigEntry<bool> ShowTeammates; internal static ConfigEntry<string> TeammateColor; internal static ConfigEntry<string> DeadTeammateColor; internal static ConfigEntry<bool> ShowEnemies; internal static ConfigEntry<string> EnemyColor; internal static ConfigEntry<bool> ShowItems; internal static ConfigEntry<string> ItemColor; internal static ConfigEntry<bool> ExploreAllRooms; internal static ConfigEntry<bool> MinimapEnabled; internal static ConfigEntry<MinimapPosition> MinimapPreset; internal static ConfigEntry<int> MinimapSize; internal static ConfigEntry<int> MinimapBuffer; internal static ConfigEntry<float> MinimapZoom; internal static ConfigEntry<float> MinimapOpacity; internal static ConfigEntry<KeyCode> ZoomInKey; internal static ConfigEntry<KeyCode> ZoomOutKey; internal static ConfigEntry<bool> ValueHudEnabled; internal static ConfigEntry<bool> ValueHudAlwaysOn; internal static ConfigEntry<bool> ValueStartingOnly; internal static ConfigEntry<bool> ValueUseRatio; internal static ConfigEntry<float> ValueRatio; internal static ConfigEntry<ValueHudPos> ValueHudPosition; internal static ConfigEntry<Vector2> ValueHudCustomCoords; internal static void Init(ConfigFile config) { //IL_028a: Unknown result type (might be due to invalid IL or missing references) ShowTeammates = config.Bind<bool>("1. 地图图标", "ShowTeammates", true, "在地图上显示队友位置"); TeammateColor = config.Bind<string>("1. 地图图标", "TeammateColor", "white", "队友图标颜色(white/red/green/blue/yellow/cyan/magenta/black/lilac/purple 或 #RRGGBB)"); DeadTeammateColor = config.Bind<string>("1. 地图图标", "DeadTeammateColor", "black", "死亡队友图标颜色"); ShowEnemies = config.Bind<bool>("1. 地图图标", "ShowEnemies", true, "在地图上显示敌人位置"); EnemyColor = config.Bind<string>("1. 地图图标", "EnemyColor", "red", "敌人图标颜色"); ShowItems = config.Bind<bool>("1. 地图图标", "ShowItems", false, "在地图上显示所有物品位置(略微剧透,默认关)"); ItemColor = config.Bind<string>("1. 地图图标", "ItemColor", "yellow", "物品图标颜色"); ExploreAllRooms = config.Bind<bool>("1. 地图图标", "ExploreAllRooms", false, "进图自动点亮全部房间(去战争迷雾)"); MinimapEnabled = config.Bind<bool>("2. 小地图", "Enabled", true, "是否启用屏幕角落小地图"); MinimapPreset = config.Bind<MinimapPosition>("2. 小地图", "Preset", MinimapPosition.BottomLeft, "小地图屏幕位置"); MinimapSize = config.Bind<int>("2. 小地图", "Size", 500, "小地图边长(像素)"); MinimapBuffer = config.Bind<int>("2. 小地图", "Buffer", 12, "小地图离屏幕边缘的距离(像素)"); MinimapZoom = config.Bind<float>("2. 小地图", "Zoom", 2.25f, "小地图缩放(数字越小放得越大)"); MinimapOpacity = config.Bind<float>("2. 小地图", "Opacity", 0.85f, "小地图不透明度 0~1"); ZoomInKey = config.Bind<KeyCode>("2. 小地图", "ZoomInKey", (KeyCode)61, "小地图放大按键"); ZoomOutKey = config.Bind<KeyCode>("2. 小地图", "ZoomOutKey", (KeyCode)45, "小地图缩小按键"); ValueHudEnabled = config.Bind<bool>("3. 价值HUD", "Enabled", true, "是否启用地图剩余价值 HUD"); ValueHudAlwaysOn = config.Bind<bool>("3. 价值HUD", "AlwaysOn", false, "始终显示价值 HUD(否则按住 Tab / 打开地图时显示)"); ValueStartingOnly = config.Bind<bool>("3. 价值HUD", "StartingValueOnly", false, "只显示进图时的初始总价值(不随破坏/萃取实时变化)"); ValueUseRatio = config.Bind<bool>("3. 价值HUD", "UseValueRatio", false, "剩余价值低于目标比例时才显示(配合 ValueRatio)"); ValueRatio = config.Bind<float>("3. 价值HUD", "ValueRatio", 1f, "比例阈值:剩余价值/萃取目标 低于它才显示"); ValueHudPosition = config.Bind<ValueHudPos>("3. 价值HUD", "Position", ValueHudPos.Default, "HUD 位置(Default=右侧目标下方)"); ValueHudCustomCoords = config.Bind<Vector2>("3. 价值HUD", "CustomCoords", new Vector2(0f, 225f), "Custom 位置时的 X,Y 偏移"); } } internal static class Util { private static readonly Dictionary<string, Color> NamedColors = new Dictionary<string, Color> { { "white", Color.white }, { "red", Color.red }, { "green", Color.green }, { "blue", Color.blue }, { "yellow", Color.yellow }, { "cyan", Color.cyan }, { "magenta", Color.magenta }, { "black", Color.black }, { "lilac", new Color(35f / 51f, 0.56078434f, 0.9137255f) }, { "purple", new Color(0.6431373f, 0.4392157f, 0.8901961f) } }; internal static Color ParseColor(string value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0056: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(value)) { return Color.white; } value = value.Trim(); Color result = default(Color); if (value.StartsWith("#") && (value.Length == 7 || value.Length == 9) && ColorUtility.TryParseHtmlString((value.Length == 7) ? (value + "FF") : value, ref result)) { return result; } if (!NamedColors.TryGetValue(value.ToLowerInvariant(), out var value2)) { return Color.white; } return value2; } internal static bool IsInLevel() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (SemiFunc.RunIsLevel() && (Object)(object)GameDirector.instance != (Object)null) { return (int)GameDirector.instance.currentState == 2; } return false; } internal static bool IsChatActive() { if ((Object)(object)ChatManager.instance != (Object)null) { return ChatManager.instance.chatActive; } return false; } internal static bool HasLocalMapToolActive() { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarVisuals != (Object)null && (Object)(object)instance.playerAvatarVisuals.playerAvatarRightArm != (Object)null && (Object)(object)instance.playerAvatarVisuals.playerAvatarRightArm.mapToolController != (Object)null) { return instance.playerAvatarVisuals.playerAvatarRightArm.mapToolController.Active; } return false; } internal static float EnemyScale(EnemyType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown return (int)t switch { 0 => 0.55f, 1 => 0.7f, 2 => 0.85f, 3 => 1f, 4 => 1.15f, _ => 1f, }; } internal static Sprite CreateCircleSprite(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)5, false); Color[] array = (Color[])(object)new Color[size * size]; float num = (float)size / 2f; float num2 = (float)size / 2f - 1f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = (float)j - num; float num4 = (float)i - num; array[i * size + j] = ((num3 * num3 + num4 * num4 <= num2 * num2) ? Color.white : Color.clear); } } val.SetPixels(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f)); } } internal static class ValueTracker { internal static float TotalValue; internal static float TotalValueInit; internal static GameObject HudObject; internal static TextMeshProUGUI ValueText; internal static void ResetValues() { if (!SemiFunc.RunIsLevel()) { TotalValue = 0f; TotalValueInit = 0f; HudObject = null; ValueText = null; } } internal static void CheckForItems() { if ((Object)(object)RoundDirector.instance == (Object)null || RoundDirector.instance.allExtractionPointsCompleted) { return; } TotalValue = 0f; ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>(); foreach (ValuableObject val in array) { if (!((Object)(object)val == (Object)null)) { TotalValue += val.dollarValueCurrent; } } } internal static void UpdateHud() { if (!Cfg.ValueHudEnabled.Value || !Util.IsInLevel() || (Object)(object)RoundDirector.instance == (Object)null) { return; } int extractionHaulGoal = RoundDirector.instance.extractionHaulGoal; bool allExtractionPointsCompleted = RoundDirector.instance.allExtractionPointsCompleted; if ((Object)(object)HudObject == (Object)null) { CreateHud(); return; } if (extractionHaulGoal == 0 && allExtractionPointsCompleted) { HudObject.SetActive(false); return; } float num = (Cfg.ValueStartingOnly.Value ? TotalValueInit : TotalValue); ((TMP_Text)ValueText).SetText("Map: $" + num.ToString("N0"), true); ApplyHudPosition(); if (Cfg.ValueHudAlwaysOn.Value) { HudObject.SetActive(true); } else if (Cfg.ValueUseRatio.Value) { float num2 = ((extractionHaulGoal > 0) ? (TotalValue / (float)extractionHaulGoal) : 0f); HudObject.SetActive(num2 <= Cfg.ValueRatio.Value); } else { bool active = ((Object)(object)MapToolController.instance != (Object)null && MapToolController.instance.mapToggled) || SemiFunc.InputHold((InputKey)8); HudObject.SetActive(active); } } private static void CreateHud() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Game Hud"); if ((Object)(object)val == (Object)null) { return; } TMP_FontAsset val2 = null; if ((Object)(object)HaulUI.instance != (Object)null && (Object)(object)HaulUI.instance.Text != (Object)null) { val2 = ((TMP_Text)HaulUI.instance.Text).font; } if ((Object)(object)val2 == (Object)null) { GameObject val3 = GameObject.Find("Tax Haul"); if ((Object)(object)val3 != (Object)null) { TMP_Text component = val3.GetComponent<TMP_Text>(); val2 = ((component != null) ? component.font : null); } } if (!((Object)(object)val2 == (Object)null)) { HudObject = new GameObject("RepoMapSuite Value HUD"); HudObject.SetActive(false); ValueText = HudObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)ValueText).font = val2; ((Graphic)ValueText).color = new Color(0.7882f, 0.9137f, 0.902f, 1f); ((TMP_Text)ValueText).fontSize = 24f; ((TMP_Text)ValueText).alignment = (TextAlignmentOptions)2052; HudObject.transform.SetParent(val.transform, false); ApplyHudPosition(); } } private static void ApplyHudPosition() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) RectTransform component = HudObject.GetComponent<RectTransform>(); component.pivot = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(1f, -1f); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 0f); component.sizeDelta = new Vector2(0f, 0f); Vector2 offsetMin = (component.offsetMax = (Vector2)(Cfg.ValueHudPosition.Value switch { Cfg.ValueHudPos.LowerRight => new Vector2(0f, 125f), Cfg.ValueHudPos.BottomRight => new Vector2(0f, 0f), Cfg.ValueHudPos.Custom => Cfg.ValueHudCustomCoords.Value, _ => new Vector2(0f, 225f), })); component.offsetMin = offsetMin; } } [HarmonyPatch(typeof(RoundDirector), "Update")] internal static class RoundDirector_Update_Patch { private static void Postfix() { Safe.Run(ValueTracker.UpdateHud, "RoundDirector.Update"); } } [HarmonyPatch(typeof(RoundDirector), "ExtractionCompleted")] internal static class RoundDirector_ExtractionCompleted_Patch { private static void Postfix() { Safe.Run(ValueTracker.CheckForItems, "ExtractionCompleted"); } } [HarmonyPatch(typeof(ValuableObject), "DollarValueSetRPC")] internal static class ValuableObject_DollarValueSetRPC_Patch { private static void Postfix(float value) { Safe.Run(delegate { ValueTracker.TotalValue += value; }, "DollarValueSetRPC"); } } [HarmonyPatch(typeof(ValuableObject), "DollarValueSetLogic")] internal static class ValuableObject_DollarValueSetLogic_Patch { private static void Postfix(ValuableObject __instance) { Safe.Run(delegate { if (SemiFunc.IsMasterClientOrSingleplayer()) { ValueTracker.TotalValue += __instance.dollarValueCurrent; } }, "DollarValueSetLogic"); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")] internal static class ImpactDetector_BreakRPC_Patch { private static void Postfix(float valueLost, bool _loseValue) { Safe.Run(delegate { if (_loseValue) { ValueTracker.TotalValue -= valueLost; } }, "BreakRPC"); } } [HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObjectRPC")] internal static class PhysGrabObject_DestroyPhysGrabObjectRPC_Patch { private static void Postfix(PhysGrabObject __instance) { Safe.Run(delegate { if (Util.IsInLevel()) { ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>(); if (!((Object)(object)component == (Object)null) && component.dollarValueCurrent >= component.dollarValueOriginal * 0.15f) { ValueTracker.TotalValue -= component.dollarValueCurrent; } } }, "DestroyPhysGrabObjectRPC"); } } [HarmonyPatch(typeof(LevelGenerator), "GenerateDone")] internal static class LevelGenerator_GenerateDone_Value_Patch { private static void Prefix() { Safe.Run(delegate { ValueTracker.CheckForItems(); ValueTracker.TotalValueInit = ValueTracker.TotalValue; }, "GenerateDone.Value"); } } }