Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of EasyPlanting v1.0.0
Mods/EasyPlanting.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using EasyPlanting; using EasyPlanting.Behaviours; using EasyPlanting.Utils; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using ScheduleOne; using ScheduleOne.DevUtilities; using ScheduleOne.Growing; using ScheduleOne.ItemFramework; using ScheduleOne.ObjectScripts; using ScheduleOne.ObjectScripts.Soil; using ScheduleOne.PlayerTasks; using ScheduleOne.PlayerTasks.Tasks; using ScheduleOne.UI; using UnityEngine; using VLB; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(ModMain), "EasyPlanting", "1.0.0", "@joeswanson.", "https://discord.gg/UH4FW8SZvV")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EasyPlanting")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+afdf91dd0bf373c901a9346d75c2c31314ea5168")] [assembly: AssemblyProduct("EasyPlanting")] [assembly: AssemblyTitle("EasyPlanting")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace EasyPlanting { public class ModMain : MelonMod { public static Config config; public override void OnInitializeMelon() { ((MelonBase)this).LoggerInstance.Msg("Loading config..."); config = new Config(); ((MelonBase)this).LoggerInstance.Msg("Loaded!"); } public override void OnDeinitializeMelon() { config.Category.SaveToFile(true); } public override void OnUpdate() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (!GameInput.GetButton((ButtonCode)0) || !Singleton<TaskManager>.InstanceExists || Singleton<TaskManager>.Instance.currentTask == null || !config.DragOverSoilChunks.Value) { return; } Task currentTask = Singleton<TaskManager>.Instance.currentTask; SowSeedTask val = (SowSeedTask)(object)((currentTask is SowSeedTask) ? currentTask : null); if (val == null || !val.seedReachedDestination) { return; } RaycastHit val2 = default(RaycastHit); Clickable clickable = ((Task)val).GetClickable(ref val2); if ((Object)(object)clickable != (Object)null) { SoilChunk val3 = (SoilChunk)(object)((clickable is SoilChunk) ? clickable : null); if (val3 != null) { ((Clickable)val3).StartClick(val2); ((Clickable)val3).EndClick(); } } } } public class Config { public MelonPreferences_Category Category; public MelonPreferences_Entry<bool> DragOverSoilChunks; public MelonPreferences_Entry<float> DragSpeedMultiplier; public MelonPreferences_Entry<float> DragTurnSpeedMultiplier; public MelonPreferences_Entry<float> SoilPourSpeedMultiplier; public MelonPreferences_Entry<float> WaterTargetSizeMultiplier; public MelonPreferences_Entry<float> WaterTargetHoverTimeDamper; public MelonPreferences_Entry<float> BudSizeMultiplier; public MelonPreferences_Entry<float> SoilBagTearHitboxMultiplier; public MelonPreferences_Entry<float> VialCapSizeMultiplier; public Config() { //IL_02be: Unknown result type (might be due to invalid IL or missing references) Category = MelonPreferences.CreateCategory("EasyPlanting"); DragOverSoilChunks = Category.CreateEntry<bool>("DragOverSoilChunks", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); DragSpeedMultiplier = Category.CreateEntry<float>("DragSpeedMultiplier", 1.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); DragTurnSpeedMultiplier = Category.CreateEntry<float>("DragTurnSpeedMultiplier", 1.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); ((MelonEventBase<LemonAction<float, float>>)(object)DragSpeedMultiplier.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float old, float val) { foreach (DraggableSpeedChanger item in DraggableSpeedChanger.Registry) { item.ApplySizing(val, DragTurnSpeedMultiplier.Value); } }, 0, false); ((MelonEventBase<LemonAction<float, float>>)(object)DragTurnSpeedMultiplier.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float old, float val) { foreach (DraggableSpeedChanger item2 in DraggableSpeedChanger.Registry) { item2.ApplySizing(DragSpeedMultiplier.Value, val); } }, 0, false); SoilPourSpeedMultiplier = Category.CreateEntry<float>("SoilPourSpeedMultiplier", 4f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); WaterTargetSizeMultiplier = Category.CreateEntry<float>("WaterTargetSizeMultiplier", 1.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); WaterTargetHoverTimeDamper = Category.CreateEntry<float>("WaterTargetHoverTimeDamper", 1.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); ((MelonEventBase<LemonAction<float, float>>)(object)WaterTargetSizeMultiplier.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float old, float val) { foreach (WaterTargetModifier item3 in WaterTargetModifier.Registry) { item3.ApplySizing(val, WaterTargetHoverTimeDamper.Value); } }, 0, false); ((MelonEventBase<LemonAction<float, float>>)(object)WaterTargetHoverTimeDamper.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float old, float val) { foreach (WaterTargetModifier item4 in WaterTargetModifier.Registry) { item4.ApplySizing(WaterTargetSizeMultiplier.Value, val); } }, 0, false); BudSizeMultiplier = Category.CreateEntry<float>("BudSizeMultiplier", 2.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); ((MelonEventBase<LemonAction<float, float>>)(object)BudSizeMultiplier.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float old, float val) { foreach (BudSizer item5 in BudSizer.Registry) { item5.ApplySizing(val, val); } }, 0, false); SoilBagTearHitboxMultiplier = Category.CreateEntry<float>("SoilBagTearHitboxMultiplier", 1.5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); ((MelonEventBase<LemonAction<float, float>>)(object)SoilBagTearHitboxMultiplier.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float old, float val) { foreach (BagSizer item6 in BagSizer.Registry) { item6.ApplySizing(val); } }, 0, false); VialCapSizeMultiplier = Category.CreateEntry<float>("VialCapSizeMultiplier", 2f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); ((MelonEventBase<LemonAction<float, float>>)(object)VialCapSizeMultiplier.OnEntryValueChanged).Subscribe((LemonAction<float, float>)delegate(float old, float val) { foreach (VialCapSizer item7 in VialCapSizer.Registry) { item7.ApplySizing(val); } }, 0, false); FieldInfo[] fields = GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType.Name.StartsWith("MelonPreferences_Entry") && fieldInfo.CustomAttributes.Where((CustomAttributeData x) => x.AttributeType == typeof(ReloadRequiredAttribute)).Count() > 0) { ((MelonEventBase<LemonAction<object, object>>)(object)((MelonPreferences_Entry)fieldInfo.GetValue(this)).OnEntryValueChangedUntyped).Subscribe((LemonAction<object, object>)delegate { NotificationUtils.SendNotification("Reload save to apply.", "EasyPlanting", NotificationUtils.NotificationType.Warn); }, 0, false); } } } } } namespace EasyPlanting.Utils { public class Embedded { public static string ResourcePath = "EasyPlanting.Resources"; public static string ResolveResource(string name) { return ResourcePath + "." + name; } public static byte[]? LoadDataFromResource(Assembly target, string identifier) { Melon<ModMain>.Logger.Msg("Loading resource \"" + identifier + "\""); if (!target.GetManifestResourceNames().Contains(identifier)) { Melon<ModMain>.Logger.Error("Resource \"" + identifier + "\" Not Found."); return null; } using Stream stream = target.GetManifestResourceStream(identifier); if (stream == null) { Melon<ModMain>.Logger.Error("Resource \"" + identifier + "\" Unavailable."); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Melon<ModMain>.Logger.Msg($"Read {stream.Length} bytes from \"{identifier}\"."); return array; } public static Sprite? LoadSprite(string resource) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) byte[] array = LoadDataFromResource(((MelonBase)Melon<ModMain>.Instance).MelonAssembly.Assembly, ResolveResource(resource)); if (array == null) { Melon<ModMain>.Logger.Error("Failed to load Sprite \"" + resource + "\"."); return null; } Texture2D val = new Texture2D(2, 2); ((Object)val).name = Path.GetFileNameWithoutExtension(resource); ImageConversion.LoadImage(val, array, false); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one / 2f); } } public class NotificationUtils { public enum NotificationType { Good, Warn, Bad } public static Sprite WarnIcon = Embedded.LoadSprite("IconWarn.png") ?? FallbackSprite(); public static Sprite GoodIcon = Embedded.LoadSprite("IconGood.png") ?? FallbackSprite(); public static Sprite BadIcon = Embedded.LoadSprite("IconBad.png") ?? FallbackSprite(); internal static Sprite _fallbackSprite = FallbackSprite(); private static void fillTexture(Texture2D tex, Color c) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < ((Texture)tex).width; i++) { for (int j = 0; j < ((Texture)tex).height; j++) { tex.SetPixel(i, j, c); } } } public static Sprite FallbackSprite() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0029: 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_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fallbackSprite == (Object)null) { Texture2D val = new Texture2D(2, 2); fillTexture(val, new Color(255f, 0f, 255f)); _fallbackSprite = Sprite.Create(val, new Rect(0f, 0f, 2f, 2f), Vector2.one / 2f); } return _fallbackSprite; } public static void SendNotification(string text, string header = "Notification", NotificationType urgency = NotificationType.Good, int duration = 5, bool playSound = true) { Sprite val = null; switch (urgency) { case NotificationType.Good: val = GoodIcon; break; case NotificationType.Warn: val = WarnIcon; break; case NotificationType.Bad: val = BadIcon; break; } if (Singleton<NotificationsManager>.InstanceExists) { Melon<ModMain>.Logger.Msg((object)(((Object)(object)val == (Object)null) ? ((string)(object)val) : "null")); Singleton<NotificationsManager>.Instance.SendNotification(header, text, val, (float)duration, playSound); return; } string text2 = "[NOTIFICATION (ingame manager not loaded)] \"" + header + "\" - \"" + text + "\""; switch (urgency) { case NotificationType.Good: Melon<ModMain>.Logger.Msg(text2); val = _fallbackSprite; break; case NotificationType.Warn: Melon<ModMain>.Logger.Warning(text2); val = _fallbackSprite; break; case NotificationType.Bad: Melon<ModMain>.Logger.Error(text2); break; } } } [AttributeUsage(AttributeTargets.Field)] public class ReloadRequiredAttribute : Attribute { } } namespace EasyPlanting.Product { public static class BuildInfo { public const string ProductName = "EasyPlanting"; public const string ProductVersion = "1.0.0"; public const string ProductAuthor = "@joeswanson."; public const string ProductLink = "https://discord.gg/UH4FW8SZvV"; } } namespace EasyPlanting.Patches { [HarmonyPatch(typeof(Draggable))] public class DraggablePatches { [HarmonyPostfix] [HarmonyPatch("Awake")] public static void Awake(Draggable __instance) { Utils.GetOrAddComponent<DraggableSpeedChanger>(((Component)__instance).gameObject).ApplySizing(ModMain.config.DragSpeedMultiplier.Value, ModMain.config.DragTurnSpeedMultiplier.Value); } } [HarmonyPatch(typeof(Plant))] public class PlantPatches { [HarmonyPostfix] [HarmonyPatch("GrowthDone")] public static void GrowthDone(Plant __instance) { if (!(__instance is WeedPlant) || !__instance.IsFullyGrown) { return; } Transform[] growthSites = __instance.FinalGrowthStage.GrowthSites; foreach (Transform val in growthSites) { if ((Object)(object)((Component)val).gameObject.GetComponent<BudSizer>() == (Object)null) { ((Component)val).gameObject.AddComponent<BudSizer>(); } } } } [HarmonyPatch(typeof(PourableSoil))] public class PourableSoilPatches { [HarmonyPrefix] [HarmonyPatch("PourAmount")] public static void PourAmount(PourableSoil __instance, ref float amount) { amount *= ModMain.config.SoilPourSpeedMultiplier.Value; } [HarmonyPrefix] [HarmonyPatch("Awake")] public static void Awake(PourableSoil __instance) { BoxCollider[] componentsInChildren = ((Component)((Component)__instance).gameObject.transform.Find("Bone")).GetComponentsInChildren<BoxCollider>(); foreach (BoxCollider val in componentsInChildren) { Utils.GetOrAddComponent<BagSizer>(((Component)val).gameObject).ApplySizing(ModMain.config.SoilBagTearHitboxMultiplier.Value); } } } [HarmonyPatch(typeof(PourWaterTask))] public class PourWaterTaskPatches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] public static void ctor(PourWaterTask __instance, Pot _pot, ItemInstance _itemInstance, Pourable _pourablePrefab) { new WaterTargetModifier(__instance).ApplySizing(ModMain.config.WaterTargetSizeMultiplier.Value, ModMain.config.WaterTargetHoverTimeDamper.Value); } } [HarmonyPatch(typeof(Clickable))] public class VialCapPatches { [HarmonyPostfix] [HarmonyPatch("Awake")] public static void Awake(Clickable __instance) { VialCap val = (VialCap)(object)((__instance is VialCap) ? __instance : null); if (val != null) { Utils.GetOrAddComponent<VialCapSizer>(((Component)__instance).gameObject).ApplySizing(ModMain.config.VialCapSizeMultiplier.Value); } } } } namespace EasyPlanting.Behaviours { public class BagSizer : MonoBehaviour { public static List<BagSizer> Registry = new List<BagSizer>(); private BoxCollider collder = null; private Vector3 originalSize; private void Start() { //IL_000a: 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) BoxCollider component = ((Component)this).GetComponent<BoxCollider>(); originalSize = component.size; collder = component; ApplySizing(ModMain.config.SoilBagTearHitboxMultiplier.Value); Registry.Add(this); } public void ApplySizing(float multiplier) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)collder != (Object)null) { collder.size = originalSize * multiplier; } } } public class BudSizer : MonoBehaviour { public static List<BudSizer> Registry = new List<BudSizer>(); private CapsuleCollider capsule = null; private float initialHeight; private float initialRadius; private void Start() { CapsuleCollider componentInChildren = ((Component)this).GetComponentInChildren<CapsuleCollider>(); initialHeight = componentInChildren.height; initialRadius = componentInChildren.radius; capsule = componentInChildren; ApplySizing(ModMain.config.BudSizeMultiplier.Value, ModMain.config.BudSizeMultiplier.Value); Registry.Add(this); } public void ApplySizing(float radius, float height) { if ((Object)(object)capsule != (Object)null) { capsule.radius = initialRadius * radius; capsule.height = initialHeight * (height / 2f); } } } public class DraggableSpeedChanger : MonoBehaviour { public static List<DraggableSpeedChanger> Registry = new List<DraggableSpeedChanger>(); private Draggable draggable = null; private float originalDragForceMultiplier; private float originalTorqueMultiplier; private void Start() { Draggable component = ((Component)this).GetComponent<Draggable>(); originalDragForceMultiplier = component.DragForceMultiplier; originalTorqueMultiplier = component.TorqueMultiplier; draggable = component; ApplySizing(ModMain.config.DragSpeedMultiplier.Value, ModMain.config.DragTurnSpeedMultiplier.Value); Registry.Add(this); } public void ApplySizing(float dragForce, float torqueForce) { if ((Object)(object)draggable != (Object)null) { draggable.DragForceMultiplier = originalDragForceMultiplier * dragForce; draggable.TorqueMultiplier = originalTorqueMultiplier * torqueForce; } } } public class VialCapSizer : MonoBehaviour { public static List<VialCapSizer> Registry = new List<VialCapSizer>(); private VialCap cap = null; private float originalRadius; private void Start() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) VialCap component = ((Component)this).GetComponent<VialCap>(); originalRadius = ((SphereCollider)component.Collider).radius; cap = component; ApplySizing(ModMain.config.VialCapSizeMultiplier.Value); Registry.Add(this); } public void ApplySizing(float multiplier) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cap != (Object)null) { ((SphereCollider)cap.Collider).radius = originalRadius * multiplier; } } } public class WaterTargetModifier { public static List<WaterTargetModifier> Registry = new List<WaterTargetModifier>(); private PourWaterTask task; private float originalSuccessThreshold; private float originalSuccessTime; public WaterTargetModifier(PourWaterTask task) { this.task = task; originalSuccessThreshold = ((PourOntoTargetTask)task).SUCCESS_THRESHOLD; originalSuccessTime = ((PourOntoTargetTask)task).SUCCESS_TIME; ApplySizing(ModMain.config.WaterTargetSizeMultiplier.Value, ModMain.config.WaterTargetHoverTimeDamper.Value); Registry.Add(this); } public void ApplySizing(float size, float timeDamper) { if (task != null) { ((PourOntoTargetTask)task).SUCCESS_THRESHOLD = originalSuccessThreshold * size; ((PourOntoTargetTask)task).SUCCESS_TIME = originalSuccessTime / timeDamper; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }