Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of UpgradedTrashCans v1.6.0
Mods/UpgradedTrashCans_IL2Cpp.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.Building; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Levelling; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.Networking; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.ObjectScripts.WateringCan; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.Trash; using Il2CppScheduleOne.UI.Items; using Il2CppScheduleOne.UI.Shop; using Il2CppSteamworks; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering.Universal; using UpgradedTrashCans; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "UpgradedTrashCans", "1.6.0", "j0ckinjz", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: AssemblyMetadata("NexusModID", "928")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("UpgradedTrashCans_IL2Cpp")] [assembly: AssemblyConfiguration("IL2CPP")] [assembly: AssemblyFileVersion("1.6.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UpgradedTrashCans_IL2Cpp")] [assembly: AssemblyTitle("UpgradedTrashCans_IL2Cpp")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UpgradedTrashCans { public class Core : MelonMod { public override void OnInitializeMelon() { Log.Msg("[UpgradedTrashCans] Game version: " + Application.version); if (VersionHelper.IsBetaOrNewer) { Log.Msg("[UpgradedTrashCans] Detected beta or newer version — using PickupSquareWidth"); } else { Log.Msg("[UpgradedTrashCans] Detected legacy version — using PickupRadius"); } ModManager.InitializeSettings(); Log.Msg("Mod Initialized. Version " + ((MelonBase)this).Info.Version); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (sceneName == "Main") { VariantSyncManager.SyncSettingsToVariants(); DefinitionTracker.ClearAll(); MelonCoroutines.Start(TrashInjector.InitializeShopListings()); } } } internal static class Log { public static void Msg(string msg) { Melon<Core>.Logger.Msg(msg); } public static void Warn(string msg) { Melon<Core>.Logger.Warning(msg); } public static void Error(string msg) { Melon<Core>.Logger.Error(msg); } public static void Debug(string message) { MelonPreferences_Entry<bool> debugLogs = ModManager.DebugLogs; if (debugLogs != null && debugLogs.Value) { Msg(message); } } } public static class TrashInjector { [CompilerGenerated] private sealed class <InitializeShopListings>d__0 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private List<ShopInterface> <hardwareStores>5__1; private BuildableItemDefinition <baseTrashCan>5__2; private TrashGrabberDefinition <baseGrabber>5__3; private Enumerator<ShopInterface> <>s__4; private ShopInterface <shop>5__5; private IEnumerator<ShopInterface> <>s__6; private ShopInterface <shop>5__7; private Enumerator<ItemRegister> <>s__8; private ItemRegister <entry>5__9; private List<Variants>.Enumerator <>s__10; private Variants <variant>5__11; private List<TrashGrabberVariant>.Enumerator <>s__12; private TrashGrabberVariant <variant>5__13; private List<ShopInterface>.Enumerator <>s__14; private ShopInterface <shop>5__15; private List<Variants>.Enumerator <>s__16; private Variants <variant>5__17; private ShopListing <listing>5__18; private List<TrashGrabberVariant>.Enumerator <>s__19; private TrashGrabberVariant <variant>5__20; private ShopListing <listing>5__21; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeShopListings>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <hardwareStores>5__1 = null; <baseTrashCan>5__2 = null; <baseGrabber>5__3 = null; <>s__4 = null; <shop>5__5 = null; <>s__6 = null; <shop>5__7 = null; <>s__8 = null; <entry>5__9 = null; <>s__10 = default(List<Variants>.Enumerator); <variant>5__11 = null; <>s__12 = default(List<TrashGrabberVariant>.Enumerator); <variant>5__13 = null; <>s__14 = default(List<ShopInterface>.Enumerator); <shop>5__15 = null; <>s__16 = default(List<Variants>.Enumerator); <variant>5__17 = null; <listing>5__18 = null; <>s__19 = default(List<TrashGrabberVariant>.Enumerator); <variant>5__20 = null; <listing>5__21 = null; <>1__state = -2; } private bool MoveNext() { //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Expected O, but got Unknown //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Expected O, but got Unknown if (<>1__state != 0) { return false; } <>1__state = -1; Lobby instance = Singleton<Lobby>.Instance; if (instance != null && !instance.IsHost && !VariantSyncManager.HasReceivedHostVariants) { Log.Msg("[TrashInjector] Skipping injection — host mod is disabled or missing."); return false; } <hardwareStores>5__1 = new List<ShopInterface>(); try { <>s__4 = ShopInterface.AllShops.GetEnumerator(); while (<>s__4.MoveNext()) { <shop>5__5 = <>s__4.Current; if (IsValidHardwareStore(<shop>5__5)) { <hardwareStores>5__1.Add(<shop>5__5); } <shop>5__5 = null; } <>s__4 = null; } catch { Log.Warn("[TrashInjector] Failed to access ShopInterface.AllShops — using fallback"); <>s__6 = Object.FindObjectsOfType<ShopInterface>().GetEnumerator(); try { while (<>s__6.MoveNext()) { <shop>5__7 = <>s__6.Current; if (IsValidHardwareStore(<shop>5__7)) { <hardwareStores>5__1.Add(<shop>5__7); } <shop>5__7 = null; } } finally { if (<>s__6 != null) { <>s__6.Dispose(); } } <>s__6 = null; } if (<hardwareStores>5__1.Count == 0) { Log.Warn("[TrashInjector] No hardware store interfaces found."); return false; } <baseTrashCan>5__2 = null; <baseGrabber>5__3 = null; <>s__8 = Singleton<Registry>.Instance.ItemRegistry.GetEnumerator(); while (<>s__8.MoveNext()) { <entry>5__9 = <>s__8.Current; if (<entry>5__9 != null && !((Object)(object)<entry>5__9.Definition == (Object)null)) { if (((Object)<entry>5__9.Definition).name == "TrashCan") { <baseTrashCan>5__2 = ((Il2CppObjectBase)<entry>5__9.Definition).TryCast<BuildableItemDefinition>(); } else if (((Object)<entry>5__9.Definition).name == "TrashGrabber") { <baseGrabber>5__3 = ((Il2CppObjectBase)<entry>5__9.Definition).TryCast<TrashGrabberDefinition>(); } if ((Object)(object)<baseTrashCan>5__2 != (Object)null && (Object)(object)<baseGrabber>5__3 != (Object)null) { break; } <entry>5__9 = null; } } <>s__8 = null; if ((Object)(object)<baseTrashCan>5__2 != (Object)null) { <>s__10 = TrashCanVariants.All.GetEnumerator(); try { while (<>s__10.MoveNext()) { <variant>5__11 = <>s__10.Current; InjectCustomTrashCan(<baseTrashCan>5__2, <variant>5__11); <variant>5__11 = null; } } finally { ((IDisposable)<>s__10).Dispose(); } <>s__10 = default(List<Variants>.Enumerator); } if ((Object)(object)<baseGrabber>5__3 != (Object)null) { <>s__12 = TrashGrabberVariants.All.GetEnumerator(); try { while (<>s__12.MoveNext()) { <variant>5__13 = <>s__12.Current; InjectCustomTrashGrabber(<baseGrabber>5__3, <variant>5__13); <variant>5__13 = null; } } finally { ((IDisposable)<>s__12).Dispose(); } <>s__12 = default(List<TrashGrabberVariant>.Enumerator); } <>s__14 = <hardwareStores>5__1.GetEnumerator(); try { while (<>s__14.MoveNext()) { <shop>5__15 = <>s__14.Current; <>s__16 = TrashCanVariants.All.GetEnumerator(); try { while (<>s__16.MoveNext()) { <variant>5__17 = <>s__16.Current; if ((Object)(object)<variant>5__17?.Definition == (Object)null) { Log.Warn("Skipped injecting trash can variant " + <variant>5__17?.Name + " due to missing definition."); continue; } <listing>5__18 = new ShopListing { Item = (StorableItemDefinition)(object)<variant>5__17.Definition, name = <variant>5__17.Name, OverridePrice = true, OverriddenPrice = <variant>5__17.Price, CurrentStock = 999 }; <shop>5__15.Listings.Add(<listing>5__18); <shop>5__15.CreateListingUI(<listing>5__18); Log.Debug("Injected " + <variant>5__17.Name + " into shop."); <listing>5__18 = null; <variant>5__17 = null; } } finally { ((IDisposable)<>s__16).Dispose(); } <>s__16 = default(List<Variants>.Enumerator); <>s__19 = TrashGrabberVariants.All.GetEnumerator(); try { while (<>s__19.MoveNext()) { <variant>5__20 = <>s__19.Current; if ((Object)(object)<variant>5__20?.Definition == (Object)null) { Log.Warn("Skipped injecting trash grabber variant " + <variant>5__20?.Name + " due to missing definition."); continue; } <listing>5__21 = new ShopListing { Item = (StorableItemDefinition)(object)<variant>5__20.Definition, name = <variant>5__20.Name, OverridePrice = true, OverriddenPrice = <variant>5__20.Price, CurrentStock = 999 }; <shop>5__15.Listings.Add(<listing>5__21); <shop>5__15.CreateListingUI(<listing>5__21); Log.Debug("Injected " + <variant>5__20.Name + " into shop."); <listing>5__21 = null; <variant>5__20 = null; } } finally { ((IDisposable)<>s__19).Dispose(); } <>s__19 = default(List<TrashGrabberVariant>.Enumerator); <shop>5__15 = null; } } finally { ((IDisposable)<>s__14).Dispose(); } <>s__14 = default(List<ShopInterface>.Enumerator); Log.Msg("Upgraded items injected successfully into all Hardware Stores!"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<InitializeShopListings>d__0))] public static IEnumerator InitializeShopListings() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InitializeShopListings>d__0(0); } private static bool IsValidHardwareStore(ShopInterface shop) { if ((Object)(object)shop == (Object)null || shop.Listings == null || shop.Listings.Count == 0) { return false; } try { return ((Object)shop).name == "HardwareStoreInterface" || ((Object)shop).name == "HardwareStoreInterface (North Store)"; } catch { return false; } } private static void InjectCustomTrashCan(BuildableItemDefinition baseDef, Variants variant) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseDef == (Object)null || (Object)(object)baseDef.BuiltItem == (Object)null) { Log.Debug("Invalid base listing for trash can injection."); return; } BuildableItemDefinition val = Object.Instantiate<BuildableItemDefinition>(baseDef); ((ItemDefinition)val).Name = variant.Name; ((ItemDefinition)val).ID = variant.ID; ((ItemDefinition)val).Description = variant.Description; ((StorableItemDefinition)val).BasePurchasePrice = variant.Price; ((Object)val).name = variant.Name.Replace(" ", ""); ((StorableItemDefinition)val).RequiresLevelToPurchase = !variant.UnlockImmediately; if (!variant.UnlockImmediately) { ((StorableItemDefinition)val).RequiredRank = new FullRank(variant.RequiredRank, variant.Tier); } if ((Object)(object)((ItemDefinition)baseDef).Icon != (Object)null) { ((ItemDefinition)val).Icon = SpriteLoader.TintSprite(((ItemDefinition)baseDef).Icon, variant.Color, variant.Name + "_Icon"); } else { Log.Warn(((ItemDefinition)baseDef).Name + " has no icon."); } val.BuiltItem = baseDef.BuiltItem; DefinitionTracker.TrackDefinition((ItemDefinition)(object)val); variant.Definition = val; } private static void InjectCustomTrashGrabber(TrashGrabberDefinition baseDef, TrashGrabberVariant variant) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseDef == (Object)null || (Object)(object)((ItemDefinition)baseDef).Equippable == (Object)null) { Log.Debug("Invalid base listing for trash grabber injection."); return; } TrashGrabberDefinition val = Object.Instantiate<TrashGrabberDefinition>(baseDef); ((ItemDefinition)val).ID = variant.ID; ((ItemDefinition)val).Name = variant.Name; ((Object)val).name = variant.Name.Replace(" ", ""); ((ItemDefinition)val).Description = variant.Description; ((StorableItemDefinition)val).BasePurchasePrice = variant.Price; ((StorableItemDefinition)val).RequiresLevelToPurchase = !variant.UnlockImmediately; if (!variant.UnlockImmediately) { ((StorableItemDefinition)val).RequiredRank = new FullRank(variant.RequiredRank, variant.Tier); } if ((Object)(object)((ItemDefinition)baseDef).Icon != (Object)null) { ((ItemDefinition)val).Icon = SpriteLoader.TintSprite(((ItemDefinition)baseDef).Icon, variant.Color, variant.Name + "_Icon"); } else { Log.Debug(((ItemDefinition)baseDef).Name + " icon not found."); } ((ItemDefinition)val).Equippable = ((ItemDefinition)baseDef).Equippable; DefinitionTracker.TrackDefinition((ItemDefinition)(object)val); variant.Definition = val; } } public enum TrashCanType { Bin, Compactor } public class Variants { public string Name; public string ID; public float Price; public string Description; public int Capacity; public Color Color; public float Radius; public ERank RequiredRank; public int Tier; public BuildableItemDefinition Definition; public bool UnlockImmediately; public TrashCanType Type; } public static class TrashCanVariants { public static List<Variants> All = new List<Variants> { new Variants { Name = "Trash Bin", ID = "trash_bin", Description = "A slightly larger trash bin.", Price = 250f, Capacity = 40, Color = Color.green, Radius = 4.5f, RequiredRank = (ERank)1, Tier = 1, Type = TrashCanType.Bin }, new Variants { Name = "Trash Compactor", ID = "trash_compactor", Description = "A high-capacity trash compactor.", Price = 1000f, Capacity = 100, Color = Color.blue, Radius = 7.5f, RequiredRank = (ERank)3, Tier = 5, Type = TrashCanType.Compactor } }; } public class TrashGrabberVariant { public string Name; public string ID; public string Description; public float Price; public Color Color; public ERank RequiredRank; public int Tier; public bool UnlockImmediately; public int Capacity; public TrashGrabberDefinition Definition; } public static class TrashGrabberVariants { public static List<TrashGrabberVariant> All = new List<TrashGrabberVariant> { new TrashGrabberVariant { Name = "Trash Grabber Pro", ID = "trash_grabber_pro", Description = "An advanced trash grabber with increased capacity.", Price = 750f, Color = Color.cyan, RequiredRank = (ERank)3, Tier = 1, UnlockImmediately = false, Capacity = 50 } }; } public static class ColorExtensions { public static Color ToUnityColor(this ColorOption option) { //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_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_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_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_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_0051: 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_0059: 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_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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result = (Color)(option switch { ColorOption.Green => Color.green, ColorOption.Blue => Color.blue, ColorOption.Red => Color.red, ColorOption.Yellow => Color.yellow, ColorOption.Cyan => Color.cyan, ColorOption.Magenta => Color.magenta, ColorOption.Black => Color.black, _ => Color.white, }); if (1 == 0) { } return result; } public static Color ToUnityColor(this ExtendedColorOption option) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b8: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result = (Color)(option switch { ExtendedColorOption.Purple => new Color(0.63f, 0.13f, 0.94f), ExtendedColorOption.Orange => new Color(1f, 0.65f, 0f), ExtendedColorOption.Pink => new Color(1f, 0.75f, 0.8f), ExtendedColorOption.Brown => new Color(0.6f, 0.3f, 0.15f), ExtendedColorOption.Lime => new Color(0.2f, 0.8f, 0.2f), ExtendedColorOption.Teal => new Color(0f, 0.5f, 0.5f), ExtendedColorOption.Indigo => new Color(0.29f, 0f, 0.51f), ExtendedColorOption.Violet => new Color(0.93f, 0.51f, 0.93f), _ => Color.white, }); if (1 == 0) { } return result; } public static bool TryParseRGB(string input, out Color color) { //IL_0002: 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) //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) color = Color.white; if (string.IsNullOrWhiteSpace(input)) { Log.Warn("RGB string is null or empty: \"" + input + "\""); return false; } string[] array = input.Split(','); if (array.Length != 3) { Log.Warn("RGB string does not contain 3 components: \"" + input + "\""); return false; } if (float.TryParse(array[0].TrimEnd('f'), out var result) && float.TryParse(array[1].TrimEnd('f'), out var result2) && float.TryParse(array[2].TrimEnd('f'), out var result3)) { color = new Color(result, result2, result3, 1f); return true; } Log.Warn("Failed to parse float values from RGB string: \"" + input + "\""); return false; } } public static class SpriteLoader { public static Sprite TintSprite(Sprite original, Color tint, string name = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //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_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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) //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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b3: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) Texture2D val = MakeReadableCopy(original.texture); Texture2D val2 = new Texture2D(((Texture)val).width, ((Texture)val).height, (TextureFormat)4, false); Color[] array = Il2CppArrayBase<Color>.op_Implicit((Il2CppArrayBase<Color>)(object)val.GetPixels()); for (int i = 0; i < array.Length; i++) { Color val3 = array[i]; Color val4 = Color.Lerp(val3, Color.black, 0.2f); float num = 0.3f * val3.r + 0.59f * val3.g + 0.11f * val3.b; Color val5 = Color.Lerp(val4, tint * num, 0.7f); array[i] = new Color(val5.r, val5.g, val5.b, val3.a); } val2.SetPixels(Il2CppStructArray<Color>.op_Implicit(array)); val2.Apply(); Sprite val6 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)); if (!string.IsNullOrEmpty(name)) { ((Object)val6).name = name; } return val6; } private static Texture2D MakeReadableCopy(Texture2D source) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) RenderTexture temporary = RenderTexture.GetTemporary(((Texture)source).width, ((Texture)source).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1); Graphics.Blit((Texture)(object)source, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } } internal static class VisualHelper { public static void TintRenderers(Transform root, Color color, params string[] targetNames) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) IEnumerable<MeshRenderer> enumerable = from t in (IEnumerable<Transform>)((Component)root).GetComponentsInChildren<Transform>(true) where targetNames.Contains(((Object)t).name) select ((Component)t).GetComponent<MeshRenderer>() into r where (Object)(object)r != (Object)null select r; foreach (MeshRenderer item in enumerable) { ((Renderer)item).material.color = color; } } } public static class DefinitionTracker { private static readonly List<ItemDefinition> TrackedDefinitions = new List<ItemDefinition>(); public static void TrackDefinition(ItemDefinition def) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003e: Expected O, but got Unknown if (!((Object)(object)def == (Object)null)) { Singleton<Registry>.Instance.AddToRegistry(def); Singleton<Registry>.Instance.AddToItemDictionary(new ItemRegister { ID = def.ID, Definition = def }); Log.Debug("Tracking definition: " + def.ID); TrackedDefinitions.Add(def); } } public static void ClearAll() { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown foreach (ItemDefinition trackedDefinition in TrackedDefinitions) { Singleton<Registry>.Instance.RemoveFromRegistry(trackedDefinition); Singleton<Registry>.Instance.RemoveItemFromDictionary(new ItemRegister { ID = trackedDefinition.ID, Definition = trackedDefinition }); } TrackedDefinitions.Clear(); Log.Msg("Cleared all tracked definitions."); } } public static class PreviewHelper { public static class State { public static Variants? Current; } public static void TrackPreviewVariant(ItemInstance item) { if ((Object)(object)((item != null) ? item.Definition : null) == (Object)null) { State.Current = null; Log.Debug("[Preview] No definition found — cleared active variant."); return; } ItemDefinition def = item.Definition; Variants variants = (State.Current = TrashCanVariants.All.FirstOrDefault((Variants v) => (Object)(object)v.Definition == (Object)(object)def)); Log.Debug((variants != null) ? ("[Preview] Spawned ghost for variant: " + variants.ID) : "[Preview] Spawned ghost for base trash can or non-variant."); } public static void ApplyRadiusIfValid(DecalProjector projector) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)projector == (Object)null) { return; } Transform transform = ((Component)projector).transform; Transform val = ((transform != null) ? transform.root : null); GameObject val2 = ((val != null) ? ((Component)val).gameObject : null); if ((Object)(object)val2 == (Object)null) { return; } TrashContainer componentInChildren = ((Component)val).GetComponentInChildren<TrashContainer>(); if ((Object)(object)componentInChildren == (Object)null) { return; } if (((val != null) ? ((Object)val).name : null) != "_Temp") { Log.Debug("[Preview] Skipped DecalProjector — not part of a build preview."); return; } Variants current = State.Current; if (current != null) { float num = current.Radius * 2f; Vector3 size = projector.size; projector.size = new Vector3(num, num, size.z); Log.Debug($"[Preview] Radius set to {num:F2} for variant: {current.ID}"); } } } public enum ColorOption { Green, Blue, Red, Yellow, Cyan, Magenta, Black, White } public enum ExtendedColorOption { Purple, Orange, Pink, Brown, Lime, Teal, Indigo, Violet } public enum ColorSource { Standard, Extended, CustomRGB } public enum RankOption { Street_Rat, Hoodlum, Peddler, Hustler, Bagman, Enforcer, Shot_Caller, Block_Boss, Underlord, Baron, Kingpin } public static class ModManager { public class ModSettingsGroup { public MelonPreferences_Category Category; public MelonPreferences_Entry<ColorOption> Color; public MelonPreferences_Entry<ExtendedColorOption> ExtendedColor; public MelonPreferences_Entry<int> Capacity; public MelonPreferences_Entry<float> Radius; public MelonPreferences_Entry<RankOption> Rank; public MelonPreferences_Entry<int> Tier; public MelonPreferences_Entry<bool> UnlockImmediately; public MelonPreferences_Entry<float> Price; public MelonPreferences_Entry<string> CustomRGB; public MelonPreferences_Entry<ColorSource> Source; public void ApplyTo(Variants variant) { //IL_005a: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_0044: 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_004c: Unknown result type (might be due to invalid IL or missing references) variant.Price = Price.Value; ColorSource value = Source.Value; if (1 == 0) { } Color color; Color color2 = (Color)(value switch { ColorSource.CustomRGB => ColorExtensions.TryParseRGB(CustomRGB.Value, out color) ? color : Color.white, ColorSource.Extended => ExtendedColor.Value.ToUnityColor(), _ => Color.Value.ToUnityColor(), }); if (1 == 0) { } variant.Color = color2; variant.Capacity = Capacity.Value; variant.Radius = Radius.Value; variant.RequiredRank = (ERank)Rank.Value; variant.Tier = Tier.Value; variant.UnlockImmediately = UnlockImmediately.Value; } } public static ModSettingsGroup TrashBinSettings; public static ModSettingsGroup TrashCompactorSettings; public static MelonPreferences_Category DebugCategory; public static MelonPreferences_Category GrabberCategory; public static MelonPreferences_Entry<ColorSource> Grabber_Source; public static MelonPreferences_Entry<ColorOption> Grabber_Color; public static MelonPreferences_Entry<ExtendedColorOption> Grabber_ExtendedColor; public static MelonPreferences_Entry<int> Grabber_Capacity; public static MelonPreferences_Entry<RankOption> Grabber_Rank; public static MelonPreferences_Entry<int> Grabber_Tier; public static MelonPreferences_Entry<bool> Grabber_UnlockImmediately; public static MelonPreferences_Entry<float> Grabber_Price; public static MelonPreferences_Entry<string> Grabber_CustomRGB; public static MelonPreferences_Entry<bool> DebugLogs; public static void InitializeSettings() { TrashBinSettings = CreateGroup("01_TrashBin", "Upgraded Trash Bin", ColorOption.Green, ExtendedColorOption.Lime, 40, 4.5f, RankOption.Hoodlum, 1, unlockImmediately: false, 250f); TrashCompactorSettings = CreateGroup("02_TrashCompactor", "Upgraded Trash Compactor", ColorOption.Blue, ExtendedColorOption.Indigo, 100, 7.5f, RankOption.Hustler, 5, unlockImmediately: false, 1000f); GrabberCategory = MelonPreferences.CreateCategory("UpgradedTrashCans_03_UpgradedTrashGrabber", "Trash Grabber Pro"); Grabber_Price = GrabberCategory.CreateEntry<float>("01_Price", 750f, "Price", "Set the shop price for the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Capacity = GrabberCategory.CreateEntry<int>("02_Capacity", 50, "Capacity", "Set the capacity of the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Rank = GrabberCategory.CreateEntry<RankOption>("03_Rank", RankOption.Hustler, "Rank Unlock", "Required rank to unlock the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Tier = GrabberCategory.CreateEntry<int>("04_Tier", 1, "Tier Unlock", "Required tier at the rank to unlock the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_UnlockImmediately = GrabberCategory.CreateEntry<bool>("05_UnlockImmediately", false, "Unlock Immediately", "Skip rank requirement for Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Source = GrabberCategory.CreateEntry<ColorSource>("06_ColorSource", ColorSource.Standard, "Color Source", "Choose which color mode to use (Base, Extended, Custom RGB).", false, false, (ValueValidator)null, (string)null); Grabber_Color = GrabberCategory.CreateEntry<ColorOption>("07_Color", ColorOption.Cyan, "Standard Colors", "Select the color of the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_ExtendedColor = GrabberCategory.CreateEntry<ExtendedColorOption>("08_ExtendedColor", ExtendedColorOption.Teal, "Extended Colors", "Custom expanded tints.", false, false, (ValueValidator)null, (string)null); Grabber_CustomRGB = GrabberCategory.CreateEntry<string>("09_CustomRGB", "0.5f, 0.5f, 0.5f", "Custom RGB Values", "Format: R,G,B (0–1 range)", false, false, (ValueValidator)null, (string)null); DebugCategory = MelonPreferences.CreateCategory("UpgradedTrashCans_04_DebugLogs", "Enable Debug Logging"); DebugLogs = DebugCategory.CreateEntry<bool>("01_Debug", false, "Enable Debug Logs", (string)null, false, false, (ValueValidator)null, (string)null); Log.Msg("ModManager Settings initialized."); } private static ModSettingsGroup CreateGroup(string keyPrefix, string displayName, ColorOption defaultColor, ExtendedColorOption defaultExtendedColor, int defaultCapacity, float defaultRadius, RankOption defaultRank, int defaultTier, bool unlockImmediately, float defaultPrice) { MelonPreferences_Category val = MelonPreferences.CreateCategory("UpgradedTrashCans_" + keyPrefix, displayName); return new ModSettingsGroup { Category = val, Price = val.CreateEntry<float>("01_Price", defaultPrice, "Price", "Shop purchase price for the " + displayName + ".", false, false, (ValueValidator)null, (string)null), Capacity = val.CreateEntry<int>("02_Capacity", defaultCapacity, "Capacity", "Number of trash items the " + displayName + " can hold.", false, false, (ValueValidator)null, (string)null), Radius = val.CreateEntry<float>("03_Radius", defaultRadius, "Cleaner Pickup Radius", "Cleaner pickup radius for the " + displayName + " (units).", false, false, (ValueValidator)null, (string)null), Rank = val.CreateEntry<RankOption>("04_Rank", defaultRank, "Rank Unlock", "Rank required to unlock the " + displayName + " in shop.", false, false, (ValueValidator)null, (string)null), Tier = val.CreateEntry<int>("05_Tier", defaultTier, "Tier Unlock", "Tier at required rank for the " + displayName + " to unlock.", false, false, (ValueValidator)null, (string)null), UnlockImmediately = val.CreateEntry<bool>("06_UnlockImmediately", unlockImmediately, "Unlock Immediately", "If true, the " + displayName + " is available immediately.", false, false, (ValueValidator)null, (string)null), Source = val.CreateEntry<ColorSource>("07_ColorSource", ColorSource.Standard, "Color Source", "Choose which color mode to use (Base, Extended, Custom RGB).", false, false, (ValueValidator)null, (string)null), Color = val.CreateEntry<ColorOption>("08_Color", defaultColor, "Standard Colors", "Color tint for the " + displayName + " model.", false, false, (ValueValidator)null, (string)null), ExtendedColor = val.CreateEntry<ExtendedColorOption>("09_ExtendedColor", defaultExtendedColor, "Extended Colors", "Expanded color tints for the " + displayName + " model.", false, false, (ValueValidator)null, (string)null), CustomRGB = val.CreateEntry<string>("10_CustomRGB", "0.5f, 0.5f, 0.5f", "Custom RGB Values", "Format: R,G,B (0–1 range)", false, false, (ValueValidator)null, (string)null) }; } } public static class VariantSyncManager { [CompilerGenerated] private sealed class <WaitForLobbyPayload>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private int <i>5__1; private string <payload>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForLobbyPayload>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <payload>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <i>5__1 = 0; break; case 1: <>1__state = -1; <payload>5__2 = null; <i>5__1++; break; } if (<i>5__1 < 10) { <payload>5__2 = SteamMatchmaking.GetLobbyData(Singleton<Lobby>.Instance.LobbySteamID, "UpgradedTrashSync"); if (!string.IsNullOrEmpty(<payload>5__2)) { Log.Msg("[MultiplayerSync] Host sync payload found. Applying..."); OnLobbyMessageReceived(<payload>5__2); return false; } Log.Debug($"[MultiplayerSync] Waiting for host sync... ({<i>5__1 + 1}/{10})"); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } Log.Warn("[MultiplayerSync] Timed out waiting for host variant sync."); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string LobbyTagPrefix = "UpgradedTrashCans_Settings:"; private static readonly string CurrentSyncVersion = typeof(Core).Assembly.GetName().Version.ToString(); public static bool HasReceivedHostVariants { get; private set; } = false; public static void SyncSettingsToVariants() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_06df: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Unknown result type (might be due to invalid IL or missing references) //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Expected I4, but got Unknown //IL_06d1: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Expected I4, but got Unknown Lobby instance = Singleton<Lobby>.Instance; bool flag = instance != null && instance.IsHost; Lobby instance2 = Singleton<Lobby>.Instance; int num; if (instance2 != null && !instance2.IsHost) { Lobby instance3 = Singleton<Lobby>.Instance; num = ((instance3 != null && instance3.IsInLobby) ? 1 : 0); } else { num = 0; } bool flag2 = (byte)num != 0; if (flag) { foreach (Variants item in TrashCanVariants.All) { if (item.Type == TrashCanType.Compactor) { ModManager.TrashCompactorSettings.ApplyTo(item); } else { ModManager.TrashBinSettings.ApplyTo(item); } Log.Debug($"Applied settings to {item.Name} — Capacity: {item.Capacity}, Color: {item.Color}"); } foreach (TrashGrabberVariant item2 in TrashGrabberVariants.All) { item2.Price = ModManager.Grabber_Price.Value; TrashGrabberVariant trashGrabberVariant = item2; ColorSource value = ModManager.Grabber_Source.Value; if (1 == 0) { } Color color; Color color2 = (Color)(value switch { ColorSource.CustomRGB => ColorExtensions.TryParseRGB(ModManager.Grabber_CustomRGB.Value, out color) ? color : Color.white, ColorSource.Extended => ModManager.Grabber_ExtendedColor.Value.ToUnityColor(), _ => ModManager.Grabber_Color.Value.ToUnityColor(), }); if (1 == 0) { } trashGrabberVariant.Color = color2; item2.Capacity = ModManager.Grabber_Capacity.Value; item2.RequiredRank = (ERank)ModManager.Grabber_Rank.Value; item2.Tier = ModManager.Grabber_Tier.Value; item2.UnlockImmediately = ModManager.Grabber_UnlockImmediately.Value; Log.Debug($"Applied settings to {item2.Name} — Capacity: {item2.Capacity}, Color: {item2.Color}, Unlock: {item2.UnlockImmediately}"); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("UpgradedTrashCans_Settings:" + CurrentSyncVersion + "|"); foreach (Variants item3 in TrashCanVariants.All) { int value2 = (item3.UnlockImmediately ? 1 : 0); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder3 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(10, 10, stringBuilder2); handler.AppendFormatted(item3.ID); handler.AppendLiteral(":"); handler.AppendFormatted(item3.Price); handler.AppendLiteral(","); handler.AppendFormatted(item3.Capacity); handler.AppendLiteral(","); handler.AppendFormatted(item3.Radius); handler.AppendLiteral(","); handler.AppendFormatted(item3.Color.r, "F2"); handler.AppendLiteral(","); handler.AppendFormatted(item3.Color.g, "F2"); handler.AppendLiteral(","); handler.AppendFormatted(item3.Color.b, "F2"); handler.AppendLiteral(","); handler.AppendFormatted((int)item3.RequiredRank); handler.AppendLiteral(","); handler.AppendFormatted(item3.Tier); handler.AppendLiteral(","); handler.AppendFormatted(value2); handler.AppendLiteral(";"); stringBuilder3.Append(ref handler); } foreach (TrashGrabberVariant item4 in TrashGrabberVariants.All) { int value3 = (item4.UnlockImmediately ? 1 : 0); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(13, 9, stringBuilder2); handler.AppendFormatted(item4.ID); handler.AppendLiteral(":"); handler.AppendFormatted(item4.Price); handler.AppendLiteral(","); handler.AppendFormatted(item4.Capacity); handler.AppendLiteral(",0.0,"); handler.AppendFormatted(item4.Color.r, "F2"); handler.AppendLiteral(","); handler.AppendFormatted(item4.Color.g, "F2"); handler.AppendLiteral(","); handler.AppendFormatted(item4.Color.b, "F2"); handler.AppendLiteral(","); handler.AppendFormatted((int)item4.RequiredRank); handler.AppendLiteral(","); handler.AppendFormatted(item4.Tier); handler.AppendLiteral(","); handler.AppendFormatted(value3); handler.AppendLiteral(";"); stringBuilder4.Append(ref handler); } Singleton<Lobby>.Instance.SetLobbyData("UpgradedTrashSync", stringBuilder.ToString()); } else if (flag2) { MelonCoroutines.Start(WaitForLobbyPayload()); } else { foreach (Variants item5 in TrashCanVariants.All) { if (item5.Type == TrashCanType.Compactor) { ModManager.TrashCompactorSettings.ApplyTo(item5); } else { ModManager.TrashBinSettings.ApplyTo(item5); } } foreach (TrashGrabberVariant item6 in TrashGrabberVariants.All) { item6.Price = ModManager.Grabber_Price.Value; TrashGrabberVariant trashGrabberVariant2 = item6; ColorSource value4 = ModManager.Grabber_Source.Value; if (1 == 0) { } Color color3; Color color2 = (Color)(value4 switch { ColorSource.CustomRGB => ColorExtensions.TryParseRGB(ModManager.Grabber_CustomRGB.Value, out color3) ? color3 : Color.white, ColorSource.Extended => ModManager.Grabber_ExtendedColor.Value.ToUnityColor(), _ => ModManager.Grabber_Color.Value.ToUnityColor(), }); if (1 == 0) { } trashGrabberVariant2.Color = color2; item6.Capacity = ModManager.Grabber_Capacity.Value; item6.RequiredRank = (ERank)ModManager.Grabber_Rank.Value; item6.Tier = ModManager.Grabber_Tier.Value; item6.UnlockImmediately = ModManager.Grabber_UnlockImmediately.Value; } } VariantLookup.Refresh(); Log.Msg("Trash can and grabber settings synced."); } [IteratorStateMachine(typeof(<WaitForLobbyPayload>d__7))] private static IEnumerator WaitForLobbyPayload() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForLobbyPayload>d__7(0); } public static void OnLobbyMessageReceived(string rawMessage) { //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) if (!rawMessage.StartsWith("UpgradedTrashCans_Settings:")) { return; } string text = rawMessage.Substring("UpgradedTrashCans_Settings:".Length); string[] array = text.Split('|'); if (array.Length != 2) { Log.Error("[MultiplayerSync] Invalid payload format."); return; } string text2 = array[0]; string text3 = array[1]; if (text2 != CurrentSyncVersion) { Log.Warn($"[MultiplayerSync] Host mod version ({text2}) does not match client mod version ({CurrentSyncVersion})."); return; } try { string[] array2 = text3.Split(';'); string[] array3 = array2; foreach (string text4 in array3) { if (string.IsNullOrWhiteSpace(text4)) { continue; } string[] array4 = text4.Split(':'); if (array4.Length != 2) { continue; } string id = array4[0]; string[] array5 = array4[1].Split(','); if (array5.Length != 9 || !float.TryParse(array5[0], out var result) || !int.TryParse(array5[1], out var result2) || !float.TryParse(array5[2], out var result3) || !float.TryParse(array5[3], out var result4) || !float.TryParse(array5[4], out var result5) || !float.TryParse(array5[5], out var result6) || !int.TryParse(array5[6], out var result7) || !int.TryParse(array5[7], out var result8) || !int.TryParse(array5[8], out var result9)) { continue; } Variants variants = TrashCanVariants.All.FirstOrDefault((Variants v) => v.ID == id); if (variants != null) { variants.Price = result; variants.Capacity = result2; variants.Radius = result3; variants.Color = new Color(result4, result5, result6); variants.RequiredRank = (ERank)result7; variants.Tier = result8; variants.UnlockImmediately = result9 == 1; continue; } TrashGrabberVariant trashGrabberVariant = TrashGrabberVariants.All.FirstOrDefault((TrashGrabberVariant v) => v.ID == id); if (trashGrabberVariant != null) { trashGrabberVariant.Price = result; trashGrabberVariant.Capacity = result2; trashGrabberVariant.Color = new Color(result4, result5, result6); trashGrabberVariant.RequiredRank = (ERank)result7; trashGrabberVariant.Tier = result8; trashGrabberVariant.UnlockImmediately = result9 == 1; } } VariantLookup.Refresh(); HasReceivedHostVariants = true; Log.Msg("[MultiplayerSync] Synced variant settings received from host."); } catch (Exception ex) { Log.Error("[MultiplayerSync] Failed to parse variant sync message: " + ex.Message); } } } public static class VersionHelper { public static readonly string RawVersion = Application.version; public static readonly Version ParsedVersion = ParseVersion(RawVersion); public static readonly bool IsBetaOrNewer = ParsedVersion >= new Version(0, 3, 6); private static Version ParseVersion(string input) { string input2 = input.Split(' ')[0].Split('f')[0]; Version result; return Version.TryParse(input2, out result) ? result : new Version(0, 0, 0); } } public static class VariantLookup { public static HashSet<string> KnownGrabberIDs { get; private set; } = new HashSet<string>(); public static Dictionary<string, TrashGrabberVariant> GrabberByID { get; private set; } = new Dictionary<string, TrashGrabberVariant>(); public static void Refresh() { KnownGrabberIDs = TrashGrabberVariants.All.Select((TrashGrabberVariant v) => v.ID).ToHashSet(); GrabberByID = TrashGrabberVariants.All.ToDictionary((TrashGrabberVariant v) => v.ID); } } [HarmonyPatch(typeof(Equippable_TrashGrabber), "GetCapacity")] public static class Patch_TrashGrabber_GetCapacity { public static void Postfix(Equippable_TrashGrabber __instance, ref int __result) { object obj; if (__instance == null) { obj = null; } else { ItemInstance itemInstance = ((Equippable)__instance).itemInstance; obj = ((itemInstance != null) ? itemInstance.Definition : null); } ItemDefinition val = (ItemDefinition)obj; if (val != null && val.ID != null && VariantLookup.KnownGrabberIDs.Contains(val.ID) && VariantLookup.GrabberByID.TryGetValue(val.ID, out var value)) { TrashGrabberInstance trashGrabberInstance = __instance.trashGrabberInstance; int num = ((trashGrabberInstance != null) ? trashGrabberInstance.GetTotalSize() : 0); __result = Mathf.Max(0, value.Capacity - num); } } } [HarmonyPatch(typeof(Equippable_TrashGrabber), "RefreshVisuals")] public static class Patch_TrashGrabber_RefreshVisuals { public static void Postfix(Equippable_TrashGrabber __instance) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((__instance != null) ? __instance.TrashContent : null) == (Object)null) && !((Object)(object)__instance.TrashContent_Min == (Object)null) && !((Object)(object)__instance.TrashContent_Max == (Object)null)) { ItemInstance itemInstance = ((Equippable)__instance).itemInstance; ItemDefinition val = ((itemInstance != null) ? itemInstance.Definition : null); if (val != null && val.ID != null && VariantLookup.KnownGrabberIDs.Contains(val.ID) && VariantLookup.GrabberByID.TryGetValue(val.ID, out var value)) { TrashGrabberInstance trashGrabberInstance = __instance.trashGrabberInstance; int num = ((trashGrabberInstance != null) ? trashGrabberInstance.GetTotalSize() : 0); float num2 = Mathf.Clamp01((float)num / (float)value.Capacity); Vector3 val2 = __instance.TrashContent_Max.localPosition - __instance.TrashContent_Min.localPosition; Vector3 localPosition = __instance.TrashContent_Min.localPosition; __instance.TrashContent.localPosition = localPosition + val2 * num2; VisualHelper.TintRenderers(((Component)__instance).transform, value.Color, "Body", "Trigger"); } } } } [HarmonyPatch(typeof(TrashGrabberItemUI), "UpdateUI")] public static class Patch_TrashGrabberItemUI_UpdateUI { public static void Postfix(TrashGrabberItemUI __instance) { if ((Object)(object)__instance == (Object)null) { return; } TextMeshProUGUI valueLabel = __instance.ValueLabel; ItemInstance itemInstance = ((ItemUI)__instance).itemInstance; ItemDefinition val = ((itemInstance != null) ? itemInstance.Definition : null); if (!((Object)(object)valueLabel == (Object)null) && val != null && val.ID != null && VariantLookup.KnownGrabberIDs.Contains(val.ID) && VariantLookup.GrabberByID.TryGetValue(val.ID, out var value)) { TrashGrabberInstance trashGrabberInstance = __instance.trashGrabberInstance; if (trashGrabberInstance != null) { float num = Mathf.Clamp01((float)trashGrabberInstance.GetTotalSize() / (float)value.Capacity); ((TMP_Text)valueLabel).text = $"{Mathf.RoundToInt(num * 100f)}%"; } } } } [HarmonyPatch(typeof(StorageVisualizer), "RefreshVisuals")] public static class Patch_StorageVisualizer_RefreshVisuals { public static void Postfix(StorageVisualizer __instance) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) Il2CppArrayBase<StoredItem> componentsInChildren = ((Component)__instance).GetComponentsInChildren<StoredItem>(true); foreach (StoredItem item2 in componentsInChildren) { StorableItemInstance item = item2.item; object obj; if (item == null) { obj = null; } else { ItemDefinition definition = ((ItemInstance)item).Definition; obj = ((definition != null) ? definition.ID : null); } if (obj != null && VariantLookup.GrabberByID.TryGetValue(((ItemInstance)item).Definition.ID, out var value)) { VisualHelper.TintRenderers(((Component)item2).transform, value.Color, "Body", "Trigger"); } } } } [HarmonyPatch(typeof(TrashContainerItem), "Start")] public static class Patch_TrashContainerItem_Start { [CompilerGenerated] private sealed class <WaitForValidName>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TrashContainerItem instance; private int <attempts>5__1; private string <name>5__2; private Exception <ex>5__3; private int <i>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForValidName>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <name>5__2 = null; <ex>5__3 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; <i>5__4++; goto IL_018a; } <>1__state = -1; <attempts>5__1 = 0; goto IL_01a1; IL_018a: if (<i>5__4 < 2) { <>2__current = null; <>1__state = 1; return true; } <name>5__2 = null; goto IL_01a1; IL_01a1: if (<attempts>5__1 < 10) { <name>5__2 = null; try { TrashContainerItem obj = instance; <name>5__2 = ((obj != null) ? obj.Name : null); } catch (Exception ex) { <ex>5__3 = ex; Log.Debug($"Exception accessing Name on attempt {<attempts>5__1 + 1}: {<ex>5__3.Message}"); } if (!string.IsNullOrWhiteSpace(<name>5__2)) { ApplyVariantSettings(instance, <name>5__2); return false; } <attempts>5__1++; Log.Debug($"Name was null or errored on attempt {<attempts>5__1}/{10}. Retrying after {2} frames..."); <i>5__4 = 0; goto IL_018a; } Log.Debug("Name remained null after all retry attempts."); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static void Postfix(TrashContainerItem __instance) { MelonCoroutines.Start(WaitForValidName(__instance)); } [IteratorStateMachine(typeof(<WaitForValidName>d__1))] private static IEnumerator WaitForValidName(TrashContainerItem instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForValidName>d__1(0) { instance = instance }; } private static void ApplyVariantSettings(TrashContainerItem instance, string name) { //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_01e6: Unknown result type (might be due to invalid IL or missing references) TrashContainer val = default(TrashContainer); foreach (Variants item in TrashCanVariants.All) { if (!string.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase)) { continue; } if (((Component)instance).TryGetComponent<TrashContainer>(ref val)) { val.TrashCapacity = item.Capacity; } float radius = item.Radius; Type type = ((object)instance).GetType(); if (VersionHelper.IsBetaOrNewer) { PropertyInfo property = type.GetProperty("PickupSquareWidth"); PropertyInfo property2 = type.GetProperty("calculatedPickupRadius"); if (property != null && property.CanWrite) { property.SetValue(instance, item.Radius); } if (property2 != null && property2.CanWrite) { property2.SetValue(instance, item.Radius * Mathf.Sqrt(2f)); } Log.Debug("Set PickupSquareWidth + calculatedPickupRadius via reflection"); } else { PropertyInfo property3 = type.GetProperty("PickupRadius"); if (property3 != null && property3.CanWrite) { property3.SetValue(instance, item.Radius); } Log.Debug("Set PickupRadius via reflection"); } if ((Object)(object)instance.PickupAreaProjector != (Object)null) { float num = radius * 2f; instance.PickupAreaProjector.size = new Vector3(num, num, instance.PickupAreaProjector.size.z); Log.Debug($"Set projector size to ({num:F2}, {num:F2}, {instance.PickupAreaProjector.size.z:F2}) using PickupSquareWidth"); } VisualHelper.TintRenderers(((Component)instance).transform, item.Color, "Body"); break; } } } [HarmonyPatch(typeof(BagTrashCanBehaviour), "AreActionConditionsMet")] public static class Patch_BagTrashCanBehaviour_Conditions { public static void Postfix(BagTrashCanBehaviour __instance, ref bool __result) { if (!__result) { return; } TrashContainerItem val = ((__instance != null) ? __instance.TargetTrashCan : null); TrashContainer val2 = ((val != null) ? val.Container : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { string name = val.Name; if (!string.IsNullOrEmpty(name) && TrashCanVariants.All.Any((Variants v) => string.Equals(v.Name, name, StringComparison.OrdinalIgnoreCase)) && val2.TrashLevel < val2.TrashCapacity) { __result = false; } } } } [HarmonyPatch(typeof(BuildStart_Grid), "StartBuilding")] public static class Patch_BuildStartGrid_StartBuilding { public static bool Prepare() { return VersionHelper.IsBetaOrNewer; } public static void Postfix(ItemInstance itemInstance) { PreviewHelper.TrackPreviewVariant(itemInstance); } } [HarmonyPatch(typeof(DecalProjector), "OnEnable")] public static class Patch_DecalProjector_OnEnable { [CompilerGenerated] private sealed class <DelayedRadiusCheck>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DecalProjector projector; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedRadiusCheck>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; PreviewHelper.ApplyRadiusIfValid(projector); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool Prepare() { return VersionHelper.IsBetaOrNewer; } public static void Postfix(DecalProjector __instance) { MelonCoroutines.Start(DelayedRadiusCheck(__instance)); } [IteratorStateMachine(typeof(<DelayedRadiusCheck>d__2))] private static IEnumerator DelayedRadiusCheck(DecalProjector projector) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedRadiusCheck>d__2(0) { projector = projector }; } } [HarmonyPatch(typeof(DecalProjector), "OnDisable")] public static class Patch_DecalProjector_OnDisable { public static bool Prepare() { return VersionHelper.IsBetaOrNewer; } public static void Postfix(DecalProjector __instance) { Transform transform = ((Component)__instance).transform; Transform val = ((transform != null) ? transform.root : null); TrashContainer val2 = ((val != null) ? ((Component)val).GetComponentInChildren<TrashContainer>() : null); if (!((Object)(object)val2 == (Object)null)) { PreviewHelper.State.Current = null; Log.Debug("Cleared active preview variant after ghost disable."); } } } [HarmonyPatch(typeof(Property), "DoBoundsContainPoint")] public static class Patch_Manor_DoBoundsContainPoint { private static readonly Vector2[] skipBinPolygon = (Vector2[])(object)new Vector2[4] { new Vector2(174f, -63.5f), new Vector2(176f, -63.5f), new Vector2(176f, -60f), new Vector2(174f, -60f) }; public static bool Prepare() { return !VersionHelper.IsBetaOrNewer; } public static void Postfix(Property __instance, Vector3 point, ref bool __result) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((__instance.PropertyName == "Manor") & __result) { Vector2 point2 = default(Vector2); ((Vector2)(ref point2))..ctor(point.x, point.z); if (PointInPolygon(point2, skipBinPolygon)) { __result = false; } } } private static bool PointInPolygon(Vector2 point, Vector2[] polygon) { //IL_001d: 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_003b: 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) int num = polygon.Length - 1; bool flag = false; int num2 = 0; while (num2 < polygon.Length) { if (polygon[num2].y > point.y != polygon[num].y > point.y && point.x < (polygon[num].x - polygon[num2].x) * (point.y - polygon[num2].y) / (polygon[num].y - polygon[num2].y) + polygon[num2].x) { flag = !flag; } num = num2++; } return flag; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }
Mods/UpgradedTrashCans_Mono.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using ScheduleOne; using ScheduleOne.Building; using ScheduleOne.DevUtilities; using ScheduleOne.Equipping; using ScheduleOne.ItemFramework; using ScheduleOne.Levelling; using ScheduleOne.NPCs.Behaviour; using ScheduleOne.Networking; using ScheduleOne.ObjectScripts; using ScheduleOne.ObjectScripts.WateringCan; using ScheduleOne.Property; using ScheduleOne.Storage; using ScheduleOne.Trash; using ScheduleOne.UI.Items; using ScheduleOne.UI.Shop; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.Rendering.Universal; using UpgradedTrashCans; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "UpgradedTrashCans", "1.6.0", "j0ckinjz", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: AssemblyMetadata("NexusModID", "928")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("UnityEngine")] [assembly: AssemblyCompany("UpgradedTrashCans_Mono")] [assembly: AssemblyConfiguration("MONO")] [assembly: AssemblyFileVersion("1.6.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UpgradedTrashCans_Mono")] [assembly: AssemblyTitle("UpgradedTrashCans_Mono")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace UpgradedTrashCans { public class Core : MelonMod { public override void OnInitializeMelon() { Log.Msg("[UpgradedTrashCans] Game version: " + Application.version); if (VersionHelper.IsBetaOrNewer) { Log.Msg("[UpgradedTrashCans] Detected beta or newer version — using PickupSquareWidth"); } else { Log.Msg("[UpgradedTrashCans] Detected legacy version — using PickupRadius"); } ModManager.InitializeSettings(); Log.Msg("Mod Initialized. Version " + ((MelonBase)this).Info.Version); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (sceneName == "Main") { VariantSyncManager.SyncSettingsToVariants(); DefinitionTracker.ClearAll(); MelonCoroutines.Start(TrashInjector.InitializeShopListings()); } } } internal static class Log { public static void Msg(string msg) { Melon<Core>.Logger.Msg(msg); } public static void Warn(string msg) { Melon<Core>.Logger.Warning(msg); } public static void Error(string msg) { Melon<Core>.Logger.Error(msg); } public static void Debug(string message) { MelonPreferences_Entry<bool> debugLogs = ModManager.DebugLogs; if (debugLogs != null && debugLogs.Value) { Msg(message); } } } public static class TrashInjector { [CompilerGenerated] private sealed class <InitializeShopListings>d__0 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private List<ShopInterface> <hardwareStores>5__1; private BuildableItemDefinition <baseTrashCan>5__2; private TrashGrabberDefinition <baseGrabber>5__3; private List<ShopInterface>.Enumerator <>s__4; private ShopInterface <shop>5__5; private ShopInterface[] <>s__6; private int <>s__7; private ShopInterface <shop>5__8; private List<ItemRegister>.Enumerator <>s__9; private ItemRegister <entry>5__10; private List<Variants>.Enumerator <>s__11; private Variants <variant>5__12; private List<TrashGrabberVariant>.Enumerator <>s__13; private TrashGrabberVariant <variant>5__14; private List<ShopInterface>.Enumerator <>s__15; private ShopInterface <shop>5__16; private List<Variants>.Enumerator <>s__17; private Variants <variant>5__18; private ShopListing <listing>5__19; private List<TrashGrabberVariant>.Enumerator <>s__20; private TrashGrabberVariant <variant>5__21; private ShopListing <listing>5__22; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeShopListings>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <hardwareStores>5__1 = null; <baseTrashCan>5__2 = null; <baseGrabber>5__3 = null; <>s__4 = default(List<ShopInterface>.Enumerator); <shop>5__5 = null; <>s__6 = null; <shop>5__8 = null; <>s__9 = default(List<ItemRegister>.Enumerator); <entry>5__10 = null; <>s__11 = default(List<Variants>.Enumerator); <variant>5__12 = null; <>s__13 = default(List<TrashGrabberVariant>.Enumerator); <variant>5__14 = null; <>s__15 = default(List<ShopInterface>.Enumerator); <shop>5__16 = null; <>s__17 = default(List<Variants>.Enumerator); <variant>5__18 = null; <listing>5__19 = null; <>s__20 = default(List<TrashGrabberVariant>.Enumerator); <variant>5__21 = null; <listing>5__22 = null; <>1__state = -2; } private bool MoveNext() { //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Expected O, but got Unknown //IL_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Expected O, but got Unknown if (<>1__state != 0) { return false; } <>1__state = -1; Lobby instance = Singleton<Lobby>.Instance; if (instance != null && !instance.IsHost && !VariantSyncManager.HasReceivedHostVariants) { Log.Msg("[TrashInjector] Skipping injection — host mod is disabled or missing."); return false; } <hardwareStores>5__1 = new List<ShopInterface>(); try { <>s__4 = ShopInterface.AllShops.GetEnumerator(); try { while (<>s__4.MoveNext()) { <shop>5__5 = <>s__4.Current; if (IsValidHardwareStore(<shop>5__5)) { <hardwareStores>5__1.Add(<shop>5__5); } <shop>5__5 = null; } } finally { ((IDisposable)<>s__4).Dispose(); } <>s__4 = default(List<ShopInterface>.Enumerator); } catch { Log.Warn("[TrashInjector] Failed to access ShopInterface.AllShops — using fallback"); <>s__6 = Object.FindObjectsOfType<ShopInterface>(); for (<>s__7 = 0; <>s__7 < <>s__6.Length; <>s__7++) { <shop>5__8 = <>s__6[<>s__7]; if (IsValidHardwareStore(<shop>5__8)) { <hardwareStores>5__1.Add(<shop>5__8); } <shop>5__8 = null; } <>s__6 = null; } if (<hardwareStores>5__1.Count == 0) { Log.Warn("[TrashInjector] No hardware store interfaces found."); return false; } <baseTrashCan>5__2 = null; <baseGrabber>5__3 = null; <>s__9 = Singleton<Registry>.Instance.ItemRegistry.GetEnumerator(); try { while (<>s__9.MoveNext()) { <entry>5__10 = <>s__9.Current; if (<entry>5__10 != null && !((Object)(object)<entry>5__10.Definition == (Object)null)) { if (((Object)<entry>5__10.Definition).name == "TrashCan") { ref BuildableItemDefinition reference = ref <baseTrashCan>5__2; ItemDefinition definition = <entry>5__10.Definition; reference = (BuildableItemDefinition)(object)((definition is BuildableItemDefinition) ? definition : null); } else if (((Object)<entry>5__10.Definition).name == "TrashGrabber") { ref TrashGrabberDefinition reference2 = ref <baseGrabber>5__3; ItemDefinition definition2 = <entry>5__10.Definition; reference2 = (TrashGrabberDefinition)(object)((definition2 is TrashGrabberDefinition) ? definition2 : null); } if ((Object)(object)<baseTrashCan>5__2 != (Object)null && (Object)(object)<baseGrabber>5__3 != (Object)null) { break; } <entry>5__10 = null; } } } finally { ((IDisposable)<>s__9).Dispose(); } <>s__9 = default(List<ItemRegister>.Enumerator); if ((Object)(object)<baseTrashCan>5__2 != (Object)null) { <>s__11 = TrashCanVariants.All.GetEnumerator(); try { while (<>s__11.MoveNext()) { <variant>5__12 = <>s__11.Current; InjectCustomTrashCan(<baseTrashCan>5__2, <variant>5__12); <variant>5__12 = null; } } finally { ((IDisposable)<>s__11).Dispose(); } <>s__11 = default(List<Variants>.Enumerator); } if ((Object)(object)<baseGrabber>5__3 != (Object)null) { <>s__13 = TrashGrabberVariants.All.GetEnumerator(); try { while (<>s__13.MoveNext()) { <variant>5__14 = <>s__13.Current; InjectCustomTrashGrabber(<baseGrabber>5__3, <variant>5__14); <variant>5__14 = null; } } finally { ((IDisposable)<>s__13).Dispose(); } <>s__13 = default(List<TrashGrabberVariant>.Enumerator); } <>s__15 = <hardwareStores>5__1.GetEnumerator(); try { while (<>s__15.MoveNext()) { <shop>5__16 = <>s__15.Current; <>s__17 = TrashCanVariants.All.GetEnumerator(); try { while (<>s__17.MoveNext()) { <variant>5__18 = <>s__17.Current; if ((Object)(object)<variant>5__18?.Definition == (Object)null) { Log.Warn("Skipped injecting trash can variant " + <variant>5__18?.Name + " due to missing definition."); continue; } <listing>5__19 = new ShopListing { Item = (StorableItemDefinition)(object)<variant>5__18.Definition, name = <variant>5__18.Name, OverridePrice = true, OverriddenPrice = <variant>5__18.Price, CurrentStock = 999 }; <shop>5__16.Listings.Add(<listing>5__19); <shop>5__16.CreateListingUI(<listing>5__19); Log.Debug("Injected " + <variant>5__18.Name + " into shop."); <listing>5__19 = null; <variant>5__18 = null; } } finally { ((IDisposable)<>s__17).Dispose(); } <>s__17 = default(List<Variants>.Enumerator); <>s__20 = TrashGrabberVariants.All.GetEnumerator(); try { while (<>s__20.MoveNext()) { <variant>5__21 = <>s__20.Current; if ((Object)(object)<variant>5__21?.Definition == (Object)null) { Log.Warn("Skipped injecting trash grabber variant " + <variant>5__21?.Name + " due to missing definition."); continue; } <listing>5__22 = new ShopListing { Item = (StorableItemDefinition)(object)<variant>5__21.Definition, name = <variant>5__21.Name, OverridePrice = true, OverriddenPrice = <variant>5__21.Price, CurrentStock = 999 }; <shop>5__16.Listings.Add(<listing>5__22); <shop>5__16.CreateListingUI(<listing>5__22); Log.Debug("Injected " + <variant>5__21.Name + " into shop."); <listing>5__22 = null; <variant>5__21 = null; } } finally { ((IDisposable)<>s__20).Dispose(); } <>s__20 = default(List<TrashGrabberVariant>.Enumerator); <shop>5__16 = null; } } finally { ((IDisposable)<>s__15).Dispose(); } <>s__15 = default(List<ShopInterface>.Enumerator); Log.Msg("Upgraded items injected successfully into all Hardware Stores!"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<InitializeShopListings>d__0))] public static IEnumerator InitializeShopListings() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InitializeShopListings>d__0(0); } private static bool IsValidHardwareStore(ShopInterface shop) { if ((Object)(object)shop == (Object)null || shop.Listings == null || shop.Listings.Count == 0) { return false; } try { return ((Object)shop).name == "HardwareStoreInterface" || ((Object)shop).name == "HardwareStoreInterface (North Store)"; } catch { return false; } } private static void InjectCustomTrashCan(BuildableItemDefinition baseDef, Variants variant) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseDef == (Object)null || (Object)(object)baseDef.BuiltItem == (Object)null) { Log.Debug("Invalid base listing for trash can injection."); return; } BuildableItemDefinition val = Object.Instantiate<BuildableItemDefinition>(baseDef); ((ItemDefinition)val).Name = variant.Name; ((ItemDefinition)val).ID = variant.ID; ((ItemDefinition)val).Description = variant.Description; ((StorableItemDefinition)val).BasePurchasePrice = variant.Price; ((Object)val).name = variant.Name.Replace(" ", ""); ((StorableItemDefinition)val).RequiresLevelToPurchase = !variant.UnlockImmediately; if (!variant.UnlockImmediately) { ((StorableItemDefinition)val).RequiredRank = new FullRank(variant.RequiredRank, variant.Tier); } if ((Object)(object)((ItemDefinition)baseDef).Icon != (Object)null) { ((ItemDefinition)val).Icon = SpriteLoader.TintSprite(((ItemDefinition)baseDef).Icon, variant.Color, variant.Name + "_Icon"); } else { Log.Warn(((ItemDefinition)baseDef).Name + " has no icon."); } val.BuiltItem = baseDef.BuiltItem; DefinitionTracker.TrackDefinition((ItemDefinition)(object)val); variant.Definition = val; } private static void InjectCustomTrashGrabber(TrashGrabberDefinition baseDef, TrashGrabberVariant variant) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseDef == (Object)null || (Object)(object)((ItemDefinition)baseDef).Equippable == (Object)null) { Log.Debug("Invalid base listing for trash grabber injection."); return; } TrashGrabberDefinition val = Object.Instantiate<TrashGrabberDefinition>(baseDef); ((ItemDefinition)val).ID = variant.ID; ((ItemDefinition)val).Name = variant.Name; ((Object)val).name = variant.Name.Replace(" ", ""); ((ItemDefinition)val).Description = variant.Description; ((StorableItemDefinition)val).BasePurchasePrice = variant.Price; ((StorableItemDefinition)val).RequiresLevelToPurchase = !variant.UnlockImmediately; if (!variant.UnlockImmediately) { ((StorableItemDefinition)val).RequiredRank = new FullRank(variant.RequiredRank, variant.Tier); } if ((Object)(object)((ItemDefinition)baseDef).Icon != (Object)null) { ((ItemDefinition)val).Icon = SpriteLoader.TintSprite(((ItemDefinition)baseDef).Icon, variant.Color, variant.Name + "_Icon"); } else { Log.Debug(((ItemDefinition)baseDef).Name + " icon not found."); } ((ItemDefinition)val).Equippable = ((ItemDefinition)baseDef).Equippable; DefinitionTracker.TrackDefinition((ItemDefinition)(object)val); variant.Definition = val; } } public enum TrashCanType { Bin, Compactor } public class Variants { public string Name; public string ID; public float Price; public string Description; public int Capacity; public Color Color; public float Radius; public ERank RequiredRank; public int Tier; public BuildableItemDefinition Definition; public bool UnlockImmediately; public TrashCanType Type; } public static class TrashCanVariants { public static List<Variants> All = new List<Variants> { new Variants { Name = "Trash Bin", ID = "trash_bin", Description = "A slightly larger trash bin.", Price = 250f, Capacity = 40, Color = Color.green, Radius = 4.5f, RequiredRank = (ERank)1, Tier = 1, Type = TrashCanType.Bin }, new Variants { Name = "Trash Compactor", ID = "trash_compactor", Description = "A high-capacity trash compactor.", Price = 1000f, Capacity = 100, Color = Color.blue, Radius = 7.5f, RequiredRank = (ERank)3, Tier = 5, Type = TrashCanType.Compactor } }; } public class TrashGrabberVariant { public string Name; public string ID; public string Description; public float Price; public Color Color; public ERank RequiredRank; public int Tier; public bool UnlockImmediately; public int Capacity; public TrashGrabberDefinition Definition; } public static class TrashGrabberVariants { public static List<TrashGrabberVariant> All = new List<TrashGrabberVariant> { new TrashGrabberVariant { Name = "Trash Grabber Pro", ID = "trash_grabber_pro", Description = "An advanced trash grabber with increased capacity.", Price = 750f, Color = Color.cyan, RequiredRank = (ERank)3, Tier = 1, UnlockImmediately = false, Capacity = 50 } }; } public static class ColorExtensions { public static Color ToUnityColor(this ColorOption option) { //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_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_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_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_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_0051: 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_0059: 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_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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result = (Color)(option switch { ColorOption.Green => Color.green, ColorOption.Blue => Color.blue, ColorOption.Red => Color.red, ColorOption.Yellow => Color.yellow, ColorOption.Cyan => Color.cyan, ColorOption.Magenta => Color.magenta, ColorOption.Black => Color.black, _ => Color.white, }); if (1 == 0) { } return result; } public static Color ToUnityColor(this ExtendedColorOption option) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b8: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } Color result = (Color)(option switch { ExtendedColorOption.Purple => new Color(0.63f, 0.13f, 0.94f), ExtendedColorOption.Orange => new Color(1f, 0.65f, 0f), ExtendedColorOption.Pink => new Color(1f, 0.75f, 0.8f), ExtendedColorOption.Brown => new Color(0.6f, 0.3f, 0.15f), ExtendedColorOption.Lime => new Color(0.2f, 0.8f, 0.2f), ExtendedColorOption.Teal => new Color(0f, 0.5f, 0.5f), ExtendedColorOption.Indigo => new Color(0.29f, 0f, 0.51f), ExtendedColorOption.Violet => new Color(0.93f, 0.51f, 0.93f), _ => Color.white, }); if (1 == 0) { } return result; } public static bool TryParseRGB(string input, out Color color) { //IL_0002: 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) //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) color = Color.white; if (string.IsNullOrWhiteSpace(input)) { Log.Warn("RGB string is null or empty: \"" + input + "\""); return false; } string[] array = input.Split(','); if (array.Length != 3) { Log.Warn("RGB string does not contain 3 components: \"" + input + "\""); return false; } if (float.TryParse(array[0].TrimEnd('f'), out var result) && float.TryParse(array[1].TrimEnd('f'), out var result2) && float.TryParse(array[2].TrimEnd('f'), out var result3)) { color = new Color(result, result2, result3, 1f); return true; } Log.Warn("Failed to parse float values from RGB string: \"" + input + "\""); return false; } } public static class SpriteLoader { public static Sprite TintSprite(Sprite original, Color tint, string name = null) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0034: 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_003b: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0060: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_008d: 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_0099: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) Texture2D val = MakeReadableCopy(original.texture); Texture2D val2 = new Texture2D(((Texture)val).width, ((Texture)val).height, (TextureFormat)4, false); Color[] pixels = val.GetPixels(); for (int i = 0; i < pixels.Length; i++) { Color val3 = pixels[i]; Color val4 = Color.Lerp(val3, Color.black, 0.2f); float num = 0.3f * val3.r + 0.59f * val3.g + 0.11f * val3.b; Color val5 = Color.Lerp(val4, tint * num, 0.7f); pixels[i] = new Color(val5.r, val5.g, val5.b, val3.a); } val2.SetPixels(pixels); val2.Apply(); Sprite val6 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f)); if (!string.IsNullOrEmpty(name)) { ((Object)val6).name = name; } return val6; } private static Texture2D MakeReadableCopy(Texture2D source) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) RenderTexture temporary = RenderTexture.GetTemporary(((Texture)source).width, ((Texture)source).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1); Graphics.Blit((Texture)(object)source, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } } internal static class VisualHelper { public static void TintRenderers(Transform root, Color color, params string[] targetNames) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) IEnumerable<MeshRenderer> enumerable = from t in ((Component)root).GetComponentsInChildren<Transform>(true) where targetNames.Contains(((Object)t).name) select ((Component)t).GetComponent<MeshRenderer>() into r where (Object)(object)r != (Object)null select r; foreach (MeshRenderer item in enumerable) { ((Renderer)item).material.color = color; } } } public static class DefinitionTracker { private static readonly List<ItemDefinition> TrackedDefinitions = new List<ItemDefinition>(); public static void TrackDefinition(ItemDefinition def) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003c: Expected O, but got Unknown if (!((Object)(object)def == (Object)null)) { Singleton<Registry>.Instance.AddToRegistry(def); Singleton<Registry>.Instance.AddToItemDictionary(new ItemRegister { ID = def.ID, Definition = def }); Log.Debug("Tracking definition: " + def.ID); TrackedDefinitions.Add(def); } } public static void ClearAll() { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown foreach (ItemDefinition trackedDefinition in TrackedDefinitions) { Singleton<Registry>.Instance.RemoveFromRegistry(trackedDefinition); Singleton<Registry>.Instance.RemoveItemFromDictionary(new ItemRegister { ID = trackedDefinition.ID, Definition = trackedDefinition }); } TrackedDefinitions.Clear(); Log.Msg("Cleared all tracked definitions."); } } public static class PreviewHelper { public static class State { public static Variants? Current; } public static void TrackPreviewVariant(ItemInstance item) { if ((Object)(object)((item != null) ? item.Definition : null) == (Object)null) { State.Current = null; Log.Debug("[Preview] No definition found — cleared active variant."); return; } ItemDefinition def = item.Definition; Variants variants = (State.Current = TrashCanVariants.All.FirstOrDefault((Variants v) => (Object)(object)v.Definition == (Object)(object)def)); Log.Debug((variants != null) ? ("[Preview] Spawned ghost for variant: " + variants.ID) : "[Preview] Spawned ghost for base trash can or non-variant."); } public static void ApplyRadiusIfValid(DecalProjector projector) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)projector == (Object)null) { return; } Transform transform = ((Component)projector).transform; Transform val = ((transform != null) ? transform.root : null); GameObject val2 = ((val != null) ? ((Component)val).gameObject : null); if ((Object)(object)val2 == (Object)null) { return; } TrashContainer componentInChildren = ((Component)val).GetComponentInChildren<TrashContainer>(); if ((Object)(object)componentInChildren == (Object)null) { return; } if (((val != null) ? ((Object)val).name : null) != "_Temp") { Log.Debug("[Preview] Skipped DecalProjector — not part of a build preview."); return; } Variants current = State.Current; if (current != null) { float num = current.Radius * 2f; Vector3 size = projector.size; projector.size = new Vector3(num, num, size.z); Log.Debug($"[Preview] Radius set to {num:F2} for variant: {current.ID}"); } } } public enum ColorOption { Green, Blue, Red, Yellow, Cyan, Magenta, Black, White } public enum ExtendedColorOption { Purple, Orange, Pink, Brown, Lime, Teal, Indigo, Violet } public enum ColorSource { Standard, Extended, CustomRGB } public enum RankOption { Street_Rat, Hoodlum, Peddler, Hustler, Bagman, Enforcer, Shot_Caller, Block_Boss, Underlord, Baron, Kingpin } public static class ModManager { public class ModSettingsGroup { public MelonPreferences_Category Category; public MelonPreferences_Entry<ColorOption> Color; public MelonPreferences_Entry<ExtendedColorOption> ExtendedColor; public MelonPreferences_Entry<int> Capacity; public MelonPreferences_Entry<float> Radius; public MelonPreferences_Entry<RankOption> Rank; public MelonPreferences_Entry<int> Tier; public MelonPreferences_Entry<bool> UnlockImmediately; public MelonPreferences_Entry<float> Price; public MelonPreferences_Entry<string> CustomRGB; public MelonPreferences_Entry<ColorSource> Source; public void ApplyTo(Variants variant) { //IL_005a: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_0044: 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_004c: Unknown result type (might be due to invalid IL or missing references) variant.Price = Price.Value; ColorSource value = Source.Value; if (1 == 0) { } Color color; Color color2 = (Color)(value switch { ColorSource.CustomRGB => ColorExtensions.TryParseRGB(CustomRGB.Value, out color) ? color : Color.white, ColorSource.Extended => ExtendedColor.Value.ToUnityColor(), _ => Color.Value.ToUnityColor(), }); if (1 == 0) { } variant.Color = color2; variant.Capacity = Capacity.Value; variant.Radius = Radius.Value; variant.RequiredRank = (ERank)Rank.Value; variant.Tier = Tier.Value; variant.UnlockImmediately = UnlockImmediately.Value; } } public static ModSettingsGroup TrashBinSettings; public static ModSettingsGroup TrashCompactorSettings; public static MelonPreferences_Category DebugCategory; public static MelonPreferences_Category GrabberCategory; public static MelonPreferences_Entry<ColorSource> Grabber_Source; public static MelonPreferences_Entry<ColorOption> Grabber_Color; public static MelonPreferences_Entry<ExtendedColorOption> Grabber_ExtendedColor; public static MelonPreferences_Entry<int> Grabber_Capacity; public static MelonPreferences_Entry<RankOption> Grabber_Rank; public static MelonPreferences_Entry<int> Grabber_Tier; public static MelonPreferences_Entry<bool> Grabber_UnlockImmediately; public static MelonPreferences_Entry<float> Grabber_Price; public static MelonPreferences_Entry<string> Grabber_CustomRGB; public static MelonPreferences_Entry<bool> DebugLogs; public static void InitializeSettings() { TrashBinSettings = CreateGroup("01_TrashBin", "Upgraded Trash Bin", ColorOption.Green, ExtendedColorOption.Lime, 40, 4.5f, RankOption.Hoodlum, 1, unlockImmediately: false, 250f); TrashCompactorSettings = CreateGroup("02_TrashCompactor", "Upgraded Trash Compactor", ColorOption.Blue, ExtendedColorOption.Indigo, 100, 7.5f, RankOption.Hustler, 5, unlockImmediately: false, 1000f); GrabberCategory = MelonPreferences.CreateCategory("UpgradedTrashCans_03_UpgradedTrashGrabber", "Trash Grabber Pro"); Grabber_Price = GrabberCategory.CreateEntry<float>("01_Price", 750f, "Price", "Set the shop price for the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Capacity = GrabberCategory.CreateEntry<int>("02_Capacity", 50, "Capacity", "Set the capacity of the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Rank = GrabberCategory.CreateEntry<RankOption>("03_Rank", RankOption.Hustler, "Rank Unlock", "Required rank to unlock the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Tier = GrabberCategory.CreateEntry<int>("04_Tier", 1, "Tier Unlock", "Required tier at the rank to unlock the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_UnlockImmediately = GrabberCategory.CreateEntry<bool>("05_UnlockImmediately", false, "Unlock Immediately", "Skip rank requirement for Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_Source = GrabberCategory.CreateEntry<ColorSource>("06_ColorSource", ColorSource.Standard, "Color Source", "Choose which color mode to use (Base, Extended, Custom RGB).", false, false, (ValueValidator)null, (string)null); Grabber_Color = GrabberCategory.CreateEntry<ColorOption>("07_Color", ColorOption.Cyan, "Standard Colors", "Select the color of the Trash Grabber Pro.", false, false, (ValueValidator)null, (string)null); Grabber_ExtendedColor = GrabberCategory.CreateEntry<ExtendedColorOption>("08_ExtendedColor", ExtendedColorOption.Teal, "Extended Colors", "Custom expanded tints.", false, false, (ValueValidator)null, (string)null); Grabber_CustomRGB = GrabberCategory.CreateEntry<string>("09_CustomRGB", "0.5f, 0.5f, 0.5f", "Custom RGB Values", "Format: R,G,B (0–1 range)", false, false, (ValueValidator)null, (string)null); DebugCategory = MelonPreferences.CreateCategory("UpgradedTrashCans_04_DebugLogs", "Enable Debug Logging"); DebugLogs = DebugCategory.CreateEntry<bool>("01_Debug", false, "Enable Debug Logs", (string)null, false, false, (ValueValidator)null, (string)null); Log.Msg("ModManager Settings initialized."); } private static ModSettingsGroup CreateGroup(string keyPrefix, string displayName, ColorOption defaultColor, ExtendedColorOption defaultExtendedColor, int defaultCapacity, float defaultRadius, RankOption defaultRank, int defaultTier, bool unlockImmediately, float defaultPrice) { MelonPreferences_Category val = MelonPreferences.CreateCategory("UpgradedTrashCans_" + keyPrefix, displayName); return new ModSettingsGroup { Category = val, Price = val.CreateEntry<float>("01_Price", defaultPrice, "Price", "Shop purchase price for the " + displayName + ".", false, false, (ValueValidator)null, (string)null), Capacity = val.CreateEntry<int>("02_Capacity", defaultCapacity, "Capacity", "Number of trash items the " + displayName + " can hold.", false, false, (ValueValidator)null, (string)null), Radius = val.CreateEntry<float>("03_Radius", defaultRadius, "Cleaner Pickup Radius", "Cleaner pickup radius for the " + displayName + " (units).", false, false, (ValueValidator)null, (string)null), Rank = val.CreateEntry<RankOption>("04_Rank", defaultRank, "Rank Unlock", "Rank required to unlock the " + displayName + " in shop.", false, false, (ValueValidator)null, (string)null), Tier = val.CreateEntry<int>("05_Tier", defaultTier, "Tier Unlock", "Tier at required rank for the " + displayName + " to unlock.", false, false, (ValueValidator)null, (string)null), UnlockImmediately = val.CreateEntry<bool>("06_UnlockImmediately", unlockImmediately, "Unlock Immediately", "If true, the " + displayName + " is available immediately.", false, false, (ValueValidator)null, (string)null), Source = val.CreateEntry<ColorSource>("07_ColorSource", ColorSource.Standard, "Color Source", "Choose which color mode to use (Base, Extended, Custom RGB).", false, false, (ValueValidator)null, (string)null), Color = val.CreateEntry<ColorOption>("08_Color", defaultColor, "Standard Colors", "Color tint for the " + displayName + " model.", false, false, (ValueValidator)null, (string)null), ExtendedColor = val.CreateEntry<ExtendedColorOption>("09_ExtendedColor", defaultExtendedColor, "Extended Colors", "Expanded color tints for the " + displayName + " model.", false, false, (ValueValidator)null, (string)null), CustomRGB = val.CreateEntry<string>("10_CustomRGB", "0.5f, 0.5f, 0.5f", "Custom RGB Values", "Format: R,G,B (0–1 range)", false, false, (ValueValidator)null, (string)null) }; } } public static class VariantSyncManager { [CompilerGenerated] private sealed class <WaitForLobbyPayload>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private int <i>5__1; private string <payload>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForLobbyPayload>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <payload>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0036: 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_00aa: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <i>5__1 = 0; break; case 1: <>1__state = -1; <payload>5__2 = null; <i>5__1++; break; } if (<i>5__1 < 10) { <payload>5__2 = SteamMatchmaking.GetLobbyData(Singleton<Lobby>.Instance.LobbySteamID, "UpgradedTrashSync"); if (!string.IsNullOrEmpty(<payload>5__2)) { Log.Msg("[MultiplayerSync] Host sync payload found. Applying..."); OnLobbyMessageReceived(<payload>5__2); return false; } Log.Debug($"[MultiplayerSync] Waiting for host sync... ({<i>5__1 + 1}/{10})"); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } Log.Warn("[MultiplayerSync] Timed out waiting for host variant sync."); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string LobbyTagPrefix = "UpgradedTrashCans_Settings:"; private static readonly string CurrentSyncVersion = typeof(Core).Assembly.GetName().Version.ToString(); public static bool HasReceivedHostVariants { get; private set; } = false; public static void SyncSettingsToVariants() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected I4, but got Unknown //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected I4, but got Unknown Lobby instance = Singleton<Lobby>.Instance; bool flag = instance != null && instance.IsHost; Lobby instance2 = Singleton<Lobby>.Instance; int num; if (instance2 != null && !instance2.IsHost) { Lobby instance3 = Singleton<Lobby>.Instance; num = ((instance3 != null && instance3.IsInLobby) ? 1 : 0); } else { num = 0; } bool flag2 = (byte)num != 0; if (flag) { foreach (Variants item in TrashCanVariants.All) { if (item.Type == TrashCanType.Compactor) { ModManager.TrashCompactorSettings.ApplyTo(item); } else { ModManager.TrashBinSettings.ApplyTo(item); } Log.Debug($"Applied settings to {item.Name} — Capacity: {item.Capacity}, Color: {item.Color}"); } foreach (TrashGrabberVariant item2 in TrashGrabberVariants.All) { item2.Price = ModManager.Grabber_Price.Value; TrashGrabberVariant trashGrabberVariant = item2; ColorSource value = ModManager.Grabber_Source.Value; if (1 == 0) { } Color color; Color color2 = (Color)(value switch { ColorSource.CustomRGB => ColorExtensions.TryParseRGB(ModManager.Grabber_CustomRGB.Value, out color) ? color : Color.white, ColorSource.Extended => ModManager.Grabber_ExtendedColor.Value.ToUnityColor(), _ => ModManager.Grabber_Color.Value.ToUnityColor(), }); if (1 == 0) { } trashGrabberVariant.Color = color2; item2.Capacity = ModManager.Grabber_Capacity.Value; item2.RequiredRank = (ERank)ModManager.Grabber_Rank.Value; item2.Tier = ModManager.Grabber_Tier.Value; item2.UnlockImmediately = ModManager.Grabber_UnlockImmediately.Value; Log.Debug($"Applied settings to {item2.Name} — Capacity: {item2.Capacity}, Color: {item2.Color}, Unlock: {item2.UnlockImmediately}"); } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("UpgradedTrashCans_Settings:" + CurrentSyncVersion + "|"); foreach (Variants item3 in TrashCanVariants.All) { int num2 = (item3.UnlockImmediately ? 1 : 0); stringBuilder.Append($"{item3.ID}:{item3.Price},{item3.Capacity},{item3.Radius},{item3.Color.r:F2},{item3.Color.g:F2},{item3.Color.b:F2},{(int)item3.RequiredRank},{item3.Tier},{num2};"); } foreach (TrashGrabberVariant item4 in TrashGrabberVariants.All) { int num3 = (item4.UnlockImmediately ? 1 : 0); stringBuilder.Append($"{item4.ID}:{item4.Price},{item4.Capacity},0.0,{item4.Color.r:F2},{item4.Color.g:F2},{item4.Color.b:F2},{(int)item4.RequiredRank},{item4.Tier},{num3};"); } Singleton<Lobby>.Instance.SetLobbyData("UpgradedTrashSync", stringBuilder.ToString()); } else if (flag2) { MelonCoroutines.Start(WaitForLobbyPayload()); } else { foreach (Variants item5 in TrashCanVariants.All) { if (item5.Type == TrashCanType.Compactor) { ModManager.TrashCompactorSettings.ApplyTo(item5); } else { ModManager.TrashBinSettings.ApplyTo(item5); } } foreach (TrashGrabberVariant item6 in TrashGrabberVariants.All) { item6.Price = ModManager.Grabber_Price.Value; TrashGrabberVariant trashGrabberVariant2 = item6; ColorSource value2 = ModManager.Grabber_Source.Value; if (1 == 0) { } Color color3; Color color2 = (Color)(value2 switch { ColorSource.CustomRGB => ColorExtensions.TryParseRGB(ModManager.Grabber_CustomRGB.Value, out color3) ? color3 : Color.white, ColorSource.Extended => ModManager.Grabber_ExtendedColor.Value.ToUnityColor(), _ => ModManager.Grabber_Color.Value.ToUnityColor(), }); if (1 == 0) { } trashGrabberVariant2.Color = color2; item6.Capacity = ModManager.Grabber_Capacity.Value; item6.RequiredRank = (ERank)ModManager.Grabber_Rank.Value; item6.Tier = ModManager.Grabber_Tier.Value; item6.UnlockImmediately = ModManager.Grabber_UnlockImmediately.Value; } } VariantLookup.Refresh(); Log.Msg("Trash can and grabber settings synced."); } [IteratorStateMachine(typeof(<WaitForLobbyPayload>d__7))] private static IEnumerator WaitForLobbyPayload() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForLobbyPayload>d__7(0); } public static void OnLobbyMessageReceived(string rawMessage) { //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) if (!rawMessage.StartsWith("UpgradedTrashCans_Settings:")) { return; } string text = rawMessage.Substring("UpgradedTrashCans_Settings:".Length); string[] array = text.Split('|'); if (array.Length != 2) { Log.Error("[MultiplayerSync] Invalid payload format."); return; } string text2 = array[0]; string text3 = array[1]; if (text2 != CurrentSyncVersion) { Log.Warn("[MultiplayerSync] Host mod version (" + text2 + ") does not match client mod version (" + CurrentSyncVersion + ")."); return; } try { string[] array2 = text3.Split(';'); string[] array3 = array2; foreach (string text4 in array3) { if (string.IsNullOrWhiteSpace(text4)) { continue; } string[] array4 = text4.Split(':'); if (array4.Length != 2) { continue; } string id = array4[0]; string[] array5 = array4[1].Split(','); if (array5.Length != 9 || !float.TryParse(array5[0], out var result) || !int.TryParse(array5[1], out var result2) || !float.TryParse(array5[2], out var result3) || !float.TryParse(array5[3], out var result4) || !float.TryParse(array5[4], out var result5) || !float.TryParse(array5[5], out var result6) || !int.TryParse(array5[6], out var result7) || !int.TryParse(array5[7], out var result8) || !int.TryParse(array5[8], out var result9)) { continue; } Variants variants = TrashCanVariants.All.FirstOrDefault((Variants v) => v.ID == id); if (variants != null) { variants.Price = result; variants.Capacity = result2; variants.Radius = result3; variants.Color = new Color(result4, result5, result6); variants.RequiredRank = (ERank)result7; variants.Tier = result8; variants.UnlockImmediately = result9 == 1; continue; } TrashGrabberVariant trashGrabberVariant = TrashGrabberVariants.All.FirstOrDefault((TrashGrabberVariant v) => v.ID == id); if (trashGrabberVariant != null) { trashGrabberVariant.Price = result; trashGrabberVariant.Capacity = result2; trashGrabberVariant.Color = new Color(result4, result5, result6); trashGrabberVariant.RequiredRank = (ERank)result7; trashGrabberVariant.Tier = result8; trashGrabberVariant.UnlockImmediately = result9 == 1; } } VariantLookup.Refresh(); HasReceivedHostVariants = true; Log.Msg("[MultiplayerSync] Synced variant settings received from host."); } catch (Exception ex) { Log.Error("[MultiplayerSync] Failed to parse variant sync message: " + ex.Message); } } } public static class VersionHelper { public static readonly string RawVersion = Application.version; public static readonly Version ParsedVersion = ParseVersion(RawVersion); public static readonly bool IsBetaOrNewer = ParsedVersion >= new Version(0, 3, 6); private static Version ParseVersion(string input) { string input2 = input.Split(' ')[0].Split('f')[0]; Version result; return Version.TryParse(input2, out result) ? result : new Version(0, 0, 0); } } public static class VariantLookup { public static HashSet<string> KnownGrabberIDs { get; private set; } = new HashSet<string>(); public static Dictionary<string, TrashGrabberVariant> GrabberByID { get; private set; } = new Dictionary<string, TrashGrabberVariant>(); public static void Refresh() { KnownGrabberIDs = TrashGrabberVariants.All.Select((TrashGrabberVariant v) => v.ID).ToHashSet(); GrabberByID = TrashGrabberVariants.All.ToDictionary((TrashGrabberVariant v) => v.ID); } } [HarmonyPatch(typeof(Equippable_TrashGrabber), "GetCapacity")] public static class Patch_TrashGrabber_GetCapacity { public static void Postfix(Equippable_TrashGrabber __instance, ref int __result) { object obj; if (__instance == null) { obj = null; } else { ItemInstance itemInstance = ((Equippable)__instance).itemInstance; obj = ((itemInstance != null) ? itemInstance.Definition : null); } ItemDefinition val = (ItemDefinition)obj; if (val != null && val.ID != null && VariantLookup.KnownGrabberIDs.Contains(val.ID) && VariantLookup.GrabberByID.TryGetValue(val.ID, out var value)) { TrashGrabberInstance trashGrabberInstance = __instance.trashGrabberInstance; int num = ((trashGrabberInstance != null) ? trashGrabberInstance.GetTotalSize() : 0); __result = Mathf.Max(0, value.Capacity - num); } } } [HarmonyPatch(typeof(Equippable_TrashGrabber), "RefreshVisuals")] public static class Patch_TrashGrabber_RefreshVisuals { public static void Postfix(Equippable_TrashGrabber __instance) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance?.TrashContent == (Object)null) && !((Object)(object)__instance.TrashContent_Min == (Object)null) && !((Object)(object)__instance.TrashContent_Max == (Object)null)) { ItemInstance itemInstance = ((Equippable)__instance).itemInstance; ItemDefinition val = ((itemInstance != null) ? itemInstance.Definition : null); if (val != null && val.ID != null && VariantLookup.KnownGrabberIDs.Contains(val.ID) && VariantLookup.GrabberByID.TryGetValue(val.ID, out var value)) { TrashGrabberInstance trashGrabberInstance = __instance.trashGrabberInstance; int num = ((trashGrabberInstance != null) ? trashGrabberInstance.GetTotalSize() : 0); float num2 = Mathf.Clamp01((float)num / (float)value.Capacity); Vector3 val2 = __instance.TrashContent_Max.localPosition - __instance.TrashContent_Min.localPosition; Vector3 localPosition = __instance.TrashContent_Min.localPosition; __instance.TrashContent.localPosition = localPosition + val2 * num2; VisualHelper.TintRenderers(((Component)__instance).transform, value.Color, "Body", "Trigger"); } } } } [HarmonyPatch(typeof(TrashGrabberItemUI), "UpdateUI")] public static class Patch_TrashGrabberItemUI_UpdateUI { public static void Postfix(TrashGrabberItemUI __instance) { if ((Object)(object)__instance == (Object)null) { return; } TextMeshProUGUI valueLabel = __instance.ValueLabel; ItemInstance itemInstance = ((ItemUI)__instance).itemInstance; ItemDefinition val = ((itemInstance != null) ? itemInstance.Definition : null); if (!((Object)(object)valueLabel == (Object)null) && val != null && val.ID != null && VariantLookup.KnownGrabberIDs.Contains(val.ID) && VariantLookup.GrabberByID.TryGetValue(val.ID, out var value)) { TrashGrabberInstance trashGrabberInstance = __instance.trashGrabberInstance; if (trashGrabberInstance != null) { float num = Mathf.Clamp01((float)trashGrabberInstance.GetTotalSize() / (float)value.Capacity); ((TMP_Text)valueLabel).text = $"{Mathf.RoundToInt(num * 100f)}%"; } } } } [HarmonyPatch(typeof(StorageVisualizer), "RefreshVisuals")] public static class Patch_StorageVisualizer_RefreshVisuals { public static void Postfix(StorageVisualizer __instance) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) StoredItem[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<StoredItem>(true); StoredItem[] array = componentsInChildren; foreach (StoredItem val in array) { StorableItemInstance item = val.item; if (((item == null) ? null : ((ItemInstance)item).Definition?.ID) != null && VariantLookup.GrabberByID.TryGetValue(((ItemInstance)item).Definition.ID, out var value)) { VisualHelper.TintRenderers(((Component)val).transform, value.Color, "Body", "Trigger"); } } } } [HarmonyPatch(typeof(TrashContainerItem), "Start")] public static class Patch_TrashContainerItem_Start { [CompilerGenerated] private sealed class <WaitForValidName>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TrashContainerItem instance; private int <attempts>5__1; private string <name>5__2; private Exception <ex>5__3; private int <i>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForValidName>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <name>5__2 = null; <ex>5__3 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; <i>5__4++; goto IL_0116; } <>1__state = -1; <attempts>5__1 = 0; goto IL_012d; IL_0116: if (<i>5__4 < 2) { <>2__current = null; <>1__state = 1; return true; } <name>5__2 = null; goto IL_012d; IL_012d: if (<attempts>5__1 < 10) { <name>5__2 = null; try { TrashContainerItem obj = instance; <name>5__2 = ((obj != null) ? obj.Name : null); } catch (Exception ex) { <ex>5__3 = ex; Log.Debug($"Exception accessing Name on attempt {<attempts>5__1 + 1}: {<ex>5__3.Message}"); } if (!string.IsNullOrWhiteSpace(<name>5__2)) { ApplyVariantSettings(instance, <name>5__2); return false; } <attempts>5__1++; Log.Debug($"Name was null or errored on attempt {<attempts>5__1}/{10}. Retrying after {2} frames..."); <i>5__4 = 0; goto IL_0116; } Log.Debug("Name remained null after all retry attempts."); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static void Postfix(TrashContainerItem __instance) { MelonCoroutines.Start(WaitForValidName(__instance)); } [IteratorStateMachine(typeof(<WaitForValidName>d__1))] private static IEnumerator WaitForValidName(TrashContainerItem instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForValidName>d__1(0) { instance = instance }; } private static void ApplyVariantSettings(TrashContainerItem instance, string name) { //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) TrashContainer val = default(TrashContainer); foreach (Variants item in TrashCanVariants.All) { if (!string.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase)) { continue; } if (((Component)instance).TryGetComponent<TrashContainer>(ref val)) { val.TrashCapacity = item.Capacity; } float radius = item.Radius; Type type = ((object)instance).GetType(); if (VersionHelper.IsBetaOrNewer) { PropertyInfo property = type.GetProperty("PickupSquareWidth"); PropertyInfo property2 = type.GetProperty("calculatedPickupRadius"); if (property != null && property.CanWrite) { property.SetValue(instance, item.Radius); } if (property2 != null && property2.CanWrite) { property2.SetValue(instance, item.Radius * Mathf.Sqrt(2f)); } Log.Debug("Set PickupSquareWidth + calculatedPickupRadius via reflection"); } else { PropertyInfo property3 = type.GetProperty("PickupRadius"); if (property3 != null && property3.CanWrite) { property3.SetValue(instance, item.Radius); } Log.Debug("Set PickupRadius via reflection"); } if ((Object)(object)instance.PickupAreaProjector != (Object)null) { float num = radius * 2f; instance.PickupAreaProjector.size = new Vector3(num, num, instance.PickupAreaProjector.size.z); Log.Debug($"Set projector size to ({num:F2}, {num:F2}, {instance.PickupAreaProjector.size.z:F2}) using PickupSquareWidth"); } VisualHelper.TintRenderers(((Component)instance).transform, item.Color, "Body"); break; } } } [HarmonyPatch(typeof(BagTrashCanBehaviour), "AreActionConditionsMet")] public static class Patch_BagTrashCanBehaviour_Conditions { public static void Postfix(BagTrashCanBehaviour __instance, ref bool __result) { if (!__result) { return; } TrashContainerItem val = ((__instance != null) ? __instance.TargetTrashCan : null); TrashContainer val2 = val?.Container; if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { string name = val.Name; if (!string.IsNullOrEmpty(name) && TrashCanVariants.All.Any((Variants v) => string.Equals(v.Name, name, StringComparison.OrdinalIgnoreCase)) && val2.TrashLevel < val2.TrashCapacity) { __result = false; } } } } [HarmonyPatch(typeof(BuildStart_Grid), "StartBuilding")] public static class Patch_BuildStartGrid_StartBuilding { public static bool Prepare() { return VersionHelper.IsBetaOrNewer; } public static void Postfix(ItemInstance itemInstance) { PreviewHelper.TrackPreviewVariant(itemInstance); } } [HarmonyPatch(typeof(DecalProjector), "OnEnable")] public static class Patch_DecalProjector_OnEnable { [CompilerGenerated] private sealed class <DelayedRadiusCheck>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DecalProjector projector; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedRadiusCheck>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; PreviewHelper.ApplyRadiusIfValid(projector); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool Prepare() { return VersionHelper.IsBetaOrNewer; } public static void Postfix(DecalProjector __instance) { MelonCoroutines.Start(DelayedRadiusCheck(__instance)); } [IteratorStateMachine(typeof(<DelayedRadiusCheck>d__2))] private static IEnumerator DelayedRadiusCheck(DecalProjector projector) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedRadiusCheck>d__2(0) { projector = projector }; } } [HarmonyPatch(typeof(DecalProjector), "OnDisable")] public static class Patch_DecalProjector_OnDisable { public static bool Prepare() { return VersionHelper.IsBetaOrNewer; } public static void Postfix(DecalProjector __instance) { Transform transform = ((Component)__instance).transform; Transform val = ((transform != null) ? transform.root : null); TrashContainer val2 = ((val != null) ? ((Component)val).GetComponentInChildren<TrashContainer>() : null); if (!((Object)(object)val2 == (Object)null)) { PreviewHelper.State.Current = null; Log.Debug("Cleared active preview variant after ghost disable."); } } } [HarmonyPatch(typeof(Property), "DoBoundsContainPoint")] public static class Patch_Manor_DoBoundsContainPoint { private static readonly Vector2[] skipBinPolygon = (Vector2[])(object)new Vector2[4] { new Vector2(174f, -63.5f), new Vector2(176f, -63.5f), new Vector2(176f, -60f), new Vector2(174f, -60f) }; public static bool Prepare() { return !VersionHelper.IsBetaOrNewer; } public static void Postfix(Property __instance, Vector3 point, ref bool __result) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((__instance.PropertyName == "Manor") & __result) { Vector2 point2 = default(Vector2); ((Vector2)(ref point2))..ctor(point.x, point.z); if (PointInPolygon(point2, skipBinPolygon)) { __result = false; } } } private static bool PointInPolygon(Vector2 point, Vector2[] polygon) { //IL_001d: 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_003b: 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) int num = polygon.Length - 1; bool flag = false; int num2 = 0; while (num2 < polygon.Length) { if (polygon[num2].y > point.y != polygon[num].y > point.y && point.x < (polygon[num].x - polygon[num2].x) * (point.y - polygon[num2].y) / (polygon[num].y - polygon[num2].y) + polygon[num2].x) { flag = !flag; } num = num2++; } return flag; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }