Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of BigSprinklerLogic v1.1.0
BigSprinklerLogic-IL2CPP.dll
Decompiled 13 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BigSprinklerLogic; using BigSprinklerLogic.Helpers; using HarmonyLib; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Employees; using Il2CppScheduleOne.EntityFramework; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Tiles; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using MelonLoader; using Microsoft.CodeAnalysis; using S1API.Items; using S1API.Shops; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(global::BigSprinklerLogic.BigSprinklerLogic), "BigSprinklerLogic", "1.1.0", "k073l", null)] [assembly: MelonColor(1, 11, 57, 84)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("BigSprinklerLogic-IL2CPP")] [assembly: AssemblyConfiguration("Release IL2CPP")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+99e9f3e9c72dc36f4744112a142a355a84d50f4b")] [assembly: AssemblyProduct("BigSprinklerLogic-IL2CPP")] [assembly: AssemblyTitle("BigSprinklerLogic-IL2CPP")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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 BigSprinklerLogic { public static class BuildInfo { public const string Name = "BigSprinklerLogic"; public const string Description = "Makes the big sprinkler work."; public const string Author = "k073l"; public const string Version = "1.1.0"; } public class BigSprinklerLogic : MelonMod { [CompilerGenerated] private sealed class <AddDelayed>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public BigSprinklerLogic <>4__this; private ItemDefinition <item>5__1; private int <addedCount>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AddDelayed>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <item>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; if (<>4__this._shopsReady) { return false; } <item>5__1 = ItemManager.GetItemDefinition("bigsprinkler"); if (<item>5__1 == (ItemDefinition)null) { Logger.Error("Could not find bigsprinkler item definition!"); return false; } <addedCount>5__2 = ShopManager.AddToCompatibleShops(<item>5__1, (float?)null); Logger.Msg($"Added bigsprinkler to {<addedCount>5__2} shops."); <>4__this._shopsReady = true; 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 static Instance Logger; private bool _shopsReady; public override void OnInitializeMelon() { Logger = ((MelonBase)this).LoggerInstance; Logger.Msg("BigSprinklerLogic initialized"); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (!(sceneName == "Menu")) { if (sceneName == "Main") { MelonCoroutines.Start(AddDelayed()); } } else { _shopsReady = false; } } [IteratorStateMachine(typeof(<AddDelayed>d__4))] private IEnumerator AddDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AddDelayed>d__4(0) { <>4__this = this }; } } internal static class SprinklerConvenienceMethods { public static bool IsBigSprinkler(Sprinkler sprinkler) { GameObject gameObject = ((Component)sprinkler).gameObject; Transform val = gameObject.transform.Find("Arrow"); return (Object)(object)val == (Object)null; } public static HashSet<GridItem> GetItemsAroundItem(GridItem item) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Coordinate origin = new Coordinate(item._originCoordinate); List<Coordinate> list = new List<Coordinate>(); for (int i = -1; i <= 2; i++) { list.Add(new Coordinate(i, -1)); list.Add(new Coordinate(i, 2)); } for (int j = 0; j <= 1; j++) { list.Add(new Coordinate(-1, j)); list.Add(new Coordinate(2, j)); } List<Coordinate> list2 = list.Select((Coordinate offset) => origin + Coordinate.RotateCoordinates(offset, (float)item._rotation)).ToList(); HashSet<GridItem> hashSet = new HashSet<GridItem>(); foreach (Coordinate item2 in list2) { Tile tile = item.OwnerGrid.GetTile(item2); if (!((Object)(object)tile == (Object)null)) { if (MelonDebug.IsEnabled()) { DrawDebugTile(((Component)tile).transform.position, 1f, Color.cyan); } Enumerator<GridItem> enumerator2 = tile.BuildableOccupants.GetEnumerator(); while (enumerator2.MoveNext()) { GridItem current2 = enumerator2.Current; hashSet.Add(current2); } } } return hashSet; } private static void DrawDebugTile(Vector3 pos, float size, Color color) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00cf: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = "DebugSquare"; val.transform.position = pos + Vector3.up * 0.01f; val.transform.rotation = Quaternion.Euler(90f, -30f, 0f); val.transform.localScale = Vector3.one * size * 0.25f; Object.Destroy((Object)(object)val.GetComponent<Collider>()); MeshRenderer component = val.GetComponent<MeshRenderer>(); Shader val2 = Shader.Find("Universal Render Pipeline/Lit"); if (!((Object)(object)val2 == (Object)null)) { Material val3 = new Material(val2); if (val3.HasProperty("_Surface")) { val3.SetFloat("_Surface", 1f); } Color val4 = color; if (val4.a <= 0f) { val4.a = 0.2f; } if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", val4); } if (val3.HasProperty("_EmissionColor")) { val3.EnableKeyword("_EMISSION"); val3.SetColor("_EmissionColor", new Color(color.r, color.g, color.b) * 1.5f); } val3.SetInt("_ZWrite", 0); val3.renderQueue = 3000; ((Renderer)component).material = val3; } } } [HarmonyPatch(typeof(Sprinkler), "GetPots")] public class SprinklerPatches { [HarmonyWrapSafe] public static bool Prefix(Sprinkler __instance, ref List<Pot> __result) { if (!SprinklerConvenienceMethods.IsBigSprinkler(__instance)) { MelonDebug.Msg("Not a big sprinkler, skipping patch"); return true; } MelonDebug.Msg("Applying big sprinkler logic"); Pot result; IEnumerable<Pot> source = from x in SprinklerConvenienceMethods.GetItemsAroundItem((GridItem)(object)__instance) select (Utils.Is<Pot>((object)x, out result), result) into t where t.Success && (Object)(object)t.Pot != (Object)null select t.Pot; __result = source.ToIl2CppList(); return false; } } [HarmonyPatch(typeof(GrowContainerBehaviour), "OnActiveTick")] public class WaterPotBehaviourPatches { [HarmonyWrapSafe] public static void Postfix(GrowContainerBehaviour __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (!InstanceFinder.IsServer || (int)__instance._currentState != 3 || !__instance.IsAtGrowContainer() || !Utils.Is<WaterPotBehaviour>((object)__instance, out WaterPotBehaviour result) || !Utils.Is<Pot>((object)((GrowContainerBehaviour)result)._growContainer, out Pot result2)) { return; } HashSet<GridItem> itemsAroundItem = SprinklerConvenienceMethods.GetItemsAroundItem((GridItem)(object)result2); MelonDebug.Msg("Found " + itemsAroundItem.Count + " items around the pot"); foreach (GridItem item in itemsAroundItem) { if (!Utils.Is<Sprinkler>((object)item, out Sprinkler result3) || !SprinklerConvenienceMethods.IsBigSprinkler(result3)) { continue; } MelonDebug.Msg("It's a big sprinkler, activating it"); if (!result3.IsSprinkling) { result3.Interacted(); } ((GrowContainerBehaviour)result).OnStopPerformAction(); ((GrowContainerBehaviour)result).OnActionSuccess((ItemInstance)null); ((Behaviour)result).Disable_Networked((NetworkConnection)null); if (Utils.Is<Botanist>((object)((Behaviour)result).Npc, out Botanist result4) && result4 != null) { ((Employee)result4).SetIdle(true); } break; } } } } namespace BigSprinklerLogic.Helpers { public static class MelonLoggerExtensions { public static void Debug(this Instance logger, string message, bool stacktrace = true) { } private static string GetLoggerName(Instance logger) { return typeof(Instance).GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(logger) as string; } private static void InvokeNativeMsg(Color namesectionColor, Color textColor, string nameSection, string message) { typeof(MelonLogger).GetMethod("NativeMsg", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, new object[5] { namesectionColor, textColor, nameSection, message ?? "null", false }); } private static string GetCallerInfo() { StackTrace stackTrace = new StackTrace(); for (int i = 2; i < stackTrace.FrameCount; i++) { StackFrame frame = stackTrace.GetFrame(i); MethodBase method = frame.GetMethod(); if (!(method?.DeclaringType == null)) { return method.DeclaringType.FullName + "." + method.Name; } } return "unknown"; } } public static class Il2CppListExtensions { public static IEnumerable<T> AsEnumerable<T>(this List<T> list) { return list ?? new List<T>(); } public static List<T> ToIl2CppList<T>(this IEnumerable<T> source) { List<T> val = new List<T>(); foreach (T item in source) { val.Add(item); } return val; } public static List<T> ConvertToList<T>(List<T> il2CppList) { List<T> list = new List<T>(); T[] collection = Il2CppArrayBase<T>.op_Implicit(il2CppList.ToArray()); list.AddRange(collection); return list; } public static IEnumerable<T> AsEnumerable<T>(this List<T> list) { IEnumerable<T> result; if (list != null) { result = ((IEnumerable<T>)list._items).Take(list._size); } else { IEnumerable<T> enumerable = Array.Empty<T>(); result = enumerable; } return result; } } public static class Utils { [CompilerGenerated] private sealed class <WaitForNetwork>d__6 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator routine; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForNetwork>d__6(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; break; case 1: <>1__state = -1; break; } if (!InstanceFinder.IsServer && !InstanceFinder.IsClient) { <>2__current = null; <>1__state = 1; return true; } MelonCoroutines.Start(routine); 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 <WaitForNetworkSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T> { private int <>1__state; private object <>2__current; public IEnumerator coroutine; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForNetworkSingleton>d__8(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; goto IL_0044; case 1: <>1__state = -1; goto IL_0044; case 2: { <>1__state = -1; return false; } IL_0044: if (!NetworkSingleton<T>.InstanceExists) { <>2__current = null; <>1__state = 1; return true; } <>2__current = coroutine; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitForNotNull>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public object obj; public float timeout; public Action onTimeout; public Action onFinish; private float <startTime>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForNotNull>d__7(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; <startTime>5__1 = Time.time; break; case 1: <>1__state = -1; break; } if (obj == null) { if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout) { onTimeout?.Invoke(); return false; } <>2__current = null; <>1__state = 1; return true; } onFinish?.Invoke(); 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 <WaitForPlayer>d__5 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator routine; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForPlayer>d__5(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; break; case 1: <>1__state = -1; break; } if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null) { <>2__current = null; <>1__state = 1; return true; } MelonCoroutines.Start(routine); 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 static readonly Instance Logger = new Instance("BigSprinklerLogic-Utils"); public static T FindObjectByName<T>(string objectName) where T : Object { try { foreach (T item in Resources.FindObjectsOfTypeAll<T>()) { if (((Object)item).name != objectName) { continue; } Logger.Debug($"Found {typeof(T).Name} '{objectName}' directly in loaded objects"); return item; } return default(T); } catch (Exception ex) { Logger.Error($"Error finding {typeof(T).Name} '{objectName}': {ex.Message}"); return default(T); } } public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component { List<T> list = new List<T>(); if ((Object)(object)obj == (Object)null) { return list; } T[] array = Il2CppArrayBase<T>.op_Implicit(obj.GetComponents<T>()); if (array.Length != 0) { list.AddRange(array); } for (int i = 0; i < obj.transform.childCount; i++) { Transform child = obj.transform.GetChild(i); list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject)); } return list; } public static bool Is<T>(object obj, out T result) where T : Object { Object val = (Object)((obj is Object) ? obj : null); if (val != null) { Type val2 = Il2CppType.Of<T>(); Type il2CppType = val.GetIl2CppType(); if (val2.IsAssignableFrom(il2CppType)) { result = ((Il2CppObjectBase)val).TryCast<T>(); return result != null; } } result = default(T); return false; } public static List<StorableItemDefinition> GetAllStorableItemDefinitions() { List<ItemRegister> list = Il2CppListExtensions.ConvertToList<ItemRegister>(Singleton<Registry>.Instance.ItemRegistry); List<StorableItemDefinition> list2 = new List<StorableItemDefinition>(); foreach (ItemRegister item in list) { if (Utils.Is<StorableItemDefinition>((object)item.Definition, out StorableItemDefinition result)) { list2.Add(result); } else { Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition"); } } return list2.ToList(); } [IteratorStateMachine(typeof(<WaitForPlayer>d__5))] public static IEnumerator WaitForPlayer(IEnumerator routine) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForPlayer>d__5(0) { routine = routine }; } [IteratorStateMachine(typeof(<WaitForNetwork>d__6))] public static IEnumerator WaitForNetwork(IEnumerator routine) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForNetwork>d__6(0) { routine = routine }; } [IteratorStateMachine(typeof(<WaitForNotNull>d__7))] public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForNotNull>d__7(0) { obj = obj, timeout = timeout, onTimeout = onTimeout, onFinish = onFinish }; } [IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__8<>))] public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T> { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForNetworkSingleton>d__8<T>(0) { coroutine = coroutine }; } } }
BigSprinklerLogic-Mono.dll
Decompiled 13 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BigSprinklerLogic; using BigSprinklerLogic.Helpers; using FishNet; using FishNet.Connection; using HarmonyLib; using MelonLoader; using Microsoft.CodeAnalysis; using S1API.Items; using S1API.Shops; using ScheduleOne; using ScheduleOne.DevUtilities; using ScheduleOne.Employees; using ScheduleOne.EntityFramework; using ScheduleOne.ItemFramework; using ScheduleOne.NPCs.Behaviour; using ScheduleOne.ObjectScripts; using ScheduleOne.PlayerScripts; using ScheduleOne.Tiles; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(global::BigSprinklerLogic.BigSprinklerLogic), "BigSprinklerLogic", "1.1.0", "k073l", null)] [assembly: MelonColor(1, 11, 57, 84)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BigSprinklerLogic-Mono")] [assembly: AssemblyConfiguration("Release Mono")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+99e9f3e9c72dc36f4744112a142a355a84d50f4b")] [assembly: AssemblyProduct("BigSprinklerLogic-Mono")] [assembly: AssemblyTitle("BigSprinklerLogic-Mono")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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 BigSprinklerLogic { public static class BuildInfo { public const string Name = "BigSprinklerLogic"; public const string Description = "Makes the big sprinkler work."; public const string Author = "k073l"; public const string Version = "1.1.0"; } public class BigSprinklerLogic : MelonMod { [CompilerGenerated] private sealed class <AddDelayed>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public BigSprinklerLogic <>4__this; private ItemDefinition <item>5__1; private int <addedCount>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AddDelayed>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <item>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; if (<>4__this._shopsReady) { return false; } <item>5__1 = ItemManager.GetItemDefinition("bigsprinkler"); if (<item>5__1 == (ItemDefinition)null) { Logger.Error("Could not find bigsprinkler item definition!"); return false; } <addedCount>5__2 = ShopManager.AddToCompatibleShops(<item>5__1, (float?)null); Logger.Msg($"Added bigsprinkler to {<addedCount>5__2} shops."); <>4__this._shopsReady = true; 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 static Instance Logger; private bool _shopsReady; public override void OnInitializeMelon() { Logger = ((MelonBase)this).LoggerInstance; Logger.Msg("BigSprinklerLogic initialized"); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (!(sceneName == "Menu")) { if (sceneName == "Main") { MelonCoroutines.Start(AddDelayed()); } } else { _shopsReady = false; } } [IteratorStateMachine(typeof(<AddDelayed>d__4))] private IEnumerator AddDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AddDelayed>d__4(0) { <>4__this = this }; } } internal static class SprinklerConvenienceMethods { public static bool IsBigSprinkler(Sprinkler sprinkler) { GameObject gameObject = ((Component)sprinkler).gameObject; Transform val = gameObject.transform.Find("Arrow"); return (Object)(object)val == (Object)null; } public static HashSet<GridItem> GetItemsAroundItem(GridItem item) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) Coordinate origin = new Coordinate(item._originCoordinate); List<Coordinate> list = new List<Coordinate>(); for (int i = -1; i <= 2; i++) { list.Add(new Coordinate(i, -1)); list.Add(new Coordinate(i, 2)); } for (int j = 0; j <= 1; j++) { list.Add(new Coordinate(-1, j)); list.Add(new Coordinate(2, j)); } List<Coordinate> list2 = list.Select((Coordinate offset) => origin + Coordinate.RotateCoordinates(offset, (float)item._rotation)).ToList(); HashSet<GridItem> hashSet = new HashSet<GridItem>(); foreach (Coordinate item2 in list2) { Tile tile = item.OwnerGrid.GetTile(item2); if ((Object)(object)tile == (Object)null) { continue; } if (MelonDebug.IsEnabled()) { DrawDebugTile(((Component)tile).transform.position, 1f, Color.cyan); } foreach (GridItem buildableOccupant in tile.BuildableOccupants) { hashSet.Add(buildableOccupant); } } return hashSet; } private static void DrawDebugTile(Vector3 pos, float size, Color color) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00cf: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = "DebugSquare"; val.transform.position = pos + Vector3.up * 0.01f; val.transform.rotation = Quaternion.Euler(90f, -30f, 0f); val.transform.localScale = Vector3.one * size * 0.25f; Object.Destroy((Object)(object)val.GetComponent<Collider>()); MeshRenderer component = val.GetComponent<MeshRenderer>(); Shader val2 = Shader.Find("Universal Render Pipeline/Lit"); if (!((Object)(object)val2 == (Object)null)) { Material val3 = new Material(val2); if (val3.HasProperty("_Surface")) { val3.SetFloat("_Surface", 1f); } Color val4 = color; if (val4.a <= 0f) { val4.a = 0.2f; } if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", val4); } if (val3.HasProperty("_EmissionColor")) { val3.EnableKeyword("_EMISSION"); val3.SetColor("_EmissionColor", new Color(color.r, color.g, color.b) * 1.5f); } val3.SetInt("_ZWrite", 0); val3.renderQueue = 3000; ((Renderer)component).material = val3; } } } [HarmonyPatch(typeof(Sprinkler), "GetPots")] public class SprinklerPatches { [HarmonyWrapSafe] public static bool Prefix(Sprinkler __instance, ref List<Pot> __result) { if (!SprinklerConvenienceMethods.IsBigSprinkler(__instance)) { MelonDebug.Msg("Not a big sprinkler, skipping patch"); return true; } MelonDebug.Msg("Applying big sprinkler logic"); Pot result; IEnumerable<Pot> source = from x in SprinklerConvenienceMethods.GetItemsAroundItem((GridItem)(object)__instance) select (Utils.Is<Pot>(x, out result), result) into t where t.Success && (Object)(object)t.Pot != (Object)null select t.Pot; __result = source.ToList(); return false; } } [HarmonyPatch(typeof(GrowContainerBehaviour), "OnActiveTick")] public class WaterPotBehaviourPatches { [HarmonyWrapSafe] public static void Postfix(GrowContainerBehaviour __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 if (!InstanceFinder.IsServer || (int)__instance._currentState != 3 || !__instance.IsAtGrowContainer() || !Utils.Is<WaterPotBehaviour>(__instance, out var result) || !Utils.Is<Pot>(((GrowContainerBehaviour)result)._growContainer, out var result2)) { return; } HashSet<GridItem> itemsAroundItem = SprinklerConvenienceMethods.GetItemsAroundItem((GridItem)(object)result2); MelonDebug.Msg("Found " + itemsAroundItem.Count + " items around the pot"); foreach (GridItem item in itemsAroundItem) { if (!Utils.Is<Sprinkler>(item, out var result3) || !SprinklerConvenienceMethods.IsBigSprinkler(result3)) { continue; } MelonDebug.Msg("It's a big sprinkler, activating it"); if (!result3.IsSprinkling) { result3.Interacted(); } ((GrowContainerBehaviour)result).OnStopPerformAction(); ((GrowContainerBehaviour)result).OnActionSuccess((ItemInstance)null); ((Behaviour)result).Disable_Networked((NetworkConnection)null); if (Utils.Is<Botanist>(((Behaviour)result).Npc, out var result4) && result4 != null) { ((Employee)result4).SetIdle(true); } break; } } } } namespace BigSprinklerLogic.Helpers { public static class MelonLoggerExtensions { public static void Debug(this Instance logger, string message, bool stacktrace = true) { } private static string GetLoggerName(Instance logger) { return typeof(Instance).GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(logger) as string; } private static void InvokeNativeMsg(Color namesectionColor, Color textColor, string nameSection, string message) { typeof(MelonLogger).GetMethod("NativeMsg", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, new object[5] { namesectionColor, textColor, nameSection, message ?? "null", false }); } private static string GetCallerInfo() { StackTrace stackTrace = new StackTrace(); for (int i = 2; i < stackTrace.FrameCount; i++) { StackFrame frame = stackTrace.GetFrame(i); MethodBase method = frame.GetMethod(); if (!(method?.DeclaringType == null)) { return method.DeclaringType.FullName + "." + method.Name; } } return "unknown"; } } public static class Il2CppListExtensions { public static IEnumerable<T> AsEnumerable<T>(this List<T> list) { return list ?? new List<T>(); } } public static class Utils { [CompilerGenerated] private sealed class <WaitForNetwork>d__6 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator routine; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForNetwork>d__6(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; break; case 1: <>1__state = -1; break; } if (!InstanceFinder.IsServer && !InstanceFinder.IsClient) { <>2__current = null; <>1__state = 1; return true; } MelonCoroutines.Start(routine); 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 <WaitForNetworkSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T> { private int <>1__state; private object <>2__current; public IEnumerator coroutine; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForNetworkSingleton>d__8(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; goto IL_0044; case 1: <>1__state = -1; goto IL_0044; case 2: { <>1__state = -1; return false; } IL_0044: if (!NetworkSingleton<T>.InstanceExists) { <>2__current = null; <>1__state = 1; return true; } <>2__current = coroutine; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitForNotNull>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public object obj; public float timeout; public Action onTimeout; public Action onFinish; private float <startTime>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForNotNull>d__7(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; <startTime>5__1 = Time.time; break; case 1: <>1__state = -1; break; } if (obj == null) { if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout) { onTimeout?.Invoke(); return false; } <>2__current = null; <>1__state = 1; return true; } onFinish?.Invoke(); 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 <WaitForPlayer>d__5 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator routine; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForPlayer>d__5(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; break; case 1: <>1__state = -1; break; } if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null) { <>2__current = null; <>1__state = 1; return true; } MelonCoroutines.Start(routine); 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 static readonly Instance Logger = new Instance("BigSprinklerLogic-Utils"); public static T FindObjectByName<T>(string objectName) where T : Object { try { T[] array = Resources.FindObjectsOfTypeAll<T>(); foreach (T val in array) { if (!(((Object)val).name != objectName)) { Logger.Debug("Found " + typeof(T).Name + " '" + objectName + "' directly in loaded objects"); return val; } } return default(T); } catch (Exception ex) { Logger.Error("Error finding " + typeof(T).Name + " '" + objectName + "': " + ex.Message); return default(T); } } public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component { List<T> list = new List<T>(); if ((Object)(object)obj == (Object)null) { return list; } T[] components = obj.GetComponents<T>(); if (components.Length != 0) { list.AddRange(components); } for (int i = 0; i < obj.transform.childCount; i++) { Transform child = obj.transform.GetChild(i); list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject)); } return list; } public static bool Is<T>(object obj, out T result) where T : class { if (obj is T val) { result = val; return true; } result = null; return false; } public static List<StorableItemDefinition> GetAllStorableItemDefinitions() { List<ItemRegister> list = Singleton<Registry>.Instance.ItemRegistry.ToList(); List<StorableItemDefinition> list2 = new List<StorableItemDefinition>(); foreach (ItemRegister item in list) { if (Is<StorableItemDefinition>(item.Definition, out var result)) { list2.Add(result); } else { Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition"); } } return list2.ToList(); } [IteratorStateMachine(typeof(<WaitForPlayer>d__5))] public static IEnumerator WaitForPlayer(IEnumerator routine) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForPlayer>d__5(0) { routine = routine }; } [IteratorStateMachine(typeof(<WaitForNetwork>d__6))] public static IEnumerator WaitForNetwork(IEnumerator routine) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForNetwork>d__6(0) { routine = routine }; } [IteratorStateMachine(typeof(<WaitForNotNull>d__7))] public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForNotNull>d__7(0) { obj = obj, timeout = timeout, onTimeout = onTimeout, onFinish = onFinish }; } [IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__8<>))] public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T> { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForNetworkSingleton>d__8<T>(0) { coroutine = coroutine }; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }