Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of SuperGrow v1.0.0
SuperGrow_Mono.dll
Decompiled 7 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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 HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using S1API.Internal.Utils; using S1API.Lifecycle; using ScheduleOne; using ScheduleOne.DevUtilities; using ScheduleOne.Equipping; using ScheduleOne.Growing; using ScheduleOne.ItemFramework; using ScheduleOne.PlayerTasks; using ScheduleOne.PlayerTasks.Tasks; using ScheduleOne.StationFramework; using ScheduleOne.Storage; using ScheduleOne.Trash; using ScheduleOne.UI.Stations; using SuperGrow; using SuperGrow.Features; using SuperGrow.Patches; 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(Core), "SuperGrow", "1.0.0", "HazDS", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SuperGrow")] [assembly: AssemblyConfiguration("Mono")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e91ebad0306c99d8571da1d664f3f9b6604438aa")] [assembly: AssemblyProduct("SuperGrow")] [assembly: AssemblyTitle("SuperGrow")] [assembly: NeutralResourcesLanguage("en-US")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SuperGrow { public class Core : MelonMod { private bool _itemsInitialized; private static MelonPreferences_Category _prefsCategory; public static Core Instance { get; private set; } public static MelonPreferences_Entry<int> PgrRequired { get; private set; } public static MelonPreferences_Entry<int> SpeedGrowRequired { get; private set; } public static MelonPreferences_Entry<int> FertilizerRequired { get; private set; } public static MelonPreferences_Entry<int> OutputQuantity { get; private set; } public static MelonPreferences_Entry<float> YieldMultiplier { get; private set; } public static MelonPreferences_Entry<float> InstantGrowth { get; private set; } public static MelonPreferences_Entry<float> QualityChange { get; private set; } public override void OnInitializeMelon() { Instance = this; SetupConfig(); GameLifecycle.OnPreLoad += OnPreLoad; ((MelonBase)this).LoggerInstance.Msg("SuperGrow initialized!"); } private void SetupConfig() { _prefsCategory = MelonPreferences.CreateCategory("SuperGrow", "SuperGrow Settings"); PgrRequired = _prefsCategory.CreateEntry<int>("PgrRequired", 1, "PGR Required", "Amount of PGR needed per craft", false, false, (ValueValidator)null, (string)null); SpeedGrowRequired = _prefsCategory.CreateEntry<int>("SpeedGrowRequired", 1, "Speed Grow Required", "Amount of Speed Grow needed per craft", false, false, (ValueValidator)null, (string)null); FertilizerRequired = _prefsCategory.CreateEntry<int>("FertilizerRequired", 1, "Fertilizer Required", "Amount of Fertilizer needed per craft", false, false, (ValueValidator)null, (string)null); OutputQuantity = _prefsCategory.CreateEntry<int>("OutputQuantity", 3, "Output Quantity", "Amount of SuperGrow produced per craft", false, false, (ValueValidator)null, (string)null); YieldMultiplier = _prefsCategory.CreateEntry<float>("YieldMultiplier", 1.5f, "Yield Multiplier", "Yield multiplier applied to plants (1.5 = 50% more yield)", false, false, (ValueValidator)null, (string)null); InstantGrowth = _prefsCategory.CreateEntry<float>("InstantGrowth", 0.5f, "Instant Growth", "Instant growth progress (0.5 = 50% instant growth)", false, false, (ValueValidator)null, (string)null); QualityChange = _prefsCategory.CreateEntry<float>("QualityChange", 1f, "Quality Change", "Quality modifier applied to plants", false, false, (ValueValidator)null, (string)null); ClampEntry(PgrRequired, 1, 10); ClampEntry(SpeedGrowRequired, 1, 10); ClampEntry(FertilizerRequired, 1, 10); ClampEntry(OutputQuantity, 1, 10); ClampEntry(YieldMultiplier, 0.1f, 10f); ClampEntry(InstantGrowth, 0f, 1f); ClampEntry(QualityChange, -1f, 1f); } private static void ClampEntry(MelonPreferences_Entry<int> entry, int min, int max) { if (entry.Value < min) { entry.Value = min; } if (entry.Value > max) { entry.Value = max; } } private static void ClampEntry(MelonPreferences_Entry<float> entry, float min, float max) { if (entry.Value < min) { entry.Value = min; } if (entry.Value > max) { entry.Value = max; } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { if (sceneName == "Menu") { _itemsInitialized = false; ChemistryStationPatches.Reset(); } } private void OnPreLoad() { if (!_itemsInitialized) { ((MelonBase)this).LoggerInstance.Msg("Creating SuperGrow item..."); SuperGrowCreator.CreateSuperGrowItem(); _itemsInitialized = true; } } } } namespace SuperGrow.Utils { public static class Constants { public static class Game { public const string GAME_STUDIO = "TVGS"; public const string GAME_NAME = "Schedule I"; } public static class Additives { public const string PGR = "pgr"; public const string SPEED_GROW = "speedgrow"; public const string FERTILIZER = "fertilizer"; } public static class ItemIds { public const string SUPER_GROW = "supergrow"; } public static class DefaultEffects { public const float YIELD_MULTIPLIER = 1.5f; public const float INSTANT_GROWTH = 0.5f; public const float QUALITY_CHANGE = 1f; } public const string MOD_NAME = "SuperGrow"; public const string MOD_VERSION = "1.0.0"; public const string MOD_AUTHOR = "HazDS"; public const string PREFERENCES_CATEGORY = "SuperGrow"; } } namespace SuperGrow.Patches { [HarmonyPatch] public static class ChemistryStationPatches { private static StationRecipe _superGrowRecipe; private static bool _recipeAdded; private static bool _additivesPatched; private static readonly Dictionary<string, GameObject> _pourablePrefabs = new Dictionary<string, GameObject>(); private static readonly Dictionary<string, Color> _additiveColors = new Dictionary<string, Color> { { "pgr", new Color(1f, 0.506f, 0.506f, 1f) }, { "speedgrow", new Color(0.506f, 0.812f, 1f, 1f) }, { "fertilizer", new Color(0.639f, 1f, 0.506f, 1f) }, { "supergrow", new Color(1f, 0.5f, 0.7f, 1f) } }; private const float LIQUID_SCALE = 0.65f; private static Texture2D _superGrowLabelTexture; private static bool _pendingSuperGrowTrash = false; private static string _superGrowTrashId = null; public static void SetupAdditiveStationItems() { if (_additivesPatched) { return; } try { ItemDefinition item = Registry.GetItem("acid"); StorableItemDefinition val = (StorableItemDefinition)(object)((item is StorableItemDefinition) ? item : null); if ((Object)(object)val == (Object)null || (Object)(object)val.StationItem == (Object)null) { MelonLogger.Error("Could not get Acid StationItem as template"); return; } CachePourablePrefab("pgr", "growing/pgr/PGR_Pourable"); CachePourablePrefab("speedgrow", "growing/speedgrow/SpeedGrow_Pourable"); CachePourablePrefab("fertilizer", "growing/fertilizer/Fertilizer_Pourable"); SetupAdditiveStationItem("pgr", val.StationItem); SetupAdditiveStationItem("speedgrow", val.StationItem); SetupAdditiveStationItem("fertilizer", val.StationItem); _additivesPatched = true; MelonLogger.Msg("Set up StationItem on base additives for chemistry station compatibility"); } catch (Exception ex) { MelonLogger.Error("Failed to set up additive StationItems: " + ex.Message); MelonLogger.Error(ex.StackTrace); } } private static void CachePourablePrefab(string additiveId, string pourablePath) { GameObject val = Resources.Load<GameObject>(pourablePath); if ((Object)(object)val != (Object)null) { _pourablePrefabs[additiveId] = val; MelonLogger.Msg("Cached pourable prefab for " + additiveId); } else { MelonLogger.Warning("Could not load pourable prefab for " + additiveId + " at " + pourablePath); } } private static void LoadSuperGrowTexture() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown if ((Object)(object)_superGrowLabelTexture != (Object)null) { return; } try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = "SuperGrow.Assets.SuperGrow_Label.png"; using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream == null) { MelonLogger.Warning("Could not find embedded resource: " + text); return; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); _superGrowLabelTexture = new Texture2D(2, 2); ImageConversion.LoadImage(_superGrowLabelTexture, array); ((Object)_superGrowLabelTexture).name = "SuperGrow_Label"; MelonLogger.Msg("Loaded SuperGrow label texture from embedded resources"); } catch (Exception ex) { MelonLogger.Error("Failed to load SuperGrow texture: " + ex.Message); } } private static void ApplySuperGrowMaterials(MeshFilter[] targetMeshFilters) { Renderer[] renderers = (Renderer[])(object)targetMeshFilters?.Select((MeshFilter mf) => ((Component)mf).GetComponent<MeshRenderer>()).ToArray(); ApplySuperGrowMaterialsToRenderers(renderers); } public static void ApplySuperGrowMaterialsToRenderers(Renderer[] renderers) { //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) if (renderers == null) { return; } if ((Object)(object)_superGrowLabelTexture == (Object)null) { MelonLogger.Warning("SuperGrow label texture is null, cannot apply"); return; } try { Color val = default(Color); ((Color)(ref val))..ctor(0.6f, 0.4f, 0.8f, 1f); foreach (Renderer val2 in renderers) { if ((Object)(object)val2 == (Object)null) { continue; } string text = ((Object)val2).name.ToLower(); bool flag = text.Contains("label"); if (!flag) { Material[] sharedMaterials = val2.sharedMaterials; Material[] array = sharedMaterials; foreach (Material val3 in array) { if ((Object)(object)val3 != (Object)null && ((Object)val3).name.ToLower().Contains("label")) { flag = true; break; } } } bool flag2 = text.Contains("lid"); if (!flag2) { Material[] sharedMaterials2 = val2.sharedMaterials; Material[] array2 = sharedMaterials2; foreach (Material val4 in array2) { if ((Object)(object)val4 != (Object)null && ((Object)val4).name.ToLower().Contains("lid")) { flag2 = true; break; } } } if (flag) { Material[] materials = val2.materials; for (int l = 0; l < materials.Length; l++) { materials[l].SetTexture("_BaseMap", (Texture)(object)_superGrowLabelTexture); materials[l].SetTexture("_MainTex", (Texture)(object)_superGrowLabelTexture); } val2.materials = materials; MelonLogger.Msg("Applied SuperGrow label texture to " + ((Object)val2).name); } else if (flag2) { Material[] materials2 = val2.materials; for (int m = 0; m < materials2.Length; m++) { materials2[m].SetColor("_BaseColor", val); materials2[m].SetColor("_Color", val); } val2.materials = materials2; MelonLogger.Msg("Applied purple tint to SuperGrow lid: " + ((Object)val2).name); } } } catch (Exception ex) { MelonLogger.Error("Failed to apply SuperGrow materials: " + ex.Message); MelonLogger.Error(ex.StackTrace); } } private static void SetupAdditiveStationItem(string additiveId, StationItem templateStationItem) { ItemDefinition item = Registry.GetItem(additiveId); StorableItemDefinition val = (StorableItemDefinition)(object)((item is StorableItemDefinition) ? item : null); if ((Object)(object)val == (Object)null) { MelonLogger.Warning("Could not find additive: " + additiveId); return; } if ((Object)(object)val.StationItem != (Object)null) { MelonLogger.Msg(additiveId + " already has StationItem set"); return; } val.StationItem = templateStationItem; MelonLogger.Msg("Assigned Acid StationItem to " + additiveId); } public static void SwapStationItemVisuals(StationItem stationItem, StorableItemDefinition itemDef) { //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown //IL_041a: 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_046b: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)stationItem == (Object)null || (Object)(object)itemDef == (Object)null) { return; } string iD = ((ItemDefinition)itemDef).ID; if (string.IsNullOrEmpty(iD)) { return; } bool flag = iD == "supergrow"; if (!flag && iD != "pgr" && iD != "speedgrow" && iD != "fertilizer") { return; } MelonLogger.Msg($"SwapStationItemVisuals called for {iD}, isSuperGrow={flag}"); GameObject value = null; if (flag) { _pourablePrefabs.TryGetValue("pgr", out value); MelonLogger.Msg($"SuperGrow: PGR prefab found = {(Object)(object)value != (Object)null}"); } else if (!_pourablePrefabs.TryGetValue(iD, out value)) { return; } if ((Object)(object)value == (Object)null) { MelonLogger.Warning("Pourable prefab is null for " + iD); return; } try { MeshRenderer[] componentsInChildren = value.GetComponentsInChildren<MeshRenderer>(true); MeshFilter[] componentsInChildren2 = value.GetComponentsInChildren<MeshFilter>(true); if (componentsInChildren.Length == 0) { MelonLogger.Warning("No mesh renderers found in pourable prefab for " + iD); return; } Transform val = ((Component)stationItem).transform.Find("Pourable"); if ((Object)(object)val == (Object)null) { MelonLogger.Warning("No Pourable child found for " + iD); return; } Transform val2 = null; foreach (Transform item in val) { Transform val3 = item; if (((Object)val3).name.Contains("Bottle") || ((Object)val3).name.Contains("bottle")) { val2 = val3; break; } } if ((Object)(object)val2 == (Object)null) { MelonLogger.Warning("No visual container found for " + iD); return; } MeshRenderer[] componentsInChildren3 = ((Component)val2).GetComponentsInChildren<MeshRenderer>(true); MeshFilter[] componentsInChildren4 = ((Component)val2).GetComponentsInChildren<MeshFilter>(true); MeshFilter[] array = componentsInChildren4; foreach (MeshFilter val4 in array) { MeshRenderer component = ((Component)val4).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null) { continue; } string text = ((Object)val4).name.ToLower(); for (int j = 0; j < componentsInChildren2.Length; j++) { string text2 = ((Object)componentsInChildren2[j]).name.ToLower(); if ((text.Contains("body") && text2.Contains("body")) || (text.Contains("label") && text2.Contains("label")) || (text.Contains("lid") && text2.Contains("lid"))) { val4.sharedMesh = componentsInChildren2[j].sharedMesh; MeshRenderer component2 = ((Component)componentsInChildren2[j]).GetComponent<MeshRenderer>(); if ((Object)(object)component2 != (Object)null) { ((Renderer)component).sharedMaterials = ((Renderer)component2).sharedMaterials; } MelonLogger.Msg("Swapped mesh/materials for " + ((Object)val4).name + " on " + iD); break; } } } if (flag) { MelonLogger.Msg($"Applying SuperGrow texture in chemistry station, targetMeshFilters count: {((componentsInChildren4 != null) ? componentsInChildren4.Length : 0)}"); LoadSuperGrowTexture(); MelonLogger.Msg($"Texture loaded: {(Object)(object)_superGrowLabelTexture != (Object)null}"); ApplySuperGrowMaterials(componentsInChildren4); } PourableModule component3 = ((Component)val).GetComponent<PourableModule>(); if ((Object)(object)component3 != (Object)null && (Object)(object)component3.LiquidContainer != (Object)null) { LiquidContainer liquidContainer = component3.LiquidContainer; if ((Object)(object)liquidContainer.LiquidVolume != (Object)null) { Transform transform = ((Component)liquidContainer.LiquidVolume).transform; transform.localScale *= 0.65f; MelonLogger.Msg("Scaled LiquidVolume for " + iD); } liquidContainer.MaxLevel *= 0.65f; if (_additiveColors.TryGetValue(iD, out var value2)) { component3.LiquidColor = value2; component3.PourParticlesColor = value2; liquidContainer.SetLiquidColor(value2, true, true); MelonLogger.Msg("Set liquid color for " + iD); } } MelonLogger.Msg("Completed visual swap for " + iD + " StationItem"); } catch (Exception ex) { MelonLogger.Error("Failed to swap visuals for " + iD + ": " + ex.Message); MelonLogger.Error(ex.StackTrace); } } [HarmonyPatch(typeof(StationItem), "Initialize")] [HarmonyPostfix] public static void StationItem_Initialize_Postfix(StationItem __instance, StorableItemDefinition itemDefinition) { SwapStationItemVisuals(__instance, itemDefinition); } [HarmonyPatch(typeof(ChemistryStationCanvas), "Start")] [HarmonyPostfix] public static void ChemistryStationCanvas_Start_Postfix(ChemistryStationCanvas __instance) { if (_recipeAdded) { return; } try { SetupAdditiveStationItems(); if ((Object)(object)_superGrowRecipe == (Object)null) { CreateSuperGrowRecipe(); } if ((Object)(object)_superGrowRecipe == (Object)null) { MelonLogger.Warning("SuperGrow recipe is null, cannot add to chemistry station"); return; } __instance.Recipes.Add(_superGrowRecipe); StationRecipeEntry val = Object.Instantiate<StationRecipeEntry>(__instance.RecipeEntryPrefab, (Transform)(object)__instance.RecipeContainer); val.AssignRecipe(_superGrowRecipe); FieldInfo field = typeof(ChemistryStationCanvas).GetField("recipeEntries", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { if (field.GetValue(__instance) is List<StationRecipeEntry> list) { list.Add(val); MelonLogger.Msg("Added SuperGrow recipe entry to recipeEntries list"); } else { MelonLogger.Warning("recipeEntries list is null"); } } else { MelonLogger.Warning("Could not find recipeEntries field - recipe validation may not work"); } _recipeAdded = true; MelonLogger.Msg("Added SuperGrow recipe to Chemistry Station"); } catch (Exception ex) { MelonLogger.Error("Failed to add SuperGrow recipe: " + ex.Message); MelonLogger.Error(ex.StackTrace); } } private static void CreateSuperGrowRecipe() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) ItemDefinition item = Registry.GetItem("pgr"); ItemDefinition item2 = Registry.GetItem("speedgrow"); ItemDefinition item3 = Registry.GetItem("fertilizer"); ItemDefinition item4 = Registry.GetItem("supergrow"); if ((Object)(object)item == (Object)null || (Object)(object)item2 == (Object)null || (Object)(object)item3 == (Object)null) { MelonLogger.Error("Could not find one or more base additive definitions"); return; } if ((Object)(object)item4 == (Object)null) { MelonLogger.Error("Could not find SuperGrow definition - ensure item is created before recipe"); return; } _superGrowRecipe = ScriptableObject.CreateInstance<StationRecipe>(); _superGrowRecipe.RecipeTitle = "SuperGrow"; _superGrowRecipe.CookTime_Mins = 5; _superGrowRecipe.Unlocked = true; List<IngredientQuantity> list = new List<IngredientQuantity>(); IngredientQuantity val = new IngredientQuantity(); val.Items = new List<ItemDefinition> { item }; val.Quantity = Core.PgrRequired.Value; list.Add(val); IngredientQuantity val2 = new IngredientQuantity(); val2.Items = new List<ItemDefinition> { item2 }; val2.Quantity = Core.SpeedGrowRequired.Value; list.Add(val2); IngredientQuantity val3 = new IngredientQuantity(); val3.Items = new List<ItemDefinition> { item3 }; val3.Quantity = Core.FertilizerRequired.Value; list.Add(val3); _superGrowRecipe.Ingredients = list; ItemQuantity val4 = new ItemQuantity(); val4.Item = item4; val4.Quantity = Core.OutputQuantity.Value; _superGrowRecipe.Product = val4; _superGrowRecipe.FinalLiquidColor = new Color(0.4f, 0.2f, 0.6f, 1f); MelonLogger.Msg($"Created SuperGrow recipe: {Core.PgrRequired.Value}x PGR + {Core.SpeedGrowRequired.Value}x Speed Grow + {Core.FertilizerRequired.Value}x Fertilizer = {Core.OutputQuantity.Value}x SuperGrow"); } [HarmonyPatch(typeof(Equippable_Additive), "Equip")] [HarmonyPostfix] public static void Equippable_Additive_Equip_Postfix(Equippable_Additive __instance, ItemInstance item) { try { if (!(((item == null) ? null : item.Definition?.ID) != "supergrow")) { MelonLogger.Msg("SuperGrow equipped, applying custom visuals to held item"); LoadSuperGrowTexture(); Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { MelonLogger.Warning("No renderers found in SuperGrow equippable"); return; } ApplySuperGrowMaterialsToRenderers(componentsInChildren); MelonLogger.Msg($"Applied SuperGrow visuals to {componentsInChildren.Length} renderers in equippable"); } } catch (Exception ex) { MelonLogger.Error("Failed to apply SuperGrow visuals to equippable: " + ex.Message); } } [HarmonyPatch(typeof(StoredItem), "InitializeStoredItem")] [HarmonyPostfix] public static void StoredItem_InitializeStoredItem_Postfix(StoredItem __instance, StorableItemInstance _item) { try { if (!(((_item == null) ? null : ((ItemInstance)_item).Definition?.ID) != "supergrow")) { MelonLogger.Msg("SuperGrow stored, applying custom visuals to stored item"); LoadSuperGrowTexture(); Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { MelonLogger.Warning("No renderers found in SuperGrow stored item"); return; } ApplySuperGrowMaterialsToRenderers(componentsInChildren); MelonLogger.Msg($"Applied SuperGrow visuals to {componentsInChildren.Length} renderers in stored item"); } } catch (Exception ex) { MelonLogger.Error("Failed to apply SuperGrow visuals to stored item: " + ex.Message); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] public static void ApplyAdditiveToPot_Ctor_Postfix(ApplyAdditiveToPot __instance) { //IL_0110: 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) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) try { FieldInfo field = typeof(GrowContainerPourTask).GetField("item", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { MelonLogger.Warning("Could not find 'item' field in GrowContainerPourTask"); return; } object? value = field.GetValue(__instance); ItemInstance val = (ItemInstance)((value is ItemInstance) ? value : null); if (((val == null) ? null : val.Definition?.ID) != "supergrow") { return; } MelonLogger.Msg("SuperGrow ApplyAdditiveToPot created, applying custom visuals"); FieldInfo field2 = typeof(GrowContainerPourTask).GetField("pourable", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 == null) { MelonLogger.Warning("Could not find 'pourable' field in GrowContainerPourTask"); return; } object? value2 = field2.GetValue(__instance); Pourable val2 = (Pourable)((value2 is Pourable) ? value2 : null); if ((Object)(object)val2 == (Object)null) { MelonLogger.Warning("Pourable is null in ApplyAdditiveToPot"); return; } Color val3 = default(Color); ((Color)(ref val3))..ctor(0.4f, 0.2f, 0.6f, 1f); PourableAdditive val4 = (PourableAdditive)(object)((val2 is PourableAdditive) ? val2 : null); if ((Object)(object)val4 != (Object)null) { val4.LiquidColor = val3; MelonLogger.Msg("Set SuperGrow pourable liquid color to purple"); } if (val2.PourParticles != null) { ParticleSystem[] pourParticles = val2.PourParticles; foreach (ParticleSystem val5 in pourParticles) { if ((Object)(object)val5 != (Object)null) { MainModule main = val5.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val3); MelonLogger.Msg("Set particle system " + ((Object)val5).name + " color to purple"); } } } FieldInfo field3 = typeof(GrowContainerPourTask).GetField("growContainer", BindingFlags.Instance | BindingFlags.NonPublic); if (field3 != null) { object? value3 = field3.GetValue(__instance); GrowContainer val6 = (GrowContainer)((value3 is GrowContainer) ? value3 : null); if ((Object)(object)((val6 != null) ? val6.SurfaceCover : null) != (Object)null) { val6.SurfaceCover.ConfigureAppearance(val3, 0.28f); MelonLogger.Msg("Reconfigured surface cover with purple color"); } } LoadSuperGrowTexture(); Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { MelonLogger.Warning("No renderers found in SuperGrow pourable"); return; } ApplySuperGrowMaterialsToRenderers(componentsInChildren); MelonLogger.Msg($"Applied SuperGrow visuals to {componentsInChildren.Length} renderers in pourable"); if ((Object)(object)val2.TrashItem != (Object)null) { _superGrowTrashId = val2.TrashItem.ID; _pendingSuperGrowTrash = true; MelonLogger.Msg("Tracking SuperGrow trash with ID: " + _superGrowTrashId); } } catch (Exception ex) { MelonLogger.Error("Failed to apply SuperGrow visuals to pourable: " + ex.Message); MelonLogger.Error(ex.StackTrace); } } [HarmonyPatch(typeof(TrashItem), "Start")] [HarmonyPostfix] public static void TrashItem_Start_Postfix(TrashItem __instance) { try { if (_pendingSuperGrowTrash && _superGrowTrashId != null && !(__instance.ID != _superGrowTrashId)) { MelonLogger.Msg("SuperGrow trash created (ID: " + __instance.ID + "), applying custom visuals"); _pendingSuperGrowTrash = false; LoadSuperGrowTexture(); Renderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { MelonLogger.Warning("No renderers found in SuperGrow trash item"); return; } ApplySuperGrowMaterialsToRenderers(componentsInChildren); MelonLogger.Msg($"Applied SuperGrow visuals to {componentsInChildren.Length} renderers in trash item"); } } catch (Exception ex) { MelonLogger.Error("Failed to apply SuperGrow visuals to trash item: " + ex.Message); } } public static void Reset() { _recipeAdded = false; _pendingSuperGrowTrash = false; _superGrowTrashId = null; } } } namespace SuperGrow.Features { public static class SuperGrowCreator { private static AdditiveDefinition _superGrowDefinition; private static Sprite _icon; public static void CreateSuperGrowItem() { try { LoadIcon(); CreateAdditiveDefinition(); MelonLogger.Msg("Created SuperGrow item (ID: supergrow)"); } catch (Exception ex) { MelonLogger.Error("Failed to create SuperGrow item: " + ex.Message); MelonLogger.Error(ex.StackTrace); } } private static void LoadIcon() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = "SuperGrow.Assets.SuperGrow_Icon.png"; _icon = ImageUtils.LoadImageFromResource(executingAssembly, text, 100f, (FilterMode)1); if ((Object)(object)_icon == (Object)null) { MelonLogger.Warning("Could not load SuperGrow icon, using default"); } } catch (Exception ex) { MelonLogger.Warning("Failed to load icon: " + ex.Message); } } private static void CreateAdditiveDefinition() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) ItemDefinition item = Registry.GetItem("pgr"); AdditiveDefinition val = (AdditiveDefinition)(object)((item is AdditiveDefinition) ? item : null); if ((Object)(object)val == (Object)null) { ItemDefinition item2 = Registry.GetItem("speedgrow"); val = (AdditiveDefinition)(object)((item2 is AdditiveDefinition) ? item2 : null); } if ((Object)(object)val == (Object)null) { ItemDefinition item3 = Registry.GetItem("fertilizer"); val = (AdditiveDefinition)(object)((item3 is AdditiveDefinition) ? item3 : null); } if ((Object)(object)val == (Object)null) { MelonLogger.Error("Could not find any existing additive to clone from!"); return; } _superGrowDefinition = ScriptableObject.CreateInstance<AdditiveDefinition>(); ((ItemDefinition)_superGrowDefinition).Category = ((ItemDefinition)val).Category; ((ItemDefinition)_superGrowDefinition).StackLimit = ((ItemDefinition)val).StackLimit; ((ItemDefinition)_superGrowDefinition).Keywords = ((ItemDefinition)val).Keywords; ((ItemDefinition)_superGrowDefinition).AvailableInDemo = ((ItemDefinition)val).AvailableInDemo; ((ItemDefinition)_superGrowDefinition).UsableInFilters = ((ItemDefinition)val).UsableInFilters; ((StorableItemDefinition)_superGrowDefinition).ResellMultiplier = ((StorableItemDefinition)val).ResellMultiplier; ((StorableItemDefinition)_superGrowDefinition).ShopCategories = ((StorableItemDefinition)val).ShopCategories; ((ItemDefinition)_superGrowDefinition).legalStatus = ((ItemDefinition)val).legalStatus; ((ItemDefinition)_superGrowDefinition).Equippable = ((ItemDefinition)val).Equippable; ((StorableItemDefinition)_superGrowDefinition).StoredItem = ((StorableItemDefinition)val).StoredItem; ((StorableItemDefinition)_superGrowDefinition).StationItem = ((StorableItemDefinition)val).StationItem; ((ItemDefinition)_superGrowDefinition).ID = "supergrow"; ((ItemDefinition)_superGrowDefinition).Name = "SuperGrow"; ((ItemDefinition)_superGrowDefinition).Description = "A powerful growth enhancer combining the effects of PGR, Speed Grow, and Fertilizer. Apply to plants for increased yield, faster growth, and improved quality."; ((Object)_superGrowDefinition).name = "SuperGrow"; ((ItemDefinition)_superGrowDefinition).LabelDisplayColor = ((ItemDefinition)val).LabelDisplayColor; ((StorableItemDefinition)_superGrowDefinition).BasePurchasePrice = ((StorableItemDefinition)val).BasePurchasePrice; if ((Object)(object)_icon != (Object)null) { ((ItemDefinition)_superGrowDefinition).Icon = _icon; } else { ((ItemDefinition)_superGrowDefinition).Icon = ((ItemDefinition)val).Icon; } SetPrivateProperty(_superGrowDefinition, "QualityChange", Core.QualityChange.Value); SetPrivateProperty(_superGrowDefinition, "YieldMultiplier", Core.YieldMultiplier.Value); SetPrivateProperty(_superGrowDefinition, "InstantGrowth", Core.InstantGrowth.Value); if ((Object)(object)val.DisplayMaterial != (Object)null) { Material val2 = new Material(val.DisplayMaterial); val2.color = new Color(0.3f, 0.9f, 0.3f, 1f); SetPrivateProperty(_superGrowDefinition, "DisplayMaterial", val2); } Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)_superGrowDefinition); MelonLogger.Msg("Cloned properties from " + ((ItemDefinition)val).Name + " for SuperGrow"); } private static void SetPrivateProperty(object obj, string propertyName, object value) { Type type = obj.GetType(); FieldInfo field = type.GetField("<" + propertyName + ">k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(obj, value); return; } PropertyInfo property = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { property.SetValue(obj, value); } else { MelonLogger.Warning("Could not set property " + propertyName + " on " + type.Name); } } } }