Decompiled source of SCT BuildUpgrade Drill v1.1.2
plugins/SCTBuildUpgrade.Drill.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.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.Json; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using SCTCommon; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Localization; using UnityEngine.Localization.Settings; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("SCTBuildUpgrade.Drill")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SCTBuildUpgrade.Drill")] [assembly: AssemblyTitle("SCTBuildUpgrade.Drill")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SCTCommon { internal static class Il2CppUtil { public static bool IsPlayer(Driller driller) { if (driller != null) { return (Object)(object)((Il2CppObjectBase)driller).TryCast<Player>() != (Object)null; } return false; } public static string Guid(BasePlugin plugin) { return MetadataHelper.GetMetadata((object)plugin).GUID; } public static IEnumerable<PluginInfo> Plugins() { if (IL2CPPChainloader.Instance == null) { yield break; } foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values) { yield return value; } } } internal static class Safe { private static readonly ManualLogSource Log = Logger.CreateLogSource("SCT Safe"); private static readonly HashSet<string> Reported = new HashSet<string>(); public static void Run(string where, Action action) { try { action(); } catch (Exception e) { Report(where, e); } } public static bool Prefix(string where, Func<bool> prefix) { try { return prefix(); } catch (Exception e) { Report(where, e); return true; } } private static void Report(string where, Exception e) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (Reported.Add(where + e.GetType().Name + e.Message)) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(where); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (ignoré, le jeu continue)\n"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace); } Log.LogError(val); } } } internal static class Vanilla { private const string Key = "sct.vanilla"; public static bool Active { get { object data = AppDomain.CurrentDomain.GetData("sct.vanilla"); bool flag = default(bool); int num; if (data is bool) { flag = (bool)data; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } } public static void Set(bool active) { AppDomain.CurrentDomain.SetData("sct.vanilla", active); } } internal static class Lang { public static bool IsFrench { get { try { Locale selectedLocale = LocalizationSettings.SelectedLocale; return ((selectedLocale != null) ? selectedLocale.Identifier.Code : null)?.StartsWith("fr", StringComparison.OrdinalIgnoreCase) ?? false; } catch (Exception) { return false; } } } public static string Pick(string fr, string en) { if (!IsFrench) { return en; } return fr; } } internal static class SaveSlotApi { private const string VersionKey = "sct.saveslot.version"; public const string Prefix = "sct_"; public static string Directory => GameInstance.SaveDirectory; public static int Version { get { object data = AppDomain.CurrentDomain.GetData("sct.saveslot.version"); if (data is int) { return (int)data; } return 0; } } public static string PathOf(string name) { return Path.Combine(Directory, "sct_" + name); } public static void BumpVersion() { AppDomain.CurrentDomain.SetData("sct.saveslot.version", Version + 1); } public static void Migrate(string oldPath, string name) { try { string text = PathOf(name); if (File.Exists(oldPath) && !File.Exists(text)) { File.Move(oldPath, text); } } catch (Exception) { } } } internal static class GameInstance { private const string IndexKey = "sct.instance.index"; private const string MutexKey = "sct.instance.mutex"; private const string ErrorKey = "sct.instance.error"; private const string MutexName = "SCT_SpaceCatDigger_Instance_"; public const int Max = 4; public static int Index { get { object data = AppDomain.CurrentDomain.GetData("sct.instance.index"); if (data is int) { return (int)data; } int i = 0; Mutex data2 = null; for (; i < 4; i++) { bool createdNew; Mutex mutex = new Mutex(initiallyOwned: false, "SCT_SpaceCatDigger_Instance_" + i, out createdNew); if (createdNew) { data2 = mutex; break; } mutex.Dispose(); } AppDomain.CurrentDomain.SetData("sct.instance.mutex", data2); AppDomain.CurrentDomain.SetData("sct.instance.index", i); if (i > 0) { PrepareTestSaves(i); } return i; } } public static bool IsTest => Index > 0; public static string Suffix { get { if (!IsTest) { return ""; } return "_test" + (Index + 1); } } public static string SaveDirectory => DirectoryOf(Index); public static string Error => AppDomain.CurrentDomain.GetData("sct.instance.error") as string; private static string DirectoryOf(int index) { if (index <= 0) { return Application.persistentDataPath; } return Path.Combine(Application.persistentDataPath, "coop_test_" + (index + 1)); } public static int OthersRunning() { int index = Index; int num = 0; for (int i = 0; i < 4; i++) { if (i != index && Mutex.TryOpenExisting("SCT_SpaceCatDigger_Instance_" + i, out Mutex result)) { result.Dispose(); num++; } } return num; } private static void PrepareTestSaves(int index) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown ManualLogSource val = Logger.CreateLogSource("SCT Instance"); bool flag = default(bool); try { string persistentDataPath = Application.persistentDataPath; string text = DirectoryOf(index); Directory.CreateDirectory(text); string[] files = Directory.GetFiles(text); for (int i = 0; i < files.Length; i++) { File.Delete(files[i]); } files = Directory.GetFiles(persistentDataPath); foreach (string text2 in files) { string fileName = Path.GetFileName(text2); if (fileName == "persistent.save" || fileName.StartsWith("sct_", StringComparison.Ordinal)) { File.Copy(text2, Path.Combine(text, fileName), overwrite: true); } } string text3 = text + "/game.save"; string text4 = text + "/persistent.save"; SaveSystem.GameFileName = text3; SaveSystem.PersistentFileName = text4; if (SaveSystem.GameFileName != text3 || SaveSystem.PersistentFileName != text4) { throw new InvalidOperationException("chemins de sauvegarde du jeu non modifiables"); } BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(58, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Exemplaire n° "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(index + 1); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" du jeu sur ce PC : sauvegarde de test dans "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); } val.LogInfo(val2); } catch (Exception ex) { AppDomain.CurrentDomain.SetData("sct.instance.error", ex.Message); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(97, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Exemplaire n° "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(index + 1); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" : sauvegarde de test impossible ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("). CET EXEMPLAIRE ÉCRIT DANS LA VRAIE SAUVEGARDE."); } val.LogError(val3); } } } internal enum ColorVision { Normal, Protanopia, Deuteranopia, Tritanopia } internal static class Palette { public const string VisionKey = "sct.colorblind.vision"; public const string RedundantKey = "sct.colorblind.redundant"; private static readonly Color Black = C(0); private static readonly Color Orange = C(15113984); private static readonly Color SkyBlue = C(5682409); private static readonly Color Green = C(40563); private static readonly Color Yellow = C(15787074); private static readonly Color Blue = C(29362); private static readonly Color Vermillion = C(13983232); private static readonly Color Purple = C(13400487); private static readonly Color White = C(16777215); private static readonly Color Grey = C(7237230); public static ColorVision Vision { get { object data = AppDomain.CurrentDomain.GetData("sct.colorblind.vision"); if (data is int) { return (ColorVision)(int)data; } return ColorVision.Normal; } } public static bool Adapted => Vision != ColorVision.Normal; public static bool Redundant { get { if (Adapted) { object data = AppDomain.CurrentDomain.GetData("sct.colorblind.redundant"); bool flag = default(bool); int num; if (data is bool) { flag = (bool)data; num = 1; } else { num = 0; } return num == 0 || flag; } return false; } } private static bool RedGreen { get { if (Vision != ColorVision.Protanopia) { return Vision == ColorVision.Deuteranopia; } return true; } } public static Color Good(Color usual) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (Adapted) { if (!RedGreen) { return Green; } return SkyBlue; } return usual; } public static Color Bad(Color usual) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (Adapted) { return Vermillion; } return usual; } public static Color Warning(Color usual) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (Adapted) { if (!RedGreen) { return Orange; } return Yellow; } return usual; } public static Color Danger(Color usual) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (Adapted) { if (!RedGreen) { return C(16719904); } return Vermillion; } return usual; } public static Color Accent(Color usual) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (Adapted) { if (!RedGreen) { return Purple; } return SkyBlue; } return usual; } public static string GoodHex(string usual = "80ff80") { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Adapted) { return usual; } return Hex(Good(White)); } public static string BadHex(string usual = "ff8080") { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Adapted) { return usual; } return Hex(Bad(White)); } public static string WarningHex(string usual = "ffcc66") { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Adapted) { return usual; } return Hex(Warning(White)); } public static Color Ore(ResourceType type, Color usual) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected I4, but got Unknown //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (!Adapted) { return usual; } bool flag = Vision == ColorVision.Tritanopia; switch (type - 2) { case 9: return Grey; case 0: if (!flag) { return Blue; } return Vermillion; case 2: return Orange; case 4: return White; case 6: if (!flag) { return Yellow; } return C(16756912); case 8: return SkyBlue; case 10: if (!flag) { return Purple; } return Blue; case 11: if (!flag) { return Green; } return C(8323072); case 12: if (!flag) { return Vermillion; } return Black; default: return usual; } } public static Color Tier(int level, Color usual) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!Adapted || level <= 0) { return usual; } Color[] array = (Color[])(object)((Vision != ColorVision.Tritanopia) ? new Color[4] { Blue, Orange, White, Yellow } : new Color[4] { SkyBlue, Vermillion, White, Purple }); return array[Mathf.Clamp(level, 1, array.Length) - 1]; } public static Color Marker(int index, Color usual) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!Adapted) { return usual; } Color[] array = (Color[])(object)((Vision != ColorVision.Tritanopia) ? new Color[5] { Yellow, SkyBlue, Orange, White, Purple } : new Color[5] { Vermillion, White, SkyBlue, C(16756912), Green }); return array[Math.Abs(index) % array.Length]; } public static float Blink(float speed = 3f) { if (!Redundant) { return 1f; } return 0.45f + 0.55f * Mathf.Abs(Mathf.Sin(Time.unscaledTime * speed)); } public static string Hex(Color c) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) return $"{Mathf.RoundToInt(Mathf.Clamp01(c.r) * 255f):X2}{Mathf.RoundToInt(Mathf.Clamp01(c.g) * 255f):X2}{Mathf.RoundToInt(Mathf.Clamp01(c.b) * 255f):X2}"; } private static Color C(int rgb) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f); } } internal static class CraftCosts { private const string OwnerKey = "sct.craft.owner"; private const string ProvidersKey = "sct.craft.providers"; private const float MinFactor = 0.25f; private const int MaxBuildId = 512; private static readonly Dictionary<int, int[]> Originals = new Dictionary<int, int[]>(); private static float _appliedFactor = 1f; private static bool _isOwner; public static float Factor { get { float num = 1f; if (AppDomain.CurrentDomain.GetData("sct.craft.providers") is Dictionary<string, Func<float>> dictionary) { foreach (Func<float> value in dictionary.Values) { try { num *= 1f - Mathf.Clamp(value(), 0f, 0.9f); } catch (Exception) { } } } return Mathf.Max(0.25f, num); } } public static void RegisterDiscount(string id, Func<float> discount) { lock (AppDomain.CurrentDomain) { Dictionary<string, Func<float>> dictionary = (AppDomain.CurrentDomain.GetData("sct.craft.providers") as Dictionary<string, Func<float>>) ?? new Dictionary<string, Func<float>>(); dictionary[id] = discount; AppDomain.CurrentDomain.SetData("sct.craft.providers", dictionary); } } public static void Install(Harmony harmony, string owner) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown lock (AppDomain.CurrentDomain) { if (AppDomain.CurrentDomain.GetData("sct.craft.owner") != null) { return; } AppDomain.CurrentDomain.SetData("sct.craft.owner", owner); _isOwner = true; } HarmonyMethod val = new HarmonyMethod(typeof(CraftCosts), "SyncPrefix", (Type[])null); string[] array = new string[3] { "Open", "RefreshCostItems", "TryPurchase" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.Method(typeof(CraftMenu), text, (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void SyncPrefix() { Safe.Run("Coûts de craft", Sync); } public static void Sync() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!_isOwner) { return; } Dictionary<BuildType, List<ResourceTypeQuantity>> craftingCosts = CraftMenu._craftingCosts; if (craftingCosts == null) { return; } float factor = Factor; bool flag = !Mathf.Approximately(factor, _appliedFactor); for (int i = 0; i < 512; i++) { BuildType val = (BuildType)i; if (!craftingCosts.ContainsKey(val)) { continue; } List<ResourceTypeQuantity> val2 = craftingCosts[val]; if (!Originals.TryGetValue(i, out var value) || value.Length != val2.Count) { value = new int[val2.Count]; for (int j = 0; j < val2.Count; j++) { value[j] = val2[j].quantity; } Originals[i] = value; flag = true; } if (flag) { for (int k = 0; k < val2.Count; k++) { ResourceTypeQuantity val3 = val2[k]; val3.quantity = ((factor >= 1f) ? value[k] : Mathf.Max(1, Mathf.CeilToInt((float)value[k] * factor))); val2[k] = val3; } } } _appliedFactor = factor; } public static void AddRecipe(BuildType type, params (ResourceType Resource, int Quantity)[] ingredients) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Dictionary<BuildType, List<ResourceTypeQuantity>> craftingCosts = CraftMenu._craftingCosts; List<ResourceTypeQuantity> val = new List<ResourceTypeQuantity>(); for (int i = 0; i < ingredients.Length; i++) { var (resourceType, quantity) = ingredients[i]; val.Add(new ResourceTypeQuantity { resourceType = resourceType, quantity = quantity }); } craftingCosts[type] = val; } } internal static class RefundBonus { private const string ProvidersKey = "sct.refund.providers"; private const string ActiveKey = "sct.refund.active"; public static bool SalvageActive { get { if (!(AppDomain.CurrentDomain.GetData("sct.refund.active") is Dictionary<string, Func<bool>> dictionary)) { return false; } foreach (Func<bool> value in dictionary.Values) { try { if (value()) { return true; } } catch (Exception) { } } return false; } } public static float Total { get { float num = 0f; if (AppDomain.CurrentDomain.GetData("sct.refund.providers") is Dictionary<string, Func<float>> dictionary) { foreach (Func<float> value in dictionary.Values) { try { num += Mathf.Max(0f, value()); } catch (Exception) { } } } return num; } } public static void Register(string id, Func<float> bonus, Func<bool> active) { lock (AppDomain.CurrentDomain) { Dictionary<string, Func<float>> dictionary = (AppDomain.CurrentDomain.GetData("sct.refund.providers") as Dictionary<string, Func<float>>) ?? new Dictionary<string, Func<float>>(); dictionary[id] = bonus; AppDomain.CurrentDomain.SetData("sct.refund.providers", dictionary); Dictionary<string, Func<bool>> dictionary2 = (AppDomain.CurrentDomain.GetData("sct.refund.active") as Dictionary<string, Func<bool>>) ?? new Dictionary<string, Func<bool>>(); dictionary2[id] = active; AppDomain.CurrentDomain.SetData("sct.refund.active", dictionary2); } } } internal static class SctGui { public const float LineHeight = 22f; public const float Gap = 4f; public static bool Themed = true; public const string TextHex = "EEF1F6"; public const string MutedHex = "AEB8C8"; private static readonly Dictionary<string, GUIStyle> ThemeStyles = new Dictionary<string, GUIStyle>(); private static readonly ManualLogSource Log = Logger.CreateLogSource("SctGui"); private static readonly HashSet<string> Reported = new HashSet<string>(); private static bool _useBroken; private static readonly HashSet<int> ClickLogged = new HashSet<int>(); private static GUIStyle _button; private static GUIStyle _buttonHover; private static GUIStyle _buttonOn; private static GUIStyle _check; private static GUIStyle _label; private static GUIStyle _richBox; private static GUIStyle _buttonToggle; public static float Row { get { if (!Themed) { return 22f; } return 26f; } } public static float TitleHeight { get { if (!Themed) { return 20f; } return 30f; } } public static float Chrome { get { if (!Themed) { return 36f; } return 44f; } } private static Color TextColor => C(15659510); private static Color AccentColor => C(3105992); private static GUIStyle Panel => Solid("panel", C(1448482, 0.97f), 14, (TextAnchor)0, 10); private static GUIStyle Border => Solid("border", C(3950432), 14, (TextAnchor)3); private static GUIStyle TitleBar => Solid("title", C(2304568), 15, (TextAnchor)3, 10); private static GUIStyle Section => Solid("section", C(2041137), 14, (TextAnchor)3); private static GUIStyle Field => Solid("field", C(856086), 14, (TextAnchor)3, 6); private static GUIStyle Accent => Solid("accent", AccentColor, 14, (TextAnchor)3); private static GUIStyle Mark => Solid("mark", TextColor, 14, (TextAnchor)3); public static GUIStyle ScrollThumb { get { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!Themed) { return GUI.skin.box; } return Solid("thumb", C(5924480), 14, (TextAnchor)3); } } public static GUIStyle Label { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (_label == null) { GUIStyle label = GUI.skin.label; _label = new GUIStyle { richText = true, wordWrap = false, alignment = (TextAnchor)3, fontSize = (Themed ? 14 : label.fontSize), padding = label.padding }; _label.normal.textColor = (Themed ? TextColor : label.normal.textColor); } return _label; } } public static GUIStyle ButtonToggle => _buttonToggle ?? (_buttonToggle = GUI.skin.button); public static GUIStyle RichBox => _richBox ?? (_richBox = BoxStyle(13, (TextAnchor)0)); private static Color C(int rgb, float a = 1f) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, a); } private static GUIStyle Solid(string key, Color background, int fontSize = 14, TextAnchor alignment = (TextAnchor)3, int padding = 0, int vertical = -1) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00c7: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (ThemeStyles.TryGetValue(key, out var value) && (Object)(object)value.normal.background != (Object)null) { return value; } Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; val.SetPixels(Il2CppStructArray<Color>.op_Implicit((Color[])(object)new Color[1] { background })); val.Apply(false); ((Object)val).hideFlags = (HideFlags)61; if (vertical < 0) { vertical = padding; } RectOffset padding2 = new RectOffset { left = padding, right = padding, top = vertical, bottom = vertical }; GUIStyle val2 = new GUIStyle { alignment = alignment, richText = true, fontSize = fontSize, wordWrap = false, padding = padding2, border = new RectOffset() }; val2.normal.background = val; val2.normal.textColor = TextColor; ThemeStyles[key] = val2; return val2; } private static GUIStyle ButtonStyle(bool on, bool hover) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!on) { if (!hover) { return Solid("btn", C(2896966), 14, (TextAnchor)4, 4); } return Solid("btn.hover", C(3818848), 14, (TextAnchor)4, 4); } return Solid("btn.on", AccentColor, 14, (TextAnchor)4, 4); } public static void DrawFrame(Rect r, bool accent = false) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = (accent ? Accent : Border); GUI.Box(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 1f), "", val); GUI.Box(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height - 1f, ((Rect)(ref r)).width, 1f), "", val); GUI.Box(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, 1f, ((Rect)(ref r)).height), "", val); GUI.Box(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 1f, ((Rect)(ref r)).y, 1f, ((Rect)(ref r)).height), "", val); } public static void DrawWindowChrome(Rect local, string title) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) GUI.Box(local, "", Panel); GUI.Box(new Rect(((Rect)(ref local)).x, ((Rect)(ref local)).y, ((Rect)(ref local)).width, TitleHeight), "<b>" + title + "</b>", TitleBar); GUI.Box(new Rect(((Rect)(ref local)).x, ((Rect)(ref local)).y + TitleHeight, ((Rect)(ref local)).width, 2f), "", Accent); DrawFrame(local); } public static void DrawSection(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) GUI.Box(r, "", Section); DrawFrame(r); } public static void DrawField(Rect r, bool focused) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) GUI.Box(r, "", Field); DrawFrame(r, focused); } public static bool Contains(Rect r, Vector2 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (p.x >= ((Rect)(ref r)).x && p.x < ((Rect)(ref r)).x + ((Rect)(ref r)).width && p.y >= ((Rect)(ref r)).y) { return p.y < ((Rect)(ref r)).y + ((Rect)(ref r)).height; } return false; } public static void Use(Event e) { if (_useBroken) { return; } try { e.Use(); } catch (Exception e2) { _useBroken = true; Report("Event.Use", e2); } } public static void NoteClick(int owner, Vector2 position) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (ClickLogged.Add(owner)) { bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(36, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Fenêtre "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" : premier clic reçu en ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(position.x, "0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(position.y, "0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } Log.LogInfo(val); } } private static GUIStyle CopyState(GUIStyle source, GUIStyleState state, TextAnchor alignment) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown GUIStyle val = new GUIStyle { alignment = alignment, richText = true, fontSize = source.fontSize, border = source.border, padding = source.padding, wordWrap = false }; val.normal.background = state.background; val.normal.textColor = state.textColor; return val; } public static void DrawButton(Rect rect, string text, bool on) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) if (Themed) { bool flag = GUI.enabled && Event.current != null && Contains(rect, Event.current.mousePosition); Color color = GUI.color; if (!GUI.enabled) { GUI.color = color * new Color(1f, 1f, 1f, 0.4f); } GUI.Box(rect, text, ButtonStyle(on, flag)); if (on) { GUI.Box(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 4f, ((Rect)(ref rect)).height), "", Mark); } DrawFrame(rect, flag && !on); GUI.color = color; return; } if (_button == null) { GUIStyle button = GUI.skin.button; _button = CopyState(button, button.normal, (TextAnchor)4); _buttonHover = CopyState(button, ((Object)(object)button.hover.background != (Object)null) ? button.hover : button.normal, (TextAnchor)4); _buttonOn = CopyState(button, ((Object)(object)button.onNormal.background != (Object)null) ? button.onNormal : button.active, (TextAnchor)4); } bool flag2 = GUI.enabled && Event.current != null && Contains(rect, Event.current.mousePosition); Color color2 = GUI.color; if (on) { GUI.color = color2 * new Color(0.65f, 0.9f, 1f, 1f); } else if (!GUI.enabled) { GUI.color = color2 * new Color(1f, 1f, 1f, 0.5f); } GUI.Box(rect, text, on ? _buttonOn : (flag2 ? _buttonHover : _button)); GUI.color = color2; } public static void DrawCheck(Rect rect, string text, bool on) { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (Themed) { bool focused = GUI.enabled && Event.current != null && Contains(rect, Event.current.mousePosition); Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - 18f) / 2f, 18f, 18f); DrawField(r, focused); if (on) { GUI.Box(new Rect(((Rect)(ref r)).x + 4f, ((Rect)(ref r)).y + 4f, 10f, 10f), "", Mark); } GUI.Label(new Rect(((Rect)(ref rect)).x + 26f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 26f, ((Rect)(ref rect)).height), text, Label); } else { if (_check == null) { _check = CopyState(GUI.skin.button, GUI.skin.button.normal, (TextAnchor)4); } GUI.Box(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - 16f) / 2f, 16f, 16f), on ? "x" : "", _check); GUI.Label(new Rect(((Rect)(ref rect)).x + 20f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 20f, ((Rect)(ref rect)).height), text, Label); } } public static void Report(string where, Exception e) { string text = where + ": " + e.GetType().Name + ": " + e.Message; if (Reported.Add(text)) { Log.LogWarning((object)(text + "\n" + e.StackTrace)); } } public static GUIStyle BoxStyle(int fontSize, TextAnchor alignment) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (Themed) { return Solid($"box.{fontSize}.{alignment}", C(1448482, 0.92f), fontSize, alignment, 10, ((int)alignment == 0) ? 8 : 2); } GUIStyle box = GUI.skin.box; GUIStyle val = new GUIStyle { alignment = alignment, richText = true, fontSize = fontSize, border = box.border, padding = box.padding, margin = box.margin, wordWrap = box.wordWrap }; val.normal.background = box.normal.background; val.normal.textColor = box.normal.textColor; return val; } public static GUIStyle TextureStyle(Texture2D texture) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown GUIStyle val = new GUIStyle { border = new RectOffset(), padding = new RectOffset(), margin = new RectOffset() }; val.normal.background = texture; return val; } public static void DrawTexture(Rect rect, GUIStyle textureStyle) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.Box(rect, "", textureStyle); } public static float TextHeight(string text) { return (float)Math.Max(1, text.Split('\n').Length) * (Themed ? 20f : 18f) + (Themed ? 6f : 4f); } } internal class SctWindow { private readonly int _id; private readonly Func<string> _title; private readonly Action<SctLayout> _content; private readonly WindowFunction _function; private readonly SctLayout _layout = new SctLayout(); private readonly bool _modal; public Rect Rect; private float _needed; public bool Draggable; public SctWindow(int id, Rect rect, Func<string> title, Action<SctLayout> content, bool modal = false) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) _id = id; Rect = rect; _title = title; _content = content; _modal = modal; _function = WindowFunction.op_Implicit((Action<int>)Draw); } public void OnGUI() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (_needed > ((Rect)(ref Rect)).height) { Rect = new Rect(((Rect)(ref Rect)).x, Math.Min(((Rect)(ref Rect)).y, Math.Max(0f, (float)Screen.height - _needed)), ((Rect)(ref Rect)).width, Math.Min(_needed, Screen.height)); } Rect = (_modal ? GUI.ModalWindow(_id, Rect, _function, _title()) : GUI.Window(_id, Rect, _function, _title())); } private void Draw(int id) { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) float num = (SctGui.Themed ? (SctGui.TitleHeight + 10f) : 22f); float num2 = (SctGui.Themed ? 12 : 8); try { if (SctGui.Themed) { SctGui.DrawWindowChrome(new Rect(0f, 0f, ((Rect)(ref Rect)).width, ((Rect)(ref Rect)).height), _title()); } _layout.Begin(new Rect(num2, num, ((Rect)(ref Rect)).width - 2f * num2, ((Rect)(ref Rect)).height - num - 6f), _id); _content(_layout); _layout.End(); _needed = _layout.Bottom + 4f; } catch (Exception ex) { SctGui.Report("Fenêtre " + _id, ex); GUI.Label(new Rect(num2, num, ((Rect)(ref Rect)).width - 2f * num2, 60f), "Erreur : " + ex.Message, SctGui.Label); } if (!_modal || Draggable) { GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref Rect)).width, SctGui.TitleHeight)); } } } internal class SctLayout { private struct Frame { public float X; public float Y; public float Width; public bool Horizontal; public float RowX; public float RowHeight; } private readonly Stack<Frame> _frames = new Stack<Frame>(); private Frame _f; private int _owner; private int _counter; private static string _activeSlider; private static string _focusedField; private static readonly Dictionary<string, float> ScrollOffsets = new Dictionary<string, float>(); private static readonly Dictionary<string, float> ContentHeights = new Dictionary<string, float>(); private static readonly Dictionary<string, float> BoxHeights = new Dictionary<string, float>(); private readonly Stack<float> _columnTops = new Stack<float>(); private readonly Stack<(string Key, float Top)> _boxKeys = new Stack<(string, float)>(); private readonly Stack<(string Key, float Height)> _scrollKeys = new Stack<(string, float)>(); public float Bottom => _f.Y; public float Width { get { if (!_f.Horizontal) { return _f.Width; } return _f.Width - (_f.RowX - _f.X); } } public static bool IsTyping => _focusedField != null; public void Begin(Rect area, int owner = 0) { _frames.Clear(); _owner = owner; _counter = 0; _f = new Frame { X = ((Rect)(ref area)).x, Y = ((Rect)(ref area)).y, Width = ((Rect)(ref area)).width }; } public void End() { if (_f.Horizontal) { EndHorizontal(); } } private string NextKey() { return _owner + ":" + _counter++; } private Rect Next(float width, float height) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (_f.Horizontal) { float num = ((width < 0f) ? (_f.Width - (_f.RowX - _f.X)) : width); Rect result = new Rect(_f.RowX, _f.Y, num, height); _f.RowX += num + 4f; _f.RowHeight = Math.Max(_f.RowHeight, height); return result; } Rect result2 = new Rect(_f.X, _f.Y, (width < 0f) ? _f.Width : width, height); _f.Y += height + 4f; return result2; } public void Space(float height = 8f) { if (_f.Horizontal) { _f.RowX += height; } else { _f.Y += height; } } public void BeginHorizontal() { _frames.Push(_f); _f.Horizontal = true; _f.RowX = _f.X; _f.RowHeight = 0f; } public void EndHorizontal() { float rowHeight = _f.RowHeight; _f = _frames.Pop(); _f.Y += rowHeight + 4f; } public void BeginColumn(float width = -1f) { float width2 = ((width < 0f) ? (_f.Width - (_f.RowX - _f.X)) : width); _frames.Push(_f); _columnTops.Push(_f.Y); _f = new Frame { X = _f.RowX, Y = _f.Y, Width = width2 }; } public void EndColumn() { float val = _f.Y - _columnTops.Pop(); float width = _f.Width; _f = _frames.Pop(); _f.RowX += width + 4f; _f.RowHeight = Math.Max(_f.RowHeight, val); } public void BeginBox() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) string text = NextKey(); BoxHeights.TryGetValue(text, out var value); float num = (SctGui.Themed ? 10 : 6); float num2 = (SctGui.Themed ? 8 : 4); if (value > 0f) { if (SctGui.Themed) { SctGui.DrawSection(new Rect(_f.X, _f.Y, _f.Width, value)); } else { GUI.Box(new Rect(_f.X, _f.Y, _f.Width, value), ""); } } _frames.Push(_f); _f.X += num; _f.Width -= 2f * num; _f.Y += num2; _boxKeys.Push((text, _f.Y - num2)); } public void EndBox() { (string Key, float Top) tuple = _boxKeys.Pop(); string item = tuple.Key; float item2 = tuple.Top; float num = _f.Y + (float)(SctGui.Themed ? 4 : 0); _f = _frames.Pop(); BoxHeights[item] = num - item2 + 2f; _f.Y = num + 2f + 4f; } public void Label(string text, float width = -1f) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) GUI.Label(Next(width, text.Contains("\n") ? SctGui.TextHeight(text) : SctGui.Row), text, SctGui.Label); } public void Header(string text, string hint = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) GUI.Label(Next(-1f, 28f), "<size=17><b>" + text + "</b></size>", SctGui.Label); if (hint != null) { Label($"<color=#{(SctGui.Themed ? "AEB8C8" : "999999")}>{hint}</color>"); } } private bool Clicked(Rect rect) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!GUI.enabled) { return false; } Event current = Event.current; if (current == null || (int)current.type != 0 || !SctGui.Contains(rect, current.mousePosition)) { return false; } SctGui.NoteClick(_owner, current.mousePosition); SctGui.Use(current); return true; } public Rect Area(float width, float height) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Next(width, height); } public bool AreaClick(Rect rect, out Vector2 local, out int button) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) local = Vector2.zero; button = -1; Event current = Event.current; if (!GUI.enabled || current == null || (int)current.type != 0 || !SctGui.Contains(rect, current.mousePosition)) { return false; } local = new Vector2(current.mousePosition.x - ((Rect)(ref rect)).x, current.mousePosition.y - ((Rect)(ref rect)).y); try { button = current.button; } catch (Exception) { button = 0; } SctGui.NoteClick(_owner, current.mousePosition); SctGui.Use(current); return true; } public bool Button(string text, float width = -1f, float height = 0f) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (height <= 0f) { height = SctGui.Row; } Rect rect = Next(width, height); bool result = Clicked(rect); SctGui.DrawButton(rect, text, on: false); return result; } public bool Toggle(bool value, string text, float width = -1f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Rect rect = Next(width, SctGui.Row); if (Clicked(rect)) { value = !value; } SctGui.DrawCheck(rect, text, value); return value; } public bool ToggleButton(bool value, string text, float width = -1f, float height = 0f) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (height <= 0f) { height = SctGui.Row; } Rect rect = Next(width, height); if (Clicked(rect)) { value = !value; } SctGui.DrawButton(rect, text, value); return value; } public int Toolbar(int selected, string[] labels, float width = -1f, float height = 0f) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (height <= 0f) { height = SctGui.Row; } float width2 = (((width < 0f) ? Width : width) - 4f * (float)(labels.Length - 1)) / (float)labels.Length; bool horizontal = _f.Horizontal; if (!horizontal) { BeginHorizontal(); } int num = selected; for (int i = 0; i < labels.Length; i++) { Rect rect = Next(width2, height); if (Clicked(rect)) { num = i; } SctGui.DrawButton(rect, labels[i], i == num); } if (!horizontal) { EndHorizontal(); } return num; } public float Slider(float value, float min, float max, float width = -1f) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0113: Invalid comparison between Unknown and I4 //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Invalid comparison between Unknown and I4 //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Invalid comparison between Unknown and I4 string text = NextKey(); Rect r = Next(width, SctGui.Row); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + ((Rect)(ref r)).height / 2f - 3f, ((Rect)(ref r)).width, 6f); float num = ((max > min) ? Mathf.Clamp01((value - min) / (max - min)) : 0f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + num * (((Rect)(ref val)).width - 12f), ((Rect)(ref r)).y + 2f, 12f, ((Rect)(ref r)).height - 4f); if (SctGui.Themed) { SctGui.DrawField(val, focused: false); SctGui.DrawButton(val2, "", _activeSlider == text); } else { GUI.Box(val, ""); GUI.Box(val2, ""); } Event current = Event.current; if ((int)current.type == 0 && SctGui.Contains(r, current.mousePosition)) { _activeSlider = text; SctGui.Use(current); } else if ((int)current.type == 1 && _activeSlider == text) { _activeSlider = null; SctGui.Use(current); } if (_activeSlider == text && ((int)current.type == 3 || (int)current.type == 0 || (int)current.type == 12)) { float num2 = Mathf.Clamp01((current.mousePosition.x - ((Rect)(ref val)).x) / Math.Max(1f, ((Rect)(ref val)).width)); value = min + num2 * (max - min); } return value; } public string TextField(string value, int maxLength, float width = -1f) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Invalid comparison between Unknown and I4 //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 string text = NextKey(); Rect val = Next(width, SctGui.Row); bool flag = _focusedField == text; Event current = Event.current; if ((int)current.type == 0) { if (SctGui.Contains(val, current.mousePosition)) { _focusedField = text; flag = true; SctGui.Use(current); } else if (flag) { _focusedField = null; flag = false; } } value = value ?? ""; if (flag && (int)current.type == 4) { if ((int)current.keyCode == 8) { if (value.Length > 0) { value = value.Substring(0, value.Length - 1); } SctGui.Use(current); } else if ((int)current.keyCode == 13 || (int)current.keyCode == 271 || (int)current.keyCode == 27) { _focusedField = null; SctGui.Use(current); } else if (current.character != 0 && !char.IsControl(current.character)) { if (value.Length < maxLength) { value += current.character; } SctGui.Use(current); } } bool flag2 = flag && Time.realtimeSinceStartup % 1f < 0.5f; if (SctGui.Themed) { SctGui.DrawField(val, flag); } else { GUI.Box(val, ""); } GUI.Label(new Rect(((Rect)(ref val)).x + 6f, ((Rect)(ref val)).y, ((Rect)(ref val)).width - 12f, ((Rect)(ref val)).height), value + (flag2 ? "|" : ""), SctGui.Label); return value; } public void BeginScroll(float height, string id = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) string text = id ?? NextKey(); Rect r = Next(-1f, height); ScrollOffsets.TryGetValue(text, out var value); ContentHeights.TryGetValue(text, out var value2); Event current = Event.current; if ((int)current.type == 6 && SctGui.Contains(r, current.mousePosition)) { value += current.delta.y * 20f; SctGui.Use(current); } value = Mathf.Clamp(value, 0f, Math.Max(0f, value2 - height)); ScrollOffsets[text] = value; if (value2 > height) { float num = Math.Max(20f, height * height / value2); float num2 = ((Rect)(ref r)).y + (height - num) * (value / (value2 - height)); GUI.Box(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width - 6f, num2, 6f, num), "", SctGui.ScrollThumb); } GUI.BeginGroup(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 8f, height)); _frames.Push(_f); _scrollKeys.Push((text, height)); _f = new Frame { X = 0f, Y = 0f - value, Width = ((Rect)(ref r)).width - 8f }; } public void EndScroll() { string item = _scrollKeys.Pop().Key; ScrollOffsets.TryGetValue(item, out var value); ContentHeights[item] = _f.Y + value; GUI.EndGroup(); _f = _frames.Pop(); } } } namespace SCTBuildUpgrades { internal class UpgradeTier { public string NameFr; public string NameEn; public (ResourceType Resource, int Quantity)[] Costs; public Color Tint; public Color Glow; public string Name => Lang.Pick(NameFr, NameEn); } internal class BuildUpgradeDefinition { public BuildType Target; public string TargetFr; public string TargetEn; public UpgradeTier[] Tiers; public float[] Speed = new float[5] { 1f, 1.15f, 1.3f, 1.5f, 1.75f }; public float[] Consumption = new float[5] { 1f, 0.9f, 0.8f, 0.7f, 0.6f }; public float[] EnergyReserve = new float[5] { 1f, 1.5f, 2f, 3f, 4f }; public float[] Storage = new float[5] { 1f, 1.5f, 2f, 3f, 4f }; public int[] InputSlot; public float[] OutputRate = new float[5] { 1f, 1f, 1.25f, 1.5f, 1.5f }; public string TargetName => Lang.Pick(TargetFr, TargetEn); public static T At<T>(T[] values, int level) { return values[Math.Max(0, Math.Min(level, values.Length - 1))]; } } public abstract class BuildUpgradePlugin : BasePlugin { internal static BuildUpgradeDefinition Definition; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<Key> HoldKey; internal static ConfigEntry<float> HoldSeconds; internal static ConfigEntry<bool> GlowEnabled; internal static ConfigEntry<int> RefundPercent; internal static ConfigEntry<string> LightFactors; internal static ManualLogSource Logger; private static BuildUpgradePlugin _instance; internal static bool Active { get { if (Enabled.Value) { return !Vanilla.Active; } return false; } } internal abstract BuildUpgradeDefinition CreateDefinition(); protected abstract void AddHost(); internal virtual void ApplyEffects(Build build, int level) { } protected virtual void BindConfig() { } public override void Load() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01e2: Expected O, but got Unknown _instance = this; Logger = ((BasePlugin)this).Log; Definition = CreateDefinition(); Enabled = ((BasePlugin)this).Config.Bind<bool>("Amelioration", "Enabled", true, "Permet d'améliorer les " + Definition.TargetFr.ToLowerInvariant() + "s."); HoldKey = ((BasePlugin)this).Config.Bind<Key>("Amelioration", "Key", (Key)35, "Touche à maintenir devant le bâtiment pour l'améliorer."); HoldSeconds = ((BasePlugin)this).Config.Bind<float>("Amelioration", "HoldSeconds", 0.6f, new ConfigDescription("Durée de maintien (secondes).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>())); GlowEnabled = ((BasePlugin)this).Config.Bind<bool>("Amelioration", "Glow", true, "Lueur pulsée de la couleur du palier (bleu, cuivre, blanc, or)."); LightFactors = ((BasePlugin)this).Config.Bind<string>("Amelioration", "LightFactors", "1.5, 2.25, 3, 4, 5", "Rayon de lumière par palier (Fer, Cuivre, Quartz, Or, puis paliers suivants), séparés par des virgules. Bâtiment non amélioré : lumière d'origine. Valeur 1 = lumière d'origine pour ce palier."); RefundPercent = ((BasePlugin)this).Config.Bind<int>("Amelioration", "RefundPercentWithSalvage", 50, new ConfigDescription("Part des lingots rendue au ramassage d'un bâtiment amélioré, UNIQUEMENT si le mod de perk Récupération est installé et activé (chaque perk prise la remonte jusqu'à 100 %). Sans ce mod, tout est rendu.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); BindConfig(); UpgradeStore.Name = $"buildupgrade_{Definition.Target}.json"; UpgradeStore.OldPath = Path.Combine(Paths.BepInExRootPath, "SCTBuildUpgrades", $"{Definition.Target}.json"); new Harmony(Il2CppUtil.Guid((BasePlugin)(object)this)).PatchAll(((object)this).GetType().Assembly); AddHost(); ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Améliorations de "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Definition.TargetFr); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" chargées ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Definition.Tiers.Length); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" paliers)"); } log.LogInfo(val); } internal static bool IsTarget(Build build) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)build != (Object)null) { return build.BuildType == Definition.Target; } return false; } internal static void Apply(Build build) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) int num = (Active ? UpgradeStore.LevelAt(build.Position) : 0); SpriteRenderer component = ((Component)build).GetComponent<SpriteRenderer>(); if ((Object)(object)component != (Object)null) { component.color = ((num > 0) ? Palette.Tier(num, Definition.Tiers[num - 1].Tint) : Color.white); UpgradeGlow.Apply(component, num); } BuildStats.Apply(build, num); _instance.ApplyEffects(build, num); } internal static int LevelOf(Build build) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!Active || !((Object)(object)build != (Object)null) || !IsTarget(build)) { return 0; } return UpgradeStore.LevelAt(build.Position); } } internal static class BuildStats { private static readonly Dictionary<IntPtr, (float Consumption, float Reserve, int Capacity)> Base = new Dictionary<IntPtr, (float, float, int)>(); public static void Apply(Build build, int level) { if (!Base.TryGetValue(((Il2CppObjectBase)build).Pointer, out (float, float, int) value)) { value = (build.energyConsumption, build.maxEnergy, build.maxCapacity); Base[((Il2CppObjectBase)build).Pointer] = value; } BuildUpgradeDefinition definition = BuildUpgradePlugin.Definition; build.energyConsumption = value.Item1 * BuildUpgradeDefinition.At(definition.Consumption, level); build.maxEnergy = value.Item2 * BuildUpgradeDefinition.At(definition.EnergyReserve, level); build.maxCapacity = Mathf.RoundToInt((float)value.Item3 * BuildUpgradeDefinition.At(definition.Storage, level)); } } [HarmonyPatch(typeof(Build), "GetTaskTime")] internal static class UpgradeSpeedPatch { private static void Postfix(Build __instance, ref float __result) { int num = BuildUpgradePlugin.LevelOf(__instance); if (__result > 0f && num > 0) { __result /= BuildUpgradeDefinition.At(BuildUpgradePlugin.Definition.Speed, num); } } } [HarmonyPatch(typeof(Build), "GetMaxInputSlotCapacity")] internal static class UpgradeInputSlotPatch { private static void Postfix(Build __instance, ref int __result) { int[] inputSlot = BuildUpgradePlugin.Definition.InputSlot; int num = BuildUpgradePlugin.LevelOf(__instance); if (inputSlot != null && num > 0) { __result = Math.Max(__result, BuildUpgradeDefinition.At(inputSlot, num)); } } } [HarmonyPatch(typeof(Build), "get_TransportOutputInterval")] internal static class UpgradeOutputPatch { private static void Postfix(Build __instance, ref float __result) { int num = BuildUpgradePlugin.LevelOf(__instance); if (num > 0) { __result /= BuildUpgradeDefinition.At(BuildUpgradePlugin.Definition.OutputRate, num); } } } internal static class UpgradeGlow { private const string ColorProperty = "_SineGlowColor"; private static Material[] _materials; private static Material _source; private static ColorVision _vision; private static bool _failed; private static Material For(int level) { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) VisualManager instance = VisualManager.Instance; if (_failed || level <= 0 || (Object)(object)instance == (Object)null || (Object)(object)instance.discoveryMaterial == (Object)null) { return null; } if ((Object)(object)_source == (Object)null || ((Il2CppObjectBase)_source).Pointer != ((Il2CppObjectBase)instance.discoveryMaterial).Pointer || _materials == null || _vision != Palette.Vision) { try { _source = instance.discoveryMaterial; _vision = Palette.Vision; Color val = (_source.HasProperty("_SineGlowColor") ? _source.GetColor("_SineGlowColor") : Color.white); float num = Mathf.Max(val.r, Mathf.Max(new float[3] { val.g, val.b, 1f })); UpgradeTier[] tiers = BuildUpgradePlugin.Definition.Tiers; _materials = (Material[])(object)new Material[tiers.Length]; for (int i = 0; i < tiers.Length; i++) { Material val2 = Object.Instantiate<Material>(_source); ((Object)val2).hideFlags = (HideFlags)61; Color val3 = Palette.Tier(i + 1, tiers[i].Glow) * num; val3.a = val.a; val2.SetColor("_SineGlowColor", val3); _materials[i] = val2; } } catch (Exception ex) { _failed = true; ManualLogSource logger = BuildUpgradePlugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Lueur des paliers indisponible : "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message); } logger.LogWarning(val4); return null; } } return _materials[Mathf.Clamp(level, 1, _materials.Length) - 1]; } public static bool IsOurs(Material material) { if ((Object)(object)material == (Object)null || _materials == null) { return false; } Material[] materials = _materials; foreach (Material val in materials) { if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)material).Pointer) { return true; } } return false; } public static void Apply(SpriteRenderer renderer, int level) { VisualManager instance = VisualManager.Instance; Material val = (BuildUpgradePlugin.GlowEnabled.Value ? For(level) : null); if ((Object)(object)val != (Object)null) { ((Renderer)renderer).sharedMaterial = val; } else if (IsOurs(((Renderer)renderer).sharedMaterial) && (Object)(object)instance != (Object)null && (Object)(object)instance.defaultMaterial != (Object)null) { ((Renderer)renderer).sharedMaterial = instance.defaultMaterial; } } public static void Maintain() { //IL_005e: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) VisualManager instance = VisualManager.Instance; BuildManager instance2 = BuildManager.Instance; if (_failed || (Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || !BuildUpgradePlugin.GlowEnabled.Value || !BuildUpgradePlugin.Active) { return; } List<Build> builds = instance2.builds; for (int i = 0; i < builds.Count; i++) { Build val = builds[i]; if (!BuildUpgradePlugin.IsTarget(val)) { continue; } int num = UpgradeStore.LevelAt(val.Position); if (num <= 0) { continue; } SpriteRenderer component = ((Component)val).GetComponent<SpriteRenderer>(); if (!((Object)(object)component == (Object)null)) { Color val2 = Palette.Tier(num, BuildUpgradePlugin.Definition.Tiers[num - 1].Tint); if (component.color != val2) { component.color = val2; } Material sharedMaterial = ((Renderer)component).sharedMaterial; bool num2 = (Object)(object)sharedMaterial != (Object)null && (Object)(object)instance.interactableMaterial != (Object)null && ((Il2CppObjectBase)sharedMaterial).Pointer == ((Il2CppObjectBase)instance.interactableMaterial).Pointer; Material val3 = For(num); if (!num2 && (Object)(object)val3 != (Object)null && ((Object)(object)sharedMaterial == (Object)null || ((Il2CppObjectBase)sharedMaterial).Pointer != ((Il2CppObjectBase)val3).Pointer)) { ((Renderer)component).sharedMaterial = val3; } } } } } [Serializable] public class UpgradeEntry { public int x; public int y; public int level; public List<int> paid = new List<int>(); } [Serializable] public class UpgradeSave { public List<UpgradeEntry> entries = new List<UpgradeEntry>(); } internal static class UpgradeStore { public static string Name; public static string OldPath; private static bool _migrated; private static int _slotVersion; private static UpgradeSave _state; private static readonly JsonSerializerOptions Options = new JsonSerializerOptions { IncludeFields = true, WriteIndented = true }; public static string FilePath { get { if (!_migrated) { _migrated = true; SaveSlotApi.Migrate(OldPath, Name); } return SaveSlotApi.PathOf(Name); } } private static UpgradeSave State { get { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown if (_slotVersion != SaveSlotApi.Version) { _slotVersion = SaveSlotApi.Version; _state = null; } if (_state != null) { return _state; } try { if (File.Exists(FilePath)) { _state = JsonSerializer.Deserialize<UpgradeSave>(File.ReadAllText(FilePath), Options); } } catch (Exception ex) { ManualLogSource logger = BuildUpgradePlugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Paliers illisibles : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logger.LogWarning(val); } return _state ?? (_state = new UpgradeSave()); } } public static UpgradeEntry At(Vector3Int p) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return State.entries.Find((UpgradeEntry e) => e.x == ((Vector3Int)(ref p)).x && e.y == ((Vector3Int)(ref p)).y); } public static int LevelAt(Vector3Int p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return At(p)?.level ?? 0; } public static UpgradeEntry GetOrAdd(Vector3Int p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) UpgradeEntry upgradeEntry = At(p); if (upgradeEntry == null) { upgradeEntry = new UpgradeEntry { x = ((Vector3Int)(ref p)).x, y = ((Vector3Int)(ref p)).y }; State.entries.Add(upgradeEntry); } return upgradeEntry; } public static void Remove(UpgradeEntry entry) { State.entries.Remove(entry); Write(); } public static void Write() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown try { Directory.CreateDirectory(Path.GetDirectoryName(FilePath)); File.WriteAllText(FilePath, JsonSerializer.Serialize(State, Options)); } catch (Exception ex) { ManualLogSource logger = BuildUpgradePlugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Sauvegarde des paliers impossible : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logger.LogWarning(val); } } public static void Reload() { _state = null; } public static void Delete() { _state = new UpgradeSave(); try { if (File.Exists(FilePath)) { File.Delete(FilePath); } } catch (Exception) { } } } internal static class UpgradeShop { public static float RefundRate { get { if (!RefundBonus.SalvageActive) { return 1f; } return Mathf.Clamp01((float)BuildUpgradePlugin.RefundPercent.Value / 100f + RefundBonus.Total); } } public static Build Target() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 Game instance = Game.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.player == (Object)null || (Object)(object)BlockManager.Instance == (Object)null || (Object)(object)BuildManager.Instance == (Object)null) { return null; } Vector3Int val = BlockManager.Instance.PositionToCell(Vector2.op_Implicit(((Component)instance.player).transform.position)); TileData tile = BlockManager.Instance.GetTile(val); if (tile == null || (int)tile.tileType != 4 || (Object)(object)tile.build == (Object)null) { return null; } if (!BuildUpgradePlugin.IsTarget(tile.build)) { return null; } return tile.build; } public static int Cost(int quantity) { return Mathf.Max(1, Mathf.CeilToInt((float)quantity * CraftCosts.Factor)); } public static UpgradeTier Next(Build build) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int num = UpgradeStore.LevelAt(build.Position); UpgradeTier[] tiers = BuildUpgradePlugin.Definition.Tiers; if (num >= tiers.Length) { return null; } return tiers[num]; } public static List<(ResourceType Resource, int Missing)> Missing(UpgradeTier tier) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Player player = Game.Instance.player; List<(ResourceType, int)> list = new List<(ResourceType, int)>(); (ResourceType, int)[] costs = tier.Costs; for (int i = 0; i < costs.Length; i++) { (ResourceType, int) tuple = costs[i]; ResourceType item = tuple.Item1; int num = Cost(tuple.Item2) - player.GetResourceQuantity(item); if (num > 0) { list.Add((item, num)); } } return list; } public static bool TryUpgrade(Build build) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected I4, but got Unknown UpgradeTier upgradeTier = Next(build); if (upgradeTier == null || Missing(upgradeTier).Count > 0) { return false; } UpgradeEntry orAdd = UpgradeStore.GetOrAdd(build.Position); (ResourceType, int)[] costs = upgradeTier.Costs; for (int i = 0; i < costs.Length; i++) { (ResourceType, int) tuple = costs[i]; ResourceType item = tuple.Item1; int num = Cost(tuple.Item2); Game.Instance.player.RemoveResource(item, num); orAdd.paid.Add((int)item); orAdd.paid.Add(num); } orAdd.level++; UpgradeStore.Write(); BuildUpgradePlugin.Apply(build); AudioManager.Play("PLACE", (MixerTarget)3, 0.5f, 1.3f); return true; } public static string Describe(Build build, out bool canUpgrade) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) BuildUpgradeDefinition definition = BuildUpgradePlugin.Definition; int num = UpgradeStore.LevelAt(build.Position); string text = ((num == 0) ? Lang.Pick("base", "basic") : definition.Tiers[num - 1].Name); UpgradeTier upgradeTier = Next(build); if (upgradeTier == null) { canUpgrade = false; return Lang.Pick(definition.TargetName + " " + text + " (niveau max)", definition.TargetName + " " + text + " (max level)") + RefundNote(num); } List<(ResourceType, int)> list = Missing(upgradeTier); canUpgrade = list.Count == 0; string value = string.Join(" + ", Array.ConvertAll(upgradeTier.Costs, ((ResourceType Resource, int Quantity) c) => $"{Cost(c.Quantity)} {ResourceNames.Of(c.Resource)}")); string text2 = Lang.Pick($"Améliorer ({text} → {upgradeTier.Name}) : {value}", $"Upgrade ({text} → {upgradeTier.Name}): {value}"); if (!canUpgrade) { string value2 = string.Join(", ", list.ConvertAll(((ResourceType Resource, int Missing) m) => $"{m.Missing} {ResourceNames.Short(m.Resource)}")); text2 += Lang.Pick($" <color=#{Palette.BadHex()}>(manque {value2})</color>", $" <color=#{Palette.BadHex()}>({value2} missing)</color>"); } return text2 + RefundNote(num); } private static string RefundNote(int level) { if (level <= 0 || !RefundBonus.SalvageActive) { return ""; } int num = Mathf.RoundToInt(RefundRate * 100f); string value = ((num >= 100) ? ("#" + Palette.GoodHex()) : ("#" + Palette.WarningHex())); return Lang.Pick($" <color={value}>· retrait : {num} % rendu</color>", $" <color={value}>· pickup: {num}% refunded</color>"); } } internal static class ResourceNames { public unsafe static string Of(ResourceType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected I4, but got Unknown return (type - 1) switch { 2 => Lang.Pick("lingots de fer", "iron ingots"), 4 => Lang.Pick("lingots de cuivre", "copper ingots"), 6 => Lang.Pick("quartz raffinés", "refined quartz"), 8 => Lang.Pick("lingots d'or", "gold ingots"), 0 => Lang.Pick("pierres", "stone"), 10 => Lang.Pick("charbon", "coal"), _ => ((object)(*(ResourceType*)(&type))/*cast due to .constrained prefix*/).ToString(), }; } public static string Short(ResourceType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected I4, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) return (type - 3) switch { 0 => Lang.Pick("fer", "iron"), 2 => Lang.Pick("cuivre", "copper"), 4 => Lang.Pick("quartz", "quartz"), 6 => Lang.Pick("or", "gold"), _ => Of(type), }; } } internal static class UpgradeHold { internal static float Progress; private static bool _waitRelease; private static GUIStyle _style; internal static bool CanInteract() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 Game instance = Game.Instance; if (BuildUpgradePlugin.Active && (Object)(object)instance != (Object)null && !instance.paused && !instance._runEnded && !instance.IsUIOpen() && !instance.HideGameplayUI && (Object)(object)BuildManager.Instance != (Object)null) { return (int)BuildManager.Instance.currentBuildPrefab == 0; } return false; } public static void Update() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; Build build = (CanInteract() ? UpgradeShop.Target() : null); bool flag = current != null && ((ButtonControl)current[BuildUpgradePlugin.HoldKey.Value]).isPressed; if ((Object)(object)build == (Object)null || !flag) { Progress = 0f; _waitRelease = false; } else { if (_waitRelease) { return; } UpgradeTier upgradeTier = UpgradeShop.Next(build); if (upgradeTier == null || UpgradeShop.Missing(upgradeTier).Count > 0) { Progress = 0f; return; } Progress += Time.deltaTime / Mathf.Max(0.1f, BuildUpgradePlugin.HoldSeconds.Value); if (!(Progress < 1f)) { Progress = 0f; _waitRelease = true; Safe.Run("Amélioration du bâtiment", delegate { UpgradeShop.TryUpgrade(build); }); } } } public static void LateUpdate() { Safe.Run("Lueur des paliers", UpgradeGlow.Maintain); } public static void OnGUI() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (UpgradePrompt.Ready || !CanInteract()) { return; } Build val = UpgradeShop.Target(); if (!((Object)(object)val == (Object)null)) { if (_style == null) { _style = SctGui.BoxStyle(14, (TextAnchor)4); } bool canUpgrade; string text = "[" + UpgradePrompt.KeyName + "] " + UpgradeShop.Describe(val, out canUpgrade) + ((Progress > 0f) ? $" {Mathf.RoundToInt(Progress * 100f)} %" : ""); GUI.Box(new Rect((float)(Screen.width - 460) / 2f, (float)(Screen.height - 120), 460f, 30f), text, _style); } } } internal static class UpgradePrompt { private static GameObject _row; private static TMP_Text _label; private static TMP_Text _key; private static Image _fill; private static Image _gamepad; private static bool _failed; public static bool Ready => (Object)(object)_row != (Object)null; public static string KeyName { get { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) try { return ((InputControl)Keyboard.current[BuildUpgradePlugin.HoldKey.Value]).displayName; } catch (Exception) { return ((object)BuildUpgradePlugin.HoldKey.Value/*cast due to .constrained prefix*/).ToString(); } } } private static void Create(BuildInteractionPrompt prompt) { ActionPromptRow deleteRow = prompt.deleteRow; if ((Object)(object)deleteRow == (Object)null) { _failed = true; return; } GameObject val = Object.Instantiate<GameObject>(((Component)deleteRow).gameObject, ((Component)deleteRow).transform.parent); ((Object)val).name = "SCT Upgrade Row"; val.transform.SetSiblingIndex(((Component)deleteRow).transform.GetSiblingIndex() + 1); ActionPromptRow component = val.GetComponent<ActionPromptRow>(); _key = component.keyboardText; _fill = component.holdFill; _gamepad = component.gamepadImage; _label = (((Object)(object)component.label != (Object)null) ? ((Component)component.label).GetComponent<TMP_Text>() : null); if ((Object)(object)component.label != (Object)null) { Object.Destroy((Object)(object)component.label); } Object.Destroy((Object)(object)component); if ((Object)(object)_label == (Object)null || (Object)(object)_key == (Object)null) { Object.Destroy((Object)(object)val); _failed = true; } else { _row = val; } } public static void Refresh(BuildInteractionPrompt prompt) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if ((Object)(object)_row == (Object)null && !_failed) { try { Create(prompt); } catch (Exception ex) { _failed = true; ManualLogSource logger = BuildUpgradePlugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(80, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ligne d'amélioration non ajoutée à l'indication du jeu ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") : affichage de secours"); } logger.LogWarning(val); } } if ((Object)(object)_row == (Object)null) { return; } Build val2 = ((UpgradeHold.CanInteract() && (Object)(object)prompt.panel != (Object)null && prompt.panel.activeSelf) ? UpgradeShop.Target() : null); _row.SetActive((Object)(object)val2 != (Object)null); if (!((Object)(object)val2 == (Object)null)) { _label.text = UpgradeShop.Describe(val2, out var canUpgrade); bool flag2 = UpgradeShop.Next(val2) == null; _key.text = (flag2 ? "—" : KeyName); if ((Object)(object)_gamepad != (Object)null) { ((Component)_ga