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.2
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.Audio; 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.Storage; using Il2CppScheduleOne.Trash; using Il2CppScheduleOne.UI.Items; using Il2CppScheduleOne.UI.Shop; using Il2CppSteamworks; using Il2CppSystem.Collections; 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.2", "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.2")] [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.2.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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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() { 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()); } } public override void OnUpdate() { TrashGrabberRadiusManager.Update(); } } 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 TrashGrabberExtensions { [CompilerGenerated] private sealed class <DelayedUIUpdate>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Equippable_TrashGrabber grabber; private IEnumerator<TrashGrabberItemUI> <>s__1; private TrashGrabberItemUI <ui>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedUIUpdate>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; <ui>5__2 = null; <>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; <>s__1 = Object.FindObjectsOfType<TrashGrabberItemUI>().GetEnumerator(); try { while (<>s__1.MoveNext()) { <ui>5__2 = <>s__1.Current; if (((ItemUI)<ui>5__2).itemInstance == ((Equippable)grabber).itemInstance) { ((ItemUI)<ui>5__2).UpdateUI(); break; } <ui>5__2 = null; } } finally { if (<>s__1 != null) { <>s__1.Dispose(); } } <>s__1 = null; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpawnTrashStack>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public List<Entry> entries; public Vector3 basePos; public Equippable_TrashGrabber grabber; private List<Entry>.Enumerator <>s__1; private Entry <entry>5__2; private string <id>5__3; private int <quantity>5__4; private int <i>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnTrashStack>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = default(List<Entry>.Enumerator); <entry>5__2 = null; <id>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; <i>5__5++; goto IL_010b; } <>1__state = -1; <>s__1 = entries.GetEnumerator(); <>1__state = -3; goto IL_0131; IL_010b: if (<i>5__5 < <quantity>5__4) { NetworkSingleton<TrashManager>.Instance.CreateTrashItem(<id>5__3, basePos, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), Vector3.down * 7f, Guid.NewGuid().ToString(), false); <>2__current = null; <>1__state = 1; return true; } <id>5__3 = null; <entry>5__2 = null; goto IL_0131; IL_0131: if (<>s__1.MoveNext()) { <entry>5__2 = <>s__1.Current; <id>5__3 = <entry>5__2.TrashID; <quantity>5__4 = <entry>5__2.Quantity; <i>5__5 = 0; goto IL_010b; } <>m__Finally1(); <>s__1 = default(List<Entry>.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static void EjectAllTrashNow(Equippable_TrashGrabber grabber) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) object obj; if (grabber == null) { obj = null; } else { ItemInstance itemInstance = ((Equippable)grabber).itemInstance; obj = ((itemInstance != null) ? itemInstance.ID : null); } if (obj == null || !VariantLookup.GrabberByID.TryGetValue(((Equippable)grabber).itemInstance.ID, out var value) || value.ID != "trash_grabber_pro") { return; } object obj2; if (grabber == null) { obj2 = null; } else { TrashGrabberInstance trashGrabberInstance = grabber.trashGrabberInstance; if (trashGrabberInstance == null) { obj2 = null; } else { TrashContent content = trashGrabberInstance.Content; obj2 = ((content != null) ? content.Entries : null); } } if (obj2 == null) { return; } TrashContent content2 = grabber.trashGrabberInstance.Content; if (content2.Entries.Count != 0) { Vector3 basePos = ((Component)grabber).transform.TransformPoint(grabber.TrashDropOffset) + ((Component)grabber).transform.forward * 1f; List<Entry> list = new List<Entry>(); Enumerator<Entry> enumerator = content2.Entries.GetEnumerator(); while (enumerator.MoveNext()) { Entry current = enumerator.Current; list.Add(current); } content2.Clear(); grabber.RefreshVisuals(); AudioSourceController trashDropSound = grabber.TrashDropSound; if (trashDropSound != null) { trashDropSound.Play(); } MelonCoroutines.Start(DelayedUIUpdate(grabber)); MelonCoroutines.Start(SpawnTrashStack(list, basePos, grabber)); } } [IteratorStateMachine(typeof(<DelayedUIUpdate>d__1))] private static IEnumerator DelayedUIUpdate(Equippable_TrashGrabber grabber) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedUIUpdate>d__1(0) { grabber = grabber }; } [IteratorStateMachine(typeof(<SpawnTrashStack>d__2))] private static IEnumerator SpawnTrashStack(List<Entry> entries, Vector3 basePos, Equippable_TrashGrabber grabber) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnTrashStack>d__2(0) { entries = entries, basePos = basePos, grabber = grabber }; } } public static class TrashGrabberRadiusManager { private static GameObject? cachedProjector; private static Equippable_TrashGrabber? activeGrabber; private static AudioSource? clickSource; private static AudioSource? whooshSource; private static bool soundPlayedThisCycle = false; private static float nextPickupTime = 0f; private const float pickupCooldown = 0.15f; public static MelonPreferences_Entry<float> Grabber_Radius; private static readonly int GroundMask = LayerMask.GetMask(new string[4] { "Default", "Ground", "Terrain", "Environment" }); private static readonly KeyCode toggleKey = (KeyCode)114; private static readonly KeyCode pickupKey = (KeyCode)101; private static bool radiusModeEnabled => ModManager.Grabber_RadiusModeEnabled.Value; public static Vector2 XZ(this Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2(v.x, v.z); } public static void Update() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) if (!ModManager.Grabber_RadiusPickup.Value) { return; } if (Input.GetKeyDown(toggleKey) && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { bool flag = !ModManager.Grabber_RadiusModeEnabled.Value; ModManager.Grabber_RadiusModeEnabled.Value = flag; Log.Msg("[RadiusManager] Radius mode " + (flag ? "enabled" : "disabled") + "."); } if ((Object)(object)activeGrabber != (Object)null) { Transform val = ((Component)activeGrabber).transform.Find("GrabberRadiusProjector"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(radiusModeEnabled); RaycastHit val2 = default(RaycastHit); if (radiusModeEnabled && Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val2, 10f, GroundMask)) { ((Component)val).transform.position = new Vector3(((RaycastHit)(ref val2)).point.x, ((RaycastHit)(ref val2)).point.y + 0.03f, ((RaycastHit)(ref val2)).point.z); ((Component)val).transform.rotation = Quaternion.LookRotation(Vector3.down); } } } if (radiusModeEnabled && !((Object)(object)activeGrabber == (Object)null) && Input.GetKeyDown(pickupKey) && Time.time >= nextPickupTime) { nextPickupTime = Time.time + 0.15f; PerformRadiusPickup(activeGrabber); } } public static void RegisterActiveGrabber(Equippable_TrashGrabber grabber) { Il2CppArrayBase<AudioSource> componentsInChildren = ((Component)grabber).GetComponentsInChildren<AudioSource>(true); foreach (AudioSource item in componentsInChildren) { if (!((Object)(object)item == (Object)null)) { string name = ((Object)((Component)item).gameObject).name; if (name == "Clicksound" && (Object)(object)clickSource == (Object)null) { clickSource = item; Log.Debug("[RadiusManager] Cached Clicksound AudioSource"); } else if (name == "Whoosh sound" && (Object)(object)whooshSource == (Object)null) { whooshSource = item; Log.Debug("[RadiusManager] Cached Whoosh AudioSource"); } } } ItemInstance itemInstance = ((Equippable)grabber).itemInstance; if (!(((itemInstance != null) ? itemInstance.ID : null) != "trash_grabber_pro")) { activeGrabber = grabber; EnsureProjectorAttached(grabber); } } private static void EnsureProjectorAttached(Equippable_TrashGrabber grabber) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)grabber).transform.Find("GrabberRadiusProjector") != (Object)null) { return; } if ((Object)(object)cachedProjector == (Object)null) { GameObject val = FindProjectorFromAnyTrashBag(); if (!((Object)(object)val != (Object)null)) { Log.Warn("[RadiusManager] Could not find projector."); return; } cachedProjector = Object.Instantiate<GameObject>(val); cachedProjector.SetActive(false); Object.DontDestroyOnLoad((Object)(object)cachedProjector); Log.Debug("[RadiusManager] Cached projector from memory."); } GameObject val2 = Object.Instantiate<GameObject>(cachedProjector, ((Component)grabber).transform); ((Object)val2).name = "GrabberRadiusProjector"; val2.SetActive(radiusModeEnabled); val2.layer = ((Component)grabber).gameObject.layer; DecalProjector val3 = default(DecalProjector); if (val2.TryGetComponent<DecalProjector>(ref val3)) { float num = Mathf.Clamp(ModManager.Grabber_Radius.Value, 0.5f, 3f); float num2 = num * 2f; val3.size = new Vector3(num2, num2, 0.5f); } Log.Debug("[RadiusManager] Projector attached to grabber."); } private static GameObject? FindProjectorFromAnyTrashBag() { Il2CppArrayBase<TrashBag_Equippable> val = Resources.FindObjectsOfTypeAll<TrashBag_Equippable>(); foreach (TrashBag_Equippable item in val) { if (!((Object)(object)item == (Object)null)) { if ((Object)(object)item.PickupAreaProjector != (Object)null) { Log.Debug("[RadiusManager] Found PickupAreaProjector on bag."); return ((Component)item.PickupAreaProjector).gameObject; } Transform val2 = FindChildRecursive(((Component)item).transform, "CircleProjector"); if ((Object)(object)val2 != (Object)null) { Log.Debug("[RadiusManager] Found fallback CircleProjector."); return ((Component)val2).gameObject; } } } return null; } private static void PerformRadiusPickup(Equippable_TrashGrabber grabber) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) TrashManager instance = NetworkSingleton<TrashManager>.Instance; List<TrashItem> val = ((instance != null) ? instance.trashItems : null); if (val == null || grabber.trashGrabberInstance == null) { return; } List<TrashItem> list = new List<TrashItem>(val.Count); for (int i = 0; i < val.Count; i++) { if ((Object)(object)val[i] != (Object)null) { list.Add(val[i]); } } Transform val2 = ((Component)grabber).transform.Find("GrabberRadiusProjector"); if ((Object)(object)val2 == (Object)null) { return; } Vector3 position = val2.position; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(position.x, position.z); float num = Mathf.Clamp(ModManager.Grabber_Radius.Value, 0.5f, 3f); float num2 = num * num; int num3 = 0; Vector2 val6 = default(Vector2); for (int j = 0; j < list.Count; j++) { TrashItem val4 = list[j]; Collider component = ((Component)val4).GetComponent<Collider>(); Vector3 val5 = ((component != null) ? component.ClosestPoint(position) : ((Component)val4).transform.position); ((Vector2)(ref val6))..ctor(val5.x, val5.z); Vector2 val7 = val6 - val3; if (!(((Vector2)(ref val7)).sqrMagnitude > num2)) { if (ForcePickup(grabber, val4)) { num3++; } else { Log.Debug("[RadiusManager] ForcePickup failed for " + ((Object)val4).name); } if (grabber.GetCapacity() <= 0) { break; } } } if (num3 > 0) { Log.Msg($"[RadiusManager] Picked up {num3} items."); } } private static bool ForcePickup(Equippable_TrashGrabber grabber, TrashItem item) { soundPlayedThisCycle = false; string text = item.ID ?? ((Object)item).name; if (string.IsNullOrEmpty(text)) { Log.Debug("[ForcePickup] Failed: item ID missing for " + ((Object)item).name); return false; } TrashGrabberInstance trashGrabberInstance = grabber.trashGrabberInstance; if (trashGrabberInstance == null) { Log.Debug("[ForcePickup] Failed: grabber instance null"); return false; } int capacity = grabber.GetCapacity(); if (capacity <= 0) { return false; } trashGrabberInstance.AddTrash(text, 1); int capacity2 = grabber.GetCapacity(); if (capacity2 >= capacity) { return false; } NetworkSingleton<TrashManager>.Instance.DestroyTrash(item); if (!soundPlayedThisCycle) { RandomizedAudioSourceController val = default(RandomizedAudioSourceController); if ((Object)(object)clickSource != (Object)null && ((Component)clickSource).TryGetComponent<RandomizedAudioSourceController>(ref val)) { ((AudioSourceController)val).Play(); } RandomizedAudioSourceController val2 = default(RandomizedAudioSourceController); if ((Object)(object)whooshSource != (Object)null && ((Component)whooshSource).TryGetComponent<RandomizedAudioSourceController>(ref val2)) { ((AudioSourceController)val2).Play(); } soundPlayedThisCycle = true; } return true; } private static Transform? FindChildRecursive(Transform root, string name) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown IEnumerator enumerator = root.GetEnumerator(); try { while (enumerator.MoveNext()) { Transform val = (Transform)enumerator.Current; if (((Object)val).name == name) { return val; } Transform val2 = FindChildRecursive(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } } finally { if (enumerator is IDisposable disposable) { disposable.Dispose(); } } return null; } } 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) 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)) { 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_Category _UpgradedTrashCansSettings; 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> Grabber_BulkEject; public static MelonPreferences_Entry<bool> Grabber_RadiusPickup; public static MelonPreferences_Entry<float> Grabber_Radius; public static MelonPreferences_Entry<bool> Grabber_RadiusModeEnabled; 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); Grabber_BulkEject = GrabberCategory.CreateEntry<bool>("10_Enable Bulk Eject", true, "Enable Shift+Click Eject All", (string)null, false, false, (ValueValidator)null, (string)null); Grabber_RadiusPickup = GrabberCategory.CreateEntry<bool>("11_EnableRadiusPickup", true, "Enable Radius Toggle (Shift+R)", "Adds a pickup radius.", false, false, (ValueValidator)null, (string)null); Grabber_Radius = GrabberCategory.CreateEntry<float>("12_GrabberRadius", 1f, "Grabber Radius (0.5 - 3)", "Adjusts the size of the pickup radius.", 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); _UpgradedTrashCansSettings = MelonPreferences.CreateCategory("xUpgradedTrashCansSettings"); Grabber_RadiusModeEnabled = _UpgradedTrashCansSettings.CreateEntry<bool>("RadiusModeEnabled", false, (string)null, (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_0768: Unknown result type (might be due to invalid IL or missing references) //IL_076d: 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_078a: Unknown result type (might be due to invalid IL or missing references) //IL_078c: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: 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_0758: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0780: 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_075a: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: 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); int value4 = (ModManager.Grabber_BulkEject.Value ? 1 : 0); int value5 = (ModManager.Grabber_RadiusPickup.Value ? 1 : 0); float value6 = Mathf.Clamp(ModManager.Grabber_Radius.Value, 0.5f, 3f); StringBuilder stringBuilder2 = stringBuilder; StringBuilder stringBuilder4 = stringBuilder2; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(16, 12, 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(","); handler.AppendFormatted(value4); handler.AppendLiteral(","); handler.AppendFormatted(value5); handler.AppendLiteral(","); handler.AppendFormatted(value6, "F2"); 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 value7 = ModManager.Grabber_Source.Value; if (1 == 0) { } Color color3; Color color2 = (Color)(value7 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_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) 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 != 12 || !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) || !int.TryParse(array5[9], out var result10) || !int.TryParse(array5[10], out var result11) || !float.TryParse(array5[11], out var result12)) { 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; ModManager.Grabber_BulkEject.Value = result10 == 1; ModManager.Grabber_RadiusPickup.Value = result11 == 1; ModManager.Grabber_Radius.Value = Mathf.Clamp(result12, 0.5f, 3f); } } 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 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), "Update")] public static class Patch_TrashGrabber_Update { public static bool Prefix(Equippable_TrashGrabber __instance) { if (!Equippable_TrashGrabber.IsEquipped) { return true; } if (!ModManager.Grabber_BulkEject.Value) { return true; } ItemInstance itemInstance = ((Equippable)__instance).itemInstance; if (((itemInstance != null) ? itemInstance.ID : null) == null || !VariantLookup.GrabberByID.TryGetValue(((Equippable)__instance).itemInstance.ID, out var value) || value.ID != "trash_grabber_pro") { return true; } if (Input.GetMouseButtonDown(0) && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { TrashGrabberExtensions.EjectAllTrashNow(__instance); return false; } return true; } public static void Postfix(Equippable_TrashGrabber __instance) { TrashGrabberRadiusManager.RegisterActiveGrabber(__instance); } } [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($"[TrashContainerItem Start] 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($"[TrashContainerItem Start] Name was null or errored on attempt {<attempts>5__1}/{10}. Retrying after {2} frames..."); <i>5__4 = 0; goto IL_018a; } Log.Debug("[TrashContainerItem Start] 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) { if (!((Object)(object)__instance == (Object)null)) { TrashContainer component = ((Component)__instance).GetComponent<TrashContainer>(); if (!((Object)(object)component == (Object)null)) { 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) 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 num = (instance.PickupSquareWidth = item.Radius); instance.calculatedPickupRadius = num * Mathf.Sqrt(2f); if ((Object)(object)instance.PickupAreaProjector != (Object)null) { float num2 = num * 2f; instance.PickupAreaProjector.size = new Vector3(num2, num2, instance.PickupAreaProjector.size.z); Log.Debug($"[TrashContainer] Set projector size to ({num2:F2}, {num2: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 void Postfix(ItemInstance itemInstance) { PreviewHelper.TrackPreviewVariant(itemInstance); } } [HarmonyPatch(typeof(DecalProjector), "OnEnable")] public static class Patch_DecalProjector_OnEnable { [CompilerGenerated] private sealed class <DelayedRadiusCheck>d__1 : 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__1(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 void Postfix(DecalProjector __instance) { MelonCoroutines.Start(DelayedRadiusCheck(__instance)); } [IteratorStateMachine(typeof(<DelayedRadiusCheck>d__1))] private static IEnumerator DelayedRadiusCheck(DecalProjector projector) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedRadiusCheck>d__1(0) { projector = projector }; } } [HarmonyPatch(typeof(DecalProjector), "OnDisable")] public static class Patch_DecalProjector_OnDisable { 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("[Preview] Cleared active preview variant after ghost disable."); } } } } 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.Audio; 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.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.2", "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.2")] [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.2.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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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() { 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()); } } public override void OnUpdate() { TrashGrabberRadiusManager.Update(); } } 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 TrashGrabberExtensions { [CompilerGenerated] private sealed class <DelayedUIUpdate>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Equippable_TrashGrabber grabber; private TrashGrabberItemUI[] <>s__1; private int <>s__2; private TrashGrabberItemUI <ui>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedUIUpdate>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; <ui>5__3 = null; <>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; <>s__1 = Object.FindObjectsOfType<TrashGrabberItemUI>(); for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++) { <ui>5__3 = <>s__1[<>s__2]; if (((ItemUI)<ui>5__3).itemInstance == ((Equippable)grabber).itemInstance) { ((ItemUI)<ui>5__3).UpdateUI(); break; } <ui>5__3 = null; } <>s__1 = null; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpawnTrashStack>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public List<Entry> entries; public Vector3 basePos; public Equippable_TrashGrabber grabber; private List<Entry>.Enumerator <>s__1; private Entry <entry>5__2; private string <id>5__3; private int <quantity>5__4; private int <i>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnTrashStack>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = default(List<Entry>.Enumerator); <entry>5__2 = null; <id>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; <i>5__5++; goto IL_010b; } <>1__state = -1; <>s__1 = entries.GetEnumerator(); <>1__state = -3; goto IL_0131; IL_010b: if (<i>5__5 < <quantity>5__4) { NetworkSingleton<TrashManager>.Instance.CreateTrashItem(<id>5__3, basePos, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), Vector3.down * 7f, Guid.NewGuid().ToString(), false); <>2__current = null; <>1__state = 1; return true; } <id>5__3 = null; <entry>5__2 = null; goto IL_0131; IL_0131: if (<>s__1.MoveNext()) { <entry>5__2 = <>s__1.Current; <id>5__3 = <entry>5__2.TrashID; <quantity>5__4 = <entry>5__2.Quantity; <i>5__5 = 0; goto IL_010b; } <>m__Finally1(); <>s__1 = default(List<Entry>.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static void EjectAllTrashNow(Equippable_TrashGrabber grabber) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if (((Equippable)(grabber?)).itemInstance?.ID == null || !VariantLookup.GrabberByID.TryGetValue(((Equippable)grabber).itemInstance.ID, out var value) || value.ID != "trash_grabber_pro" || grabber?.trashGrabberInstance?.Content?.Entries == null) { return; } TrashContent content = grabber.trashGrabberInstance.Content; if (content.Entries.Count == 0) { return; } Vector3 basePos = ((Component)grabber).transform.TransformPoint(grabber.TrashDropOffset) + ((Component)grabber).transform.forward * 1f; List<Entry> list = new List<Entry>(); foreach (Entry entry in content.Entries) { list.Add(entry); } content.Clear(); grabber.RefreshVisuals(); AudioSourceController trashDropSound = grabber.TrashDropSound; if (trashDropSound != null) { trashDropSound.Play(); } MelonCoroutines.Start(DelayedUIUpdate(grabber)); MelonCoroutines.Start(SpawnTrashStack(list, basePos, grabber)); } [IteratorStateMachine(typeof(<DelayedUIUpdate>d__1))] private static IEnumerator DelayedUIUpdate(Equippable_TrashGrabber grabber) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedUIUpdate>d__1(0) { grabber = grabber }; } [IteratorStateMachine(typeof(<SpawnTrashStack>d__2))] private static IEnumerator SpawnTrashStack(List<Entry> entries, Vector3 basePos, Equippable_TrashGrabber grabber) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnTrashStack>d__2(0) { entries = entries, basePos = basePos, grabber = grabber }; } } public static class TrashGrabberRadiusManager { private static GameObject? cachedProjector; private static Equippable_TrashGrabber? activeGrabber; private static AudioSource? clickSource; private static AudioSource? whooshSource; private static bool soundPlayedThisCycle = false; private static float nextPickupTime = 0f; private const float pickupCooldown = 0.15f; public static MelonPreferences_Entry<float> Grabber_Radius; private static readonly int GroundMask = LayerMask.GetMask(new string[4] { "Default", "Ground", "Terrain", "Environment" }); private static readonly KeyCode toggleKey = (KeyCode)114; private static readonly KeyCode pickupKey = (KeyCode)101; private static bool radiusModeEnabled => ModManager.Grabber_RadiusModeEnabled.Value; public static Vector2 XZ(this Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2(v.x, v.z); } public static void Update() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) if (!ModManager.Grabber_RadiusPickup.Value) { return; } if (Input.GetKeyDown(toggleKey) && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { bool flag = !ModManager.Grabber_RadiusModeEnabled.Value; ModManager.Grabber_RadiusModeEnabled.Value = flag; Log.Msg("[RadiusManager] Radius mode " + (flag ? "enabled" : "disabled") + "."); } if ((Object)(object)activeGrabber != (Object)null) { Transform val = ((Component)activeGrabber).transform.Find("GrabberRadiusProjector"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(radiusModeEnabled); RaycastHit val2 = default(RaycastHit); if (radiusModeEnabled && Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val2, 10f, GroundMask)) { ((Component)val).transform.position = new Vector3(((RaycastHit)(ref val2)).point.x, ((RaycastHit)(ref val2)).point.y + 0.03f, ((RaycastHit)(ref val2)).point.z); ((Component)val).transform.rotation = Quaternion.LookRotation(Vector3.down); } } } if (radiusModeEnabled && !((Object)(object)activeGrabber == (Object)null) && Input.GetKeyDown(pickupKey) && Time.time >= nextPickupTime) { nextPickupTime = Time.time + 0.15f; PerformRadiusPickup(activeGrabber); } } public static void RegisterActiveGrabber(Equippable_TrashGrabber grabber) { AudioSource[] componentsInChildren = ((Component)grabber).GetComponentsInChildren<AudioSource>(true); AudioSource[] array = componentsInChildren; foreach (AudioSource val in array) { if (!((Object)(object)val == (Object)null)) { string name = ((Object)((Component)val).gameObject).name; if (name == "Clicksound" && (Object)(object)clickSource == (Object)null) { clickSource = val; Log.Debug("[RadiusManager] Cached Clicksound AudioSource"); } else if (name == "Whoosh sound" && (Object)(object)whooshSource == (Object)null) { whooshSource = val; Log.Debug("[RadiusManager] Cached Whoosh AudioSource"); } } } if (!(((Equippable)grabber).itemInstance?.ID != "trash_grabber_pro")) { activeGrabber = grabber; EnsureProjectorAttached(grabber); } } private static void EnsureProjectorAttached(Equippable_TrashGrabber grabber) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)grabber).transform.Find("GrabberRadiusProjector") != (Object)null) { return; } if ((Object)(object)cachedProjector == (Object)null) { GameObject val = FindProjectorFromAnyTrashBag(); if (!((Object)(object)val != (Object)null)) { Log.Warn("[RadiusManager] Could not find projector."); return; } cachedProjector = Object.Instantiate<GameObject>(val); cachedProjector.SetActive(false); Object.DontDestroyOnLoad((Object)(object)cachedProjector); Log.Debug("[RadiusManager] Cached projector from memory."); } GameObject val2 = Object.Instantiate<GameObject>(cachedProjector, ((Component)grabber).transform); ((Object)val2).name = "GrabberRadiusProjector"; val2.SetActive(radiusModeEnabled); val2.layer = ((Component)grabber).gameObject.layer; DecalProjector val3 = default(DecalProjector); if (val2.TryGetComponent<DecalProjector>(ref val3)) { float num = Mathf.Clamp(ModManager.Grabber_Radius.Value, 0.5f, 3f); float num2 = num * 2f; val3.size = new Vector3(num2, num2, 0.5f); } Log.Debug("[RadiusManager] Projector attached to grabber."); } private static GameObject? FindProjectorFromAnyTrashBag() { TrashBag_Equippable[] array = Resources.FindObjectsOfTypeAll<TrashBag_Equippable>(); TrashBag_Equippable[] array2 = array; foreach (TrashBag_Equippable val in array2) { if (!((Object)(object)val == (Object)null)) { if ((Object)(object)val.PickupAreaProjector != (Object)null) { Log.Debug("[RadiusManager] Found PickupAreaProjector on bag."); return ((Component)val.PickupAreaProjector).gameObject; } Transform val2 = FindChildRecursive(((Component)val).transform, "CircleProjector"); if ((Object)(object)val2 != (Object)null) { Log.Debug("[RadiusManager] Found fallback CircleProjector."); return ((Component)val2).gameObject; } } } return null; } private static void PerformRadiusPickup(Equippable_TrashGrabber grabber) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) List<TrashItem> list = NetworkSingleton<TrashManager>.Instance?.trashItems; if (list == null || grabber.trashGrabberInstance == null) { return; } List<TrashItem> list2 = new List<TrashItem>(list.Count); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] != (Object)null) { list2.Add(list[i]); } } Transform val = ((Component)grabber).transform.Find("GrabberRadiusProjector"); if ((Object)(object)val == (Object)null) { return; } Vector3 position = val.position; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(position.x, position.z); float num = Mathf.Clamp(ModManager.Grabber_Radius.Value, 0.5f, 3f); float num2 = num * num; int num3 = 0; Vector2 val5 = default(Vector2); for (int j = 0; j < list2.Count; j++) { TrashItem val3 = list2[j]; Collider component = ((Component)val3).GetComponent<Collider>(); Vector3 val4 = ((component != null) ? component.ClosestPoint(position) : ((Component)val3).transform.position); ((Vector2)(ref val5))..ctor(val4.x, val4.z); Vector2 val6 = val5 - val2; if (!(((Vector2)(ref val6)).sqrMagnitude > num2)) { if (ForcePickup(grabber, val3)) { num3++; } else { Log.Debug("[RadiusManager] ForcePickup failed for " + ((Object)val3).name); } if (grabber.GetCapacity() <= 0) { break; } } } if (num3 > 0) { Log.Msg($"[RadiusManager] Picked up {num3} items."); } } private static bool ForcePickup(Equippable_TrashGrabber grabber, TrashItem item) { soundPlayedThisCycle = false; string text = item.ID ?? ((Object)item).name; if (string.IsNullOrEmpty(text)) { Log.Debug("[ForcePickup] Failed: item ID missing for " + ((Object)item).name); return false; } TrashGrabberInstance trashGrabberInstance = grabber.trashGrabberInstance; if (trashGrabberInstance == null) { Log.Debug("[ForcePickup] Failed: grabber instance null"); return false; } int capacity = grabber.GetCapacity(); if (capacity <= 0) { return false; } trashGrabberInstance.AddTrash(text, 1); int capacity2 = grabber.GetCapacity(); if (capacity2 >= capacity) { return false; } NetworkSingleton<TrashManager>.Instance.DestroyTrash(item); if (!soundPlayedThisCycle) { RandomizedAudioSourceController val = default(RandomizedAudioSourceController); if ((Object)(object)clickSource != (Object)null && ((Component)clickSource).TryGetComponent<RandomizedAudioSourceController>(ref val)) { ((AudioSourceController)val).Play(); } RandomizedAudioSourceController val2 = default(RandomizedAudioSourceController); if ((Object)(object)whooshSource != (Object)null && ((Component)whooshSource).TryGetComponent<RandomizedAudioSourceController>(ref val2)) { ((AudioSourceController)val2).Play(); } soundPlayedThisCycle = true; } return true; } private static Transform? FindChildRecursive(Transform root, string name) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in root) { Transform val = item; if (((Object)val).name == name) { return val; } Transform val2 = FindChildRecursive(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } } 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) 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)) { 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_Category _UpgradedTrashCansSettings; 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> Grabber_BulkEject; public static MelonPreferences_Entry<bool> Grabber_RadiusPickup; public static MelonPreferences_Entry<float> Grabber_Radius; public static MelonPreferences_Entry<bool> Grabber_RadiusModeEnabled; 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); Grabber_BulkEject = GrabberCategory.CreateEntry<bool>("10_Enable Bulk Eject", true, "Enable Shift+Click Eject All", (string)null, false, false, (ValueValidator)null, (string)null); Grabber_RadiusPickup = GrabberCategory.CreateEntry<bool>("11_EnableRadiusPickup", true, "Enable Radius Toggle (Shift+R)", "Adds a pickup radius.", false, false, (ValueValidator)null, (string)null); Grabber_Radius = GrabberCategory.CreateEntry<float>("12_GrabberRadius", 1f, "Grabber Radius (0.5 - 3)", "Adjusts the size of the pickup radius.", 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); _UpgradedTrashCansSettings = MelonPreferences.CreateCategory("xUpgradedTrashCansSettings"); Grabber_RadiusModeEnabled = _UpgradedTrashCansSettings.CreateEntry<bool>("RadiusModeEnabled", false, (string)null, (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_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: 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_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: 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_0591: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: 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_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_042e: 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); int num4 = (ModManager.Grabber_BulkEject.Value ? 1 : 0); int num5 = (ModManager.Grabber_RadiusPickup.Value ? 1 : 0); float num6 = Mathf.Clamp(ModManager.Grabber_Radius.Value, 0.5f, 3f); 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},{num4},{num5},{num6:F2};"); } 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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 != 12 || !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) || !int.TryParse(array5[9], out var result10) || !int.TryParse(array5[10], out var result11) || !float.TryParse(array5[11], out var result12)) { 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; ModManager.Grabber_BulkEject.Value = result10 == 1; ModManager.Grabber_RadiusPickup.Value = result11 == 1; ModManager.Grabber_Radius.Value = Mathf.Clamp(result12, 0.5f, 3f); } } 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 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), "Update")] public static class Patch_TrashGrabber_Update { public static bool Prefix(Equippable_TrashGrabber __instance) { if (!Equippable_TrashGrabber.IsEquipped) { return true; } if (!ModManager.Grabber_BulkEject.Value) { return true; } if (((Equippable)__instance).itemInstance?.ID == null || !VariantLookup.GrabberByID.TryGetValue(((Equippable)__instance).itemInstance.ID, out var value) || value.ID != "trash_grabber_pro") { return true; } if (Input.GetMouseButtonDown(0) && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { TrashGrabberExtensions.EjectAllTrashNow(__instance); return false; } return true; } public static void Postfix(Equippable_TrashGrabber __instance) { TrashGrabberRadiusManager.RegisterActiveGrabber(__instance); } } [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($"[TrashContainerItem Start] 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($"[TrashContainerItem Start] Name was null or errored on attempt {<attempts>5__1}/{10}. Retrying after {2} frames..."); <i>5__4 = 0; goto IL_0116; } Log.Debug("[TrashContainerItem Start] 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) { if (!((Object)(object)__instance == (Object)null)) { TrashContainer component = ((Component)__instance).GetComponent<TrashContainer>(); if (!((Object)(object)component == (Object)null)) { 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_00ee: 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_00a8: 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) 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 num = (instance.PickupSquareWidth = item.Radius); instance.calculatedPickupRadius = num * Mathf.Sqrt(2f); if ((Object)(object)instance.PickupAreaProjector != (Object)null) { float num2 = num * 2f; instance.PickupAreaProjector.size = new Vector3(num2, num2, instance.PickupAreaProjector.size.z); Log.Debug($"[TrashContainer] Set projector size to ({num2:F2}, {num2: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 void Postfix(ItemInstance itemInstance) { PreviewHelper.TrackPreviewVariant(itemInstance); } } [HarmonyPatch(typeof(DecalProjector), "OnEnable")] public static class Patch_DecalProjector_OnEnable { [CompilerGenerated] private sealed class <DelayedRadiusCheck>d__1 : 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__1(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 void Postfix(DecalProjector __instance) { MelonCoroutines.Start(DelayedRadiusCheck(__instance)); } [IteratorStateMachine(typeof(<DelayedRadiusCheck>d__1))] private static IEnumerator DelayedRadiusCheck(DecalProjector projector) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedRadiusCheck>d__1(0) { projector = projector }; } } [HarmonyPatch(typeof(DecalProjector), "OnDisable")] public static class Patch_DecalProjector_OnDisable { 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("[Preview] Cleared active preview variant after ghost disable."); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }