Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of BotanistUseSprinkler Mono v1.0.0
BotanistUseSprinkler_Mono.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BotanistUseSprinkler; using FishNet; using FishNet.Connection; using HarmonyLib; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using ScheduleOne.Employees; using ScheduleOne.EntityFramework; using ScheduleOne.NPCs.Behaviour; using ScheduleOne.ObjectScripts; 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(BotanistUseSprinklerMod), "Botanist Use Sprinkler", "1.0.0", "Fortis", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BotanistUseSprinkler_Mono")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+089e200b56f9674cc50e95bb14eaefe236d62c5f")] [assembly: AssemblyProduct("BotanistUseSprinkler_Mono")] [assembly: AssemblyTitle("BotanistUseSprinkler_Mono")] [assembly: AssemblyVersion("1.0.0.0")] [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 BotanistUseSprinkler { public class BotanistUseSprinklerMod : MelonMod { [HarmonyPatch(typeof(PotActionBehaviour), "ActiveMinPass")] public static class PotActionBehaviourActiveMinPassPatch { [HarmonyPostfix] private static void Postfix(PotActionBehaviour __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown if (!InstanceFinder.IsServer || (int)__instance.CurrentState != 4 || (int)__instance.CurrentActionType != 3 || !IsAtPot(__instance)) { return; } List<Sprinkler> sprinklers = GetSprinklers(__instance.AssignedPot); Log($"(PotActionBehaviour/ActiveMinPass) Sprinklers found: {sprinklers.Count}", LogLevel.Debug); if (sprinklers.Count <= 0) { return; } Coordinate val = new Coordinate(((GridItem)__instance.AssignedPot).OriginCoordinate); foreach (Sprinkler item in sprinklers) { List<Pot> pots = GetPots(item); if (pots == null) { Log("(PotActionBehaviour/ActiveMinPass) Pots is null!", LogLevel.Debug); continue; } if (pots.Count <= 0) { Log("(PotActionBehaviour/ActiveMinPass) Pots count is less than 0 or equal to 0", LogLevel.Debug); continue; } Log($"(PotActionBehaviour/ActiveMinPass) Pot 0 coords: x: {((GridItem)pots[0]).OriginCoordinate.x}, y: {((GridItem)pots[0]).OriginCoordinate.y}", LogLevel.Debug); Log($"(PotActionBehaviour/ActiveMinPass) Assigned Pot coords: x: {((GridItem)__instance.AssignedPot).OriginCoordinate.x}, y: {((GridItem)__instance.AssignedPot).OriginCoordinate.y}", LogLevel.Debug); Coordinate val2 = new Coordinate(((GridItem)pots[0]).OriginCoordinate); if (val2.x == val.x && val2.y == val.y && !item.IsSprinkling) { Log("(PotActionBehaviour/ActiveMinPass) Activating sprinkler", LogLevel.Debug); item.Interacted(); } } ((Behaviour)__instance).Disable_Networked((NetworkConnection)null); Botanist val3 = default(Botanist); if (((Component)__instance).TryGetComponent<Botanist>(ref val3) && val3 != null) { ((Employee)val3).SetIdle(true); } } private static bool IsAtPot(PotActionBehaviour behaviour) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (behaviour.AssignedPot == null) { return false; } for (int i = 0; i < behaviour.AssignedPot.AccessPoints.Length; i++) { if (Vector3.Distance(((Component)((Behaviour)behaviour).Npc).transform.position, behaviour.AssignedPot.AccessPoints[i].position) < 0.4f) { return true; } if (((Behaviour)behaviour).Npc.Movement.IsAsCloseAsPossible(((Component)behaviour.AssignedPot.AccessPoints[i]).transform.position, 0.4f)) { return true; } } return false; } private static List<Sprinkler> GetSprinklers(Pot pot) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown Log($"(GetSprinklers) Assigned Pot Origin Coords: x: {((GridItem)pot).OriginCoordinate.x}, y: {((GridItem)pot).OriginCoordinate.y}", LogLevel.Debug); Coordinate val = new Coordinate(((GridItem)pot).OriginCoordinate); List<Tile> list = new List<Tile>(); for (int i = 0; i < 3; i++) { Coordinate val2 = new Coordinate(val.x + i, val.y); Coordinate val3 = new Coordinate(val.x - i, val.y); Coordinate val4 = new Coordinate(val.x, val.y + i); Coordinate val5 = new Coordinate(val.x, val.y - i); Tile tile = ((GridItem)pot).OwnerGrid.GetTile(val2); Tile tile2 = ((GridItem)pot).OwnerGrid.GetTile(val3); Tile tile3 = ((GridItem)pot).OwnerGrid.GetTile(val4); Tile tile4 = ((GridItem)pot).OwnerGrid.GetTile(val5); if (tile != null) { list.Add(tile); } if (tile2 != null) { list.Add(tile2); } if (tile3 != null) { list.Add(tile3); } if (tile4 != null) { list.Add(tile4); } } if (list.Count <= 0) { Log("Test tile count 0", LogLevel.Debug); return new List<Sprinkler>(); } List<Sprinkler> list2 = new List<Sprinkler>(); foreach (Tile item in list) { Sprinkler val6 = TryGetSprinkler(item.BuildableOccupants); if (val6 != null) { Coordinate val7 = new Coordinate(((GridItem)val6).OriginCoordinate); Log($"TestSprinkler Sprinkler found at coords: x: {val7.x}, y: {val7.y}", LogLevel.Debug); list2.Add(val6); } } return list2; } private static List<Pot> GetPots(Sprinkler sprinkler) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_002a: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_004e: Expected O, but got Unknown List<Pot> list = new List<Pot>(); Coordinate val = new Coordinate(((GridItem)sprinkler).OriginCoordinate) + Coordinate.RotateCoordinates(new Coordinate(0, 1), (float)((GridItem)sprinkler).Rotation); Coordinate val2 = new Coordinate(((GridItem)sprinkler).OriginCoordinate) + Coordinate.RotateCoordinates(new Coordinate(1, 1), (float)((GridItem)sprinkler).Rotation); Tile tile = ((GridItem)sprinkler).OwnerGrid.GetTile(val); Tile tile2 = ((GridItem)sprinkler).OwnerGrid.GetTile(val2); if ((Object)(object)tile != (Object)null && (Object)(object)tile2 != (Object)null) { Pot val3 = null; foreach (GridItem buildableOccupant in tile.BuildableOccupants) { if (buildableOccupant is Pot) { val3 = (Pot)(object)((buildableOccupant is Pot) ? buildableOccupant : null); break; } } if ((Object)(object)val3 != (Object)null && tile2.BuildableOccupants.Contains((GridItem)(object)val3)) { list.Add(val3); } } return list; } private static Sprinkler? TryGetSprinkler(List<GridItem> gridItems) { Sprinkler val = null; Sprinkler result = default(Sprinkler); foreach (GridItem gridItem in gridItems) { if (((Component)gridItem).TryGetComponent<Sprinkler>(ref result)) { return result; } } return null; } } private enum LogLevel { Debug, Info, Warn, Error, Fatal } private Harmony _harmony; private static readonly string ConfigDirectoryPath = Path.Combine(MelonEnvironment.UserDataDirectory, "BotanistUseSprinkler") ?? ""; private static readonly string ConfigFilePath = Path.Combine(ConfigDirectoryPath, "configuration.json") ?? ""; private static Configuration _config; public override void OnInitializeMelon() { Log("Initializing...", LogLevel.Info); LoadConfigFromFile(); if (_config.Enabled) { _harmony = Harmony.CreateAndPatchAll(typeof(BotanistUseSprinklerMod), "com.fortis.botanistusesprinkler"); } Log("Initialized", LogLevel.Info); } private static void LoadConfigFromFile() { Configuration configuration = new Configuration(); configuration.Enabled = true; configuration.Debug = false; if (!Directory.Exists(ConfigDirectoryPath)) { Directory.CreateDirectory(ConfigDirectoryPath); } if (!File.Exists(ConfigFilePath)) { CreateConfigFile(); _config = configuration; return; } string text = File.ReadAllText(ConfigFilePath); Configuration configuration2 = JsonConvert.DeserializeObject<Configuration>(text); if (configuration2 == null) { _config = configuration; return; } configuration.Enabled = configuration2.Enabled; configuration.Debug = configuration2.Debug; _config = configuration; } private static void CreateConfigFile() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown JsonSerializerSettings val = new JsonSerializerSettings(); val.Formatting = (Formatting)1; Configuration configuration = new Configuration(); configuration.Enabled = true; configuration.Debug = false; string contents = JsonConvert.SerializeObject((object)configuration, val); File.WriteAllText(ConfigFilePath, contents); } private static void Log(string message, LogLevel level) { string logPrefix = GetLogPrefix(level); if (level != 0 || _config.Debug) { MelonLogger.Msg(logPrefix + " " + message); } } private static string GetLogPrefix(LogLevel level) { return level switch { LogLevel.Debug => "[DEBUG]", LogLevel.Info => "[INFO]", LogLevel.Warn => "[WARN]", LogLevel.Error => "[ERROR]", LogLevel.Fatal => "[FATAL]", _ => "[MISC]", }; } } public class Configuration { [JsonProperty("enabled")] public bool Enabled { get; set; } [JsonProperty("debug")] public bool Debug { get; set; } } }