Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of Empire2 v2.1.0
Empire-S1API.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.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using Empire; using Empire.DebtHelpers; using Empire.GeneralSetup.Data; using Empire.NPC; using Empire.NPC.Data; using Empire.NPC.Data.Enums; using Empire.NPC.S1API_NPCs; using Empire.NPC.SaveData; using Empire.Phone; using Empire.Phone.Data; using Empire.PhoneCalls; using Empire.Quest; using Empire.Quest.Data; using Empire.Reward; using Empire.Utilities; using Empire.Utilities.DealDayHelpers; using Empire.Utilities.EffectHelpers; using Empire.Utilities.ListHelpers; using Empire.Utilities.QualityHelpers; using Empire.Utilities.QuestHelpers; using Empire_S1API.Utilities; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using S1API.Console; using S1API.DeadDrops; using S1API.Entities; using S1API.Entities.NPCs; using S1API.GameTime; using S1API.Internal.Abstraction; using S1API.Internal.Utils; using S1API.Items; using S1API.Messaging; using S1API.Money; using S1API.PhoneApp; using S1API.PhoneCalls; using S1API.Products; using S1API.Properties.Interfaces; using S1API.Quests; using S1API.Quests.Constants; using S1API.Saveables; using S1API.Storages; using S1API.UI; using S1API.Utils; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(EmpireMod), "Empire (Forked by Kaen01)", "2.0", "Aracor", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: InternalsVisibleTo("Empire.Tests")] [assembly: AssemblyCompany("Aracor")] [assembly: AssemblyConfiguration("CrossCompat")] [assembly: AssemblyDescription("A Schedule One NPC Framework")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9ecc8de481f933bd55267681005f34caca31a7a1")] [assembly: AssemblyProduct("Empire-S1API")] [assembly: AssemblyTitle("Empire-S1API")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/pranjalchakraborty/Silkroad_S1API.git")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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; } } } public static class EmpireResourceLoader { public static Sprite? LoadEmbeddedIcon(string fileName) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Assembly assembly = typeof(EmpireNPC).Assembly; string name = IconResourcePath(fileName); using Stream stream = assembly.GetManifestResourceStream(name); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = EmpirePngLoader.LoadTexture(array); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } private static string IconResourcePath(string fileName) { return "Empire.NPC.S1API_NPCs.Icons." + fileName; } } namespace Empire_S1API.Utilities { public static class EmpireConfig { public static bool NoNecessaryEffects = false; public static readonly float[] RandomRanges = new float[8] { 0.25f, 0.5f, 0.5f, 1.5f, 0.5f, 1.5f, 0.25f, 1f }; } } namespace Empire { public class EmpireMod : MelonMod { public static MelonPreferences_Category Config; public static MelonPreferences_Entry<bool> RandomizeDealDays; public static MelonPreferences_Entry<int> Tier1MinDays; public static MelonPreferences_Entry<int> Tier2MinDays; public static MelonPreferences_Entry<int> Tier3MinDays; public static MelonPreferences_Entry<int> Tier4MinDays; public static MelonPreferences_Entry<int> Tier5MinDays; public override void OnInitializeMelon() { ((MelonBase)this).OnInitializeMelon(); TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(EmpirePhoneApp.DetermineDealDaysStatic)); TimeManager.OnDayPass = (Action)Delegate.Combine(TimeManager.OnDayPass, new Action(EmpirePhoneApp.DetermineDealDaysStatic)); Config = MelonPreferences.CreateCategory("Empire (Forked by Kaen01)", "Empire 2.0 Mod Configuration"); RandomizeDealDays = Config.CreateEntry<bool>("RandomizeDealDays", false, "Randomize Deal Days", "If enabled, the days on which deals are available will be randomized each week. Must be true for the MinDays (below) to be used.", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("✅ Loaded setting: RandomizeDealDays = " + RandomizeDealDays.Value); Tier1MinDays = Config.CreateEntry<int>("Tier1MinDays", 4, "Tier 1 Minimum Deal Days", "Minimum number of days per week Tier 1 dealers can have deals. Max = Min + 2", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("✅ Loaded setting: Tier1MinDays = " + Tier1MinDays.Value); Tier2MinDays = Config.CreateEntry<int>("Tier2MinDays", 3, "Tier 2 Minimum Deal Days", "Minimum number of days per week Tier 2 dealers can have deals. Max = Min + 2", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("✅ Loaded setting: Tier2MinDays = " + Tier2MinDays.Value); Tier3MinDays = Config.CreateEntry<int>("Tier3MinDays", 2, "Tier 3 Minimum Deal Days", "Minimum number of days per week Tier 3 dealers can have deals. Max = Min + 2", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("✅ Loaded setting: Tier3MinDays = " + Tier3MinDays.Value); Tier4MinDays = Config.CreateEntry<int>("Tier4MinDays", 1, "Tier 4 Minimum Deal Days", "Minimum number of days per week Tier 4 dealers can have deals. Max = Min + 2", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("✅ Loaded setting: Tier4MinDays = " + Tier4MinDays.Value); Tier5MinDays = Config.CreateEntry<int>("Tier5MinDays", 1, "Tier 5 Minimum Deal Days", "Minimum number of days per week Tier 5 dealers can have deals. Max = Min + 2", false, false, (ValueValidator)null, (string)null); MelonLogger.Msg("✅ Loaded setting: Tier5MinDays = " + Tier5MinDays.Value); MelonPreferences.Save(); } public override void OnSceneWasUnloaded(int buildIndex, string sceneName) { if (sceneName == "Main") { MelonLogger.Msg("\ud83e\uddf9 Resetting Empire static state after Main scene unload"); if (EmpirePhoneApp.Instance != null) { EmpirePhoneApp.Reset(); } Contacts.Reset(); TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(EmpirePhoneApp.DetermineDealDaysStatic)); } } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { if (sceneName == "Main") { MelonLogger.Msg("\ud83e\uddf9 Resetting Empire static state after Main scene initialization"); if (EmpirePhoneApp.Instance != null) { EmpirePhoneApp.Reset(); } Contacts.Reset(); TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(EmpirePhoneApp.DetermineDealDaysStatic)); TimeManager.OnDayPass = (Action)Delegate.Combine(TimeManager.OnDayPass, new Action(EmpirePhoneApp.DetermineDealDaysStatic)); } } public override void OnApplicationQuit() { ((MelonBase)this).OnApplicationQuit(); TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(EmpirePhoneApp.DetermineDealDaysStatic)); } } } namespace Empire.Utilities { public static class EmpirePngLoader { public static Texture2D? LoadTexture(byte[] pngData) { //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Expected O, but got Unknown //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) using MemoryStream input = new MemoryStream(pngData); using BinaryReader binaryReader = new BinaryReader(input); byte[] array = binaryReader.ReadBytes(8); if (array.Length != 8 || array[0] != 137 || array[1] != 80 || array[2] != 78 || array[3] != 71 || array[4] != 13 || array[5] != 10 || array[6] != 26 || array[7] != 10) { MelonLogger.Msg("Invalid PNG signature"); } int num = 0; int num2 = 0; byte b = 0; byte b2 = 0; byte[] array2 = null; while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length) { int count = ReadInt(binaryReader); string text = new string(binaryReader.ReadChars(4)); byte[] array3 = binaryReader.ReadBytes(count); binaryReader.ReadBytes(4); switch (text) { case "IHDR": num = ReadInt(array3, 0); num2 = ReadInt(array3, 4); b = array3[8]; b2 = array3[9]; continue; case "IDAT": array2 = ((array2 == null) ? array3 : Combine(array2, array3)); continue; default: continue; case "IEND": break; } break; } if (array2 == null) { MelonLogger.Msg("PNG missing IDAT"); return null; } if (b != 8 || b2 != 6) { MelonLogger.Msg($"Unsupported PNG format (bitDepth={b}, colorType={b2}), expected 8-bit RGBA"); return null; } byte[] array4 = DecompressZlib(array2); int num3 = 4; int num4 = num * num3; Color32[] array5 = (Color32[])(object)new Color32[num * num2]; int num5 = 0; int num6 = 0; byte[] array6 = new byte[num4]; byte[] array7 = new byte[num4]; for (int i = 0; i < num2; i++) { byte b3 = array4[num5++]; switch (b3) { case 0: Buffer.BlockCopy(array4, num5, array7, 0, num4); num5 += num4; break; case 1: { for (int l = 0; l < num4; l++) { byte b9 = (byte)((l >= num3) ? array7[l - num3] : 0); array7[l] = (byte)(array4[num5++] + b9); } break; } case 2: { for (int m = 0; m < num4; m++) { byte b10 = array6[m]; array7[m] = (byte)(array4[num5++] + b10); } break; } case 3: { for (int k = 0; k < num4; k++) { byte b6 = (byte)((k >= num3) ? array7[k - num3] : 0); byte b7 = array6[k]; byte b8 = (byte)((b6 + b7) / 2); array7[k] = (byte)(array4[num5++] + b8); } break; } case 4: { for (int j = 0; j < num4; j++) { byte a = (byte)((j >= num3) ? array7[j - num3] : 0); byte b4 = array6[j]; byte c = (byte)((j >= num3) ? array6[j - num3] : 0); byte b5 = PaethPredictor(a, b4, c); array7[j] = (byte)(array4[num5++] + b5); } break; } default: MelonLogger.Msg($"Unsupported PNG filter type: {b3}"); break; } for (int n = 0; n < num; n++) { int num7 = n * 4; byte b11 = array7[num7]; byte b12 = array7[num7 + 1]; byte b13 = array7[num7 + 2]; byte b14 = array7[num7 + 3]; array5[num6++] = new Color32(b11, b12, b13, b14); } byte[] array8 = array6; array6 = array7; array7 = array8; } Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); for (int num8 = 0; num8 < array5.Length; num8++) { int num9 = num8 % num; int num10 = num8 / num; val.SetPixel(num9, num2 - 1 - num10, Color32.op_Implicit(array5[num8])); } val.Apply(); return val; } private static int ReadInt(BinaryReader br) { byte[] array = br.ReadBytes(4); if (BitConverter.IsLittleEndian) { Array.Reverse(array); } return BitConverter.ToInt32(array, 0); } private static int ReadInt(byte[] data, int offset) { byte[] array = new byte[4]; Buffer.BlockCopy(data, offset, array, 0, 4); if (BitConverter.IsLittleEndian) { Array.Reverse(array); } return BitConverter.ToInt32(array, 0); } private static byte[] Combine(byte[] a, byte[] b) { byte[] array = new byte[a.Length + b.Length]; Buffer.BlockCopy(a, 0, array, 0, a.Length); Buffer.BlockCopy(b, 0, array, a.Length, b.Length); return array; } private static byte[] DecompressZlib(byte[] data) { using MemoryStream memoryStream = new MemoryStream(data); memoryStream.ReadByte(); memoryStream.ReadByte(); using DeflateStream deflateStream = new DeflateStream(memoryStream, CompressionMode.Decompress); using MemoryStream memoryStream2 = new MemoryStream(); deflateStream.CopyTo(memoryStream2); return memoryStream2.ToArray(); } private static byte PaethPredictor(byte a, byte b, byte c) { int num = a + b - c; int num2 = Math.Abs(num - a); int num3 = Math.Abs(num - b); int num4 = Math.Abs(num - c); if (num2 <= num3 && num2 <= num4) { return a; } if (num3 <= num4) { return b; } return c; } } } namespace Empire.Utilities.QuestHelpers { public class QuestBuilder { private readonly EmpireNPC buyer; private readonly Drug unlockedDrug; private readonly Shipping shipping; public QuestBuilder(EmpireNPC buyer, Drug unlockedDrug) { this.buyer = buyer; this.unlockedDrug = unlockedDrug; shipping = buyer.Shippings[buyer.DealerSaveData.ShippingTier]; } public int CalculateAmount() { int minAmount = shipping.MinAmount; int maxAmount = shipping.MaxAmount; double num = 0.0; if (buyer.RepLogBase > 1f) { num = Math.Log(buyer.DealerSaveData.Reputation + 1, buyer.RepLogBase); num = ((num < 4.0) ? 0.0 : (num - 4.0)); } int num2 = (maxAmount - minAmount) / shipping.StepAmount; int num3 = ((num2 > 0) ? RandomUtils.RangeInt(0, num2 + 1) : 0); num3 = (int)((double)num3 * (1.0 + num)); return minAmount + num3 * shipping.StepAmount; } public (string name, float mult, string color) SelectQuality() { Quality q = unlockedDrug.Qualities.RandomElement(); return QualityEffectResolver.ResolveQuality(q); } public (List<string> necessary, List<float> necessaryMult, List<string> optional, List<float> optionalMult, float tempMult11, float tempMult21) SelectEffects(float randomNum1) { List<string> list = new List<string>(); List<float> list2 = new List<float>(); List<string> list3 = new List<string>(); List<float> list4 = new List<float>(); float num = 1f; float num2 = 1f; bool noNecessaryEffects = EmpireConfig.NoNecessaryEffects; foreach (Effect effect in unlockedDrug.Effects) { bool flag = effect.Probability > 1f && Random.value < effect.Probability - 1f && !noNecessaryEffects; bool flag2 = (effect.Probability > 0f && effect.Probability <= 1f && Random.value < effect.Probability) || noNecessaryEffects; if (!flag && !flag2) { continue; } string text = effect.Name; if (text == "Random") { text = QualityEffectResolver.ResolveRandomEffectName(list.Concat(list3)); } if (!string.IsNullOrEmpty(text)) { (string name, float mult, string color) tuple = QualityEffectResolver.ResolveEffect(text, effect.DollarMult); string item = tuple.name; float item2 = tuple.mult; float num3 = item2 * randomNum1; if (flag) { list.Add(item); list2.Add(num3); num += num3; num2 += num3; } else { list3.Add(item); list4.Add(num3); num2 += num3; } } } return (list, list2, list3, list4, num, num2); } } } namespace Empire.Utilities.QualityHelpers { public static class QualityEffectResolver { public static (string name, float mult, string color) ResolveQuality(Quality q) { QualityInfo quality = q.Type.GetQuality(); string item = quality?.Name ?? q.Type; float item2 = q.DollarMult + (quality?.DollarMult ?? 0f); string item3 = quality?.Color ?? "#FFFFFF"; return (item, item2, item3); } public static string ResolveRandomEffectName(IEnumerable<string> exclude) { IEnumerable<string> exclude2 = exclude; List<EffectInfo> list = EffectRegistry.Effects.Where((EffectInfo e) => !e.Name.Equals("Random", StringComparison.OrdinalIgnoreCase) && !exclude2.Contains<string>(e.Name, StringComparer.OrdinalIgnoreCase)).ToList(); if (list.Count == 0) { return ""; } return list[Random.Range(0, list.Count)].Name; } public static (string name, float mult, string color) ResolveEffect(string effectName, float baseMult) { EffectInfo effect = effectName.GetEffect(); string item = effect?.Name ?? effectName; float item2 = baseMult + (effect?.DollarMult ?? 0f); string item3 = "#FFFFFF"; return (item, item2, item3); } } public static class QualityExtensions { public static QualityInfo? GetQuality(this string name) { QualityInfo value; return QualityRegistry.ByName.TryGetValue(name, out value) ? value : null; } } public class QualityInfo { public string Name { get; set; } public string Color { get; set; } public float DollarMult { get; set; } } public static class QualityRegistry { public static readonly List<QualityInfo> Qualities = new List<QualityInfo> { new QualityInfo { Name = "trash", Color = "#a84545", DollarMult = 0f }, new QualityInfo { Name = "poor", Color = "#5bad38", DollarMult = 0f }, new QualityInfo { Name = "standard", Color = "#358ecd", DollarMult = 0f }, new QualityInfo { Name = "premium", Color = "#e93be9", DollarMult = 0.25f }, new QualityInfo { Name = "heavenly", Color = "#ecb522", DollarMult = 0.5f } }; public static readonly Dictionary<string, QualityInfo> ByName = Qualities.ToDictionary<QualityInfo, string, QualityInfo>((QualityInfo q) => q.Name, (QualityInfo q) => q, StringComparer.OrdinalIgnoreCase); } } namespace Empire.Utilities.ListHelpers { public static class ListExtensions { public static T RandomElement<T>(this IList<T> list) { if (list == null || list.Count == 0) { throw new InvalidOperationException("Cannot select a random element from an empty list."); } return list[Random.Range(0, list.Count)]; } public static T RandomOrDefault<T>(this IList<T> list) { if (list == null || list.Count == 0) { return default(T); } return list[Random.Range(0, list.Count)]; } } } namespace Empire.Utilities.EffectHelpers { public static class EffectExtensions { public static EffectInfo? GetEffect(this string name) { EffectInfo value; return EffectRegistry.ByName.TryGetValue(name, out value) ? value : null; } } public class EffectInfo { public string Name { get; set; } public float DollarMult { get; set; } } public static class EffectRegistry { public static readonly List<EffectInfo> Effects = new List<EffectInfo> { new EffectInfo { Name = "AntiGravity", DollarMult = 0.46f }, new EffectInfo { Name = "Athletic", DollarMult = 0.68f }, new EffectInfo { Name = "Balding", DollarMult = 0.7f }, new EffectInfo { Name = "BrightEyed", DollarMult = 0.6f }, new EffectInfo { Name = "Calming", DollarMult = 0.9f }, new EffectInfo { Name = "CalorieDense", DollarMult = 0.72f }, new EffectInfo { Name = "Cyclopean", DollarMult = 0.44f }, new EffectInfo { Name = "Disorienting", DollarMult = 1f }, new EffectInfo { Name = "Electrifying", DollarMult = 0.5f }, new EffectInfo { Name = "Energizing", DollarMult = 0.78f }, new EffectInfo { Name = "Euphoric", DollarMult = 0.82f }, new EffectInfo { Name = "Explosive", DollarMult = 1f }, new EffectInfo { Name = "Focused", DollarMult = 0.84f }, new EffectInfo { Name = "Foggy", DollarMult = 0.64f }, new EffectInfo { Name = "Gingeritis", DollarMult = 0.8f }, new EffectInfo { Name = "Glowie", DollarMult = 0.52f }, new EffectInfo { Name = "Jennerising", DollarMult = 0.58f }, new EffectInfo { Name = "Laxative", DollarMult = 1f }, new EffectInfo { Name = "LongFaced", DollarMult = 0.48f }, new EffectInfo { Name = "Munchies", DollarMult = 0.88f }, new EffectInfo { Name = "Paranoia", DollarMult = 1f }, new EffectInfo { Name = "Refreshing", DollarMult = 0.86f }, new EffectInfo { Name = "Schizophrenic", DollarMult = 1f }, new EffectInfo { Name = "Sedating", DollarMult = 0.74f }, new EffectInfo { Name = "Seizure", DollarMult = 1f }, new EffectInfo { Name = "Shrinking", DollarMult = 0.4f }, new EffectInfo { Name = "Slippery", DollarMult = 0.66f }, new EffectInfo { Name = "Smelly", DollarMult = 1f }, new EffectInfo { Name = "Sneaky", DollarMult = 0.76f }, new EffectInfo { Name = "Spicy", DollarMult = 0.62f }, new EffectInfo { Name = "ThoughtProvoking", DollarMult = 0.56f }, new EffectInfo { Name = "Toxic", DollarMult = 1f }, new EffectInfo { Name = "TropicThunder", DollarMult = 0.54f }, new EffectInfo { Name = "Zombifying", DollarMult = 0.42f }, new EffectInfo { Name = "Random", DollarMult = 0f } }; public static readonly Dictionary<string, EffectInfo> ByName = Effects.ToDictionary((EffectInfo e) => e.Name, (EffectInfo e) => e); } } namespace Empire.Utilities.DealDayHelpers { public static class DealDayUtility { public static readonly Dictionary<int, string> DaysOfTheWeek = new Dictionary<int, string> { { 0, "Sunday" }, { 1, "Monday" }, { 2, "Tuesday" }, { 3, "Wednesday" }, { 4, "Thursday" }, { 5, "Friday" }, { 6, "Saturday" } }; public static List<string> GetRandomDays(int count) { count = Mathf.Clamp(count, 1, DaysOfTheWeek.Count); List<int> list = new List<int>(DaysOfTheWeek.Keys); for (int num = list.Count - 1; num > 0; num--) { int index = Random.Range(0, num + 1); int value = list[num]; list[num] = list[index]; list[index] = value; } List<int> range = list.GetRange(0, count); range.Sort(); List<string> list2 = new List<string>(); for (int i = 0; i < range.Count; i++) { list2.Add(DaysOfTheWeek[range[i]]); } return list2; } public static List<string> GetSequentialDays(int count) { count = Mathf.Clamp(count, 1, DaysOfTheWeek.Count); List<string> list = new List<string>(); for (int i = 0; i < count; i++) { list.Add(DaysOfTheWeek[i]); } return list; } public static List<string> GetDealDays(int count, bool randomize) { return randomize ? GetRandomDays(count) : GetSequentialDays(count); } } } namespace Empire.Reward { public class RewardManager { [CompilerGenerated] private sealed class <ExecuteRewardAfterDelay>d__6 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RewardManager <>4__this; private string <rewardType>5__1; private string <commandLine>5__2; private string[] <commands>5__3; private string[] <>s__4; private int <>s__5; private string <rawCmd>5__6; private string <cmd>5__7; private List<string> <args>5__8; private int <bindonceIdx>5__9; private string <key>5__10; private string <filteredCmd>5__11; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ExecuteRewardAfterDelay>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <rewardType>5__1 = null; <commandLine>5__2 = null; <commands>5__3 = null; <>s__4 = null; <rawCmd>5__6 = null; <cmd>5__7 = null; <args>5__8 = null; <key>5__10 = null; <filteredCmd>5__11 = null; <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; MelonLogger.Msg("Reward execution will start in 10 seconds..."); <>2__current = (object)new WaitForSeconds(10f); <>1__state = 1; return true; case 1: <>1__state = -1; <rewardType>5__1 = <>4__this.buyer.Reward.Type.ToLower(); if (<rewardType>5__1 == "console" && <>4__this.buyer.Reward.Args != null && <>4__this.buyer.Reward.Args.Count > 0) { <commandLine>5__2 = string.Join(" ", <>4__this.buyer.Reward.Args); <commands>5__3 = <commandLine>5__2.Split(new string[1] { "&&" }, StringSplitOptions.RemoveEmptyEntries); <>s__4 = <commands>5__3; for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++) { <rawCmd>5__6 = <>s__4[<>s__5]; <cmd>5__7 = <rawCmd>5__6.Trim(); <args>5__8 = <cmd>5__7.Split(' ', StringSplitOptions.RemoveEmptyEntries).ToList(); <bindonceIdx>5__9 = <args>5__8.IndexOf("bindonce"); if (<bindonceIdx>5__9 >= 0 && <bindonceIdx>5__9 < <args>5__8.Count - 1) { <key>5__10 = <args>5__8[<bindonceIdx>5__9 + 1]; <args>5__8[<bindonceIdx>5__9] = "bind"; <filteredCmd>5__11 = string.Join(" ", <args>5__8); MelonLogger.Msg("Executing console command: " + <filteredCmd>5__11); ConsoleHelper.Submit(<filteredCmd>5__11); MelonCoroutines.Start(<>4__this.WaitForBindOnceKey(<key>5__10)); <key>5__10 = null; <filteredCmd>5__11 = null; } else { MelonLogger.Msg("Executing console command: " + <cmd>5__7); ConsoleHelper.Submit(<cmd>5__7); } <cmd>5__7 = null; <args>5__8 = null; <rawCmd>5__6 = null; } <>s__4 = null; <commandLine>5__2 = null; <commands>5__3 = null; } MelonLogger.Msg("Reward executed successfully."); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitForBindOnceKey>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string key; public RewardManager <>4__this; private KeyCode <keyCode>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForBindOnceKey>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!Enum.TryParse<KeyCode>(key, ignoreCase: true, out <keyCode>5__1)) { MelonLogger.Error("Invalid key specified for bindonce: " + key); return false; } MelonLogger.Msg($"Waiting for key press: {<keyCode>5__1}"); break; case 1: <>1__state = -1; break; } if (!Input.GetKeyDown(<keyCode>5__1)) { <>2__current = null; <>1__state = 1; return true; } MelonLogger.Msg($"Key {<keyCode>5__1} pressed, unbinding..."); ConsoleHelper.Submit("unbind " + key); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private EmpireNPC buyer; public bool isRewardAvailable = false; public RewardManager(EmpireNPC buyer) { this.buyer = buyer; isRewardAvailable = true; TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(SetRewardAvailable)); TimeManager.OnDayPass = (Action)Delegate.Combine(TimeManager.OnDayPass, new Action(SetRewardAvailable)); } public void SetRewardAvailable() { isRewardAvailable = true; } public string GetRewardType() { if (buyer.Reward?.Args == null || buyer.Reward.Args.Count == 0) { return "No special favors available from this contact right now."; } switch (buyer.Reward.Args[0].ToLower()) { case "freecam": return "Contact can provide surveillance equipment"; case "hidefps": return "Contact offering to modify your HUD display"; case "settime": return "Contact knows when to make things happen"; case "settimescale": return "Contact can help time move differently"; case "give": case "additemtoinventory": return "Contact has special items to offer"; case "clearinventory": return "Contact can help you clean house"; case "changecash": return "Contact offering some quick cash"; case "changebalance": return "Contact can adjust your digital assets"; case "addxp": return "Contact willing to share street knowledge"; case "spawnvehicle": return "Contact has connections at the chop shop"; case "setmovespeed": return "Contact knows ways to enhance your mobility"; case "setjumpforce": return "Contact has experimental movement tech"; case "setstaminareserve": return "Contact offering stamina boosters"; case "teleport": return "Contact knows some shortcuts through the city"; case "setowned": return "Contact can arrange property ownership papers"; case "packageproduct": return "Contact can help with product packaging"; case "addemployee": return "Contact knows reliable workers"; case "setdiscovered": return "Contact can reveal hidden locations"; case "growplants": return "Contact knows ways to accelerate plant growth"; case "raisewanted": case "lowerwanted": case "clearwanted": return "Contact has influence with law enforcement"; case "setlawintensity": return "Contact can adjust police patrol intensity"; case "sethealth": return "Contact knows a back-alley medic"; case "setquality": return "Contact can improve product quality"; case "setquestentrystate": return "Contact can influence ongoing situations"; case "setemotion": return "Contact knows how to affect people's moods"; case "setrelationship": return "Contact can influence relationships"; case "setunlocked": return "Contact can unlock new opportunities"; case "cleartrash": return "Contact knows clean-up specialists"; case "clearbinds": return "Contact offering to adjust your controls"; case "enable": return "Contact can toggle certain operations"; case "endtutorial": return "Contact can end your training period"; case "disablenpcasset": return "Contact can make certain people scarce"; default: return "Contact has an undefined favor to offer"; } } public void GiveReward() { if (!isRewardAvailable) { MelonLogger.Error("Reward is not available right now."); return; } if (buyer.Reward == null || buyer.Reward.Args == null || buyer.Reward.Args.Count == 0 || string.IsNullOrEmpty(buyer.Reward.Type)) { MelonLogger.Error("No reward available from this contact."); return; } if (buyer.Reward.unlockRep > 0 && buyer.DealerSaveData.Reputation < buyer.Reward.unlockRep) { MelonLogger.Error($"Insufficient reputation to claim reward. Required: {buyer.Reward.unlockRep}, Current: {buyer.DealerSaveData.Reputation}"); return; } MelonLogger.Msg("Claiming reward: " + buyer.Reward.Type + " with args: " + string.Join(", ", buyer.Reward.Args)); buyer.DealerSaveData.Reputation -= buyer.Reward.RepCost; isRewardAvailable = false; MelonCoroutines.Start(ExecuteRewardAfterDelay()); } [IteratorStateMachine(typeof(<ExecuteRewardAfterDelay>d__6))] private IEnumerator ExecuteRewardAfterDelay() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ExecuteRewardAfterDelay>d__6(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<WaitForBindOnceKey>d__7))] private IEnumerator WaitForBindOnceKey(string key) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForBindOnceKey>d__7(0) { <>4__this = this, key = key }; } } } namespace Empire.Quest { public class QuestDelivery : Quest { [CompilerGenerated] private sealed class <DelayedReward>d__28 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string source; public QuestDelivery <>4__this; private int <i>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedReward>d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <i>5__1 = 0; goto IL_006f; case 1: <>1__state = -1; <i>5__1++; goto IL_006f; case 2: { <>1__state = -1; <>4__this.GiveReward(source); return false; } IL_006f: if (<i>5__1 < <>4__this.buyer.Tier - 1) { ConsoleHelper.RaiseWanted(); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds((float)RandomUtils.RangeInt(5, 10)); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitForBuyerAndLoad>d__19 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public QuestDelivery <>4__this; private float <timeout>5__1; private float <waited>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForBuyerAndLoad>d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <timeout>5__1 = 5f; <waited>5__2 = 0f; MelonLogger.Msg("Quest-WaitForBuyerAndLoad-Waiting for buyer to be initialized..."); break; case 1: <>1__state = -1; break; } if (!Contacts.IsInitialized && <waited>5__2 < <timeout>5__1) { <waited>5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } if (!Contacts.IsInitialized) { MelonLogger.Warning("⚠\ufe0f Buyer NPCs still not initialized after timeout. Skipping status sync."); return false; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [SaveableField("DeliveryData")] public DeliverySaveData Data = new DeliverySaveData(); public EmpireNPC buyer; private DeadDropInstance deliveryDrop; private StorageInstance? subscribedStorage; public QuestEntry deliveryEntry; public QuestEntry rewardEntry; public static bool QuestActive; private const string DropNameColor = "00FFCC"; private const string DealTimeColor = "FFD166"; public static QuestDelivery? Active { get; internal set; } protected override Sprite? QuestIcon => EmpireResourceLoader.LoadEmbeddedIcon(Data.QuestImage ?? "EmpireIcon_quest.png"); protected override string Title => (!string.IsNullOrEmpty(Data?.ProductID)) ? ("Deliver " + Data.ProductID + " to " + Data.DealerName) : "Empire Delivery"; protected override string Description => (!string.IsNullOrEmpty(Data?.ProductID) && Data.RequiredAmount != 0) ? (Data.Task ?? "") : "Deliver the assigned product to the stash location."; public QuestEntry GetDeliveryEntry() { return deliveryEntry; } public QuestEntry GetRewardEntry() { return rewardEntry; } public void ForceCancel() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 MelonLogger.Msg("\ud83d\udeab QuestDelivery.ForceCancel() called."); GiveReward("Failed"); if (deliveryEntry != null && (int)deliveryEntry.State != 2) { deliveryEntry.SetState((QuestState)4); } if (rewardEntry != null && (int)rewardEntry.State != 2) { rewardEntry.SetState((QuestState)3); } QuestActive = false; Active = null; ((Quest)this).Fail(); } public void Cleanup() { MelonLogger.Msg("\ud83d\udeab QuestDelivery.Cleanup() called."); CleanupSubscriptions(); MelonLogger.Msg("Calling"); ((Quest)this).Fail(); QuestActive = false; Active = null; } private void ExpireCountdown() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Invalid comparison between Unknown and I4 MelonLogger.Msg($"ExpireCountdown called. DealTime before: {Data.DealTime}"); Data.DealTime--; MelonLogger.Msg($"DealTime after: {Data.DealTime}"); deliveryEntry.Title = Data.Task + " at the " + Colorize(deliveryDrop.Name, "00FFCC") + ". Expiry: " + Colorize(Data.DealTime.ToString(), "FFD166") + " Days"; if (Data.DealTime <= 0 && (int)rewardEntry.State != 1) { GiveReward("Expired"); if (deliveryEntry != null && (int)deliveryEntry.State != 2) { deliveryEntry.SetState((QuestState)4); } if (rewardEntry != null && (int)rewardEntry.State != 2) { rewardEntry.SetState((QuestState)4); } QuestActive = false; Active = null; ((Quest)this).Expire(); } } protected override void OnLoaded() { MelonLogger.Msg("Quest OnLoaded called."); ((Saveable)this).OnLoaded(); MelonCoroutines.Start(WaitForBuyerAndLoad()); MelonLogger.Msg("Quest OnLoaded() done."); } [IteratorStateMachine(typeof(<WaitForBuyerAndLoad>d__19))] private IEnumerator WaitForBuyerAndLoad() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForBuyerAndLoad>d__19(0) { <>4__this = this }; } protected override void OnCreated() { //IL_01eb: Unknown result type (might be due to invalid IL or missing references) MelonLogger.Msg("Quest OnCreated called."); ((Registerable)this).OnCreated(); MelonLogger.Msg("QuestOnCreated() done."); if (Active != null && Active != this) { Active.CleanupSubscriptions(); } buyer = Contacts.GetBuyer(Data.DealerName); ConsoleHelper.SetLawIntensity(2f * (float)buyer.Tier); QuestActive = true; Active = this; TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(ExpireCountdown)); TimeManager.OnDayPass = (Action)Delegate.Combine(TimeManager.OnDayPass, new Action(ExpireCountdown)); if (!Data.Initialized) { List<DeadDropInstance> list = DeadDropManager.All?.ToList(); if (list == null || list.Count < 1) { MelonLogger.Error("❌ Not enough dead drops to assign delivery/reward."); return; } deliveryDrop = list[RandomUtils.RangeInt(0, list.Count)]; Data.DeliveryDropGUID = deliveryDrop.GUID; Data.Initialized = true; } else { deliveryDrop = ((IEnumerable<DeadDropInstance>)DeadDropManager.All).FirstOrDefault((Func<DeadDropInstance, bool>)((DeadDropInstance d) => d.GUID == Data.DeliveryDropGUID)); } deliveryEntry = ((Quest)this).AddEntry(Data.Task + " at the " + Colorize(deliveryDrop.Name, "00FFCC") + ". Expiry: " + Colorize(Data.DealTime.ToString(), "FFD166") + " Days", (Vector3?)null); deliveryEntry.POIPosition = deliveryDrop.Position; deliveryEntry.Begin(); rewardEntry = ((Quest)this).AddEntry("Wait for the payment to arrive.", (Vector3?)null); MelonLogger.Msg("\ud83d\udce6 Setting rewardEntry state to Inactive."); rewardEntry.SetState((QuestState)0); DeadDropInstance obj = deliveryDrop; if (((obj != null) ? obj.Storage : null) != null) { MelonLogger.Msg("Subscribing CheckDelivery for quest " + Data.DealerName + " on storage " + deliveryDrop.GUID); subscribedStorage = deliveryDrop.Storage; subscribedStorage.OnClosed -= CheckDelivery; subscribedStorage.OnClosed += CheckDelivery; } else { MelonLogger.Warning("⚠\ufe0f deliveryDrop.Storage is null when attempting to subscribe to OnClosed."); } MelonLogger.Msg("\ud83d\udce6 QuestDelivery started with drop locations assigned."); } private uint PackageAmount(string packaging) { if (1 == 0) { } uint result = packaging switch { "Brick" => 20u, "Jar" => 5u, "Baggie" => 1u, _ => 0u, }; if (1 == 0) { } return result; } private void SendBuyerMessage(DialogueType type, string context = "") { if (buyer == null) { MelonLogger.Warning($"Cannot send {type} message: buyer is null. Context: {context}"); return; } try { buyer.SendCustomMessage(type, Data.ProductID, (int)Data.RequiredAmount, Data.Quality, Data.NecessaryEffects, Data.OptionalEffects, Data.Reward); } catch (Exception ex) { MelonLogger.Error($"Failed to send {type} message from {buyer.DisplayName}: {ex.Message}"); } } private void SendBuyerCustomMessage(string message, string context = "") { if (buyer == null) { MelonLogger.Warning("Cannot send custom message: buyer is null. Context: " + context); return; } if (string.IsNullOrWhiteSpace(message)) { MelonLogger.Warning("Cannot send empty message from " + buyer.DisplayName + ". Context: " + context); return; } try { buyer.SendCustomMessage(message); } catch (Exception ex) { MelonLogger.Error("Failed to send custom message from " + buyer.DisplayName + ": " + ex.Message); } } private void CheckDelivery() { //IL_0765: Unknown result type (might be due to invalid IL or missing references) //IL_076b: Invalid comparison between Unknown and I4 //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) if (!QuestActive || Active != this) { MelonLogger.Msg("CheckDelivery ignored: quest not active or not current."); if (subscribedStorage != null) { subscribedStorage.OnClosed -= CheckDelivery; subscribedStorage = null; } DeadDropInstance obj = deliveryDrop; if (((obj != null) ? obj.Storage : null) != null) { deliveryDrop.Storage.OnClosed -= CheckDelivery; } return; } MelonLogger.Msg("CheckDelivery called."); DeadDropInstance obj2 = deliveryDrop; object obj3; if (obj2 == null) { obj3 = null; } else { StorageInstance storage = obj2.Storage; obj3 = ((storage != null) ? storage.Slots : null); } if (obj3 == null) { MelonLogger.Error("❌ Storage or slots are null in CheckDelivery"); return; } MelonLogger.Msg($"Expecting ProductID: {Data.ProductID}, RequiredAmount: {Data.RequiredAmount}"); if (buyer != null && buyer.CurfewDeal && !TimeManager.IsNight) { MelonLogger.Msg("❌ Curfew deal is true but it is not night. Cannot deliver."); SendBuyerCustomMessage("Deliveries only after Curfew.", "curfew check"); return; } ItemSlotInstance[] slots = deliveryDrop.Storage.Slots; ProductInstance item = default(ProductInstance); foreach (ItemSlotInstance val in slots) { if (((val != null) ? val.ItemInstance : null) == null) { MelonLogger.Warning("⚠\ufe0f Encountered null slot or item instance, skipping..."); continue; } bool flag = val.ItemInstance is ProductInstance; ref ProductInstance reference = ref item; ItemInstance itemInstance = val.ItemInstance; reference = (ProductInstance)(object)((itemInstance is ProductInstance) ? itemInstance : null); if (item == null) { SendBuyerCustomMessage("This is not even a product...", "invalid product instance"); MelonLogger.Warning("⚠\ufe0f Item is not a ProductInstance, skipping..."); continue; } ProductDefinition definition = item.Definition; object arg = ((definition != null) ? new ItemCategory?(((ItemDefinition)definition).Category) : null); object arg2 = val.Quantity; ProductDefinition definition2 = item.Definition; MelonLogger.Msg($"Slot: {arg} - {arg2} package - {((definition2 != null) ? ((ItemDefinition)definition2).Name : null)} "); object obj4; if (!flag) { obj4 = "null"; } else { ProductDefinition definition3 = item.Definition; obj4 = ((definition3 != null) ? ((ItemDefinition)definition3).Name : null); } string text = (string)obj4; object obj5; if (!flag) { obj5 = "null"; } else { PackagingDefinition appliedPackaging = item.AppliedPackaging; obj5 = ((appliedPackaging != null) ? ((ItemDefinition)appliedPackaging).Name : null); } string packaging = (string)obj5; int quantity = val.Quantity; if (Data?.NecessaryEffects == null) { MelonLogger.Error("❌ NecessaryEffects is null"); return; } ProductDefinition val2 = ((IEnumerable<ProductDefinition>)ProductManager.DiscoveredProducts).FirstOrDefault((Func<ProductDefinition, bool>)delegate(ProductDefinition p) { string iD = ((ItemDefinition)p).ID; ProductInstance obj7 = item; return iD == ((obj7 != null) ? ((ItemDefinition)obj7.Definition).ID : null); }); string productType = GetProductType(val2); if (productType != Data.ProductID) { MelonLogger.Error("❌ Product type mismatch: " + productType + " != " + Data.ProductID); SendBuyerCustomMessage("This is not the drug type I ordered.", "product type mismatch"); continue; } IReadOnlyList<PropertyBase> properties2 = val2.Properties; WeedDefinition val3 = (WeedDefinition)(object)((val2 is WeedDefinition) ? val2 : null); if (val3 != null) { properties2 = val3.GetProperties(); } else { MethDefinition val4 = (MethDefinition)(object)((val2 is MethDefinition) ? val2 : null); if (val4 != null) { properties2 = val4.GetProperties(); } else { CocaineDefinition val5 = (CocaineDefinition)(object)((val2 is CocaineDefinition) ? val2 : null); if (val5 != null) { properties2 = val5.GetProperties(); } else { ShroomDefinition val6 = (ShroomDefinition)(object)((val2 is ShroomDefinition) ? val2 : null); if (val6 != null) { properties2 = val6.GetProperties(); } } } } MelonLogger.Msg($"count : {properties2.Count}"); List<string> properties = new List<string>(); if (properties2.Count > 0) { for (int j = 0; j < properties2.Count; j++) { PropertyBase val7 = properties2[j]; properties.Add(val7.name.Trim().ToLower()); } } MelonLogger.Msg("Item Properties: " + string.Join(", ", properties)); MelonLogger.Msg("NecessaryEffects: " + string.Join(", ", Data.NecessaryEffects)); MelonLogger.Msg("OptionalEffects: " + string.Join(", ", Data.OptionalEffects)); if (!Data.NecessaryEffects.All((string effect) => properties.Contains(effect.Trim().ToLower()))) { MelonLogger.Error("❌ Effect type mismatch"); SendBuyerCustomMessage("All the required necessary effects are not present.", "missing required effects"); continue; } ProductInstance obj6 = item; Quality val8 = (Quality)((obj6 != null) ? ((int)obj6.Quality) : 0); MelonLogger.Msg($"Quality: {val8}"); string quality = ((object)(Quality)(ref val8)).ToString().ToLower().Trim(); int qualityNumber = GetQualityNumber(quality); if (qualityNumber < GetQualityNumber(Data.Quality)) { MelonLogger.Error($"❌ Quality mismatch: {val8} < {GetQualityNumber(Data.Quality)} or {val8} > {GetQualityNumber(Data.Quality)}"); SendBuyerCustomMessage("The quality of the product is worse than what I ordered.", "quality too low"); } else if (flag) { uint num = (uint)(quantity * PackageAmount(packaging)); if (num > Data.RequiredAmount) { int val9 = (int)Math.Ceiling((float)Data.RequiredAmount / (float)PackageAmount(packaging)); val9 = Math.Min(val9, val.Quantity); val.AddQuantity(-val9); UpdateReward(Data.RequiredAmount, val2, properties); Data.RequiredAmount = 0u; MelonLogger.Msg($"✅ Delivered {num}x {text} to the stash. Remaining: {Data.RequiredAmount}. Reward now: {Data.Reward}"); break; } val.AddQuantity(-quantity); UpdateReward(num, val2, properties); Data.RequiredAmount -= num; MelonLogger.Msg($"✅ Delivered {num}x {text} to the stash. Remaining: {Data.RequiredAmount}. Reward now: {Data.Reward}"); } } if (Data.RequiredAmount == 0 && (int)deliveryEntry.State == 1) { SendBuyerMessage(DialogueType.Success, "delivery complete"); MelonLogger.Msg("❌ No required amount to deliver. Quest done."); deliveryEntry.Complete(); rewardEntry.SetState((QuestState)1); MelonCoroutines.Start(DelayedReward("Completed")); } else if (Data.RequiredAmount != 0) { SendBuyerMessage(DialogueType.Incomplete, "partial delivery"); MelonLogger.Msg($"Continue delivery. Remaining amount: {Data.RequiredAmount}"); } } private string? GetProductType(ProductDefinition? productDef) { if (productDef is WeedDefinition) { return "weed"; } if (productDef is MethDefinition) { return "meth"; } if (productDef is CocaineDefinition) { return "cocaine"; } if (productDef is ShroomDefinition) { return "shrooms"; } return null; } private int GetQualityNumber(string quality) { if (string.IsNullOrWhiteSpace(quality)) { MelonLogger.Error("❌ Quality is null or empty."); return -1; } string key = quality.Trim(); if (!QualityRegistry.ByName.TryGetValue(key, out QualityInfo value)) { MelonLogger.Error("❌ Quality not found: " + quality); return -1; } return QualityRegistry.Qualities.IndexOf(value); } private void UpdateReward(uint total, ProductDefinition? productDef, List<string> properties) { if ((ItemDefinition)(object)productDef == (ItemDefinition)null) { MelonLogger.Error("❌ Product definition is null or not a ProductDefinition. Reward calculation skipped."); return; } float qualityMult = Data.QualityMult; int qualityNumber = GetQualityNumber(Data.Quality); float num = Data.NecessaryEffectMult.Sum(); for (int i = 0; i < Data.OptionalEffects.Count; i++) { if (properties.Contains(Data.OptionalEffects[i])) { num += Data.OptionalEffectMult[i]; } } Data.Reward += (int)((float)total * productDef.MarketValue * (1f + qualityMult) * Data.DealTimeMult * (1f + num)); MelonLogger.Msg($" Reward updated: {Data.Reward} with Price: {productDef.MarketValue}, Quality: {qualityMult} and EffectsSum: {num} and DealTimeMult: {Data.DealTimeMult}."); } [IteratorStateMachine(typeof(<DelayedReward>d__28))] private IEnumerator DelayedReward(string source) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedReward>d__28(0) { <>4__this = this, source = source }; } private void CleanupSubscriptions() { if (subscribedStorage != null) { string dealerName = Data.DealerName; DeadDropInstance obj = deliveryDrop; MelonLogger.Msg("Unsubscribing CheckDelivery for quest " + dealerName + " on storage " + ((obj != null) ? obj.GUID : null)); subscribedStorage.OnClosed -= CheckDelivery; subscribedStorage = null; } else { DeadDropInstance obj2 = deliveryDrop; if (((obj2 != null) ? obj2.Storage : null) != null) { MelonLogger.Msg("Unsubscribing CheckDelivery for quest " + Data.DealerName + " on storage " + deliveryDrop.GUID); deliveryDrop.Storage.OnClosed -= CheckDelivery; } } TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(ExpireCountdown)); } private void GiveReward(string source) { CleanupSubscriptions(); switch (source) { case "Expired": Data.Reward = -Data.Penalties[0]; Data.RepReward = -Data.Penalties[1]; Money.ChangeCashBalance((float)Data.Reward, true, false); if (buyer != null) { buyer.GiveReputation(Data.RepReward); SendBuyerMessage(DialogueType.Expire, "quest expired"); } break; case "Failed": Data.Reward = -Data.Penalties[0]; Data.RepReward = -Data.Penalties[1]; Money.ChangeCashBalance((float)Data.Reward, true, false); if (buyer != null) { buyer.GiveReputation(Data.RepReward); SendBuyerMessage(DialogueType.Fail, "quest failed"); } break; case "Completed": Data.RepReward += (int)((float)Data.Reward * Data.RepMult); Data.XpReward += (int)((float)Data.Reward * Data.XpMult); if (buyer != null) { buyer.GiveReputation(Data.RepReward); buyer.IncreaseCompletedDeals(1); buyer.UnlockDrug(); SendBuyerMessage(DialogueType.Reward, "quest completed"); } ConsoleHelper.GiveXp(Data.XpReward); Contacts.Update(); ((Quest)this).Complete(); QuestActive = false; Active = null; if (buyer.DebtManager == null) { Money.ChangeCashBalance((float)Data.Reward, true, false); } else if (buyer.DealerSaveData.DebtRemaining > 0f && !buyer.DebtManager.paidthisweek) { if (buyer.DealerSaveData.DebtRemaining <= buyer.Debt.ProductBonus * (float)Data.Reward) { int num = Data.Reward - (int)(buyer.DealerSaveData.DebtRemaining / buyer.Debt.ProductBonus); float debtRemaining = buyer.DealerSaveData.DebtRemaining; buyer.DealerSaveData.DebtRemaining = 0f; MelonLogger.Msg(" Paid off debt to " + buyer.DisplayName); Money.ChangeCashBalance((float)num, true, false); if (buyer.DebtManager != null) { buyer.DebtManager.SendDebtMessage((int)debtRemaining, "deal"); } } else { MelonLogger.Msg($" Paid off debt: ${Data.Reward} to {buyer.DisplayName}"); buyer.DealerSaveData.DebtRemaining -= buyer.Debt.ProductBonus * (float)Data.Reward; buyer.DealerSaveData.DebtPaidThisWeek += buyer.Debt.ProductBonus * (float)Data.Reward; if (buyer.DebtManager != null) { buyer.DebtManager.SendDebtMessage((int)((float)Data.Reward * buyer.Debt.ProductBonus), "deal"); } } if (buyer.DebtManager != null) { buyer.DebtManager.CheckIfPaidThisWeek(); } } else { Money.ChangeCashBalance((float)Data.Reward, true, false); } break; default: MelonLogger.Error("❌ Unknown source: " + source + "."); return; } MelonLogger.Msg($" Rewarded : ${Data.Reward} and Rep {Data.RepReward} and Xp (if completed) {Data.XpReward} from {Data.DealerName}"); EmpirePhoneApp.Instance.OnQuestComplete(); QuestEntry obj = rewardEntry; if (obj != null) { obj.Complete(); } } private string Colorize(string text, string hex) { return "<color=#" + hex + ">" + text + "</color>"; } } } namespace Empire.Quest.Data { public class DeliverySaveData { public string ProductID; public uint RequiredAmount; public string DeliveryDropGUID; public string RewardDropGUID; public bool Initialized; public string DealerName; public string? QuestImage; public string Task; public int Reward; public int RepReward; public int XpReward; public float RepMult; public float XpMult; public int DealTime; public float DealTimeMult; public List<int> Penalties; public List<string> OptionalEffects; public List<float> OptionalEffectMult; public List<string> NecessaryEffects; public List<float> NecessaryEffectMult; public string Quality; public float QualityMult; public DeliverySaveData() { Penalties = new List<int>(); OptionalEffects = new List<string>(); NecessaryEffects = new List<string>(); OptionalEffectMult = new List<float>(); NecessaryEffectMult = new List<float>(); } } } namespace Empire.Phone { public class EmpirePhoneApp : PhoneApp { [CompilerGenerated] private sealed class <BlinkMessage>d__49 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Text message; public EmpirePhoneApp <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BlinkMessage>d__49(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)message != (Object)null) { Object.Destroy((Object)(object)((Component)message).gameObject); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitForBuyerAndInitialize>d__50 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EmpirePhoneApp <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForBuyerAndInitialize>d__50(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; MelonLogger.Msg("PhoneApp-WaitForBuyerAndInitialize-Waiting for Contacts to be initialized..."); goto IL_0051; case 1: <>1__state = -1; goto IL_0051; case 2: { <>1__state = -1; break; } IL_0051: if (!Contacts.IsInitialized) { <>2__current = null; <>1__state = 1; return true; } MelonLogger.Msg("PhoneApp: Contacts.IsInitialized is true, now waiting for full processing..."); break; } if (!Contacts.AreContactsFullyProcessed) { <>2__current = null; <>1__state = 2; return true; } MelonLogger.Msg("Dealers and Buyers initialized successfully."); <>4__this.LoadQuests(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private List<QuestData> quests; private RectTransform questListContainer; private RectTransform buyerListContainer; private Text questTitle; private Text questTask; private Text questReward; private Text deliveryStatus; private Text acceptLabel; private Text cancelLabel; private Text refreshLabel; private Text manageLabel; private Button acceptButton; private Button cancelButton; private Button refreshButton; private Button manageButton; private Text statusText; private Text managementTabLabel; public static int Index; private EmpireNPC selectedBuyer; private GameObject managementDetailPanel; public static string QuestImage; private GameObject messageContainer; private Quest? q; private static readonly Dictionary<int, MelonPreferences_Entry<int>> TierMinDaysMap = new Dictionary<int, MelonPreferences_Entry<int>> { { 1, EmpireMod.Tier1MinDays }, { 2, EmpireMod.Tier2MinDays }, { 3, EmpireMod.Tier3MinDays }, { 4, EmpireMod.Tier4MinDays }, { 5, EmpireMod.Tier5MinDays } }; public static EmpirePhoneApp Instance { get; set; } protected override string AppName => "Empire"; protected override string AppTitle => "Empire"; protected override string IconLabel => "Empire"; protected override string IconFileName => ""; protected override Sprite? IconSprite => EmpireResourceLoader.LoadEmbeddedIcon("EmpireIcon.png"); public static void Reset() { if (QuestDelivery.QuestActive && QuestDelivery.Active != null) { MelonLogger.Msg("[EmpireApp] Resetting active quest state."); QuestDelivery.Active.Cleanup(); } if (Instance.q != null) { MelonLogger.Msg("[EmpireApp] Resetting EmpirePhoneApp instance."); Instance.q = null; } } private Transform GetMessageParent() { if ((Object)(object)messageContainer != (Object)null) { return messageContainer.transform; } if ((Object)(object)managementDetailPanel != (Object)null) { return managementDetailPanel.transform; } return null; } protected override void OnCreated() { ((PhoneApp)this).OnCreated(); MelonLogger.Msg("[EmpirePhoneApp] OnCreated called"); Instance = this; Reset(); TimeManager.OnDayPass = (Action)Delegate.Remove(TimeManager.OnDayPass, new Action(LoadQuests)); TimeManager.OnDayPass = (Action)Delegate.Combine(TimeManager.OnDayPass, new Action(LoadQuests)); MelonLogger.Msg("✅ TimeManager.OnDayPass event subscribed"); } public static void DetermineDealDaysStatic() { Instance?.DetermineDealDays(); } public static void DetermineDealDaysStatic(EmpireNPC buyer) { Instance?.DetermineDealDays(buyer); } public void DetermineDealDays(EmpireNPC buyer) { if (EmpireMod.RandomizeDealDays.Value) { MelonLogger.Msg("[EmpirePhoneApp] Determining deal days for buyer " + buyer.DisplayName + "."); int configuredMinDealDays = GetConfiguredMinDealDays(buyer.Tier); int num = configuredMinDealDays + 2; int value = Random.Range(configuredMinDealDays, num + 1); int num2 = Math.Clamp(value, 1, 7); buyer.ActiveDealDays = DealDayUtility.GetRandomDays(num2); MelonLogger.Msg(string.Format("[EmpirePhoneApp] Buyer {0} (Tier {1}) assigned {2} deal days: {3}", buyer.DisplayName, buyer.Tier, num2, string.Join(", ", buyer.ActiveDealDays))); } else { MelonLogger.Msg("[EmpirePhoneApp] Using default deal days for buyer " + buyer.DisplayName + "."); buyer.ActiveDealDays = new List<string>(buyer.DefaultDealDays); MelonLogger.Msg(string.Format("[EmpirePhoneApp] Buyer {0} (Tier {1}) assigned default deal days: {2}", buyer.DisplayName, buyer.Tier, string.Join(", ", buyer.ActiveDealDays))); } } public void DetermineDealDays() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)TimeManager.CurrentDay > 0) { MelonLogger.Msg("[EmpirePhoneApp] Skipping deal day determination - not Monday."); return; } foreach (EmpireNPC value in Contacts.Buyers.Values) { if (value != null && value.IsUnlocked) { DetermineDealDays(value); } } } private int GetConfiguredMinDealDays(int buyerTier) { if (TierMinDaysMap.TryGetValue(buyerTier, out MelonPreferences_Entry<int> value)) { return value.Value; } MelonLogger.Msg($"[EmpirePhoneApp] Unknown buyer tier {buyerTier} - defaulting to 1 min deal day."); return 1; } protected override void OnCreatedUI(GameObject container) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_01b5: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) GameObject bg = UIFactory.Panel("MainBG", container.transform, Color.black, (Vector2?)null, (Vector2?)null, true); UIFactory.TopBar("TopBar", bg.transform, "Deals", 0.82f, 75, 75, 0, 35); statusText = UIFactory.Text("Status", "", bg.transform, 14, (TextAnchor)0, (FontStyle)0); ((Graphic)statusText).rectTransform.anchorMin = new Vector2(0.7f, 0.85f); ((Graphic)statusText).rectTransform.anchorMax = new Vector2(0.98f, 0.9f); statusText.alignment = (TextAnchor)5; GameObject val = UIFactory.Panel("QuestListPanel", bg.transform, new Color(0.1f, 0.1f, 0.1f), (Vector2?)new Vector2(0.02f, 0.05f), (Vector2?)new Vector2(0.49f, 0.82f), false); ScrollRect val2 = default(ScrollRect); questListContainer = UIFactory.ScrollableVerticalList("QuestListScroll", val.transform, ref val2); UIFactory.FitContentHeight(questListContainer); GameObject val3 = UIFactory.Panel("DetailPanel", bg.transform, new Color(0.12f, 0.12f, 0.12f), (Vector2?)new Vector2(0.49f, 0f), (Vector2?)new Vector2(0.98f, 0.82f), false); UIFactory.VerticalLayoutOnGO(val3, 14, new RectOffset(24, 50, 15, 70)); questTitle = UIFactory.Text("Title", "", val3.transform, 24, (TextAnchor)3, (FontStyle)1); questTask = UIFactory.Text("Task", "", val3.transform, 18, (TextAnchor)3, (FontStyle)0); questReward = UIFactory.Text("Reward", "", val3.transform, 18, (TextAnchor)3, (FontStyle)0); deliveryStatus = UIFactory.Text("DeliveryStatus", "", val3.transform, 16, (TextAnchor)3, (FontStyle)2); ((Graphic)deliveryStatus).color = new Color(32f, 130f, 246f, 255f); GameObject val4 = UIFactory.Panel("TopButtonRow", val3.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); UIFactory.HorizontalLayoutOnGO(val4, 12, 0, 0, 0, 0, (TextAnchor)4); UIFactory.SetLayoutGroupPadding((LayoutGroup)(object)val4.GetComponent<HorizontalLayoutGroup>(), 0, 0, 0, 0); (GameObject, Button, Text) tuple = UIFactory.RoundedButtonWithLabel("AcceptBtn", "No quest selected", val3.transform, Color32.op_Implicit(new Color32((byte)32, (byte)130, (byte)246, byte.MaxValue)), 460f, 60f, 22, Color.black); GameObject item = tuple.Item1; Button item2 = tuple.Item2; Text item3 = tuple.Item3; acceptButton = item2; acceptLabel = item3; ButtonUtils.Disable(item2, acceptLabel, "No quest selected"); (GameObject, Button, Text) tuple2 = UIFactory.RoundedButtonWithLabel("CancelBtn", "Cancel current delivery", val3.transform, Color32.op_Implicit(new Color32((byte)32, (byte)130, (byte)246, byte.MaxValue)), 460f, 60f, 22, Color.black); GameObject item4 = tuple2.Item1; Button item5 = tuple2.Item2; Text item6 = tuple2.Item3; cancelButton = item5; cancelLabel = item6; if (!QuestDelivery.QuestActive) { ButtonUtils.Disable(cancelButton, cancelLabel, "No quest active"); } (GameObject, Button, Text) tuple3 = UIFactory.RoundedButtonWithLabel("ManageBtn", "Manage", bg.transform, new Color(0.2f, 0.2f, 0.2f, 1f), 100f, 40f, 16, Color.white); GameObject item7 = tuple3.Item1; Button item8 = tuple3.Item2; Text item9 = tuple3.Item3; manageButton = item8; manageLabel = item9; ButtonUtils.AddListener(item8, (Action)delegate { OpenManageUI(bg); }); RectTransform component = item7.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.75f, 0.96f); component.anchorMax = new Vector2(0.85f, 1f); component.pivot = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(-10f, -10f); component.sizeDelta = new Vector2(50f, 25f); (GameObject, Button, Text) tuple4 = UIFactory.RoundedButtonWithLabel("RefreshBtn", "Contact Dealers", bg.transform, new Color(0.2f, 0.2f, 0.2f, 1f), 300f, 90f, 22, Color.white); GameObject item10 = tuple4.Item1; Button item11 = tuple4.Item2; Text item12 = tuple4.Item3; refreshButton = item11; refreshLabel = item12; ButtonUtils.AddListener(refreshButton, (Action)delegate { RefreshButton(); }); RectTransform component2 = item10.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.9f, 0.96f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(1f, 1f); component2.anchoredPosition = new Vector2(-10f, -10f); component2.sizeDelta = new Vector2(50f, 25f); MelonCoroutines.Start(WaitForBuyerAndInitialize()); } private void OpenManageUI(GameObject bg) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0395: 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_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Expected O, but got Unknown //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) GameObject managementPanel = UIFactory.Panel("ManagementPanel", bg.transform, new Color(40f / 51f, 40f / 51f, 40f / 51f, 0.3f), (Vector2?)null, (Vector2?)null, true); managementPanel.gameObject.SetActive(true); managementPanel.transform.SetAsLastSibling(); GameObject val = UIFactory.Panel("ManageTopBar", managementPanel.transform, new Color(10f / 51f, 10f / 51f, 10f / 51f, 1f), (Vector2?)null, (Vector2?)null, false); RectTransform component = val.GetComponent<RectTransform>(); int num = 110; component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(0f, (float)num); component.anchoredPosition = new Vector2(0f, 0f); UIFactory.HorizontalLayoutOnGO(val, 20, 20, 20, 10, 10, (TextAnchor)3); (GameObject, Button, Text) tuple = UIFactory.RoundedButtonWithLabel("RepButton", "Reputation", val.transform, new Color(0.2f, 0.2f, 0.2f, 1f), 120f, 40f, 16, Color.white); ButtonUtils.ClearListeners(tuple.Item2); ButtonUtils.AddListener(tuple.Item2, (Action)delegate { UpdateBuyerDetails("Reputation"); }); (GameObject, Button, Text) tuple2 = UIFactory.RoundedButtonWithLabel("ProdButton", "Product", val.transform, new Color(0.2f, 0.2f, 0.2f, 1f), 120f, 40f, 16, Color.white); ButtonUtils.ClearListeners(tuple2.Item2); ButtonUtils.AddListener(tuple2.Item2, (Action)delegate { UpdateBuyerDetails("Product"); }); (GameObject, Button, Text) tuple3 = UIFactory.RoundedButtonWithLabel("ShipButton", "Shipping", val.transform, new Color(0.2f, 0.2f, 0.2f, 1f), 120f, 40f, 16, Color.white); ButtonUtils.ClearListeners(tuple3.Item2); ButtonUtils.AddListener(tuple3.Item2, (Action)delegate { UpdateBuyerDetails("Shipping"); }); (GameObject, Button, Text) tuple4 = UIFactory.RoundedButtonWithLabel("GiftsButton", "Gifts", val.transform, new Color(0.2f, 0.2f, 0.2f, 1f), 120f, 40f, 16, Color.white); ButtonUtils.ClearListeners(tuple4.Item2); ButtonUtils.AddListener(tuple4.Item2, (Action)delegate { UpdateBuyerDetails("Gifts"); }); (GameObject, Button, Text) tuple5 = UIFactory.RoundedButtonWithLabel("DebtButton", "Debt", val.transform, new Color(0.2f, 0.2f, 0.2f, 1f), 120f, 40f, 16, Color.white); ButtonUtils.ClearListeners(tuple5.Item2); ButtonUtils.AddListener(tuple5.Item2, (Action)delegate { UpdateBuyerDetails("Debt"); }); LayoutElement val2 = val.AddComponent<LayoutElement>(); val2.flexibleWidth = 1f; managementTabLabel = UIFactory.Text("ManagementTabLabel", "Reputation", val.transform, 20, (TextAnchor)4, (FontStyle)1); (GameObject, Button, Text) tuple6 = UIFactory.RoundedButtonWithLabel("CloseButton", "X", val.transform, Color32.op_Implicit(new Color32((byte)235, (byte)53, (byte)56, byte.MaxValue)), 50f, 40f, 16, Color.white); ButtonUtils.AddListener(tuple6.Item2, (Action)delegate { Object.Destroy((Object)(object)managementPanel); RefreshQuestList(); }); ((Transform)tuple6.Item1.GetComponent<RectTransform>()).SetAsLastSibling(); GameObject val3 = UIFactory.Panel("ManageContent", managementPanel.transform, new Color(0.12f, 0.12f, 0.12f, 1f), (Vector2?)null, (Vector2?)null, false); RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 0f); component2.anchorMax = new Vector2(1f, 0.85f); component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; GameObject val4 = UIFactory.Panel("BuyerListPanel", val3.transform, new Color(0.1f, 0.1f, 0.1f, 1f), (Vector2?)null, (Vector2?)null, false); RectTransform component3 = val4.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(0.4f, 1f); component3.offsetMin = Vector2.zero; component3.offsetMax = Vector2.zero; ScrollRect val5 = default(ScrollRect); buyerListContainer = UIFactory.ScrollableVerticalList("BuyerListScroll", val4.transform, ref val5); UIFactory.FitContentHeight(buyerListContainer); PopulateBuyerList(buyerListContainer); GameObject val6 = UIFactory.Panel("DetailPanel", val3.transform, new Color(0.12f, 0.12f, 0.12f, 1f), (Vector2?)null, (Vector2?)null, false); RectTransform component4 = val6.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0.4f, 0f); component4.anchorMax = new Vector2(1f, 0.89f); component4.offsetMin = Vector2.zero; component4.offsetMax = Vector2.zero; UIFactory.VerticalLayoutOnGO(val6, 14, new RectOffset(24, 50, 15, 70)); managementDetailPanel = val6; messageContainer = UIFactory.Panel("MessageContainer", val3.transform, new Color(0f, 0f, 0f, 0f), (Vector2?)null, (Vector2?)null, false); RectTransform component5 = messageContainer.GetComponent<RectTransform>(); component5.anchorMin = new Vector2(0.4f, 0f); component5.anchorMax = new Vector2(1f, 0f); component5.pivot = new Vector2(0.5f, 0f); component5.sizeDelta = new Vector2(0f, 70f); component5.anchoredPosition = new Vector2(0f, 10f); Image component6 = messageContainer.GetComponent<Image>(); if ((Object)(object)component6 != (Object)null) { ((Graphic)component6).color = new Color(0f, 0f, 0f, 0f); } messageContainer.transform.SetAsLastSibling(); val.transform.SetAsLastSibling(); EmpireNPC empireNPC = Contacts.Buyers.Values.FirstOrDefault((EmpireNPC b) => b.IsUnlocked); if (empireNPC != null) { if (selectedBuyer == null || !selectedBuyer.IsUnlocked) { selectedBuyer = empireNPC; } UpdateBuyerDetails("Reputation"); } else { selectedBuyer = null; UpdateBuyerDetails("Reputation"); } } private void UpdateBuyerDetails(string tab) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_07b6: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_0b4b: Unknown result type (might be due to invalid IL or missing references) //IL_0b50: Unknown result type (might be due to invalid IL or missing references) //IL_0b61: Unknown result type (might be due to invalid IL or missing references) //IL_0bb6: Unknown result type (might be due to invalid IL or missing references) //IL_0bbb: Unknown result type (might be due to invalid IL or missing references) //IL_0bcc: Unknown result type (might be due to invalid IL or missing references) //IL_08df: Unknown result type (might be due to invalid IL or missing references) //IL_08e4: Unknown result type (might be due to invalid IL or missing references) //IL_08f5: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Unknown result type (might be due to invalid IL or missing references) //IL_06d9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)managementDetailPanel == (Object)null) { MelonLogger.Warning("[EmpirePhoneApp] UpdateBuyerDetails called but managementDetailPanel is null."); return; } for (int num = managementDetailPanel.transform.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)managementDetailPanel.transform.GetChild(num)).gameObject); } if (selectedBuyer == null) { UIFactory.Text("NoSelectionText", "Select a contact from the list.", managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); return; } string text = ""; switch (tab) { case "Reputation": { string fileName = selectedBuyer.Image ?? "fallback-dealer.png"; UIFactory.SetIcon(EmpireResourceLoader.LoadEmbeddedIcon(fileName), managementDetailPanel.transform); Image componentInChildren = ((Component)managementDetailPanel.transform).GetComponentInChildren<Image>(); if ((Object)(object)componentInChildren != (Object)null) { ((Component)componentInChildren).GetComponent<RectTransform>().sizeDelta = new Vector2(127f, 127f); } text = $"<b>Reputation:</b> {selectedBuyer.DealerSaveData.Reputation}"; if (selectedBuyer.ActiveDealDays != null && selectedBuyer.ActiveDealDays.Count > 0) { string text3 = string.Join(", ", selectedBuyer.ActiveDealDays); text = text + "\n\n<b><color=#FFA500>Deal Days:</color></b> <color=#FFFFFF>" + text3 + "</color>"; } List<EmpireNPC> list = Contacts.Buyers.Values.Where((EmpireNPC b) => !b.IsUnlocked && b.UnlockRequirements != null && b.UnlockRequirements.Any((UnlockRequirement r) => r.Name == selectedBuyer.DisplayName && r.MinRep > selectedBuyer.DealerSaveData.Reputation)).ToList(); if (list.Count > 0) { text += "\n\n<b>Pending Unlocks:</b>\n"; foreach (EmpireNPC item in list) { UnlockRequirement unlockRequirement = item.UnlockRequirements.FirstOrDefault((UnlockRequirement r) => r.Name == selectedBuyer.DisplayName && r.MinRep > selectedBuyer.DealerSaveData.Reputation); text += $"• {item.DisplayName}: Requires Rep {unlockRequirement?.MinRep}\n"; } } text = text + "\n\n<b>Deliver after curfew only:</b> " + (selectedBuyer.CurfewDeal ? "Yes" : "No") + "\n"; UIFactory.Text("DetailText", text, managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); break; } case "Product": text = selectedBuyer.GetDrugUnlockInfo(); UIFactory.Text("ProductDetailText", text, managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); break; case "Shipping": { int currentTier = selectedBuyer.DealerSaveData.ShippingTier; string text4 = ""; string text5 = ""; double value = 0.0; if (selectedBuyer.RepLogBase > 1f) { value = Math.Log((double)selectedBuyer.DealerSaveData.Reputation + 1.0, selectedBuyer.RepLogBase); value = ((!(value < 4.0)) ? (value - 4.0) : 0.0); } value = Math.Round(value, 2); if (selectedBuyer.Shippings != null && currentTier < selectedBuyer.Shippings.Count) { Shipping shipping = selectedBuyer.Shippings[currentTier]; text4 = $"<b><color=#FF6347>Current Tier ({currentTier})</color></b>\n" + " • <i>Name:</i> <color=#FFFFFF>" + shipping.Name + "</color>\n" + $" • <i>Cost:</i> <color=#00FFFF>{shipping.Cost}</color>\n" + $" • <i>Unlock Rep:</i> <color=#00FF00>{shipping.UnlockRep}</color>\n" + $" • <i>Amounts:</i> <color=#FFFF00>{shipping.MinAmount} - {shipping.MaxAmount}</color>\n" + $" • <i>Package:</i> <color=#FFFF00>{shipping.StepAmount}</color>\n" + $" • <i>Rep Multiple Bonus:</i> <color=#FFFF00>x {value}</color>\n" + " • <i>Deal Modifier:</i> <color=#FFA500>" + string.Join(", ", shipping.DealModifier) + "</color>\n"; } else { text4 = "<b><color=#FF6347>Current shipping info not available.</color></b>"; } if (selectedBuyer.Shippings != null && currentTier + 1 < selectedBuyer.Shippings.Count) { Shipping shipping2 = selectedBuyer.Shippings[currentTier + 1]; text5 = $"<b><color=#FF6347>Next Tier ({currentTier + 1})</color></b>\n" + " • <i>Name:</i> <color=#FFFFFF>" + shipping2.Name + "</color>\n" + $" • <i>Cost:</i> <color=#00FFFF>{shipping2.Cost}</color>\n" + $" • <i>Unlock Rep:</i> <color=#00FF00>{shipping2.UnlockRep}</color>\n" + $" • <i>Amounts:</i> <color=#FFFF00>{shipping2.MinAmount} - {shipping2.MaxAmount}</color>\n" + $" • <i>Package:</i> <color=#FFFF00>{shipping2.StepAmount}</color>\n" + $" • <i>Rep Multiple Bonus:</i> <color=#FFFF00>x {value}</color>\n" + " • <i>Deal Modifier:</i> <color=#FFA500>" + string.Join(", ", shipping2.DealModifier) + "</color>\n"; } else { text5 = "<b><color=#FF6347>Next Tier:</color></b> <color=#FFFFFF>Maximum tier unlocked.</color>"; } text = text4 + "\n" + text5; UIFactory.Text("ShippingDetailText", text, managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); if (selectedBuyer.Shippings == null || currentTier + 1 >= selectedBuyer.Shippings.Count) { break; } (GameObject, Button, Text) tuple5 = UIFactory.RoundedButtonWithLabel("UpgradeShippingButton", "Upgrade Shipping", managementDetailPanel.transform, Color32.op_Implicit(new Color32((byte)0, (byte)123, byte.MaxValue, byte.MaxValue)), 160f, 42f, 16, Color.white); ButtonUtils.ClearListeners(tuple5.Item2); ButtonUtils.AddListener(tuple5.Item2, (Action)delegate { Shipping shipping3 = selectedBuyer.Shippings[currentTier + 1]; int cost = shipping3.Cost; if (Money.GetCashBalance() < (float)cost) { Text message = UIFactory.Text("UpgradeErrorText", "<color=#FF0000>Not enough cash (cost: " + cost + ").</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message)); } else if (selectedBuyer.DealerSaveData.Reputation < shipping3.UnlockRep) { Text message2 = UIFactory.Text("UpgradeErrorText", "<color=#FF0000>Not enough reputation (required: " + shipping3.UnlockRep + ").</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message2)); } else if (selectedBuyer.UpgradeShipping()) { ConsoleHelper.RunCashCommand(-cost); UpdateBuyerDetails("Shipping"); } else { Text message3 = UIFactory.Text("UpgradeErrorText", "<color=#FF0000>Maximum tier reached.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message3)); } }); break; } case "Gifts": { EmpireNPC capturedBuyer = selectedBuyer; UIFactory.Text("SpecialDetailText", $"<b>Special Gift</b>\nCost: ${capturedBuyer.Gift.Cost}\nReputation Gain: {capturedBuyer.Gift.Rep}", managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); (GameObject, Button, Text) tuple3 = UIFactory.RoundedButtonWithLabel("GiftButton", "Give Gift", managementDetailPanel.transform, Color32.op_Implicit(new Color32((byte)0, (byte)123, byte.MaxValue, byte.MaxValue)), 460f, 60f, 22, Color.white); ButtonUtils.ClearListeners(tuple3.Item2); ButtonUtils.AddListener(tuple3.Item2, (Action)delegate { int cost2 = capturedBuyer.Gift.Cost; if (Money.GetCashBalance() < (float)cost2) { Text message8 = UIFactory.Text("SpecialErrorText", "<color=#FF0000>Not enough cash for gift.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message8)); } else { ConsoleHelper.RunCashCommand(-cost2); capturedBuyer.GiveReputation(capturedBuyer.Gift.Rep); Text message9 = UIFactory.Text("SpecialSuccessText", $"Gift given! Reputation increased by {capturedBuyer.Gift.Rep}.", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message9)); Contacts.Update(); if (Contacts.Buyers.TryGetValue(capturedBuyer.DisplayName, out EmpireNPC value2) && value2.IsInitialized) { selectedBuyer = value2; } else { selectedBuyer = capturedBuyer; } UpdateBuyerDetails("Gifts"); } }); RewardManager rewardManager = capturedBuyer.RewardManager; string rewardType = rewardManager.GetRewardType(); rewardType = ((capturedBuyer.Reward?.Args == null || capturedBuyer.Reward.Args.Count <= 0) ? "No reward available" : (rewardType + " - " + string.Join(" ", capturedBuyer.Reward.Args) + " - Reward will be given after 10 secs")); UIFactory.Text("RewardTypeText", "Reward Type: " + rewardType, managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); (GameObject, Button, Text) tuple4 = UIFactory.RoundedButtonWithLabel("RewardButton", "Claim Reward", managementDetailPanel.transform, Color32.op_Implicit(new Color32((byte)0, (byte)123, byte.MaxValue, byte.MaxValue)), 460f, 60f, 22, Color.white); ButtonUtils.ClearListeners(tuple4.Item2); ButtonUtils.AddListener(tuple4.Item2, (Action)delegate { if (!rewardManager.isRewardAvailable) { Text message4 = UIFactory.Text("RewardResultText", "<color=#FF0000>Reward not available today.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message4)); } else if (string.IsNullOrEmpty(rewardManager.GetRewardType())) { Text message5 = UIFactory.Text("RewardResultText", "<color=#FF0000>No reward available from this contact.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message5)); } else { DealerReward reward = capturedBuyer.Reward; if (reward != null && reward.unlockRep > 0 && capturedBuyer.DealerSaveData.Reputation < capturedBuyer.Reward.unlockRep) { Text message6 = UIFactory.Text("RewardResultText", $"<color=#FF0000>Insufficient reputation. Required: {capturedBuyer.Reward.unlockRep}</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message6)); } else { rewardManager.GiveReward(); Text message7 = UIFactory.Text("RewardResultText", "<color=#00FF00>Reward will be given in 10 secs!</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message7)); Contacts.Update(); UpdateBuyerDetails("Gifts"); } } }); break; } case "Debt": { if (selectedBuyer.Debt == null || selectedBuyer.DealerSaveData.DebtRemaining <= 0f) { UIFactory.Text("NoDebtText", "No outstanding debt with this contact.", managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); break; } int elapsedDays = TimeManager.ElapsedDays; int num2 = (int)Math.Ceiling((double)(elapsedDays + 1) / 7.0) * 7; float num3 = selectedBuyer.Debt.DayMultiple * (float)Math.Pow(num2, selectedBuyer.Debt.DayExponent); num3 -= selectedBuyer.DealerSaveData.DebtPaidThisWeek; if (num3 < 0f) { num3 = 0f; } num3 = Mathf.Min(num3, selectedBuyer.DealerSaveData.DebtRemaining); string text2 = $"<b><color=#FF6347>Total Debt:</color></b> <color=#FFFFFF>${selectedBuyer.DealerSaveData.DebtRemaining:N0}</color>\n" + $"<b><color=#FFA500>Next Weekly Payment:</color></b> <color=#FFFFFF>${num3:N0}</color>\n" + $"<b><color=#FFA500>Interest Rate:</color></b> <color=#FFFFFF>{selectedBuyer.Debt.InterestRate:P1}</color>\n" + $"<b><color=#00FF00>Paid This Week:</color></b> <color=#FFFFFF>${selectedBuyer.DealerSaveData.DebtPaidThisWeek:N0}</color>"; UIFactory.Text("DebtInfoText", text2, managementDetailPanel.transform, 18, (TextAnchor)0, (FontStyle)0); EmpireNPC debtBuyer = selectedBuyer; int num4 = (int)Mathf.Max(1000f, debtBuyer.DealerSaveData.DebtRemaining * 0.1f); num4 = (int)Mathf.Floor(Mathf.Min((float)num4, debtBuyer.DealerSaveData.DebtRemaining)); (GameObject, Button, Text) tuple = UIFactory.RoundedButtonWithLabel("PayDebtButton", $"Pay ${num4:N0}", managementDetailPanel.transform, Color32.op_Implicit(new Color32((byte)0, (byte)123, byte.MaxValue, byte.MaxValue)), 220f, 42f, 22, Color.white); ButtonUtils.ClearListeners(tuple.Item2); ButtonUtils.AddListener(tuple.Item2, (Action)delegate { int num7 = (int)Mathf.Max(1000f, debtBuyer.DealerSaveData.DebtRemaining * 0.1f); num7 = (int)Mathf.Floor(Mathf.Min((float)num7, debtBuyer.DealerSaveData.DebtRemaining)); if (Money.GetCashBalance() < (float)num7) { Text message13 = UIFactory.Text("DebtErrorText", "<color=#FF0000>Not enough cash to make payment.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message13)); } else { ConsoleHelper.RunCashCommand(-num7); debtBuyer.DealerSaveData.DebtRemaining = (int)(debtBuyer.DealerSaveData.DebtRemaining - (float)num7); debtBuyer.DealerSaveData.DebtPaidThisWeek = (int)(debtBuyer.DealerSaveData.DebtPaidThisWeek + (float)num7); Text message14 = UIFactory.Text("DebtSuccessText", $"<color=#00FF00>Paid ${num7:N0}.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message14)); Contacts.Update(); if (Contacts.Buyers.TryGetValue(debtBuyer.DisplayName, out EmpireNPC value4) && value4.IsInitialized) { selectedBuyer = value4; } else { selectedBuyer = debtBuyer; } debtBuyer.DebtManager.SendDebtMessage(num7, "payment"); debtBuyer.DebtManager.CheckIfPaidThisWeek(); UpdateBuyerDetails("Debt"); } }); (GameObject, Button, Text) tuple2 = UIFactory.RoundedButtonWithLabel("PayThousandButton", "Pay $1,000", managementDetailPanel.transform, Color32.op_Implicit(new Color32((byte)0, (byte)123, byte.MaxValue, byte.MaxValue)), 220f, 42f, 22, Color.white); ButtonUtils.ClearListeners(tuple2.Item2); ButtonUtils.AddListener(tuple2.Item2, (Action)delegate { int num5 = 1000; int num6 = (int)Mathf.Floor(Mathf.Min((float)num5, debtBuyer.DealerSaveData.DebtRemaining)); if (num6 <= 0) { Text message10 = UIFactory.Text("DebtZeroText", "<color=#FFFF00>No debt remaining to pay.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message10)); UpdateBuyerDetails("Debt"); } else if (Money.GetCashBalance() < (float)num6) { Text message11 = UIFactory.Text("DebtThousandErrorText", "<color=#FF0000>Not enough cash to pay $1,000.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message11)); } else { ConsoleHelper.RunCashCommand(-num6); debtBuyer.DealerSaveData.DebtRemaining = (int)(debtBuyer.DealerSaveData.DebtRemaining - (float)num6); debtBuyer.DealerSaveData.DebtPaidThisWeek = (int)(debtBuyer.DealerSaveData.DebtPaidThisWeek + (float)num6); Text message12 = UIFactory.Text("DebtThousandSuccessText", $"<color=#00FF00>Paid ${num6:N0}.</color>", GetMessageParent(), 18, (TextAnchor)0, (FontStyle)0); MelonCoroutines.Start(BlinkMessage(message12)); Contacts.Update(); if (Contacts.Buyers.TryGetValue(debtBuyer.DisplayName, out EmpireNPC value3) && value3.IsInitialized) { selectedBuyer = value3; } else { selectedBuyer = debtBuyer; } debtBuyer.DebtManager.SendDebtMessage(num6, "payment"); debtBuyer.DebtManager.CheckIfPaidThisWeek(); UpdateBuyerDetails("Debt"); } }); break; } } if ((Object)(object)managementTabLabel != (Object)null) { managementTabLabel.text = tab; } if ((Object)(object)buyerListContainer != (Object)null) { PopulateBuyerList(buyerListContainer); } } [IteratorStateMachine(typeof(<BlinkMessage>d_