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 MurphysTruckExtraction v1.1.0
plugins/MurphysTruckExtraction.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MurphysTruckExtraction")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MurphysTruckExtraction")] [assembly: AssemblyTitle("MurphysTruckExtraction")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MurphysTruckExtraction { internal readonly struct CargoItem { public readonly ValuableObject Valuable; public readonly float Current; public readonly float? Original; public CargoItem(ValuableObject valuable, float current, float? original) { Valuable = valuable; Current = current; Original = original; } } internal sealed class CargoMonitor { private const int Width = 760; private const int Height = 494; private const int RowsPerPage = 5; private static readonly Color Ink = Color32.op_Implicit(new Color32((byte)240, (byte)244, byte.MaxValue, byte.MaxValue)); private static readonly Color Sky = Color32.op_Implicit(new Color32((byte)105, (byte)213, byte.MaxValue, byte.MaxValue)); private static readonly Color Pink = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)133, (byte)211, byte.MaxValue)); private static readonly Color Muted = Color32.op_Implicit(new Color32((byte)166, (byte)180, (byte)203, byte.MaxValue)); private readonly GameObject panel; private readonly TMP_FontAsset font; private readonly TextMeshProUGUI total; private readonly TextMeshProUGUI status; private readonly TextMeshProUGUI empty; private readonly TextMeshProUGUI pageIndicator; private readonly TextMeshProUGUI[] names = (TextMeshProUGUI[])(object)new TextMeshProUGUI[5]; private readonly TextMeshProUGUI[] rolls = (TextMeshProUGUI[])(object)new TextMeshProUGUI[5]; private readonly TextMeshProUGUI[] current = (TextMeshProUGUI[])(object)new TextMeshProUGUI[5]; private readonly Dictionary<int, int> loadingOrder = new Dictionary<int, int>(); private HashSet<int> previousCargo = new HashSet<int>(); private HashSet<int> currentCargo = new HashSet<int>(); private int loadSequence; private float pageStart; public bool IsAlive => (Object)(object)panel != (Object)null; private CargoMonitor(GameObject panel, TMP_FontAsset font) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) this.panel = panel; this.font = font; Image obj = panel.AddComponent<Image>(); ((Graphic)obj).color = Color32.op_Implicit(new Color32((byte)10, (byte)15, (byte)27, byte.MaxValue)); ((Graphic)obj).raycastTarget = false; Panel("Pink accent", 0, 0, 380, 6, Pink); Panel("Blue accent", 380, 0, 380, 6, Sky); ((TMP_Text)Text("Truck Extraction", 26, 20, 480, 52, 39, Ink)).fontStyle = (FontStyles)1; Text("CREATED BY MURPHY.DEV", 492, 30, 242, 27, 18, Pink, alignRight: true); Panel("Haul summary", 24, 82, 712, 96, Color32.op_Implicit(new Color32((byte)23, (byte)34, (byte)53, byte.MaxValue))); Text("CARGO VALUE", 42, 91, 270, 24, 21, Muted); total = Text("", 42, 116, 310, 52, 38, Sky); ((TMP_Text)total).fontStyle = (FontStyles)1; status = Text("", 364, 97, 350, 65, 25, Ink, alignRight: true); Text("VALUABLE", 28, 191, 342, 32, 22, Muted); Text("ORIGINAL ROLL", 370, 191, 156, 32, 21, Muted, alignRight: true); Text("CURRENT VALUE", 544, 191, 186, 32, 21, Muted, alignRight: true); Panel("Header rule", 26, 225, 706, 2, Color32.op_Implicit(new Color32((byte)51, (byte)69, (byte)98, byte.MaxValue))); for (int i = 0; i < 5; i++) { int y = 232 + 43 * i; if (i % 2 == 0) { Panel("Cargo row", 24, y, 712, 42, Color32.op_Implicit(new Color32((byte)17, (byte)25, (byte)42, byte.MaxValue))); } names[i] = Text("", 32, y, 326, 42, 27, Ink); rolls[i] = Text("", 366, y, 160, 42, 27, Muted, alignRight: true); current[i] = Text("", 538, y, 190, 42, 27, Sky, alignRight: true); } empty = Text("Truck is empty", 32, 232, 480, 42, 28, Muted); pageIndicator = Text("", 28, 453, 704, 29, 22, Muted, alignRight: true); } public static CargoMonitor? TryCreate() { //IL_004d: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00f4: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) TruckScreenText val = Object.FindFirstObjectByType<TruckScreenText>(); if ((Object)(object)val == (Object)null) { return null; } Transform obj = ((Component)val).transform.Find("Canvas/Bg"); RectTransform val2 = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (val2 == null) { Canvas componentInChildren = ((Component)val).GetComponentInChildren<Canvas>(true); Transform obj2 = ((componentInChildren != null) ? ((Component)componentInChildren).transform : null); val2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); } if (!((Object)(object)val2 == (Object)null)) { Rect rect = val2.rect; if (!(((Rect)(ref rect)).width <= 0f)) { TMP_Text componentInChildren2 = ((Component)val).GetComponentInChildren<TMP_Text>(true); TMP_FontAsset val3 = (((Object)(object)componentInChildren2 != (Object)null && (Object)(object)componentInChildren2.font != (Object)null) ? componentInChildren2.font : TMP_Settings.defaultFontAsset); if ((Object)(object)val3 == (Object)null) { return null; } GameObject val4 = new GameObject("Murphys Truck Extraction Monitor", new Type[2] { typeof(RectTransform), typeof(Canvas) }); try { RectTransform val5 = (RectTransform)val4.transform; Transform transform = ((Component)val).transform; ((Transform)val5).SetParent(transform, false); val5.sizeDelta = new Vector2(760f, 494f); RectTransform obj3 = val2; rect = val2.rect; Vector3 val6 = ((Transform)obj3).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); TruckSafetySpawnPoint val7 = Object.FindFirstObjectByType<TruckSafetySpawnPoint>(); Vector3 val8 = (((Object)(object)val7 != (Object)null) ? (((Component)val7).transform.position - val6) : (-((Transform)val2).forward)); float num = ((Vector3.Dot(val8, ((Transform)val2).right) < 0f) ? (-1f) : 1f); float num2 = ((Vector3.Dot(val8, ((Transform)val2).forward) < 0f) ? (-1f) : 1f); RectTransform obj4 = val2; Vector3 right = Vector3.right; rect = val2.rect; Vector3 val9 = ((Transform)obj4).TransformVector(right * ((Rect)(ref rect)).width); float magnitude = ((Vector3)(ref val9)).magnitude; ((Transform)val5).SetPositionAndRotation(val6 + ((Transform)val2).right * (num * magnitude * 0.97f) + ((Transform)val2).forward * (num2 * 0.04f), ((Transform)val2).rotation); val9 = transform.TransformVector(((Transform)val5).localRotation * Vector3.right); float magnitude2 = ((Vector3)(ref val9)).magnitude; ((Transform)val5).localScale = Vector3.one * (magnitude * 0.84f / (760f * Mathf.Max(magnitude2, 0.0001f))); val4.layer = ((Component)val2).gameObject.layer; val4.GetComponent<Canvas>().renderMode = (RenderMode)2; return new CargoMonitor(val4, val3); } catch { Object.Destroy((Object)(object)val4); throw; } } } return null; } public void Refresh(List<CargoItem> cargo, double dollars, int payout, bool canExtract, float now) { bool flag = false; currentCargo.Clear(); foreach (CargoItem item in cargo) { int instanceID = ((Object)item.Valuable).GetInstanceID(); currentCargo.Add(instanceID); if (!previousCargo.Contains(instanceID)) { loadingOrder[instanceID] = ++loadSequence; flag = true; } } foreach (int item2 in previousCargo) { if (!currentCargo.Contains(item2)) { loadingOrder.Remove(item2); } } HashSet<int> hashSet = currentCargo; HashSet<int> hashSet2 = previousCargo; previousCargo = hashSet; currentCargo = hashSet2; cargo.Sort((CargoItem a, CargoItem b) => loadingOrder[((Object)b.Valuable).GetInstanceID()].CompareTo(loadingOrder[((Object)a.Valuable).GetInstanceID()])); if (flag || cargo.Count == 0) { pageStart = now; } int num2 = Math.Max(1, (cargo.Count + 5 - 1) / 5); int num3 = (int)((now - pageStart) / 4f) % num2; int num4 = num3 * 5; Set(total, Dollars(dollars)); Set(status, canExtract ? ("PAYOUT ON DEPARTURE\n" + Dollars((long)payout * 1000L)) : "PAYOUT LOCKED\nFinish all extractions"); ((Behaviour)empty).enabled = cargo.Count == 0; for (int num5 = 0; num5 < 5; num5++) { int num6 = num4 + num5; if (num6 >= cargo.Count) { Set(names[num5], ""); Set(rolls[num5], ""); Set(current[num5], ""); continue; } CargoItem cargoItem = cargo[num6]; Set(names[num5], CleanName(((Object)cargoItem.Valuable).name)); TextMeshProUGUI text = rolls[num5]; float? original = cargoItem.Original; object value; if (original.HasValue) { float valueOrDefault = original.GetValueOrDefault(); value = Dollars(valueOrDefault); } else { value = "—"; } Set(text, (string)value); Set(current[num5], Dollars(cargoItem.Current)); } string text2 = ((cargo.Count == 1) ? "1 valuable" : $"{cargo.Count} valuables"); Set(pageIndicator, (num2 > 1) ? $"{text2} • {num3 + 1}/{num2}" : text2); } public void Destroy() { if ((Object)(object)panel != (Object)null) { Object.Destroy((Object)(object)panel); } } private TextMeshProUGUI Text(string content, int x, int y, int width, int height, int size, Color color, bool alignRight = false) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = ((Component)Child("Text", x, y, width, height)).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = font; ((TMP_Text)obj).fontSize = size; ((TMP_Text)obj).fontSizeMin = (float)size * 0.72f; ((TMP_Text)obj).fontSizeMax = size; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).alignment = (TextAlignmentOptions)(alignRight ? 4100 : 4097); ((TMP_Text)obj).enableWordWrapping = false; ((TMP_Text)obj).overflowMode = (TextOverflowModes)1; ((TMP_Text)obj).richText = false; ((Graphic)obj).raycastTarget = false; ((Graphic)obj).color = color; ((TMP_Text)obj).text = content; return obj; } private void Panel(string name, int x, int y, int width, int height, Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) Image obj = ((Component)Child(name, x, y, width, height)).gameObject.AddComponent<Image>(); ((Graphic)obj).color = color; ((Graphic)obj).raycastTarget = false; } private RectTransform Child(string name, int x, int y, int width, int height) { //IL_0014: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) //IL_0062: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = panel.layer }.transform; ((Transform)val).SetParent(panel.transform, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; val.anchoredPosition = new Vector2((float)x, (float)(-y)); val.sizeDelta = new Vector2((float)width, (float)height); return val; } private static string CleanName(string name) { string text = name.Replace("(Clone)", "").Replace("_", " ").Trim(); if (!text.StartsWith("Valuable ", StringComparison.OrdinalIgnoreCase)) { return text; } return text.Substring("Valuable ".Length); } private static string Dollars(double value) { return "$" + Math.Floor(value).ToString("N0", CultureInfo.InvariantCulture); } private static void Set(TextMeshProUGUI text, string value) { if (((TMP_Text)text).text != value) { ((TMP_Text)text).text = value; } } } [BepInPlugin("com.murphyslavv.truckextraction", "Murphys Truck Extraction", "1.1.0")] public sealed class Plugin : BaseUnityPlugin { private const string PluginId = "com.murphyslavv.truckextraction"; private static Plugin? instance; private Harmony? harmony; private FieldInfo? roundInstance; private FieldInfo? allExtractionsCompleted; private FieldInfo? currentValue; private RoundDirector? settledRound; private bool settling; private readonly List<CargoItem> cargo = new List<CargoItem>(); private FieldInfo? originalValue; private CargoMonitor? monitor; private bool monitorFailed; private float nextDisplayRefresh; private void Awake() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown try { roundInstance = RequireField(typeof(RoundDirector), "instance", typeof(RoundDirector), isStatic: true); allExtractionsCompleted = RequireField(typeof(RoundDirector), "allExtractionPointsCompleted", typeof(bool)); currentValue = RequireField(typeof(ValuableObject), "dollarValueCurrent", typeof(float)); originalValue = AccessTools.DeclaredField(typeof(ValuableObject), "dollarValueOriginal"); MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(RunManager), "ChangeLevel", new Type[3] { typeof(bool), typeof(bool), typeof(ChangeLevelType) }, (Type[])null) ?? throw new MissingMethodException("RunManager", "ChangeLevel"); HarmonyMethod val = new HarmonyMethod(typeof(Plugin), "BeforeDeparture", (Type[])null) { priority = 0 }; harmony = new Harmony("com.murphyslavv.truckextraction"); harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Truck extraction ready for hosts and solo runs. Created by Murphy.Dev."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Truck extraction could not initialize for this R.E.P.O. version. {arg}"); } } private void OnDestroy() { if (instance == this) { instance = null; } if (monitor != null) { monitor.Destroy(); } Harmony? obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private static FieldInfo RequireField(Type owner, string name, Type fieldType, bool isStatic = false) { FieldInfo fieldInfo = AccessTools.DeclaredField(owner, name); if (fieldInfo == null || fieldInfo.FieldType != fieldType || fieldInfo.IsStatic != isStatic) { throw new MissingFieldException(owner.FullName, name); } return fieldInfo; } private static void BeforeDeparture(bool __0, bool __1, ChangeLevelType __2, bool __runOriginal) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) Plugin plugin = instance; if ((Object)(object)plugin == (Object)null || !__runOriginal || !__0 || __1 || (int)__2 != 0) { return; } try { plugin.CreditTruckAtDeparture(); } catch (Exception arg) { ((BaseUnityPlugin)plugin).Logger.LogError((object)$"Truck extraction payout failed. {arg}"); } } private void CreditTruckAtDeparture() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (settling || !SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.RunIsLevel()) { return; } RoundDirector val = (RoundDirector)roundInstance.GetValue(null); if ((Object)(object)val == (Object)null || settledRound == val || !(bool)allExtractionsCompleted.GetValue(val)) { return; } settling = true; try { double num = ReadTruckCargo(cargo); int count = cargo.Count; if (count == 0) { return; } int num2 = SemiFunc.StatGetRunCurrency(); int num3 = SemiFunc.StatGetRunTotalHaul(); if (num2 < 0 || num3 < 0) { throw new InvalidOperationException("Native run stats are unavailable."); } int num4 = CalculatePayout(num, num2, num3); if (num4 == 0) { settledRound = val; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Truck cargo value was ${num:N0}. No whole $1,000 units were credited."); return; } settledRound = val; try { SemiFunc.StatSetRunCurrency(num2 + num4); SemiFunc.StatSetRunTotalHaul(num3 + num4); if (SemiFunc.StatGetRunCurrency() != num2 + num4 || SemiFunc.StatGetRunTotalHaul() != num3 + num4) { throw new InvalidOperationException("The game did not accept both updated stats."); } } catch { RestoreStat((Func<int>)SemiFunc.StatGetRunCurrency, (Func<int, int>)SemiFunc.StatSetRunCurrency, num2); RestoreStat((Func<int>)SemiFunc.StatGetRunTotalHaul, (Func<int, int>)SemiFunc.StatSetRunTotalHaul, num3); throw; } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Truck extraction credited ${(long)num4 * 1000L:N0} from {count} valuables (cargo value ${num:N0})."); } finally { settling = false; } } private void Update() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (instance != this || monitorFailed || Time.unscaledTime < nextDisplayRefresh) { return; } nextDisplayRefresh = Time.unscaledTime + 0.35f; try { RoundDirector val = (RoundDirector)roundInstance.GetValue(null); if ((Object)(object)val == (Object)null || !SemiFunc.RunIsLevel()) { monitor?.Destroy(); monitor = null; return; } if (monitor == null || !monitor.IsAlive) { monitor = CargoMonitor.TryCreate(); if (monitor == null) { return; } } double dollars = ReadTruckCargo(cargo); bool canExtract = (bool)allExtractionsCompleted.GetValue(val); int payout = CalculatePayout(dollars, Math.Max(0, SemiFunc.StatGetRunCurrency()), Math.Max(0, SemiFunc.StatGetRunTotalHaul())); monitor.Refresh(cargo, dollars, payout, canExtract, Time.unscaledTime); } catch (Exception arg) { monitor?.Destroy(); monitor = null; monitorFailed = true; ((BaseUnityPlugin)this).Logger.LogError((object)$"Truck cargo screen failed to initialize or update. {arg}"); } } private double ReadTruckCargo(List<CargoItem> items) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) items.Clear(); double num = 0.0; ValuableObject[] array = Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0); RoomVolume val2 = default(RoomVolume); Vector3 val3 = default(Vector3); foreach (ValuableObject val in array) { if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && currentValue.GetValue(val) is float num2 && !(num2 <= 0f) && !float.IsInfinity(num2) && !float.IsNaN(num2) && SemiFunc.GetRoomVolumeAtPosition(((Component)val).transform.position, ref val2, ref val3) && !((Object)(object)val2 == (Object)null) && val2.Truck) { float? original = ((originalValue?.GetValue(val) is float num3 && num3 > 0f && !float.IsInfinity(num3)) ? new float?(num3) : ((float?)null)); items.Add(new CargoItem(val, num2, original)); num += (double)num2; } } return num; } internal static int CalculatePayout(double dollars, int currency, int haul) { int num = int.MaxValue - Math.Max(currency, haul); return (int)Math.Min(Math.Floor(dollars / 1000.0), num); } private void RestoreStat(Func<int> read, Func<int, int> write, int previous) { try { if (read() != previous) { write(previous); } if (read() != previous) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Truck extraction could not restore {read.Method.Name} to {previous}."); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Truck extraction could not restore {read.Method.Name}. {arg}"); } } } }