Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of UnicornsCustomSeeds v1.1.1
UnicornsCustomSeeds_IL2Cpp_1.1.1.dll
Decompiled 2 months agousing System; using System.Collections; 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 Il2Cpp; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFluffyUnderware.DevTools.Extensions; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.AvatarFramework.Equipping; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Dialogue; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.EntityFramework; using Il2CppScheduleOne.Equipping; using Il2CppScheduleOne.Growing; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Management; using Il2CppScheduleOne.Messaging; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.CharacterClasses; using Il2CppScheduleOne.NPCs.Relation; using Il2CppScheduleOne.ObjectScripts; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Product; using Il2CppScheduleOne.Product.Packaging; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.StationFramework; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.UI.MainMenu; using Il2CppScheduleOne.UI.Phone; using Il2CppScheduleOne.UI.Phone.Delivery; using Il2CppScheduleOne.UI.Phone.Messages; using Il2CppScheduleOne.UI.Phone.ProductManagerApp; using Il2CppScheduleOne.UI.Shop; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.IO; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1API.Quests; using S1API.Saveables; using UnicornsCustomSeeds; using UnicornsCustomSeeds.Managers; using UnicornsCustomSeeds.Patches; using UnicornsCustomSeeds.SeedQuests; using UnicornsCustomSeeds.Seeds; using UnicornsCustomSeeds.TemplateUtils; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [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), "Unicorns Custom Seeds", "1.1.1", "OverweightUnicorn", null)] [assembly: MelonColor(255, 191, 0, 255)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("UnicornsCustomSeeds_IL2Cpp_1.1.1")] [assembly: AssemblyConfiguration("IL2CPP")] [assembly: AssemblyFileVersion("1.1.1")] [assembly: AssemblyInformationalVersion("1.0.0+0ea043a8feb584ee5677fdd4bbe56297e6c59355")] [assembly: AssemblyProduct("UnicornsCustomSeeds_IL2Cpp_1.1.1")] [assembly: AssemblyTitle("UnicornsCustomSeeds_IL2Cpp_1.1.1")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 UnicornsCustomSeeds { public static class BuildInfo { public const string Name = "Unicorns Custom Seeds"; public const string Description = "Your good buddy Unicorn can help you synthesize seeds"; public const string Author = "OverweightUnicorn"; public const string Company = "UnicornsCanMod"; public const string Version = "1.1.1"; public const string DownloadLink = null; } public class Core : MelonMod { public override void OnInitializeMelon() { AssetBundleUtils.Initialize(this); } public override void OnLateInitializeMelon() { StashManager.InitializeConfig(); SeedVisualsManager.LoadSeedMaterial(); Singleton<LoadManager>.Instance.onLoadComplete.AddListener(UnityAction.op_Implicit((Action)InitMod)); Singleton<SaveManager>.Instance.onSaveComplete.AddListener(UnityAction.op_Implicit((Action)SaveData)); } public void SaveData() { try { string loadedGameFolderPath = Singleton<LoadManager>.Instance.LoadedGameFolderPath; if (!string.IsNullOrEmpty(loadedGameFolderPath) && Directory.Exists(loadedGameFolderPath)) { string path = Path.Combine(loadedGameFolderPath, "DiscoveredCustomSeeds.json"); List<UnicornSeedData> list = CustomSeedsManager.DiscoveredSeeds.Values.ToList(); string contents = JsonConvert.SerializeObject((object)list, (Formatting)1); File.WriteAllText(path, contents); } } catch (Exception e) { Utility.PrintException(e); } } public void InitMod() { CustomSeedsManager.Initialize(); StashManager.GetAlbertsStash(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { SeedDefinition item = Registry.GetItem<SeedDefinition>("ogkushseed"); if (CustomSeedsManager.factory == null && (Object)(object)item != (Object)null) { CustomSeedsManager.factory = new SeedFactory(item); } StashManager.GetAlbertsStash(); if (sceneName.ToLower() != "main") { CustomSeedsManager.ClearAll(); ProductManagerAppPatches.ClearPendingIndicators(); } else if ((Object)(object)SeedVisualsManager.seedIcon == (Object)null || (Object)(object)SeedVisualsManager.baseSeedSprite == (Object)null) { SeedVisualsManager.LoadSeedMaterial(); } } } } namespace UnicornsCustomSeeds.TemplateUtils { public static class AssetBundleUtils { private static Core mod; private static MelonAssembly melonAssembly; private static Dictionary<string, Il2CppAssetBundle> assetBundles = new Dictionary<string, Il2CppAssetBundle>(); public static void Initialize(Core coreMod) { mod = coreMod; melonAssembly = ((MelonBase)mod).MelonAssembly; } public static Il2CppAssetBundle LoadAssetBundle(string bundleFileName) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown if (assetBundles.ContainsKey(bundleFileName)) { return assetBundles[bundleFileName]; } try { string text = typeof(Core).Namespace + ".Assets." + bundleFileName; Stream manifestResourceStream = melonAssembly.Assembly.GetManifestResourceStream(text ?? ""); if (manifestResourceStream == null) { ((MelonBase)mod).Unregister($"AssetBundle: '{text}' not found. \nOpen .csproj file and search for '{bundleFileName}'.\nIf it doesn't exist,\nCopy your asset to Assets/ folder then look for 'your.assetbundle' in .csproj file.", false); return null; } byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { manifestResourceStream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Stream val = (Stream)new MemoryStream(Il2CppStructArray<byte>.op_Implicit(array)); Il2CppAssetBundle val2 = Il2CppAssetBundleManager.LoadFromStream(val); assetBundles.Add(bundleFileName, val2); return val2; } catch (Exception value) { ((MelonBase)mod).Unregister($"Failed to load AssetBundle. Please report to dev: {value}", false); return null; } } public static Il2CppAssetBundle GetLoadedAssetBundle(string bundleName) { if (assetBundles.ContainsKey(bundleName)) { return assetBundles[bundleName]; } ((MelonBase)mod).Unregister("Failed to get " + bundleName, false); throw new Exception("Asset '" + bundleName + "' has not been loaded in yet"); } public static T LoadAssetFromBundle<T>(string assetName, string bundleName) where T : Object { Il2CppAssetBundle loadedAssetBundle = GetLoadedAssetBundle(bundleName); if (loadedAssetBundle == null) { throw new Exception("Couldn't find " + bundleName + ", Did you load it?"); } T val = loadedAssetBundle.LoadAsset<T>(assetName); if ((Object)(object)val == (Object)null) { throw new Exception(assetName + " not found in bundle"); } return val; } } public static class Utility { public static void PrintException(Exception e) { MelonLogger.Msg(ConsoleColor.Red, e.GetType().FullName); MelonLogger.Msg(ConsoleColor.DarkRed, e.Message); if (!string.IsNullOrWhiteSpace(e.StackTrace)) { MelonLogger.Msg(ConsoleColor.DarkRed, "StackTrace:"); string[] array = e.StackTrace.Split('\n'); foreach (string text in array) { MelonLogger.Msg(ConsoleColor.DarkRed, " " + text.Trim()); } } if (e.InnerException != null) { MelonLogger.Msg(ConsoleColor.DarkRed, " -- Inner Exception --"); PrintException(e.InnerException); } } public static void Error(string msg) { MelonLogger.Msg(ConsoleColor.Red, msg); } public static void Log(string msg) { MelonLogger.Msg(ConsoleColor.DarkMagenta, msg); } public static void Success(string msg) { MelonLogger.Msg(ConsoleColor.Green, msg); } } } namespace UnicornsCustomSeeds.Seeds { [Serializable] public class UnicornSeedData { public string seedId { get; set; } public string weedId { get; set; } public string baseSeedId { get; set; } public float price { get; set; } } public class SeedFactory { private Transform rootGameObject; private WeedPlant basePlantPrefab; private PlantHarvestable baseBranchPrefab; private FunctionalSeed baseFunctionalSeedPrefab; private Equippable_Seed baseEquippableSeedPrefab; private AvatarEquippable baseAvatarEquippablePrefab; private StoredItem baseStorableItem; public SeedDefinition baseSeedDefinition; public SeedFactory(SeedDefinition seedDefinition) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown baseSeedDefinition = seedDefinition; baseFunctionalSeedPrefab = seedDefinition.FunctionSeedPrefab; baseStorableItem = ((StorableItemDefinition)seedDefinition).StoredItem; InitializeBasePlant(seedDefinition); InitializeEquippable(seedDefinition); if ((Object)(object)rootGameObject == (Object)null) { GameObject val = new GameObject(((BaseItemDefinition)baseSeedDefinition).ID + "_CustomSeeds"); val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); rootGameObject = val.transform; } } private void InitializeBasePlant(SeedDefinition seedDefinition) { WeedPlant val = ((Il2CppObjectBase)seedDefinition.PlantPrefab).TryCast<WeedPlant>(); if ((Object)(object)val != (Object)null) { basePlantPrefab = val; if ((Object)(object)basePlantPrefab != (Object)null) { baseBranchPrefab = basePlantPrefab.BranchPrefab; } } else { Utility.Log("Failed to cast PlantPrefab to WeedPlant."); } } private void InitializeEquippable(SeedDefinition seedDefinition) { Equippable_Seed val = ((Il2CppObjectBase)((ItemDefinition)seedDefinition).Equippable).TryCast<Equippable_Seed>(); if ((Object)(object)val != (Object)null) { baseEquippableSeedPrefab = val; baseAvatarEquippablePrefab = ((Equippable_Viewmodel)val).AvatarEquippable; } else { Utility.Log("Failed to cast Equippable to Equippable_Seed."); } } public void DeleteChildren() { TransformExt.DeleteChildren(rootGameObject, true, false); } private void GrowLabel(Transform root, string seedDefId) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Transform val = null; Il2CppArrayBase<Transform> componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(); foreach (Transform item in componentsInChildren) { if (((Object)item).name == "Label") { val = ((Component)item).transform; } } if ((Object)(object)val != (Object)null) { val.localScale = new Vector3(1.05f, 1.05f, 2f); val.position = new Vector3(0f, -0.05f, 0f); if ((Object)(object)SeedVisualsManager.customMat == (Object)null) { SeedVisualsManager.LoadSeedMaterial(); } if ((Object)(object)SeedVisualsManager.customMat != (Object)null) { Renderer component = ((Component)val).GetComponent<Renderer>(); component.material = SeedVisualsManager.customMat; ((Component)val).gameObject.AddComponent<SeedVialLabel>(); ((Object)val).name = ((Object)val).name + ":" + seedDefId; } else { Utility.Log("MATERIAL NOT LOADED!!!"); } } } public WeedPlant ClonePlantPrefab(WeedDefinition newDef) { if ((Object)(object)basePlantPrefab == (Object)null) { throw new InvalidOperationException("Base plant prefab not initialized."); } WeedPlant val = Object.Instantiate<WeedPlant>(basePlantPrefab, rootGameObject); SetPlantAppearance(newDef, val); PlantHarvestable val2 = CloneBranchPrefab(newDef); SetBranchAppearance(((Component)val2).transform, newDef); val.BranchPrefab = val2; Il2CppArrayBase<PlantHarvestable> componentsInChildren = ((Component)val).GetComponentsInChildren<PlantHarvestable>(); foreach (PlantHarvestable item in componentsInChildren) { item.Product = (StorableItemDefinition)(object)newDef; } return val; } public void SetPlantAppearance(WeedDefinition newDef, WeedPlant plant) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) foreach (PlantGrowthStage item in (Il2CppArrayBase<PlantGrowthStage>)(object)((Plant)plant).GrowthStages) { WeedAppearanceSettings val = newDef.appearance; if (val == null) { val = WeedDefinition.GetAppearanceSettings(((PropertyItemDefinition)newDef).Properties); } if ((Object)(object)item != (Object)null && val != null) { for (int i = 0; i < ((Component)item).transform.childCount; i++) { Transform child = ((Component)item).transform.GetChild(i); if ((Object)(object)child == (Object)null) { continue; } MeshRenderer component = ((Component)child).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null) { continue; } Material material = ((Renderer)component).material; if ((Object)(object)material == (Object)null) { continue; } if (((Object)child).name == "Stem") { material.color = Color32.op_Implicit(val.StemColor); } if (((Object)child).name == "BigLeaves") { material.color = Color32.op_Implicit(val.LeafColor); } if (((Object)child).name == "SmallLeaves") { material.color = Color32.op_Implicit(val.LeafColor); } foreach (Transform item2 in (Il2CppArrayBase<Transform>)(object)item.GrowthSites) { if ((Object)(object)item2 != (Object)null) { Transform child2 = item2.GetChild(0); if (Object.op_Implicit((Object)(object)child2)) { SetBranchAppearance(child2, val); } } } } } else { Utility.Error("Plant Stage is NULL! Thats impossible"); } } } public void SetBranchAppearance(Transform branchTransform, WeedDefinition weedDef) { WeedAppearanceSettings val = weedDef.appearance; if (val == null) { val = WeedDefinition.GetAppearanceSettings(((PropertyItemDefinition)weedDef).Properties); } if (val != null && (Object)(object)branchTransform != (Object)null) { SetBranchAppearance(branchTransform, val); } } public void SetBranchAppearance(Transform branchTransform, WeedAppearanceSettings weedAppearance) { //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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) Transform child = branchTransform.GetChild(0); Transform val = ((child != null) ? child.GetChild(0) : null); if ((Object)(object)val == (Object)null) { return; } for (int i = 0; i < val.childCount; i++) { Transform child2 = val.GetChild(i); if ((Object)(object)child2 == (Object)null) { continue; } MeshRenderer component = ((Component)child2).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null) { continue; } Material material = ((Renderer)component).material; if (!((Object)(object)material == (Object)null)) { if (((Object)child2).name == "Stem") { material.color = Color32.op_Implicit(weedAppearance.StemColor); } if (((Object)child2).name == "Leaves") { material.color = Color32.op_Implicit(weedAppearance.LeafColor); } if (((Object)child2).name == "Main") { material.color = Color32.op_Implicit(weedAppearance.MainColor); } if (((Object)child2).name == "Secondary") { material.color = Color32.op_Implicit(weedAppearance.SecondaryColor); } } } } public PlantHarvestable CloneBranchPrefab(WeedDefinition newDef) { if ((Object)(object)baseBranchPrefab == (Object)null) { throw new InvalidOperationException("Base branch prefab not initialized."); } PlantHarvestable val = Object.Instantiate<PlantHarvestable>(baseBranchPrefab, rootGameObject); ((Object)((Component)val).gameObject).name = ((BaseItemDefinition)newDef).ID + "_Harvestable"; ((Component)val).gameObject.layer = ((Component)baseBranchPrefab).gameObject.layer; val.Product = (StorableItemDefinition)(object)newDef; return val; } public FunctionalSeed CloneFunctionalSeedPrefab(string seedDefId) { if ((Object)(object)baseFunctionalSeedPrefab == (Object)null) { throw new InvalidOperationException("Base functional seed prefab not initialized."); } FunctionalSeed val = Object.Instantiate<FunctionalSeed>(baseFunctionalSeedPrefab, rootGameObject); GrowLabel(((Component)val).transform, seedDefId); return val; } public Equippable_Seed CloneEquippableSeedPrefab(SeedDefinition newDef, WeedAppearanceSettings weedAppearance) { if ((Object)(object)baseEquippableSeedPrefab == (Object)null) { throw new InvalidOperationException("Base equippable seed prefab not initialized."); } Equippable_Seed val = Object.Instantiate<Equippable_Seed>(baseEquippableSeedPrefab, rootGameObject); GrowLabel(((Component)val).transform, ((BaseItemDefinition)newDef).ID); ((Object)((Component)val).gameObject).name = ((BaseItemDefinition)newDef).ID + "_Equippable"; ((Component)val).gameObject.layer = ((Component)baseEquippableSeedPrefab).gameObject.layer; val.Seed = newDef; ((Equippable_Viewmodel)val).AvatarEquippable = CloneAvatarEquippablePrefab(((BaseItemDefinition)newDef).ID); ((Object)((Equippable_Viewmodel)val).AvatarEquippable).name = ((BaseItemDefinition)newDef).ID + "_AvatarEquippable"; return val; } public AvatarEquippable CloneAvatarEquippablePrefab(string newDefId) { if ((Object)(object)baseAvatarEquippablePrefab == (Object)null) { throw new InvalidOperationException("Base avatar equippable prefab not initialized."); } AvatarEquippable val = Object.Instantiate<AvatarEquippable>(baseAvatarEquippablePrefab, rootGameObject); GrowLabel(((Component)val).transform, newDefId); return val; } public StoredItem CloneStoredItem(string newDefId) { if ((Object)(object)baseStorableItem == (Object)null) { throw new InvalidOperationException("Base Stored Item not initialized."); } StoredItem val = Object.Instantiate<StoredItem>(baseStorableItem, rootGameObject); GrowLabel(((Component)val).transform, newDefId); return val; } public SeedDefinition CreateSeedDefinition(WeedDefinition weedDef) { //IL_0145: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseSeedDefinition == (Object)null) { throw new InvalidOperationException("Base seed definition not initialized."); } SeedDefinition val = Object.Instantiate<SeedDefinition>(baseSeedDefinition); WeedAppearanceSettings val2 = weedDef.appearance; if (val2 == null) { val2 = WeedDefinition.GetAppearanceSettings(((PropertyItemDefinition)weedDef).Properties); } ((Object)val).name = ((BaseItemDefinition)weedDef).ID + "_customseeddefinition"; ((BaseItemDefinition)val).ID = ((BaseItemDefinition)weedDef).ID + "_customseeddefinition"; ((BaseItemDefinition)val).Name = ((Object)weedDef).name + " Seed"; ((BaseItemDefinition)val).Description = ((Object)weedDef).name + " Seed"; ((BaseItemDefinition)val).Icon = ((BaseItemDefinition)baseSeedDefinition).Icon; ((ItemDefinition)val).Equippable = (Equippable)(object)CloneEquippableSeedPrefab(val, val2); val.PlantPrefab = (Plant)(object)ClonePlantPrefab(weedDef); val.PlantPrefab.SeedDefinition = val; val.FunctionSeedPrefab = CloneFunctionalSeedPrefab(((BaseItemDefinition)val).ID); ((Object)val.FunctionSeedPrefab).name = ((BaseItemDefinition)weedDef).ID + "Seed_Functional"; ((StorableItemDefinition)val).StoredItem = CloneStoredItem(((BaseItemDefinition)val).ID); SeedVisualsManager.appearanceMap.Add(((BaseItemDefinition)val).ID, val2); if ((Object)(object)SeedVisualsManager.baseSeedSprite != (Object)null) { try { Sprite val3 = SeedVisualsManager.GenerateSpriteWithGradient(Color32.op_Implicit(val2.MainColor), Color32.op_Implicit(val2.SecondaryColor)); ((Object)val3).name = ((Object)val).name + "_icon"; SeedVisualsManager.seedIcons.Add(((BaseItemDefinition)val).ID, val3); ((BaseItemDefinition)val).Icon = val3; } catch (Exception e) { ((BaseItemDefinition)val).Icon = SeedVisualsManager.baseSeedSprite; Utility.PrintException(e); } } return val; } } [RegisterTypeInIl2Cpp] public class SeedVialLabel : MonoBehaviour { private Renderer rend; private MaterialPropertyBlock block; public Color colorA; public Color colorB; public bool useRandomColors = false; private void Start() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (useRandomColors) { colorA = Random.ColorHSV(); colorB = Random.ColorHSV(); } rend = ((Component)this).GetComponent<Renderer>(); block = new MaterialPropertyBlock(); SetupLabel(); } public void SetupLabel() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rend == (Object)null) { return; } MeshFilter component = ((Component)this).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { string key = ((Object)this).name.Split(':')[1]; SeedVisualsManager.appearanceMap.TryGetValue(key, out var value); if (value != null) { colorA = Color32.op_Implicit(value.MainColor); colorB = Color32.op_Implicit(value.SecondaryColor); } Bounds bounds = component.sharedMesh.bounds; rend.GetPropertyBlock(block); block.SetColor("_ColorA", colorA); block.SetColor("_ColorB", colorB); block.SetFloat("_MinZ", ((Bounds)(ref bounds)).min.z); block.SetFloat("_MaxZ", ((Bounds)(ref bounds)).max.z); rend.SetPropertyBlock(block); } } } } namespace UnicornsCustomSeeds.SeedQuests { public class CustomSeedQuest : Quest { [SaveableField("QuestData")] private CustomSeedQuestData _data = new CustomSeedQuestData(); public QuestEntry customSeedEntry; protected override string Title => "Drop off the Mix"; protected override string Description => $"Take {StashManager.StashQtyEntry.Value}x of your weed mix and ${StashManager.StashCostEntry.Value} dollary doos to Albert Hoovers supply stash"; protected override void OnLoaded() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (base.QuestEntries.Count == 0) { customSeedEntry = ((Quest)this).AddEntry($"Give Albert {StashManager.StashQtyEntry.Value}x of a Weed Mix and ${StashManager.StashCostEntry.Value}", (Vector3?)((Component)StashManager.albertsStash).transform.position); } } protected override void OnCreated() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (base.QuestEntries.Count == 0) { customSeedEntry = ((Quest)this).AddEntry($"Give Albert {StashManager.StashQtyEntry.Value}x of a Weed Mix and ${StashManager.StashCostEntry.Value}", (Vector3?)((Component)StashManager.albertsStash).transform.position); } } } [Serializable] public class CustomSeedQuestData { public float quantity { get; set; } = 0f; public string seedId { get; set; } = string.Empty; } } namespace UnicornsCustomSeeds.Patches { [HarmonyPatch(typeof(QuestManager), "OnSpawnServer")] public static class QuestManager_OnSpawnServer_Patch { public static void Postfix(NetworkConnection connection) { if (InstanceFinder.IsServer && QuestManager.GetQuestByName("Drop off the Mix") is CustomSeedQuest) { SeedQuestManager.BroadcastCustomQuest(); } } } [HarmonyPatch(typeof(ProductManager), "OnSpawnServer")] public static class ProductManager_OnSpawnServer_NetTest { public static void Postfix(ProductManager __instance, NetworkConnection connection) { //IL_0044: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown if (connection == (NetworkConnection)null || !InstanceFinder.IsServer || connection.IsHost) { return; } List<string> val = new List<string>(); WeedAppearanceSettings val2 = new WeedAppearanceSettings(Color32.op_Implicit(__instance.DefaultWeed.MainMat.color), Color32.op_Implicit(__instance.DefaultWeed.SecondaryMat.color), Color32.op_Implicit(__instance.DefaultWeed.LeafMat.color), Color32.op_Implicit(__instance.DefaultWeed.StemMat.color)); foreach (KeyValuePair<string, UnicornSeedData> discoveredSeed in CustomSeedsManager.DiscoveredSeeds) { __instance.CreateWeed_Server("[NET-JSON]" + JsonConvert.SerializeObject((object)discoveredSeed.Value, (Formatting)0), "ogkushseed", (EDrugType)0, val, val2); } } } [HarmonyPatch(typeof(ProductManager), "RpcLogic___CreateWeed_1777266891")] public static class ProductManager_RpcLogic_CreateWeed_NetTest { public static void Postfix(ProductManager __instance, NetworkConnection conn, string name, string id, EDrugType type, List<string> properties, WeedAppearanceSettings appearance) { if (id != "ogkushseed" || name == null) { return; } if (name.StartsWith("[NET-QUEST]") && InstanceFinder.IsClientOnly) { string text = name.Replace("[NET-QUEST]", ""); try { string[] array = text.Split(','); if (array.Length == 3) { if (int.TryParse(array[0], out var result)) { StashManager.StashCostEntry.Value = result; } if (int.TryParse(array[1], out var result2)) { StashManager.StashQtyEntry.Value = result2; } if (int.TryParse(array[2], out var result3)) { StashManager.SynthesizeTime.Value = result3; } } } catch (Exception e) { Utility.PrintException(e); } if ((Object)(object)StashManager.albertsStash == (Object)null) { StashManager.GetAlbertsStash(); } CustomSeedQuest customSeedQuest = QuestManager.GetQuestByName("Drop off the Mix") as CustomSeedQuest; if (customSeedQuest == null) { SeedQuestManager.CreateQuestAsync(); } } else { if (!name.StartsWith("[NET-JSON]")) { return; } string text2 = name.Replace("[NET-JSON]", ""); try { UnicornSeedData unicornSeedData = JsonConvert.DeserializeObject<UnicornSeedData>(text2); if (Registry.ItemExists(unicornSeedData.seedId)) { return; } if (!CustomSeedsManager.DiscoveredSeeds.ContainsKey(unicornSeedData.weedId)) { CustomSeedsManager.DiscoveredSeeds.Add(unicornSeedData.weedId, unicornSeedData); } SeedDefinition val = CustomSeedsManager.SeedDefinitionLoader(unicornSeedData); if ((Object)(object)val != (Object)null) { try { WeedDefinition item = Registry.GetItem<WeedDefinition>(unicornSeedData.weedId); float ingredientCost = StashManager.GetIngredientCost((ProductDefinition)(object)item); Singleton<ManagementUtilities>.Instance.Seeds.Add(val); CustomSeedsManager.CreateShopListing(val, ingredientCost); CustomSeedsManager.AddSeedToPots(val); CustomSeedsManager.EnableSeedIndicator(unicornSeedData.weedId); } catch (Exception e2) { Utility.PrintException(e2); } } if (InstanceFinder.IsClient) { DeferredPlantsManager.TrySpawnQueuedPlants(((BaseItemDefinition)val).ID); } } catch (Exception e3) { Utility.PrintException(e3); } } } } [HarmonyPatch(typeof(Pot), "RpcLogic___PlantSeed_Client_4077118173")] public static class Patch_Pot_RpcLogic___PlantSeed_Client_4077118173 { public static bool Prefix(Pot __instance, NetworkConnection conn, string seedID, float normalizedSeedProgress) { if (!InstanceFinder.IsClient || InstanceFinder.IsServer) { return true; } if (DeferredPlantsManager.IsReplaying) { return true; } if (string.IsNullOrEmpty(seedID)) { return true; } if (!seedID.Contains("customseeddefinition")) { return true; } if (Registry.ItemExists(seedID)) { return true; } DeferredPlantsManager.AddDeferredSeed(__instance, seedID, normalizedSeedProgress); return false; } } [HarmonyPatch(typeof(Pot), "RpcLogic___SetHarvestableActive_Client_338960014")] public static class Patch_Pot_RpcLogic___SetHarvestableActive_Client_338960014 { public static bool Prefix(Pot __instance, NetworkConnection conn, int harvestableIndex, bool active) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!InstanceFinder.IsClient || InstanceFinder.IsServer) { return true; } HashSet<string> pendingPotGuids = DeferredPlantsManager.PendingPotGuids; Guid gUID = ((BuildableItem)__instance).GUID; if (pendingPotGuids.Contains(((object)(Guid)(ref gUID)).ToString())) { gUID = ((BuildableItem)__instance).GUID; DeferredPlantsManager.AddHarvestableUpdate(((object)(Guid)(ref gUID)).ToString(), harvestableIndex, active); return false; } return true; } } public class ProductManagerAppPatches { [HarmonyPatch(typeof(ProductManagerApp))] public static class ProductManagerApp_Patch { [HarmonyPrefix] [HarmonyPatch("Start")] public static bool StartPatch(ProductManagerApp __instance) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.EntryPrefab != (Object)null && (Object)(object)__instance.EntryPrefab.transform.Find("SeedIndicator") == (Object)null) { GameObject val = new GameObject("Temp"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(__instance.EntryPrefab, val.transform); ProductEntry component = __instance.EntryPrefab.GetComponent<ProductEntry>(); GameObject val3 = Object.Instantiate<GameObject>(((Component)component.FavouriteButton).gameObject, val2.transform); Button component2 = val3.GetComponent<Button>(); Object.Destroy((Object)(object)component2); ((Object)val3).name = "SeedIndicator"; RectTransform component3 = val3.GetComponent<RectTransform>(); if ((Object)(object)component3 != (Object)null) { component3.anchoredPosition = new Vector2(15f, -15f); component3.anchorMax = new Vector2(0f, 1f); component3.anchorMin = new Vector2(0f, 1f); } TrySetSeedIconSprite(val3); __instance.EntryPrefab = val2; isPrefabInitialized = true; } return true; } [HarmonyPostfix] [HarmonyPatch("Start")] public static void StartPostfix(ProductManagerApp __instance) { UpdatePendingIndicators(); } } [HarmonyPatch(typeof(ProductEntry), "Initialize")] public static class ProductEntry_Initialize_Patch { [HarmonyPostfix] public static void Postfix(ProductEntry __instance, ProductDefinition definition) { if (!((Object)(object)__instance != (Object)null) || !((Object)(object)definition != (Object)null)) { return; } Transform val = ((Component)__instance).transform.Find("SeedIndicator"); if ((Object)(object)val != (Object)null) { TrySetSeedIconSprite(((Component)val).gameObject); if (CustomSeedsManager.DiscoveredSeeds.ContainsKey(((BaseItemDefinition)definition).ID)) { ((Component)val).gameObject.SetActive(true); } else { ((Component)val).gameObject.SetActive(false); } } } } private static bool isPrefabInitialized = false; private static List<GameObject> pendingIndicators = new List<GameObject>(); private static void TrySetSeedIconSprite(GameObject indicatorObject) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)SeedVisualsManager.seedIcon == (Object)null) { SeedVisualsManager.LoadSeedMaterial(); } Image component = ((Component)indicatorObject.transform.GetChild(0)).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { if ((Object)(object)SeedVisualsManager.seedIcon != (Object)null) { component.sprite = SeedVisualsManager.seedIcon; ((Graphic)component).color = Color.white; } else if (!pendingIndicators.Contains(indicatorObject)) { pendingIndicators.Add(indicatorObject); Utility.Log("Seed icon not loaded yet, added to pending list"); } } } catch (Exception e) { Utility.PrintException(e); } } private static void UpdatePendingIndicators() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (pendingIndicators.Count == 0) { return; } for (int num = pendingIndicators.Count - 1; num >= 0; num--) { GameObject val = pendingIndicators[num]; if ((Object)(object)val == (Object)null) { pendingIndicators.RemoveAt(num); } else { try { Image component = ((Component)val.transform.GetChild(0)).GetComponent<Image>(); if ((Object)(object)component != (Object)null && (Object)(object)SeedVisualsManager.seedIcon != (Object)null) { component.sprite = SeedVisualsManager.seedIcon; ((Graphic)component).color = Color.white; pendingIndicators.RemoveAt(num); } } catch (Exception e) { Utility.PrintException(e); pendingIndicators.RemoveAt(num); } } } } public static void ClearPendingIndicators() { pendingIndicators.Clear(); isPrefabInitialized = false; } } [HarmonyPatch(typeof(ProductDefinition), "AddRecipe")] public class ProductDefinition_AddRecipe_Patch { private static void Postfix(ProductDefinition __instance) { StashManager.ProcessNewRecipe(__instance); } } [HarmonyPatch(typeof(SendableMessage), "IsValid")] public class SendableMessage_IsValid_Patch { public static bool Prefix(SendableMessage __instance, ref bool __result, out string invalidReason) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) invalidReason = string.Empty; if (__instance.Text != null && __instance.Text == SeedQuestManager.messageId) { if (SeedQuestManager.HasActiveQuest) { invalidReason = "Seed Synthesizing is already in progress"; __result = false; } else if ((Object)(object)DeadDrop.GetRandomEmptyDrop(((Component)Player.Local).transform.position) == (Object)null) { invalidReason = "No deaddrops are available"; __result = false; } else if ((Object)(object)ConversationManager.albert == (Object)null || ((NPC)ConversationManager.albert).RelationData.RelationDelta < 4f) { invalidReason = "Relationship isn't good enough"; __result = false; } else { __result = true; } return false; } return true; } } [HarmonyPatch(typeof(LoadManager), "ExitToMenu")] public static class LoadManager_ExitToMenu_Patch { public static void Postfix(LoadManager __instance, SaveInfo autoLoadSave, Data mainMenuPopup, bool preventLeaveLobby) { List<SeedDefinition> seeds = Singleton<ManagementUtilities>.Instance.Seeds; List<SeedDefinition> val = new List<SeedDefinition>(); Enumerator<SeedDefinition> enumerator = seeds.GetEnumerator(); while (enumerator.MoveNext()) { SeedDefinition current = enumerator.Current; if ((Object)(object)current != (Object)null && !((BaseItemDefinition)current).ID.Contains("customseeddefinition")) { val.Add(current); } } Singleton<ManagementUtilities>.Instance.Seeds = val; } } [HarmonyPatch(typeof(LoadManager), "StartGame")] public static class LoadManager_StartGame_Patch { public static void Postfix(LoadManager __instance) { if ((Object)(object)__instance == (Object)null || string.IsNullOrEmpty(__instance.LoadedGameFolderPath)) { return; } try { string loadedGameFolderPath = __instance.LoadedGameFolderPath; if (string.IsNullOrEmpty(loadedGameFolderPath)) { return; } string path = Path.Combine(loadedGameFolderPath, "DiscoveredCustomSeeds.json"); List<UnicornSeedData> list = new List<UnicornSeedData>(); if (File.Exists(path)) { CustomSeedsManager.FirstLoad = false; string text = File.ReadAllText(path); try { list = JsonConvert.DeserializeObject<List<UnicornSeedData>>(text) ?? new List<UnicornSeedData>(); Utility.Success($"Successfully loaded {list.Count} custom seeds"); } catch (Exception e) { Utility.PrintException(e); CustomSeedsManager.FirstLoad = true; list = new List<UnicornSeedData>(); } } else { CustomSeedsManager.FirstLoad = true; } foreach (UnicornSeedData item in list) { ItemDefinition val = Singleton<Registry>.Instance._GetItem(item.weedId, true); if (item != null && !CustomSeedsManager.DiscoveredSeeds.ContainsKey(item.weedId)) { CustomSeedsManager.DiscoveredSeeds.Add(item.weedId, item); } } } catch (Exception value) { MelonLogger.Error($"Error handling DiscoveredCustomSeeds.json: {value}"); } } } [HarmonyPatch(typeof(ProductManager), "CreateWeed")] public static class Patch_ProductManager_CreateWeed { public static void Postfix(NetworkConnection conn, string name, string id, EDrugType type, List<string> properties, WeedAppearanceSettings appearance) { if (Registry.ItemExists(id + "_customseeddefinition") || !CustomSeedsManager.DiscoveredSeeds.TryGetValue(id, out var value)) { return; } SeedDefinition val = CustomSeedsManager.SeedDefinitionLoader(value); if (!((Object)(object)val != (Object)null)) { return; } try { Singleton<ManagementUtilities>.Instance.Seeds.Add(val); } catch (Exception e) { Utility.PrintException(e); } } } } namespace UnicornsCustomSeeds.Managers { public static class ConversationManager { [CompilerGenerated] private sealed class <WelcomeRoutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WelcomeRoutine>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>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(10f); <>1__state = 1; return true; case 1: <>1__state = -1; AlbertWelcomeMessage((EUnlockType)1, temp: 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(); } } public static Dictionary<string, MSGConversation> Conversations = new Dictionary<string, MSGConversation>(); public static Albert albert; public static NPCRelationData albertRelation; public static string welcomeMessage = "A <color='#FA2FBD'><b>Unicorn</b></color> I know can synthesize your custom mixes into seeds. If you'd like to use that service, send me a text."; public static void Init() { albert = Object.FindObjectOfType<Albert>(); if ((Object)(object)albert != (Object)null) { if (((NPC)albert).MSGConversation != null) { RegisterConversation("Albert", ((NPC)albert).MSGConversation); albertRelation = ((NPC)albert).RelationData; } if (!CustomSeedsManager.FirstLoad || ((NPC)albert).RelationData == null) { return; } if (((NPC)albert).RelationData.RelationDelta >= 4f) { MelonCoroutines.Start(WelcomeRoutine()); return; } DialogueDatabase database = ((NPC)albert).DialogueHandler.Database; DialogueModule module = database.GetModule((EDialogueModule)0); for (int i = 0; i < module.Entries.Count; i++) { if (module.Entries[i] != null && module.Entries[i].Key == "supplier_meetings_unlocked") { Entry val = module.Entries[i]; DialogueChain val2 = ((Il2CppArrayBase<DialogueChain>)(object)val.Chains)[0]; if (val2 != null && ((Il2CppArrayBase<string>)(object)val2.Lines)[((Il2CppArrayBase<string>)(object)val2.Lines).Length - 1] != welcomeMessage) { string[] array = Il2CppArrayBase<string>.op_Implicit((Il2CppArrayBase<string>)(object)val2.Lines); string[] array2 = new string[array.Length + 1]; array2[0] = array[0]; array2[1] = array[1]; array2[2] = welcomeMessage; val2.Lines = Il2CppStringArray.op_Implicit(array2); } } } } else { Utility.Error("ConversationManager: Could not find Albert or his conversation."); } } public static void RegisterConversation(string name, MSGConversation convo) { if (!Conversations.ContainsKey(name)) { Conversations.Add(name, convo); } else { Conversations[name] = convo; } } public static MSGConversation GetConversation(string name) { if (Conversations.TryGetValue(name, out var value)) { return value; } return null; } public static void SendMessage(string characterName, string text) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if (!InstanceFinder.IsServer) { return; } if (Conversations.TryGetValue(characterName, out var value)) { if (value != null) { value.SendMessage(new Message(text, (ESenderType)1, true, -1), true, true); } } else { Utility.Error("ConversationManager: Conversation for " + characterName + " not found."); } } public static void SendMessageChain(string characterName, List<string> messages) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if (!InstanceFinder.IsServer) { return; } if (Conversations.TryGetValue(characterName, out var value)) { if (value == null) { return; } MessageChain val = new MessageChain(); foreach (string message in messages) { val.Messages.Add(message); } val.id = Random.Range(int.MinValue, int.MaxValue); value.SendMessageChain(val, 0.5f, true, true); } else { Utility.Error("Conversation for " + characterName + " not found."); } } public static void AlbertWelcomeMessage(EUnlockType type, bool temp) { SendMessage("Albert", welcomeMessage); } [IteratorStateMachine(typeof(<WelcomeRoutine>d__10))] private static IEnumerator WelcomeRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WelcomeRoutine>d__10(0); } } public static class DeferredPlantsManager { public struct DeferredSeedData { public Pot Pot; public string SeedId; public float Progress; } public struct HarvestableUpdateData { public int Index; public bool Active; } public static bool IsReplaying = false; public static HashSet<string> PendingPotGuids = new HashSet<string>(); public static Dictionary<string, List<DeferredSeedData>> seedsToLoad = new Dictionary<string, List<DeferredSeedData>>(); public static Dictionary<string, List<HarvestableUpdateData>> DeferredHarvestables = new Dictionary<string, List<HarvestableUpdateData>>(); public static void AddDeferredSeed(Pot pot, string seedId, float progress) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (seedsToLoad.ContainsKey(seedId)) { seedsToLoad[seedId].Add(new DeferredSeedData { Pot = pot, SeedId = seedId, Progress = progress }); } else { List<DeferredSeedData> list = new List<DeferredSeedData>(); list.Add(new DeferredSeedData { Pot = pot, SeedId = seedId, Progress = progress }); seedsToLoad.Add(seedId, list); } HashSet<string> pendingPotGuids = PendingPotGuids; Guid gUID = ((BuildableItem)pot).GUID; pendingPotGuids.Add(((object)(Guid)(ref gUID)).ToString()); } public static void AddHarvestableUpdate(string potGuid, int index, bool active) { if (!DeferredHarvestables.ContainsKey(potGuid)) { DeferredHarvestables[potGuid] = new List<HarvestableUpdateData>(); } DeferredHarvestables[potGuid].Add(new HarvestableUpdateData { Index = index, Active = active }); } public static void TrySpawnQueuedPlants(string seedId) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!seedsToLoad.ContainsKey(seedId)) { return; } List<DeferredSeedData> list = seedsToLoad[seedId]; foreach (DeferredSeedData item in list) { item.Pot.PlantSeed_Client((NetworkConnection)null, item.SeedId, item.Progress); Guid gUID = ((BuildableItem)item.Pot).GUID; string text = ((object)(Guid)(ref gUID)).ToString(); if (DeferredHarvestables.ContainsKey(text)) { foreach (HarvestableUpdateData item2 in DeferredHarvestables[text]) { item.Pot.Plant.SetHarvestableActive(item2.Index, item2.Active); } DeferredHarvestables.Remove(text); } PendingPotGuids.Remove(text); } } } public static class SeedQuestManager { [CompilerGenerated] private sealed class <CreateQuestCoroutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private int <attemptCount>5__1; private CustomSeedQuest <existingQuest>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CreateQuestCoroutine>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <existingQuest>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <attemptCount>5__1 = 0; break; case 1: <>1__state = -1; break; } while (<attemptCount>5__1 < 5) { <attemptCount>5__1++; try { <existingQuest>5__2 = QuestManager.GetQuestByName("Drop off the Mix") as CustomSeedQuest; if (<existingQuest>5__2 != null) { seedDropoff = <existingQuest>5__2; IsWaitingForDropoff = true; return false; } seedDropoff = QuestManager.CreateQuest<CustomSeedQuest>((string)null) as CustomSeedQuest; if (seedDropoff != null) { IsWaitingForDropoff = true; return false; } <existingQuest>5__2 = null; } catch { } if (<attemptCount>5__1 < 5) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } } Utility.Error($"[CreateQuestAsync] Failed to Load Quest after {5} attempts"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static CustomSeedQuest seedDropoff; public static string messageId = "Synthesize Seeds"; public static bool IsWaitingForDropoff = false; private static float lastSentTime = 0f; public static bool HasActiveQuest => IsWaitingForDropoff; public static void Init() { if (QuestManager.GetQuestByName("Drop off the Mix") is CustomSeedQuest customSeedQuest) { seedDropoff = customSeedQuest; IsWaitingForDropoff = true; } else { IsWaitingForDropoff = false; } MSGConversation conversation = ConversationManager.GetConversation("Albert"); if (conversation != null) { MessageSenderInterface senderInterface = conversation.senderInterface; SendableMessage val = conversation.CreateSendableMessage(messageId); val.onSent += Action.op_Implicit((Action)OnSent); } } public static void OnSent() { if (!InstanceFinder.IsServer || Time.time - lastSentTime < 1f) { return; } List<string> list = new List<string>(); list.Add("Drop the weed mix and cash in my drop box."); ConversationManager.SendMessageChain("Albert", list); IsWaitingForDropoff = true; if (seedDropoff == null) { if (InstanceFinder.IsServer) { BroadcastCustomQuest(); } seedDropoff = QuestManager.CreateQuest<CustomSeedQuest>((string)null) as CustomSeedQuest; } } public static void BroadcastCustomQuest() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00d6: Expected O, but got Unknown ProductManager instance = NetworkSingleton<ProductManager>.Instance; string text = $"[NET-QUEST]{StashManager.StashCostEntry.Value},{StashManager.StashQtyEntry.Value},{StashManager.SynthesizeTime.Value}"; List<string> val = new List<string>(); WeedAppearanceSettings val2 = new WeedAppearanceSettings(Color32.op_Implicit(instance.DefaultWeed.MainMat.color), Color32.op_Implicit(instance.DefaultWeed.SecondaryMat.color), Color32.op_Implicit(instance.DefaultWeed.LeafMat.color), Color32.op_Implicit(instance.DefaultWeed.StemMat.color)); instance.CreateWeed_Server(text, "ogkushseed", (EDrugType)0, val, val2); } public static void CreateQuestAsync() { MelonCoroutines.Start(CreateQuestCoroutine()); } [IteratorStateMachine(typeof(<CreateQuestCoroutine>d__10))] private static IEnumerator CreateQuestCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CreateQuestCoroutine>d__10(0); } public static void CompleteQuest() { if (seedDropoff != null) { ((Quest)seedDropoff).Complete(); seedDropoff = null; } IsWaitingForDropoff = false; } public static void SendMessage(string text) { ConversationManager.SendMessage("Albert", text); } public static void OnSelected() { MSGConversation conversation = ConversationManager.GetConversation("Albert"); if (conversation != null) { conversation.senderInterface.SetVisibility((EVisibility)1); } } } public static class SeedVisualsManager { public enum BlendMode { Lerp, Multiply, Add, Screen } public static Dictionary<string, Sprite> seedIcons = new Dictionary<string, Sprite>(); public static Dictionary<string, WeedAppearanceSettings> appearanceMap = new Dictionary<string, WeedAppearanceSettings>(); public static Shader customShader; public static Material customMat; public static Sprite baseSeedSprite; public static Sprite seedIcon; public static BlendMode blendMode = BlendMode.Lerp; public static Rect gradientArea01 = new Rect(0.37f, 0.312f, 0.24f, 0.38f); public static float gradientOpacity = 1f; public static void LoadSeedMaterial() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown try { AssetBundleUtils.LoadAssetBundle("customshaders"); Sprite val = AssetBundleUtils.LoadAssetFromBundle<Sprite>("customseed_icon.png", "customshaders"); if ((Object)(object)val != (Object)null) { baseSeedSprite = val; Object.DontDestroyOnLoad((Object)(object)baseSeedSprite); } Sprite val2 = AssetBundleUtils.LoadAssetFromBundle<Sprite>("seedicon.png", "customshaders"); if ((Object)(object)val2 != (Object)null) { seedIcon = val2; Object.DontDestroyOnLoad((Object)(object)seedIcon); } Shader val3 = AssetBundleUtils.LoadAssetFromBundle<Shader>("labelgradient.shader", "customshaders"); if ((Object)(object)val3 != (Object)null) { customShader = val3; Material val4 = new Material(customShader); if ((Object)(object)val4 != (Object)null) { customMat = val4; Object.DontDestroyOnLoad((Object)(object)val3); } } else { Utility.Error("Fail"); } } catch (Exception e) { Utility.PrintException(e); } } public static Sprite GenerateSpriteWithGradient(Color topColor, Color bottomColor) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseSeedSprite == (Object)null || (Object)(object)baseSeedSprite.texture == (Object)null) { Utility.Error("[VialTextureGenerator] Base Sprite is missing."); return null; } Texture2D texture = baseSeedSprite.texture; Rect rect = baseSeedSprite.rect; ((Rect)(ref rect)).x = ((Rect)(ref rect)).x / (float)((Texture)texture).width; ((Rect)(ref rect)).y = ((Rect)(ref rect)).y / (float)((Texture)texture).height; ((Rect)(ref rect)).width = ((Rect)(ref rect)).width / (float)((Texture)texture).width; ((Rect)(ref rect)).height = ((Rect)(ref rect)).height / (float)((Texture)texture).height; Color[] array = Il2CppArrayBase<Color>.op_Implicit((Il2CppArrayBase<Color>)(object)texture.GetPixels(Mathf.FloorToInt(((Rect)(ref rect)).x * (float)((Texture)texture).width), Mathf.FloorToInt(((Rect)(ref rect)).y * (float)((Texture)texture).height), Mathf.FloorToInt(((Rect)(ref rect)).width * (float)((Texture)texture).width), Mathf.FloorToInt(((Rect)(ref rect)).height * (float)((Texture)texture).height))); ApplyVerticalGradientInRect(array, Mathf.FloorToInt(((Rect)(ref rect)).width * (float)((Texture)texture).width), Mathf.FloorToInt(((Rect)(ref rect)).height * (float)((Texture)texture).height), gradientArea01, topColor, bottomColor, gradientOpacity, blendMode); int num = Mathf.FloorToInt(((Rect)(ref rect)).width * (float)((Texture)texture).width); int num2 = Mathf.FloorToInt(((Rect)(ref rect)).height * (float)((Texture)texture).height); Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array)); val.Apply(); ((Object)val).name = "Copy"; return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f)); } private static void ApplyVerticalGradientInRect(Color[] pixels, int width, int height, Rect rect01, Color top, Color bottom, float opacity, BlendMode mode) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(((Rect)(ref rect01)).x * (float)width); int num2 = Mathf.RoundToInt(((Rect)(ref rect01)).y * (float)height); int num3 = Mathf.RoundToInt(((Rect)(ref rect01)).width * (float)width); int num4 = Mathf.RoundToInt(((Rect)(ref rect01)).height * (float)height); num = Mathf.Clamp(num, 0, width); num2 = Mathf.Clamp(num2, 0, height); num3 = Mathf.Clamp(num3, 0, width - num); num4 = Mathf.Clamp(num4, 0, height - num2); if (num3 <= 0 || num4 <= 0) { return; } for (int i = 0; i < num4; i++) { float num5 = (float)i / (float)((num4 - 1 <= 0) ? 1 : (num4 - 1)); Color dst = Color.Lerp(bottom, top, num5); dst.a *= opacity; int num6 = num2 + i; int num7 = num6 * width; for (int j = 0; j < num3; j++) { int num8 = num + j; int num9 = num7 + num8; Color src = pixels[num9]; pixels[num9] = Blend(dst, src, mode); } } } private static Color Blend(Color dst, Color src, BlendMode mode) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) switch (mode) { case BlendMode.Multiply: return new Color(dst.r * Mathf.Lerp(1f, src.r, src.a), dst.g * Mathf.Lerp(1f, src.g, src.a), dst.b * Mathf.Lerp(1f, src.b, src.a), Mathf.Max(dst.a, src.a)); case BlendMode.Add: return new Color(Mathf.Clamp01(dst.r + src.r * src.a), Mathf.Clamp01(dst.g + src.g * src.a), Mathf.Clamp01(dst.b + src.b * src.a), Mathf.Max(dst.a, src.a)); case BlendMode.Screen: { float num = 1f - (1f - dst.r) * (1f - src.r * src.a); float num2 = 1f - (1f - dst.g) * (1f - src.g * src.a); float num3 = 1f - (1f - dst.b) * (1f - src.b * src.a); return new Color(num, num2, num3, Mathf.Max(dst.a, src.a)); } default: return new Color(Mathf.Lerp(dst.r, src.r, src.a), Mathf.Lerp(dst.g, src.g, src.a), Mathf.Lerp(dst.b, src.b, src.a), Mathf.Max(dst.a, src.a)); } } } public struct SeedComponents { public string seedId; public string baseSeedId; } public static class CustomSeedsManager { public delegate bool ValidityCheckDelegate(SendableMessage message, out String invalidReason); [CompilerGenerated] private sealed class <CreateSeed>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public WeedDefinition weedDef; private SeedDefinition <newSeed>5__1; private float <price>5__2; private UnicornSeedData <newSeedData>5__3; private DeadDrop <randomEmptyDrop>5__4; private ItemInstance <defaultInstance>5__5; private string <guidString>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CreateSeed>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <newSeed>5__1 = null; <newSeedData>5__3 = null; <randomEmptyDrop>5__4 = null; <defaultInstance>5__5 = null; <guidString>5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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_01ab: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds((float)StashManager.SynthesizeTime.Value); <>1__state = 1; return true; case 1: <>1__state = -1; <newSeed>5__1 = factory.CreateSeedDefinition(weedDef); Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)<newSeed>5__1); <price>5__2 = StashManager.GetIngredientCost((ProductDefinition)(object)weedDef); <newSeedData>5__3 = new UnicornSeedData { seedId = ((BaseItemDefinition)<newSeed>5__1).ID, weedId = ((BaseItemDefinition)weedDef).ID, baseSeedId = "ogkushseed", price = <price>5__2 }; DiscoveredSeeds.Add(<newSeedData>5__3.weedId, <newSeedData>5__3); CreateShopListing(<newSeed>5__1, <price>5__2); AddSeedToPots(<newSeed>5__1); EnableSeedIndicator(<newSeedData>5__3.weedId); <randomEmptyDrop>5__4 = DeadDrop.GetRandomEmptyDrop(((Component)Player.Local).transform.position); if ((Object)(object)<randomEmptyDrop>5__4 != (Object)null && InstanceFinder.IsServer) { <defaultInstance>5__5 = ((ItemDefinition)<newSeed>5__1).GetDefaultInstance(1); ((BaseItemInstance)<defaultInstance>5__5).SetQuantity(10); ((StorageEntity)<randomEmptyDrop>5__4.Storage).InsertItem(<defaultInstance>5__5, true); Guid val = GUIDManager.GenerateUniqueGUID(); <guidString>5__6 = ((object)(Guid)(ref val)).ToString(); QuestManager instance = NetworkSingleton<QuestManager>.Instance; val = <randomEmptyDrop>5__4.GUID; instance.CreateDeaddropCollectionQuest((NetworkConnection)null, ((object)(Guid)(ref val)).ToString(), <guidString>5__6); SeedQuestManager.SendMessage(((Object)weedDef).name + " is synthesized and placed in the deaddrop"); <defaultInstance>5__5 = null; <guidString>5__6 = null; } else { if ((Object)(object)<randomEmptyDrop>5__4 == (Object)null) { Utility.Error("No Dead Drop found"); } SeedQuestManager.SendMessage("Wasn't able to find a deadrop for " + ((Object)weedDef).name + " Seed. It is synthesized and available in the shop"); } BroadcastCustomSeed(<newSeedData>5__3); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string BASE_SEED_ID = "ogkushseed"; public static SeedFactory factory; public static Dictionary<string, UnicornSeedData> DiscoveredSeeds = new Dictionary<string, UnicornSeedData>(); public static ShopInterface Shop = null; public static GameObject shopGo = null; public static Dictionary<string, SeedDefinition> baseSeedDefinitions = new Dictionary<string, SeedDefinition>(); public static Dictionary<string, ShopListing> baseShopListing = new Dictionary<string, ShopListing>(); public static bool FirstLoad = false; public static void Initialize() { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown Il2CppArrayBase<ShopInterface> val = Object.FindObjectsOfType<ShopInterface>(); foreach (ShopInterface item2 in val) { if (((Object)((Component)item2).gameObject).name == "WeedSupplierInterface") { shopGo = ((Component)item2).gameObject; Shop = item2; break; } } if ((Object)(object)Shop == (Object)null) { Utility.Error("Shop is null!"); return; } ConversationManager.Init(); SeedQuestManager.Init(); SeedVisualsManager.LoadSeedMaterial(); InitDictionary(); AddScrollToPhoneInterface(); foreach (KeyValuePair<string, UnicornSeedData> discoveredSeed in DiscoveredSeeds) { SeedDefinition item = Registry.GetItem<SeedDefinition>(discoveredSeed.Value.seedId); if ((Object)(object)item != (Object)null) { CreateShopListing(item, discoveredSeed.Value.price); if ((Object)(object)ConversationManager.albert != (Object)null) { Listing val2 = new Listing((StorableItemDefinition)(object)item); IEnumerable<Listing> source = CollectionExtensions.AddItem<Listing>((IEnumerable<Listing>)((Supplier)ConversationManager.albert).OnlineShopItems, val2); ((Supplier)ConversationManager.albert).OnlineShopItems = Il2CppReferenceArray<Listing>.op_Implicit(source.ToArray()); } } } } public static void ClearAll() { SeedVisualsManager.seedIcons.Clear(); SeedVisualsManager.appearanceMap.Clear(); SeedQuestManager.seedDropoff = null; DiscoveredSeeds.Clear(); factory.DeleteChildren(); FirstLoad = false; } public static void AddScrollToPhoneInterface() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)PlayerSingleton<MessagesApp>.Instance.PhoneShopInterface).transform; Transform val = transform.Find("Shade/Content/Entries"); if ((Object)(object)val != (Object)null) { GameObject gameObject = ((Component)val).gameObject; RectTransform component = gameObject.GetComponent<RectTransform>(); Image component2 = gameObject.GetComponent<Image>(); if ((Object)(object)component == (Object)null) { Utility.Error("Entries does not have a RectTransform component"); return; } GameObject val2 = new GameObject("ScrollView"); val2.transform.SetParent(((Transform)component).parent, false); RectTransform val3 = val2.AddComponent<RectTransform>(); val3.anchorMin = new Vector2(0f, 1f); val3.anchorMax = new Vector2(1f, 1f); val3.pivot = new Vector2(0.5f, 1f); val3.anchoredPosition = new Vector2(0f, -140f); val3.sizeDelta = component.sizeDelta; val2.AddComponent<Mask>(); ((Behaviour)gameObject.GetComponent<Mask>()).enabled = false; Image val4 = val2.AddComponent<Image>(); ((Graphic)val4).color = ((Graphic)component2).color; ScrollRect val5 = val2.AddComponent<ScrollRect>(); val5.horizontal = false; val5.vertical = true; val5.movementType = (MovementType)2; val5.inertia = true; val5.scrollSensitivity = 20f; component.pivot = new Vector2(0.5f, 1f); ContentSizeFitter val6 = gameObject.AddComponent<ContentSizeFitter>(); if ((Object)(object)val6 != (Object)null) { val6.verticalFit = (FitMode)2; } VerticalLayoutGroup component3 = gameObject.GetComponent<VerticalLayoutGroup>(); ((LayoutGroup)component3).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)component3).spacing = 20f; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = false; ((LayoutGroup)component3).padding.top = 20; ((LayoutGroup)component3).padding.bottom = 20; gameObject.transform.SetParent(val2.transform, false); val5.content = component; component.anchoredPosition = Vector2.zero; } else { Utility.Error("Could not find Shade/Content/Entries in phone shop interface"); } } public static void StartSeedCreation(WeedDefinition weedDef) { MelonCoroutines.Start(CreateSeed(weedDef)); } public static void BroadcastCustomSeed(UnicornSeedData seed) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown ProductManager instance = NetworkSingleton<ProductManager>.Instance; string text = JsonConvert.SerializeObject((object)seed); string text2 = "[NET-JSON]" + text; List<string> val = new List<string>(); WeedAppearanceSettings val2 = new WeedAppearanceSettings(Color32.op_Implicit(instance.DefaultWeed.MainMat.color), Color32.op_Implicit(instance.DefaultWeed.SecondaryMat.color), Color32.op_Implicit(instance.DefaultWeed.LeafMat.color), Color32.op_Implicit(instance.DefaultWeed.StemMat.color)); instance.CreateWeed_Server(text2, "ogkushseed", (EDrugType)0, val, val2); } [IteratorStateMachine(typeof(<CreateSeed>d__14))] public static IEnumerator CreateSeed(WeedDefinition weedDef) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CreateSeed>d__14(0) { weedDef = weedDef }; } public static void InitDictionary() { List<ShopListing> listings = Shop.Listings; Enumerator<ShopListing> enumerator = listings.GetEnumerator(); while (enumerator.MoveNext()) { ShopListing current = enumerator.Current; SeedDefinition val = ((Il2CppObjectBase)current.Item).TryCast<SeedDefinition>(); if (val != null) { if (!baseSeedDefinitions.ContainsKey(((BaseItemDefinition)val).ID)) { baseSeedDefinitions.Add(((BaseItemDefinition)val).ID, val); baseShopListing.Add(((BaseItemDefinition)val).ID, current); } } else { MelonLogger.Warning(current.name + " could not be cast to SeedDefinition"); } } } public static void CreateDeliveryListing(ShopListing newListing) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) DeliveryShop shop = PlayerSingleton<DeliveryApp>.Instance.GetShop("Albert Hoover"); ListingEntry val = Object.Instantiate<ListingEntry>(shop.ListingEntryPrefab, (Transform)(object)shop.ListingContainer); val.Initialize(newListing); val.onQuantityChanged.AddListener(UnityAction.op_Implicit((Action)shop.RefreshCart)); shop.listingEntries.Add(val); shop.ListingContainer.sizeDelta = new Vector2(shop.ListingContainer.sizeDelta.x, 230f + (float)Math.Ceiling((double)shop.listingEntries.Count / 2.0) * 60f); } public static void CreateShopListing(SeedDefinition newSeed, float price = 10f) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) ShopListing val = Shop.Listings[0]; val.name = "Test"; ShopListing val2 = new ShopListing(); val2.name = $"{((BaseItemDefinition)newSeed).ID} (${price}) (Agriculture, )"; val2.OverridePrice = true; val2.OverriddenPrice = price; val2.Item = (StorableItemDefinition)(object)newSeed; val2.IconTint = new Color(0f, 0.859f, 1f, 1f); val2.MinimumGameCreationVersion = 27f; val2.DefaultStock = 1000; val2.CurrentStock = 100000; val2.CanBeDelivered = true; Shop.Listings.Add(val2); Shop.CreateListingUI(val2); CreateDeliveryListing(val2); Shop.RefreshShownItems(); } public static void EnableSeedIndicator(string weedId) { ProductDefinition item = Registry.GetItem<ProductDefinition>(weedId); if ((Object)(object)item == (Object)null) { Utility.Error("Could not find ProductDefinition for weedId: " + weedId); return; } ProductManagerApp instance = PlayerSingleton<ProductManagerApp>.instance; if ((Object)(object)instance == (Object)null) { Utility.Error("ProductManagerApp instance is null"); return; } bool flag = ProductManager.FavouritedProducts.Contains(item); if (instance.entries != null) { for (int i = 0; i < instance.entries.Count; i++) { ProductEntry val = instance.entries[i]; if ((Object)(object)val != (Object)null && (Object)(object)val.Definition != (Object)null && ((BaseItemDefinition)val.Definition).ID == weedId) { Transform val2 = ((Component)val).transform.Find("SeedIndicator"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(true); } break; } } } if (!flag || instance.favouriteEntries == null) { return; } for (int j = 0; j < instance.favouriteEntries.Count; j++) { ProductEntry val3 = instance.favouriteEntries[j]; if ((Object)(object)val3 != (Object)null && (Object)(object)val3.Definition != (Object)null && ((BaseItemDefinition)val3.Definition).ID == weedId) { Transform val4 = ((Component)val3).transform.Find("SeedIndicator"); if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(true); } break; } } } public static void AddSeedToPots(SeedDefinition newSeed) { Il2CppArrayBase<Pot> val = Object.FindObjectsOfType<Pot>(); foreach (Pot item in val) { PotConfiguration val2 = ((Il2CppObjectBase)item.Configuration).TryCast<PotConfiguration>(); if (val2 != null) { val2.Seed.Options.Add((ItemDefinition)(object)newSeed); } } } public static void SeedFactoryLoader() { SeedDefinition item = Registry.GetItem<SeedDefinition>("ogkushseed"); if ((Object)(object)item != (Object)null) { factory = new SeedFactory(item); } } public static SeedDefinition SeedDefinitionLoader(UnicornSeedData newSeedData) { SeedDefinition val = null; WeedDefinition item = Registry.GetItem<WeedDefinition>(newSeedData.weedId); if ((Object)(object)item != (Object)null) { val = factory.CreateSeedDefinition(item); if ((Object)(object)val == (Object)null) { Utility.Error("New seed not created"); } Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)val); } else { MelonLogger.Error("Could not parse weed and seed defitions"); } return val; } } public static class StashManager { private static Dictionary<string, List<PropertyItemDefinition>> ingredientsCache = new Dictionary<string, List<PropertyItemDefinition>>(); private static Dictionary<string, float> ingredientCostCache = new Dictionary<string, float>(); private static float lastClosedTime = 0f; public static SupplierStash albertsStash; public static MelonPreferences_Category ConfigCategory; public static MelonPreferences_Entry<int> StashCostEntry; public static MelonPreferences_Entry<int> StashQtyEntry; public static MelonPreferences_Entry<int> SynthesizeTime; public static void InitializeConfig() { ConfigCategory = MelonPreferences.CreateCategory("Unicorns Custom Seeds"); StashCostEntry = ConfigCategory.CreateEntry<int>("StashCostRequirement", 500, "Stash Cost Requirement", "The price that Albert charges to synthesize seeds", false, false, (ValueValidator)null, (string)null); StashQtyEntry = ConfigCategory.CreateEntry<int>("StashQtyRequirement", 20, "Stash Quantity Requirement", "The quantity of weed that needs to be provided of a certain mix", false, false, (ValueValidator)null, (string)null); SynthesizeTime = ConfigCategory.CreateEntry<int>("SynthesizeTime", 30, "Synthesize Time", "Time in secondsd that it will take for Albert to synthesize a seed", false, false, (ValueValidator)null, (string)null); } public static void GetAlbertsStash() { Il2CppArrayBase<SupplierStash> val = Object.FindObjectsOfType<SupplierStash>(); foreach (SupplierStash item in val) { if ((Object)(object)item != (Object)null && ((Object)((Component)item).gameObject).name.ToLower().Contains("albert")) { Utility.Log("Alberts Ready to Synthesize"); albertsStash = item; StorageEntity storage = item.Storage; storage.onClosed += Action.op_Implicit((Action)AlbertsStashClosed); break; } } } public static void AlbertsStashClosed() { if (Time.time - lastClosedTime < 1f) { return; } lastClosedTime = Time.time; ItemSlot val = null; CashInstance val2 = null; ItemSlot val3 = null; WeedInstance val4 = null; List<ItemInstance> allItems = albertsStash.Storage.GetAllItems(); Utility.Log("Alberts Stash Looping through items"); Enumerator<ItemSlot> enumerator = albertsStash.Storage.ItemSlots.GetEnumerator(); while (enumerator.MoveNext()) { ItemSlot current = enumerator.Current; if (((current != null) ? current.ItemInstance : null) == null) { continue; } CashInstance val5 = ((Il2CppObjectBase)current.ItemInstance).TryCast<CashInstance>(); if (val5 != null) { val = current; val2 = val5; continue; } WeedInstance val6 = ((Il2CppObjectBase)current.ItemInstance).TryCast<WeedInstance>(); if (val6 != null) { val3 = current; val4 = val6; } } if (val2 == null || val4 == null) { return; } PackagingDefinition appliedPackaging = ((ProductItemInstance)val4).AppliedPackaging; string packaging = ((appliedPackaging != null) ? ((BaseItemDefinition)appliedPackaging).Name : null); int quantity = ((BaseItemInstance)val4).Quantity; uint num = PackageAmount(packaging); if (num == 0) { return; } uint num2 = (uint)(quantity * num); if (val2.Balance >= (float)StashCostEntry.Value && num2 >= StashQtyEntry.Value) { WeedDefinition val7 = ((Il2CppObjectBase)((ItemInstance)val4).Definition).TryCast<WeedDefinition>(); if ((Object)(object)val7 != (Object)null && !CustomSeedsManager.DiscoveredSeeds.ContainsKey(((BaseItemDefinition)((ItemInstance)val4).Definition).ID) && SeedQuestManager.HasActiveQuest) { val3.ChangeQuantity(-(StashQtyEntry.Value / (int)num), false); val2.ChangeBalance((float)(-StashCostEntry.Value)); SeedQuestManager.CompleteQuest(); SeedQuestManager.SendMessage("I will begin synthesizing the seed"); CustomSeedsManager.StartSeedCreation(val7); } } } private static uint PackageAmount(string packaging) { if (1 == 0) { } uint result = packaging switch { "Brick" => 20u, "Jar" => 5u, "Baggie" => 1u, _ => 1u, }; if (1 == 0) { } return result; } public static WeedDefinition GetBaseStrain(ProductDefinition product) { List<PropertyItemDefinition> recipe = GetRecipe(product); PropertyItemDefinition val = recipe[0]; WeedDefinition val2 = ((Il2CppObjectBase)val).TryCast<WeedDefinition>(); if ((Object)(object)val2 != (Object)null) { return val2; } return null; } public static List<PropertyItemDefinition> GetRecipe(ProductDefinition product) { if (ingredientsCache.ContainsKey(((BaseItemDefinition)product).ID)) { return ingredientsCache[((BaseItemDefinition)product).ID]; } return DeepSearchRecipe(product); } public static float GetIngredientCost(ProductDefinition product) { if (ingredientCostCache.ContainsKey(((BaseItemDefinition)product).ID)) { return ingredientCostCache[((BaseItemDefinition)product).ID]; } List<PropertyItemDefinition> recipe = GetRecipe(product); float num = CalculateTotalCost(recipe); ingredientCostCache.Add(((BaseItemDefinition)product).ID, num); return num; } public static void ProcessNewRecipe(ProductDefinition product) { if (!((Object)(object)product == (Object)null)) { List<PropertyItemDefinition> ingredients = DeepSearchRecipe(product); float num = CalculateTotalCost(ingredients); } } private static float CalculateTotalCost(List<PropertyItemDefinition> ingredients) { float num = 0f; foreach (PropertyItemDefinition ingredient in ingredients) { if (!(ingredient is ProductDefinition)) { num += ((StorableItemDefinition)ingredient).BasePurchasePrice; } } return num; } public static List<PropertyItemDefinition> DeepSearchRecipe(ProductDefinition product) { if (ingredientsCache.ContainsKey(((BaseItemDefinition)product).ID)) { return ingredientsCache[((BaseItemDefinition)product).ID]; } List<PropertyItemDefinition> list = new List<PropertyItemDefinition>(); HashSet<string> visited = new HashSet<string>(); DeepSearchRecursive(product, list, visited); ingredientsCache.Add(((BaseItemDefinition)product).ID, list); return list; } private static void DeepSearchRecursive(ProductDefinition product, List<PropertyItemDefinition> result, HashSet<string> visited) { if ((Object)(object)product == (Object)null || visited.Contains(((BaseItemDefinition)product).ID)) { return; } visited.Add(((BaseItemDefinition)product).ID); if (product.Recipes.Count == 0) { result.Insert(0, (PropertyItemDefinition)(object)product); return; } Enumerator<IngredientQuantity> enumerator = product.Recipes[0].Ingredients.GetEnumerator(); while (enumerator.MoveNext()) { IngredientQuantity current = enumerator.Current; if (current == null) { continue; } ProductDefinition val = ((Il2CppObjectBase)current.Item).TryCast<ProductDefinition>(); if (val != null) { DeepSearchRecursive(val, result, visited); continue; } PropertyItemDefinition val2 = ((Il2CppObjectBase)current.Item).TryCast<PropertyItemDefinition>(); if (val2 != null) { result.Add(val2); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }
UnicornsCustomSeeds_Mono_1.1.1.dll
Decompiled 2 months agousing System; using System.Collections; 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 FishNet; using FishNet.Connection; using FluffyUnderware.DevTools.Extensions; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using S1API.Quests; using S1API.Saveables; using ScheduleOne; using ScheduleOne.AvatarFramework.Equipping; using ScheduleOne.Core.Items.Framework; using ScheduleOne.DevUtilities; using ScheduleOne.Dialogue; using ScheduleOne.Economy; using ScheduleOne.EntityFramework; using ScheduleOne.Equipping; using ScheduleOne.Growing; using ScheduleOne.ItemFramework; using ScheduleOne.Management; using ScheduleOne.Messaging; using ScheduleOne.NPCs; using ScheduleOne.NPCs.CharacterClasses; using ScheduleOne.NPCs.Relation; using ScheduleOne.ObjectScripts; using ScheduleOne.Persistence; using ScheduleOne.PlayerScripts; using ScheduleOne.Product; using ScheduleOne.Quests; using ScheduleOne.StationFramework; using ScheduleOne.Storage; using ScheduleOne.UI.MainMenu; using ScheduleOne.UI.Phone; using ScheduleOne.UI.Phone.Delivery; using ScheduleOne.UI.Phone.Messages; using ScheduleOne.UI.Phone.ProductManagerApp; using ScheduleOne.UI.Shop; using UnicornsCustomSeeds; using UnicornsCustomSeeds.Managers; using UnicornsCustomSeeds.Patches; using UnicornsCustomSeeds.SeedQuests; using UnicornsCustomSeeds.Seeds; using UnicornsCustomSeeds.TemplateUtils; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [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), "Unicorns Custom Seeds", "1.1.1", "OverweightUnicorn", null)] [assembly: MelonColor(255, 191, 0, 255)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ScheduleOne.Core")] [assembly: AssemblyCompany("UnicornsCustomSeeds_Mono_1.1.1")] [assembly: AssemblyConfiguration("MONO")] [assembly: AssemblyFileVersion("1.1.1")] [assembly: AssemblyInformationalVersion("1.0.0+0ea043a8feb584ee5677fdd4bbe56297e6c59355")] [assembly: AssemblyProduct("UnicornsCustomSeeds_Mono_1.1.1")] [assembly: AssemblyTitle("UnicornsCustomSeeds_Mono_1.1.1")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 UnicornsCustomSeeds { public static class BuildInfo { public const string Name = "Unicorns Custom Seeds"; public const string Description = "Your good buddy Unicorn can help you synthesize seeds"; public const string Author = "OverweightUnicorn"; public const string Company = "UnicornsCanMod"; public const string Version = "1.1.1"; public const string DownloadLink = null; } public class Core : MelonMod { public override void OnInitializeMelon() { AssetBundleUtils.Initialize(this); } public override void OnLateInitializeMelon() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown StashManager.InitializeConfig(); SeedVisualsManager.LoadSeedMaterial(); Singleton<LoadManager>.Instance.onLoadComplete.AddListener(new UnityAction(InitMod)); Singleton<SaveManager>.Instance.onSaveComplete.AddListener(new UnityAction(SaveData)); } public void SaveData() { try { string loadedGameFolderPath = Singleton<LoadManager>.Instance.LoadedGameFolderPath; if (!string.IsNullOrEmpty(loadedGameFolderPath) && Directory.Exists(loadedGameFolderPath)) { string path = Path.Combine(loadedGameFolderPath, "DiscoveredCustomSeeds.json"); List<UnicornSeedData> list = CustomSeedsManager.DiscoveredSeeds.Values.ToList(); string contents = JsonConvert.SerializeObject((object)list, (Formatting)1); File.WriteAllText(path, contents); } } catch (Exception e) { Utility.PrintException(e); } } public void InitMod() { CustomSeedsManager.Initialize(); StashManager.GetAlbertsStash(); } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { SeedDefinition item = Registry.GetItem<SeedDefinition>("ogkushseed"); if (CustomSeedsManager.factory == null && (Object)(object)item != (Object)null) { CustomSeedsManager.factory = new SeedFactory(item); } StashManager.GetAlbertsStash(); if (sceneName.ToLower() != "main") { CustomSeedsManager.ClearAll(); ProductManagerAppPatches.ClearPendingIndicators(); } else if ((Object)(object)SeedVisualsManager.seedIcon == (Object)null || (Object)(object)SeedVisualsManager.baseSeedSprite == (Object)null) { SeedVisualsManager.LoadSeedMaterial(); } } } } namespace UnicornsCustomSeeds.TemplateUtils { public static class AssetBundleUtils { private static Core mod; private static MelonAssembly melonAssembly; private static Dictionary<string, AssetBundle> assetBundles = new Dictionary<string, AssetBundle>(); public static void Initialize(Core coreMod) { mod = coreMod; melonAssembly = ((MelonBase)mod).MelonAssembly; } public static AssetBundle LoadAssetBundle(string bundleFileName) { if (assetBundles.ContainsKey(bundleFileName)) { return assetBundles[bundleFileName]; } try { string text = typeof(Core).Namespace + ".Assets." + bundleFileName; Stream manifestResourceStream = melonAssembly.Assembly.GetManifestResourceStream(text ?? ""); if (manifestResourceStream == null) { ((MelonBase)mod).Unregister("AssetBundle: '" + text + "' not found. \nOpen .csproj file and search for '" + bundleFileName + "'.\nIf it doesn't exist,\nCopy your asset to Assets/ folder then look for 'your.assetbundle' in .csproj file.", false); return null; } AssetBundle val = AssetBundle.LoadFromStream(manifestResourceStream); assetBundles.Add(bundleFileName, val); return val; } catch (Exception arg) { ((MelonBase)mod).Unregister($"Failed to load AssetBundle. Please report to dev: {arg}", false); return null; } } public static AssetBundle GetLoadedAssetBundle(string bundleName) { if (assetBundles.ContainsKey(bundleName)) { return assetBundles[bundleName]; } ((MelonBase)mod).Unregister("Failed to get " + bundleName, false); throw new Exception("Asset '" + bundleName + "' has not been loaded in yet"); } public static T LoadAssetFromBundle<T>(string assetName, string bundleName) where T : Object { AssetBundle loadedAssetBundle = GetLoadedAssetBundle(bundleName); if ((Object)(object)loadedAssetBundle == (Object)null) { throw new Exception("Couldn't find " + bundleName + ", Did you load it?"); } T val = loadedAssetBundle.LoadAsset<T>(assetName); if ((Object)(object)val == (Object)null) { throw new Exception(assetName + " not found in bundle"); } return val; } } public static class Utility { public static void PrintException(Exception e) { MelonLogger.Msg(ConsoleColor.Red, e.GetType().FullName); MelonLogger.Msg(ConsoleColor.DarkRed, e.Message); if (!string.IsNullOrWhiteSpace(e.StackTrace)) { MelonLogger.Msg(ConsoleColor.DarkRed, "StackTrace:"); string[] array = e.StackTrace.Split('\n'); foreach (string text in array) { MelonLogger.Msg(ConsoleColor.DarkRed, " " + text.Trim()); } } if (e.InnerException != null) { MelonLogger.Msg(ConsoleColor.DarkRed, " -- Inner Exception --"); PrintException(e.InnerException); } } public static void Error(string msg) { MelonLogger.Msg(ConsoleColor.Red, msg); } public static void Log(string msg) { MelonLogger.Msg(ConsoleColor.DarkMagenta, msg); } public static void Success(string msg) { MelonLogger.Msg(ConsoleColor.Green, msg); } } } namespace UnicornsCustomSeeds.Seeds { [Serializable] public class UnicornSeedData { public string seedId { get; set; } public string weedId { get; set; } public string baseSeedId { get; set; } public float price { get; set; } } public class SeedFactory { private Transform rootGameObject; private WeedPlant basePlantPrefab; private PlantHarvestable baseBranchPrefab; private FunctionalSeed baseFunctionalSeedPrefab; private Equippable_Seed baseEquippableSeedPrefab; private AvatarEquippable baseAvatarEquippablePrefab; private StoredItem baseStorableItem; public SeedDefinition baseSeedDefinition; public SeedFactory(SeedDefinition seedDefinition) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown baseSeedDefinition = seedDefinition; baseFunctionalSeedPrefab = seedDefinition.FunctionSeedPrefab; baseStorableItem = ((StorableItemDefinition)seedDefinition).StoredItem; InitializeBasePlant(seedDefinition); InitializeEquippable(seedDefinition); if ((Object)(object)rootGameObject == (Object)null) { GameObject val = new GameObject(((BaseItemDefinition)baseSeedDefinition).ID + "_CustomSeeds"); val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); rootGameObject = val.transform; } } private void InitializeBasePlant(SeedDefinition seedDefinition) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown WeedPlant val = (WeedPlant)seedDefinition.PlantPrefab; if ((Object)(object)val != (Object)null) { basePlantPrefab = val; if ((Object)(object)basePlantPrefab != (Object)null) { baseBranchPrefab = basePlantPrefab.BranchPrefab; } } else { Utility.Log("Failed to cast PlantPrefab to WeedPlant."); } } private void InitializeEquippable(SeedDefinition seedDefinition) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown Equippable_Seed val = (Equippable_Seed)((ItemDefinition)seedDefinition).Equippable; if ((Object)(object)val != (Object)null) { baseEquippableSeedPrefab = val; baseAvatarEquippablePrefab = ((Equippable_Viewmodel)val).AvatarEquippable; } else { Utility.Log("Failed to cast Equippable to Equippable_Seed."); } } public void DeleteChildren() { TransformExt.DeleteChildren(rootGameObject, true, false); } private void GrowLabel(Transform root, string seedDefId) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) Transform val = null; Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(); Transform[] array = componentsInChildren; foreach (Transform val2 in array) { if (((Object)val2).name == "Label") { val = ((Component)val2).transform; } } if ((Object)(object)val != (Object)null) { val.localScale = new Vector3(1.05f, 1.05f, 2f); val.position = new Vector3(0f, -0.05f, 0f); if ((Object)(object)SeedVisualsManager.customMat == (Object)null) { SeedVisualsManager.LoadSeedMaterial(); } if ((Object)(object)SeedVisualsManager.customMat != (Object)null) { Renderer component = ((Component)val).GetComponent<Renderer>(); component.material = SeedVisualsManager.customMat; ((Component)val).gameObject.AddComponent<SeedVialLabel>(); ((Object)val).name = ((Object)val).name + ":" + seedDefId; } else { Utility.Log("MATERIAL NOT LOADED!!!"); } } } public WeedPlant ClonePlantPrefab(WeedDefinition newDef) { if ((Object)(object)basePlantPrefab == (Object)null) { throw new InvalidOperationException("Base plant prefab not initialized."); } WeedPlant val = Object.Instantiate<WeedPlant>(basePlantPrefab, rootGameObject); SetPlantAppearance(newDef, val); PlantHarvestable val2 = CloneBranchPrefab(newDef); SetBranchAppearance(((Component)val2).transform, newDef); val.BranchPrefab = val2; PlantHarvestable[] componentsInChildren = ((Component)val).GetComponentsInChildren<PlantHarvestable>(); PlantHarvestable[] array = componentsInChildren; foreach (PlantHarvestable val3 in array) { val3.Product = (StorableItemDefinition)(object)newDef; } return val; } public void SetPlantAppearance(WeedDefinition newDef, WeedPlant plant) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) PlantGrowthStage[] growthStages = ((Plant)plant).GrowthStages; foreach (PlantGrowthStage val in growthStages) { WeedAppearanceSettings val2 = newDef.appearance; if (val2 == null) { val2 = WeedDefinition.GetAppearanceSettings(((PropertyItemDefinition)newDef).Properties); } if ((Object)(object)val != (Object)null && val2 != null) { for (int j = 0; j < ((Component)val).transform.childCount; j++) { Transform child = ((Component)val).transform.GetChild(j); if ((Object)(object)child == (Object)null) { continue; } MeshRenderer component = ((Component)child).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null) { continue; } Material material = ((Renderer)component).material; if ((Object)(object)material == (Object)null) { continue; } if (((Object)child).name == "Stem") { material.color = Color32.op_Implicit(val2.StemColor); } if (((Object)child).name == "BigLeaves") { material.color = Color32.op_Implicit(val2.LeafColor); } if (((Object)child).name == "SmallLeaves") { material.color = Color32.op_Implicit(val2.LeafColor); } Transform[] growthSites = val.GrowthSites; foreach (Transform val3 in growthSites) { if ((Object)(object)val3 != (Object)null) { Transform child2 = val3.GetChild(0); if (Object.op_Implicit((Object)(object)child2)) { SetBranchAppearance(child2, val2); } } } } } else { Utility.Error("Plant Stage is NULL! Thats impossible"); } } } public void SetBranchAppearance(Transform branchTransform, WeedDefinition weedDef) { WeedAppearanceSettings val = weedDef.appearance; if (val == null) { val = WeedDefinition.GetAppearanceSettings(((PropertyItemDefinition)weedDef).Properties); } if (val != null && (Object)(object)branchTransform != (Object)null) { SetBranchAppearance(branchTransform, val); } } public void SetBranchAppearance(Transform branchTransform, WeedAppearanceSettings weedAppearance) { //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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) Transform child = branchTransform.GetChild(0); Transform val = ((child != null) ? child.GetChild(0) : null); if ((Object)(object)val == (Object)null) { return; } for (int i = 0; i < val.childCount; i++) { Transform child2 = val.GetChild(i); if ((Object)(object)child2 == (Object)null) { continue; } MeshRenderer component = ((Component)child2).GetComponent<MeshRenderer>(); if ((Object)(object)component == (Object)null) { continue; } Material material = ((Renderer)component).material; if (!((Object)(object)material == (Object)null)) { if (((Object)child2).name == "Stem") { material.color = Color32.op_Implicit(weedAppearance.StemColor); } if (((Object)child2).name == "Leaves") { material.color = Color32.op_Implicit(weedAppearance.LeafColor); } if (((Object)child2).name == "Main") { material.color = Color32.op_Implicit(weedAppearance.MainColor); } if (((Object)child2).name == "Secondary") { material.color = Color32.op_Implicit(weedAppearance.SecondaryColor); } } } } public PlantHarvestable CloneBranchPrefab(WeedDefinition newDef) { if ((Object)(object)baseBranchPrefab == (Object)null) { throw new InvalidOperationException("Base branch prefab not initialized."); } PlantHarvestable val = Object.Instantiate<PlantHarvestable>(baseBranchPrefab, rootGameObject); ((Object)((Component)val).gameObject).name = ((BaseItemDefinition)newDef).ID + "_Harvestable"; ((Component)val).gameObject.layer = ((Component)baseBranchPrefab).gameObject.layer; val.Product = (StorableItemDefinition)(object)newDef; return val; } public FunctionalSeed CloneFunctionalSeedPrefab(string seedDefId) { if ((Object)(object)baseFunctionalSeedPrefab == (Object)null) { throw new InvalidOperationException("Base functional seed prefab not initialized."); } FunctionalSeed val = Object.Instantiate<FunctionalSeed>(baseFunctionalSeedPrefab, rootGameObject); GrowLabel(((Component)val).transform, seedDefId); return val; } public Equippable_Seed CloneEquippableSeedPrefab(SeedDefinition newDef, WeedAppearanceSettings weedAppearance) { if ((Object)(object)baseEquippableSeedPrefab == (Object)null) { throw new InvalidOperationException("Base equippable seed prefab not initialized."); } Equippable_Seed val = Object.Instantiate<Equippable_Seed>(baseEquippableSeedPrefab, rootGameObject); GrowLabel(((Component)val).transform, ((BaseItemDefinition)newDef).ID); ((Object)((Component)val).gameObject).name = ((BaseItemDefinition)newDef).ID + "_Equippable"; ((Component)val).gameObject.layer = ((Component)baseEquippableSeedPrefab).gameObject.layer; val.Seed = newDef; ((Equippable_Viewmodel)val).AvatarEquippable = CloneAvatarEquippablePrefab(((BaseItemDefinition)newDef).ID); ((Object)((Equippable_Viewmodel)val).AvatarEquippable).name = ((BaseItemDefinition)newDef).ID + "_AvatarEquippable"; return val; } public AvatarEquippable CloneAvatarEquippablePrefab(string newDefId) { if ((Object)(object)baseAvatarEquippablePrefab == (Object)null) { throw new InvalidOperationException("Base avatar equippable prefab not initialized."); } AvatarEquippable val = Object.Instantiate<AvatarEquippable>(baseAvatarEquippablePrefab, rootGameObject); GrowLabel(((Component)val).transform, newDefId); return val; } public StoredItem CloneStoredItem(string newDefId) { if ((Object)(object)baseStorableItem == (Object)null) { throw new InvalidOperationException("Base Stored Item not initialized."); } StoredItem val = Object.Instantiate<StoredItem>(baseStorableItem, rootGameObject); GrowLabel(((Component)val).transform, newDefId); return val; } public SeedDefinition CreateSeedDefinition(WeedDefinition weedDef) { //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseSeedDefinition == (Object)null) { throw new InvalidOperationException("Base seed definition not initialized."); } SeedDefinition val = Object.Instantiate<SeedDefinition>(baseSeedDefinition); WeedAppearanceSettings val2 = weedDef.appearance; if (val2 == null) { val2 = WeedDefinition.GetAppearanceSettings(((PropertyItemDefinition)weedDef).Properties); } ((Object)val).name = ((BaseItemDefinition)weedDef).ID + "_customseeddefinition"; ((BaseItemDefinition)val).ID = ((BaseItemDefinition)weedDef).ID + "_customseeddefinition"; ((BaseItemDefinition)val).Name = ((Object)weedDef).name + " Seed"; ((BaseItemDefinition)val).Description = ((Object)weedDef).name + " Seed"; ((BaseItemDefinition)val).Icon = ((BaseItemDefinition)baseSeedDefinition).Icon; ((ItemDefinition)val).Equippable = (Equippable)(object)CloneEquippableSeedPrefab(val, val2); val.PlantPrefab = (Plant)(object)ClonePlantPrefab(weedDef); val.PlantPrefab.SeedDefinition = val; val.FunctionSeedPrefab = CloneFunctionalSeedPrefab(((BaseItemDefinition)val).ID); ((Object)val.FunctionSeedPrefab).name = ((BaseItemDefinition)weedDef).ID + "Seed_Functional"; ((StorableItemDefinition)val).StoredItem = CloneStoredItem(((BaseItemDefinition)val).ID); SeedVisualsManager.appearanceMap.Add(((BaseItemDefinition)val).ID, val2); if ((Object)(object)SeedVisualsManager.baseSeedSprite != (Object)null) { try { Sprite val3 = SeedVisualsManager.GenerateSpriteWithGradient(Color32.op_Implicit(val2.MainColor), Color32.op_Implicit(val2.SecondaryColor)); ((Object)val3).name = ((Object)val).name + "_icon"; SeedVisualsManager.seedIcons.Add(((BaseItemDefinition)val).ID, val3); ((BaseItemDefinition)val).Icon = val3; } catch (Exception e) { ((BaseItemDefinition)val).Icon = SeedVisualsManager.baseSeedSprite; Utility.PrintException(e); } } return val; } } [RegisterTypeInIl2Cpp] public class SeedVialLabel : MonoBehaviour { private Renderer rend; private MaterialPropertyBlock block; public Color colorA; public Color colorB; public bool useRandomColors = false; private void Start() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (useRandomColors) { colorA = Random.ColorHSV(); colorB = Random.ColorHSV(); } rend = ((Component)this).GetComponent<Renderer>(); block = new MaterialPropertyBlock(); SetupLabel(); } public void SetupLabel() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rend == (Object)null) { return; } MeshFilter component = ((Component)this).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { string key = ((Object)this).name.Split(':')[1]; SeedVisualsManager.appearanceMap.TryGetValue(key, out var value); if (value != null) { colorA = Color32.op_Implicit(value.MainColor); colorB = Color32.op_Implicit(value.SecondaryColor); } Bounds bounds = component.sharedMesh.bounds; rend.GetPropertyBlock(block); block.SetColor("_ColorA", colorA); block.SetColor("_ColorB", colorB); block.SetFloat("_MinZ", ((Bounds)(ref bounds)).min.z); block.SetFloat("_MaxZ", ((Bounds)(ref bounds)).max.z); rend.SetPropertyBlock(block); } } } } namespace UnicornsCustomSeeds.SeedQuests { public class CustomSeedQuest : Quest { [SaveableField("QuestData")] private CustomSeedQuestData _data = new CustomSeedQuestData(); public QuestEntry customSeedEntry; protected override string Title => "Drop off the Mix"; protected override string Description => $"Take {StashManager.StashQtyEntry.Value}x of your weed mix and ${StashManager.StashCostEntry.Value} dollary doos to Albert Hoovers supply stash"; protected override void OnLoaded() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (base.QuestEntries.Count == 0) { customSeedEntry = ((Quest)this).AddEntry($"Give Albert {StashManager.StashQtyEntry.Value}x of a Weed Mix and ${StashManager.StashCostEntry.Value}", (Vector3?)((Component)StashManager.albertsStash).transform.position); } } protected override void OnCreated() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (base.QuestEntries.Count == 0) { customSeedEntry = ((Quest)this).AddEntry($"Give Albert {StashManager.StashQtyEntry.Value}x of a Weed Mix and ${StashManager.StashCostEntry.Value}", (Vector3?)((Component)StashManager.albertsStash).transform.position); } } } [Serializable] public class CustomSeedQuestData { public float quantity { get; set; } = 0f; public string seedId { get; set; } = string.Empty; } } namespace UnicornsCustomSeeds.Patches { [HarmonyPatch(typeof(QuestManager), "OnSpawnServer")] public static class QuestManager_OnSpawnServer_Patch { public static void Postfix(NetworkConnection connection) { if (InstanceFinder.IsServer && QuestManager.GetQuestByName("Drop off the Mix") is CustomSeedQuest) { SeedQuestManager.BroadcastCustomQuest(); } } } [HarmonyPatch(typeof(ProductManager), "OnSpawnServer")] public static class ProductManager_OnSpawnServer_NetTest { public static void Postfix(ProductManager __instance, NetworkConnection connection) { //IL_0044: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown if (connection == (NetworkConnection)null || !InstanceFinder.IsServer || connection.IsHost) { return; } List<string> list = new List<string>(); WeedAppearanceSettings val = new WeedAppearanceSettings(Color32.op_Implicit(__instance.DefaultWeed.MainMat.color), Color32.op_Implicit(__instance.DefaultWeed.SecondaryMat.color), Color32.op_Implicit(__instance.DefaultWeed.LeafMat.color), Color32.op_Implicit(__instance.DefaultWeed.StemMat.color)); foreach (KeyValuePair<string, UnicornSeedData> discoveredSeed in CustomSeedsManager.DiscoveredSeeds) { __instance.CreateWeed_Server("[NET-JSON]" + JsonConvert.SerializeObject((object)discoveredSeed.Value, (Formatting)0), "ogkushseed", (EDrugType)0, list, val); } } } [HarmonyPatch(typeof(ProductManager), "RpcLogic___CreateWeed_1777266891")] public static class ProductManager_RpcLogic_CreateWeed_NetTest { public static void Postfix(ProductManager __instance, NetworkConnection conn, string name, string id, EDrugType type, List<string> properties, WeedAppearanceSettings appearance) { if (id != "ogkushseed" || name == null) { return; } if (name.StartsWith("[NET-QUEST]") && InstanceFinder.IsClientOnly) { string text = name.Replace("[NET-QUEST]", ""); try { string[] array = text.Split(','); if (array.Length == 3) { if (int.TryParse(array[0], out var result)) { StashManager.StashCostEntry.Value = result; } if (int.TryParse(array[1], out var result2)) { StashManager.StashQtyEntry.Value = result2; } if (int.TryParse(array[2], out var result3)) { StashManager.SynthesizeTime.Value = result3; } } } catch (Exception e) { Utility.PrintException(e); } if ((Object)(object)StashManager.albertsStash == (Object)null) { StashManager.GetAlbertsStash(); } CustomSeedQuest customSeedQuest = QuestManager.GetQuestByName("Drop off the Mix") as CustomSeedQuest; if (customSeedQuest == null) { SeedQuestManager.CreateQuestAsync(); } } else { if (!name.StartsWith("[NET-JSON]")) { return; } string text2 = name.Replace("[NET-JSON]", ""); try { UnicornSeedData unicornSeedData = JsonConvert.DeserializeObject<UnicornSeedData>(text2); if (Registry.ItemExists(unicornSeedData.seedId)) { return; } if (!CustomSeedsManager.DiscoveredSeeds.ContainsKey(unicornSeedData.weedId)) { CustomSeedsManager.DiscoveredSeeds.Add(unicornSeedData.weedId, unicornSeedData); } SeedDefinition val = CustomSeedsManager.SeedDefinitionLoader(unicornSeedData); if ((Object)(object)val != (Object)null) { try { WeedDefinition item = Registry.GetItem<WeedDefinition>(unicornSeedData.weedId); float ingredientCost = StashManager.GetIngredientCost((ProductDefinition)(object)item); Singleton<ManagementUtilities>.Instance.Seeds.Add(val); CustomSeedsManager.CreateShopListing(val, ingredientCost); CustomSeedsManager.AddSeedToPots(val); CustomSeedsManager.EnableSeedIndicator(unicornSeedData.weedId); } catch (Exception e2) { Utility.PrintException(e2); } } if (InstanceFinder.IsClient) { DeferredPlantsManager.TrySpawnQueuedPlants(((BaseItemDefinition)val).ID); } } catch (Exception e3) { Utility.PrintException(e3); } } } } [HarmonyPatch(typeof(Pot), "RpcLogic___PlantSeed_Client_4077118173")] public static class Patch_Pot_RpcLogic___PlantSeed_Client_4077118173 { public static bool Prefix(Pot __instance, NetworkConnection conn, string seedID, float normalizedSeedProgress) { if (!InstanceFinder.IsClient || InstanceFinder.IsServer) { return true; } if (DeferredPlantsManager.IsReplaying) { return true; } if (string.IsNullOrEmpty(seedID)) { return true; } if (!seedID.Contains("customseeddefinition")) { return true; } if (Registry.ItemExists(seedID)) { return true; } DeferredPlantsManager.AddDeferredSeed(__instance, seedID, normalizedSeedProgress); return false; } } [HarmonyPatch(typeof(Pot), "RpcLogic___SetHarvestableActive_Client_338960014")] public static class Patch_Pot_RpcLogic___SetHarvestableActive_Client_338960014 { public static bool Prefix(Pot __instance, NetworkConnection conn, int harvestableIndex, bool active) { if (!InstanceFinder.IsClient || InstanceFinder.IsServer) { return true; } if (DeferredPlantsManager.PendingPotGuids.Contains(((BuildableItem)__instance).GUID.ToString())) { DeferredPlantsManager.AddHarvestableUpdate(((BuildableItem)__instance).GUID.ToString(), harvestableIndex, active); return false; } return true; } } public class ProductManagerAppPatches { [HarmonyPatch(typeof(ProductManagerApp))] public static class ProductManagerApp_Patch { [HarmonyPrefix] [HarmonyPatch("Start")] public static bool StartPatch(ProductManagerApp __instance) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.EntryPrefab != (Object)null && (Object)(object)__instance.EntryPrefab.transform.Find("SeedIndicator") == (Object)null) { GameObject val = new GameObject("Temp"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(__instance.EntryPrefab, val.transform); ProductEntry component = __instance.EntryPrefab.GetComponent<ProductEntry>(); GameObject val3 = Object.Instantiate<GameObject>(((Component)component.FavouriteButton).gameObject, val2.transform); Button component2 = val3.GetComponent<Button>(); Object.Destroy((Object)(object)component2); ((Object)val3).name = "SeedIndicator"; RectTransform component3 = val3.GetComponent<RectTransform>(); if ((Object)(object)component3 != (Object)null) { component3.anchoredPosition = new Vector2(15f, -15f); component3.anchorMax = new Vector2(0f, 1f); component3.anchorMin = new Vector2(0f, 1f); } TrySetSeedIconSprite(val3); __instance.EntryPrefab = val2; isPrefabInitialized = true; } return true; } [HarmonyPostfix] [HarmonyPatch("Start")] public static void StartPostfix(ProductManagerApp __instance) { UpdatePendingIndicators(); } } [HarmonyPatch(typeof(ProductEntry), "Initialize")] public static class ProductEntry_Initialize_Patch { [HarmonyPostfix] public static void Postfix(ProductEntry __instance, ProductDefinition definition) { if (!((Object)(object)__instance != (Object)null) || !((Object)(object)definition != (Object)null)) { return; } Transform val = ((Component)__instance).transform.Find("SeedIndicator"); if ((Object)(object)val != (Object)null) { TrySetSeedIconSprite(((Component)val).gameObject); if (CustomSeedsManager.DiscoveredSeeds.ContainsKey(((BaseItemDefinition)definition).ID)) { ((Component)val).gameObject.SetActive(true); } else { ((Component)val).gameObject.SetActive(false); } } } } private static bool isPrefabInitialized = false; private static List<GameObject> pendingIndicators = new List<GameObject>(); private static void TrySetSeedIconSprite(GameObject indicatorObject) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)SeedVisualsManager.seedIcon == (Object)null) { SeedVisualsManager.LoadSeedMaterial(); } Image component = ((Component)indicatorObject.transform.GetChild(0)).GetComponent<Image>(); if ((Object)(object)component != (Object)null) { if ((Object)(object)SeedVisualsManager.seedIcon != (Object)null) { component.sprite = SeedVisualsManager.seedIcon; ((Graphic)component).color = Color.white; } else if (!pendingIndicators.Contains(indicatorObject)) { pendingIndicators.Add(indicatorObject); Utility.Log("Seed icon not loaded yet, added to pending list"); } } } catch (Exception e) { Utility.PrintException(e); } } private static void UpdatePendingIndicators() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (pendingIndicators.Count == 0) { return; } for (int num = pendingIndicators.Count - 1; num >= 0; num--) { GameObject val = pendingIndicators[num]; if ((Object)(object)val == (Object)null) { pendingIndicators.RemoveAt(num); } else { try { Image component = ((Component)val.transform.GetChild(0)).GetComponent<Image>(); if ((Object)(object)component != (Object)null && (Object)(object)SeedVisualsManager.seedIcon != (Object)null) { component.sprite = SeedVisualsManager.seedIcon; ((Graphic)component).color = Color.white; pendingIndicators.RemoveAt(num); } } catch (Exception e) { Utility.PrintException(e); pendingIndicators.RemoveAt(num); } } } } public static void ClearPendingIndicators() { pendingIndicators.Clear(); isPrefabInitialized = false; } } [HarmonyPatch(typeof(ProductDefinition), "AddRecipe")] public class ProductDefinition_AddRecipe_Patch { private static void Postfix(ProductDefinition __instance) { StashManager.ProcessNewRecipe(__instance); } } [HarmonyPatch(typeof(SendableMessage), "IsValid")] public class SendableMessage_IsValid_Patch { public static bool Prefix(SendableMessage __instance, ref bool __result, out string invalidReason) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) invalidReason = string.Empty; if (__instance.Text != null && __instance.Text == SeedQuestManager.messageId) { if (SeedQuestManager.HasActiveQuest) { invalidReason = "Seed Synthesizing is already in progress"; __result = false; } else if ((Object)(object)DeadDrop.GetRandomEmptyDrop(((Component)Player.Local).transform.position) == (Object)null) { invalidReason = "No deaddrops are available"; __result = false; } else if ((Object)(object)ConversationManager.albert == (Object)null || ((NPC)ConversationManager.albert).RelationData.RelationDelta < 4f) { invalidReason = "Relationship isn't good enough"; __result = false; } else { __result = true; } return false; } return true; } } [HarmonyPatch(typeof(LoadManager), "ExitToMenu")] public static class LoadManager_ExitToMenu_Patch { public static void Postfix(LoadManager __instance, SaveInfo autoLoadSave, Data mainMenuPopup, bool preventLeaveLobby) { List<SeedDefinition> seeds = Singleton<ManagementUtilities>.Instance.Seeds; List<SeedDefinition> list = new List<SeedDefinition>(); foreach (SeedDefinition item in seeds) { if ((Object)(object)item != (Object)null && !((BaseItemDefinition)item).ID.Contains("customseeddefinition")) { list.Add(item); } } Singleton<ManagementUtilities>.Instance.Seeds = list; } } [HarmonyPatch(typeof(LoadManager), "StartGame")] public static class LoadManager_StartGame_Patch { public static void Postfix(LoadManager __instance) { if ((Object)(object)__instance == (Object)null || string.IsNullOrEmpty(__instance.LoadedGameFolderPath)) { return; } try { string loadedGameFolderPath = __instance.LoadedGameFolderPath; if (string.IsNullOrEmpty(loadedGameFolderPath)) { return; } string path = Path.Combine(loadedGameFolderPath, "DiscoveredCustomSeeds.json"); List<UnicornSeedData> list = new List<UnicornSeedData>(); if (File.Exists(path)) { CustomSeedsManager.FirstLoad = false; string text = File.ReadAllText(path); try { list = JsonConvert.DeserializeObject<List<UnicornSeedData>>(text) ?? new List<UnicornSeedData>(); Utility.Success($"Successfully loaded {list.Count} custom seeds"); } catch (Exception e) { Utility.PrintException(e); CustomSeedsManager.FirstLoad = true; list = new List<UnicornSeedData>(); } } else { CustomSeedsManager.FirstLoad = true; } foreach (UnicornSeedData item in list) { ItemDefinition val = Singleton<Registry>.Instance._GetItem(item.weedId, true); if (item != null && !CustomSeedsManager.DiscoveredSeeds.ContainsKey(item.weedId)) { CustomSeedsManager.DiscoveredSeeds.Add(item.weedId, item); } } } catch (Exception arg) { MelonLogger.Error($"Error handling DiscoveredCustomSeeds.json: {arg}"); } } } [HarmonyPatch(typeof(ProductManager), "CreateWeed")] public static class Patch_ProductManager_CreateWeed { public static void Postfix(NetworkConnection conn, string name, string id, EDrugType type, List<string> properties, WeedAppearanceSettings appearance) { if (Registry.ItemExists(id + "_customseeddefinition") || !CustomSeedsManager.DiscoveredSeeds.TryGetValue(id, out var value)) { return; } SeedDefinition val = CustomSeedsManager.SeedDefinitionLoader(value); if (!((Object)(object)val != (Object)null)) { return; } try { Singleton<ManagementUtilities>.Instance.Seeds.Add(val); } catch (Exception e) { Utility.PrintException(e); } } } } namespace UnicornsCustomSeeds.Managers { public static class ConversationManager { [CompilerGenerated] private sealed class <WelcomeRoutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WelcomeRoutine>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>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(10f); <>1__state = 1; return true; case 1: <>1__state = -1; AlbertWelcomeMessage((EUnlockType)1, temp: 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(); } } public static Dictionary<string, MSGConversation> Conversations = new Dictionary<string, MSGConversation>(); public static Albert albert; public static NPCRelationData albertRelation; public static string welcomeMessage = "A <color='#FA2FBD'><b>Unicorn</b></color> I know can synthesize your custom mixes into seeds. If you'd like to use that service, send me a text."; public static void Init() { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) albert = Object.FindObjectOfType<Albert>(); if ((Object)(object)albert != (Object)null) { if (((NPC)albert).MSGConversation != null) { RegisterConversation("Albert", ((NPC)albert).MSGConversation); albertRelation = ((NPC)albert).RelationData; } if (!CustomSeedsManager.FirstLoad || ((NPC)albert).RelationData == null) { return; } if (((NPC)albert).RelationData.RelationDelta >= 4f) { MelonCoroutines.Start(WelcomeRoutine()); return; } DialogueDatabase database = ((NPC)albert).DialogueHandler.Database; DialogueModule module = database.GetModule((EDialogueModule)0); for (int i = 0; i < module.Entries.Count; i++) { if (module.Entries[i].Key == "supplier_meetings_unlocked") { Entry val = module.Entries[i]; DialogueChain val2 = val.Chains[0]; if (val2 != null && val2.Lines[val2.Lines.Length - 1] != welcomeMessage) { string[] lines = val2.Lines; string[] array = new string[lines.Length + 1]; array[0] = lines[0]; array[1] = lines[1]; array[2] = welcomeMessage; val2.Lines = array; } } } } else { Utility.Error("ConversationManager: Could not find Albert or his conversation."); } } public static void RegisterConversation(string name, MSGConversation convo) { if (!Conversations.ContainsKey(name)) { Conversations.Add(name, convo); } else { Conversations[name] = convo; } } public static MSGConversation GetConversation(string name) { if (Conversations.TryGetValue(name, out var value)) { return value; } return null; } public static void SendMessage(string characterName, string text) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown if (!InstanceFinder.IsServer) { return; } if (Conversations.TryGetValue(characterName, out var value)) { if (value != null) { value.SendMessage(new Message(text, (ESenderType)1, true, -1), true, true); } } else { Utility.Error("ConversationManager: Conversation for " + characterName + " not found."); } } public static void SendMessageChain(string characterName, List<string> messages) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown if (!InstanceFinder.IsServer) { return; } if (Conversations.TryGetValue(characterName, out var value)) { if (value == null) { return; } MessageChain val = new MessageChain(); foreach (string message in messages) { val.Messages.Add(message); } val.id = Random.Range(int.MinValue, int.MaxValue); value.SendMessageChain(val, 0.5f, true, true); } else { Utility.Error("Conversation for " + characterName + " not found."); } } public static void AlbertWelcomeMessage(EUnlockType type, bool temp) { SendMessage("Albert", welcomeMessage); } [IteratorStateMachine(typeof(<WelcomeRoutine>d__10))] private static IEnumerator WelcomeRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WelcomeRoutine>d__10(0); } } public static class DeferredPlantsManager { public struct DeferredSeedData { public Pot Pot; public string SeedId; public float Progress; } public struct HarvestableUpdateData { public int Index; public bool Active; } public static bool IsReplaying = false; public static HashSet<string> PendingPotGuids = new HashSet<string>(); public static Dictionary<string, List<DeferredSeedData>> seedsToLoad = new Dictionary<string, List<DeferredSeedData>>(); public static Dictionary<string, List<HarvestableUpdateData>> DeferredHarvestables = new Dictionary<string, List<HarvestableUpdateData>>(); public static void AddDeferredSeed(Pot pot, string seedId, float progress) { if (seedsToLoad.ContainsKey(seedId)) { seedsToLoad[seedId].Add(new DeferredSeedData { Pot = pot, SeedId = seedId, Progress = progress }); } else { List<DeferredSeedData> list = new List<DeferredSeedData>(); list.Add(new DeferredSeedData { Pot = pot, SeedId = seedId, Progress = progress }); seedsToLoad.Add(seedId, list); } PendingPotGuids.Add(((BuildableItem)pot).GUID.ToString()); } public static void AddHarvestableUpdate(string potGuid, int index, bool active) { if (!DeferredHarvestables.ContainsKey(potGuid)) { DeferredHarvestables[potGuid] = new List<HarvestableUpdateData>(); } DeferredHarvestables[potGuid].Add(new HarvestableUpdateData { Index = index, Active = active }); } public static void TrySpawnQueuedPlants(string seedId) { if (!seedsToLoad.ContainsKey(seedId)) { return; } List<DeferredSeedData> list = seedsToLoad[seedId]; foreach (DeferredSeedData item in list) { item.Pot.PlantSeed_Client((NetworkConnection)null, item.SeedId, item.Progress); string text = ((BuildableItem)item.Pot).GUID.ToString(); if (DeferredHarvestables.ContainsKey(text)) { foreach (HarvestableUpdateData item2 in DeferredHarvestables[text]) { item.Pot.Plant.SetHarvestableActive(item2.Index, item2.Active); } DeferredHarvestables.Remove(text); } PendingPotGuids.Remove(text); } } } public static class SeedQuestManager { [CompilerGenerated] private sealed class <CreateQuestCoroutine>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private int <attemptCount>5__1; private CustomSeedQuest <existingQuest>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CreateQuestCoroutine>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <existingQuest>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <attemptCount>5__1 = 0; break; case 1: <>1__state = -1; break; } while (<attemptCount>5__1 < 5) { <attemptCount>5__1++; try { <existingQuest>5__2 = QuestManager.GetQuestByName("Drop off the Mix") as CustomSeedQuest; if (<existingQuest>5__2 != null) { seedDropoff = <existingQuest>5__2; IsWaitingForDropoff = true; return false; } seedDropoff = QuestManager.CreateQuest<CustomSeedQuest>((string)null) as CustomSeedQuest; if (seedDropoff != null) { IsWaitingForDropoff = true; return false; } <existingQuest>5__2 = null; } catch { } if (<attemptCount>5__1 < 5) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } } Utility.Error($"[CreateQuestAsync] Failed to Load Quest after {5} attempts"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static CustomSeedQuest seedDropoff; public static string messageId = "Synthesize Seeds"; public static bool IsWaitingForDropoff = false; private static float lastSentTime = 0f; public static bool HasActiveQuest => IsWaitingForDropoff; public static void Init() { if (QuestManager.GetQuestByName("Drop off the Mix") is CustomSeedQuest customSeedQuest) { seedDropoff = customSeedQuest; IsWaitingForDropoff = true; } else { IsWaitingForDropoff = false; } MSGConversation conversation = ConversationManager.GetConversation("Albert"); if (conversation != null) { MessageSenderInterface senderInterface = conversation.senderInterface; SendableMessage val = conversation.CreateSendableMessage(messageId); val.onSent = (Action)Delegate.Combine(val.onSent, new Action(OnSent)); } } public static void OnSent() { if (!InstanceFinder.IsServer || Time.time - lastSentTime < 1f) { return; } List<string> list = new List<string>(); list.Add("Drop the weed mix and cash in my drop box."); ConversationManager.SendMessageChain("Albert", list); IsWaitingForDropoff = true; if (seedDropoff == null) { if (InstanceFinder.IsServer) { BroadcastCustomQuest(); } seedDropoff = QuestManager.CreateQuest<CustomSeedQuest>((string)null) as CustomSeedQuest; } } public static void BroadcastCustomQuest() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown ProductManager instance = NetworkSingleton<ProductManager>.Instance; string text = $"[NET-QUEST]{StashManager.StashCostEntry.Value},{StashManager.StashQtyEntry.Value},{StashManager.SynthesizeTime.Value}"; List<string> list = new List<string>(); WeedAppearanceSettings val = new WeedAppearanceSettings(Color32.op_Implicit(instance.DefaultWeed.MainMat.color), Color32.op_Implicit(instance.DefaultWeed.SecondaryMat.color), Color32.op_Implicit(instance.DefaultWeed.LeafMat.color), Color32.op_Implicit(instance.DefaultWeed.StemMat.color)); instance.CreateWeed_Server(text, "ogkushseed", (EDrugType)0, list, val); } public static void CreateQuestAsync() { MelonCoroutines.Start(CreateQuestCoroutine()); } [IteratorStateMachine(typeof(<CreateQuestCoroutine>d__10))] private static IEnumerator CreateQuestCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CreateQuestCoroutine>d__10(0); } public static void CompleteQuest() { if (seedDropoff != null) { ((Quest)seedDropoff).Complete(); seedDropoff = null; } IsWaitingForDropoff = false; } public static void SendMessage(string text) { ConversationManager.SendMessage("Albert", text); } public static void OnSelected() { MSGConversation conversation = ConversationManager.GetConversation("Albert"); if (conversation != null) { conversation.senderInterface.SetVisibility((EVisibility)1); } } } public static class SeedVisualsManager { public enum BlendMode { Lerp, Multiply, Add, Screen } public static Dictionary<string, Sprite> seedIcons = new Dictionary<string, Sprite>(); public static Dictionary<string, WeedAppearanceSettings> appearanceMap = new Dictionary<string, WeedAppearanceSettings>(); public static Shader customShader; public static Material customMat; public static Sprite baseSeedSprite; public static Sprite seedIcon; public static BlendMode blendMode = BlendMode.Lerp; public static Rect gradientArea01 = new Rect(0.37f, 0.312f, 0.24f, 0.38f); public static float gradientOpacity = 1f; public static void LoadSeedMaterial() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown try { AssetBundleUtils.LoadAssetBundle("customshaders"); Sprite val = AssetBundleUtils.LoadAssetFromBundle<Sprite>("customseed_icon.png", "customshaders"); if ((Object)(object)val != (Object)null) { baseSeedSprite = val; Object.DontDestroyOnLoad((Object)(object)baseSeedSprite); } Sprite val2 = AssetBundleUtils.LoadAssetFromBundle<Sprite>("seedicon.png", "customshaders"); if ((Object)(object)val2 != (Object)null) { seedIcon = val2; Object.DontDestroyOnLoad((Object)(object)seedIcon); } Shader val3 = AssetBundleUtils.LoadAssetFromBundle<Shader>("labelgradient.shader", "customshaders"); if ((Object)(object)val3 != (Object)null) { customShader = val3; Material val4 = new Material(customShader); if ((Object)(object)val4 != (Object)null) { customMat = val4; Object.DontDestroyOnLoad((Object)(object)val3); } } else { Utility.Error("Fail"); } } catch (Exception e) { Utility.PrintException(e); } } public static Sprite GenerateSpriteWithGradient(Color topColor, Color bottomColor) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)baseSeedSprite == (Object)null || (Object)(object)baseSeedSprite.texture == (Object)null) { Utility.Error("[VialTextureGenerator] Base Sprite is missing."); return null; } Texture2D texture = baseSeedSprite.texture; Rect rect = baseSeedSprite.rect; ((Rect)(ref rect)).x = ((Rect)(ref rect)).x / (float)((Texture)texture).width; ((Rect)(ref rect)).y = ((Rect)(ref rect)).y / (float)((Texture)texture).height; ((Rect)(ref rect)).width = ((Rect)(ref rect)).width / (float)((Texture)texture).width; ((Rect)(ref rect)).height = ((Rect)(ref rect)).height / (float)((Texture)texture).height; Color[] pixels = texture.GetPixels(Mathf.FloorToInt(((Rect)(ref rect)).x * (float)((Texture)texture).width), Mathf.FloorToInt(((Rect)(ref rect)).y * (float)((Texture)texture).height), Mathf.FloorToInt(((Rect)(ref rect)).width * (float)((Texture)texture).width), Mathf.FloorToInt(((Rect)(ref rect)).height * (float)((Texture)texture).height)); ApplyVerticalGradientInRect(pixels, Mathf.FloorToInt(((Rect)(ref rect)).width * (float)((Texture)texture).width), Mathf.FloorToInt(((Rect)(ref rect)).height * (float)((Texture)texture).height), gradientArea01, topColor, bottomColor, gradientOpacity, blendMode); int num = Mathf.FloorToInt(((Rect)(ref rect)).width * (float)((Texture)texture).width); int num2 = Mathf.FloorToInt(((Rect)(ref rect)).height * (float)((Texture)texture).height); Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false); val.SetPixels(pixels); val.Apply(); ((Object)val).name = "Copy"; return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0.5f, 0.5f)); } private static void ApplyVerticalGradientInRect(Color[] pixels, int width, int height, Rect rect01, Color top, Color bottom, float opacity, BlendMode mode) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.RoundToInt(((Rect)(ref rect01)).x * (float)width); int num2 = Mathf.RoundToInt(((Rect)(ref rect01)).y * (float)height); int num3 = Mathf.RoundToInt(((Rect)(ref rect01)).width * (float)width); int num4 = Mathf.RoundToInt(((Rect)(ref rect01)).height * (float)height); num = Mathf.Clamp(num, 0, width); num2 = Mathf.Clamp(num2, 0, height); num3 = Mathf.Clamp(num3, 0, width - num); num4 = Mathf.Clamp(num4, 0, height - num2); if (num3 <= 0 || num4 <= 0) { return; } for (int i = 0; i < num4; i++) { float num5 = (float)i / (float)((num4 - 1 <= 0) ? 1 : (num4 - 1)); Color dst = Color.Lerp(bottom, top, num5); dst.a *= opacity; int num6 = num2 + i; int num7 = num6 * width; for (int j = 0; j < num3; j++) { int num8 = num + j; int num9 = num7 + num8; Color src = pixels[num9]; pixels[num9] = Blend(dst, src, mode); } } } private static Color Blend(Color dst, Color src, BlendMode mode) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) switch (mode) { case BlendMode.Multiply: return new Color(dst.r * Mathf.Lerp(1f, src.r, src.a), dst.g * Mathf.Lerp(1f, src.g, src.a), dst.b * Mathf.Lerp(1f, src.b, src.a), Mathf.Max(dst.a, src.a)); case BlendMode.Add: return new Color(Mathf.Clamp01(dst.r + src.r * src.a), Mathf.Clamp01(dst.g + src.g * src.a), Mathf.Clamp01(dst.b + src.b * src.a), Mathf.Max(dst.a, src.a)); case BlendMode.Screen: { float num = 1f - (1f - dst.r) * (1f - src.r * src.a); float num2 = 1f - (1f - dst.g) * (1f - src.g * src.a); float num3 = 1f - (1f - dst.b) * (1f - src.b * src.a); return new Color(num, num2, num3, Mathf.Max(dst.a, src.a)); } default: return new Color(Mathf.Lerp(dst.r, src.r, src.a), Mathf.Lerp(dst.g, src.g, src.a), Mathf.Lerp(dst.b, src.b, src.a), Mathf.Max(dst.a, src.a)); } } } public struct SeedComponents { public string seedId; public string baseSeedId; } public static class CustomSeedsManager { public delegate bool ValidityCheckDelegate(SendableMessage message, out string invalidReason); [CompilerGenerated] private sealed class <CreateSeed>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public WeedDefinition weedDef; private SeedDefinition <newSeed>5__1; private float <price>5__2; private UnicornSeedData <newSeedData>5__3; private DeadDrop <randomEmptyDrop>5__4; private ItemInstance <defaultInstance>5__5; private string <guidString>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CreateSeed>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <newSeed>5__1 = null; <newSeedData>5__3 = null; <randomEmptyDrop>5__4 = null; <defaultInstance>5__5 = null; <guidString>5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds((float)StashManager.SynthesizeTime.Value); <>1__state = 1; return true; case 1: <>1__state = -1; <newSeed>5__1 = factory.CreateSeedDefinition(weedDef); Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)<newSeed>5__1); <price>5__2 = StashManager.GetIngredientCost((ProductDefinition)(object)weedDef); <newSeedData>5__3 = new UnicornSeedData { seedId = ((BaseItemDefinition)<newSeed>5__1).ID, weedId = ((BaseItemDefinition)weedDef).ID, baseSeedId = "ogkushseed", price = <price>5__2 }; DiscoveredSeeds.Add(<newSeedData>5__3.weedId, <newSeedData>5__3); CreateShopListing(<newSeed>5__1, <price>5__2); AddSeedToPots(<newSeed>5__1); EnableSeedIndicator(<newSeedData>5__3.weedId); <randomEmptyDrop>5__4 = DeadDrop.GetRandomEmptyDrop(((Component)Player.Local).transform.position); if ((Object)(object)<randomEmptyDrop>5__4 != (Object)null && InstanceFinder.IsServer) { <defaultInstance>5__5 = ((ItemDefinition)<newSeed>5__1).GetDefaultInstance(1); ((BaseItemInstance)<defaultInstance>5__5).SetQuantity(10); ((StorageEntity)<randomEmptyDrop>5__4.Storage).InsertItem(<defaultInstance>5__5, true); <guidString>5__6 = GUIDManager.GenerateUniqueGUID().ToString(); NetworkSingleton<QuestManager>.Instance.CreateDeaddropCollectionQuest((NetworkConnection)null, <randomEmptyDrop>5__4.GUID.ToString(), <guidString>5__6); SeedQuestManager.SendMessage(((Object)weedDef).name + " is synthesized and placed in the deaddrop"); <defaultInstance>5__5 = null; <guidString>5__6 = null; } else { if ((Object)(object)<randomEmptyDrop>5__4 == (Object)null) { Utility.Error("No Dead Drop found"); } SeedQuestManager.SendMessage("Wasn't able to find a deadrop for " + ((Object)weedDef).name + " Seed. It is synthesized and available in the shop"); } BroadcastCustomSeed(<newSeedData>5__3); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public const string BASE_SEED_ID = "ogkushseed"; public static SeedFactory factory; public static Dictionary<string, UnicornSeedData> DiscoveredSeeds = new Dictionary<string, UnicornSeedData>(); public static ShopInterface Shop = null; public static GameObject shopGo = null; public static Dictionary<string, SeedDefinition> baseSeedDefinitions = new Dictionary<string, SeedDefinition>(); public static Dictionary<string, ShopListing> baseShopListing = new Dictionary<string, ShopListing>(); public static bool FirstLoad = false; public static void Initialize() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown ShopInterface[] array = Object.FindObjectsOfType<ShopInterface>(); ShopInterface[] array2 = array; foreach (ShopInterface val in array2) { if (((Object)((Component)val).gameObject).name == "WeedSupplierInterface") { shopGo = ((Component)val).gameObject; Shop = val; break; } } if ((Object)(object)Shop == (Object)null) { Utility.Error("Shop is null!"); return; } ConversationManager.Init(); SeedQuestManager.Init(); SeedVisualsManager.LoadSeedMaterial(); InitDictionary(); AddScrollToPhoneInterface(); foreach (KeyValuePair<string, UnicornSeedData> discoveredSeed in DiscoveredSeeds) { SeedDefinition item = Registry.GetItem<SeedDefinition>(discoveredSeed.Value.seedId); if ((Object)(object)item != (Object)null) { CreateShopListing(item, discoveredSeed.Value.price); if ((Object)(object)ConversationManager.albert != (Object)null) { Listing val2 = new Listing((StorableItemDefinition)(object)item); IEnumerable<Listing> source = CollectionExtensions.AddItem<Listing>((IEnumerable<Listing>)((Supplier)ConversationManager.albert).OnlineShopItems, val2); ((Supplier)ConversationManager.albert).OnlineShopItems = source.ToArray(); } } } } public static void ClearAll() { SeedVisualsManager.seedIcons.Clear(); SeedVisualsManager.appearanceMap.Clear(); SeedQuestManager.seedDropoff = null; DiscoveredSeeds.Clear(); factory.DeleteChildren(); FirstLoad = false; } public static void AddScrollToPhoneInterface() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)PlayerSingleton<MessagesApp>.Instance.PhoneShopInterface).transform; Transform val = transform.Find("Shade/Content/Entries"); if ((Object)(object)val != (Object)null) { GameObject gameObject = ((Component)val).gameObject; RectTransform component = gameObject.GetComponent<RectTransform>(); Image component2 = gameObject.GetComponent<Image>(); if ((Object)(object)component == (Object)null) { Utility.Error("Entries does not have a RectTransform component"); return; } GameObject val2 = new GameObject("ScrollView"); val2.transform.SetParent(((Transform)component).parent, false); RectTransform val3 = val2.AddComponent<RectTransform>(); val3.anchorMin = new Vector2(0f, 1f); val3.anchorMax = new Vector2(1f, 1f); val3.pivot = new Vector2(0.5f, 1f); val3.anchoredPosition = new Vector2(0f, -140f); val3.sizeDelta = component.sizeDelta; val2.AddComponent<Mask>(); ((Behaviour)gameObject.GetComponent<Mask>()).enabled = false; Image val4 = val2.AddComponent<Image>(); ((Graphic)val4).color = ((Graphic)component2).color; ScrollRect val5 = val2.AddComponent<ScrollRect>(); val5.horizontal = false; val5.vertical = true; val5.movementType = (MovementType)2; val5.inertia = true; val5.scrollSensitivity = 20f; component.pivot = new Vector2(0.5f, 1f); ContentSizeFitter val6 = gameObject.AddComponent<ContentSizeFitter>(); if ((Object)(object)val6 != (Object)null) { val6.verticalFit = (FitMode)2; } VerticalLayoutGroup component3 = gameObject.GetComponent<VerticalLayoutGroup>(); ((LayoutGroup)component3).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)component3).spacing = 20f; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = false; ((LayoutGroup)component3).padding.top = 20; ((LayoutGroup)component3).padding.bottom = 20; gameObject.transform.SetParent(val2.transform, false); val5.content = component; component.anchoredPosition = Vector2.zero; } else { Utility.Error("Could not find Shade/Content/Entries in phone shop interface"); } } public static void StartSeedCreation(WeedDefinition weedDef) { MelonCoroutines.Start(CreateSeed(weedDef)); } public static void BroadcastCustomSeed(UnicornSeedData seed) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown ProductManager instance = NetworkSingleton<ProductManager>.Instance; string text = JsonConvert.SerializeObject((object)seed); string text2 = "[NET-JSON]" + text; List<string> list = new List<string>(); WeedAppearanceSettings val = new WeedAppearanceSettings(Color32.op_Implicit(instance.DefaultWeed.MainMat.color), Color32.op_Implicit(instance.DefaultWeed.SecondaryMat.color), Color32.op_Implicit(instance.DefaultWeed.LeafMat.color), Color32.op_Implicit(instance.DefaultWeed.StemMat.color)); instance.CreateWeed_Server(text2, "ogkushseed", (EDrugType)0, list, val); } [IteratorStateMachine(typeof(<CreateSeed>d__14))] public static IEnumerator CreateSeed(WeedDefinition weedDef) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CreateSeed>d__14(0) { weedDef = weedDef }; } public static void InitDictionary() { List<ShopListing> listings = Shop.Listings; foreach (ShopListing item2 in listings) { StorableItemDefinition item = item2.Item; SeedDefinition val = (SeedDefinition)(object)((item is SeedDefinition) ? item : null); if (val != null) { if (!baseSeedDefinitions.ContainsKey(((BaseItemDefinition)val).ID)) { baseSeedDefinitions.Add(((BaseItemDefinition)val).ID, val); baseShopListing.Add(((BaseItemDefinition)val).ID, item2); } } else { MelonLogger.Warning(item2.name + " could not be cast to SeedDefinition"); } } } public static void CreateDeliveryListing(ShopListing newListing) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) DeliveryShop shop = PlayerSingleton<DeliveryApp>.Instance.GetShop("Albert Hoover"); ListingEntry val = Object.Instantiate<ListingEntry>(shop.ListingEntryPrefab, (Transform)(object)shop.ListingContainer); val.Initialize(newListing); val.onQuantityChanged.AddListener(new UnityAction(shop.RefreshCart)); shop.listingEntries.Add(val); shop.ListingContainer.sizeDelta = new Vector2(shop.ListingContainer.sizeDelta.x, 230f + (float)Math.Ceiling((double)shop.listingEntries.Count / 2.0) * 60f); } public static void CreateShopListing(SeedDefinition newSeed, float price = 10f) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) ShopListing val = Shop.Listings[0]; val.name = "Test"; ShopListing val2 = new ShopListing(); val2.name = $"{((BaseItemDefinition)newSeed).ID} (${price}) (Agriculture, )"; val2.OverridePrice = true; val2.OverriddenPrice = price; val2.Item = (StorableItemDefinition)(object)newSeed; val2.IconTint = new Color(0f, 0.859f, 1f, 1f); val2.MinimumGameCreationVersion = 27f; val2.DefaultStock = 1000; val2.CurrentStock = 100000; val2.CanBeDelivered = true; Shop.Listings.Add(val2); Shop.CreateListingUI(val2); CreateDeliveryListing(val2); Shop.RefreshShownItems(); } public static void EnableSeedIndicator(string weedId) { ProductDefinition item = Registry.GetItem<ProductDefinition>(weedId); if ((Object)(object)item == (Object)null) { Utility.Error("Could not find ProductDefinition for weedId: " + weedId); return; } ProductManagerApp instance = PlayerSingleton<ProductManagerApp>.instance; if ((Object)(object)instance == (Object)null) { Utility.Error("ProductManagerApp instance is null"); return; } bool flag = ProductManager.FavouritedProducts.Contains(item); if (instance.entries != null) { for (int i = 0; i < instance.entries.Count; i++) { ProductEntry val = instance.entries[i]; if ((Object)(object)val != (Object)null && (Object)(object)val.Definition != (Object)null && ((BaseItemDefinition)val.Definition).ID == weedId) { Transform val2 = ((Component)val).transform.Find("SeedIndicator"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(true); } break; } } } if (!flag || instance.favouriteEntries == null) { return; } for (int j = 0; j < instance.favouriteEntries.Count; j++) { ProductEntry val3 = instance.favouriteEntries[j]; if ((Object)(object)val3 != (Object)null && (Object)(object)val3.Definition != (Object)null && ((BaseItemDefinition)val3.Definition).ID == weedId) { Transform val4 = ((Component)val3).transform.Find("SeedIndicator"); if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(true); } break; } } } public static void AddSeedToPots(SeedDefinition newSeed) { Pot[] array = Object.FindObjectsOfType<Pot>(); Pot[] array2 = array; foreach (Pot val in array2) { EntityConfiguration configuration = val.Configuration; ((PotConfiguration)(((configuration is PotConfiguration) ? configuration : null)?)).Seed.Options.Add((ItemDefinition)(object)newSeed); } } public static void SeedFactoryLoader() { SeedDefinition item = Registry.GetItem<SeedDefinition>("ogkushseed"); if ((Object)(object)item != (Object)null) { factory = new SeedFactory(item); } } public static SeedDefinition SeedDefinitionLoader(UnicornSeedData newSeedData) { SeedDefinition val = null; WeedDefinition item = Registry.GetItem<WeedDefinition>(newSeedData.weedId); if ((Object)(object)item != (Object)null) { val = factory.CreateSeedDefinition(item); if ((Object)(object)val == (Object)null) { Utility.Error("New seed not created"); } Singleton<Registry>.Instance.AddToRegistry((ItemDefinition)(object)val); } else { MelonLogger.Error("Could not parse weed and seed defitions"); } return val; } } public static class StashManager { private static Dictionary<string, List<PropertyItemDefinition>> ingredientsCache = new Dictionary<string, List<PropertyItemDefinition>>(); private static Dictionary<string, float> ingredientCostCache = new Dictionary<string, float>(); private static float lastClosedTime = 0f; public static SupplierStash albertsStash; public static MelonPreferences_Category ConfigCategory; public static MelonPreferences_Entry<int> StashCostEntry; public static MelonPreferences_Entry<int> StashQtyEntry; public static MelonPreferences_Entry<int> SynthesizeTime; public static void InitializeConfig() { ConfigCategory = MelonPreferences.CreateCategory("Unicorns Custom Seeds"); StashCostEntry = ConfigCategory.CreateEntry<int>("StashCostRequirement", 500, "Stash Cost Requirement", "The price that Albert charges to synthesize seeds", false, false, (ValueValidator)null, (string)null); StashQtyEntry = ConfigCategory.CreateEntry<int>("StashQtyRequirement", 20, "Stash Quantity Requirement", "The quantity of weed that needs to be provided of a certain mix", false, false, (ValueValidator)null, (string)null); SynthesizeTime = ConfigCategory.CreateEntry<int>("SynthesizeTime", 30, "Synthesize Time", "Time in secondsd that it will take for Albert to synthesize a seed", false, false, (ValueValidator)null, (string)null); } public static void GetAlbertsStash() { SupplierStash[] array = Object.FindObjectsOfType<SupplierStash>(); SupplierStash[] array2 = array; foreach (SupplierStash val in array2) { if ((Object)(object)val != (Object)null && ((Object)((Component)val).gameObject).name.ToLower().Contains("albert")) { Utility.Log("Alberts Ready to Synthesize"); albertsStash = val; StorageEntity storage = val.Storage; storage.onClosed = (Action)Delegate.Combine(storage.onClosed, new Action(AlbertsStashClosed)); break; } } } public static void AlbertsStashClosed() { //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown if (Time.time - lastClosedTime < 1f) { return; } lastClosedTime = Time.time; ItemSlot val = null; CashInstance val2 = null; ItemSlot val3 = null; WeedInstance val4 = null; List<ItemInstance> allItems = albertsStash.Storage.GetAllItems(); Utility.Log("Alberts Stash Looping through items"); foreach (ItemSlot itemSlot in albertsStash.Storage.ItemSlots) { if (((itemSlot != null) ? itemSlot.ItemInstance : null) == null) { continue; } ItemInstance itemInstance = itemSlot.ItemInstance; CashInstance val5 = (CashInstance)(object)((itemInstance is CashInstance) ? itemInstance : null); if (val5 != null) { val = itemSlot; val2 = val5; continue; } ItemInstance itemInstance2 = itemSlot.ItemInstance; WeedInstance val6 = (WeedInstance)(object)((itemInstance2 is WeedInstance) ? itemInstance2 : null); if (val6 != null) { val3 = itemSlot; val4 = val6; } } if (val2 == null || val4 == null) { return; } string packaging = ((BaseItemDefinition)(((ProductItemInstance)val4).AppliedPackaging?)).Name; int quantity = ((BaseItemInstance)val4).Quantity; uint num = PackageAmount(packaging); if (num == 0) { return; } uint num2 = (uint)(quantity * num); if (val2.Balance >= (float)StashCostEntry.Value && num2 >= StashQtyEntry.Value) { WeedDefinition val7 = (WeedDefinition)((ItemInstance)val4).Definition; if ((Object)(object)val7 != (Object)null && !CustomSeedsManager.DiscoveredSeeds.ContainsKey(((BaseItemDefinition)((ItemInstance)val4).Definition).ID) && SeedQuestManager.HasActiveQuest) { val3.ChangeQuantity(-(StashQtyEntry.Value / (int)num), false); val2.ChangeBalance((float)(-StashCostEntry.Value)); SeedQuestManager.CompleteQuest(); SeedQuestManager.SendMessage("I will begin synthesizing the seed"); CustomSeedsManager.StartSeedCreation(val7); } } } private static uint PackageAmount(string packaging) { if (1 == 0) { } uint result = packaging switch { "Brick" => 20u, "Jar" => 5u, "Baggie" => 1u, _ => 1u, }; if (1 == 0) { } return result; } public static WeedDefinition GetBaseStrain(ProductDefinition product) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown List<PropertyItemDefinition> recipe = GetRecipe(product); PropertyItemDefinition val = recipe[0]; WeedDefinition val2 = (WeedDefinition)val; if ((Object)(object)val2 != (Object)null) { return val2; } return null; } public static List<PropertyItemDefinition> GetRecipe(ProductDefinition product) { if (ingredientsCache.ContainsKey(((BaseItemDefinition)product).ID)) { return ingredientsCache[((BaseItemDefinition)product).ID]; } return DeepSearchRecipe(product); } public static float GetIngredientCost(ProductDefinition product) { if (ingredientCostCache.ContainsKey(((BaseItemDefinition)product).ID)) { return ingredientCostCache[((BaseItemDefinition)product).ID]; } List<PropertyItemDefinition> recipe = GetRecipe(product); float num = CalculateTotalCost(recipe); ingredientCostCache.Add(((BaseItemDefinition)product).ID, num); return num; } public static void ProcessNewRecipe(ProductDefinition product) { if (!((Object)(object)product == (Object)null)) { List<PropertyItemDefinition> ingredients = DeepSearchRecipe(product); float num = CalculateTotalCost(ingredients); } } private static float CalculateTotalCost(List<PropertyItemDefinition> ingredients) { float num = 0f; foreach (PropertyItemDefinition ingredient in ingredients) { if (!(ingredient is ProductDefinition)) { num += ((StorableItemDefinition)ingredient).BasePurchasePrice; } } return num; } public static List<PropertyItemDefinition> DeepSearchRecipe(ProductDefinition product) { if (ingredientsCache.ContainsKey(((BaseItemDefinition)product).ID)) { return ingredientsCache[((BaseItemDefinition)product).ID]; } List<PropertyItemDefinition> list = new List<PropertyItemDefinition>(); HashSet<string> visited = new HashSet<string>(); DeepSearchRecursive(product, list, visited); ingredientsCache.Add(((BaseItemDefinition)product).ID, list); return list; } private static void DeepSearchRecursive(ProductDefinition product, List<PropertyItemDefinition> result, HashSet<string> visited) { if ((Object)(object)product == (Object)null || visited.Contains(((BaseItemDefinition)product).ID)) { return; } visited.Add(((BaseItemDefinition)product).ID); if (product.Recipes.Count == 0) { result.Insert(0, (PropertyItemDefinition)(object)product); return; } foreach (IngredientQuantity ingredient in product.Recipes[0].Ingredients) { if (ingredient == null) { continue; } ItemDefinition item = ingredient.Item; ProductDefinition val = (ProductDefinition)(object)((item is ProductDefinition) ? item : null); if (val != null) { DeepSearchRecursive(val, result, visited); continue; } ItemDefinition item2 = ingredient.Item; PropertyItemDefinition val2 = (PropertyItemDefinition)(object)((item2 is PropertyItemDefinition) ? item2 : null); if (val2 != null) { result.Add(val2); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }