using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using COTL_API.CustomEnemy; using COTL_API.CustomFollowerCommand; using COTL_API.CustomInventory; using COTL_API.CustomLocalization; using COTL_API.CustomMission; using COTL_API.CustomObjectives; using COTL_API.CustomRelics; using COTL_API.CustomSettings; using COTL_API.CustomSettings.Elements; using COTL_API.CustomSkins; using COTL_API.CustomStructures; using COTL_API.CustomTarotCard; using COTL_API.CustomTasks; using COTL_API.Debug; using COTL_API.Guid; using COTL_API.Helpers; using COTL_API.Icons; using COTL_API.Prefabs; using COTL_API.Saves; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using FMOD; using FMODUnity; using FoodPlus.CustomTraits; using HarmonyLib; using I2.Loc; using Lamb.UI; using Lamb.UI.Assets; using Lamb.UI.BuildMenu; using Lamb.UI.FollowerInteractionWheel; using Lamb.UI.MainMenu; using Lamb.UI.PauseMenu; using Lamb.UI.RefineryMenu; using Lamb.UI.Rituals; using Lamb.UI.Settings; using Lamb.UI.SettingsMenu; using LeTai.Asset.TranslucentImage; using MMBiomeGeneration; using MMRoomGeneration; using MMTools; using Microsoft.CodeAnalysis; using Microsoft.Win32.SafeHandles; using MonoMod.Utils; using Sirenix.Serialization.Utilities; using Spine; using Spine.Unity; using Spine.Unity.AttachmentTools; using Spine.Unity.Examples; using TMPro; using Unify; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Experimental.Rendering; using UnityEngine.ProBuilder; using UnityEngine.ResourceManagement; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceProviders; using UnityEngine.TextCore; using UnityEngine.UI; using src.Alerts; using src.Extensions; using src.UI.InfoCards; using src.UI.Menus; using src.UINavigator; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("xhayper")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A modding API for Cult of the Lamb")] [assembly: AssemblyFileVersion("0.3.4.0")] [assembly: AssemblyInformationalVersion("0.3.4+88dbb15fd9260388b2fc88b7df28aeb5a8d071b5")] [assembly: AssemblyProduct("COTL_API")] [assembly: AssemblyTitle("COTL_API")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/xhayper/COTL_API")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.4.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] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FoodPlus.CustomTraits { public abstract class CustomTrait { internal string ModPrefix = ""; internal TraitType TraitType; public abstract string InternalName { get; } public virtual TraitFlags TraitFlags => TraitFlags.NONE; public virtual List ExclusiveTraits => new List(); public virtual Sprite Icon => TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual bool Positive => true; public virtual string LocalizedTitle() { return LocalizationManager.GetTranslation("Traits/" + ModPrefix + "." + InternalName, true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string LocalizedDescription() { return LocalizationManager.GetTranslation("Traits/" + InternalName + ".description", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual bool IsTraitUnavailable() { return false; } } [Flags] public enum TraitFlags { NONE = 0, STARTING_TRAIT = 1, FAITHFUL_TRAIT = 2, RARE_STARTING_TRAIT = 4, SINGLE_TRAIT = 8, EXCLUDE_FROM_MATING = 0x10, SIN_TRAIT = 0x20, PURE_BLOOD_TRAIT = 0x40, REQUIRES_ONBOARDING_COMPLETE = 0x80 } [HarmonyPatch] public static class CustomTraitManager { private static Dictionary CustomTraitList { get; } = new Dictionary(); public static TraitType Add(CustomTrait trait) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0073: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); TraitType val = (trait.TraitType = GuidManager.GetEnumValue(modIdFromCallstack, trait.InternalName)); trait.ModPrefix = modIdFromCallstack; HandleTraitFlags(trait); foreach (TraitType exclusiveTrait in trait.ExclusiveTraits) { FollowerTrait.ExclusiveTraits.Add(val, exclusiveTrait); } CustomTraitList.Add(val, trait); return val; } private static void HandleTraitFlags(CustomTrait item) { CustomTrait item2 = item; foreach (KeyValuePair item3 in new Dictionary { { TraitFlags.STARTING_TRAIT, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.StartingTraits.Add(item2.TraitType); } }, { TraitFlags.FAITHFUL_TRAIT, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.FaithfulTraits.Add(item2.TraitType); } }, { TraitFlags.RARE_STARTING_TRAIT, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.RareStartingTraits.Add(item2.TraitType); } }, { TraitFlags.SINGLE_TRAIT, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.SingleTraits.Add(item2.TraitType); } }, { TraitFlags.SIN_TRAIT, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.SinTraits.Add(item2.TraitType); } }, { TraitFlags.EXCLUDE_FROM_MATING, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.ExcludedFromMating.Add(item2.TraitType); } }, { TraitFlags.PURE_BLOOD_TRAIT, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.PureBloodTraits.Add(item2.TraitType); } }, { TraitFlags.REQUIRES_ONBOARDING_COMPLETE, delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) FollowerTrait.RequiresOnboardingCompleted.Add(item2.TraitType); } } }) { if (item2.TraitFlags.HasFlag(item3.Key)) { item3.Value(); } } } [HarmonyPatch(typeof(FollowerTrait), "GetIcon")] [HarmonyPostfix] private static void FollowerTrait_GetIcon(TraitType Type, ref Sprite __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomTraitList.TryGetValue(Type, out CustomTrait value)) { __result = value.Icon; } } [HarmonyPatch(typeof(FollowerTrait), "IsPositiveTrait")] [HarmonyPostfix] private static void FollowerTrait_IsPositiveTrait(TraitType traitType, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomTraitList.TryGetValue(traitType, out CustomTrait value)) { __result = value.Positive; } } [HarmonyPatch(typeof(FollowerTrait), "GetLocalizedTitle")] [HarmonyPostfix] private static void FollowerTrait_GetLocalizedTitle(TraitType Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomTraitList.TryGetValue(Type, out CustomTrait value)) { __result = value.LocalizedTitle(); } } [HarmonyPatch(typeof(FollowerTrait), "GetLocalizedDescription")] [HarmonyPostfix] private static void FollowerTrait_GetLocalizedDescription(TraitType Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomTraitList.TryGetValue(Type, out CustomTrait value)) { __result = value.LocalizedDescription(); } } [HarmonyPatch(typeof(FollowerTrait), "IsTraitUnavailable")] [HarmonyPostfix] private static void FollowerTrait_IsTraitUnavailable(TraitType trait, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomTraitList.TryGetValue(trait, out CustomTrait value)) { __result = value.IsTraitUnavailable(); } } } } namespace COTL_API { public static class CustomType { public static Type? GetType(string nameSpace, string typeName) { string text = nameSpace + "." + typeName; Type type = Type.GetType(text); if (type != null) { return type; } if (text.Contains(".")) { Assembly assembly = Assembly.Load(text.Substring(0, text.IndexOf('.'))); if (assembly == null) { return null; } type = assembly.GetType(text); if (type != null) { return type; } } AssemblyName[] referencedAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies(); for (int i = 0; i < referencedAssemblies.Length; i++) { Assembly assembly2 = Assembly.Load(referencedAssemblies[i]); if (!(assembly2 == null)) { type = assembly2.GetType(text); if (type != null) { return type; } } } return null; } } [BepInPlugin("io.github.xhayper.COTL_API", "COTL_API", "0.3.4")] [HarmonyPatch] public class Plugin : BaseUnityPlugin { internal static Dropdown? LambFleeceSkinSettings; internal static Dropdown? GoatFleeceSkinSettings; internal static Dropdown? LambFleeceBleatSettings; internal static Dropdown? GoatFleeceBleatSettings; internal static Dropdown? CustomPlayerSpineSettings; internal static Dropdown? CustomPlayer2SpineSettings; internal readonly Harmony _harmony = new Harmony("io.github.xhayper.COTL_API"); internal readonly ModdedSaveData APIData = new ModdedSaveData("io.github.xhayper.COTL_API") { LoadOrder = ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE }; internal readonly ModdedSaveData APISlotData = new ModdedSaveData("io.github.xhayper.COTL_API_slot"); public readonly ModdedSaveData ModdedSettingsData = new ModdedSaveData("modded_settings") { LoadOrder = ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE }; internal static ConfigEntry UnityDebug { get; private set; } = null; internal static Plugin? Instance { get; private set; } internal ManualLogSource Logger { get; private set; } = new ManualLogSource("COTL_API"); internal string PluginPath { get; private set; } = ""; private ConfigEntry? _debug { get; set; } public bool Debug => _debug?.Value ?? false; private ConfigEntry? _skipSplashScreen { get; set; } public bool SkipSplashScreen => _skipSplashScreen?.Value ?? false; private ConfigEntry? _disableAchievement { get; set; } public bool DisableAchievement => _disableAchievement?.Value ?? true; internal static bool Started { get; private set; } internal static ObjectDictionary? SettingsData => Instance?.ModdedSettingsData.Data; internal static Dictionary? QuestData { get { if (!((Object)(object)Instance != (Object)null)) { return null; } return Instance.APISlotData.Data?.QuestData; } } internal static ObjectDictionary? EnumData => Instance?.APIData.Data?.EnumData; internal static event Action OnStart; private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty; ModdedSaveManager.RegisterModdedSave(ModdedSettingsData); ModdedSaveManager.RegisterModdedSave(APIData); ModdedSaveManager.RegisterModdedSave(APISlotData); RunSavePatch(); _skipSplashScreen = ((BaseUnityPlugin)this).Config.Bind("Miscellaneous", "Skip splash screen", false, "Should we skip the splash screen or not?"); _disableAchievement = ((BaseUnityPlugin)this).Config.Bind("Miscellaneous", "Disable new achievement", true, "Should we disable saving new achievements? (You will still be able to get achievement but it won't save)"); _debug = ((BaseUnityPlugin)this).Config.Bind("Debug", "API debug", false, "API debug mode. Will add debug content to your game for testing. Not recommended for normal play."); UnityDebug = ((BaseUnityPlugin)this).Config.Bind("Debug", "Unity debug logging", false, "Unity debug logging. Helpful to filter out unrelated entries during testing."); UnityDebug.SettingChanged += delegate { Debug.unityLogger.logEnabled = UnityDebug.Value; }; CustomSkinManager.AddPlayerSkin(new OverridingPlayerSkin("Lamb", () => ((SkeletonRenderer)PlayerFarming.Instance.Spine).Skeleton.Data.FindSkin("Lamb"))); CustomSkinManager.AddPlayerSkin(new OverridingPlayerSkin("Goat", () => ((SkeletonRenderer)PlayerFarming.Instance.Spine).Skeleton.Data.FindSkin("Goat"))); CustomSkinManager.AddPlayerSkin(new OverridingPlayerSkin("Owl", () => ((SkeletonRenderer)PlayerFarming.Instance.Spine).Skeleton.Data.FindSkin("Owl"))); CustomSkinManager.AddPlayerSkin(new OverridingPlayerSkin("Snake", () => ((SkeletonRenderer)PlayerFarming.Instance.Spine).Skeleton.Data.FindSkin("Snake"))); CustomSkinManager.AddPlayerSpine("Placeholder", null, new List(1) { "Placeholder selection" }); LambFleeceSkinSettings = CustomSettingsManager.AddSavedDropdown("API", "io.github.xhayper.COTL_API", "Lamb fleece skin", "Lamb", CustomSkinManager.CustomPlayerSkins.Keys.ToArray(), delegate(int i) { if (0 >= i) { CustomSkinManager.ResetPlayerSkin(PlayerType.LAMB); } else { CustomSkinManager.SetPlayerSkinOverride(PlayerType.LAMB, CustomSkinManager.CustomPlayerSkins.Values.ElementAt(i)); } }); GoatFleeceSkinSettings = CustomSettingsManager.AddSavedDropdown("API", "io.github.xhayper.COTL_API", "Goat fleece skin", "Goat", CustomSkinManager.CustomPlayerSkins.Keys.ToArray(), delegate(int i) { if ((i < 0 || i == 1) ? true : false) { CustomSkinManager.ResetPlayerSkin(PlayerType.GOAT); } else { CustomSkinManager.SetPlayerSkinOverride(PlayerType.GOAT, CustomSkinManager.CustomPlayerSkins.Values.ElementAt(i)); } }); LambFleeceBleatSettings = CustomSettingsManager.AddSavedDropdown("API", "io.github.xhayper.COTL_API", "Lamb fleece bleat", "Lamb", Enum.GetNames(typeof(PlayerBleat)), delegate(int i) { CustomSkinManager.SetPlayerBleatOverride(PlayerType.LAMB, (PlayerBleat)i); }); GoatFleeceBleatSettings = CustomSettingsManager.AddSavedDropdown("API", "io.github.xhayper.COTL_API", "Goat fleece bleat", "Goat", Enum.GetNames(typeof(PlayerBleat)), delegate(int i) { CustomSkinManager.SetPlayerBleatOverride(PlayerType.GOAT, (PlayerBleat)i); }); CustomPlayerSpineSettings = CustomSettingsManager.AddSavedDropdown("API", "io.github.xhayper.COTL_API", "Custom player spine", "Lamb Spine", CustomSkinManager.CustomPlayerSpines.Keys.ToArray(), delegate(int i) { CustomSkinManager.ChangeSelectedPlayerSpine(CustomSkinManager.CustomPlayerSpines.Keys.ElementAt(i)); }); CustomPlayer2SpineSettings = CustomSettingsManager.AddSavedDropdown("API", "io.github.xhayper.COTL_API", "Custom player 2 spine", "Lamb Spine", CustomSkinManager.CustomPlayerSpines.Keys.ToArray(), delegate(int i) { CustomSkinManager.ChangeSelectedPlayerSpine(CustomSkinManager.CustomPlayerSpines.Keys.ElementAt(i), 1); }); CustomSettingsManager.AddBepInExConfig("API", "Skip splash screen", _skipSplashScreen); CustomSettingsManager.AddBepInExConfig("API", "Disable new achievement", _disableAchievement, delegate(bool isActivated) { if (!isActivated) { AchievementsWrapper.LoadAchievementData(); AchievementsWrapper.compareAchievements(); } }); CustomSettingsManager.AddBepInExConfig("API", "Debug", _debug, delegate(bool isActivated) { if (!isActivated) { string text = LambFleeceSkinSettings?.Value; if ((text == "Debug" || text == "Debug_1") ? true : false) { LambFleeceSkinSettings.Value = "Lamb"; CustomSkinManager.ResetPlayerSkin(PlayerType.LAMB); } text = GoatFleeceSkinSettings?.Value; if ((text == "Debug" || text == "Debug_1") ? true : false) { GoatFleeceSkinSettings.Value = "Goat"; CustomSkinManager.ResetPlayerSkin(PlayerType.GOAT); } } else { DebugManager.AddDebugContent(); } }); CustomSettingsManager.AddBepInExConfig("API", "Unity debug logging", UnityDebug); if (Debug) { DebugManager.AddDebugContent(); } LogHelper.LogInfo("COTL_API loaded!"); } private void Start() { Plugin.OnStart(); Started = true; } public void Update() { //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) if (!Debug) { return; } if (Input.GetKeyDown((KeyCode)282)) { List list = new List(Health.team2); GameObject entityObject = GameObject.FindWithTag("Player"); CollectionExtensions.DoIf((IEnumerable)list, (Func)((Health x) => Object.op_Implicit((Object)(object)x)), (Action)delegate(Health x) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) x.DealDamage(999999f, (GameObject)null, entityObject.transform.position, false, (AttackTypes)0, false, (AttackFlags)0); }); } if (Input.GetKeyDown((KeyCode)283)) { IEnumerable values = from x in ((SkeletonRenderer)PlayerFarming.Instance.Spine).Skeleton.Skin.Attachments.OrderBy((SkinEntry x) => ((SkinEntry)(ref x)).SlotIndex).ToList() select $"{{ \"{((SkinEntry)(ref x)).Name}\", Tuple.Create({((SkinEntry)(ref x)).SlotIndex}, \"{((SkinEntry)(ref x)).Name}\") }}"; LogHelper.LogDebug(string.Join(",\n", values)); } if (Input.GetKeyDown((KeyCode)284)) { foreach (SkinEntry attachment in ((SkeletonRenderer)PlayerFarming.Instance.Spine).Skeleton.Skin.Attachments) { SkinEntry current = attachment; LogHelper.LogDebug($"{{ \"{((SkinEntry)(ref current)).Name}\", Tuple.Create({((SkinEntry)(ref current)).SlotIndex}, \"{((SkinEntry)(ref current)).Name}\") }}"); } } if (Input.GetKeyDown((KeyCode)291)) { DebugEnemy debugEnemy = new DebugEnemy(); CustomEnemyManager.Add(debugEnemy); ((MonoBehaviour)this).StartCoroutine(CustomEnemyManager.BuildEnemyPrefab(debugEnemy)); LogHelper.LogInfo("Generated Enemy Prefab: " + debugEnemy.EnemyToMimic); } if (Input.GetKeyDown((KeyCode)292) && CustomEnemyManager.CustomEnemyList.Count >= 0) { CustomEnemyManager.Spawn(CustomEnemyManager.CustomEnemyList.Keys.ElementAt(0), ((Component)PlayerFarming.Instance).transform.position); LogHelper.LogInfo($"Spawned debug enemy: {CustomEnemyManager.CustomEnemyList.Keys.ElementAt(0)}"); } } private void OnEnable() { _harmony.PatchAll(Assembly.GetExecutingAssembly()); LogHelper.LogInfo($"{_harmony.GetPatchedMethods().Count()} harmony patches applied!"); } private void OnDisable() { _harmony.UnpatchSelf(); LogHelper.LogInfo("COTL_API unloaded!"); } private void RunSavePatch() { SaveAndLoad.OnLoadComplete = (Action)Delegate.Combine(SaveAndLoad.OnLoadComplete, (Action)delegate { LogHelper.LogDebug("Loading Modded Save Data with LoadOrder=ModdedSaveLoadOrder.LOAD_AFTER_SAVE_START."); foreach (BaseModdedSaveData item in ModdedSaveManager.ModdedSaveDataList.Values.Where((BaseModdedSaveData save) => save.LoadOrder == ModdedSaveLoadOrder.LOAD_AFTER_SAVE_START)) { item.Load(SaveAndLoad.SAVE_SLOT); } LogHelper.LogDebug("Re-adding any custom quests from the players existing objectives."); Dictionary dictionary = new Dictionary(); if (QuestData == null) { return; } foreach (KeyValuePair objective in QuestData) { if (DataManager.instance.Objectives.Exists((ObjectivesData a) => a.ID == objective.Key)) { dictionary.Add(objective.Key, objective.Value); } else if (Quests.QuestsAll.Exists((ObjectivesData a) => a.ID == objective.Key)) { dictionary.Add(objective.Key, objective.Value); } } Extensions.AddRange(CustomObjectiveManager.CustomObjectiveList, dictionary); LogHelper.LogDebug("Added custom quests to Plugin.Instance.APIQuestData.Data.QuestData."); foreach (KeyValuePair customObjective in CustomObjectiveManager.CustomObjectiveList) { Extensions.TryAdd(QuestData, customObjective.Key, customObjective.Value); } }); COTLDataReadWriter readWriter = Singleton.Instance._readWriter; ((MMDataReadWriterBase)(object)readWriter).OnReadCompleted = (Action)Delegate.Combine(((MMDataReadWriterBase)(object)readWriter).OnReadCompleted, (Action)delegate { if (!LocalizationManager.HasLanguage(SettingsManager.Settings.Game.Language, true, true, true)) { SettingsManager.Settings.Game.Language = "English"; LocalizationManager.CurrentLanguage = "English"; if (TwitchAuthentication.IsAuthenticated) { TwitchManager.SetLanguage(LocalizationManager.CurrentLanguageCode); } LocalizationManager.LocalizeAll(true); } }); SaveAndLoad.OnLoadComplete = (Action)Delegate.Combine(SaveAndLoad.OnLoadComplete, (Action)delegate { if (DataManager.Instance == null) { return; } foreach (QuestHistoryData item2 in DataManager.Instance.CompletedQuestsHistorys.Where((QuestHistoryData a) => a.QuestIndex >= Quests.QuestsAll.Count)) { if (Debug) { LogHelper.LogDebug("Found quests in history with an index higher than total quests (user may have removed mods that add quests), resetting to maximum possible."); } item2.QuestIndex = Quests.QuestsAll.Count - 1; } }); } static Plugin() { Plugin.OnStart = delegate { CustomItemManager.InitiateCustomCrops(); }; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "io.github.xhayper.COTL_API"; public const string PLUGIN_NAME = "COTL_API"; public const string PLUGIN_VERSION = "0.3.4"; } } namespace COTL_API.Utility { public class CinematicCameraManager { [CompilerGenerated] private sealed class d__8 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private List.Enumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = default(List.Enumerator); <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = ActiveFocusPoints.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } if (<>7__wrap1.MoveNext()) { IEnumerator current = <>7__wrap1.Current; <>2__current = current; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = default(List.Enumerator); ResetAllFocusPoints(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__6 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Vector3 position; public Quaternion rotation; public float zoom; public float duration; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0089: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: { <>1__state = -1; SetFollowTarget(CreateFocusPoint(position, rotation)); DOTween.Kill((object)"CinematicFocusPoint", false); CameraFollowTarget instance = CameraFollowTarget.Instance; if (instance != null) { TweenSettingsExtensions.SetId>(ShortcutExtensions.DORotate(((Component)instance).transform, ((Quaternion)(ref rotation)).eulerAngles, 1f, (RotateMode)0), "CinematicFocusPoint"); } Zoom(zoom); <>2__current = (object)new WaitForSeconds(duration); <>1__state = 1; return true; } case 1: <>1__state = -1; 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 List ActiveFocusPoints = new List(); public static Quaternion defaultCameraRotation = Quaternion.Euler(315f, 0f, 0f); public static void Zoom(float targetZoom) { GameManager.GetInstance().CameraSetTargetZoom(targetZoom); } public static void ZoomReset() { GameManager.GetInstance().CameraResetTargetZoom(); } public static GameObject CreateAndActivateFocusPoint(Vector3 position, Quaternion rotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateFocusPoint(position, rotation); SetFollowTarget(obj); DOTween.Kill((object)"CinematicFocusPoint", false); CameraFollowTarget instance = CameraFollowTarget.Instance; if (instance != null) { TweenSettingsExtensions.SetId>(ShortcutExtensions.DORotate(((Component)instance).transform, ((Quaternion)(ref rotation)).eulerAngles, 1f, (RotateMode)0), "CinematicFocusPoint"); return obj; } return obj; } public static void CreateAndPrepareTimedFocusPoint(Vector3 position, Quaternion rotation, float duration) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ActiveFocusPoints.Add(CreateTimedFocusPoint(position, rotation, duration)); } [IteratorStateMachine(typeof(d__6))] private static IEnumerator CreateTimedFocusPoint(Vector3 position, Quaternion rotation, float duration, float zoom = 1f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { position = position, rotation = rotation, duration = duration, zoom = zoom }; } private static GameObject CreateFocusPoint(Vector3 position, Quaternion rotation) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown GameObject val = new GameObject("CinematicCameraFocusPoint"); val.transform.position = position; val.transform.rotation = rotation; return val; } [IteratorStateMachine(typeof(d__8))] public static IEnumerator ActivateAllCreatedFocusPoints() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0); } public static void ResetAllFocusPoints(float speed = 1f) { GameManager.GetInstance().CamFollowTarget.ResetTargetCamera(speed); ActiveFocusPoints.Clear(); } public static void SetFollowTarget(GameObject target) { ResetAllFocusPoints(); ResetCameraTargets(); CameraFollowTarget instance = CameraFollowTarget.Instance; if (instance != null) { instance.ClearAllTargets(); } CameraFollowTarget instance2 = CameraFollowTarget.Instance; if (instance2 != null) { instance2.CleanTargets(); } CameraFollowTarget instance3 = CameraFollowTarget.Instance; if (instance3 != null) { instance3.AddTarget(target, 1f); } } public static void AddFollowTarget(GameObject target, float weight = 1f) { CameraFollowTarget instance = CameraFollowTarget.Instance; if (instance != null) { instance.AddTarget(target, weight); } } public static void RemoveFollowTarget(GameObject target) { CameraFollowTarget instance = CameraFollowTarget.Instance; if (instance != null) { instance.RemoveTarget(target); } } public static void ResetCameraTargets() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) CameraFollowTarget instance = CameraFollowTarget.Instance; if (instance != null) { instance.ClearAllTargets(); } CameraFollowTarget instance2 = CameraFollowTarget.Instance; if (instance2 != null) { ShortcutExtensions.DORotate(((Component)instance2).transform, ((Quaternion)(ref defaultCameraRotation)).eulerAngles, 1f, (RotateMode)0); } GameManager instance3 = GameManager.instance; if (instance3 != null) { instance3.AddPlayersToCamera(); } } public static void SetCameraLimits(bool enabled, Bounds limits) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!enabled) { CameraFollowTarget instance = CameraFollowTarget.Instance; if (instance != null) { instance.DisableCameraLimits(); } } else { CameraFollowTarget instance2 = CameraFollowTarget.Instance; if (instance2 != null) { instance2.SetCameraLimits(limits); } } } public static void ShowLetterbox(bool show, bool showHudAfterHide = true, string subtitle = "") { if (show) { LetterBox.Show(false); if (subtitle != "") { LetterBox instance = LetterBox.Instance; if (instance != null) { instance.ShowSubtitle(subtitle); } } } else { LetterBox.Hide(showHudAfterHide); } } public static void ShowHUD(bool show, int delay = 1) { if (show) { HUD_Manager instance = HUD_Manager.Instance; if (instance != null) { instance.Show(delay, false); } } else { HUD_Manager instance2 = HUD_Manager.Instance; if (instance2 != null) { instance2.Hide(false, 1, false); } } } } } namespace COTL_API.Sounds { internal class ChannelWrapper { private readonly SoundWrapper soundWrapper; private Channel channel; public float VolumeMultiplier = 1f; public string ID { get; } public ChannelWrapper(string id, in SoundWrapper sound, bool loop = false) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) channel = default(Channel); ID = id; soundWrapper = sound; } public RESULT Play() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) System coreSystem = RuntimeManager.CoreSystem; RESULT val = ((System)(ref coreSystem)).playSound(soundWrapper.GetSound(), default(ChannelGroup), false, ref channel); if ((int)val == 0) { return val; } val.IfErrorPrintWith("Play -- SoundHandler instance id: " + ID); return val; } public void SetVolume(float a) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) ((Channel)(ref channel)).setVolume(a * VolumeMultiplier).IfErrorPrintWith("SetVolume -- SoundHandler instance id: " + ID); } public void SetMultiplier(float a) { VolumeMultiplier = a; } public void Stop() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Channel)(ref channel)).stop().IfErrorPrintWith("Stop -- SoundHandler instance id: " + ID); } public bool IsPlaying() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) bool result = default(bool); ((Channel)(ref channel)).isPlaying(ref result).IfErrorPrintWith("isPlaying -- SoundHandler instance id: " + ID); return result; } public bool IsPaused() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!IsPlaying()) { return false; } bool result = default(bool); ((Channel)(ref channel)).getPaused(ref result).IfErrorPrintWith("isPaused -- SoundHandler instance id: " + ID); return result; } public void Pause(bool pause) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (IsPlaying()) { ((Channel)(ref channel)).setPaused(pause).IfErrorPrintWith("Pause -- SoundHandler instance id: " + ID); } } public void SetReverb(bool active, float a) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(a, 0f, 1f) * (float)Convert.ToInt32(active); ((Channel)(ref channel)).setReverbProperties(0, num).IfErrorPrintWith("SetReverb -- SoundHandler instance id: " + ID); } public void SetLowPass(float a) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) a = Mathf.Clamp(a, 0f, 1f); ((Channel)(ref channel)).setLowPassGain(a).IfErrorPrintWith("SetLowPass -- SoundHandler instance id: " + ID); } } public class SoundLoader : MonoBehaviour { internal static readonly List InstanceList = new List(); private readonly List _channelList = new List(); private readonly Dictionary _soundCache = new Dictionary(); private void OnDestroy() { InstanceList.Remove(this); StopAll(); } public string CreateSound(string fileName, string? name = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SoundWrapper value = new SoundWrapper(SoundUtils.MakeSound(fileName)); if (name == null) { name = fileName; } _soundCache.Add(name, value); return name; } public void PlaySfx(string name) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!_soundCache.ContainsKey(name)) { LogHelper.LogError("Error playing sound " + name + ": Sound doesn't exist!"); } SoundUtils.PlayOneShot(_soundCache[name]); } public void PlayMusic(string name) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!_soundCache.ContainsKey(name)) { LogHelper.LogError("Error playing sound " + name + ": Sound doesn't exist!"); } SoundWrapper sound = _soundCache[name]; sound.ChangeLoopMode((MODE)2); ChannelWrapper channelWrapper = new ChannelWrapper(name, in sound); RESULT val = channelWrapper.Play(); channelWrapper.SetVolume(SoundUtils.MusicVolume); if ((int)val == 0) { _channelList.Add(channelWrapper); } } public void CreateAndPlayMusic(string fileName, string? name = null) { string name2 = CreateSound(fileName, name); PlayMusic(name2); } public void CreateAndPlaySfx(string fileName, string? name = null) { string name2 = CreateSound(fileName, name); PlaySfx(name2); } public void StopAll() { _channelList.ForEach(delegate(ChannelWrapper x) { x.Stop(); }); _channelList.Clear(); } internal void SyncAllVolume() { _channelList.ForEach(delegate(ChannelWrapper x) { x.SetVolume(SoundUtils.MusicVolume); }); } public void ClearSounds() { _soundCache.Clear(); } private ChannelWrapper? GetHandlerByID(string id) { string id2 = id; return _channelList.FirstOrDefault((ChannelWrapper x) => x.ID == id2); } internal void SyncVolume(string id) { GetHandlerByID(id)?.SetVolume(SoundUtils.MusicVolume); } public void VolumeMultiplier(string id, float mul) { ChannelWrapper? handlerByID = GetHandlerByID(id); handlerByID?.SetMultiplier(mul); handlerByID?.SetVolume(SoundUtils.MusicVolume); } public void Stop(string name) { ChannelWrapper handlerByID = GetHandlerByID(name); handlerByID?.Stop(); if (handlerByID != null) { _channelList.Remove(handlerByID); } } public void Pause(string name, bool pause) { GetHandlerByID(name)?.Pause(pause); } public bool IsPlaying(string name) { return GetHandlerByID(name)?.IsPlaying() ?? false; } public bool IsPaused(string name) { return GetHandlerByID(name)?.IsPaused() ?? false; } } public static class SoundLoaderExtensions { public static SoundLoader AddSoundLoader(this GameObject obj) { SoundLoader soundLoader = obj.AddComponent(); SoundLoader.InstanceList.Add(soundLoader); return soundLoader; } } public enum VolumeCategory { MASTER, MUSIC, SFX, VO } public static class SoundUtils { public static float MasterVolume => SettingsManager.Settings.Audio.MasterVolume; public static float MusicVolume => SettingsManager.Settings.Audio.MusicVolume * MasterVolume; public static float SfxVolume => SettingsManager.Settings.Audio.SFXVolume * MasterVolume; public static float VoVolume => SettingsManager.Settings.Audio.VOVolume * MasterVolume; internal static RESULT SyncVolume(this Channel channel, VolumeCategory volumeCategory = VolumeCategory.MASTER) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return ((Channel)(ref channel)).setVolume(GetVolume(volumeCategory)); } internal static float GetVolume(VolumeCategory x) { return x switch { VolumeCategory.MUSIC => MusicVolume, VolumeCategory.SFX => SfxVolume, VolumeCategory.VO => VoVolume, _ => MasterVolume, }; } internal static void IfErrorPrintWith(this RESULT result, string where) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if ((int)result != 0) { LogHelper.LogError($"Sound Error: {result} caught at {where}"); } } internal static string? GetPath(string fileName) { string obj = (Path.IsPathRooted(fileName) ? fileName : Directory.GetFiles(Paths.PluginPath, fileName, SearchOption.AllDirectories).FirstOrDefault()); if (obj == null) { LogHelper.LogError("Error: Couldn't find \"" + fileName + "\""); } return obj; } internal static Sound MakeSound(string fileName, bool loop = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) string path = GetPath(fileName); if (path == null) { return default(Sound); } System coreSystem = RuntimeManager.CoreSystem; MODE val = (MODE)((!loop) ? 1 : 2); Sound result = default(Sound); RESULT val2 = ((System)(ref coreSystem)).createSound(path, val, ref result); if ((int)val2 == 0) { return result; } LogHelper.LogError("Error making sound from file " + fileName + "!"); val2.IfErrorPrintWith("MakeSound() -- fileName: " + fileName); return default(Sound); } internal static RESULT PlayOneShot(SoundWrapper soundHandle, VolumeCategory volume = VolumeCategory.SFX) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) System coreSystem = RuntimeManager.CoreSystem; soundHandle.ChangeLoopMode((MODE)1); Channel channel = default(Channel); RESULT result = ((System)(ref coreSystem)).playSound(soundHandle.GetSound(), default(ChannelGroup), false, ref channel); channel.SyncVolume(volume); return result; } internal static RESULT PlayOneShot(string path, VolumeCategory volume = VolumeCategory.SFX) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return PlayOneShot(new SoundWrapper(MakeSound(path)), volume); } } internal class SoundWrapper : SafeHandleZeroOrMinusOneIsInvalid { private readonly Sound? sound; public SoundWrapper(Sound sound) : base(ownsHandle: true) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) SetHandle(sound.handle); this.sound = sound; } public Sound GetSound() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return sound.GetValueOrDefault(); } public void ChangeLoopMode(MODE mode) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0019: Unknown result type (might be due to invalid IL or missing references) ref readonly Sound? reference = ref sound; if (reference.HasValue) { Sound valueOrDefault = reference.GetValueOrDefault(); ((Sound)(ref valueOrDefault)).setMode(mode); } } [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] protected override bool ReleaseHandle() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) ref readonly Sound? reference = ref sound; if (reference.HasValue) { Sound valueOrDefault = reference.GetValueOrDefault(); ((Sound)(ref valueOrDefault)).release(); } return true; } } } namespace COTL_API.Sounds.Patches { [HarmonyPatch] public static class SoundSyncPatches { [HarmonyPatch(typeof(AudioSettings), "OnMasterVolumeChanged")] [HarmonyPostfix] private static void SyncMaster() { SoundLoader.InstanceList.ForEach(delegate(SoundLoader x) { x.SyncAllVolume(); }); } [HarmonyPatch(typeof(AudioSettings), "OnMusicVolumeChanged")] [HarmonyPostfix] private static void SyncMusic() { SoundLoader.InstanceList.ForEach(delegate(SoundLoader x) { x.SyncAllVolume(); }); } } } namespace COTL_API.Prefabs { [HarmonyPatch] public static class CustomPrefabManager { private static string? _pathOverride; internal static Dictionary PrefabStrings { get; } = new Dictionary(); public static string GetOrCreateBuildingPrefab(CustomStructure structure) { string text = "CustomBuildingPrefab_" + structure.InternalName; string key = "Assets/" + text + ".prefab"; if (PrefabStrings.ContainsValue(structure)) { return text; } PrefabStrings.Add(text, structure); PrefabStrings.Add(key, structure); return text; } private static void CreateBuildingPrefabOverride(string name, ref AsyncOperationHandle handle) { string name2 = name; if (!PrefabStrings.ContainsKey(name2)) { CustomStructure structureByPrefabName = CustomStructureManager.GetStructureByPrefabName(name2); if (structureByPrefabName == null) { LogHelper.LogWarning("Structure " + name2 + " not found in CustomStructureManager"); return; } GetOrCreateBuildingPrefab(structureByPrefabName); } Sprite sprite = PrefabStrings[name2].Sprite; handle.Completed += delegate(AsyncOperationHandle obj) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_00a8: Unknown result type (might be due to invalid IL or missing references) SpriteRenderer componentInChildren = obj.Result.GetComponentInChildren(); obj.Result.GetComponentInChildren().Type = PrefabStrings[name2].StructureType; if (PrefabStrings[name2].BuildingParts.Count > 0) { LogHelper.LogInfo("Overriding building parts for " + name2); CustomStructureManager.OverrideStructureBuilding(obj.Result, PrefabStrings[name2].BuildingParts); } else { Sprite sprite2 = Sprite.Create(sprite.texture, sprite.rect, new Vector2(0.5f, 0f)); componentInChildren.sprite = sprite2; } ((Object)obj.Result).name = name2 + " (Custom Structure)"; }; } [HarmonyWrapSafe] [HarmonyPatch(typeof(AddressablesImpl), "InstantiateAsync", new Type[] { typeof(object), typeof(InstantiationParameters), typeof(bool) })] [HarmonyPrefix] private static void Addressables_InstantiateAsync(ref object key) { if (key is string text && text.Contains("CustomBuildingPrefab_")) { if (!CustomStructureManager.CustomStructureExists(text)) { LogHelper.LogWarning("Structure attempting to be loaded no longer exists. Path: " + text); _pathOverride = null; key = "Assets/Prefabs/Structures/Other/Rubble.prefab"; } else { _pathOverride = text; key = "Assets/Prefabs/Structures/Buildings/Decoration Wreath Stick.prefab"; } } } [HarmonyWrapSafe] [HarmonyPatch(typeof(ResourceManager), "ProvideInstance")] [HarmonyPostfix] private static void ResourceManager_ProvideInstance(ref AsyncOperationHandle __result) { if (_pathOverride != null) { CreateBuildingPrefabOverride(_pathOverride, ref __result); _pathOverride = null; } } public static GameObject CreatePlacementObjectFor(CustomStructure structure) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) GameObject placementObject = TypeAndPlacementObjects.GetByType((TYPES)2).PlacementObject; PlacementObject component = placementObject.GetComponent(); component.ToBuildAsset = structure.PrefabPath; component.StructureType = structure.StructureType; component.Bounds = structure.Bounds; return placementObject; } } } namespace COTL_API.Patches { [HarmonyPatch] public static class AchievementsWrapperPatches { [HarmonyPatch(typeof(AchievementsWrapper), "UnlockAchievement")] [HarmonyPrefix] private static bool AchievementsWrapper_UnlockAchievement(ref Achievement achievementId) { //IL_0056: 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) if ((Object)(object)Plugin.Instance == (Object)null || !Plugin.Instance.DisableAchievement) { return true; } if (AchievementsWrapper.unlockedAchievements.Contains(achievementId.id)) { return false; } AchievementsWrapper.unlockedAchievements.Add(achievementId.id); AchievementsWrapper.OnAchievementUnlocked?.Invoke(achievementId.label); if (achievementId == Achievements.Instance.Lookup("platinum")) { return false; } AchievementsWrapper.compareAchievements(); return false; } [HarmonyPatch(typeof(AchievementsWrapper), "GetAchievementProgress")] [HarmonyPrefix] private static bool AchievementsWrapper_GetAchievementProgress(ref List result) { //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_0064: 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) if ((Object)(object)Plugin.Instance == (Object)null || !Plugin.Instance.DisableAchievement) { return true; } if (result == null || result.Count == 0) { return false; } foreach (AchievementProgress item in result.Where((AchievementProgress achievementProgress) => achievementProgress.progress >= 100 && !AchievementsWrapper.unlockedAchievements.Contains(achievementProgress.id))) { AchievementsWrapper.unlockedAchievements.Add(item.id); AchievementsWrapper.OnAchievementUnlocked?.Invoke(item.name); } return false; } [HarmonyPatch(typeof(AchievementsWrapper), "UnlockPlatinum")] [HarmonyPrefix] private static bool AchievementsWrapper_UnlockPlatinum() { if (!((Object)(object)Plugin.Instance == (Object)null)) { return !Plugin.Instance.DisableAchievement; } return true; } } [HarmonyPatch] public static class IconPatcher { [HarmonyPatch(typeof(TMP_SpriteAsset), "SearchForSpriteByHashCode")] [HarmonyPrefix] private static bool TMP_SpriteAsset_SearchForSpriteByHashCode(TMP_SpriteAsset spriteAsset, int hashCode, bool includeFallbacks, ref int spriteIndex, ref TMP_SpriteAsset __result) { //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_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) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)spriteAsset == (Object)null) { return true; } Rect rect; GlyphMetrics iconMetrics = default(GlyphMetrics); foreach (CustomInventoryItem value in CustomItemManager.CustomItemList.Values) { string text = "icon_ITEM_" + value.ModPrefix + "." + value.InternalName; if (hashCode == COTL_API.Helpers.HashCode.GetValueHashCode(text)) { spriteIndex = 0; Sprite inventoryIcon = value.InventoryIcon; rect = inventoryIcon.rect; float width = ((Rect)(ref rect)).width; rect = inventoryIcon.rect; float height = ((Rect)(ref rect)).height; rect = inventoryIcon.rect; float num = ((Rect)(ref rect)).height * 0.75f; rect = inventoryIcon.rect; ((GlyphMetrics)(ref iconMetrics))..ctor(width, height, 0f, num, ((Rect)(ref rect)).width); __result = CustomIconManager.GetIcon(inventoryIcon, text, iconMetrics); return false; } } GlyphMetrics iconMetrics2 = default(GlyphMetrics); foreach (COTL_API.CustomFollowerCommand.CustomFollowerCommand value2 in CustomFollowerCommandManager.CustomFollowerCommandList.Values) { string text2 = "icon_FCOMMAND_" + value2.ModPrefix + "." + value2.InternalName; if (hashCode == COTL_API.Helpers.HashCode.GetValueHashCode(text2)) { spriteIndex = 0; Sprite commandIcon = value2.CommandIcon; rect = commandIcon.rect; float width2 = ((Rect)(ref rect)).width; rect = commandIcon.rect; float height2 = ((Rect)(ref rect)).height; rect = commandIcon.rect; float height3 = ((Rect)(ref rect)).height; rect = commandIcon.rect; ((GlyphMetrics)(ref iconMetrics2))..ctor(width2, height2, 0f, height3, ((Rect)(ref rect)).width); __result = CustomIconManager.GetIcon(commandIcon, text2, iconMetrics2); return false; } } return true; } } [HarmonyPatch] public static class LoadMainMenuPatches { [CompilerGenerated] private sealed class d__0 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; 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(); } } [IteratorStateMachine(typeof(d__0))] private static IEnumerator GetEmptyEnumerator() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0); } [HarmonyPatch(typeof(LoadMainMenu), "RunSplashScreens")] [HarmonyPrefix] private static bool LoadMainMenu_RunSplashScreens(ref IEnumerator __result) { if ((Object)(object)Plugin.Instance != (Object)null && !Plugin.Instance.SkipSplashScreen) { return true; } __result = GetEmptyEnumerator(); MMTransition.Play((TransitionType)0, (Effect)0, "Main Menu", 1f, "", (Action)null, (Action)null); return false; } } [HarmonyPatch] public static class SettingsPatches { [HarmonyPatch(typeof(MMHorizontalSelector), "UpdateContent")] [HarmonyPrefix] private static void MMHorizontalSelector_UpdateContent(MMHorizontalSelector __instance, string[] newContent) { if (__instance._contentIndex >= newContent.Length) { __instance._contentIndex = 0; } } [HarmonyPatch(typeof(LoadMenu), "OnTryLoadSaveSlot")] [HarmonyPostfix] private static void LoadMenu_OnTryLoadSaveSlot() { if (Plugin.LambFleeceSkinSettings?.Value != null) { if (CustomSkinManager.CustomPlayerSkins.TryGetValue(Plugin.LambFleeceSkinSettings.Value, out CustomPlayerSkin value)) { CustomSkinManager.SetPlayerSkinOverride(PlayerType.LAMB, value); } else { Plugin.LambFleeceSkinSettings.Value = "Lamb"; } } if (Plugin.GoatFleeceSkinSettings?.Value != null) { if (CustomSkinManager.CustomPlayerSkins.TryGetValue(Plugin.GoatFleeceSkinSettings.Value, out CustomPlayerSkin value2)) { CustomSkinManager.SetPlayerSkinOverride(PlayerType.GOAT, value2); } else { Plugin.GoatFleeceSkinSettings.Value = "Goat"; } } if (Plugin.LambFleeceBleatSettings?.Value != null && Plugin.LambFleeceBleatSettings.Value != "Default") { CustomSkinManager.SetPlayerBleatOverride(PlayerType.LAMB, (PlayerBleat)Enum.Parse(typeof(PlayerBleat), Plugin.LambFleeceBleatSettings.Value, ignoreCase: true)); } if (Plugin.GoatFleeceBleatSettings?.Value != null && Plugin.GoatFleeceBleatSettings.Value != "Default") { CustomSkinManager.SetPlayerBleatOverride(PlayerType.GOAT, (PlayerBleat)Enum.Parse(typeof(PlayerBleat), Plugin.GoatFleeceBleatSettings.Value, ignoreCase: true)); } } } [HarmonyPatch] public static class UIFollowerInteractionWheelOverlayControllerPatches { [HarmonyPatch(typeof(UIFollowerInteractionWheelOverlayController), "MakeChoice", new Type[] { typeof(UIFollowerWheelInteractionItem) })] [HarmonyWrapSafe] public static class MakeChoice { [HarmonyPrefix] public static bool Prefix(ref UIFollowerWheelInteractionItem item, ref bool __state) { if (item.CommandItem is COTL_API.CustomFollowerCommand.CustomFollowerCommand) { List subCommands = item.CommandItem.SubCommands; if (subCommands != null && subCommands.Count > 0) { LogHelper.LogDebug("Custom command with sub commands, not letting normal method run."); __state = true; return false; } } if ((Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.Debug) { LogHelper.LogDebug("Not a custom command or doesnt have sub-commands, letting normal method run."); } __state = false; return true; } [HarmonyPostfix] public static void Postfix(ref UIFollowerInteractionWheelOverlayController __instance, ref UIFollowerWheelInteractionItem item, ref Follower ____follower, ref Stack> ____commandStack, ref Stack ____commandHistory, ref List ____rootCommandItems, ref bool __state) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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) //IL_0122: Expected I4, but got Unknown if (!__state) { return; } if ((Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.Debug) { LogHelper.LogDebug("Custom command original method skipped, this is from the postfix."); } List subCommands = item.CommandItem.SubCommands; if (subCommands != null && subCommands.Count > 0) { if (item.CommandItem.IsAvailable(____follower)) { ____commandStack.Push(____rootCommandItems); ____commandHistory.Push(item.CommandItem.Command); ____rootCommandItems = item.CommandItem.SubCommands; ((MonoBehaviour)__instance).StartCoroutine(__instance.NextCategory(____rootCommandItems)); } else { if ((Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.Debug) { LogHelper.LogDebug("User pressed select on a greyed out sub command, closing menu and aborting choice."); } ((UIMenuBase)__instance).OnCancelButtonInput(); } return; } if ((int)item.FollowerCommand == 41) { ((UIMenuBase)__instance).OnCancelButtonInput(); return; } ((UIMenuBase)__instance).Hide(false); ____commandHistory.Push(item.CommandItem.Command); Action onItemChosen = ((UIRadialMenuBase)(object)__instance).OnItemChosen; if (onItemChosen == null) { return; } Stack obj = ____commandHistory; int num = 0; FollowerCommands[] array = (FollowerCommands[])(object)new FollowerCommands[obj.Count]; foreach (FollowerCommands item2 in obj) { array[num] = (FollowerCommands)(int)item2; num++; } onItemChosen(array); } } } } namespace COTL_API.Icons { internal static class CustomIconManager { private static Dictionary Icons { get; } = new Dictionary(); internal static TMP_SpriteAsset GetIcon(Sprite icon, string name, GlyphMetrics iconMetrics) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (Icons.TryGetValue(icon, out TMP_SpriteAsset value)) { return value; } ((Object)icon).name = name; TMP_SpriteAsset val = CreateAssetFor(icon, iconMetrics); Icons.Add(icon, val); return val; } private static TMP_SpriteAsset CreateAssetFor(Sprite sprite, GlyphMetrics iconMetrics) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_005f: 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_0067: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0097: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown Texture2D texture = sprite.texture; TMP_SpriteAsset val = ScriptableObject.CreateInstance(); val.version = "1.1.0"; ((Object)val).name = ((Object)sprite).name; ((TMP_Asset)val).hashCode = TMP_TextUtilities.GetSimpleHashCode(((Object)val).name); val.spriteSheet = (Texture)(object)texture; val.spriteGlyphTable = new List(); val.spriteCharacterTable = new List(); TMP_SpriteGlyph val2 = new TMP_SpriteGlyph { index = 0u, metrics = iconMetrics, glyphRect = new GlyphRect(sprite.rect), scale = 1.25f, sprite = sprite }; val.spriteGlyphTable.Add(val2); TMP_SpriteCharacter item = new TMP_SpriteCharacter(0u, val2) { name = ((Object)sprite).name, scale = 1.25f }; val.spriteCharacterTable.Add(item); Material val3 = new Material(Shader.Find("TextMeshPro/Sprite")); val3.SetTexture(ShaderUtilities.ID_MainTex, val.spriteSheet); ((TMP_Asset)val).material = val3; val.UpdateLookupTables(); return val; } } } namespace COTL_API.Saves { [Serializable] public class ObjectDictionary : Dictionary { public ObjectDictionary() { } protected ObjectDictionary(SerializationInfo info, StreamingContext context) : base(info, context) { } public T? GetValue(string key) { if (ContainsKey(key)) { return (T)base[key]; } return default(T); } public string? GetValueAsString(string key) { return GetValue(key); } public int GetValueAsInt(string key) { long valueAsLong = GetValueAsLong(key); if (valueAsLong <= int.MaxValue) { if (valueAsLong < int.MinValue) { return int.MinValue; } return (int)valueAsLong; } return int.MaxValue; } public long GetValueAsLong(string key) { return GetValue(key); } public float GetValueAsFloat(string key) { return Convert.ToSingle(GetValue(key)); } public bool GetValueAsBoolean(string key) { return GetValue(key); } public void SetValue(string key, T? value) { if (value == null) { Remove(key); } else if (ContainsKey(key)) { base[key] = value; } else { Add(key, value); } } } internal class ApiData { private readonly string[] _randomEasterEgg = new string[4] { "Rawr~", "Hewwo, twis pwoject was made bwy a fwwy, and I'm suwe you'ww wuv it!", "Another day another unstable API! Hello!", "Proud bug maker!" }; public string OwO => _randomEasterEgg[Random.Range(0, _randomEasterEgg.Length)]; public ObjectDictionary EnumData { get; set; } = new ObjectDictionary(); } public class ApiSlotData { private readonly string[] _randomEasteregg = new string[4] { "Rawr~", "Hewwo, twis pwoject was made bwy a fwwy, and I'm suwe you'ww wuv it!", "Another day another unstable API! Hello!", "Proud bug maker!" }; public string OwO => _randomEasteregg[Random.Range(0, _randomEasteregg.Length)]; public Dictionary QuestData { get; set; } = new Dictionary(); } public enum ModdedSaveLoadOrder { LOAD_AS_SOON_AS_POSSIBLE, LOAD_AFTER_SAVE_START } public abstract class BaseModdedSaveData { public abstract int SAVE_SLOT { get; protected set; } public abstract bool IsLoaded { get; protected set; } public abstract string GUID { get; protected set; } public abstract ModdedSaveLoadOrder LoadOrder { get; set; } public Action? OnSaveCompleted { get; set; } public Action? OnSaveError { get; set; } public Action? OnLoadComplete { get; set; } public Action? OnSaveSlotDeleted { get; set; } public abstract void CreateDefault(); public abstract void Save(bool encrypt = true, bool backup = true); public abstract void Saving(); public abstract void Load(int? saveSlot = null); public abstract bool SaveExist(int? saveSlot = null); public abstract void DeleteSaveSlot(int? saveSlot = null); public abstract void ResetSave(int? saveSlot = null, bool newGame = false); public abstract string MakeSaveSlot(int? slot = null); } public class ModdedSaveData : BaseModdedSaveData where T : class, new() { private readonly COTLDataReadWriter _dataReadWriter = new COTLDataReadWriter(); public override int SAVE_SLOT { get; protected set; } = 5; public override ModdedSaveLoadOrder LoadOrder { get; set; } = ModdedSaveLoadOrder.LOAD_AFTER_SAVE_START; public sealed override string GUID { get; protected set; } public override bool IsLoaded { get; protected set; } public T? Data { get; private set; } public ModdedSaveData(string guid) { GUID = guid; COTLDataReadWriter dataReadWriter = _dataReadWriter; ((MMDataReadWriterBase)(object)dataReadWriter).OnReadCompleted = (Action)Delegate.Combine(((MMDataReadWriterBase)(object)dataReadWriter).OnReadCompleted, (Action)delegate(T saveData) { Data = saveData; IsLoaded = true; base.OnLoadComplete?.Invoke(); }); COTLDataReadWriter dataReadWriter2 = _dataReadWriter; ((MMDataReadWriterBase)(object)dataReadWriter2).OnCreateDefault = (Action)Delegate.Combine(((MMDataReadWriterBase)(object)dataReadWriter2).OnCreateDefault, (Action)delegate { CreateDefault(); base.OnLoadComplete?.Invoke(); IsLoaded = true; base.OnSaveCompleted?.Invoke(); }); COTLDataReadWriter dataReadWriter3 = _dataReadWriter; ((MMDataReadWriterBase)(object)dataReadWriter3).OnWriteCompleted = (Action)Delegate.Combine(((MMDataReadWriterBase)(object)dataReadWriter3).OnWriteCompleted, (Action)delegate { base.OnSaveCompleted?.Invoke(); }); COTLDataReadWriter dataReadWriter4 = _dataReadWriter; ((MMDataReadWriterBase)(object)dataReadWriter4).OnWriteError = (Action)Delegate.Combine(((MMDataReadWriterBase)(object)dataReadWriter4).OnWriteError, (Action)delegate(MMReadWriteError error) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) base.OnSaveError?.Invoke(error); }); } public override void CreateDefault() { Data = new T(); } public override void Save(bool encrypt = true, bool backup = true) { if ((LoadOrder == ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE || (DataManager.Instance.AllowSaving && !CheatConsole.IN_DEMO)) && Data != null) { ((MMDataReadWriterBase)(object)_dataReadWriter).Write(Data, MakeSaveSlot((LoadOrder == ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE) ? null : new int?(SAVE_SLOT)), encrypt, backup); } } public override void Saving() { if (Data != null) { ((MMDataReadWriterBase)(object)_dataReadWriter).Write(Data, MakeSaveSlot((LoadOrder == ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE) ? null : new int?(SAVE_SLOT)), true, true); } } public override void Load(int? saveSlot = null) { if (LoadOrder == ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE || !CheatConsole.IN_DEMO) { if (saveSlot.HasValue) { SAVE_SLOT = saveSlot.Value; } ((MMDataReadWriterBase)(object)_dataReadWriter).Read(MakeSaveSlot((LoadOrder == ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE) ? null : new int?(SAVE_SLOT))); } } public override bool SaveExist(int? saveSlot = null) { return ((MMDataReadWriterBase)(object)_dataReadWriter).FileExists(MakeSaveSlot(saveSlot)); } public override void DeleteSaveSlot(int? saveSlot = null) { ((MMDataReadWriterBase)(object)_dataReadWriter).Delete(MakeSaveSlot(saveSlot)); if (saveSlot.HasValue) { base.OnSaveSlotDeleted?.Invoke(saveSlot.Value); } } public override void ResetSave(int? saveSlot = null, bool newGame = false) { if (saveSlot.HasValue) { SAVE_SLOT = saveSlot.Value; } CreateDefault(); if (!newGame) { Save(); } IsLoaded = true; } public override string MakeSaveSlot(int? slot = null) { if (!slot.HasValue) { return GUID + ".json"; } return $"{GUID}_{slot}.json"; } } [HarmonyPatch] public static class ModdedSaveManager { internal static readonly Dictionary ModdedSaveDataList = new Dictionary(); public static void RegisterModdedSave(BaseModdedSaveData saveData) { ModdedSaveDataList.Add(saveData.GUID, saveData); if (saveData.LoadOrder == ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE) { saveData.Load(); } } [HarmonyPatch(typeof(SaveAndLoad), "Load")] [HarmonyPostfix] private static void SaveAndLoad_Load(int saveSlot) { foreach (BaseModdedSaveData item in ModdedSaveDataList.Values.Where((BaseModdedSaveData save) => save.LoadOrder != ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE)) { item.Load(saveSlot); } } [HarmonyPatch(typeof(SaveAndLoad), "Save", new Type[] { })] [HarmonyPostfix] private static void SaveAndLoad_Save() { foreach (BaseModdedSaveData value in ModdedSaveDataList.Values) { value.Save(); } } [HarmonyPatch(typeof(SaveAndLoad), "Saving")] [HarmonyPostfix] private static void SaveAndLoad_Saving() { foreach (BaseModdedSaveData value in ModdedSaveDataList.Values) { value.Saving(); } } [HarmonyPatch(typeof(SaveAndLoad), "ResetSave")] [HarmonyPostfix] private static void SaveAndLoad_ResetSave(int saveSlot, bool newGame) { foreach (BaseModdedSaveData item in ModdedSaveDataList.Values.Where((BaseModdedSaveData save) => save.LoadOrder != ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE)) { item.ResetSave(saveSlot, newGame); } } [HarmonyPatch(typeof(SaveAndLoad), "DeleteSaveSlot")] [HarmonyPostfix] private static void SaveAndLoad_DeleteSaveSlot(int saveSlot) { foreach (BaseModdedSaveData item in ModdedSaveDataList.Values.Where((BaseModdedSaveData save) => save.LoadOrder != ModdedSaveLoadOrder.LOAD_AS_SOON_AS_POSSIBLE)) { item.DeleteSaveSlot(saveSlot); } } } } namespace COTL_API.UI { internal static class SettingsUtils { internal static GameObject? HeaderTemplate { get; set; } internal static GameObject? SliderTemplate { get; set; } internal static GameObject? DropdownTemplate { get; set; } internal static GameObject? HorizontalSelectorTemplate { get; set; } internal static GameObject? ToggleTemplate { get; set; } public static void AddHeader(Transform parent, string? text) { if ((Object)(object)HeaderTemplate == (Object)null) { LogHelper.LogError("Unable to find header template!"); return; } GameObject obj = Object.Instantiate(HeaderTemplate, parent); ((Object)obj).name = text; ((TMP_Text)obj.GetComponentInChildren()).text = text; } public static void AddSlider(Transform parent, string text, float value, float minValue, float maxValue, int increment, ValueDisplayFormat format = 1, UnityAction? onChange = null) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SliderTemplate == (Object)null) { LogHelper.LogError("Unable to find slider template!"); return; } GameObject obj = Object.Instantiate(SliderTemplate, parent); ((Object)obj).name = text; ((TMP_Text)obj.GetComponentInChildren()).text = text; MMSlider componentInChildren = obj.GetComponentInChildren(); ((Slider)componentInChildren).minValue = minValue; ((Slider)componentInChildren).maxValue = maxValue; componentInChildren._increment = increment; componentInChildren._valueDisplayFormat = format; if (onChange != null) { ((UnityEvent)(object)((Slider)componentInChildren).onValueChanged).AddListener(onChange); } ((Slider)componentInChildren).value = value; } public static void AddDropdown(Transform parent, string text, string?[] options, int index = 0, Action? onChange = null, string? indexStringOverride = null) { if ((Object)(object)DropdownTemplate == (Object)null) { LogHelper.LogError("Unable to find dropdown template!"); return; } GameObject obj = Object.Instantiate(DropdownTemplate, parent); ((Object)obj).name = text; ((TMP_Text)obj.GetComponentInChildren()).text = text; MMDropdown componentInChildren = obj.GetComponentInChildren(); componentInChildren._localizeContent = false; componentInChildren.UpdateContent(options); int num = Math.Max(0, ArrayExtensions.IndexOf(options, indexStringOverride)); componentInChildren.ContentIndex = ((indexStringOverride != null) ? num : index); if (onChange != null) { componentInChildren.OnValueChanged = (Action)Delegate.Combine(componentInChildren.OnValueChanged, onChange); } } public static void AddKeyboardShortcutDropdown(Transform parent, string text, int index = 0, Action? onChange = null, string? indexStringOverride = null) { Action onChange2 = onChange; if ((Object)(object)DropdownTemplate == (Object)null) { LogHelper.LogError("Unable to find dropdown template!"); return; } GameObject val = Object.Instantiate(DropdownTemplate, parent); ((Object)val).name = text; ((TMP_Text)val.GetComponentInChildren()).text = text; MMDropdown mmDropdown = val.GetComponentInChildren(); mmDropdown._localizeContent = false; mmDropdown.UpdateContent(Enum.GetNames(typeof(KeyCode))); if (indexStringOverride != null) { index = Array.IndexOf(mmDropdown.Content, indexStringOverride); } mmDropdown.ContentIndex = index; if (onChange2 != null) { MMDropdown obj = mmDropdown; obj.OnValueChanged = (Action)Delegate.Combine(obj.OnValueChanged, (Action)delegate(int selectedIndex) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) KeyCode val2 = (KeyCode)Enum.Parse(typeof(KeyCode), mmDropdown.Content[selectedIndex]); KeyboardShortcut obj2 = default(KeyboardShortcut); ((KeyboardShortcut)(ref obj2))..ctor(val2, Array.Empty()); onChange2(obj2); }); } } public static void AddHorizontalSelector(Transform parent, string text, string?[] options, int index = 0, Action? onChange = null, string? indexStringOverride = null) { if ((Object)(object)HorizontalSelectorTemplate == (Object)null) { LogHelper.LogError("Unable to find horizontal selector template!"); return; } GameObject obj = Object.Instantiate(HorizontalSelectorTemplate, parent); ((Object)obj).name = text; ((TMP_Text)obj.GetComponentInChildren()).text = text; MMHorizontalSelector componentInChildren = obj.GetComponentInChildren(); componentInChildren._localizeContent = false; componentInChildren.UpdateContent(options); int num = Math.Max(0, ArrayExtensions.IndexOf(options, indexStringOverride)); componentInChildren.ContentIndex = ((indexStringOverride != null) ? num : index); if (onChange != null) { componentInChildren.OnSelectionChanged = (Action)Delegate.Combine(componentInChildren.OnSelectionChanged, onChange); } } public static void AddToggle(Transform parent, string text, bool value, Action? onChange = null) { if ((Object)(object)ToggleTemplate == (Object)null) { LogHelper.LogError("Unable to find toggle template!"); return; } GameObject obj = Object.Instantiate(ToggleTemplate, parent); ((Object)obj).name = text; ((TMP_Text)obj.GetComponentInChildren()).text = text; MMToggle componentInChildren = obj.GetComponentInChildren(); componentInChildren.Value = value; componentInChildren.UpdateState(true); if (onChange != null) { componentInChildren.OnValueChanged = (Action)Delegate.Combine(componentInChildren.OnValueChanged, onChange); } } } [HarmonyPatch] public static class UIManager { public static Action OnSettingsLoaded { get; set; } = delegate { }; [HarmonyPatch(typeof(UISettingsMenuController), "OnShowStarted")] [HarmonyPostfix] private static void UISettingsMenuController_OnShowStarted(UISettingsMenuController __instance) { //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown if ((Object)(object)SettingsUtils.SliderTemplate == (Object)null) { SettingsUtils.SliderTemplate = ((Component)((Transform)((Component)__instance._audioSettings).GetComponentInChildren().content).GetChild(0)).gameObject; } if ((Object)(object)SettingsUtils.HeaderTemplate == (Object)null) { SettingsUtils.HeaderTemplate = ((Component)((Transform)((Component)__instance._graphicsSettings).GetComponentInChildren().content).GetChild(0)).gameObject; } if ((Object)(object)SettingsUtils.DropdownTemplate == (Object)null) { SettingsUtils.DropdownTemplate = ((Component)((Transform)((Component)__instance._graphicsSettings).GetComponentInChildren().content).GetChild(2)).gameObject; } if ((Object)(object)SettingsUtils.HorizontalSelectorTemplate == (Object)null) { SettingsUtils.HorizontalSelectorTemplate = ((Component)((Transform)((Component)__instance._graphicsSettings).GetComponentInChildren().content).GetChild(3)).gameObject; } if ((Object)(object)SettingsUtils.ToggleTemplate == (Object)null) { SettingsUtils.ToggleTemplate = ((Component)((Transform)((Component)__instance._graphicsSettings).GetComponentInChildren().content).GetChild(4)).gameObject; } GraphicsSettings graphicsSettings = __instance._graphicsSettings; SettingsTabNavigatorBase stnb = ((Component)((Component)__instance).transform).GetComponentInChildren(); HorizontalLayoutGroup componentInChildren = ((Component)stnb).GetComponentInChildren(); Transform val = Object.Instantiate(((Component)componentInChildren).transform.GetChild(2), ((Component)componentInChildren).transform); val.SetSiblingIndex(((Component)componentInChildren).transform.childCount - 2); ((Object)val).name = "Mod Settings Button"; TMP_Text componentInChildren2 = ((Component)val).GetComponentInChildren(); Object.Destroy((Object)(object)((Component)val).GetComponentInChildren()); componentInChildren2.text = "Mods"; GameObject gameObject = ((Component)((Component)((Component)__instance).GetComponentInChildren()).transform.parent).gameObject; Transform obj = Object.Instantiate(gameObject.transform.GetChild(1), gameObject.transform); ((Object)obj).name = "Mod Settings Content"; ((Component)obj).gameObject.SetActive(true); GraphicsSettings componentInChildren3 = ((Component)obj).GetComponentInChildren(); SettingsTab tab = ((Component)val).GetComponent(); ((MMTab)tab)._menu = (UISubmenuBase)(object)componentInChildren3; ((UIMenuBase)componentInChildren3)._defaultSelectable = ((Component)((ScrollRect)componentInChildren3._scrollRect).content).GetComponentInChildren(); ((UIMenuBase)componentInChildren3)._defaultSelectableFallbacks = Array.Empty(); Action onShow = ((UIMenuBase)graphicsSettings).OnShow; Action onHide = ((UIMenuBase)graphicsSettings).OnHide; Delegate[] invocationList = onShow.GetInvocationList(); Delegate[] invocationList2 = onHide.GetInvocationList(); Action action = (Action)invocationList[1]; Action b = (Action)invocationList2[1]; Action action2 = (Action)invocationList2[2]; ((UIMenuBase)componentInChildren3).OnShow = (Action)Delegate.Combine(((UIMenuBase)componentInChildren3).OnShow, action); ((UIMenuBase)componentInChildren3).OnHide = (Action)Delegate.Combine(((UIMenuBase)componentInChildren3).OnHide, action2); ((UIMenuBase)componentInChildren3).OnHide = (Action)Delegate.Combine(((UIMenuBase)componentInChildren3).OnHide, b); ((UIMenuBase)graphicsSettings).OnShow = (Action)Delegate.Remove(((UIMenuBase)graphicsSettings).OnShow, action); ((UIMenuBase)graphicsSettings).OnHide = (Action)Delegate.Remove(((UIMenuBase)graphicsSettings).OnHide, action2); SettingsTabNavigatorBase componentInChildren4 = ((Component)((Component)__instance).transform).GetComponentInChildren(); SettingsTab[] tabs = ((MMTabNavigatorBase)(object)((Component)((Component)__instance).transform).GetComponentInChildren())._tabs; int num = 0; SettingsTab[] array = (SettingsTab[])(object)new SettingsTab[1 + tabs.Length]; SettingsTab[] array2 = tabs; foreach (SettingsTab val2 in array2) { array[num] = val2; num++; } array[num] = tab; ((MMTabNavigatorBase)(object)componentInChildren4)._tabs = array; MMButton componentInChildren5 = ((Component)val).GetComponentInChildren(); ((UnityEventBase)((Button)componentInChildren5).onClick).RemoveAllListeners(); ((UnityEvent)((Button)componentInChildren5).onClick).AddListener((UnityAction)delegate { ((MMTabNavigatorBase)(object)stnb).TransitionTo(tab); }); } [HarmonyPatch(typeof(GraphicsSettings), "OnShowStarted")] [HarmonyPrefix] private static void UISettingsMenuController_OnShowStarted(GraphicsSettings __instance) { if (!(((Object)__instance).name != "Mod Settings Content")) { __instance._targetFpsSelectable.HorizontalSelector._canvasGroup = ((UIMenuBase)__instance)._canvasGroup; ((UIMenuBase)__instance)._defaultSelectable = ((Component)((ScrollRect)__instance._scrollRect).content).GetComponentInChildren(); ? val = MonoSingleton.Instance; Selectable defaultSelectable = ((UIMenuBase)__instance)._defaultSelectable; ((UINavigatorNew)val).NavigateToNew((IMMSelectable)(object)((defaultSelectable is IMMSelectable) ? defaultSelectable : null)); } } [HarmonyPatch(typeof(GraphicsSettings), "Start")] [HarmonyPrefix] private static bool GraphicsSettings_Start(GraphicsSettings __instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) if (((Object)__instance).name != "Mod Settings Content") { return true; } Transform content = (Transform)(object)((ScrollRect)__instance._scrollRect).content; foreach (Transform item in content) { Object.Destroy((Object)(object)((Component)item).gameObject); } OnSettingsLoaded(); OnSettingsLoaded = delegate { }; string text = null; foreach (ISettingsElement item2 in CustomSettingsManager.SettingsElements.OrderBy((ISettingsElement x) => x.Category)) { if (item2.Category != text) { text = item2.Category; SettingsUtils.AddHeader(content, text); } Slider slider = item2 as Slider; Dropdown dropdown; KeyboardShortcutDropdown keyboardShortcutDropdown; HorizontalSelector horizontalSelector; Toggle toggle; if (slider == null) { dropdown = item2 as Dropdown; if (dropdown == null) { keyboardShortcutDropdown = item2 as KeyboardShortcutDropdown; if (keyboardShortcutDropdown == null) { horizontalSelector = item2 as HorizontalSelector; if (horizontalSelector == null) { toggle = item2 as Toggle; if (toggle != null) { SettingsUtils.AddToggle(content, toggle.Text, toggle.Value, OnValueChanged); } } else { SettingsUtils.AddHorizontalSelector(content, horizontalSelector.Text, horizontalSelector.Options, -1, OnValueChanged, horizontalSelector.Value); } } else { SettingsUtils.AddKeyboardShortcutDropdown(content, keyboardShortcutDropdown.Text, 0, OnValueChanged, keyboardShortcutDropdown.Value.ToString()); } } else { SettingsUtils.AddDropdown(content, dropdown.Text, dropdown.Options, -1, OnValueChanged, dropdown.Value); } } else { SettingsUtils.AddSlider(content, slider.Text, slider.Value, slider.Min, slider.Max, slider.Increment, slider.DisplayFormat, OnValueChanged); } void OnValueChanged(bool i) { toggle.Value = i; toggle.OnValueChanged?.Invoke(i); } void OnValueChanged(int i) { horizontalSelector.Value = horizontalSelector.Options[i]; horizontalSelector.OnValueChanged?.Invoke(i); } void OnValueChanged(KeyboardShortcut i) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) keyboardShortcutDropdown.Value = ((KeyboardShortcut)(ref i)).MainKey; keyboardShortcutDropdown.OnValueChanged?.Invoke(i); } void OnValueChanged(int i) { dropdown.Value = dropdown.Options[i]; dropdown.OnValueChanged?.Invoke(i); } void OnValueChanged(float i) { slider.Value = i; slider.OnValueChanged?.Invoke(i); } } if (!CustomSettingsManager.SettingsElements.Any()) { SettingsUtils.AddHeader(content, "(No mods have settings)"); } return false; } } } namespace COTL_API.UI.Helpers { public static class GameHash { public static void LogGameInfo() { string gameAssemblyHash = GetGameAssemblyHash(); LogHelper.LogInfo("Cult of the Lamb " + Application.version + " - SHA256 Hash: " + gameAssemblyHash); } private static string GetGameAssemblyHash() { byte[] buffer = File.ReadAllBytes(Assembly.GetAssembly(typeof(TwitchManager)).Location); byte[] array; using (SHA256 sHA = SHA256.Create()) { array = sHA.ComputeHash(buffer); } return BitConverter.ToString(array).Replace("-", ""); } private static bool VerifyAssemblyHash(string assemblyHash, string correctHash) { return assemblyHash.Equals(correctHash, StringComparison.OrdinalIgnoreCase); } } [HarmonyPatch] public static class ModdedStructuresPatches { private const string MiniMods = "InfernoDragon0.cotl.CotLChef"; private static readonly string[] ModdedVanillaStructures = new string[2] { "Building Fishing Hut(Clone)", "Building Fishing Hut" }; private static readonly string[] ModdedVanillaPrefabPaths = new string[1] { "Building Fishing Hut" }; [HarmonyTranspiler] [HarmonyPatch(typeof(ControlUtilities), "GetCurrentInputType")] private static IEnumerable ControlUtilities_GetCurrentInputType(IEnumerable instructions, MethodBase originalMethod) { List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode != OpCodes.Ldstr || !list[i].operand.ToString().Contains("Steam informs us the controller is a {0}")) { continue; } for (int j = i + 1; j < list.Count; j++) { if (!(list[j].opcode != OpCodes.Call) && list[j].operand is MethodInfo methodInfo && methodInfo.Name == "Log") { list.RemoveRange(i, j - i + 1); break; } } break; } return list.AsEnumerable(); } [HarmonyPrefix] [HarmonyPatch(typeof(Debugger), "LogInvalidTween")] private static bool Debugger_LogInvalidTween() { return false; } [HarmonyPrefix] [HarmonyPatch(typeof(Debug), "LogError", new Type[] { typeof(object) })] [HarmonyPatch(typeof(Debug), "LogError", new Type[] { typeof(object), typeof(Object) })] private static bool Debug_LogError(ref object message) { if (!(message is string text)) { return true; } bool flag; switch (LocalizationManager.CurrentCulture.Name) { case "zh-CN": case "zh-TW": case "ja-JP": case "ko-KR": flag = true; break; default: flag = false; break; } if (!flag) { return !text.Contains("Font at path"); } return true; } [HarmonyFinalizer] [HarmonyPatch(typeof(StructureBrain), "ApplyConfigToData")] [HarmonyPatch(typeof(LocationManager), "PlaceStructure")] private static Exception? Finalizer() { return null; } [HarmonyPostfix] [HarmonyPatch(typeof(GenerateRoom), "OnDisable")] private static void GenerateRoom_OnDisable(ref GenerateRoom __instance) { if (!ModdedVanillaStructureExists()) { LogHelper.LogDebug("No modded vanilla structure mods found, checking for left over gameobjects."); RemoveModdedVanillaGameObjects(); } LogHelper.LogDebug("Checking other custom structures and correcting DataManager (SaveData)"); RemoveRogueCustomStructuresFromDataManager(); } private static void RemoveModdedVanillaGameObjects() { List list = (from obj in Object.FindObjectsOfType() where ModdedVanillaStructures.Any(((Object)obj).name.Contains) select obj).ToList(); if (!list.Any()) { return; } foreach (GameObject item in list) { LogHelper.LogWarning("Destroyed " + ((Object)item).name); Object.DestroyImmediate((Object)(object)item); } } private static void RemoveRogueCustomStructuresFromDataManager() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); List list = (from a in AccessTools.GetDeclaredFields(typeof(DataManager)) where a.FieldType == typeof(List) select a).ToList(); bool flag = false; foreach (FieldInfo field in list) { if (!(field.GetValue(DataManager.Instance) is List list2)) { continue; } List itemsToRemove = new List(); list2.ForEach(delegate(StructuresData structure) { if (structure.PrefabPath != null && structure.PrefabPath.Contains("CustomBuildingPrefab")) { LogHelper.LogInfo("Found custom item in " + field.Name + ": " + structure.PrefabPath); if (!CustomStructureManager.CustomStructureExists(structure.PrefabPath)) { LogHelper.LogWarning("Found custom item in " + field.Name + " from a mod no longer installed!: " + structure.PrefabPath); itemsToRemove.Add(structure); } } }); int num = list2.RemoveAll((StructuresData a) => itemsToRemove.Contains(a)); int num2 = 0; if (!ModdedVanillaStructureExists()) { num2 = list2.RemoveAll((StructuresData a) => a == null || (a != null && a.PrefabPath != null && ModdedVanillaPrefabPaths.Any(a.PrefabPath.Contains))); } field.SetValue(DataManager.Instance, list2); if (num > 0 || num2 > 0) { flag = true; LogHelper.LogDebug($"Removed {num} orphaned structure(s) and {num2} orphaned modded vanilla structure(s) from {field.Name}."); } } stopwatch.Stop(); if (flag) { LogHelper.LogDebug($"Finished correcting DataManager (SaveData) in {stopwatch.ElapsedMilliseconds}ms & {stopwatch.ElapsedTicks} ticks."); SaveAndLoad.Save(); } else { LogHelper.LogDebug($"No orphaned structure(s), so no changes made to DataManager (SaveData) in {stopwatch.ElapsedMilliseconds}ms & {stopwatch.ElapsedTicks} ticks."); } } private static bool ModdedVanillaStructureExists() { return Chainloader.PluginInfos.FirstOrDefault((KeyValuePair a) => a.Value.Metadata.GUID.Contains("InfernoDragon0.cotl.CotLChef")).Value != null; } } public static class FontHelpers { internal static TMP_FontAsset? _startMenu { get; set; } internal static TMP_FontAsset? _pauseMenu { get; set; } public static TMP_FontAsset? PauseMenu => _pauseMenu; public static TMP_FontAsset? StartMenu => _startMenu; public static TMP_FontAsset? UIFont { get { if (!Object.op_Implicit((Object)(object)PauseMenu)) { return StartMenu; } return PauseMenu; } } } public static class GameObjectExtensions { public static GameObject AttachToParent(this GameObject obj, Transform parent) { obj.transform.SetParent(parent); return obj; } public static GameObject ChangePosition(this GameObject obj, float? x = null, float? y = null, float? z = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_003d: 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_005d: Unknown result type (might be due to invalid IL or missing references) Quaternion localRotation = obj.transform.localRotation; float valueOrDefault = x.GetValueOrDefault(); if (!x.HasValue) { valueOrDefault = localRotation.x; x = valueOrDefault; } valueOrDefault = y.GetValueOrDefault(); if (!y.HasValue) { valueOrDefault = localRotation.y; y = valueOrDefault; } valueOrDefault = z.GetValueOrDefault(); if (!z.HasValue) { valueOrDefault = localRotation.z; z = valueOrDefault; } obj.transform.localPosition = new Vector3(x.Value, y.Value, z.Value); return obj; } public static GameObject ChangeScale(this GameObject obj, float? x = null, float? y = null, float? z = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 localScale = obj.transform.localScale; float valueOrDefault = x.GetValueOrDefault(); if (!x.HasValue) { valueOrDefault = localScale.x; x = valueOrDefault; } valueOrDefault = y.GetValueOrDefault(); if (!y.HasValue) { valueOrDefault = localScale.y; y = valueOrDefault; } valueOrDefault = z.GetValueOrDefault(); if (!z.HasValue) { valueOrDefault = localScale.z; z = valueOrDefault; } ((Vector3)(ref localScale))..ctor(x.Value, y.Value, z.Value); obj.transform.localScale = localScale; return obj; } public static GameObject ChangeRotation(this GameObject obj, float? x = null, float? y = null, float? z = null) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_003d: 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_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 eulerAngles = obj.transform.eulerAngles; float valueOrDefault = x.GetValueOrDefault(); if (!x.HasValue) { valueOrDefault = eulerAngles.x; x = valueOrDefault; } valueOrDefault = y.GetValueOrDefault(); if (!y.HasValue) { valueOrDefault = eulerAngles.y; y = valueOrDefault; } valueOrDefault = z.GetValueOrDefault(); if (!z.HasValue) { valueOrDefault = eulerAngles.z; z = valueOrDefault; } obj.transform.Rotate(new Vector3(x.Value, y.Value, z.Value)); return obj; } public static GameObject CreateChild(this GameObject obj, string name) { Transform transform = obj.transform; return UIHelpers.CreateUIObject(name, transform); } public static GameObject MakeDraggable(this GameObject obj) { obj.AddComponent(); return obj; } public static GameObject MakeDraggable(this GameObject obj, in RectTransform? dragRect) { obj.AddComponent().dragRectTransform = dragRect; return obj; } public static GameObject MakeDraggable(this GameObject obj, in GameObject dragObj) { UIBehaviourHelpers.DraggableUIObject draggableUIObject = obj.AddComponent(); RectTransform component = dragObj.GetComponent(); draggableUIObject.dragRectTransform = component; return obj; } public static UIButton MakeButton(this GameObject obj) { return obj.AddComponent(); } public static GameObject AddText(this GameObject obj, string message, float fontSize = 10f, TextAlignmentOptions alignment = 514) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj2 = obj.AddComponent(); ((TMP_Text)obj2).font = FontHelpers.UIFont; ((TMP_Text)obj2).fontSize = fontSize; ((TMP_Text)obj2).text = message; ((TMP_Text)obj2).alignment = alignment; return obj; } public static GameObject EditText(this GameObject obj, string message) { TextMeshProUGUI component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { LogHelper.LogWarning("EditText: TextMeshProUGUI component not found."); return obj; } ((TMP_Text)component).text = message; return obj; } private static string? GetPathToImage(string filename) { if (!Path.IsPathRooted(filename)) { return Directory.GetFiles(Paths.PluginPath, filename, SearchOption.AllDirectories).FirstOrDefault(); } return filename; } public static GameObject AttachImage(this GameObject obj, string imagePath, int opacity = 100) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) string pathToImage = GetPathToImage(imagePath); if (pathToImage == null) { LogHelper.LogError("File " + imagePath + " not found."); return obj; } Sprite sprite = TextureHelper.CreateSpriteFromPath(pathToImage); Image obj2 = obj.AddComponent(); obj2.sprite = sprite; ((Graphic)obj2).SetNativeSize(); obj2.preserveAspect = true; opacity = Mathf.Clamp(opacity, 0, 100); Color color = ((Graphic)obj2).color; color.a = (float)opacity / 100f; ((Graphic)obj2).color = color; return obj; } public static GameObject AttachImage(this GameObject obj, Sprite sprite, int opacity = 100) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Image val = obj.AddComponent(); val.sprite = sprite; ((Graphic)val).SetNativeSize(); val.preserveAspect = true; if ((opacity >= 100 || opacity < 0) ? true : false) { return obj; } Color color = ((Graphic)val).color; color.a = (float)opacity / 100f; ((Graphic)val).color = color; return obj; } public static GameObject EditImage(this GameObject obj, Sprite sprite) { Image component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { LogHelper.LogError("EditImage: Image component not found."); return obj; } component.sprite = sprite; return obj; } public static GameObject EditImage(this GameObject obj, string imagePath) { string pathToImage = GetPathToImage(imagePath); if (pathToImage == null) { LogHelper.LogError("File " + imagePath + " not found."); return obj; } Sprite sprite = TextureHelper.CreateSpriteFromPath(pathToImage); Image component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { LogHelper.LogError("EditImage: Image component not found."); return obj; } component.sprite = sprite; return obj; } public static GameObject ChangeImageOpacity(this GameObject obj, int opacity = 100) { //IL_001d: 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_003e: Unknown result type (might be due to invalid IL or missing references) Image component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { LogHelper.LogError("ChangeOpacity: Image component not found."); return obj; } Color color = ((Graphic)component).color; opacity = Mathf.Clamp(opacity, 0, 100); color.a = (float)opacity / 100f; ((Graphic)component).color = color; return obj; } } internal class UIBehaviourHelpers { public class DraggableUIObject : MonoBehaviour, IDragHandler, IEventSystemHandler { public RectTransform? dragRectTransform; public Canvas? canvas; public void Start() { if (dragRectTransform == null) { dragRectTransform = ((Component)this).GetComponent(); } if (canvas == null) { canvas = ((Component)this).GetComponentInParent(); } } public void OnDrag(PointerEventData eventData) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)dragRectTransform != (Object)null && (Object)(object)canvas != (Object)null) { RectTransform? obj = dragRectTransform; obj.anchoredPosition += eventData.delta / canvas.scaleFactor; } } } } public class UIButton : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler { public delegate void ButtonAction(); public event ButtonAction? OnClick; public event ButtonAction? OnCursorEnter; public event ButtonAction? OnCursorExit; public void OnPointerDown(PointerEventData eventData) { this.OnClick?.Invoke(); } public void OnPointerEnter(PointerEventData eventData) { this.OnCursorEnter?.Invoke(); } public void OnPointerExit(PointerEventData eventData) { this.OnCursorExit?.Invoke(); } } public static class UIHelpers { public static LayerMask UILayer => LayerMask.op_Implicit(LayerMask.NameToLayer("UI")); public static void AddToPauseMenu() where T : UIMenuBase { UIPatches.PauseMenuQueue.Add(typeof(T)); } public static GameObject CreateUIObject(string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = LayerMask.op_Implicit(UILayer) }; val.transform.localPosition = Vector3.zero; val.transform.localScale = Vector3.one; return val; } public static GameObject CreateUIObject(string name, Transform parent) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = LayerMask.op_Implicit(UILayer) }; val.transform.SetParent(parent); val.transform.localPosition = Vector3.zero; val.transform.localScale = Vector3.one; return val; } } public abstract class UIMenuBase : MonoBehaviour { public static Transform? Parent { get; set; } public void Start() { if ((Object)(object)Parent != (Object)null) { InitializeMenu(Parent); } } public abstract void InitializeMenu(Transform parent); } internal static class UIPatches { [HarmonyPatch] public static class PauseMenuPatch { [HarmonyPatch(typeof(UIPauseMenuController), "Start")] [HarmonyPostfix] public static void AddUIItems(UIPauseMenuController __instance) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) Transform val = ((Component)__instance).gameObject.transform.Find("PauseMenuContainer"); FontHelpers._pauseMenu = ((TMP_Text)((Component)((Component)((Component)((Component)((Component)val.Find("Left")).transform.Find("Transform")).transform.Find("MenuContainer")).transform.Find("Settings")).transform.Find("Text")).GetComponent()).font; GameObject container = new GameObject("COTL_API_MenuContainer"); container.transform.SetParent(val); container.layer = LayerMask.op_Implicit(UIHelpers.UILayer); container.transform.position = Vector3.zero; container.transform.localScale = Vector3.one; UIMenuBase.Parent = container.transform; PauseMenuQueue.ForEach(delegate(Type x) { container.AddComponent(x); }); } } [HarmonyPatch] public static class StartMenuPatch { [HarmonyPatch(typeof(MainMenuController), "Start")] [HarmonyPostfix] public static void AddUIItems(MainMenuController __instance) { FontHelpers._startMenu = ((TMP_Text)((Component)((Component)((Component)((Component)((Component)((Component)((Component)((Component)((Component)__instance).gameObject.transform.Find("Main Menu")).transform.Find("MainMenuContainer")).transform.Find("Left")).transform.Find("Transform")).transform.Find("MenusContainer")).transform.Find("MainMenu")).transform.Find("Settings")).transform.Find("Text (TMP)")).GetComponent()).font; } } public static readonly List PauseMenuQueue = new List(); public static readonly List StartMenuQueue = new List(); } } namespace COTL_API.Helpers { public static class OnInteractHelper { [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyPatch(typeof(Interaction), "OnInteract")] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] public static void Interaction_OnInteract(Interaction instance, StateMachine state) { if ((Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.Debug) { LogHelper.LogWarning($"Interaction.OnInteract Test({instance}, {state})"); } } } internal static class Debugging { public static void PrintStatistics(bool printNames = false) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) Dictionary customItemList = CustomItemManager.CustomItemList; LogHelper.LogInfo($"Items: {customItemList.Count}"); if (printNames) { foreach (KeyValuePair item in customItemList) { LogHelper.LogInfo($"{item.Key}: {item.Value.InternalName}"); } } Dictionary customEffectList = CustomFoodEffectManager.CustomEffectList; LogHelper.LogInfo($"Meal Effects: {customEffectList.Count}"); if (printNames) { foreach (KeyValuePair item2 in customEffectList) { LogHelper.LogInfo($"{item2.Key}: {item2.Value.InternalName}"); } } Dictionary customStructureList = CustomStructureManager.CustomStructureList; LogHelper.LogInfo($"Structures: {customStructureList.Count}"); if (printNames) { foreach (KeyValuePair item3 in customStructureList) { LogHelper.LogInfo($"{item3.Key}: {item3.Value.InternalName}"); } } Dictionary customTaskList = CustomTaskManager.CustomTaskList; LogHelper.LogInfo($"Tasks: {customTaskList.Count}"); if (printNames) { foreach (KeyValuePair item4 in customTaskList) { LogHelper.LogInfo($"{item4.Key}: {item4.Value.InternalName}"); } } Dictionary customFollowerCommandList = CustomFollowerCommandManager.CustomFollowerCommandList; LogHelper.LogInfo($"Commands: {customFollowerCommandList.Count}"); if (printNames) { foreach (KeyValuePair item5 in customFollowerCommandList) { LogHelper.LogInfo($"{item5.Key}: {item5.Value.InternalName}"); } } Dictionary customMissionList = CustomMissionManager.CustomMissionList; LogHelper.LogInfo($"Missions: {customMissionList.Count}"); if (printNames) { foreach (KeyValuePair item6 in customMissionList) { LogHelper.LogInfo($"{item6.Key}: {item6.Value.InternalName}"); } } Dictionary customObjectiveList = CustomObjectiveManager.CustomObjectiveList; LogHelper.LogInfo($"Objectives: {customObjectiveList.Count}"); if (printNames) { foreach (KeyValuePair item7 in customObjectiveList) { LogHelper.LogInfo($"{item7.Key}: {item7.Value.InitialQuestText}"); } } Dictionary customRelicDataList = CustomRelicManager.CustomRelicDataList; LogHelper.LogInfo($"Relics: {customRelicDataList.Count}"); if (printNames) { foreach (KeyValuePair item8 in customRelicDataList) { LogHelper.LogInfo($"{item8.Key}: {item8.Value.InternalName}"); } } Dictionary prefabStrings = CustomPrefabManager.PrefabStrings; LogHelper.LogInfo($"Prefabs: {prefabStrings.Count}"); if (!printNames) { return; } foreach (KeyValuePair item9 in prefabStrings) { LogHelper.LogInfo(item9.Key + ": " + item9.Value.InternalName); } } } public static class Extensions { public static bool TryAdd(this IDictionary dictionary, TKey key, TValue value) { if (dictionary.ContainsKey(key)) { return false; } dictionary.Add(key, value); return true; } } public static class HashCode { public static int GetNameHashCode(string str) { return str.Aggregate(0, (int current, char c) => (current << 3) - current + c); } public static int GetValueHashCode(string str) { return str.Aggregate(0, (int current, char c) => ((current << 5) + current) ^ c); } } public static class ItemPickUp { public static string GetItemPickUpPath(ITEM_TYPE type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected I4, but got Unknown return (type - 1) switch { 0 => "Log", 1 => "Rock1", 2 => "Rock2", 3 => "Rock3", 4 => "Seed - Sword", 5 => "Meat", 6 => "Wheat", 7 => "Seed", 8 => "VileBones", 9 => "Soul", 10 => "GildedVine", 11 => "Red Heart", 12 => "Half Heart", 13 => "Blue Heart", 14 => "Half Blue Heart", 15 => "Time Token", 16 => "Generic Pick Up", 17 => "StainedGlass", 18 => "SacredFlower", 19 => (!DungeonSandboxManager.Active) ? "BlackGold" : "ChallengeGold", 20 => "Berries", 21 => "Monster Heart", 25 => "TarotCard", 26 => "SoulFragment", 27 => "Fish", 28 => "Mushroom Small", 29 => "Black Soul", 30 => "Mushroom Big", 31 => "Assets/Prefabs/Structures/Other/Meal.prefab", 32 => "Fish Small", 33 => "Fish Big", 34 => "Grass", 35 => "Thorns", 36 => "Key Piece", 38 => "Poop", 39 => "FoundItem", 40 => "FoundItemWeapon", 41 => "FoundItemCurse", 42 => "Gift Small", 43 => "Gift Medium", 44 => "Necklace 1", 45 => "Necklace 2", 46 => "Necklace 3", 47 => "Necklace 4", 48 => "Necklace 5", 49 => "Pumpkin", 50 => "Seed Pumpkin", 51 => "FoundItemSkin", 52 => "Black Heart", 53 => "Permanent Half Heart", 54 => "Flower_red", 55 => "Flower_White", 56 => "Assets/Prefabs/Structures/Other/Meal Grass.prefab", 57 => "Assets/Prefabs/Structures/Other/Meal Good.prefab", 58 => "Assets/Prefabs/Structures/Other/Meal Great.prefab", 59 => "Assets/Prefabs/Structures/Other/Meal Good Fish.prefab", 60 => "Meat Rotten", 61 => "Follower Meat", 62 => "Follower Meat", 64 => "Assets/Prefabs/Structures/Other/Meal Follower Meat.prefab", 68 => "Assets/Prefabs/Structures/Other/Meal Poop.prefab", 69 => "Seed Mushroom", 70 => "Seed White Flower", 71 => "Seed Red Flower", 72 => "Grass 2", 73 => "Grass 3", 74 => "Grass 4", 75 => "Grass 5", 76 => "Flower_Purple", 77 => "Seed_tree", 78 => "FoundItemMap", 79 => "Assets/Prefabs/Structures/Other/Meal Mushrooms.prefab", 80 => "Log Refined", 81 => "Stone Refined", 82 => "Gold Nugget", 83 => "Rope", 85 => "Gold Refined", 86 => "Bloodstone", 87 => "TarotCardUnlocked", 88 => "Crystal", 89 => "Spider Web", 90 => "Fish Crab", 91 => "Fish Lobster", 92 => "Fish Octopus", 93 => "Fish Squid", 94 => "Fish Swordfish", 95 => "Fish Blowfish", 96 => "Beetroot", 97 => "Seed Beetroot", 98 => "Assets/Prefabs/Structures/Other/Meal Great Fish.prefab", 99 => "Assets/Prefabs/Structures/Other/Meal Bad Fish.prefab", 100 => "Beholder Eye", 101 => "Cauliflower", 102 => "Seed Cauliflower", 104 => "Meat Morsel", 105 => "Assets/Prefabs/Structures/Other/Meal Berries.prefab", 106 => "Assets/Prefabs/Structures/Other/Meal Medium Veg.prefab", 107 => "Assets/Prefabs/Structures/Other/Meal Bad Mixed.prefab", 108 => "Assets/Prefabs/Structures/Other/Meal Medium Mixed.prefab", 109 => "Assets/Prefabs/Structures/Other/Meal Great Mixed.prefab", 110 => "Assets/Prefabs/Structures/Other/Meal Deadly.prefab", 111 => "Assets/Prefabs/Structures/Other/Meal Bad Meat.prefab", 112 => "Assets/Prefabs/Structures/Other/Meal Great Meat.prefab", 114 => "Assets/Prefabs/Structures/Other/Meal Burned.prefab", 115 => "Doctrine Stone Piece", 116 => "Shell", 117 => "Relic", 118 => "God Tear", 121 => "Necklace Loyalty", 122 => "Necklace Demonic", 123 => "Necklace Dark", 124 => "Necklace Light", 125 => "Necklace Missionary", 126 => "Necklace Gold Skull", 128 => "Assets/Prefabs/Structures/Buildings/Webber Skull.prefab", 129 => "Snow Chunk", 130 => "Charcoal", 131 => "Silk Thread", 132 => "Cotton", 134 => "Fish Cod", 135 => "Fish Pike", 136 => "Fish Catfish", 137 => "FoundItem_Outfit", 138 => "Lightning Shard", 139 => "Seed Cotton", 140 => "LoreStone", 141 => "Poop Gold", 142 => "Poop Rainbow", 143 => "Poop Glow", 149 => "Hops", 150 => "Grapes", 151 => "Seed Hops", 152 => "Seed Grapes", 154 => "Assets/Prefabs/Structures/Buildings/Egg Follower.prefab", 158 => "Yolk", 160 => "Assets/Prefabs/Structures/Other/Meal Egg.prefab", 161 => "Poop Devotion", 162 => "Necklace Bell", _ => "Poop", }; } public static GameObject? GetItemPickUpObject(ITEM_TYPE type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) LogHelper.LogWarning($"ImitatePickUpObject: {type}"); string itemPickUpPath = GetItemPickUpPath(type); LogHelper.LogWarning("ImitateItemPickUpText: " + itemPickUpPath); if (!itemPickUpPath.EndsWith(".prefab", StringComparison.InvariantCultureIgnoreCase)) { Object obj = Resources.Load("Prefabs/Resources/" + itemPickUpPath); return (GameObject?)(object)((obj is GameObject) ? obj : null); } Object obj2 = Resources.Load(itemPickUpPath); return (GameObject?)(object)((obj2 is GameObject) ? obj2 : null); } public static bool ShouldUseObjectPool(ITEM_TYPE type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_0061: 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_00ae: Expected I4, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected I4, but got Unknown if ((int)type <= 80) { if ((int)type <= 65) { if ((int)type == 32) { return true; } switch (type - 57) { case 0: return true; case 1: return true; case 2: return true; case 3: return true; case 8: return true; } } else { if ((int)type == 69) { return true; } if ((int)type == 80) { return true; } } } else if ((int)type <= 129) { switch (type - 99) { default: if ((int)type != 129) { break; } return true; case 0: return true; case 1: return true; case 7: return true; case 8: return true; case 9: return true; case 10: return true; case 11: return true; case 12: return true; case 13: return true; case 14: return true; case 16: return true; case 2: case 3: case 4: case 5: case 6: case 15: break; } } else { if ((int)type == 155) { return true; } if ((int)type == 161) { return true; } } return false; } } public static class KeyCodes { public static string KeyCodeToString(KeyCode keyCode) { return ((object)(KeyCode)(ref keyCode)).ToString(); } public static KeyCode StringToKeyCode(string keyCodeString) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)Enum.Parse(typeof(KeyCode), keyCodeString, ignoreCase: true); } public static string[] GetKeyCodeOptions() { return Enum.GetNames(typeof(KeyCode)); } } internal static class LogHelper { internal static void Log(LogLevel level, object? data) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Plugin.Instance == (Object)null)) { Plugin.Instance.Logger.Log(level, data); } } internal static void LogFatal(object? data) { Log((LogLevel)1, data); } internal static void LogError(object? data) { Log((LogLevel)2, data); } internal static void LogWarning(object? data) { Log((LogLevel)4, data); } internal static void LogMessage(object? data) { Log((LogLevel)8, data); } internal static void LogInfo(object? data) { Log((LogLevel)16, data); } internal static void LogDebug(object data) { if (!((Object)(object)Plugin.Instance == (Object)null) && Plugin.Instance.Debug) { Log((LogLevel)8, data); } } } internal static class PluginPaths { internal static string ResolvePath(params string[] paths) { string text = (((Object)(object)Plugin.Instance != (Object)null) ? Plugin.Instance.PluginPath : ""); int num = 0; string[] array = new string[1 + paths.Length]; array[num] = text; num++; foreach (string text2 in paths) { array[num] = text2; num++; } return Path.Combine(array); } internal static string ResolveAssetPath(params string[] paths) { return ResolvePath("Assets", Path.Combine(paths)); } } public static class TaskUtils { public static Structure? GetAvailableStructureOfType() { return ((IEnumerable)Structure.Structures).FirstOrDefault((Func)delegate(Structure str) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) if (str.Structure_Info?.Type == (TYPES?)CustomStructureManager.GetStructureByType()) { StructureBrain brain = str.Brain; if (brain != null) { return !brain.ReservedForTask; } return false; } return false; }); } } public static class TextureHelper { private static readonly Dictionary SpriteCache = new Dictionary(); private static readonly Dictionary TextureCache = new Dictionary(); public static Texture2D CreateTextureFromPath(string path, TextureFormat textureFormat = 4, bool mipmaps = false, bool linear = false) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown if (TextureCache.TryGetValue(path, out Texture2D value)) { return value; } Texture2D val = new Texture2D(1, 1, textureFormat, mipmaps, linear) { filterMode = (FilterMode)0 }; ImageConversion.LoadImage(val, File.ReadAllBytes(path)); TextureCache[path] = val; return val; } public static Sprite CreateSpriteFromPath(string path) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (SpriteCache.TryGetValue(path, out Sprite value)) { return value; } Texture2D val = CreateTextureFromPath(path, (TextureFormat)4); Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); SpriteCache[path] = val2; return val2; } } } namespace COTL_API.Guid { public static class GuidManager { private const int StartIndex = 5000; private const string MaxDataKey = "maximumStoredValueForEnum"; private static readonly Dictionary ReverseMapper = new Dictionary(); public static string GetFullyQualifiedName(string guid, string value) { return guid + "_" + value; } public static Type? GetEnumType(int number) { ReverseMapper.TryGetValue(number, out Type value); return value; } public unsafe static List GetValues() where T : unmanaged, Enum { List list = Enum.GetValues(typeof(T)).Cast().ToList(); string value = typeof(T).Name + "_"; foreach (KeyValuePair enumDatum in Plugin.EnumData) { if (enumDatum.Key.StartsWith(value)) { int num = int.Parse((string)enumDatum.Value); T item = *(T*)(&num); list.Add(item); } } return list; } public unsafe static T GetEnumValue(string guid, string value) where T : unmanaged, Enum { if (sizeof(T) != 4) { throw new NotSupportedException("Cannot manage values of type " + typeof(T).Name + " in GuidManager.GetEnumValue"); } string key = typeof(T).Name + "_" + guid + "_" + value; int num = Plugin.EnumData.GetValueAsInt(key); if (num == 0) { num = Plugin.EnumData.GetValueAsInt("maximumStoredValueForEnum"); if (num < 5000) { num = 5000; } Plugin.EnumData.SetValue("maximumStoredValueForEnum", (long)(num + 1)); Plugin.EnumData.SetValue(key, (long)num); Plugin.Instance.APIData.Save(); } ReverseMapper[num] = typeof(T); return *(T*)(&num); } } [HarmonyPatch] public static class TypeManager { private static readonly Dictionary TypeCache = new Dictionary(); private static readonly Dictionary ModIds = new Dictionary(); internal static void Add(string key, Type value) { if (!TypeCache.ContainsKey(key) || !(TypeCache[key] == value)) { TypeCache.Add(key, value); } } internal static void Replace(string key, Type value) { if (TypeCache.ContainsKey(key)) { TypeCache.Remove(key); } Add(key, value); } private static string GetModIdFromAssembly(Assembly assembly) { if (ModIds.TryGetValue(assembly.FullName, out string value)) { return value; } Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { BepInPlugin customAttribute = ((MemberInfo)types[i]).GetCustomAttribute(); if (customAttribute != null) { ModIds.Add(assembly.FullName, customAttribute.GUID); return customAttribute.GUID; } } ModIds.Add(assembly.FullName, null); return null; } public static string GetModIdFromCallstack(Assembly callingAssembly) { string modIdFromAssembly = GetModIdFromAssembly(callingAssembly); if (!string.IsNullOrEmpty(modIdFromAssembly)) { return modIdFromAssembly; } return new StackTrace().GetFrames()?.Select((StackFrame frame) => GetModIdFromAssembly(frame.GetMethod().DeclaringType?.Assembly)).FirstOrDefault((string newVal) => !string.IsNullOrEmpty(newVal)); } [MethodImpl(MethodImplOptions.NoInlining)] [HarmonyPatch(typeof(CustomType), "GetType", new Type[] { typeof(string), typeof(string) })] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] public static Type OriginalGetType(string nameSpace, string typeName) { throw new NotImplementedException(); } [HarmonyPatch(typeof(CustomType), "GetType", new Type[] { typeof(string), typeof(string) })] [HarmonyPrefix] private static bool CustomType_GetType(string nameSpace, string typeName, ref Type __result) { if (TypeCache.TryGetValue(typeName, out Type value)) { __result = value; return false; } __result = AccessTools.TypeByName(nameSpace + "." + typeName); TypeCache.Add(typeName, __result); return false; } } } namespace COTL_API.Debug { [HarmonyPatch] public class DebugCode { [HarmonyPatch(typeof(InventoryMenu), "OnShowStarted")] [HarmonyPrefix] private static void InventoryMenu_OnShowStarted(InventoryMenu __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Plugin.Instance == (Object)null) && Plugin.Instance.Debug) { Inventory.AddItem(DebugManager.DebugItem, 1, true); Inventory.AddItem(DebugManager.DebugItem2, 1, true); Inventory.AddItem(DebugManager.DebugItem3, 1, true); Inventory.AddItem(DebugManager.DebugItem4, 1, true); if ((Object)(object)PlayerFarming.Instance.playerRelic.CurrentRelic == (Object)null || PlayerFarming.Instance.playerRelic.CurrentRelic.RelicType != DebugManager.DebugRelic) { PlayerFarming.Instance.playerRelic.EquipRelic(EquipmentManager.GetRelicData(DebugManager.DebugRelic), true, false); } CustomObjectiveManager.BedRest("Test").InitialQuestText = "This is my custom quest text for this objective."; } } [HarmonyPatch(typeof(UITarotChoiceOverlayController), "Show")] [HarmonyPrefix] private static bool UITarotChoiceOverlayController_Show(UITarotChoiceOverlayController __instance, TarotCard card1, TarotCard card2, bool instant) { if ((Object)(object)Plugin.Instance == (Object)null || !Plugin.Instance.Debug) { return true; } __instance._card1 = GetRandModdedCard(); __instance._card2 = GetRandVanillaCard(); __instance._uiCard1.Play(__instance._card1); __instance._uiCard2.Play(__instance._card2); ((UIMenuBase)__instance).Show(instant); return false; } internal static TarotCard GetRandVanillaCard() { //IL_0043: 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_004f: Expected O, but got Unknown List list = new List(DataManager.Instance.PlayerFoundTrinkets); list.RemoveAll((Card c) => CustomTarotCardManager.CustomTarotCardList.ContainsKey(c) || PlayerFarming.Instance.RunTrinkets.Any((TarotCard t) => t.CardType == c)); return new TarotCard(list.ElementAt(Random.Range(0, list.Count)), 0); } internal static TarotCard GetRandModdedCard() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return new TarotCard(CustomTarotCardManager.CustomTarotCardList.Keys.ElementAt(Random.Range(0, CustomTarotCardManager.CustomTarotCardList.Count)), 0); } internal static int getTarotMult(Card obj) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) int num = 0; if (DataManager.Instance.dungeonRun < 5) { return Mathf.Min(num, TarotCards.GetMaxTarotCardLevel(obj)); } while (Random.Range(0f, 1f) < 0.275f * DataManager.Instance.GetLuckMultiplier()) { num++; } return Mathf.Min(num, TarotCards.GetMaxTarotCardLevel(obj)); } } public class DebugEnemy : COTL_API.CustomEnemy.CustomEnemy { public override string InternalName => "DebugEnemy"; } public class DebugFollowerCommand : COTL_API.CustomFollowerCommand.CustomFollowerCommand { public override string InternalName => "DEBUG_FOLLOWER_COMMAND"; public override string CommandStringIcon() { return ""; } public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand = 0) { interaction_FollowerInteraction interaction2 = interaction; ((MonoBehaviour)interaction2).StartCoroutine(interaction2.FrameDelayCallback((Action)delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown interaction2.eventListener.PlayFollowerVO(interaction2.generalAcknowledgeVO); interaction2.follower.Brain.HardSwapToTask((FollowerTask)new FollowerTask_InstantPoop()); })); interaction2.Close(true, true, false); } } public class DebugFollowerCommandClass2 : COTL_API.CustomFollowerCommand.CustomFollowerCommand { public override string InternalName => "DEBUG_FOLLOWER_COMMAND_2"; public override List Categories => new List(1) { FollowerCommandCategory.MAKE_DEMAND_COMMAND }; public DebugFollowerCommandClass2() { ((CommandItem)this).SubCommands = FollowerCommandGroups.AreYouSureCommands(); } public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand = 0) { interaction.follower.Brain.MakeDissenter(false); interaction.Close(true, true, false); } } public class DebugFollowerCommandClass3 : COTL_API.CustomFollowerCommand.CustomFollowerCommand { public override string InternalName => "DEBUG_FOLLOWER_COMMAND_3"; public override bool IsAvailable(Follower follower) { return false; } public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand = 0) { interaction.Close(true, true, false); } } public class DebugFollowerSkin : CustomFollowerSkin { public override string Name => "Debug"; public override Texture2D Texture => TextureHelper.CreateTextureFromPath(PluginPaths.ResolveAssetPath("debug_sheet2.png"), (TextureFormat)4); public override List Overrides => new List(4) { new SkinOverride("HEAD_SKIN_TOP_BACK", new Rect(0f, 127f, 111f, 127f)), new SkinOverride("HEAD_SKIN_BTM_BACK", new Rect(0f, 0f, 111f, 127f)), new SkinOverride("HEAD_SKIN_TOP", new Rect(111f, 127f, 149f, 127f)), new SkinOverride("HEAD_SKIN_BTM", new Rect(111f, 0f, 149f, 127f)) }; public override List Colors { get; } = new List(3) { new SlotsAndColours { SlotAndColours = new List(9) { new SlotAndColor("ARM_LEFT_SKIN", new Color(1f, 0f, 0f)), new SlotAndColor("ARM_RIGHT_SKIN", new Color(1f, 0f, 0f)), new SlotAndColor("LEG_LEFT_SKIN", new Color(1f, 0f, 0f)), new SlotAndColor("LEG_RIGHT_SKIN", new Color(1f, 0f, 0f)), new SlotAndColor("Body_Naked", new Color(1f, 0f, 0f)), new SlotAndColor("Body_Naked_Up", new Color(1f, 0f, 0f)), new SlotAndColor("BODY_BTM", new Color(1f, 0f, 0f)), new SlotAndColor("BODY_BTM_UP", new Color(1f, 0f, 0f)), new SlotAndColor("BODY_TOP", new Color(1f, 0.5f, 0f)) } }, new SlotsAndColours { SlotAndColours = new List(9) { new SlotAndColor("ARM_LEFT_SKIN", new Color(0f, 1f, 0f)), new SlotAndColor("ARM_RIGHT_SKIN", new Color(0f, 1f, 0f)), new SlotAndColor("LEG_LEFT_SKIN", new Color(0f, 1f, 0f)), new SlotAndColor("LEG_RIGHT_SKIN", new Color(0f, 1f, 0f)), new SlotAndColor("Body_Naked", new Color(0f, 1f, 0f)), new SlotAndColor("Body_Naked_Up", new Color(0f, 1f, 0f)), new SlotAndColor("BODY_BTM", new Color(0f, 1f, 0f)), new SlotAndColor("BODY_BTM_UP", new Color(0f, 1f, 0f)), new SlotAndColor("BODY_TOP", new Color(0f, 1f, 0.5f)) } }, new SlotsAndColours { SlotAndColours = new List(9) { new SlotAndColor("ARM_LEFT_SKIN", new Color(0f, 0f, 1f)), new SlotAndColor("ARM_RIGHT_SKIN", new Color(0f, 0f, 1f)), new SlotAndColor("LEG_LEFT_SKIN", new Color(0f, 0f, 1f)), new SlotAndColor("LEG_RIGHT_SKIN", new Color(0f, 0f, 1f)), new SlotAndColor("Body_Naked", new Color(0f, 0f, 1f)), new SlotAndColor("Body_Naked_Up", new Color(0f, 0f, 1f)), new SlotAndColor("BODY_BTM", new Color(0f, 0f, 1f)), new SlotAndColor("BODY_BTM_UP", new Color(0f, 0f, 1f)), new SlotAndColor("BODY_TOP", new Color(0.5f, 0f, 1f)) } } }; } public class DebugFollowerSkin2 : CustomFollowerSkin { public override string Name => "Debug_1"; public override Texture2D Texture => TextureHelper.CreateTextureFromPath(PluginPaths.ResolveAssetPath("debug_sheet2.png"), (TextureFormat)4); public override List Overrides => new List(4) { new SkinOverride("HEAD_SKIN_TOP_BACK", new Rect(0f, 127f, 111f, 127f)), new SkinOverride("HEAD_SKIN_BTM_BACK", new Rect(0f, 0f, 111f, 127f)), new SkinOverride("HEAD_SKIN_TOP", new Rect(111f, 127f, 149f, 127f)), new SkinOverride("HEAD_SKIN_BTM", new Rect(265f, 0f, 145f, 129f)) }; } public class DebugGiftFollowerCommand : COTL_API.CustomFollowerCommand.CustomFollowerCommand { public override string InternalName => "DEBUG_GIFT_FOLLOWER_COMMAND"; public override bool ShouldAppearFor(Follower follower) { return false; } public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand = 0) { interaction_FollowerInteraction interaction2 = interaction; if (!((Object)(object)Plugin.Instance == (Object)null)) { ((MonoBehaviour)interaction2).StartCoroutine(interaction2.FrameDelayCallback((Action)delegate { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) interaction2.eventListener.PlayFollowerVO(interaction2.positiveAcknowledgeVO); interaction2.follower.Brain.HardSwapToTask((FollowerTask)new FollowerTask_InstantPoop()); Inventory.ChangeItemQuantity(DebugManager.DebugItem, -1, 0); })); interaction2.Close(true, true, false); } } } public class DebugItemClass : CustomInventoryItem { public override string InternalName => "DEBUG_ITEM"; public override CustomInventoryItemType InventoryItemType => CustomInventoryItemType.CURRENCY; public override bool IsCurrency => true; public override bool IsBurnableFuel => true; public override int FuelWeight => 100; public override bool CanBeGivenToFollower => true; public override FollowerCommands GiftCommand => DebugManager.DebugGiftFollowerCommand; } public class DebugItemClass2 : CustomCrop { public override string InternalName => "DEBUG_ITEM_2"; public override CustomInventoryItemType InventoryItemType => CustomInventoryItemType.FOOD; public override bool IsFood => true; public override List HarvestResult { get; } = new List(2) { DebugManager.DebugItem, DebugManager.DebugItem2 }; } public class DebugItemClass3 : CustomInventoryItem { public override string InternalName => "DEBUG_ITEM_3"; } public class DebugItemClass4 : CustomInventoryItem { public override string InternalName => "DEBUG_ITEM_4"; public override ITEM_TYPE ItemPickUpToImitate => (ITEM_TYPE)20; public override CustomItemManager.ItemRarity Rarity => CustomItemManager.ItemRarity.COMMON; public override bool AddItemToDungeonChests => true; public override int DungeonChestSpawnChance => 15; public override int DungeonChestMinAmount => 4; public override int DungeonChestMaxAmount => 7; public override bool AddItemToOfferingShrine => true; public override Vector3 LocalScale { get; } = new Vector3(0.6f, 0.6f, 0.6f); } internal class DebugManager { internal static bool DebugContentAdded; internal static Dictionary CustomClassMappings = new Dictionary { { typeof(InventoryItem), typeof(CustomInventoryItem) }, { typeof(TarotCards), typeof(COTL_API.CustomTarotCard.CustomTarotCard) }, { typeof(FollowerTrait), typeof(CustomTrait) } }; internal static List PatchedClass = new List(76) { typeof(CropController), typeof(StructuresData), typeof(StructureBrain), typeof(FarmPlot), typeof(Interaction_Berries), typeof(InventoryItem), typeof(ObjectPool), typeof(ItemInfoCard), typeof(Interaction_AddFuel), typeof(Inventory), typeof(FollowerCommandGroups), typeof(FollowerCommandItems), typeof(FontImageNames), typeof(InventoryIconMapping), typeof(CookingData), typeof(InventoryMenu), typeof(Structures_Refinery), typeof(UIMenuBase), typeof(RefineryInfoCard), typeof(Interaction_Chest), typeof(InventoryItemDisplay), typeof(Interaction_OfferingShrine), typeof(Structures_OfferingShrine), typeof(RecipeInfoCard), typeof(interaction_FollowerInteraction), typeof(Meal), typeof(FollowerTask_EatMeal), typeof(UISettingsMenuController), typeof(GraphicsSettings), typeof(UIPauseMenuController), typeof(MainMenuController), typeof(SkeletonData), typeof(CharacterSkinAlerts), typeof(Graphics), typeof(FollowerInformationBox), typeof(UIFollowerIndoctrinationMenuController), typeof(PlayerFarming), typeof(FollowerTrait), typeof(FollowerCategory), typeof(TypeAndPlacementObjects), typeof(Structure), typeof(AddressablesImpl), typeof(ResourceManager), typeof(ControlUtilities), typeof(LocationManager), typeof(GenerateRoom), typeof(UIFollowerInteractionWheelOverlayController), typeof(LoadMainMenu), typeof(MMHorizontalSelector), typeof(LoadMenu), typeof(TMP_SpriteAsset), typeof(AchievementsWrapper), typeof(TermData), typeof(LanguageSourceData), typeof(GameSettings), typeof(Quests), typeof(UIWeaponCard), typeof(TarotInfoCard), typeof(TarotCards), typeof(LocalizationManager), typeof(RelicData), typeof(PlayerRelic), typeof(EquipmentManager), typeof(CommandItem), typeof(AudioSettings), typeof(SaveAndLoad), typeof(MissionInfoCard), typeof(MissionaryManager), typeof(CustomType), typeof(UIRitualsMenuController), typeof(RitualItem), typeof(RitualIconMapping), typeof(UpgradeSystem), typeof(Interaction_TempleAltar), typeof(Interaction), typeof(UITarotChoiceOverlayController) }; internal static ITEM_TYPE DebugItem { get; private set; } internal static ITEM_TYPE DebugItem2 { get; private set; } internal static ITEM_TYPE DebugItem3 { get; private set; } internal static ITEM_TYPE DebugItem4 { get; private set; } internal static FollowerCommands DebugGiftFollowerCommand { get; private set; } internal static RelicType DebugRelic { get; private set; } private static string BeautifyNamespace(string? str) { if ((str != null && !(str == "")) || 1 == 0) { return str + "."; } return ""; } internal static void ShowPatches(Type a) { Type a2 = a; IEnumerable source = from methodBase in Plugin.Instance._harmony.GetPatchedMethods() where methodBase.DeclaringType == a2 select methodBase; MethodInfo[] methods = a2.GetMethods(); foreach (MethodInfo methodInfo in methods) { LogHelper.LogDebug(source.Contains(methodInfo) ? (BeautifyNamespace(a2.Namespace) + a2.Name + "." + methodInfo.Name + ": Patched") : (BeautifyNamespace(a2.Namespace) + a2.Name + "." + methodInfo.Name + ": Unpatched")); } } internal static void ShowPatchedClasses() { foreach (Type item in PatchedClass) { ShowPatches(item); } } internal static void ShowDiff(Type a, Type b) { LogHelper.LogDebug("Showing diff between " + BeautifyNamespace(a.Namespace) + a.Name + " and " + BeautifyNamespace(b.Namespace) + b.Name); LogHelper.LogDebug("Methods"); MethodInfo[] methods = a.GetMethods(); foreach (MethodInfo method in methods) { if (method.Name.StartsWith("get_") || method.Name.StartsWith("set_")) { continue; } MethodInfo methodInfo = b.GetMethods().FirstOrDefault((MethodInfo m) => m.Name == method.Name); if ((object)methodInfo == null) { LogHelper.LogDebug(BeautifyNamespace(a.Namespace) + a.Name + "." + method.Name + ": missing corrsponding method"); continue; } if (!method.ReturnType.IsAssignableFrom(methodInfo.ReturnType)) { LogHelper.LogDebug(BeautifyNamespace(a.Namespace) + a.Name + "." + method.Name + " and " + BeautifyNamespace(b.Namespace) + b.Name + "." + method.Name + " have mismatched return type"); continue; } ParameterInfo[] corrospondingParameters = method.GetParameters(); ParameterInfo[] array = method.GetParameters(); if (array.Length == 1 && array[0].GetType().IsEnum) { array = array.Skip(1).ToArray(); } if (array.Length != corrospondingParameters.Length || !array.All((ParameterInfo info) => info.ParameterType.IsAssignableFrom(corrospondingParameters[info.Position].ParameterType))) { LogHelper.LogDebug(BeautifyNamespace(a.Namespace) + a.Name + "." + method.Name + " and " + BeautifyNamespace(b.Namespace) + b.Name + "." + method.Name + " have mismatched parameters"); LogHelper.LogDebug($"{BeautifyNamespace(a.Namespace)}{a.Name}.{method.Name}: {array}"); LogHelper.LogDebug($"{BeautifyNamespace(b.Namespace)}{b.Name}.{method.Name}: {corrospondingParameters}"); } else { LogHelper.LogDebug(BeautifyNamespace(a.Namespace) + a.Name + "." + method.Name + " matches " + BeautifyNamespace(b.Namespace) + b.Name + "." + method.Name); } } } internal static void CheckCustomClasses() { foreach (KeyValuePair customClassMapping in CustomClassMappings) { ShowDiff(customClassMapping.Key, customClassMapping.Value); } } internal static void AddDebugContent() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) if (!DebugContentAdded) { CustomLocalizationManager.LoadLocalization("English", PluginPaths.ResolveAssetPath("English-Debug.language")); CustomSkinManager.AddFollowerSkin(new List(2) { new DebugFollowerSkin(), new DebugFollowerSkin2() }); CustomSkinManager.AddPlayerSkin(new DebugPlayerSkin()); CustomFollowerCommandManager.Add(new DebugFollowerCommand()); CustomFollowerCommandManager.Add(new DebugFollowerCommandClass2()); CustomFollowerCommandManager.Add(new DebugFollowerCommandClass3()); DebugGiftFollowerCommand = CustomFollowerCommandManager.Add(new DebugGiftFollowerCommand()); DebugItem = CustomItemManager.Add(new DebugItemClass()); DebugItem2 = CustomItemManager.Add(new DebugItemClass2()); DebugItem3 = CustomItemManager.Add(new DebugItemClass3()); DebugItem4 = CustomItemManager.Add(new DebugItemClass4()); CustomStructureManager.Add(new DebugStructure()); CustomStructureManager.Add(new DebugStructure2()); CustomStructureManager.Add(new DebugStructure3()); CustomTarotCardManager.Add(new DebugTarotCard()); CustomTaskManager.Add(new DebugTask()); CustomObjectiveManager.BedRest("Test").InitialQuestText = "This is my custom quest text for this objective."; CustomSettingsManager.AddDropdown("Debug", "Dropdown", "Option 1", new string[3] { "Option 1", "Option 2", "Option 3" }, delegate(int i) { LogHelper.LogDebug($"Dropdown selected {i}"); }); CustomSettingsManager.AddKeyboardShortcutDropdown("Debug", "Keyboard Shortcut", (KeyCode)0, delegate(KeyboardShortcut i) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) LogHelper.LogDebug($"Keyboard Shortcut selected {i}"); }); CustomSettingsManager.AddHorizontalSelector("Debug", "Horizontal Selector", "Option 1", new string[3] { "Option 1", "Option 2", "Option 3" }, delegate(int i) { LogHelper.LogDebug($"Horizontal Selector selected {i}"); }); CustomSettingsManager.AddSlider("Debug", "Slider", 0f, -100f, 100f, 1, (ValueDisplayFormat)1, delegate(float i) { LogHelper.LogDebug($"Slider value: {i}"); }); CustomSettingsManager.AddToggle("Debug", "Toggle", value: true, delegate(bool i) { LogHelper.LogDebug($"Toggled: {i}"); }); DebugRelic = CustomRelicManager.Add(ScriptableObject.CreateInstance()); LogHelper.LogDebug("Debug mode enabled!"); DebugContentAdded = true; } } } public class DebugPlayerSkin : CustomPlayerSkin { public override string Name => "Debug"; public override Texture2D Texture => TextureHelper.CreateTextureFromPath(PluginPaths.ResolveAssetPath("debug_lamb_sheet.png"), (TextureFormat)4); public override List Overrides => new List(6) { new SkinOverride("HeadBack", new Rect(0f, 0f, 128f, 128f)), new SkinOverride("HeadBackDown", new Rect(128f, 0f, 128f, 128f)), new SkinOverride("HeadBackDown_RITUAL", new Rect(0f, 128f, 128f, 128f)), new SkinOverride("HeadBackDown_SERMON", new Rect(128f, 128f, 128f, 128f)), new SkinOverride("HeadFront", new Rect(256f, 0f, 128f, 128f)), new SkinOverride("HeadFrontDown", new Rect(256f, 128f, 128f, 128f)) }; } public class DebugRelicClass : CustomRelicData { public override string InternalName => "DEBUG_RELIC"; public override bool CanBeBlessed => true; public override bool CanBeDamned => true; public override string GetDescriptionLocalisation() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 RelicSubType relicSubType = ((RelicData)this).RelicSubType; if ((int)relicSubType != 1) { if ((int)relicSubType == 2) { return "Gain 10 gold."; } return "Gain 5 gold."; } return "Gain 5 poop."; } public override void Init() { ((RelicData)this).UISprite = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); ((RelicData)this).UISpriteOutline = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); ((RelicData)this).CleansedSprite = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); ((RelicData)this).CleansedSpriteOutline = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); ((RelicData)this).DamageRequiredToCharge = 5f; } public override void OnUse(bool forceConsumableAnimation = false) { Inventory.AddItem((ITEM_TYPE)20, 5, false); } public override void OnUseDamned(bool forceConsumableAnimation = false) { Inventory.AddItem((ITEM_TYPE)39, 5, false); } public override void OnUseBlessed(bool forceConsumableAnimation = false) { Inventory.AddItem((ITEM_TYPE)20, 10, false); } } public class DebugStructure : CustomStructure { public override Sprite Sprite => TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder_1.png")); public override string InternalName => "DEBUG_STRUCTURE"; public override Vector2Int Bounds => new Vector2Int(1, 1); public override int BuildDurationMinutes => 15; public override List Cost => new List(1) { new ItemCost(DebugManager.DebugItem, 1) }; } public class DebugStructure2 : CustomStructure { public override Sprite Sprite => TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder_2.png")); public override string InternalName => "DEBUG_STRUCTURE_2"; public override Category Category => (Category)1; public override Vector2Int Bounds => new Vector2Int(2, 2); public override int BuildDurationMinutes => 30; public override List Cost => new List(1) { new ItemCost(DebugManager.DebugItem2, 2) }; } public class DebugStructure3 : CustomStructure { public override Sprite Sprite => TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder_3.png")); public override string InternalName => "DEBUG_STRUCTURE_3"; public override Category Category => (Category)2; public override Vector2Int Bounds => new Vector2Int(3, 3); public override int BuildDurationMinutes => 45; public override List Cost => new List(1) { new ItemCost(DebugManager.DebugItem3, 3) }; } public class DebugTarotCard : COTL_API.CustomTarotCard.CustomTarotCard { public override string InternalName => "DEBUG_TAROT_CARD"; public override float GetMovementSpeedMultiplier(TarotCard card) { return 25f; } public override void ApplyInstantEffects(TarotCard card) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) HealthPlayer component = ((Component)PlayerFarming.Instance).GetComponent(); ((Health)component).BlueHearts = ((Health)component).BlueHearts + 50f; Vector3 position = PlayerFarming.Instance.CameraBone.transform.position; BiomeConstants.Instance.EmitHeartPickUpVFX(position, 0f, "blue", "burst_big", true); AudioManager.Instance.PlayOneShot("event:/player/collect_blue_heart", position); } } public class DebugTask : CustomTask { private Follower? _follower; private float _progress; private Structure? _structure; public override string InternalName => "DEBUG_TASK"; public override bool BlockReactTasks => true; public override bool BlockTaskChanges => true; public override FollowerLocation Location => GetStructure().Brain.Data.Location; private Structure GetStructure() { if ((Object)(object)_structure != (Object)null) { return _structure; } return _structure = TaskUtils.GetAvailableStructureOfType(); } public override void TaskTick(float deltaGameTime) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (!((Object)(object)_follower == (Object)null) && (int)((FollowerTask)this).State == 4) { _progress += deltaGameTime; if (_progress >= 50f) { _follower.Brain.AddAdoration((AdorationActions)22, (Action)null); _progress -= 50f; } if (_follower.Brain.Stats.Adoration >= _follower.Brain.Stats.MAX_ADORATION) { ((FollowerTask)this).Complete(); } } } public override void ClaimReservations() { GetStructure().Brain.ReservedForTask = true; } public override void ReleaseReservations() { GetStructure().Brain.ReservedForTask = false; } public override void Setup(Follower follower) { ((FollowerTask)this).Setup(follower); _follower = follower; follower.SetHat((FollowerHatType)6); } public override void Cleanup(Follower follower) { follower.SetHat((FollowerHatType)0); ((FollowerTask)this).Cleanup(follower); } public override Vector3 UpdateDestination(Follower follower) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0028: Unknown result type (might be due to invalid IL or missing references) Vector3 position = GetStructure().Brain.Data.Position; return new Vector3(position.x, position.y, position.z); } public override void OnStart() { ((FollowerTask)this).SetState((FollowerTaskState)3); } } public class DebugTaskFollowerCommand : COTL_API.CustomFollowerCommand.CustomFollowerCommand { public override string InternalName => "DEBUG_TASK_FOLLOWER_COMMAND"; public override void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand = 0) { interaction_FollowerInteraction interaction2 = interaction; ((MonoBehaviour)interaction2).StartCoroutine(interaction2.FrameDelayCallback((Action)delegate { interaction2.eventListener.PlayFollowerVO(interaction2.generalAcknowledgeVO); if ((Object)(object)TaskUtils.GetAvailableStructureOfType() == (Object)null) { interaction2.eventListener.PlayFollowerVO(interaction2.negativeAcknowledgeVO); interaction2.CloseAndSpeak("No_Debug_Structures", (Action)null, true); } else { interaction2.follower.Brain.HardSwapToTask((FollowerTask)(object)new DebugTask()); } })); interaction2.Close(true, true, false); } } } namespace COTL_API.CustomTasks { public abstract class CustomTask : FollowerTask { internal string ModPrefix = ""; internal FollowerTaskType TaskType; public abstract string InternalName { get; } public override FollowerTaskType Type => TaskType; public override FollowerLocation Location => (FollowerLocation)1; public override int GetSubTaskCode() { return 0; } public override void TaskTick(float deltaGameTime) { } public override Vector3 UpdateDestination(Follower follower) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)follower == (Object)null)) { return ((Component)follower).transform.position; } return base._brain.LastPosition; } } [HarmonyPatch] [HarmonyPatch] public static class CustomTaskManager { public static Dictionary CustomTaskList { get; } = new Dictionary(); public static FollowerTaskType Add(CustomTask task) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); FollowerTaskType val = (task.TaskType = GuidManager.GetEnumValue(modIdFromCallstack, task.InternalName)); task.ModPrefix = modIdFromCallstack; CustomTaskList.Add(val, task); return val; } } } namespace COTL_API.CustomTarotCard { public abstract class CustomTarotCard { internal Card CardType; internal string ModPrefix = ""; public abstract string InternalName { get; } public virtual CardCategory Category { get; } public virtual Sprite? CustomSprite { get; internal set; } = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual Sprite? CustomBackSprite { get; internal set; } = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual string Skin => "Custom"; public virtual int TarotCardWeight => 150; public virtual int MaxTarotCardLevel => 0; public virtual string AnimationSuffix => "Card " + ModPrefix + "." + InternalName + " Animation Suffix not set"; public virtual bool IsCursedRelated => false; public virtual string LocalisedName() { int upgradeIndex = (from playerRunTrinket in PlayerFarming.Instance.RunTrinkets where playerRunTrinket.CardType == CardType select playerRunTrinket.UpgradeIndex).FirstOrDefault(); return LocalisedName(upgradeIndex); } public virtual string LocalisedName(int upgradeIndex) { StringBuilder stringBuilder = new StringBuilder(""); for (int i = 0; i < upgradeIndex; i++) { stringBuilder.Append("+"); } return upgradeIndex switch { 1 => "", 2 => "", _ => "", } + LocalizationManager.GetTranslation($"TarotCards/{ModPrefix}.{InternalName}/Name{stringBuilder}", true, 0, true, false, (GameObject)null, (string)null, true) + ""; } public virtual string LocalisedDescription() { int upgradeIndex = (from playerRunTrinket in PlayerFarming.Instance.RunTrinkets where playerRunTrinket.CardType == CardType select playerRunTrinket.UpgradeIndex).FirstOrDefault(); return LocalisedDescription(upgradeIndex); } public virtual string LocalisedDescription(int upgradeIndex) { string text = "TarotCards/" + ModPrefix + "." + InternalName + "/Description"; if (upgradeIndex > 0) { text += upgradeIndex; } return LocalizationManager.GetTranslation(text, true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string LocalisedLore() { return LocalizationManager.GetTranslation("TarotCards/" + ModPrefix + "." + InternalName + "/Lore", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual float GetSpiritHeartCount(TarotCard card) { return 0f; } public virtual int GetSpiritAmmoCount(TarotCard card) { return 0; } public virtual float GetWeaponDamageMultiplerIncrease(TarotCard card) { return 0f; } public virtual float GetCurseDamageMultiplerIncrease(TarotCard card) { return 0f; } public virtual float GetWeaponCritChanceIncrease(TarotCard card) { return 0f; } public virtual int GetLootIncreaseModifier(TarotCard card, ITEM_TYPE itemType) { return 0; } public virtual float GetMovementSpeedMultiplier(TarotCard card) { return 0f; } public virtual float GetAttackRateMultiplier(TarotCard card) { return 0f; } public virtual float GetBlackSoulsMultiplier(TarotCard card) { return 0f; } public virtual float GetHealChance(TarotCard card) { return 0f; } public virtual float GetNegateDamageChance(TarotCard card) { return 0f; } public virtual int GetDamageAllEnemiesAmount(TarotCard card) { return 0; } public virtual int GetHealthAmountMultiplier(TarotCard card) { return 0; } public virtual float GetAmmoEfficiency(TarotCard card) { return 0f; } public virtual int GetBlackSoulsOnDamage(TarotCard card) { return 0; } public virtual InventoryItem? GetItemToDrop(TarotCard card) { return null; } public virtual float GetChanceOfGainingBlueHeart(TarotCard card) { return 0f; } public virtual float GetChanceForRelicsMultiplier(TarotCard card) { return 0f; } public virtual float GetRelicChargeMultiplier(TarotCard card) { return 0f; } public virtual void ApplyInstantEffects(TarotCard card) { } } [HarmonyPatch] public static class CustomTarotCardManager { public static Dictionary CustomTarotCardList { get; } = new Dictionary(); public static Card Add(CustomTarotCard card) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); Card val = (card.CardType = GuidManager.GetEnumValue(modIdFromCallstack, card.InternalName)); card.ModPrefix = modIdFromCallstack; CustomTarotCardList.Add(val, card); if (!DataManager.AllTrinkets.Contains(val)) { DataManager.AllTrinkets.Add(val); } return val; } private static void UpdateUIWeaponCard(UIWeaponCard UICard, TarotCard Card) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (CustomTarotCardList.TryGetValue(Card.CardType, out CustomTarotCard value)) { ((TMP_Text)UICard.NameText).text = value.LocalisedName(); ((TMP_Text)UICard.SubtitleText).text = CustomTarotCardList[Card.CardType].LocalisedLore(); ((TMP_Text)UICard.EffectText).text = CustomTarotCardList[Card.CardType].LocalisedDescription(); } } [HarmonyPatch(typeof(UIWeaponCard), "Play")] [HarmonyPostfix] private static void UIWeaponCard_Play(UIWeaponCard __instance, TarotCard Card) { UpdateUIWeaponCard(__instance, Card); } [HarmonyPatch(typeof(UIWeaponCard), "Show")] [HarmonyPostfix] private static void UIWeaponCard_Show(UIWeaponCard __instance, TarotCard Card) { UpdateUIWeaponCard(__instance, Card); } [HarmonyPatch(typeof(TarotInfoCard), "Configure")] [HarmonyPostfix] private static void TarotInfoCard_Configure(TarotInfoCard __instance, TarotCard card) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (CustomTarotCardList.ContainsKey(card.CardType)) { __instance._tarotCard.Configure(card); ((TMP_Text)__instance._itemHeader).text = CustomTarotCardList[card.CardType].LocalisedName(); ((TMP_Text)__instance._itemLore).text = CustomTarotCardList[card.CardType].LocalisedLore(); ((TMP_Text)__instance._itemDescription).text = CustomTarotCardList[card.CardType].LocalisedDescription(); } } [HarmonyPatch(typeof(TarotCards), "GetCardCategory")] [HarmonyPrefix] private static bool TarotCards_GetCardCategory(Card Type, ref CardCategory __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected I4, but got Unknown if (!CustomTarotCardList.TryGetValue(Type, out CustomTarotCard value)) { return true; } __result = (CardCategory)(int)value.Category; return false; } [HarmonyPatch(typeof(TarotCards), "LocalisedName", new Type[] { typeof(Card) })] [HarmonyPrefix] private static bool TarotCards_LocalisedName(Card type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(type, out CustomTarotCard value)) { return true; } __result = value.LocalisedName(); return false; } [HarmonyPatch(typeof(TarotCards), "LocalisedName", new Type[] { typeof(Card), typeof(int) })] [HarmonyPrefix] private static bool TarotCards_LocalisedName(Card Card, int upgradeIndex, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(Card, out CustomTarotCard value)) { return true; } __result = value.LocalisedName(upgradeIndex); return false; } [HarmonyPatch(typeof(TarotCards), "LocalisedDescription", new Type[] { typeof(Card), typeof(PlayerFarming) })] [HarmonyPrefix] private static bool TarotCards_LocalisedDescription(Card Type, PlayerFarming playerFarming, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(Type, out CustomTarotCard value)) { return true; } __result = value.LocalisedDescription(); return false; } [HarmonyPatch(typeof(TarotCards), "LocalisedDescription", new Type[] { typeof(Card), typeof(int), typeof(PlayerFarming) })] [HarmonyPrefix] private static bool TarotCards_LocalisedDescription(Card Type, PlayerFarming playerFarming, int upgradeIndex, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(Type, out CustomTarotCard value)) { return true; } __result = value.LocalisedDescription(upgradeIndex); return false; } [HarmonyPatch(typeof(TarotCards), "LocalisedLore")] [HarmonyPrefix] private static bool TarotCards_LocalisedLore(Card Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(Type, out CustomTarotCard value)) { return true; } __result = value.LocalisedLore(); return false; } [HarmonyPatch(typeof(TarotCards), "Skin")] [HarmonyPrefix] private static bool TarotCards_Skin(Card Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.ContainsKey(Type)) { return true; } if (CustomTarotCardList[Type].Skin == "Custom") { __result = CustomSkinManager.GetOrCreateTarotSkin(CustomTarotCardList[Type].ModPrefix + "." + CustomTarotCardList[Type].InternalName, CustomTarotCardList[Type].CustomSprite, CustomTarotCardList[Type].CustomBackSprite); return false; } __result = CustomTarotCardList[Type].Skin; return false; } [HarmonyPatch(typeof(TarotCards), "GetTarotCardWeight")] [HarmonyPrefix] private static bool TarotCards_GetTarotCardWeight(Card cardType, ref int __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(cardType, out CustomTarotCard value)) { return true; } __result = value.TarotCardWeight; return false; } [HarmonyPatch(typeof(TarotCards), "GetMaxTarotCardLevel")] [HarmonyPrefix] private static bool TarotCards_GetMaxTarotCardLevel(Card cardType, ref int __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(cardType, out CustomTarotCard value)) { return true; } __result = value.MaxTarotCardLevel; return false; } [HarmonyPatch(typeof(TarotCards), "AnimationSuffix")] [HarmonyPrefix] private static bool TarotCards_AnimationSuffix(Card Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(Type, out CustomTarotCard value)) { return true; } __result = value.AnimationSuffix; return false; } [HarmonyPatch(typeof(TarotCards), "IsCurseRelatedTarotCard")] [HarmonyPrefix] private static bool TarotCards_IsCurseRelatedTarotCard(Card card, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card, out CustomTarotCard value)) { return true; } __result = value.IsCursedRelated; return false; } [HarmonyPatch(typeof(TarotCards), "ApplyInstantEffects")] [HarmonyPrefix] private static bool TarotCards_ApplyInstantEffects(TarotCard card) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } value.ApplyInstantEffects(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetSpiritHeartCount")] [HarmonyPrefix] private static bool TarotCards_GetSpiritHeartCount(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetSpiritHeartCount(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetSpiritAmmoCount")] [HarmonyPrefix] private static bool TarotCards_GetSpiritAmmoCount(TarotCard card, ref int __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetSpiritAmmoCount(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetWeaponDamageMultiplerIncrease")] [HarmonyPrefix] private static bool TarotCards_GetWeaponDamageMultiplerIncrease(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetWeaponDamageMultiplerIncrease(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetCurseDamageMultiplerIncrease")] [HarmonyPrefix] private static bool TarotCards_GetCurseDamageMultiplerIncrease(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetCurseDamageMultiplerIncrease(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetWeaponCritChanceIncrease")] [HarmonyPrefix] private static bool TarotCards_GetWeaponCritChanceIncrease(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetWeaponCritChanceIncrease(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetLootIncreaseModifier")] [HarmonyPrefix] private static bool TarotCards_GetLootIncreaseModifier(TarotCard card, ITEM_TYPE itemType, ref int __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetLootIncreaseModifier(card, itemType); return false; } [HarmonyPatch(typeof(TarotCards), "GetMovementSpeedMultiplier")] [HarmonyPrefix] private static bool TarotCards_GetMovementSpeedMultiplier(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetMovementSpeedMultiplier(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetAttackRateMultiplier")] [HarmonyPrefix] private static bool TarotCards_GetAttackRateMultiplier(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetAttackRateMultiplier(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetBlackSoulsMultiplier")] [HarmonyPrefix] private static bool TarotCards_GetBlackSoulsMultiplier(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetBlackSoulsMultiplier(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetHealChance")] [HarmonyPrefix] private static bool TarotCards_GetHealChance(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetHealChance(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetNegateDamageChance")] [HarmonyPrefix] private static bool TarotCards_GetNegateDamageChance(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetNegateDamageChance(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetDamageAllEnemiesAmount")] [HarmonyPrefix] private static bool TarotCards_GetDamageAllEnemiesAmount(TarotCard card, ref int __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetDamageAllEnemiesAmount(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetHealthAmountMultiplier")] [HarmonyPrefix] private static bool TarotCards_GetHealthAmountMultiplier(TarotCard card, ref int __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetHealthAmountMultiplier(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetAmmoEfficiency")] [HarmonyPrefix] private static bool TarotCards_GetAmmoEfficiency(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetAmmoEfficiency(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetBlackSoulsOnDamage")] [HarmonyPrefix] private static bool TarotCards_GetBlackSoulsOnDamage(TarotCard card, ref int __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetBlackSoulsOnDamage(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetItemToDrop")] [HarmonyPrefix] private static bool TarotCards_GetItemToDrop(TarotCard card, ref InventoryItem __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetItemToDrop(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetChanceOfGainingBlueHeart")] [HarmonyPrefix] private static bool TarotCards_GetChanceOfGainingBlueHeart(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetChanceOfGainingBlueHeart(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetChanceForRelicsMultiplier")] [HarmonyPrefix] private static bool TarotCards_GetChanceForRelicsMultiplier(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetChanceForRelicsMultiplier(card); return false; } [HarmonyPatch(typeof(TarotCards), "GetRelicChargeMultiplier")] [HarmonyPrefix] private static bool TarotCards_GetRelicChargeMultiplier(TarotCard card, ref float __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomTarotCardList.TryGetValue(card.CardType, out CustomTarotCard value)) { return true; } __result = value.GetRelicChargeMultiplier(card); return false; } } } namespace COTL_API.CustomStructures { public abstract class CustomStructure : StructureBrain { internal string ModPrefix = ""; internal TYPES StructureType; public abstract string InternalName { get; } public virtual Sprite Sprite { get; } = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual List BuildingParts => new List(); public virtual Category Category => (Category)0; public virtual string PrefabPath => CustomPrefabManager.GetOrCreateBuildingPrefab(this); public virtual int BuildDurationMinutes => 30; public virtual Type? Interaction => null; public virtual Categories StructureCategories => (Categories)14; public virtual Tier Tier => (Tier)0; internal StructuresData StructuresData { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown StructuresData val = new StructuresData { PrefabPath = PrefabPath, Bounds = Bounds }; Vector2Int bounds = Bounds; val.TILE_WIDTH = ((Vector2Int)(ref bounds)).x; bounds = Bounds; val.TILE_HEIGHT = ((Vector2Int)(ref bounds)).y; return val; } } public virtual Vector2Int Bounds => new Vector2Int(1, 1); public virtual List Cost => new List(); internal TypeAndPlacementObject GetTypeAndPlacementObject() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown return new TypeAndPlacementObject { IconImage = Sprite, Category = StructureCategories, PlacementObject = CustomPrefabManager.CreatePlacementObjectFor(this), Type = StructureType, Tier = Tier }; } internal string GetLocalizedNameStatic() { return GetLocalizedName(); } internal string LocalizedName() { return GetLocalizedNameStatic(); } internal string LocalizedDescription() { return GetLocalizedDescription(); } public virtual string LocalizedPros() { return LocalizationManager.GetTranslation("Structures/" + ModPrefix + "." + InternalName + "/Pros", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string LocalizedCons() { return LocalizationManager.GetTranslation("Structures/" + ModPrefix + "." + InternalName + "/Cons", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string GetLocalizedName() { return LocalizationManager.GetTranslation("Structures/" + ModPrefix + "." + InternalName, true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string GetLocalizedName(bool plural, bool withArticle, bool definite) { string text = (definite ? "/Definite" : "/Indefinite"); return LocalizationManager.GetTranslation("Structures/" + ModPrefix + "." + InternalName + (plural ? "/Plural" : "") + ((!withArticle) ? "" : text), true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string GetLocalizedDescription() { return LocalizationManager.GetTranslation("Structures/" + ModPrefix + "." + InternalName + "/Description", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string GetLocalizedLore() { return LocalizationManager.GetTranslation("Structures/" + ModPrefix + "." + InternalName + "/Lore", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual int GetResearchCost() { return 5; } public virtual bool RequiresTempleToBuild() { return true; } public virtual bool GetBuildOnlyOne() { return false; } public virtual string GetBuildSfx() { return "event:/building/finished_wood"; } public virtual bool HiddenUntilUnlocked() { return false; } public virtual bool CanBeFlipped() { return true; } } [HarmonyPatch] [HarmonyPatch] public static class CustomStructureManager { public static Dictionary CustomStructureList { get; } = new Dictionary(); public static TYPES Add(CustomStructure structure) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); TYPES val = (structure.StructureType = GuidManager.GetEnumValue(modIdFromCallstack, structure.InternalName)); structure.ModPrefix = modIdFromCallstack; CustomStructureList.Add(val, structure); if (!StructuresData.AllStructures.Contains(val)) { StructuresData.AllStructures.Add(val); } return val; } public static TYPES GetStructureByType() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) return CustomStructureList.FirstOrDefault>((KeyValuePair x) => ((object)x.Value).GetType() == typeof(T)).Key; } public static CustomStructure GetStructureByPrefabName(string name) { string name2 = name; return CustomStructureList.FirstOrDefault>((KeyValuePair x) => x.Value.PrefabPath == name2 || "Assets/" + x.Value.PrefabPath + ".prefab" == name2).Value; } public static bool CustomStructureExists(string name) { string name2 = name; return CustomStructureList.ToList().Exists((KeyValuePair x) => x.Value.PrefabPath == name2 || "Assets/" + x.Value.PrefabPath + ".prefab" == name2); } internal static GameObject CreateBuildingPart(CustomStructureBuildingData data) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown GameObject val = new GameObject("Part"); val.AddComponent().sprite = data.Sprite; return val; } public static void OverrideStructureBuilding(GameObject existingStructure, List buildingParts) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("CustomBuilding"); val.transform.SetParent(existingStructure.transform); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; LogHelper.LogInfo("Removing old building parts"); SpriteRenderer[] componentsInChildren = existingStructure.GetComponentsInChildren(); foreach (SpriteRenderer val2 in componentsInChildren) { if (!((Object)(object)((Component)val2).gameObject == (Object)(object)existingStructure)) { ((Component)val2).gameObject.SetActive(false); } } foreach (CustomStructureBuildingData buildingPart in buildingParts) { GameObject obj = CreateBuildingPart(buildingPart); obj.transform.SetParent(val.transform); obj.transform.localPosition = new Vector3(buildingPart.Offset.x, buildingPart.Offset.y, buildingPart.Offset.z); obj.transform.localScale = new Vector3(buildingPart.Scale.x, buildingPart.Scale.y, buildingPart.Scale.z); obj.transform.localRotation = Quaternion.Euler(buildingPart.Rotation); } } [HarmonyPatch(typeof(StructureBrain), "CreateBrain")] [HarmonyPrefix] private static bool StructureBrain_CreateBrain(ref StructureBrain __result, StructuresData data) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(data.Type, out CustomStructure value)) { return true; } object? obj = Activator.CreateInstance(((object)value).GetType()); StructureBrain val = (StructureBrain)((obj is StructureBrain) ? obj : null); StructureBrain.ApplyConfigToData(data); if (val != null) { val.Init(data); } StructureBrain.TryAddBrain(ref data.ID, ref val); StructureManager.StructuresAtLocation(data.Location).Add(val); __result = val; return false; } [HarmonyPatch(typeof(StructuresData), "GetInfoByType")] [HarmonyPrefix] private static bool StructuresData_GetInfoByType(ref StructuresData __result, TYPES Type, int variantIndex) { //IL_0005: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.StructuresData; StructuresData val = __result; if (val.PrefabPath == null) { val.PrefabPath = CustomStructureList[Type].PrefabPath; } __result.Type = Type; __result.VariantIndex = variantIndex; __result.IsUpgrade = StructuresData.IsUpgradeStructure(__result.Type); __result.UpgradeFromType = StructuresData.GetUpgradePrerequisite(__result.Type); return false; } [HarmonyPatch(typeof(FollowerCategory), "GetStructuresForCategory")] [HarmonyPostfix] private static void FollowerCategory_GetStructuresForCategory(ref List __result, Category category) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) __result.AddRange(from structure in CustomStructureList.Values where structure.Category == category select structure.StructureType); } [HarmonyPatch(typeof(StructuresData), "GetUnlocked")] [HarmonyPrefix] private static void StructuresData_GetUnlocked(TYPES Types) { //IL_0005: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (CustomStructureList.ContainsKey(Types)) { if (!DataManager.Instance.UnlockedStructures.Contains(Types)) { DataManager.Instance.UnlockedStructures.Add(Types); } if (!DataManager.Instance.RevealedStructures.Contains(Types)) { DataManager.Instance.RevealedStructures.Add(Types); } } } [HarmonyPatch(typeof(TypeAndPlacementObjects), "GetByType")] [HarmonyPrefix] private static bool TypeAndPlacementObjects_GetByType(ref TypeAndPlacementObject __result, TYPES Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.GetTypeAndPlacementObject(); return false; } [HarmonyPatch(typeof(StructuresData), "BuildDurationGameMinutes")] [HarmonyPrefix] private static bool StructuresData_BuildDurationGameMinutes(ref int __result, TYPES Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.BuildDurationMinutes; return false; } [HarmonyPatch(typeof(StructuresData), "GetCost")] [HarmonyPrefix] private static bool StructuresData_GetCost(ref List __result, TYPES Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.Cost; return false; } [HarmonyPatch(typeof(StructuresData), "GetLocalizedNameStatic", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_GetLocalizedNameStatic(TYPES Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.GetLocalizedNameStatic(); return false; } [HarmonyPatch(typeof(StructuresData), "LocalizedName", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_LocalizedName(TYPES Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.LocalizedName(); return false; } [HarmonyPatch(typeof(StructuresData), "LocalizedDescription", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_LocalizedDescription(TYPES Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.LocalizedDescription(); return false; } [HarmonyPatch(typeof(StructuresData), "LocalizedPros", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_LocalizedPros(TYPES Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.LocalizedPros(); return false; } [HarmonyPatch(typeof(StructuresData), "LocalizedCons", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_LocalizedCons(TYPES Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.LocalizedCons(); return false; } [HarmonyPatch(typeof(StructuresData), "GetLocalizedName", new Type[] { })] [HarmonyPrefix] private static bool StructuresData_GetLocalizedName(StructuresData __instance, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(__instance.Type, out CustomStructure value)) { return true; } __result = value.GetLocalizedName(); return false; } [HarmonyPatch(typeof(StructuresData), "GetLocalizedName", new Type[] { typeof(bool), typeof(bool), typeof(bool) })] [HarmonyPrefix] private static bool StructuresData_GetLocalizedName(StructuresData __instance, bool plural, bool withArticle, bool definite, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(__instance.Type, out CustomStructure value)) { return true; } __result = value.GetLocalizedName(plural, withArticle, definite); return false; } [HarmonyPatch(typeof(StructuresData), "GetLocalizedDescription", new Type[] { })] [HarmonyPrefix] private static bool StructuresData_GetLocalizedDescription(StructuresData __instance, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(__instance.Type, out CustomStructure value)) { return true; } __result = value.GetLocalizedDescription(); return false; } [HarmonyPatch(typeof(StructuresData), "GetLocalizedLore", new Type[] { })] [HarmonyPrefix] private static bool StructuresData_GetLocalizedLore(StructuresData __instance, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(__instance.Type, out CustomStructure value)) { return true; } __result = value.GetLocalizedLore(); return false; } [HarmonyPatch(typeof(StructuresData), "GetResearchCost", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_GetResearchCost(TYPES Type, ref int __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.GetResearchCost(); return false; } [HarmonyPatch(typeof(StructuresData), "RequiresTempleToBuild", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_RequiresTempleToBuild(TYPES type, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(type, out CustomStructure value)) { return true; } __result = value.RequiresTempleToBuild(); return false; } [HarmonyPatch(typeof(StructuresData), "GetBuildOnlyOne", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_GetBuildOnlyOne(TYPES Type, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.GetBuildOnlyOne(); return false; } [HarmonyPatch(typeof(StructuresData), "GetBuildSfx", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_GetBuildSfx(TYPES Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(Type, out CustomStructure value)) { return true; } __result = value.GetBuildSfx(); return false; } [HarmonyPatch(typeof(StructuresData), "HiddenUntilUnlocked", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_HiddenUntilUnlocked(TYPES structure, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(structure, out CustomStructure value)) { return true; } __result = value.HiddenUntilUnlocked(); return false; } [HarmonyPatch(typeof(StructuresData), "CanBeFlipped", new Type[] { typeof(TYPES) })] [HarmonyPrefix] private static bool StructuresData_CanBeFlipped(TYPES type, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomStructureList.TryGetValue(type, out CustomStructure value)) { return true; } __result = value.CanBeFlipped(); return false; } [HarmonyPatch(typeof(Structure), "BrainAssigned")] [HarmonyPostfix] private static void Structure_BrainAssigned(Structure __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) if (CustomStructureList.TryGetValue(__instance.Type, out CustomStructure value) && !(value.Interaction == null)) { LogHelper.LogDebug("adding structure interaction " + CustomStructureList[__instance.Type].Interaction); ((Component)((Component)__instance).GetComponentInParent()).gameObject.AddComponent(CustomStructureList[__instance.Type].Interaction); } } } public class CustomStructureBuildingData { public Vector3 Offset = Vector3.zero; public Vector3 Rotation = Vector3.zero; public Vector3 Scale = Vector3.one; public Sprite? Sprite; } public abstract class CustomStructureWithTask : CustomStructure, ITaskProvider { public override string InternalName => "Custom_Task_Structure"; public abstract FollowerTask StructureTask { get; } public bool CheckOverrideComplete() { return true; } public FollowerTask? GetOverrideTask(FollowerBrain brain) { return null; } public virtual void GetAvailableTasks(ScheduledActivity activity, SortedList sortedTasks) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)activity == 0 && !((StructureBrain)this).ReservedForTask) { sortedTasks.Add(StructureTask.Priorty, StructureTask); } } } } namespace COTL_API.CustomSkins { public abstract class CustomFollowerSkin : CustomSkin { public virtual bool TwitchPremium { get; } public virtual bool Hidden { get; } public virtual bool Unlocked { get; } = true; public virtual bool Invariant { get; } public virtual List Colors { get; } = new List(1) { new SlotsAndColours { SlotAndColours = new List(9) { new SlotAndColor("ARM_LEFT_SKIN", new Color(1f, 0f, 1f)), new SlotAndColor("ARM_RIGHT_SKIN", new Color(0f, 0f, 0f)), new SlotAndColor("LEG_LEFT_SKIN", new Color(1f, 0f, 1f)), new SlotAndColor("LEG_RIGHT_SKIN", new Color(0f, 0f, 0f)), new SlotAndColor("Body_Naked", new Color(1f, 0f, 1f)), new SlotAndColor("Body_Naked_Up", new Color(1f, 0f, 1f)), new SlotAndColor("BODY_BTM", new Color(1f, 0f, 1f)), new SlotAndColor("BODY_BTM_UP", new Color(1f, 0f, 1f)), new SlotAndColor("BODY_TOP", new Color(0f, 0f, 0f)) } } }; } public abstract class CustomPlayerSkin : CustomSkin { private Skin? _cachedSkin; public virtual void Apply(PlayerType who = PlayerType.LAMB) { if (who == PlayerType.LAMB) { if (!SkinUtils.LambFleeceSkinLoaded) { SkinUtils.LambFleeceSkinToLoad = Action; } else { Action(); } } else if (!SkinUtils.GoatFleeceSkinLoaded) { SkinUtils.GoatFleeceToLoad = Action; } else { Action(); } void Action() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown if (_cachedSkin == null) { Skin from = ((SkeletonRenderer)PlayerFarming.Instance.Spine).Skeleton.Data.FindSkin((who == PlayerType.LAMB) ? "Lamb" : "Goat"); Skin to = new Skin(Name); Material skinMaterial; SpineAtlasAsset atlasAsset; List> overrides = SkinUtils.CreateSkinAtlas(Name, Texture, GenerateAtlasText(), delegate(AtlasRegion region) { //IL_00f7: 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) string simpleName = region.name; string text = ""; if (simpleName.Contains("#")) { string[] array = simpleName.Split(new char[1] { '#' }); text = "#" + array[1]; simpleName = array[0]; } if (CustomSkinManager.PlayerSkinDict.TryGetValue(simpleName, out Tuple value)) { region.name = value.Item1 + ":" + value.Item2 + text; return new List>(1) { value }; } IEnumerable enumerable = from.Attachments.Where((SkinEntry x) => ((SkinEntry)(ref x)).Name == simpleName); List> list = new List>(); if (from.Attachments.All((SkinEntry x) => ((SkinEntry)(ref x)).Name != simpleName)) { return new List>(); } foreach (SkinEntry item in enumerable) { SkinEntry current = item; region.name = ((SkinEntry)(ref current)).SlotIndex + ":" + ((SkinEntry)(ref current)).Name + text; list.Add(Tuple.Create(((SkinEntry)(ref current)).SlotIndex, ((SkinEntry)(ref current)).Name)); } return list; }, out skinMaterial, out atlasAsset); Skin cachedSkin = SkinUtils.ApplyAllOverrides(from, to, overrides, skinMaterial, (AtlasAssetBase)(object)atlasAsset); _cachedSkin = cachedSkin; } CustomSkinManager.SetPlayerSkinOverride(who, _cachedSkin); } } } public abstract class CustomSkin { public class SkinOverride { public string Name { get; } public Rect Rect { get; } public Vector2 Scale { get; } public Vector2 Translate { get; } public SkinOverride(string name, Rect rect, Vector2 scale, Vector2 translate) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Name = name; Rect = rect; Scale = scale; Translate = translate; } public SkinOverride(string name, Rect rect, float scaleX = 1f, float scaleY = 1f, float translateX = 0f, float translateY = 0f) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Name = name; Rect = rect; Scale = new Vector2(scaleX, scaleY); Translate = new Vector2(translateX, translateY); } public SkinOverride(string name, Rect rect, Tuple? scale, Tuple? translate) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Name = name; Rect = rect; Scale = (Vector2)((scale != null) ? new Vector2(scale.Item1, scale.Item2) : Vector2.one); Translate = (Vector2)((translate != null) ? new Vector2(translate.Item1, translate.Item2) : Vector2.zero); } } public abstract string Name { get; } public abstract Texture2D Texture { get; } public abstract List Overrides { get; } public string GenerateAtlasText() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_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) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(); stringBuilder.AppendLine(Name ?? ""); stringBuilder.AppendLine($"size: {((Texture)Texture).width}, {((Texture)Texture).height}"); stringBuilder.AppendLine("format: RGBA8888"); stringBuilder.AppendLine("filter: Linear,Linear"); stringBuilder.AppendLine("repeat: none"); foreach (SkinOverride @override in Overrides) { stringBuilder.AppendLine($"{@override.Name}#{@override.Scale.x},{@override.Scale.y},{@override.Translate.x},{@override.Translate.y}"); stringBuilder.AppendLine(" rotate: false"); Rect rect = @override.Rect; object arg = ((Rect)(ref rect)).x; rect = @override.Rect; stringBuilder.AppendLine($" xy: {arg},{((Rect)(ref rect)).y}"); rect = @override.Rect; object arg2 = ((Rect)(ref rect)).width; rect = @override.Rect; stringBuilder.AppendLine($" size: {arg2},{((Rect)(ref rect)).height}"); rect = @override.Rect; object arg3 = ((Rect)(ref rect)).width; rect = @override.Rect; stringBuilder.AppendLine($" orig: {arg3},{((Rect)(ref rect)).height}"); stringBuilder.AppendLine(" offset: 0,0"); stringBuilder.AppendLine(" index: -1"); } return stringBuilder.ToString(); } } public enum PlayerType { LAMB, GOAT } public enum PlayerBleat { DEFAULT, LAMB, GOAT, COWBOY } [HarmonyPatch] [HarmonyPatch] public static class CustomSkinManager { [CompilerGenerated] private sealed class d__57 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PlayerFarming instance; public PlayerBleat? bleatOverride; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__57(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Invalid comparison between Unknown and I4 //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown string text; string text2; string text3; switch (<>1__state) { default: return false; case 0: <>1__state = -1; instance.state.CURRENT_STATE = (State)49; if (!bleatOverride.HasValue) { goto IL_007d; } switch (bleatOverride.GetValueOrDefault()) { case PlayerBleat.LAMB: break; case PlayerBleat.GOAT: goto IL_006d; case PlayerBleat.COWBOY: goto IL_0075; default: goto IL_007d; } text = "bleat"; goto IL_0083; case 1: <>1__state = -1; if ((int)instance.state.CURRENT_STATE == 49) { instance.state.CURRENT_STATE = (State)0; } <>2__current = null; <>1__state = 2; return true; case 2: { <>1__state = -1; return false; } IL_00be: text = "event:/player/goat_player/goat_bleat"; goto IL_00d4; IL_00c6: text = "event:/player/yeehaa"; goto IL_00d4; IL_0075: text = "Cowboy/yeehaw-bleat"; goto IL_0083; IL_006d: text = "bleat-goat3"; goto IL_0083; IL_00ce: text = "event:/player/speak_to_follower_noBookPage"; goto IL_00d4; IL_007d: text = "bleat"; goto IL_0083; IL_0083: text2 = text; if (!bleatOverride.HasValue) { goto IL_00ce; } switch (bleatOverride.GetValueOrDefault()) { case PlayerBleat.LAMB: break; case PlayerBleat.GOAT: goto IL_00be; case PlayerBleat.COWBOY: goto IL_00c6; default: goto IL_00ce; } text = "event:/player/speak_to_follower_noBookPage"; goto IL_00d4; IL_00d4: text3 = text; instance.simpleSpineAnimator.Animate(text2, 0, false); AudioManager.Instance.PlayOneShot(text3, ((Component)instance).gameObject); <>2__current = (object)new WaitForSeconds((bleatOverride.GetValueOrDefault() == PlayerBleat.LAMB) ? 0.4f : 1.25f); <>1__state = 1; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static readonly Dictionary CustomAtlases = new Dictionary(); internal static readonly Dictionary CustomFollowerSkins = new Dictionary(); internal static readonly Dictionary AlwaysUnlockedSkins = new Dictionary(); internal static readonly Dictionary SkinTextures = new Dictionary(); internal static readonly Dictionary SkinMaterials = new Dictionary(); internal static readonly Dictionary TarotSkins = new Dictionary(); internal static readonly Dictionary TarotSprites = new Dictionary(); internal static readonly Dictionary TarotBackSprites = new Dictionary(); internal static readonly Dictionary CustomPlayerSpines = new Dictionary(); internal static readonly Dictionary CustomFollowerSpines = new Dictionary(); internal static string SelectedSpine = ""; internal static string SelectedSpine2 = ""; internal static int NumGenericAtlases; internal static readonly Dictionary CustomPlayerSkins = new Dictionary(); internal static readonly Dictionary> FollowerSkinDict = new Dictionary> { { "LEFT_ARM_SKIN", Tuple.Create(26, "ARM_LEFT_SKIN") }, { "LEFT_SLEEVE", Tuple.Create(27, "SLEEVE_LEFT_BTM") }, { "LEFT_SLEEVE_TOP", Tuple.Create(28, "SLEEVE_LEFT_TOP") }, { "WEAPON_HAND_SKIN", Tuple.Create(37, "WEAPON_HAND_SKIN") }, { "LEFT_LEG_SKIN", Tuple.Create(38, "LEG_LEFT_SKIN") }, { "RIGHT_LEG_SKIN", Tuple.Create(39, "LEG_RIGHT_SKIN") }, { "BODY_SKIN", Tuple.Create(43, "Body_Naked") }, { "BODY_SKIN_BOWED", Tuple.Create(43, "Body_Naked_Up") }, { "BODY_BTM", Tuple.Create(44, "BODY_BTM") }, { "BODY_BTM_UP", Tuple.Create(44, "BODY_BTM_UP") }, { "BODY_SKIN_UP", Tuple.Create(45, "BODY_TOP") }, { "Body_Lvl3", Tuple.Create(45, "BODY_TOP_UP") }, { "BODY_EXTRA_UP", Tuple.Create(46, "BODY_EXTRA_UP") }, { "BODY_EXTRA", Tuple.Create(46, "BODY_EXTRA") }, { "BowlBtm", Tuple.Create(55, "BowlBtm") }, { "BowlFood", Tuple.Create(56, "BowlFood") }, { "BowlFront", Tuple.Create(57, "BowlFront") }, { "RIGHT_ARM_SKIN", Tuple.Create(63, "ARM_RIGHT_SKIN") }, { "RIGHT_SLEEVE", Tuple.Create(64, "SLEEVE_RIGHT_BTM") }, { "RIGHT_SLEEVE_TOP", Tuple.Create(65, "SLEEVE_RIGHT_TOP") }, { "LEFT_SHAWL", Tuple.Create(74, "SHAWL") }, { "LEFT_SHAWL_UP", Tuple.Create(74, "SHAWL_UP") }, { "RIGHT_SHAWL", Tuple.Create(75, "SHAWL") }, { "RIGHT_SHAWL_UP", Tuple.Create(75, "SHAWL_UP") }, { "HEAD_SKIN_BTM", Tuple.Create(78, "HEAD_SKIN_BTM") }, { "HEAD_SKIN_BTM_BACK", Tuple.Create(78, "HEAD_SKIN_BTM_BACK") }, { "MARKINGS", Tuple.Create(81, "MARKINGS") }, { "HEAD_SKIN_TOP", Tuple.Create(80, "HEAD_SKIN_TOP") }, { "HEAD_SKIN_TOP_BACK", Tuple.Create(80, "HEAD_SKIN_TOP_BACK") }, { "Angry_Colouring", Tuple.Create(82, "Angry_Colouring") }, { "Embarrassed_Colouring", Tuple.Create(82, "Embarrassed_Colouring") }, { "Possessed_Colouring", Tuple.Create(82, "Possessed_Colouring") }, { "Freezing_Colouring", Tuple.Create(82, "Freezing_Colouring") }, { "Hot_Colouring", Tuple.Create(82, "Hot_Colouring") }, { "Sick_Colouring", Tuple.Create(82, "Sick_Colouring") }, { "EXTRA_TOP", Tuple.Create(83, "EXTRA_TOP") }, { "EXTRA_TOP_BACK", Tuple.Create(83, "EXTRA_TOP_BACK") }, { "MOUTH_BEDREST", Tuple.Create(85, "Face/MOUTH_BEDREST") }, { "MOUTH_CHEEKY", Tuple.Create(85, "Face/MOUTH_CHEEKY") }, { "MOUTH_DEAD", Tuple.Create(85, "Face/MOUTH_DEAD") }, { "MOUTH_DERP", Tuple.Create(85, "Face/MOUTH_DERP") }, { "MOUTH_ENLIGHTENED", Tuple.Create(85, "Face/MOUTH_ENLIGHTENED") }, { "MOUTH_GRIN", Tuple.Create(85, "Face/MOUTH_GRIN") }, { "MOUTH_HAPPY", Tuple.Create(85, "Face/MOUTH_HAPPY") }, { "MOUTH_HAPPY_2", Tuple.Create(85, "Face/MOUTH_HAPPY-2") }, { "MOUTH_HUNGRY_1", Tuple.Create(85, "Face/MOUTH_HUNGRY1") }, { "MOUTH_HUNGRY_2", Tuple.Create(85, "Face/MOUTH_HUNGRY2") }, { "MOUTH_INDIFFERENT", Tuple.Create(85, "Face/MOUTH_INDIFFERENT") }, { "MOUTH_INDIFFERENT_HUNGRY", Tuple.Create(85, "Face/MOUTH_INDIFFERENT_HUNGRY") }, { "MOUTH_INSANE", Tuple.Create(85, "Face/MOUTH_INSANE") }, { "MOUTH_KISS", Tuple.Create(85, "Face/MOUTH_KISS") }, { "MOUTH_KISS_BIG", Tuple.Create(85, "Face/MOUTH_KISS_BIG") }, { "MOUTH_MUMBLE", Tuple.Create(85, "Face/MOUTH_MUMBLE") }, { "MOUTH_MUMBLE_HUNGRY", Tuple.Create(85, "Face/MOUTH_MUMBLE_HUNGRY") }, { "MOUTH_RED", Tuple.Create(85, "Face/MOUTH_RED") }, { "MOUTH_SACRIFICE", Tuple.Create(85, "Face/MOUTH_SACRIFICE") }, { "MOUTH_SAD", Tuple.Create(85, "Face/MOUTH_SAD") }, { "MOUTH_SADDER", Tuple.Create(85, "Face/MOUTH_SADDER") }, { "MOUTH_SCARED", Tuple.Create(85, "Face/MOUTH_SCARED") }, { "MOUTH_SICK", Tuple.Create(85, "Face/MOUTH_SICK") }, { "MOUTH_SLEEP_0", Tuple.Create(85, "Face/MOUTH_SLEEP_0") }, { "MOUTH_SLEEP_1", Tuple.Create(85, "Face/MOUTH_SLEEP_1") }, { "MOUTH_TALK_HAPPY", Tuple.Create(85, "Face/MOUTH_TALK_HAPPY") }, { "MOUTH_TALK_INDIFFERENT", Tuple.Create(85, "Face/MOUTH_TALK_INDIFFERENT") }, { "MOUTH_TONGUE_1", Tuple.Create(85, "Face/MOUTH_TONGUE_1") }, { "MOUTH_TONGUE_2", Tuple.Create(85, "Face/MOUTH_TONGUE_2") }, { "MOUTH_TONGUE_3", Tuple.Create(85, "Face/MOUTH_TONGUE_3") }, { "MOUTH_TONGUE_4", Tuple.Create(85, "Face/MOUTH_TONGUE_4") }, { "MOUTH_WORRIED", Tuple.Create(85, "Face/MOUTH_WORRIED") }, { "MOUTH_FREEZING_1", Tuple.Create(85, "MOUTH_FREEZING1") }, { "MOUTH_FREEZING_2", Tuple.Create(85, "MOUTH_FREEZING2") }, { "MOUTH_DEAD_FREEZING", Tuple.Create(85, "MOUTH_DEAD_FREEZING") }, { "MOUTH_HOT", Tuple.Create(85, "Face/MOUTH_HOT") }, { "MOUTH_CURSED", Tuple.Create(85, "Face/MOUTH_CURSED") }, { "MOUTH_ENLIGHTENED_2", Tuple.Create(85, "MOUTH_ENLIGHTENED2") }, { "RIGHT_EYE", Tuple.Create(90, "EYE") }, { "RIGHT_EYE_ANGRY", Tuple.Create(90, "EYE_ANGRY") }, { "RIGHT_EYE_ANGRY_UP", Tuple.Create(90, "EYE_ANGRY_UP") }, { "RIGHT_EYE_BLACK", Tuple.Create(90, "EYE_BLACK") }, { "RIGHT_EYE_BRAINWASHED", Tuple.Create(90, "EYE_BRAINWASHED") }, { "RIGHT_EYE_CLOSED", Tuple.Create(90, "EYE_CLOSED") }, { "RIGHT_EYE_CRAZY", Tuple.Create(90, "EYE_CRAZY") }, { "RIGHT_EYE_DEAD", Tuple.Create(90, "EYE_DEAD") }, { "RIGHT_EYE_DISSENTER", Tuple.Create(90, "EYE_DISSENTER") }, { "RIGHT_EYE_DISSENTER_ANGRY", Tuple.Create(90, "EYE_DISSENTER_ANGRY") }, { "RIGHT_EYE_ENLIGHTENED", Tuple.Create(90, "EYE_ENLIGHTENED") }, { "RIGHT_EYE_HALF_CLOSED", Tuple.Create(90, "EYE_HALF_CLOSED") }, { "RIGHT_EYE_HALF_CLOSED_ANGRY", Tuple.Create(90, "EYE_HALF_CLOSED_ANGRY") }, { "RIGHT_EYE_INSANE", Tuple.Create(90, "EYE_INSANE") }, { "RIGHT_EYE_SACRIFICE_1", Tuple.Create(90, "EYE_SACRIFICE_1") }, { "RIGHT_EYE_SACRIFICE_2", Tuple.Create(90, "EYE_SACRIFICE_2") }, { "RIGHT_EYE_SHOCKED", Tuple.Create(90, "EYE_SHOCKED") }, { "RIGHT_EYE_SICK_2", Tuple.Create(90, "EYE_SICK_2_RIGHT") }, { "RIGHT_EYE_SICK", Tuple.Create(90, "EYE_SICK_RIGHT") }, { "RIGHT_EYE_SLEEPING", Tuple.Create(90, "EYE_SLEEPING") }, { "RIGHT_EYE_SLEEPING_SICK", Tuple.Create(90, "EYE_SLEEPING_SICK") }, { "RIGHT_EYE_SLEEPING_TIRED", Tuple.Create(90, "EYE_SLEEPING_TIRED") }, { "RIGHT_EYE_SLEEPY", Tuple.Create(90, "EYE_SLEEPY_RIGHT") }, { "RIGHT_EYE_SMILE", Tuple.Create(90, "EYE_SMILE") }, { "RIGHT_EYE_SMILE_DOWN", Tuple.Create(90, "EYE_SMILE_DOWN") }, { "RIGHT_EYE_SMILE_UP", Tuple.Create(90, "EYE_SMILE_UP") }, { "RIGHT_EYE_SQUINT", Tuple.Create(90, "EYE_SQUINT") }, { "RIGHT_EYE_STARS", Tuple.Create(90, "EYE_STARS") }, { "RIGHT_EYE_UNCONVERTED", Tuple.Create(90, "EYE_UNCONVERTED") }, { "RIGHT_EYE_UP", Tuple.Create(90, "EYE_UP") }, { "RIGHT_EYE_VERY_ANGRY", Tuple.Create(90, "EYE_VERY_ANGRY") }, { "RIGHT_EYE_WHITE", Tuple.Create(90, "EYE_WHITE") }, { "RIGHT_EYE_WORRIED", Tuple.Create(90, "EYE_WORRIED_RIGHT") }, { "RIGHT_EYE_FIRE_1", Tuple.Create(90, "Face/EYE_FIRE1") }, { "RIGHT_EYE_FIRE_2", Tuple.Create(90, "Face/EYE_FIRE2") }, { "RIGHT_EYE_FIRE_3", Tuple.Create(90, "Face/EYE_FIRE3") }, { "RIGHT_EYE_FIRE_4", Tuple.Create(90, "Face/EYE_FIRE4") }, { "RIGHT_EYE_FIRE_5", Tuple.Create(90, "Face/EYE_FIRE5") }, { "RIGHT_EYE_FIRE_6", Tuple.Create(90, "Face/EYE_FIRE6") }, { "RIGHT_EYE_FIRE_7", Tuple.Create(90, "Face/EYE_FIRE7") }, { "RIGHT_EYE_WORRIED_FREEZING", Tuple.Create(90, "EYE_WORRIED_RIGHT_FREEZING") }, { "RIGHT_EYE_DEAD_FREEZING", Tuple.Create(90, "EYE_DEAD_FREEZING") }, { "RIGHT_EYE_HOT", Tuple.Create(90, "EYE_HOT") }, { "RIGHT_EYE_CURSED", Tuple.Create(90, "EYE_CURSED") }, { "LEFT_EYE", Tuple.Create(91, "EYE") }, { "LEFT_EYE_ANGRY", Tuple.Create(91, "EYE_ANGRY_LEFT") }, { "LEFT_EYE_ANGRY_UP", Tuple.Create(91, "EYE_ANGRY_UP_LEFT") }, { "LEFT_EYE_BLACK", Tuple.Create(91, "EYE_BLACK") }, { "LEFT_EYE_BRAINWASHED", Tuple.Create(91, "EYE_BRAINWASHED") }, { "LEFT_EYE_CLOSED", Tuple.Create(91, "EYE_CLOSED") }, { "LEFT_EYE_CRAZY", Tuple.Create(91, "EYE_CRAZY") }, { "LEFT_EYE_DEAD", Tuple.Create(91, "EYE_DEAD") }, { "LEFT_EYE_DISSENTER", Tuple.Create(91, "EYE_DISSENTER") }, { "LEFT_EYE_DISSENTER_ANGRY", Tuple.Create(91, "EYE_DISSENTER_ANGRY") }, { "LEFT_EYE_ENLIGHTENED", Tuple.Create(91, "EYE_ENLIGHTENED") }, { "LEFT_EYE_HALF_CLOSED", Tuple.Create(91, "EYE_HALF_CLOSED") }, { "LEFT_EYE_HALF_CLOSED_ANGRY", Tuple.Create(91, "EYE_HALF_CLOSED_ANGRY_LEFT") }, { "LEFT_EYE_INSANE", Tuple.Create(91, "EYE_INSANE_LEFT") }, { "LEFT_EYE_SACRIFICE_1", Tuple.Create(91, "EYE_SACRIFICE_1") }, { "LEFT_EYE_SACRIFICE_2", Tuple.Create(91, "EYE_SACRIFICE_2") }, { "LEFT_EYE_SHOCKED", Tuple.Create(91, "EYE_SHOCKED") }, { "LEFT_EYE_SICK_2", Tuple.Create(91, "EYE_SICK_2_LEFT") }, { "LEFT_EYE_SICK", Tuple.Create(91, "EYE_SICK_LEFT") }, { "LEFT_EYE_SLEEPING", Tuple.Create(91, "EYE_SLEEPING") }, { "LEFT_EYE_SLEEPING_SICK", Tuple.Create(91, "EYE_SLEEPING_SICK") }, { "LEFT_EYE_SLEEPING_TIRED", Tuple.Create(91, "EYE_SLEEPING_TIRED") }, { "LEFT_EYE_SLEEPY", Tuple.Create(91, "EYE_SLEEPY_LEFT") }, { "LEFT_EYE_SMILE", Tuple.Create(91, "EYE_SMILE") }, { "LEFT_EYE_SMILE_DOWN", Tuple.Create(91, "EYE_SMILE_DOWN") }, { "LEFT_EYE_SMILE_UP", Tuple.Create(91, "EYE_SMILE_UP") }, { "LEFT_EYE_SQUINT", Tuple.Create(91, "EYE_SQUINT") }, { "LEFT_EYE_STARS", Tuple.Create(91, "EYE_STARS") }, { "LEFT_EYE_UNCONVERTED", Tuple.Create(91, "EYE_UNCONVERTED") }, { "LEFT_EYE_UP", Tuple.Create(91, "EYE_UP") }, { "LEFT_EYE_VERY_ANGRY", Tuple.Create(91, "EYE_VERY_ANGRY") }, { "LEFT_EYE_WHITE", Tuple.Create(91, "EYE_WHITE") }, { "LEFT_EYE_WORRIED", Tuple.Create(91, "EYE_WORRIED_LEFT") }, { "LEFT_EYE_FIRE_1", Tuple.Create(91, "Face/EYE_FIRE1") }, { "LEFT_EYE_FIRE_2", Tuple.Create(91, "Face/EYE_FIRE2") }, { "LEFT_EYE_FIRE_3", Tuple.Create(91, "Face/EYE_FIRE3") }, { "LEFT_EYE_FIRE_4", Tuple.Create(91, "Face/EYE_FIRE4") }, { "LEFT_EYE_FIRE_5", Tuple.Create(91, "Face/EYE_FIRE5") }, { "LEFT_EYE_FIRE_6", Tuple.Create(91, "Face/EYE_FIRE6") }, { "LEFT_EYE_FIRE_7", Tuple.Create(91, "Face/EYE_FIRE7") }, { "LEFT_EYE_WORRIED_FREEZING", Tuple.Create(91, "EYE_WORRIED_LEFT_FREEZING") }, { "LEFT_EYE_DEAD_FREEZING", Tuple.Create(91, "EYE_DEAD_LEFT_FREEZING") }, { "LEFT_EYE_HOT", Tuple.Create(91, "EYE_LEFT_HOT") }, { "EYE_CURSED", Tuple.Create(91, "EYE_CURSED") }, { "LESHY_FACE", Tuple.Create(92, "LESHY_FACE") }, { "LESHY_FACE_HAPPY", Tuple.Create(92, "LESHY_FACE_HAPPY") }, { "LESHY_FACE_SAD", Tuple.Create(92, "LESHY_FACE_SAD") }, { "LESHY_FACE_DISSENTER", Tuple.Create(92, "LESHY_FACE_DISSENTER") }, { "LESHY_FACE_POSSESSED", Tuple.Create(92, "LESHY_FACE_POSSESSED") }, { "LESHY_FACE_SCARED", Tuple.Create(92, "LESHY_FACE_SCARED") }, { "LESHY_FACE_SIN", Tuple.Create(92, "LESHY_FACE_SIN") }, { "LESHY_FACE_BRAINWASHED", Tuple.Create(92, "LESHY_FACE_BRAINWASHED") }, { "LESHY_FACE_SICK", Tuple.Create(92, "LESHY_FACE_SICK") } }; internal static readonly Dictionary> PlayerSkinDict = new Dictionary> { { "Crown_Particle1", Tuple.Create(0, "Crown_Particle1") }, { "Crown_Particle2", Tuple.Create(1, "Crown_Particle2") }, { "Crown_Particle6", Tuple.Create(2, "Crown_Particle6") }, { "effects/Crown_Particle3", Tuple.Create(3, "effects/Crown_Particle3") }, { "effects/Crown_Particle4", Tuple.Create(4, "effects/Crown_Particle4") }, { "effects/Crown_Particle5", Tuple.Create(5, "effects/Crown_Particle5") }, { "sunburst", Tuple.Create(9, "sunburst") }, { "sunburst2", Tuple.Create(9, "sunburst2") }, { "Corpse", Tuple.Create(11, "Corpse") }, { "Corpse2", Tuple.Create(12, "Corpse") }, { "Halo", Tuple.Create(13, "Halo") }, { "ARM_LEFT", Tuple.Create(14, "ARM_LEFT") }, { "PonchoShoulder", Tuple.Create(15, "PonchoShoulder") }, { "Tools/PITCHFORK", Tuple.Create(16, "Tools/PITCHFORK") }, { "Tools/SEED_BAG", Tuple.Create(16, "Tools/SEED_BAG") }, { "Tools/SPADE", Tuple.Create(16, "Tools/SPADE") }, { "Tools/WATERING_CAN", Tuple.Create(16, "Tools/WATERING_CAN") }, { "Tools/FishingRod", Tuple.Create(16, "Tools/FishingRod") }, { "Tools/FishingRod2", Tuple.Create(16, "Tools/FishingRod2") }, { "Tools/Mop", Tuple.Create(16, "Tools/Mop") }, { "FishingRod_Front", Tuple.Create(16, "FishingRod_Front") }, { "GauntletHeavya", Tuple.Create(16, "GauntletHeavy") }, { "GauntletHeavy2a", Tuple.Create(16, "GauntletHeavy2") }, { "images/AttackHand1", Tuple.Create(16, "images/AttackHand1") }, { "images/AttackHand2", Tuple.Create(16, "images/AttackHand2") }, { "LEG_LEFT", Tuple.Create(17, "LEG_LEFT") }, { "LEG_RIGHT", Tuple.Create(18, "LEG_RIGHT") }, { "Body", Tuple.Create(19, "Body") }, { "PonchoLeft", Tuple.Create(21, "PonchoLeft") }, { "PonchoLeft2", Tuple.Create(21, "PonchoLeft2") }, { "Weapons/Axe", Tuple.Create(22, "Weapons/Axe") }, { "Weapons/Blunderbuss", Tuple.Create(22, "Weapons/Blunderbuss") }, { "Weapons/Dagger", Tuple.Create(22, "Weapons/Dagger") }, { "Weapons/Hammer", Tuple.Create(22, "Weapons/Hammer") }, { "Weapons/Sword", Tuple.Create(22, "Weapons/Sword") }, { "DaggerFlipped", Tuple.Create(22, "DaggerFlipped") }, { "Shield", Tuple.Create(22, "Shield") }, { "Blunderbuss/Flipped", Tuple.Create(22, "Blunderbuss/Flipped") }, { "ARM_RIGHT", Tuple.Create(23, "ARM_RIGHT") }, { "PonchoShoulder_Right", Tuple.Create(24, "PonchoShoulder_Right") }, { "ArmSpikes", Tuple.Create(25, "ArmSpikes") }, { "PonchoRight", Tuple.Create(26, "PonchoRight") }, { "PonchoRight2", Tuple.Create(26, "PonchoRight2") }, { "PonchoExtra", Tuple.Create(27, "PonchoExtra") }, { "images/Rope", Tuple.Create(28, "images/Rope") }, { "images/RopeTopRight", Tuple.Create(29, "images/RopeTopRight") }, { "images/RopeTopLeft", Tuple.Create(30, "images/RopeTopLeft") }, { "Bell", Tuple.Create(31, "Bell") }, { "Antler", Tuple.Create(32, "Antler") }, { "Antler_RITUAL", Tuple.Create(32, "Antler_RITUAL") }, { "Antler_SERMON", Tuple.Create(32, "Antler_SERMON") }, { "Antler_Horn", Tuple.Create(32, "Antler_Horn") }, { "Antler2", Tuple.Create(33, "Antler") }, { "Antler_SERMON2", Tuple.Create(33, "Antler_SERMON") }, { "Antler_RITUAL2", Tuple.Create(33, "Antler_RITUAL") }, { "Antler_Horn2", Tuple.Create(33, "Antler_Horn") }, { "EAR_LEFT", Tuple.Create(34, "EAR_LEFT") }, { "EAR_RITUAL", Tuple.Create(34, "EAR_RITUAL") }, { "EAR_SERMON", Tuple.Create(34, "EAR_SERMON") }, { "CrownGlow", Tuple.Create(35, "CrownGlow") }, { "images/CrownSpikesc", Tuple.Create(36, "images/CrownSpikes") }, { "CROWN", Tuple.Create(37, "CROWN") }, { "CROWN_RITUAL", Tuple.Create(37, "CROWN_RITUAL") }, { "CROWN_SERMON", Tuple.Create(37, "CROWN_SERMON") }, { "BigCrown", Tuple.Create(37, "BigCrown") }, { "CROWN_WHITE", Tuple.Create(37, "CROWN_WHITE") }, { "images/CrownEyeShut3a", Tuple.Create(39, "images/CrownEyeShut3") }, { "images/CrownEyeShut2a", Tuple.Create(39, "images/CrownEyeShut2") }, { "images/CrownEyeShuta", Tuple.Create(39, "images/CrownEyeShut") }, { "CROWN_EYEa", Tuple.Create(39, "CROWN_EYE") }, { "images/CrownEye_RITUALa", Tuple.Create(39, "images/CrownEye_RITUAL") }, { "images/CrownEye_SERMONa", Tuple.Create(39, "images/CrownEye_SERMON") }, { "images/CrownEyeBiga", Tuple.Create(39, "images/CrownEyeBig") }, { "images/CrownEyeBig2a", Tuple.Create(39, "images/CrownEyeBig2") }, { "CrownEyeSina", Tuple.Create(39, "CrownEyeSin") }, { "CROWN_EYEb", Tuple.Create(40, "CROWN_EYE") }, { "images/CrownEyeBigb", Tuple.Create(40, "images/CrownEyeBig") }, { "images/CrownEyeBig2b", Tuple.Create(40, "images/CrownEyeBig2") }, { "images/CrownEyeShutb", Tuple.Create(40, "images/CrownEyeShut") }, { "images/CrownEyeShut2b", Tuple.Create(40, "images/CrownEyeShut2") }, { "images/CrownEyeShut3b", Tuple.Create(40, "images/CrownEyeShut3") }, { "images/CrownEye_RITUALb", Tuple.Create(40, "images/CrownEye_RITUAL") }, { "images/CrownEye_SERMONb", Tuple.Create(40, "images/CrownEye_SERMON") }, { "CrownEyeSinb", Tuple.Create(40, "CrownEyeSin") }, { "HeadBack", Tuple.Create(43, "HeadBack") }, { "HeadBackDown", Tuple.Create(43, "HeadBackDown") }, { "HeadBackDown_RITUAL", Tuple.Create(43, "HeadBackDown_RITUAL") }, { "HeadBackDown_SERMON", Tuple.Create(43, "HeadBackDown_SERMON") }, { "HeadFront", Tuple.Create(44, "HeadFront") }, { "HeadFrontDown", Tuple.Create(44, "HeadFrontDown") }, { "EAR_RIGHT", Tuple.Create(46, "EAR_RIGHT") }, { "EAR_RIGHT_RITUAL", Tuple.Create(46, "EAR_RIGHT_RITUAL") }, { "EAR_RIGHT_SERMON", Tuple.Create(46, "EAR_RIGHT_SERMON") }, { "effects/eye_blood", Tuple.Create(47, "effects/eye_blood") }, { "effects/eye_tears", Tuple.Create(47, "effects/eye_tears") }, { "effects/eye_blood2", Tuple.Create(48, "effects/eye_blood") }, { "effects/eye_tears2", Tuple.Create(48, "effects/eye_tears") }, { "MOUTH_NORMAL", Tuple.Create(49, "MOUTH_NORMAL") }, { "Face/MOUTH_CHEEKY", Tuple.Create(49, "Face/MOUTH_CHEEKY") }, { "Face/MOUTH_CHUBBY", Tuple.Create(49, "Face/MOUTH_CHUBBY") }, { "Face/MOUTH_DEAD", Tuple.Create(49, "Face/MOUTH_DEAD") }, { "Face/MOUTH_GRUMPY", Tuple.Create(49, "Face/MOUTH_GRUMPY") }, { "Face/MOUTH_HAPPY", Tuple.Create(49, "Face/MOUTH_HAPPY") }, { "Face/MOUTH_INDIFFERENT", Tuple.Create(49, "Face/MOUTH_INDIFFERENT") }, { "Face/MOUTH_KAWAII", Tuple.Create(49, "Face/MOUTH_KAWAII") }, { "Face/MOUTH_OO", Tuple.Create(49, "Face/MOUTH_OO") }, { "Face/MOUTH_OPEN", Tuple.Create(49, "Face/MOUTH_OPEN") }, { "Face/MOUTH_SAD", Tuple.Create(49, "Face/MOUTH_SAD") }, { "Face/MOUTH_SCARED", Tuple.Create(49, "Face/MOUTH_SCARED") }, { "Face/MOUTH_SLEEP_0", Tuple.Create(49, "Face/MOUTH_SLEEP_0") }, { "Face/MOUTH_SLEEP_1", Tuple.Create(49, "Face/MOUTH_SLEEP_1") }, { "Face/MOUTH_TONGUE", Tuple.Create(49, "Face/MOUTH_TONGUE") }, { "Face/MOUTH_UNCONVERTED", Tuple.Create(49, "Face/MOUTH_UNCONVERTED") }, { "MOUTH_TALK", Tuple.Create(49, "MOUTH_TALK") }, { "MOUTH_TALK_HAPPY", Tuple.Create(49, "MOUTH_TALK_HAPPY") }, { "MOUTH_UNCONVERTED_SPEAK", Tuple.Create(49, "MOUTH_UNCONVERTED_SPEAK") }, { "MOUTH_GRIMACE", Tuple.Create(49, "MOUTH_GRIMACE") }, { "MOUTH_SNARL", Tuple.Create(49, "MOUTH_SNARL") }, { "MOUTH_TALK1", Tuple.Create(49, "MOUTH_TALK1") }, { "MOUTH_TALK2", Tuple.Create(49, "MOUTH_TALK2") }, { "MOUTH_TALK3", Tuple.Create(49, "MOUTH_TALK3") }, { "MOUTH_TALK4", Tuple.Create(49, "MOUTH_TALK4") }, { "MOUTH_TALK5", Tuple.Create(49, "MOUTH_TALK5") }, { "Face/MOUTH_HUNGRY1", Tuple.Create(49, "Face/MOUTH_HUNGRY1") }, { "Face/MOUTH_HUNGRY2", Tuple.Create(49, "Face/MOUTH_HUNGRY2") }, { "EYE_LEFT", Tuple.Create(50, "EYE") }, { "EYE_ANGRY_LEFT", Tuple.Create(50, "EYE_ANGRY_LEFT") }, { "EYE_BACK_LEFT", Tuple.Create(50, "EYE_BACK") }, { "EYE_DETERMINED_DOWN_LEFT", Tuple.Create(50, "EYE_DETERMINED_DOWN_LEFT") }, { "EYE_DETERMINED_LEFT", Tuple.Create(50, "EYE_DETERMINED_LEFT") }, { "EYE_DOWN_LEFT", Tuple.Create(50, "EYE_DOWN") }, { "EYE_HALF_CLOSED_LEFT", Tuple.Create(50, "EYE_HALF_CLOSED") }, { "EYE_HAPPY_LEFT", Tuple.Create(50, "EYE_HAPPY") }, { "EYE_UP_LEFT", Tuple.Create(50, "EYE_UP") }, { "EYE_WORRIED_LEFT", Tuple.Create(50, "EYE_WORRIED_LEFT") }, { "Face/EYE_CLOSED_LEFT", Tuple.Create(50, "Face/EYE_CLOSED") }, { "Face/EYE_DEAD_LEFT", Tuple.Create(50, "Face/EYE_DEAD") }, { "Face/EYE_RED_LEFT", Tuple.Create(50, "Face/EYE_RED") }, { "Face/EYE_SHOCKED_LEFT", Tuple.Create(50, "Face/EYE_SHOCKED") }, { "Face/EYE_SLEEPING_LEFT", Tuple.Create(50, "Face/EYE_SLEEPING") }, { "Face/EYE_SQUINT_LEFT", Tuple.Create(50, "Face/EYE_SQUINT") }, { "Face/EYE_UNCONVERTED_LEFT", Tuple.Create(50, "Face/EYE_UNCONVERTED") }, { "Face/EYE_UNCONVERTED_WORRIED_LEFT", Tuple.Create(50, "Face/EYE_UNCONVERTED_WORRIED") }, { "EYE_ANGRY_LEFT_UP", Tuple.Create(50, "EYE_ANGRY_LEFT_UP") }, { "EYE_WHITE_LEFT", Tuple.Create(50, "EYE_WHITE") }, { "EYE_WEARY_LEFT", Tuple.Create(50, "EYE_WEARY_LEFT") }, { "EYE_GRIMACE_LEFT", Tuple.Create(50, "EYE_GRIMACE") }, { "EYE_WEARY_LEFT_DOWN", Tuple.Create(50, "EYE_WEARY_LEFT_DOWN") }, { "EYE_HAPPY2_LEFT", Tuple.Create(50, "EYE_HAPPY2") }, { "Face/EYE_RED_ANGRY_LEFT", Tuple.Create(50, "Face/EYE_RED_ANGRY") }, { "EYE_WHITE_ANGRY_LEFT", Tuple.Create(50, "EYE_WHITE_ANGRY") }, { "Face/EYE_HAPPY_UP_LEFT", Tuple.Create(50, "Face/EYE_HAPPY_UP") }, { "EYE_RIGHT", Tuple.Create(51, "EYE") }, { "EYE_ANGRY_RIGHT", Tuple.Create(51, "EYE_ANGRY_RIGHT") }, { "EYE_BACK_RIGHT", Tuple.Create(51, "EYE_BACK") }, { "EYE_DETERMINED_DOWN_RIGHT", Tuple.Create(51, "EYE_DETERMINED_DOWN_RIGHT") }, { "EYE_DETERMINED_RIGHT", Tuple.Create(51, "EYE_DETERMINED_RIGHT") }, { "EYE_DOWN_RIGHT", Tuple.Create(51, "EYE_DOWN") }, { "EYE_HALF_CLOSED_RIGHT", Tuple.Create(51, "EYE_HALF_CLOSED") }, { "EYE_HAPPY_RIGHT", Tuple.Create(51, "EYE_HAPPY") }, { "EYE_UP_RIGHT", Tuple.Create(51, "EYE_UP") }, { "EYE_WORRIED_RIGHT", Tuple.Create(51, "EYE_WORRIED_RIGHT") }, { "Face/EYE_CLOSED_RIGHT", Tuple.Create(51, "Face/EYE_CLOSED") }, { "Face/EYE_DEAD_RIGHT", Tuple.Create(51, "Face/EYE_DEAD") }, { "Face/EYE_RED_RIGHT", Tuple.Create(51, "Face/EYE_RED") }, { "Face/EYE_SHOCKED_RIGHT", Tuple.Create(51, "Face/EYE_SHOCKED") }, { "Face/EYE_SLEEPING_RIGHT", Tuple.Create(51, "Face/EYE_SLEEPING") }, { "Face/EYE_SQUINT_RIGHT", Tuple.Create(51, "Face/EYE_SQUINT") }, { "Face/EYE_UNCONVERTED_RIGHT", Tuple.Create(51, "Face/EYE_UNCONVERTED") }, { "Face/EYE_UNCONVERTED_WORRIED_RIGHT", Tuple.Create(51, "Face/EYE_UNCONVERTED_WORRIED") }, { "EYE_ANGRY_RIGHT_UP", Tuple.Create(51, "EYE_ANGRY_RIGHT_UP") }, { "EYE_WHITE_RIGHT", Tuple.Create(51, "EYE_WHITE") }, { "EYE_WEARY_RIGHT", Tuple.Create(51, "EYE_WEARY_RIGHT") }, { "EYE_GRIMACE_RIGHT", Tuple.Create(51, "EYE_GRIMACE") }, { "EYE_WEARY_RIGHT_DOWN", Tuple.Create(51, "EYE_WEARY_RIGHT_DOWN") }, { "EYE_HAPPY2_RIGHT", Tuple.Create(51, "EYE_HAPPY2") }, { "Face/EYE_RED_ANGRY_RIGHT", Tuple.Create(51, "Face/EYE_RED_ANGRY") }, { "EYE_WHITE_ANGRY_RIGHT", Tuple.Create(51, "EYE_WHITE_ANGRY") }, { "Face/EYE_HAPPY_UP_RIGHT", Tuple.Create(51, "Face/EYE_HAPPY_UP") }, { "HairTuft", Tuple.Create(52, "HairTuft") }, { "Tools/Book_open", Tuple.Create(53, "Tools/Book_open") }, { "Tools/Book_closed", Tuple.Create(53, "Tools/Book_closed") }, { "Tools/BookFlipping_3", Tuple.Create(53, "Tools/BookFlipping_3") }, { "Tools/BookFlipping_2", Tuple.Create(53, "Tools/BookFlipping_2") }, { "Tools/BookFlipping_1", Tuple.Create(53, "Tools/BookFlipping_1") }, { "Tools/BookFlipping_4", Tuple.Create(53, "Tools/BookFlipping_4") }, { "PonchoRightCorner", Tuple.Create(55, "PonchoRightCorner") }, { "PonchoRightCorner2", Tuple.Create(56, "PonchoRightCorner") }, { "images/CrownMouth", Tuple.Create(57, "images/CrownMouth") }, { "images/CrownMouthOpen", Tuple.Create(57, "images/CrownMouthOpen") }, { "DRINK", Tuple.Create(58, "DRINK") }, { "Tools/Chalice", Tuple.Create(59, "Tools/Chalice") }, { "Tools/Chalice_Skull", Tuple.Create(59, "Tools/Chalice_Skull") }, { "Tools/Chalice_Skull_Drink", Tuple.Create(59, "Tools/Chalice_Skull_Drink") }, { "effects/slam_effect0006", Tuple.Create(60, "effects/slam_effect0006") }, { "effects/slam_effect0005", Tuple.Create(60, "effects/slam_effect0005") }, { "effects/slam_effect0004", Tuple.Create(60, "effects/slam_effect0004") }, { "effects/slam_effect0003", Tuple.Create(60, "effects/slam_effect0003") }, { "effects/slam_effect0002", Tuple.Create(60, "effects/slam_effect0002") }, { "effects/slam_effect0001", Tuple.Create(60, "effects/slam_effect0001") }, { "images/CrownSpikesa", Tuple.Create(61, "images/CrownSpikes") }, { "images/CrownSpikes2a", Tuple.Create(62, "images/CrownSpikes2") }, { "images/CrownSpikesb", Tuple.Create(63, "images/CrownSpikes") }, { "images/CrownSpikes2b", Tuple.Create(64, "images/CrownSpikes2") }, { "AttackHand1", Tuple.Create(65, "AttackHand1") }, { "AttackHand2", Tuple.Create(65, "AttackHand2") }, { "GauntletHeavyb", Tuple.Create(66, "GauntletHeavy") }, { "GauntletHeavy2b", Tuple.Create(66, "GauntletHeavy2") }, { "Weapons/Sling", Tuple.Create(67, "Weapons/Sling") }, { "Weapons/SlingRope", Tuple.Create(68, "Weapons/SlingRope") }, { "GunHand", Tuple.Create(69, "GunHand") }, { "SlingHand", Tuple.Create(70, "SlingHand") }, { "Arm_frontbit", Tuple.Create(71, "Arm_frontbit") }, { "Arm_frontbit2", Tuple.Create(72, "Arm_frontbit") }, { "whiteball", Tuple.Create(73, "whiteball") }, { "effects/whiteball", Tuple.Create(74, "effects/whiteball") }, { "Weapons/SlingHand", Tuple.Create(75, "Weapons/SlingHand") }, { "effects/portal_btm", Tuple.Create(76, "effects/portal_btm") }, { "effects/portal_top", Tuple.Create(77, "effects/portal_top") }, { "portal_splash", Tuple.Create(78, "portal_splash") }, { "GrappleHook", Tuple.Create(79, "GrappleHook") }, { "Weapons/Lute", Tuple.Create(80, "Weapons/Lute") }, { "Weapons/SlingHand2", Tuple.Create(81, "Weapons/SlingHand") }, { "images/Crown_half_left", Tuple.Create(82, "images/Crown_half_left") }, { "images/Crown_half_right", Tuple.Create(83, "images/Crown_half_right") }, { "Sparks1a", Tuple.Create(87, "Sparks1") }, { "Sparks1b", Tuple.Create(88, "Sparks1") }, { "Sparks2a", Tuple.Create(89, "Sparks2") }, { "Sparks2b", Tuple.Create(90, "Sparks2") }, { "Weapons/SpecialSword_1", Tuple.Create(91, "Weapons/SpecialSword_1") }, { "Weapons/SpecialSword_2", Tuple.Create(91, "Weapons/SpecialSword_2") }, { "Weapons/SpecialSword_3", Tuple.Create(91, "Weapons/SpecialSword_3") }, { "Weapons/SpecialSword_4", Tuple.Create(91, "Weapons/SpecialSword_4") }, { "MonsterHeart_glow", Tuple.Create(93, "MonsterHeart_glow") }, { "KnowledgeParchment", Tuple.Create(93, "KnowledgeParchment") }, { "Knowledge_Trinket", Tuple.Create(93, "Knowledge_Trinket") }, { "Knowledge_Curse", Tuple.Create(93, "Knowledge_Curse") }, { "Knowledge_Decoration", Tuple.Create(93, "Knowledge_Decoration") }, { "Knowledge_Weapon", Tuple.Create(93, "Knowledge_Weapon") }, { "Tools/Woodaxe", Tuple.Create(93, "Tools/Woodaxe") }, { "Tools/Woodaxe2", Tuple.Create(93, "Tools/Woodaxe2") }, { "Tools/Pickaxe", Tuple.Create(93, "Tools/Pickaxe") }, { "Tools/Pickaxe2", Tuple.Create(93, "Tools/Pickaxe2") }, { "Tools/Hammer", Tuple.Create(93, "Tools/Hammer") }, { "Net", Tuple.Create(93, "Net") }, { "Items/WebberSkull", Tuple.Create(93, "Items/WebberSkull") }, { "Tools/Book_open2", Tuple.Create(93, "Tools/Book_open") }, { "Tools/Book_closed2", Tuple.Create(93, "Tools/Book_closed") }, { "MonsterHeart_glow2", Tuple.Create(94, "MonsterHeart_glow") }, { "GiftSmall", Tuple.Create(94, "GiftSmall") }, { "GiftMedium", Tuple.Create(94, "GiftMedium") }, { "RedHeartPickUp", Tuple.Create(94, "Red Heart Pick Up") }, { "effects/MonsterBlood1a", Tuple.Create(95, "effects/MonsterBlood1") }, { "effects/MonsterBlood1b", Tuple.Create(96, "effects/MonsterBlood1") }, { "MonsterBlood2", Tuple.Create(97, "MonsterBlood2") }, { "Tools/CardBack", Tuple.Create(98, "Tools/CardBack") }, { "Tools/CardFront", Tuple.Create(98, "Tools/CardFront") }, { "Tools/CardBack2", Tuple.Create(99, "Tools/CardBack") }, { "Tools/CardFront2", Tuple.Create(99, "Tools/CardFront") }, { "Tools/CardBack3", Tuple.Create(100, "Tools/CardBack") }, { "Tools/CardFront3", Tuple.Create(100, "Tools/CardFront") }, { "Tools/CardBack4", Tuple.Create(101, "Tools/CardBack") }, { "Tools/CardFront4", Tuple.Create(101, "Tools/CardFront") }, { "Tools/CardBack5", Tuple.Create(102, "Tools/CardBack") }, { "Tools/CardFront5", Tuple.Create(102, "Tools/CardFront") }, { "Tools/CardBack6", Tuple.Create(103, "Tools/CardBack") }, { "Tools/CardFront6", Tuple.Create(103, "Tools/CardFront") }, { "RitualSymbolHalo", Tuple.Create(104, "RitualSymbolHalo") }, { "RitualSymbol_1", Tuple.Create(105, "RitualSymbol_1") }, { "RitualSymbol_2", Tuple.Create(105, "RitualSymbol_2") }, { "effects/RitualRing2", Tuple.Create(106, "effects/RitualRing2") }, { "effects/SermonRing2", Tuple.Create(106, "effects/SermonRing2") }, { "AttackSlash1", Tuple.Create(107, "AttackSlash1") }, { "AttackSlash2", Tuple.Create(107, "AttackSlash2") }, { "effects/RitualRing", Tuple.Create(108, "effects/RitualRing") }, { "effects/SermonRing", Tuple.Create(108, "effects/SermonRing") }, { "CollarPiece1", Tuple.Create(109, "CollarPiece1") }, { "CollarPiece2", Tuple.Create(110, "CollarPiece2") }, { "ChainBit1", Tuple.Create(111, "ChainBit1") }, { "ChainBit2", Tuple.Create(112, "ChainBit2") }, { "ChainBit1b", Tuple.Create(113, "ChainBit1") }, { "ChainBit3", Tuple.Create(114, "ChainBit3") }, { "SwordHeavy", Tuple.Create(116, "SwordHeavy") }, { "Weapons/SwordHeavy_Necromancy", Tuple.Create(116, "Weapons/SwordHeavy_Necromancy") }, { "Weapons/SwordHeavy_Ice", Tuple.Create(116, "Weapons/SwordHeavy_Ice") }, { "Weapons/SwordHeavy_Charm", Tuple.Create(116, "Weapons/SwordHeavy_Charm") }, { "AxeHeavy", Tuple.Create(116, "AxeHeavy") }, { "HammerHeavy", Tuple.Create(116, "HammerHeavy") }, { "Blunderbuss_Heavy", Tuple.Create(116, "Blunderbuss_Heavy") }, { "effects/SpawnHeavy_1", Tuple.Create(117, "effects/SpawnHeavy_1") }, { "effects/SpawnHeavy_2", Tuple.Create(117, "effects/SpawnHeavy_2") }, { "effects/SpawnHeavy_3", Tuple.Create(117, "effects/SpawnHeavy_3") }, { "effects/SpawnHeavy_4", Tuple.Create(117, "effects/SpawnHeavy_4") }, { "SpawnHeavy_glow", Tuple.Create(118, "SpawnHeavy_glow") }, { "FireSmall_0001", Tuple.Create(119, "FireSmall_0001") }, { "FireSmall_0002", Tuple.Create(119, "FireSmall_0002") }, { "FireSmall_0003", Tuple.Create(119, "FireSmall_0003") }, { "FireSmall_0004", Tuple.Create(119, "FireSmall_0004") }, { "FireSmall_0005", Tuple.Create(119, "FireSmall_0005") }, { "FireSmall_0006", Tuple.Create(119, "FireSmall_0006") }, { "FireSmall_0007", Tuple.Create(119, "FireSmall_0007") }, { "FireWild_0001", Tuple.Create(120, "FireWild_0001") }, { "FireWild_0002", Tuple.Create(120, "FireWild_0002") }, { "FireWild_0003", Tuple.Create(120, "FireWild_0003") }, { "FireWild_0004", Tuple.Create(120, "FireWild_0004") }, { "FireWild_0005", Tuple.Create(120, "FireWild_0005") }, { "FireWild_0006", Tuple.Create(120, "FireWild_0006") }, { "FireWild_0007", Tuple.Create(120, "FireWild_0007") }, { "FireWild_0008", Tuple.Create(120, "FireWild_0008") }, { "FireWild_0009", Tuple.Create(120, "FireWild_0009") }, { "effects/chunder_1", Tuple.Create(121, "effects/chunder_1") }, { "effects/chunder_2", Tuple.Create(121, "effects/chunder_2") }, { "effects/chunder_3", Tuple.Create(121, "effects/chunder_3") }, { "Curses/Icon_Curse_Blast", Tuple.Create(122, "Curses/Icon_Curse_Blast") }, { "Curses/Icon_Curse_Fireball", Tuple.Create(122, "Curses/Icon_Curse_Fireball") }, { "Curses/Icon_Curse_Slash", Tuple.Create(122, "Curses/Icon_Curse_Slash") }, { "Curses/Icon_Curse_Splatter", Tuple.Create(122, "Curses/Icon_Curse_Splatter") }, { "Curses/Icon_Curse_Tentacle", Tuple.Create(122, "Curses/Icon_Curse_Tentacle") } }; internal static readonly Dictionary CachedTextures = new Dictionary(); internal static Dictionary?> PlayerSkinOverride { get; set; } = new Dictionary>(); internal static Dictionary PlayerBleatOverride { get; set; } = new Dictionary(); public static void AddPlayerSpine(string name, SkeletonDataAsset? skeletonDataAsset, List options) { if (options.Count == 0) { LogHelper.LogInfo("Must have Spine Options for " + name); return; } string text = name.Replace("/", ""); foreach (string option in options) { CustomPlayerSpines[text + "/" + option] = skeletonDataAsset; } if (Plugin.CustomPlayerSpineSettings != null) { Plugin.CustomPlayerSpineSettings.Options = CustomPlayerSpines.Keys.ToArray(); } if (Plugin.CustomPlayer2SpineSettings != null) { Plugin.CustomPlayer2SpineSettings.Options = CustomPlayerSpines.Keys.ToArray(); } } public static void ChangeSelectedPlayerSpine(string name, int playerId = 0) { string[] array = name.Split(new char[1] { '/' }, 2); bool flag = false; if (!CustomPlayerSpines.ContainsKey(name) || (Object)(object)CustomPlayerSpines[name] == (Object)null) { return; } switch (playerId) { case 0: flag = !SelectedSpine.Split(new char[1] { '/' }, 2)[0].Equals(array[0]); SelectedSpine = name; break; case 1: flag = !SelectedSpine2.Split(new char[1] { '/' }, 2)[0].Equals(array[0]); SelectedSpine2 = name; break; default: flag = true; SelectedSpine = name; break; } LogHelper.LogInfo("Selected Spine P1: " + SelectedSpine + " , P2: " + SelectedSpine2); if (!((Object)(object)PlayerFarming.Instance != (Object)null && flag)) { return; } int num; PlayerFarming obj; if (CoopManager.CoopActive) { num = ((playerId == 1) ? 1 : 0); if (num != 0) { obj = PlayerFarming.players[1]; goto IL_00f2; } } else { num = 0; } obj = PlayerFarming.Instance; goto IL_00f2; IL_00f2: PlayerFarming val = obj; LogHelper.LogWarning("player instance hotswap spine: " + ((object)val)?.ToString() + "!"); string text = ((num != 0) ? SelectedSpine2 : SelectedSpine); if (!(text == "") && CustomPlayerSpines.ContainsKey(text) && !((Object)(object)CustomPlayerSpines[text] == (Object)null)) { val.Start(); NotificationCentre.Instance.PlayGenericNotification("Experimental: Spine hotswap detected! If you encounter any issues, please report them in the COTL Modding Discord.", (Flair)3); } } public static void AddFollowerSpine(string name, SkeletonDataAsset? skeletonDataAsset) { CustomFollowerSpines[name] = skeletonDataAsset; } public static void ChangeSelectedFollowerSpine(string name, int followerid) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown if (CustomFollowerSpines.ContainsKey(name) && !((Object)(object)CustomFollowerSpines[name] == (Object)null)) { LogHelper.LogInfo($"Selected Follower Spine: {name} for follower {followerid}"); Follower val = FollowerManager.FindFollowerByID(followerid); if (!((Object)(object)val == (Object)null)) { ((SkeletonRenderer)val.Spine).skeletonDataAsset = CustomFollowerSpines[name]; ((SkeletonRenderer)val.Spine).Initialize(true); val.Spine.AnimationState.Start -= new TrackEntryDelegate(val.SetEmotionAnimation); val.Spine.AnimationState.Start += new TrackEntryDelegate(val.SetEmotionAnimation); LogHelper.LogInfo($"Changed Follower {followerid} Spine to {name}"); } } } public static void AddFollowerSkin(CustomFollowerSkin followerSkin) { AddFollowerSkin(new List(1) { followerSkin }); } public static void AddFollowerSkin(List followerVariants) { List variants = followerVariants.Select((CustomFollowerSkin f) => f.GenerateAtlasText()).ToList(); CustomFollowerSkin customFollowerSkin = followerVariants[0]; AddFollowerSkin(customFollowerSkin.Name, customFollowerSkin.Texture, variants, customFollowerSkin.Colors, customFollowerSkin.Hidden, customFollowerSkin.Unlocked, customFollowerSkin.TwitchPremium, customFollowerSkin.Invariant); } public static void AddFollowerSkin(string name, Texture2D sheet, List variants, List colors, bool hidden = false, bool unlocked = true, bool twitchPremium = false, bool invariant = false) { List list = new List(); for (int i = 0; i < variants.Count; i++) { string text = ((i == 0) ? name : (name + "_" + i)); list.Add(text); Material skinMaterial; SpineAtlasAsset atlasAsset; List> overrides = SkinUtils.CreateSkinAtlas(text, sheet, variants[i], RegionOverrideFunction, out skinMaterial, out atlasAsset); SkinTextures.Add(text, sheet); SkinMaterials.Add(text, skinMaterial); CustomAtlases.Add(text, atlasAsset); CreateFollowerSkin(text, overrides, unlocked); } CreateNewFollowerType(name, list, colors, hidden, twitchPremium, invariant); } public static void AddPlayerSkin(CustomPlayerSkin playerSkin) { CustomPlayerSkins.Add(playerSkin.Name, playerSkin); if (Plugin.LambFleeceSkinSettings != null) { Plugin.LambFleeceSkinSettings.Options = CustomPlayerSkins.Keys.ToArray(); } if (Plugin.GoatFleeceSkinSettings != null) { Plugin.GoatFleeceSkinSettings.Options = CustomPlayerSkins.Keys.ToArray(); } } private static List> RegionOverrideFunction(AtlasRegion region) { string text = region.name; string text2 = ""; if (text.Contains("#")) { string[] array = text.Split(new char[1] { '#' }); text2 = "#" + array[1]; text = array[0]; } if (FollowerSkinDict.TryGetValue(text, out Tuple value)) { region.name = value.Item1 + ":" + value.Item2 + text2; return new List>(1) { value }; } if (!text.Contains(":")) { return new List>(); } try { string text3 = text.Split(new char[1] { ':' })[1]; int item = (int)(SkinSlots)Enum.Parse(typeof(SkinSlots), text.Split(new char[1] { ':' })[0], ignoreCase: true); region.name = item + ":" + text3 + "#" + text2; return new List>(1) { Tuple.Create(item, text3) }; } catch (Exception) { } return new List>(); } internal static void CreateNewFollowerType(string name, List variantNames, List colors, bool hidden = false, bool twitchPremium = false, bool invariant = false) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0060: 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_0072: Expected O, but got Unknown List skin = ((IEnumerable)variantNames).Select((Func)((string v) => new CharacterSkin { Skin = v })).ToList(); WorshipperData.Instance.Characters.Add(new SkinAndData { Title = name, Skin = skin, SlotAndColours = colors, TwitchPremium = twitchPremium, _hidden = hidden, _dropLocation = (DropLocation)4, _invariant = invariant }); } internal static void CreateFollowerSkin(string name, List> overrides, bool unlocked) { string name2 = name; List> overrides2 = overrides; if (Plugin.Started) { Action(); } else { Plugin.OnStart += Action; } void Action() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Skin to = new Skin(name2); Skin value = SkinUtils.ApplyAllOverrides(((SkeletonRenderer)WorshipperData.Instance.SkeletonData).Skeleton.Data.FindSkin("Dog"), to, overrides2, SkinMaterials[name2], (AtlasAssetBase)(object)CustomAtlases[name2]); CustomFollowerSkins.Add(name2, value); AlwaysUnlockedSkins.Add(name2, unlocked); } } internal static string GetOrCreateTarotSkin(string internalName, Sprite skin, Sprite? backSkin) { string text = "CustomTarotSkin/" + internalName; if (!TarotSprites.ContainsKey(text)) { TarotSprites.Add(text, skin); } if ((Object)(object)backSkin != (Object)null && !TarotBackSprites.ContainsKey(text)) { TarotBackSprites.Add(text, backSkin); } return text; } internal static Skin CreateOrGetTarotSkinFromTemplate(SkeletonData template, string skinName) { if (!TarotSkins.TryGetValue(skinName, out Skin value)) { return CreateTarotSkin(((IEnumerable)template.Skins).ToList()[1], skinName); } return value; } private static Skin CreateTarotSkin(Skin template, string skinName) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) SpineAtlasAsset obj = CreateSingleTextureAtlas(TarotSprites[skinName]); Skin val = new Skin(skinName); AtlasRegion val2 = ((AtlasAssetBase)obj).GetAtlas().FindRegion("GENERIC_ATTACHMENT").Clone(); SkinEntry val3 = template.Attachments.ToList()[0]; ((SkinEntry)(ref val3))..ctor(((SkinEntry)(ref val3)).SlotIndex, ((SkinEntry)(ref val3)).Name, ((SkinEntry)(ref val3)).Attachment.Copy()); Attachment attachment = ((SkinEntry)(ref val3)).Attachment; MeshAttachment val4 = (MeshAttachment)(object)((attachment is MeshAttachment) ? attachment : null); if (val4 != null && TarotBackSprites.TryGetValue(skinName, out Sprite value)) { AtlasRegion val5 = ((AtlasAssetBase)CreateSingleTextureAtlas(value)).GetAtlas().FindRegion("GENERIC_ATTACHMENT").Clone(); float num = 2.1474836E+09f; float num2 = -2.1474836E+09f; float num3 = 2.1474836E+09f; float num4 = -2.1474836E+09f; for (int i = 0; i < ((VertexAttachment)val4).Vertices.Length; i++) { switch (i % 3) { case 0: num3 = Math.Min(num3, ((VertexAttachment)val4).Vertices[i]); num4 = Math.Max(num4, ((VertexAttachment)val4).Vertices[i]); break; case 1: num = Math.Min(num, ((VertexAttachment)val4).Vertices[i]); num2 = Math.Max(num2, ((VertexAttachment)val4).Vertices[i]); break; } } ((Attachment)val4).Name = skinName; AttachmentRegionExtensions.SetRegion(val4, val5, false); val5.name = skinName + "/" + val2.name; val4.HullLength = 4; val4.Triangles = new int[6] { 1, 2, 3, 1, 3, 0 }; float num5 = val5.page.width; float num6 = val5.page.height; float num7 = val5.x; float num8 = val5.y; float num9 = val5.width; float num10 = val5.height; val4.UVs = new float[8] { (num7 + num9) / num5, num8 / num6, (num7 + num9) / num5, (num8 + num10) / num6, num7 / num5, (num8 + num10) / num6, num7 / num5, num8 / num6 }; float[] obj2 = new float[12] { 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f }; obj2[0] = num3; obj2[1] = num; obj2[3] = num4; obj2[4] = num; obj2[6] = num4; obj2[7] = num2; obj2[9] = num3; obj2[10] = num2; ((VertexAttachment)val4).Vertices = obj2; ((VertexAttachment)val4).WorldVerticesLength = 8; val4.UpdateUVs(); val.SetAttachment(((SkinEntry)(ref val3)).SlotIndex, ((SkinEntry)(ref val3)).Name, (Attachment)(object)val4); } else { val.SetAttachment(((SkinEntry)(ref val3)).SlotIndex, ((SkinEntry)(ref val3)).Name, ((SkinEntry)(ref val3)).Attachment); } SkinEntry val6 = template.Attachments.ToList()[1]; ((SkinEntry)(ref val6))..ctor(((SkinEntry)(ref val6)).SlotIndex, ((SkinEntry)(ref val6)).Name, ((SkinEntry)(ref val6)).Attachment.Copy()); Attachment attachment2 = ((SkinEntry)(ref val6)).Attachment; MeshAttachment val7 = (MeshAttachment)(object)((attachment2 is MeshAttachment) ? attachment2 : null); if (val7 != null) { float val8 = 2.1474836E+09f; float val9 = -2.1474836E+09f; float val10 = 2.1474836E+09f; float val11 = -2.1474836E+09f; for (int j = 0; j < ((VertexAttachment)val7).Vertices.Length; j++) { switch (j % 3) { case 0: val10 = Math.Min(val10, ((VertexAttachment)val7).Vertices[j]); val11 = Math.Max(val11, ((VertexAttachment)val7).Vertices[j]); break; case 1: val8 = Math.Min(val8, ((VertexAttachment)val7).Vertices[j]); val9 = Math.Max(val9, ((VertexAttachment)val7).Vertices[j]); break; } } ((Attachment)val7).Name = skinName; AttachmentRegionExtensions.SetRegion(val7, val2, false); val2.name = skinName + "/" + val2.name; float num11 = val2.page.width; float num12 = val2.page.height; float num13 = val2.x; float num14 = val2.y; float num15 = val2.width; float num16 = val2.height; val7.UVs = new float[8] { (num13 + num15) / num11, num14 / num12, (num13 + num15) / num11, (num14 + num16) / num12, num13 / num11, (num14 + num16) / num12, num13 / num11, num14 / num12 }; val7.UpdateUVs(); val.SetAttachment(((SkinEntry)(ref val6)).SlotIndex, ((SkinEntry)(ref val6)).Name, (Attachment)(object)val7); } TarotSkins.Add(skinName, val); return val; } private static SpineAtlasAsset CreateSingleTextureAtlas(Sprite sprite) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown int numGenericAtlases = NumGenericAtlases; Bounds bounds = sprite.bounds; int num = (int)((Bounds)(ref bounds)).size.x; bounds = sprite.bounds; int num2 = (int)((Bounds)(ref bounds)).size.y; string text = $"\r\ngeneric_sheet_{numGenericAtlases}\r\nsize: {num},{num2}\r\nformat: RGBA8888\r\nfilter: Linear,Linear" + "\r\nrepeat: none\r\nGENERIC_ATTACHMENT\r\nrotate: false\r\nxy: 0, 0\r\n" + $"size: {num}, {num2}\r\norig: {num}, {num2}\r\noffset: 0, 0\r\nindex: -1"; Texture texture = (Texture)(object)sprite.texture; ((Object)texture).name = $"generic_sheet_{numGenericAtlases}"; Material val = new Material(Shader.Find("Spine/Skeleton")) { mainTexture = texture }; Material[] array = (Material[])(object)new Material[1] { val }; SpineAtlasAsset result = SpineAtlasAsset.CreateRuntimeInstance(new TextAsset(text), array, true); NumGenericAtlases++; return result; } public static void SetPlayerSkinOverride(PlayerType who, Skin? normalSkin, Skin? hurtSkin = null, Skin? hurtSkin2 = null) { List value = new List(3) { normalSkin, hurtSkin, hurtSkin2 }; PlayerSkinOverride[who] = value; } public static void SetPlayerSkinOverride(PlayerType who, CustomPlayerSkin skin) { skin.Apply(who); } public static void SetPlayerBleatOverride(PlayerType who, PlayerBleat? bleat) { if (bleat == PlayerBleat.DEFAULT) { PlayerBleatOverride[who] = null; } else { PlayerBleatOverride[who] = bleat; } } public static void ResetPlayerSkin() { PlayerSkinOverride = new Dictionary>(); SkinUtils.LambFleeceSkinToLoad = null; SkinUtils.GoatFleeceToLoad = null; } public static void ResetPlayerSkin(PlayerType who) { PlayerSkinOverride[who] = null; if (who == PlayerType.LAMB) { SkinUtils.LambFleeceSkinToLoad = null; } else { SkinUtils.LambFleeceSkinToLoad = null; } } [HarmonyPatch(typeof(SkeletonData), "FindSkin", new Type[] { typeof(string) })] [HarmonyPostfix] private static void SkeletonData_FindSkin(ref Skin? __result, SkeletonData __instance, string skinName) { if (__result != null) { return; } if (skinName.StartsWith("CustomTarotSkin/")) { __result = CreateOrGetTarotSkinFromTemplate(__instance, skinName); return; } if (CustomFollowerSkins.TryGetValue(skinName, out Skin value)) { __result = value; } if (AlwaysUnlockedSkins.TryGetValue(skinName, out var value2) && value2) { DataManager.SetFollowerSkinUnlocked(skinName); } } [HarmonyPatch(typeof(CharacterSkinAlerts), "OnSkinUnlocked", new Type[] { typeof(string) })] [HarmonyPrefix] private static bool CharacterSkinAlerts_OnSkinUnlocked(string skinName) { return false; } [HarmonyPatch(typeof(Graphics), "CopyTexture", new Type[] { typeof(Texture), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(Texture), typeof(int), typeof(int), typeof(int), typeof(int) })] [HarmonyPrefix] private static bool Graphics_CopyTexture(ref Texture src, int srcElement, int srcMip, int srcX, int srcY, int srcWidth, int srcHeight, ref Texture dst, int dstElement, int dstMip, int dstX, int dstY) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) Texture obj = src; Texture2D val = (Texture2D)(object)((obj is Texture2D) ? obj : null); if (val == null) { return true; } if (src.graphicsFormat == dst.graphicsFormat) { return false; } Texture2D val2; if (CachedTextures.TryGetValue(((Object)src).name, out Texture2D value)) { LogHelper.LogDebug($"Using cached texture {((Object)src).name} ({((Texture)value).width}x{((Texture)value).height})"); val2 = value; } else { LogHelper.LogDebug($"Copying texture {((Object)src).name} ({src.width}x{src.height}) to {((Object)dst).name} ({src.width}x{src.height} with different formats: {src.graphicsFormat} to {dst.graphicsFormat}"); val2 = DuplicateTexture((Texture)(object)val, dst.graphicsFormat); CachedTextures[((Object)src).name] = val2; } Texture2D val3 = (Texture2D)dst; Color32[] pixels = val2.GetPixels32(); Color32[] array = (Color32[])(object)new Color32[srcWidth * srcHeight]; for (int i = 0; i < srcHeight; i++) { for (int j = 0; j < srcWidth; j++) { array[i * srcWidth + j] = pixels[(i + srcY) * ((Texture)val2).width + j + srcX]; } } val3.SetPixels32(array); return false; } private static Texture2D DuplicateTexture(Texture source, GraphicsFormat format) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown RenderTexture temporary = RenderTexture.GetTemporary(source.width, source.height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1); Graphics.Blit(source, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(source.width, source.height, format, (TextureCreationFlags)0); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } [HarmonyPatch(typeof(FollowerInformationBox), "ConfigureImpl")] [HarmonyPostfix] private static void FollowerInformationBox_ConfigureImpl(FollowerInformationBox __instance) { if (SkinTextures.ContainsKey(((FollowerSelectItem)__instance).FollowerInfo.SkinName)) { __instance.FollowerSpine.Skeleton.Skin = CustomFollowerSkins[((FollowerSelectItem)__instance).FollowerInfo.SkinName]; } } [HarmonyPatch(typeof(UIFollowerIndoctrinationMenuController), "OnShowStarted")] [HarmonyPostfix] private static void UIFollowerIndoctrinationMenuController_OnShowStarted(UIFollowerIndoctrinationMenuController __instance) { Object.Destroy((Object)(object)((Component)__instance).gameObject.GetComponentsInChildren(typeof(TranslucentImage))[0].gameObject); } [HarmonyPatch(typeof(PlayerFarming), "SetSkin", new Type[] { typeof(bool) })] [HarmonyPrefix] private static bool PlayerFarming_SetSkin(ref Skin __result, PlayerFarming __instance, bool BlackAndWhite) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Invalid comparison between Unknown and I4 //IL_0117: Unknown result type (might be due to invalid IL or missing references) PlayerType playerType = ((!__instance.isLamb || __instance.IsGoat) ? PlayerType.GOAT : PlayerType.LAMB); SkinUtils.InvokeOnFindSkin(playerType); string text = ((CoopManager.CoopActive && __instance.playerID == 1) ? SelectedSpine2 : SelectedSpine); if (!PlayerSkinOverride.ContainsKey(playerType) && !CustomPlayerSpines.ContainsKey(text)) { return true; } __instance.IsGoat = DataManager.Instance.PlayerVisualFleece == 1003; __instance.PlayerSkin = new Skin("Player Skin"); List list = null; if (PlayerSkinOverride.ContainsKey(playerType) && !CustomPlayerSpines.ContainsKey(text)) { list = PlayerSkinOverride[playerType]; if (list == null) { return true; } Skin val = list[0]; __instance.PlayerSkin.AddSkin(val); } else { string text2 = text.Split(new char[1] { '/' }, 2)[1]; __instance.PlayerSkin.AddSkin(((SkeletonRenderer)__instance.Spine).Skeleton.Data.FindSkin(text2)); } Skins val2 = (Skins)0; string text3 = ((object)(Skins)(ref val2)).ToString(); if ((int)__instance.currentWeapon != 9999) { text3 = ((object)(Skins)(ref EquipmentManager.GetWeaponData(__instance.currentWeapon).Skin)).ToString(); } Skin val3 = ((SkeletonRenderer)__instance.Spine).Skeleton.Data.FindSkin("Weapons/" + text3); __instance.PlayerSkin.AddSkin(val3); if (((Health)__instance.health).HP + ((Health)__instance.health).BlackHearts + ((Health)__instance.health).BlueHearts + ((Health)__instance.health).SpiritHearts <= 1f && !Mathf.Approximately(DataManager.Instance.PLAYER_TOTAL_HEALTH, 2f)) { Skin val4 = ((SkeletonRenderer)__instance.Spine).Skeleton.Data.FindSkin("Hurt2"); if (list != null) { if (list[2] != null) { val4 = list[2]; } else if (list[1] != null) { val4 = list[1]; } else if (list[0] != null) { val4 = list[0]; } } __instance.PlayerSkin.AddSkin(val4); } else if ((((Health)__instance.health).HP + ((Health)__instance.health).BlackHearts + ((Health)__instance.health).BlueHearts + ((Health)__instance.health).SpiritHearts <= 2f && !Mathf.Approximately(DataManager.Instance.PLAYER_TOTAL_HEALTH, 2f)) || (((Health)__instance.health).HP + ((Health)__instance.health).BlackHearts + ((Health)__instance.health).BlueHearts + ((Health)__instance.health).SpiritHearts <= 1f && Mathf.Approximately(DataManager.Instance.PLAYER_TOTAL_HEALTH, 2f))) { Skin val5 = ((SkeletonRenderer)__instance.Spine).Skeleton.Data.FindSkin("Hurt1"); if (list != null) { if (list[1] != null) { val5 = list[1]; } else if (list[0] != null) { val5 = list[0]; } } __instance.PlayerSkin.AddSkin(val5); } __instance.PlayerSkin.AddSkin(((SkeletonRenderer)__instance.Spine).Skeleton.Data.FindSkin("Mops/" + Mathf.Clamp(__instance.isLamb ? (DataManager.Instance.ChoreXPLevel + 1) : (DataManager.Instance.ChoreXPLevel_Coop + 1), 0, 9))); ((SkeletonRenderer)__instance.Spine).Skeleton.SetSkin(__instance.PlayerSkin); ((SkeletonRenderer)__instance.Spine).Skeleton.SetToSetupPose(); __result = __instance.PlayerSkin; return false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static bool PlayerFarming_BleatRoutine(PlayerFarming __instance) { PlayerType key = PlayerType.LAMB; LogHelper.LogInfo("IsLamb" + __instance.isLamb); LogHelper.LogInfo("IsGoat" + __instance.IsGoat); PlayerFarming instance = PlayerFarming.players[0]; if (CoopManager.CoopActive) { key = ((!__instance.isLamb || __instance.IsGoat) ? PlayerType.GOAT : PlayerType.LAMB); instance = ((!__instance.isLamb || __instance.IsGoat) ? PlayerFarming.players[1] : PlayerFarming.players[0]); } if (!PlayerBleatOverride.ContainsKey(key)) { return true; } PlayerBleat? bleatOverride = PlayerBleatOverride[key]; if (!bleatOverride.HasValue) { return true; } ((MonoBehaviour)PlayerFarming.Instance).StartCoroutine(BleatOverrideRoutine(instance, bleatOverride)); return false; } [HarmonyPatch(typeof(PlayerFarming), "Awake")] [HarmonyPrefix] private static bool PlayerFarming_Awake(PlayerFarming __instance) { if (!CustomPlayerSpines.ContainsKey("Default")) { AddPlayerSpine("Default", ((SkeletonRenderer)__instance.Spine).skeletonDataAsset, new List(4) { "Lamb", "Goat", "Owl", "Snake" }); } return true; } [HarmonyPatch(typeof(PlayerFarming), "Start")] [HarmonyPrefix] private static bool PlayerFarming_Start(PlayerFarming __instance) { //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown PlayerFarming __instance2 = __instance; string text = ((CoopManager.CoopActive && __instance2.playerID == 1) ? SelectedSpine2 : SelectedSpine); if (text == "") { return true; } if (!CustomPlayerSpines.ContainsKey(text)) { return true; } if ((Object)(object)CustomPlayerSpines[text] == (Object)null) { return true; } __instance2.simpleSpineAnimator = ((Component)__instance2).GetComponentInChildren(); MulticastDelegate multicastDelegate; try { LogHelper.LogWarning("Reflection start BEFORE"); AnimationState animationState = __instance2.simpleSpineAnimator.anim.AnimationState; FieldInfo? field = ((object)animationState).GetType().GetField("Event", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); LogHelper.LogWarning("Reflection field 1"); multicastDelegate = field.GetValue(animationState) as MulticastDelegate; LogHelper.LogWarning("Reflection field 2 delegate success, size is " + multicastDelegate.GetInvocationList().Length); LinqExtensions.ForEach((IEnumerable)multicastDelegate.GetInvocationList(), (Action)delegate(Delegate x) { __instance2.simpleSpineAnimator.anim.AnimationState.Event += (TrackEntryEventDelegate)(object)((x is TrackEntryEventDelegate) ? x : null); }); } catch (Exception ex) { multicastDelegate = null; LogHelper.LogWarning(ex.ToString()); } string text2 = text.Split(new char[1] { '/' }, 2)[1]; SkeletonDataAsset skeletonDataAsset = CustomPlayerSpines[text]; ((SkeletonRenderer)__instance2.Spine).skeletonDataAsset = skeletonDataAsset; ((SkeletonRenderer)__instance2.Spine).initialSkinName = text2; ((SkeletonRenderer)__instance2.Spine).Initialize(true); __instance2.Spine.AnimationState.ClearTracks(); __instance2.Spine.AnimationState.SetEmptyAnimation(0, 0f); try { if ((object)multicastDelegate != null) { Delegate[] invocationList = multicastDelegate.GetInvocationList(); foreach (Delegate @delegate in invocationList) { LogHelper.LogWarning("Attempting to Reapply animation handler - " + @delegate.GetMethodInfo().DeclaringType?.ToString() + "." + @delegate.GetMethodInfo().Name); __instance2.simpleSpineAnimator.anim.AnimationState.Event -= (TrackEntryEventDelegate)(object)((@delegate is TrackEntryEventDelegate) ? @delegate : null); __instance2.simpleSpineAnimator.anim.AnimationState.Event += (TrackEntryEventDelegate)(object)((@delegate is TrackEntryEventDelegate) ? @delegate : null); } } } catch (Exception ex2) { LogHelper.LogWarning("Error trying to add animation handlers! Some actions may not work! " + ex2.ToString()); } __instance2.simpleSpineAnimator.anim.AnimationState.Event -= new TrackEntryEventDelegate(__instance2.simpleSpineAnimator.SpineEventHandler); __instance2.simpleSpineAnimator.anim.AnimationState.Event += new TrackEntryEventDelegate(__instance2.simpleSpineAnimator.SpineEventHandler); ((SkeletonRenderer)__instance2.Spine).CustomMaterialOverride.Clear(); ((SkeletonRenderer)__instance2.Spine).CustomSlotMaterials.Clear(); SkeletonRendererCustomMaterials[] componentsInChildren = ((Component)__instance2).GetComponentsInChildren(); foreach (SkeletonRendererCustomMaterials obj in componentsInChildren) { obj.customMaterialOverrides.Clear(); obj.customSlotMaterials.Clear(); ((Behaviour)obj).enabled = false; } LogHelper.LogInfo("PLAYERFARMING_START: Loaded Custom Spine " + text + " with skin " + text2 + " For player ID " + __instance2.playerID); return true; } [HarmonyPatch(typeof(PlayerFarming), "OnEnable")] [HarmonyPrefix] private static bool PlayerFarming_OnEnable(PlayerFarming __instance) { if (PlayerFarming.players.Count <= 0 || (Object)(object)PlayerFarming.Instance == (Object)null) { return true; } LogHelper.LogInfo("PLAYERFARMING_ONENABLE (Respawn/Others): Reapplying Custom Spine!"); __instance.Start(); return true; } [HarmonyPatch(typeof(PlayerPrisonerController), "Start")] [HarmonyPrefix] private static bool PlayerPrisonerController_Start(PlayerPrisonerController __instance) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown string selectedSpine = SelectedSpine; if (selectedSpine == "") { return true; } if (!CustomPlayerSpines.ContainsKey(selectedSpine)) { return true; } if ((Object)(object)CustomPlayerSpines[selectedSpine] == (Object)null) { return true; } string text = selectedSpine.Split(new char[1] { '/' }, 2)[1]; SkeletonDataAsset val = CustomPlayerSpines[selectedSpine]; Skin val2 = ((val != null) ? val.skeletonData.FindSkin("Lamb_Intro") : null) ?? ((SkeletonRenderer)__instance.Spine).skeleton.Skin; ((SkeletonRenderer)__instance.Spine).skeletonDataAsset = val; ((SkeletonRenderer)__instance.Spine).initialSkinName = text; ((SkeletonRenderer)__instance.Spine).Initialize(true); Skin val3 = new Skin("temp"); val3.AddSkin(((SkeletonRenderer)__instance.Spine).skeleton.Skin); foreach (var item in new List<(string, string)>(14) { ("images/PonchoLeft", "PonchoLeft"), ("images/PonchoRight", "PonchoRight"), ("images/PonchoLeft", "PonchoLeft2"), ("images/PonchoRight", "PonchoRight2"), ("images/PonchoExtra", "PonchoExtra"), ("images/PonchoRightCorner2", "PonchoRightCorner"), ("images/PonchoRightCorner", "PonchoRightCorner"), ("images/PonchoShoulder", "PonchoShoulder"), ("images/PonchoShoulder2", "PonchoShoulder_Right"), ("RopeTopLeft", "images/RopeTopLeft"), ("RopeTopRight", "images/RopeTopRight"), ("images/Rope", "images/Rope"), ("images/Bell", "Bell"), ("images/Body", "Body") }) { int num = ((SkeletonRenderer)__instance.Spine).Skeleton.FindSlotIndex(item.Item1); Attachment attachment = val2.GetAttachment(num, item.Item2); if (attachment == null) { val3.RemoveAttachment(num, item.Item2); } else { val3.SetAttachment(num, item.Item2, attachment); } } ((SkeletonRenderer)__instance.Spine).skeleton.SetSkin(val3); ((SkeletonRenderer)__instance.Spine).skeleton.SetToSetupPose(); __instance.Spine.AnimationState.SetAnimation(0, "intro/idle", true); LogHelper.LogInfo("INTRO PLAYER (Others): Loaded Custom Spine " + selectedSpine + " with skin " + text); return true; } [IteratorStateMachine(typeof(d__57))] private static IEnumerator BleatOverrideRoutine(PlayerFarming instance, PlayerBleat? bleatOverride) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__57(0) { instance = instance, bleatOverride = bleatOverride }; } } internal class OverridingPlayerSkin : CustomPlayerSkin { private Skin? _cachedSkin; internal Func overrideSkin; public override string Name { get; } public override Texture2D Texture => null; public override List Overrides => null; public OverridingPlayerSkin(string name, Func overrideSkin) { this.overrideSkin = overrideSkin; Name = name; base..ctor(); } public override void Apply(PlayerType who = PlayerType.LAMB) { if (who == PlayerType.LAMB) { if (!SkinUtils.LambFleeceSkinLoaded) { SkinUtils.LambFleeceSkinToLoad = Action; } else { Action(); } } else if (!SkinUtils.GoatFleeceSkinLoaded) { SkinUtils.GoatFleeceToLoad = Action; } else { Action(); } void Action() { if (who == PlayerType.LAMB && Name == "Lamb") { CustomSkinManager.ResetPlayerSkin(who); } else { if (_cachedSkin == null) { _cachedSkin = overrideSkin(); } CustomSkinManager.SetPlayerSkinOverride(who, _cachedSkin); } } } } public enum SkinSlots { OTHER_STOCKS, OTHER_CRUCIFIX_BTM, OTHER_CRUCIFIX_TOP, PORTAL_MASK, OTHER_PORTAL, OTHER_PORTALRING, OTHER_PORTALRING4, OTHER_PORTALRING5, OTHER_PORTALRING2, OTHER_PORTALRING3, OTHER_PORTALRING6, OTHER_PORTALOUTLINE, OTHER_SHERPA_BACK, OTHER_SHERPA_BAG, OTHER_SHERPA_LANTERN, OTHER_CONVERTFOLLOWERRING2, OTHER_CONVERTFOLLOWERRING, TELEPORT, OTHER_CONVERSION_GLOW, OTHER_CONVERSION_GLOW2, OTHER_CONVERT_BURST, OTHER_CONVERT_BURST2, OTHER_CONVERT_BURST6, OTHER_CONVERT_BURST7, OTHER_CONVERT_BURST3, OTHER_CONVERT_BURST4, OTHER_CONVERT_BURST5, OTHER_TENTACLE_3, OTHER_TENTACLE_5, OTHER_TENTACLE_2, OTHER_TENTACLE_4, TENTACLESMALL1, TENTACLESMALL2, TENTACLEMEDIUM, TENTACLEMEDIUM2, OTHER_TENTACLE_END, TOOL, ARM_LEFT_DEAD, ARM_LEFT_SKIN, SLEEVE_LEFT, SLEEVE_LEFT_GLOW, OTHER_CORPSE, ARROW, BOWSTRING, MASK, SWORD, WARRIOR_SWORD, BOW, BOW_HAND, BODY_WEAPONHAND, LEG_LEFT_SKIN, LEG_RIGHT_SKIN, LEG_LEFT_DEAD, LEG_RIGHT_DEAD, BODY_SKIN, BODY_BODY_GLOW, RELOAD_ARROW, TOOLS_QUILL, TOOLS_HAMMER, BOWLBTM, BOWLFOOD, BOWLTOP, NECKLACE, OTHER_TENTACLE_COIL, OTHER_TENTACLE_1, TENTACLEMAIN1, ARM_RIGHT_DEAD, ARM_RIGHT_SKIN, SLEEVE_RIGHT_SKIN, SLEEVE_RIGHT_GLOW, OTHER_CRUCIFIX_ROPE, OTHER_CRUCIFIX_ROPE2, OTHER_CRUCIFIX_ROPE3, SHAWL, OTHER_SPIDER, EXTRA_BTM, HEAD_SKIN_BTM, HEAD_HEADDEAD, HEAD_SKIN_TOP, MARKINGS, EXTRA_TOP, FACE_COLOURING, MOUTH, HOOD, EYE_RIGHT, EYE_LEFT, HEADACCESSORY, HAT, BLACKGOO1, BLACKGOO6, BLACKGOO7, BLACKGOO2, BLACKGOO3, BLACKGOO4, BLACKGOO5, OTHER_CONVERTPARTICLE1, OTHER_CONVERTPARTICLE9, OTHER_CONVERTPARTICLE2, OTHER_CONVERTPARTICLE10, OTHER_CONVERTPARTICLE3, OTHER_CONVERTPARTICLE11, OTHER_CONVERTPARTICLE4, OTHER_CONVERTPARTICLE12, OTHER_CONVERTPARTICLE8, OTHER_CONVERTPARTICLE13, OTHER_CONVERTPARTICLE5, OTHER_CONVERTPARTICLE14, OTHER_CONVERTPARTICLE6, OTHER_CONVERTPARTICLE15, OTHER_CONVERTPARTICLE7, OTHER_CONVERTPARTICLE16, BOOK, CHALICE, OTHER_TELESCOPE_LEGS, OTHER_TELESCOPE_TOP, OTHER_TELESCOPE_FRONT, OTHER_HAND_PINCH, OTHER_BUBBLE, OTHER_CHUNDER_1, POSSESSED_CHUNDER, OTHER_SACRIFICE_ICON, OTHER_TEAR1, OTHER_TEAR3, OTHER_TEAR4, OTHER_TEAR5, OTHER_TEAR6, OTHER_TEAR7, OTHER_TEAR2, OTHER_FLY, OTHER_FLY2, OTHER_FLY3, ITEM, ITEM2, OTHER_BEDREST_BANDAGE, GIFTBURST, OTHER_SHERPA_LANTERN_UP, OTHER_SHERPA_BAG_UP, OTHER_SHERPA_BACK_UP, OTHER_ATTACKSLASH1, OTHER_COFFIN_FRONT, OTHER_COFFIN_BACK, HAT_NORMAL, HAT_UP } internal static class SkinUtils { public static bool LambFleeceSkinLoaded { get; internal set; } public static Action? LambFleeceSkinToLoad { get; set; } = delegate { }; public static bool GoatFleeceSkinLoaded { get; internal set; } public static Action? GoatFleeceToLoad { get; set; } = delegate { }; public static event Action OnFindLambFleeceSkin; public static event Action OnFindGoatFleeceSkin; public static void ApplyOverride(Skin skin, Attachment a, int slot, string ovrName, AtlasRegion atlasRegion, float scaleX, float scaleY, float translationX, float translationY) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown MeshAttachment val = (MeshAttachment)(object)((a is MeshAttachment) ? a : null); if (val == null) { RegionAttachment val2 = (RegionAttachment)(object)((a is RegionAttachment) ? a : null); if (val2 != null) { ((Attachment)val2).Name = "Custom" + ovrName; atlasRegion.name = "Custom" + atlasRegion.name; AttachmentRegionExtensions.SetRegion(val2, atlasRegion, true); val2.X += translationX; val2.Y += translationY; val2.ScaleX = scaleX; val2.ScaleY = scaleY; val2.rotation = -90f; skin.SetAttachment(slot, ovrName, (Attachment)(object)val2); } else { LogHelper.LogWarning("Attachment " + a.Name + " is not a MeshAttachment or RegionAttachment, skipping..."); } return; } float num = 2.1474836E+09f; float num2 = -2.1474836E+09f; float num3 = 2.1474836E+09f; float num4 = -2.1474836E+09f; for (int i = 0; i < ((VertexAttachment)val).Vertices.Length; i++) { switch (i % 3) { case 0: num3 = Math.Min(num3, ((VertexAttachment)val).Vertices[i]); num4 = Math.Max(num4, ((VertexAttachment)val).Vertices[i]); break; case 1: num = Math.Min(num, ((VertexAttachment)val).Vertices[i]); num2 = Math.Max(num2, ((VertexAttachment)val).Vertices[i]); break; } } float num5 = num2 - num; float num6 = num4 - num3; float num7 = num + num5 / 2f; float num8 = num3 + num6 / 2f; RegionAttachment val3 = new RegionAttachment("Custom" + ovrName); AttachmentRegionExtensions.SetRegion(val3, atlasRegion, true); val3.X = num8 - translationY; val3.Y = num7 - translationX; val3.rotation = -90f; val3.ScaleX = scaleX; val3.ScaleY = scaleY; val3.Width = num5; val3.Height = num6; skin.SetAttachment(slot, ovrName, (Attachment)(object)val3); } public static Skin ApplyAllOverrides(Skin from, Skin to, List> overrides, Material material, AtlasAssetBase atlas) { Skin to2 = to; string name = to2.name; from.Attachments.ToList().ForEach(delegate(SkinEntry att) { to2.SetAttachment(((SkinEntry)(ref att)).SlotIndex, ((SkinEntry)(ref att)).Name, ((SkinEntry)(ref att)).Attachment.Copy()); }); ((IEnumerable)from.Bones).ToList().ForEach((Action)to2.Bones.Add); ((IEnumerable)from.Constraints).ToList().ForEach((Action)to2.Constraints.Add); foreach (Tuple @override in overrides) { @override.Deconstruct(out var item, out var item2, out var item3, out var item4, out var item5, out var item6); int num = item; string text = item2; float translationX = item3; float translationY = item4; float scaleX = item5; float scaleY = item6; AtlasRegion atlasRegion = atlas.GetAtlas().FindRegion(num + ":" + text); Attachment attachment = from.GetAttachment(num, text); if (attachment != null) { attachment = attachment.Copy(); ApplyOverride(to2, attachment, num, text, atlasRegion, scaleX, scaleY, translationX, translationY); } } Material val = default(Material); Texture2D val2 = default(Texture2D); Skin repackedSkin = AtlasUtilities.GetRepackedSkin(to2, name, material, ref val, ref val2, 1024, 2, (TextureFormat)4, false, true, false, (int[])null, (Texture2D[])null, (TextureFormat[])null, (bool[])null); CustomSkinManager.CachedTextures.Clear(); AtlasUtilities.ClearCache(); return repackedSkin; } public static List> CreateSkinAtlas(string name, Texture2D sheet, string atlasText, Func>> regionOverrideFunction, out Material skinMaterial, out SpineAtlasAsset atlasAsset) { //IL_0037: 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_0044: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown ((Object)sheet).name = atlasText.Replace("\r", "").Split(new char[1] { '\n' })[1].Trim(); Material val = (skinMaterial = new Material(Shader.Find("Spine/Skeleton")) { mainTexture = (Texture)(object)sheet }); Material[] array = (Material[])(object)new Material[1] { val }; SpineAtlasAsset val2 = (atlasAsset = SpineAtlasAsset.CreateRuntimeInstance(new TextAsset(atlasText), array, true)); List> list = new List>(); foreach (List> item in ((AtlasAssetBase)val2).GetAtlas().regions.Select(regionOverrideFunction)) { list.AddRange(item); } List> list2 = new List>(); List regions = ((AtlasAssetBase)val2).GetAtlas().regions; for (int i = 0; i < regions.Count; i++) { float[] array2 = new float[4] { 0f, 0f, 1f, 1f }; AtlasRegion val3 = regions[i]; string[] array3 = val3.name.Split(new char[1] { '#' }); if (array3.Length == 2) { string[] array4 = array3[1].Split(new char[1] { ',' }); switch (array4.Length) { case 2: array2[2] = float.Parse(array4[0]); array2[3] = float.Parse(array4[1]); break; case 4: array2[0] = float.Parse(array4[2]); array2[1] = float.Parse(array4[3]); array2[2] = float.Parse(array4[0]); array2[3] = float.Parse(array4[1]); break; default: LogHelper.LogWarning($"Invalid scale length, Expected 3 or 4, got {array2.Length}."); break; } val3.name = array3[0]; } list2.Add(Tuple.Create(list[i].Item1, list[i].Item2, array2[0], array2[1], array2[2], array2[3])); } return list2; } internal static void InvokeOnFindSkin(PlayerType who) { if (who == PlayerType.LAMB) { SkinUtils.OnFindLambFleeceSkin(); SkinUtils.OnFindLambFleeceSkin = delegate { }; } else { SkinUtils.OnFindGoatFleeceSkin(); SkinUtils.OnFindGoatFleeceSkin = delegate { }; } } static SkinUtils() { SkinUtils.OnFindLambFleeceSkin = delegate { LambFleeceSkinToLoad(); LambFleeceSkinLoaded = true; }; SkinUtils.OnFindGoatFleeceSkin = delegate { GoatFleeceToLoad(); GoatFleeceSkinLoaded = true; }; } } } namespace COTL_API.CustomSettings { public static class CustomSettingsManager { internal static List SettingsElements { get; } = new List(); internal static ReadOnlyCollection Sliders => SettingsElements.OfType().ToList().AsReadOnly(); internal static ReadOnlyCollection Dropdowns => SettingsElements.OfType().ToList().AsReadOnly(); internal static ReadOnlyCollection HorizontalSelectors => SettingsElements.OfType().ToList().AsReadOnly(); internal static ReadOnlyCollection Toggles => SettingsElements.OfType().ToList().AsReadOnly(); public static Slider AddSlider(string? category, string text, float value, float min, float max, int increment, ValueDisplayFormat displayFormat, Action? onValueChanged = null) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (onValueChanged == null) { onValueChanged = delegate { }; } Slider slider = new Slider(category, text, value, min, max, increment, displayFormat, onValueChanged); SettingsElements.Add(slider); return slider; } public static Slider? AddSavedSlider(string? category, string guid, string text, float value, float min, float max, int increment, ValueDisplayFormat displayFormat, Action? onValueChanged = null) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Action onValueChanged2 = onValueChanged; if (Plugin.SettingsData == null) { return null; } string fullGuid = guid + "." + category + "." + text; if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } if (!Plugin.SettingsData.ContainsKey(fullGuid)) { Plugin.SettingsData.Add(fullGuid, value); } Slider slider = new Slider(category, text, Plugin.SettingsData.GetValueAsFloat(fullGuid), min, max, increment, displayFormat, delegate(float newValue) { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.SettingsData.SetValue(fullGuid, newValue); Plugin.Instance.ModdedSettingsData.Save(); } onValueChanged2(newValue); }); SettingsElements.Add(slider); return slider; } public static Dropdown AddDropdown(string? category, string text, string? value, string?[] options, Action? onValueChanged = null) { if (onValueChanged == null) { onValueChanged = delegate { }; } Dropdown dropdown = new Dropdown(category, text, value, options, onValueChanged); SettingsElements.Add(dropdown); return dropdown; } public static Dropdown? AddSavedDropdown(string? category, string guid, string text, string value, string?[] options, Action? onValueChanged = null) { Action onValueChanged2 = onValueChanged; if (Plugin.SettingsData == null) { return null; } string fullGuid = guid + "." + category + "." + text; if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } if (!Plugin.SettingsData.ContainsKey(fullGuid)) { Plugin.SettingsData.Add(fullGuid, value); } Dropdown dropdown = new Dropdown(category, text, Plugin.SettingsData.GetValueAsString(fullGuid), options, null); dropdown.OnValueChanged = delegate(int newValue) { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.SettingsData.SetValue(fullGuid, dropdown.Options[newValue]); Plugin.Instance.ModdedSettingsData.Save(); } onValueChanged2(newValue); }; SettingsElements.Add(dropdown); return dropdown; } public static HorizontalSelector AddHorizontalSelector(string? category, string text, string? value, string?[] options, Action? onValueChanged = null) { if (onValueChanged == null) { onValueChanged = delegate { }; } HorizontalSelector horizontalSelector = new HorizontalSelector(category, text, value, options, onValueChanged); SettingsElements.Add(horizontalSelector); return horizontalSelector; } public static HorizontalSelector? AddSavedHorizontalSelector(string? category, string guid, string text, string value, string?[] options, Action? onValueChanged = null) { Action onValueChanged2 = onValueChanged; if (Plugin.SettingsData == null) { return null; } string fullGuid = guid + "." + category + "." + text; if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } if (!Plugin.SettingsData.ContainsKey(fullGuid)) { Plugin.SettingsData.Add(fullGuid, value); } HorizontalSelector horizontalSelector = new HorizontalSelector(category, text, Plugin.SettingsData.GetValueAsString(fullGuid), options, null); horizontalSelector.OnValueChanged = delegate(int newValue) { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.SettingsData.SetValue(fullGuid, horizontalSelector.Options[newValue]); Plugin.Instance.ModdedSettingsData.Save(); } onValueChanged2(newValue); }; SettingsElements.Add(horizontalSelector); return horizontalSelector; } public static KeyboardShortcutDropdown AddKeyboardShortcutDropdown(string? category, string text, KeyCode? value, Action? onValueChanged = null) { if (onValueChanged == null) { onValueChanged = delegate { }; } KeyboardShortcutDropdown keyboardShortcutDropdown = new KeyboardShortcutDropdown(category, text, value, onValueChanged); SettingsElements.Add(keyboardShortcutDropdown); return keyboardShortcutDropdown; } public static KeyboardShortcutDropdown? AddSavedKeyboardShortcutDropdown(string? category, string guid, string text, KeyCode value, Action? onValueChanged = null) { //IL_00c6: 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) //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) Action onValueChanged2 = onValueChanged; if (Plugin.SettingsData == null) { return null; } string fullGuid = guid + "." + category + "." + text; if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } if (!Plugin.SettingsData.ContainsKey(fullGuid)) { ObjectDictionary? settingsData = Plugin.SettingsData; string key = fullGuid; KeyboardShortcut val = new KeyboardShortcut(value, Array.Empty()); settingsData.Add(key, ((object)(KeyboardShortcut)(ref val)).ToString()); } Enum.TryParse(Plugin.SettingsData.GetValueAsString(fullGuid), out KeyCode result); KeyboardShortcutDropdown keyboardShortcutDropdown = new KeyboardShortcutDropdown(category, text, result, onValueChanged2) { OnValueChanged = delegate(KeyboardShortcut newValue) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.SettingsData.SetValue(fullGuid, ((object)(KeyboardShortcut)(ref newValue)).ToString()); Plugin.Instance.ModdedSettingsData.Save(); } onValueChanged2(newValue); } }; SettingsElements.Add(keyboardShortcutDropdown); return keyboardShortcutDropdown; } public static Toggle AddToggle(string? category, string text, bool value, Action? onValueChanged = null) { if (onValueChanged == null) { onValueChanged = delegate { }; } Toggle toggle = new Toggle(category, text, value, onValueChanged); SettingsElements.Add(toggle); return toggle; } public static Toggle? AddSavedToggle(string? category, string guid, string text, bool value, Action? onValueChanged = null) { Action onValueChanged2 = onValueChanged; if (Plugin.SettingsData == null) { return null; } string fullGuid = "Settings." + guid + "." + category + "." + text; if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } if (!Plugin.SettingsData.ContainsKey(fullGuid)) { Plugin.SettingsData.Add(fullGuid, value); } Toggle toggle = new Toggle(category, text, Plugin.SettingsData.GetValueAsBoolean(fullGuid), delegate(bool newValue) { if ((Object)(object)Plugin.Instance != (Object)null) { Plugin.SettingsData.SetValue(fullGuid, newValue); Plugin.Instance.ModdedSettingsData.Save(); } onValueChanged2(newValue); }); SettingsElements.Add(toggle); return toggle; } public static HorizontalSelector? AddBepInExConfig(string? category, string text, ConfigEntry entry, Action? onValueChanged = null) { ConfigEntry entry2 = entry; Action onValueChanged2 = onValueChanged; AcceptableValueBase acceptableValues = ((ConfigEntryBase)entry2).Description.AcceptableValues; AcceptableValueList acceptedValue = acceptableValues as AcceptableValueList; if (acceptedValue == null) { return null; } if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } HorizontalSelector selector = new HorizontalSelector(category, text, entry2.Value, acceptedValue.AcceptableValues, delegate(int newValue) { entry2.Value = acceptedValue.AcceptableValues[newValue]; onValueChanged2(newValue); }); entry2.SettingChanged += delegate { selector.Value = entry2.Value; }; SettingsElements.Add(selector); return selector; } public static Slider? AddBepInExConfig(string? category, string text, ConfigEntry entry, int increment, ValueDisplayFormat displayFormat, Action? onValueChanged = null) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) ConfigEntry entry2 = entry; Action onValueChanged2 = onValueChanged; if (!(((ConfigEntryBase)entry2).Description.AcceptableValues is AcceptableValueRange val)) { return null; } if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } Slider slider = new Slider(category, text, entry2.Value, val.MinValue, val.MaxValue, increment, displayFormat, delegate(float newValue) { entry2.Value = newValue; onValueChanged2(newValue); }); entry2.SettingChanged += delegate { slider.Value = entry2.Value; }; SettingsElements.Add(slider); return slider; } public static Slider? AddBepInExConfig(string? category, string text, ConfigEntry entry, int increment, ValueDisplayFormat displayFormat, Action? onValueChanged = null) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) ConfigEntry entry2 = entry; Action onValueChanged2 = onValueChanged; if (!(((ConfigEntryBase)entry2).Description.AcceptableValues is AcceptableValueRange val)) { return null; } if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } Slider slider = new Slider(category, text, entry2.Value, val.MinValue, val.MaxValue, increment, displayFormat, delegate(float newValue) { int num = (int)Math.Floor(newValue); entry2.Value = num; onValueChanged2(num); }); entry2.SettingChanged += delegate { slider.Value = entry2.Value; }; SettingsElements.Add(slider); return slider; } public static Toggle AddBepInExConfig(string? category, string text, ConfigEntry entry, Action? onValueChanged = null) { ConfigEntry entry2 = entry; Action onValueChanged2 = onValueChanged; if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } Toggle toggle = new Toggle(category, text, entry2.Value, delegate(bool newValue) { ((ConfigEntryBase)entry2).BoxedValue = newValue; onValueChanged2(newValue); }); entry2.SettingChanged += delegate { toggle.Value = entry2.Value; }; SettingsElements.Add(toggle); return toggle; } public static KeyboardShortcutDropdown AddBepInExConfig(string? category, string text, ConfigEntry entry, Action? onValueChanged = null) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) ConfigEntry entry2 = entry; Action onValueChanged2 = onValueChanged; if (onValueChanged2 == null) { onValueChanged2 = delegate { }; } KeyboardShortcut value = entry2.Value; KeyboardShortcutDropdown dropdown = new KeyboardShortcutDropdown(category, text, ((KeyboardShortcut)(ref value)).MainKey, delegate(KeyboardShortcut newKeyCode) { //IL_0006: 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) entry2.Value = newKeyCode; onValueChanged2(entry2.Value); }); entry2.SettingChanged += delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcutDropdown keyboardShortcutDropdown = dropdown; KeyboardShortcut value2 = entry2.Value; keyboardShortcutDropdown.Value = ((KeyboardShortcut)(ref value2)).MainKey; }; SettingsElements.Add(dropdown); return dropdown; } } } namespace COTL_API.CustomSettings.Elements { public interface ISettingsElement { string? Category { get; } string Text { get; } } public class Slider : ISettingsElement { public string? Category { get; set; } public string Text { get; set; } public float Value { get; set; } public float Min { get; set; } public float Max { get; set; } public int Increment { get; set; } public ValueDisplayFormat DisplayFormat { get; set; } public Action? OnValueChanged { get; set; } string? ISettingsElement.Category => Category; string ISettingsElement.Text => Text; public Slider(string? category, string text, float value, float min, float max, int increment, ValueDisplayFormat displayFormat, Action? onValueChanged) { //IL_002e: 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) Category = category; Text = text; Value = value; Min = min; Max = max; Increment = increment; DisplayFormat = displayFormat; OnValueChanged = onValueChanged; base..ctor(); } } public class Dropdown : ISettingsElement { public string? Category { get; set; } public string Text { get; set; } public string? Value { get; set; } public string?[] Options { get; set; } public Action? OnValueChanged { get; set; } string? ISettingsElement.Category => Category; string ISettingsElement.Text => Text; public Dropdown(string? category, string text, string? value, string?[] options, Action? onValueChanged) { Category = category; Text = text; Value = value; Options = options; OnValueChanged = onValueChanged; base..ctor(); } } public class KeyboardShortcutDropdown : ISettingsElement { public KeyCode? Value { get; set; } public Action? OnValueChanged { get; set; } public string? Category { get; set; } public string Text { get; set; } public KeyboardShortcutDropdown(string? category, string text, KeyCode? value, Action? onValueChanged) { Value = value; OnValueChanged = onValueChanged; Category = category; Text = text; base..ctor(); } } public class HorizontalSelector : ISettingsElement { public string? Category { get; set; } public string Text { get; set; } public string? Value { get; set; } public string?[] Options { get; set; } public Action? OnValueChanged { get; set; } string? ISettingsElement.Category => Category; string ISettingsElement.Text => Text; public HorizontalSelector(string? category, string text, string? value, string?[] options, Action? onValueChanged) { Category = category; Text = text; Value = value; Options = options; OnValueChanged = onValueChanged; base..ctor(); } } public class Toggle : ISettingsElement { public string? Category { get; set; } public string Text { get; set; } public bool Value { get; set; } public Action? OnValueChanged { get; set; } string? ISettingsElement.Category => Category; string ISettingsElement.Text => Text; public Toggle(string? category, string text, bool value, Action? onValueChanged) { Category = category; Text = text; Value = value; OnValueChanged = onValueChanged; base..ctor(); } } } namespace COTL_API.CustomRituals { public abstract class CustomRitual : Ritual { internal string ModPrefix = ""; public abstract string InternalName { get; } public Type UpgradeType { get; set; } public virtual Sprite Sprite { get; } = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual List ItemCosts { get; } = new List(1) { new ItemCost((ITEM_TYPE)1, 1) }; public override Type RitualType => UpgradeType; public virtual string GetLocalizedName => "Custom_Ritual_" + InternalName; public virtual string GetLocalizedDescription => "Custom_Ritual_" + InternalName + "_Description"; public virtual float FaithChange => 5f; public virtual TraitType RitualTrait => (TraitType)0; public virtual float Cooldown => 120f; } [HarmonyPatch] public static class CustomRitualManager { public static Dictionary CustomRitualList { get; } = new Dictionary(); public static Type Add(CustomRitual ritual) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); Type enumValue = GuidManager.GetEnumValue(modIdFromCallstack, ritual.InternalName); ritual.ModPrefix = modIdFromCallstack; ritual.UpgradeType = enumValue; CustomRitualList.Add(enumValue, ritual); return enumValue; } [HarmonyPatch(typeof(UIRitualsMenuController), "OnShowStarted")] [HarmonyPrefix] private static void UIRitualsMenuController_OnShowStarted(UIRitualsMenuController __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) foreach (Type key in CustomRitualList.Keys) { __instance.ConfigureItem(GameObjectExtensions.Instantiate(__instance._ritualItemTemplate, (Transform)(object)__instance._ritualsContent, true), key); } } [HarmonyPatch(typeof(RitualItem), "Configure")] [HarmonyPrefix] private static bool RitualItem_Configure(RitualItem __instance, Type ritualType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!CustomRitualList.ContainsKey(ritualType)) { return true; } if (!DataManager.Instance.UnlockedUpgrades.Contains(ritualType)) { DataManager.Instance.UnlockedUpgrades.Add(ritualType); } return true; } [HarmonyPatch(typeof(RitualIconMapping), "GetImage", new Type[] { typeof(Type) })] [HarmonyPrefix] private static bool DoctrineUpgradeSystem_GetIconForRitual(ref Sprite __result, Type type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomRitualList.TryGetValue(type, out CustomRitual value)) { return true; } __result = value.Sprite; return false; } [HarmonyPatch(typeof(UpgradeSystem), "GetCost")] [HarmonyPrefix] private static bool UpgradeSystem_GetCost(ref List __result, Type Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomRitualList.TryGetValue(Type, out CustomRitual value)) { return true; } __result = value.ItemCosts; return false; } [HarmonyPatch(typeof(UpgradeSystem), "GetLocalizedName")] [HarmonyPrefix] private static bool UpgradeSystem_GetLocalizedName(ref string __result, Type Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomRitualList.TryGetValue(Type, out CustomRitual value)) { return true; } __result = value.GetLocalizedName; return false; } [HarmonyPatch(typeof(UpgradeSystem), "GetLocalizedDescription")] [HarmonyPrefix] private static bool UpgradeSystem_GetLocalizedDescription(ref string __result, Type Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomRitualList.TryGetValue(Type, out CustomRitual value)) { return true; } __result = value.GetLocalizedDescription; return false; } [HarmonyPatch(typeof(UpgradeSystem), "GetRitualFaithChange")] [HarmonyPrefix] private static bool UpgradeSystem_GetRitualFaithChange(ref float __result, Type Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomRitualList.TryGetValue(Type, out CustomRitual value)) { return true; } __result = value.FaithChange; return false; } [HarmonyPatch(typeof(UpgradeSystem), "GetRitualTrait")] [HarmonyPrefix] private static bool UpgradeSystem_GetRitualTrait(ref TraitType __result, Type Type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected I4, but got Unknown if (!CustomRitualList.TryGetValue(Type, out CustomRitual value)) { return true; } __result = (TraitType)(int)value.RitualTrait; return false; } [HarmonyPatch(typeof(Interaction_TempleAltar), "PerformRitual")] [HarmonyPostfix] private static void Interaction_TempleAltar_PerformRitual(Interaction_TempleAltar __instance, Type RitualType) { //IL_0005: 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_0043: Unknown result type (might be due to invalid IL or missing references) if (CustomRitualList.TryGetValue(RitualType, out CustomRitual value)) { CustomRitual customRitual = (CustomRitual)(object)((Component)__instance).gameObject.AddComponent(((object)value).GetType()); customRitual.UpgradeType = CustomRitualList[RitualType].UpgradeType; customRitual.ModPrefix = CustomRitualList[RitualType].ModPrefix; __instance.CurrentRitual = (Ritual)(object)customRitual; __instance.CurrentRitual.Play(); } } [HarmonyPatch(typeof(Interaction_TempleAltar), "RitualOnEnd")] [HarmonyPostfix] private static void Interaction_TempleAltar_RitualOnEnd(Interaction_TempleAltar __instance, bool cancelled) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (CustomRitualList.TryGetValue(__instance.RitualType, out CustomRitual value) && !cancelled) { UpgradeSystem.AddCooldown(__instance.RitualType, value.Cooldown); } } } } namespace COTL_API.CustomRelics { public abstract class CustomRelicData : RelicData { internal string ModPrefix = ""; public abstract string InternalName { get; } public virtual bool CanBeBlessed => false; public virtual bool CanBeDamned => false; public CustomRelicData() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) base.UISprite = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); base.UISpriteOutline = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); base.CleansedSprite = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); base.CleansedSpriteOutline = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); base.InteractionType = (RelicInteractionType)1; } public virtual string GetTitleLocalisation() { return LocalizationManager.GetTermTranslation("Relics/" + ModPrefix + "." + InternalName, true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string GetDescriptionLocalisation() { return LocalizationManager.GetTermTranslation("Relics/" + ModPrefix + "." + InternalName + "/Description", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string GetLoreLocalization() { return LocalizationManager.GetTermTranslation("Relics/" + ModPrefix + "." + InternalName + "/Lore", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual void Init() { } public virtual RelicChargeCategory GetChargeCategory() { if (!((double)base.DamageRequiredToCharge < 50.0)) { if ((double)base.DamageRequiredToCharge < 80.0) { return (RelicChargeCategory)1; } return (RelicChargeCategory)2; } return (RelicChargeCategory)0; } public abstract void OnUse(bool forceConsumableAnimation = false); public virtual void OnUseBlessed(bool forceConsumableAnimation = false) { OnUse(forceConsumableAnimation); } public virtual void OnUseDamned(bool forceConsumableAnimation = false) { OnUse(forceConsumableAnimation); } public virtual void OnUseAny(bool forceConsumableAnimation = false) { OnUse(forceConsumableAnimation); } public CustomRelicData ToBlessed() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) CustomRelicData obj = (CustomRelicData)((object)this).MemberwiseClone(); ((RelicData)obj).RelicSubType = (RelicSubType)2; return obj; } public CustomRelicData ToDamned() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) CustomRelicData obj = (CustomRelicData)((object)this).MemberwiseClone(); ((RelicData)obj).RelicSubType = (RelicSubType)1; return obj; } } [HarmonyPatch] public static class CustomRelicManager { public static Dictionary CustomRelicDataList { get; } = new Dictionary(); public static RelicType Add(CustomRelicData relicData) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); RelicType enumValue = GuidManager.GetEnumValue(modIdFromCallstack, relicData.InternalName); relicData.ModPrefix = modIdFromCallstack; ((RelicData)relicData).RelicType = enumValue; relicData.Init(); CustomRelicDataList.Add(enumValue, relicData); return enumValue; } [HarmonyPatch(typeof(LocalizationManager), "GetTranslation", new Type[] { typeof(string), typeof(bool), typeof(int), typeof(bool), typeof(bool), typeof(GameObject), typeof(string), typeof(bool) })] [HarmonyPrefix] private static bool LocalizationManager_GetTranslation(string Term, ref string __result) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) string[] array = Term.Split(new char[1] { '/' }); if (array[0] != "Relics") { return true; } if (!Enum.TryParse(array[1], out RelicType result)) { return true; } if (!CustomRelicDataList.ContainsKey(result)) { return true; } if (array.Length == 2) { __result = CustomRelicDataList[result].GetTitleLocalisation(); } else { string text = array[2]; if (!(text == "Description")) { if (!(text == "Lore")) { return true; } __result = CustomRelicDataList[result].GetLoreLocalization(); } else { __result = CustomRelicDataList[result].GetDescriptionLocalisation(); } } return false; } [HarmonyPatch(typeof(RelicData), "GetChargeCategory", new Type[] { typeof(RelicType) })] [HarmonyPrefix] private static bool RelicData_GetChargeCategory(RelicType relicType, ref RelicChargeCategory __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected I4, but got Unknown if (!CustomRelicDataList.TryGetValue(relicType, out CustomRelicData value)) { return true; } __result = (RelicChargeCategory)(int)value.GetChargeCategory(); return false; } [HarmonyPatch(typeof(RelicData), "GetChargeCategory", new Type[] { typeof(RelicData) })] [HarmonyPrefix] private static bool RelicData_GetChargeCategory(RelicData relicData, ref RelicChargeCategory __result) { //IL_0006: 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_001e: Expected I4, but got Unknown if (!CustomRelicDataList.TryGetValue(relicData.RelicType, out CustomRelicData value)) { return true; } __result = (RelicChargeCategory)(int)value.GetChargeCategory(); return false; } [HarmonyPatch(typeof(PlayerRelic), "UseRelic", new Type[] { typeof(RelicType), typeof(bool) })] [HarmonyPostfix] private static void PlayerRelic_UseRelic(RelicType relicType, bool forceConsumableAnimation) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected I4, but got Unknown //IL_005c: 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_0038: 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) if (CustomRelicDataList.ContainsKey(relicType)) { RelicSubType relicSubType = ((RelicData)CustomRelicDataList[relicType]).RelicSubType; switch ((int)relicSubType) { case 2: CustomRelicDataList[relicType].OnUseBlessed(forceConsumableAnimation); break; case 1: CustomRelicDataList[relicType].OnUseDamned(forceConsumableAnimation); break; case 0: CustomRelicDataList[relicType].OnUseAny(forceConsumableAnimation); break; default: CustomRelicDataList[relicType].OnUse(forceConsumableAnimation); break; } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void EquipmentManager_RelicData(ref RelicData[] __result) { foreach (CustomRelicData item in CustomRelicDataList.Select, CustomRelicData>((KeyValuePair relic) => relic.Value)) { RelicData[] array = __result; int num = 0; RelicData[] array2 = (RelicData[])(object)new RelicData[1 + array.Length]; RelicData[] array3 = array; foreach (RelicData val in array3) { array2[num] = val; num++; } array2[num] = (RelicData)(object)item; __result = array2; if (item.CanBeBlessed) { array2 = __result; num = 0; array = (RelicData[])(object)new RelicData[1 + array2.Length]; array3 = array2; foreach (RelicData val in array3) { array[num] = val; num++; } array[num] = (RelicData)(object)item.ToBlessed(); __result = array; } if (item.CanBeDamned) { array = __result; num = 0; array2 = (RelicData[])(object)new RelicData[1 + array.Length]; array3 = array; foreach (RelicData val in array3) { array2[num] = val; num++; } array2[num] = (RelicData)(object)item.ToDamned(); __result = array2; } } } } } namespace COTL_API.CustomObjectives { public class CustomObjective { public int QuestID { get; internal set; } public string InitialQuestText { get; set; } public ObjectivesData ObjectiveData { get; internal set; } public CustomObjective(int questID, string initialQuestText, ObjectivesData objectiveData) { QuestID = questID; InitialQuestText = initialQuestText; ObjectiveData = objectiveData; base..ctor(); } } [HarmonyPatch] public static class CustomObjectiveManager { private const string GroupId = "Objectives/GroupTitles/Quest"; private static string DefaultQuestText => "I didn't set a custom quest text for this objective!"; internal static Dictionary CustomObjectiveList { get; } = new Dictionary(); public static CustomObjective BedRest(string followerName) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Objectives_BedRest val = new Objectives_BedRest("Objectives/GroupTitles/Quest", followerName); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective BuildStructure(TYPES structureType, int target = 1, float expireTimestamp = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown Objectives_BuildStructure val = new Objectives_BuildStructure("Objectives/GroupTitles/Quest", structureType, target, expireTimestamp, false); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective CollectItem(ITEM_TYPE itemType, int target, bool targetIsTotal = true, FollowerLocation targetLocation = 1, float expireTimestamp = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Objectives_CollectItem val = new Objectives_CollectItem("Objectives/GroupTitles/Quest", itemType, target, targetIsTotal, targetLocation, expireTimestamp); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective CookMeal(ITEM_TYPE mealType, int count, float expireTimestamp = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown Objectives_CookMeal val = new Objectives_CookMeal("Objectives/GroupTitles/Quest", mealType, count, expireTimestamp); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective Custom(CustomQuestTypes customQuestType, int targetFollowerID = -1, float questExpireDuration = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown Objectives_Custom val = new Objectives_Custom("Objectives/GroupTitles/Quest", customQuestType, targetFollowerID, questExpireDuration); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective DefeatKnucklebones(string characterNameTerm, float expireTimestamp = -1f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown Objectives_DefeatKnucklebones val = new Objectives_DefeatKnucklebones("Objectives/GroupTitles/Quest", characterNameTerm, expireTimestamp); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective DepositFood() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Objectives_DepositFood val = new Objectives_DepositFood("Objectives/GroupTitles/Quest"); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective EatMeal(TYPES mealType, float questExpireDuration = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown Objectives_EatMeal val = new Objectives_EatMeal("Objectives/GroupTitles/Quest", mealType, questExpireDuration); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective FindFollower(FollowerLocation targetLocation, string followerSkin, int followerColour, int followerVariant, string targetFollowerName, int objectiveVariant, float expireTimestamp = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown Objectives_FindFollower val = new Objectives_FindFollower("Objectives/GroupTitles/Quest", targetLocation, followerSkin, followerColour, followerVariant, targetFollowerName, objectiveVariant, expireTimestamp); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective KillEnemies(Enemy enemyType, int killsRequired, float questDuration) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown Objectives_KillEnemies val = new Objectives_KillEnemies("Objectives/GroupTitles/Quest", enemyType, killsRequired, questDuration); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective NoCurses(int roomsRequired) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Objectives_NoCurses val = new Objectives_NoCurses("Objectives/GroupTitles/Quest", roomsRequired); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective NoDamage(int roomsRequired) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Objectives_NoDamage val = new Objectives_NoDamage("Objectives/GroupTitles/Quest", roomsRequired); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective NoDodge(int roomsRequired) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Objectives_NoDodge val = new Objectives_NoDodge("Objectives/GroupTitles/Quest", roomsRequired); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective NoHealing(int roomsRequired) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Objectives_NoHealing val = new Objectives_NoHealing("Objectives/GroupTitles/Quest", roomsRequired); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective PerformRitual(Type ritual, int targetFollowerID = 1, int requiredFollowers = 0, float questExpireDuration = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown Objectives_PerformRitual val = new Objectives_PerformRitual("Objectives/GroupTitles/Quest", ritual, targetFollowerID, requiredFollowers, questExpireDuration); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective PlaceStructure(Categories category, DecorationType type, int target, float expireDuration) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown Objectives_PlaceStructure val = new Objectives_PlaceStructure("Objectives/GroupTitles/Quest", category, type, target, expireDuration, false); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective RecruitCursedFollower(Thought cursedState, int target = 1, float expireTimestamp = -1f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown Objectives_RecruitCursedFollower val = new Objectives_RecruitCursedFollower("Objectives/GroupTitles/Quest", cursedState, target, expireTimestamp); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective RecruitFollower(int count = 1) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Objectives_RecruitFollower val = new Objectives_RecruitFollower("Objectives/GroupTitles/Quest", count); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective RemoveStructure(TYPES structureType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Objectives_RemoveStructure val = new Objectives_RemoveStructure("Objectives/GroupTitles/Quest", structureType); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective ShootDummy() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Objectives_ShootDummy val = new Objectives_ShootDummy("Objectives/GroupTitles/Quest"); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective TalkToFollower(string term = "", float expireTimestamp = -1f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown Objectives_TalkToFollower val = new Objectives_TalkToFollower("Objectives/GroupTitles/Quest", term, expireTimestamp); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } public static CustomObjective UnlockUpgrade(Type unlockType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Objectives_UnlockUpgrade val = new Objectives_UnlockUpgrade("Objectives/GroupTitles/Quest", unlockType, -1f); return WorkMagic(((ObjectivesData)val).ID, DefaultQuestText, (ObjectivesData)(object)val); } private static CustomObjective WorkMagic(int id, string text, ObjectivesData objectiveData) { CustomObjective customObjective = new CustomObjective(id, text, objectiveData); CustomObjectiveList.Add(id, customObjective); Quests.QuestsAll.Add(objectiveData); return customObjective; } [HarmonyPatch(typeof(interaction_FollowerInteraction), "GetConversationEntry", new Type[] { typeof(ComplaintType), typeof(ObjectivesData), typeof(FollowerTask_GetAttention) })] [HarmonyPostfix] private static void interaction_FollowerInteraction_GetConversationEntry(ObjectivesData objective, ref List __result) { if (objective != null) { if (CustomObjectiveList.TryGetValue(objective.ID, out CustomObjective value)) { LogHelper.LogWarning($"Matching quest found for {objective.ID}!"); __result[0].TermToSpeak = value.InitialQuestText; } else { LogHelper.LogWarning($"No matching quest found for {objective.ID}!"); } } } [HarmonyPatch(typeof(Quests), "GetQuest")] [HarmonyPrefix] private static void Quests_GetQuest() { foreach (QuestHistoryData item in DataManager.Instance.CompletedQuestsHistorys.Where((QuestHistoryData a) => a.QuestIndex >= Quests.QuestsAll.Count)) { LogHelper.LogWarning("Found quests in history with an index higher than total quests (user may have removed mods that add quests), resetting to maximum possible."); item.QuestIndex = Quests.QuestsAll.Count - 1; } } } } namespace COTL_API.CustomMission { public abstract class CustomMission { internal string ModPrefix = ""; public abstract string InternalName { get; } internal ITEM_TYPE InnerType { get; set; } public virtual ITEM_TYPE RewardType => (ITEM_TYPE)9; public virtual int BaseChance => 75; public virtual IntRange RewardRange { get; } = new IntRange(15, 25); } [HarmonyPatch] public static class CustomMissionManager { public class MissionInstance { public int Instance { get; } public MissionButton? Button { get; } private ITEM_TYPE Type { get; } public CustomMission Mission { get; } public MissionInstance(int instance, MissionButton? button, ITEM_TYPE type, CustomMission mission) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Instance = instance; Button = button; Type = type; Mission = mission; base..ctor(); } } private static MissionButton? _newMissionButton; private static readonly List MissionInstanceList = new List(); internal static Dictionary CustomMissionList { get; } = new Dictionary(); public static ITEM_TYPE Add(CustomMission mission) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); ITEM_TYPE val = (mission.InnerType = GuidManager.GetEnumValue(modIdFromCallstack, mission.InternalName)); mission.ModPrefix = modIdFromCallstack; CustomMissionList.Add(val, mission); LogHelper.LogWarning($"Added: {val} {mission.InternalName} {mission.ModPrefix}"); return val; } [HarmonyPostfix] [HarmonyPatch(typeof(MissionInfoCard), "Configure")] public static void MissionInfoCard_Configure(ref MissionInfoCard __instance, ref FollowerInfo config) { //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) MissionInstanceList.RemoveAll((MissionInstance a) => (Object)(object)a.Button == (Object)null); foreach (CustomMission customMission in CustomMissionList.Select, CustomMission>((KeyValuePair x) => x.Value)) { MissionInfoCard instance = __instance; List list = MissionInstanceList.FindAll((MissionInstance a) => a.Instance == ((Object)instance).GetInstanceID() && a.Mission == customMission); if (list.Count > 0) { foreach (MissionButton item in list.Select((MissionInstance x) => x.Button)) { MissionButton val = (_newMissionButton = item); if (!((Object)(object)val == (Object)null)) { val.Configure(config); val.Start(); } } continue; } MissionButton obj = ArrayExtensions.RandomElement(__instance._missionButtons); _newMissionButton = Object.Instantiate(obj, ((Component)obj).transform.parent); ArrayUtility.Add(__instance._missionButtons, _newMissionButton); ((Object)_newMissionButton).name = "MISSION_BUTTON_" + customMission.InternalName; _newMissionButton._type = customMission.InnerType; _newMissionButton.Configure(config); _newMissionButton.Start(); MissionInfoCard card = __instance; MissionButton? newMissionButton = _newMissionButton; newMissionButton.OnMissionSelected = (Action)Delegate.Combine(newMissionButton.OnMissionSelected, (Action)delegate(ITEM_TYPE itemType) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) card.OnMissionSelected?.Invoke(itemType); }); MissionInstanceList.Add(new MissionInstance(((Object)__instance).GetInstanceID(), _newMissionButton, customMission.InnerType, customMission)); } } [HarmonyPrefix] [HarmonyPatch(typeof(FontImageNames), "GetIconByType", new Type[] { typeof(ITEM_TYPE) })] [HarmonyPatch(typeof(InventoryItem), "LocalizedName", new Type[] { typeof(ITEM_TYPE) })] public static void PrefixPatchesOne(ref ITEM_TYPE Type) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown if (CustomMissionList.TryGetValue(Type, out CustomMission value)) { Type = (ITEM_TYPE)(int)value.RewardType; } } [HarmonyPrefix] [HarmonyPatch(typeof(MissionaryManager), "GetDurationDeterministic")] public static void MissionaryManager_GetDurationDeterministic(ref ITEM_TYPE type) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown if (CustomMissionList.TryGetValue(type, out CustomMission value)) { type = (ITEM_TYPE)(int)value.RewardType; } } [HarmonyPrefix] [HarmonyPatch(typeof(Inventory), "GetItemQuantity", new Type[] { typeof(ITEM_TYPE) })] public static void Inventory_GetItemQuantity(ref ITEM_TYPE itemType) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown if (CustomMissionList.TryGetValue(itemType, out CustomMission value)) { itemType = (ITEM_TYPE)(int)value.RewardType; } } [HarmonyPrefix] [HarmonyPatch(typeof(MissionaryManager), "GetChance")] public static bool MissionaryManager_GetChance(ref float __result, ITEM_TYPE type, FollowerInfo followerInfo, TYPES missionaryType) { //IL_0005: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected I4, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!CustomMissionList.TryGetValue(type, out CustomMission value)) { return true; } float baseChanceMultiplier = MissionaryManager.GetBaseChanceMultiplier(value.RewardType, followerInfo); Random random = new Random(followerInfo.ID + CustomMissionList[type].RewardType); __result = Mathf.Clamp((float)(CustomMissionList[type].BaseChance + random.Next(-MissionaryManager.RandomSeedSpread, MissionaryManager.RandomSeedSpread)) / 100f * baseChanceMultiplier, 0f, 0.95f); return false; } [HarmonyPrefix] [HarmonyPatch(typeof(MissionaryManager), "GetRewardRange")] public static bool MissionaryManager_GetRewardRange(ref IntRange __result, ITEM_TYPE type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomMissionList.TryGetValue(type, out CustomMission value)) { return true; } __result = value.RewardRange; return false; } [HarmonyPrefix] [HarmonyPatch(typeof(MissionaryManager), "GetReward")] public static bool GetReward(ref ITEM_TYPE type, ref float chance, ref int followerID, ref InventoryItem[] __result) { //IL_007e: 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 if (!CustomMissionList.ContainsKey(type)) { return true; } float num = Random.Range(0f, 1f); foreach (ObjectivesData completedObjective in DataManager.Instance.CompletedObjectives) { if (completedObjective.Follower == followerID) { chance = float.MaxValue; break; } } if (chance > num) { __result = (InventoryItem[])(object)new InventoryItem[1] { new InventoryItem(CustomMissionList[type].RewardType, CustomMissionList[type].RewardRange.Random()) }; } return false; } } } namespace COTL_API.CustomLocalization { [HarmonyPatch] [HarmonyPatch] public class CustomLocalizationManager { public static Dictionary> LocalizationMap { get; } = new Dictionary>(); public static List LanguageList { get; } = new List(); public static void LoadLocalization(string name, string path) { if (!LocalizationMap.ContainsKey(name)) { LocalizationMap.Add(name, new Dictionary()); } if (!LanguageList.Contains(name)) { LanguageList.Add(name); } if (File.Exists(path)) { string[] array = File.ReadAllLines(path); bool flag = false; string[] array2 = array; foreach (string text in array2) { string key = ""; string value = ""; for (int j = 0; j < text.Length; j++) { if (text[j] == '"' && (0 >= j || text[j - 1] != '\\') && (1 >= j || text[j - 2] != '\\')) { flag = !flag; } else if (text[j] == ',' && !flag) { key = text.Substring(1, j - 2); value = text.Substring(j + 3, text.Length - j - 4); break; } } LocalizationMap[name].Add(key, value); } LogHelper.LogDebug("Loaded localization: " + name); } else { LogHelper.LogError("Localization file not found! Please make sure that the path \"" + path + "\" contains the localization file."); } } [HarmonyPatch(typeof(TermData), "GetTranslation")] [HarmonyPrefix] private static bool TermData_GetTranslation(ref string __result, TermData __instance) { if (__instance.Term.StartsWith("\"\"") && __instance.Term.EndsWith("\"\"")) { string text = __instance.Term.Substring(2, __instance.Term.Length - 4); __result = text; return false; } string language = SettingsManager.Settings.Game.Language; if (!LocalizationMap.TryGetValue(language, out Dictionary value)) { return true; } if (!value.ContainsKey(__instance.Term)) { return true; } __result = LocalizationMap[language][__instance.Term]; return false; } [HarmonyPatch(typeof(LanguageSourceData), "TryGetTranslation")] [HarmonyPrefix] private static bool LanguageSourceData_TryGetTranslation(string term, ref string Translation, ref bool __result) { string language = SettingsManager.Settings.Game.Language; if (!LocalizationMap.TryGetValue(language, out Dictionary value)) { return true; } if (!value.ContainsKey(term)) { return true; } Translation = LocalizationMap[language][term]; __result = true; return false; } [HarmonyPatch(typeof(GameSettings), "OnLanguageChanged")] [HarmonyPrefix] private static bool GameSettings_OnLanguageChanged(GameSettings __instance, int index) { if (index >= LanguageUtilities.AllLanguages.Length) { string text = LanguageList[index - LanguageUtilities.AllLanguages.Length]; SettingsManager.Settings.Game.Language = text; LocalizationManager.CurrentLanguage = text; __instance._cachedLanguage = text; if (TwitchAuthentication.IsAuthenticated) { TwitchManager.SetLanguage(LocalizationManager.CurrentLanguageCode); } Debug.Log((object)("GameSettings - Change Language to " + text)); LocalizationManager.LocalizeAll(true); return false; } LocalizationManager.LocalizeAll(true); return true; } [HarmonyPatch(typeof(GameSettings), "GetLanguageIndex")] [HarmonyPrefix] private static bool GameSettings_GetLanguageIndex(GameSettings __instance, ref int __result) { __instance._languageSelector._prefilledContent = ArrayUtility.AddRange(__instance._languageSelector._prefilledContent, LocalizationMap.Keys.ToArray()); __instance._languageSelector.UpdateContent(__instance._languageSelector._prefilledContent); if (!LanguageList.Contains(SettingsManager.Settings.Game.Language)) { return true; } __result = LanguageUtilities.AllLanguages.Length + LanguageList.IndexOf(SettingsManager.Settings.Game.Language); return false; } } } namespace COTL_API.CustomInventory { public abstract class CustomCrop : CustomInventoryItem { internal TYPES StructureType { get; set; } internal int CropStatesCount => CropStates.Count; public virtual List CropStates { get; } = new List(); public virtual float CropGrowthTime => 9f; public abstract List HarvestResult { get; } public virtual float PickingTime => 2.5f; public virtual Vector2Int CropCountToDropRange => new Vector2Int(3, 4); public virtual string HarvestText => "Pick Berries"; } [HarmonyPatch] [HarmonyPatch] [HarmonyPatch] [HarmonyPatch] [HarmonyPatch] [HarmonyPatch] [HarmonyPatch] [HarmonyPatch] [HarmonyPatch] public static class CustomItemManager { private class TransformHolder : MonoBehaviour { public Vector3 localPosition; public void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) localPosition = ((Component)this).transform.localPosition; } } public enum ItemRarity { COMMON, RARE } [HarmonyPatch(typeof(InventoryMenu))] private static class InventoryMenu_Patches { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private IEnumerator <>7__wrap1; private CodeInstruction 5__3; CodeInstruction? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 3u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; if (CodeInstructionExtensions.LoadsField(5__3, typeof(InventoryMenu).GetField("_currencyFilter", BindingFlags.Instance | BindingFlags.NonPublic), false)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression)(() => AppendCustomCurrencies(null)))); <>1__state = 2; return true; } goto IL_0107; case 2: <>1__state = -3; goto IL_0107; case 3: <>1__state = -3; goto IL_018e; case 4: { <>1__state = -3; goto IL_0212; } IL_0212: 5__3 = null; break; IL_0107: if (CodeInstructionExtensions.LoadsField(5__3, typeof(InventoryMenu).GetField("_foodSorter", BindingFlags.Instance | BindingFlags.NonPublic), false)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression)(() => AppendCustomFood(null)))); <>1__state = 3; return true; } goto IL_018e; IL_018e: if (CodeInstructionExtensions.LoadsField(5__3, typeof(InventoryMenu).GetField("_itemsSorter", BindingFlags.Instance | BindingFlags.NonPublic), false)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)SymbolExtensions.GetMethodInfo((Expression)(() => AppendCustomItem(null)))); <>1__state = 4; return true; } goto IL_0212; } if (<>7__wrap1.MoveNext()) { 5__3 = <>7__wrap1.Current; <>2__current = 5__3; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__0 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__0(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyPatch("OnShowStarted")] [HarmonyTranspiler] public static IEnumerable OnShowStarted(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2) { <>3__instructions = instructions }; } internal static List? AppendCustomCurrencies(ICollection? currencyFilter) { ICollection currencyFilter2 = currencyFilter; return currencyFilter2?.Concat(from i in CustomItemList where !currencyFilter2.Contains(i.Key) && i.Value.InventoryItemType == CustomInventoryItemType.CURRENCY select i.Key).ToList(); } internal static List? AppendCustomFood(ICollection? foodSorter) { ICollection foodSorter2 = foodSorter; return foodSorter2?.Concat(from i in CustomItemList where !foodSorter2.Contains(i.Key) && i.Value.InventoryItemType == CustomInventoryItemType.FOOD select i.Key).ToList(); } internal static List? AppendCustomItem(ICollection? itemsSorter) { ICollection itemsSorter2 = itemsSorter; return itemsSorter2?.Concat(from i in CustomItemList where !itemsSorter2.Contains(i.Key) && i.Value.InventoryItemType == CustomInventoryItemType.ITEM select i.Key).ToList(); } } [HarmonyPatch(typeof(Interaction_Chest))] private static class DungeonChestPatches { [HarmonyPatch("Reveal")] [HarmonyPostfix] private static void RevealPostfix(Interaction_Chest __instance) { //IL_003a: 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) foreach (KeyValuePair item in CustomItemList.Where>((KeyValuePair item) => item.Value.AddItemToDungeonChests && DropLoot(item.Value))) { InventoryItem.Spawn(item.Key, Random.Range(item.Value.DungeonChestMinAmount, item.Value.DungeonChestMaxAmount + 1), ((Component)__instance).transform.position, 4f, (Action)null); } } [HarmonyPatch("RevealBossReward")] [HarmonyPostfix] private static void RevealBossRewardPostfix(Interaction_Chest __instance) { //IL_003a: 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) foreach (KeyValuePair item in CustomItemList.Where>((KeyValuePair item) => item.Value.AddItemToDungeonChests && DropLoot(item.Value))) { InventoryItem.Spawn(item.Key, Random.Range(item.Value.DungeonChestMinAmount, item.Value.DungeonChestMaxAmount + 1), ((Component)__instance).transform.position, 4f, (Action)null); } } } [HarmonyPatch(typeof(Structures_OfferingShrine), "Complete")] private static class StructuresOfferingShrineCompletePatches { [HarmonyPrefix] private static void Prefix(ref Structures_OfferingShrine __instance) { //IL_0093: 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) foreach (KeyValuePair item in CustomItemList.Where>((KeyValuePair item) => item.Value.AddItemToOfferingShrine)) { List list; switch (item.Value.Rarity) { case ItemRarity.COMMON: list = __instance.Offerings; break; case ItemRarity.RARE: list = __instance.RareOfferings; break; default: list = __instance.Offerings; if ((Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.Debug) { LogHelper.LogDebug("Something went horribly wrong here... we should never hit this."); } break; } if (list != null && !list.Contains(item.Key)) { list.Add(item.Key); } } } } [HarmonyPatch(typeof(InventoryItem), "Spawn", new Type[] { typeof(ITEM_TYPE), typeof(int), typeof(Vector3), typeof(float), typeof(Action) })] private static class InventoryItemSpawnPatches { [HarmonyPrefix] private static bool Prefix(ITEM_TYPE type, int quantity, Vector3 position, float StartSpeed, ref Action result, ref PickUp __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_013f: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.ContainsKey(type)) { return true; } GameObject val = GameObject.FindGameObjectWithTag("Unit Layer"); Transform val2 = (((Object)(object)val != (Object)null) ? val.transform : null); PickUp val3 = null; while (--quantity >= 0) { BiomeGenerator instance = BiomeGenerator.Instance; if ((((Object)(object)instance != (Object)null) ? instance.CurrentRoom : null) != null) { val2 = BiomeGenerator.Instance.CurrentRoom.GameObject.transform; } if ((Object)(object)val2 == (Object)null && (Object)(object)GenerateRoom.Instance != (Object)null) { val2 = ((Component)GenerateRoom.Instance).transform; } if ((Object)(object)val2 == (Object)null) { break; } if (ItemPickUp.ShouldUseObjectPool(CustomItemList[type].ItemPickUpToImitate)) { ObjectPool.Spawn(ItemPickUp.GetItemPickUpPath(CustomItemList[type].ItemPickUpToImitate), position, Quaternion.identity, val2, (Action)delegate(GameObject o) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //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_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) CustomInventoryItem customInventoryItem = CustomItemList[type]; ((Object)o).name = customInventoryItem.InternalName; o.transform.localScale = customInventoryItem.LocalScale; o.GetComponentInChildren().sprite = customInventoryItem.Sprite; Meal component = o.GetComponent(); if ((Object)(object)component != (Object)null) { component.CreateStructureOnStop = true; component.CreateStructureLocation = (FollowerLocation)1; if (customInventoryItem is CustomMeal) { component.spriteRenderer.sprite = (customInventoryItem as CustomMeal).Sprite; component.structure.Type = (customInventoryItem as CustomMeal).StructureType; } } PickUp component2 = o.GetComponent(); if (!((Object)(object)component2 == (Object)null)) { component2.type = type; component2.Speed = StartSpeed; } }, true); } else { GameObject obj = ObjectPoolExtensions.Spawn(GetObject.GetCustomObject(CustomItemList[type]), val2); obj.transform.position = position; obj.transform.eulerAngles = Vector3.zero; val3 = obj.GetComponent(); if (!((Object)(object)val3 == (Object)null)) { val3.type = type; val3.Speed = StartSpeed; } } } GetObject.SetInactive(); __result = val3; return false; } } [HarmonyPatch(typeof(ObjectPool), "Spawn", new Type[] { typeof(string), typeof(Vector3), typeof(Quaternion), typeof(Transform), typeof(Action), typeof(bool) })] private static class ObjectPoolSpawnStringPatches { [HarmonyPrefix] private static void Prefix(ref string path) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) if (!path.StartsWith("CustomItem_")) { return; } KeyValuePair item = GetItemObjectByInternalObjectName(path); if (ObjectPool.instance.loadedAddressables.TryGetValue(item.Value.InternalObjectName, out var _)) { return; } AsyncOperationHandle value2 = Addressables.LoadAssetAsync((object)item.Value.InternalObjectName); value2.Completed += delegate(AsyncOperationHandle obj) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) GameObject result = obj.Result; if ((Object)(object)result != (Object)null) { result.SetActive(true); } Object obj2 = Object.Instantiate((Object)(object)ItemPickUp.GetItemPickUpObject(item.Value.ItemPickUpToImitate), (Transform)null, false); result = (GameObject)(object)((obj2 is GameObject) ? obj2 : null); result.GetComponentInChildren().sprite = item.Value.Sprite; ((Object)result).name = item.Value.InternalObjectName; result.transform.localScale = item.Value.LocalScale; }; ObjectPool.instance.loadedAddressables.Add(item.Value.InternalObjectName, value2); } } private static class GetObject { private static GameObject? _myObject; public static GameObject GetCustomObject(CustomInventoryItem item) { //IL_001f: 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) if ((Object)(object)_myObject != (Object)null) { _myObject.SetActive(true); return _myObject; } Object obj = Object.Instantiate((Object)(object)ItemPickUp.GetItemPickUpObject(item.ItemPickUpToImitate), (Transform)null, false); _myObject = (GameObject?)(object)((obj is GameObject) ? obj : null); _myObject.GetComponentInChildren().sprite = item.Sprite; ((Object)_myObject).name = item.InternalObjectName; _myObject.transform.localScale = item.LocalScale; return _myObject; } public static void SetInactive() { if (!((Object)(object)_myObject == (Object)null)) { _myObject.SetActive(false); } } } private const string AssetPath = "Prefabs/Structures/Crops/Berry Crop"; internal static GameObject CropPrefab = null; private const string PathPrefix = "CustomItem_"; public static Dictionary CustomCropList { get; } = new Dictionary(); private static Dictionary CropObjectList { get; } = new Dictionary(); public static Dictionary CustomDrinkList { get; } = new Dictionary(); internal static Dictionary CustomFoodList { get; } = new Dictionary(); public static Dictionary CustomMealList { get; } = new Dictionary(); public static Dictionary CustomItemList { get; } = new Dictionary(); public static ITEM_TYPE Add(CustomCrop crop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) ITEM_TYPE val = (crop.ItemType = Add((CustomInventoryItem)crop)); crop.StructureType = GuidManager.GetEnumValue(CustomItemList[val].ModPrefix, crop.InternalName); CustomCropList.Add(val, crop); return val; } private static void CreateCropObject(CustomCrop crop) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)CropPrefab == (Object)null) { throw new NullReferenceException("This REALLY shouldn't happen, send a bug report!"); } GameObject val = Object.Instantiate(CropPrefab); if ((Object)(object)val == (Object)null) { throw new NullReferenceException("Somehow, the Crop Prefab could not be instantiated, send a bug report"); } ((Object)val.transform).name = crop.Name() + " Crop"; CropController component = val.GetComponent(); component.CropStates = new List(); component.SeedType = crop.ItemType; Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(1)).gameObject); Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(1)).gameObject); Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(1)).gameObject); Transform child = val.transform.GetChild(1); Transform child2 = child.GetChild(2).GetChild(0).GetChild(0); Transform child3 = val.transform.GetChild(2).GetChild(3).GetChild(0) .GetChild(0); Transform child4 = val.transform.GetChild(0); component.CropStates.Add(((Component)child4).gameObject); if (crop.CropStates.Count > 0) { ((Component)child2).GetComponent().sprite = crop.CropStates.Last(); ((Component)child3).GetComponent().sprite = crop.CropStates.Last(); ((Component)child4).GetComponent().sprite = crop.CropStates[0]; } for (int i = 1; i < crop.CropStates.Count - 1; i++) { Transform val2 = Object.Instantiate(child4, val.transform); ((Object)val2).name = $"Crop {i + 1}"; val2.SetSiblingIndex(i); ((Component)val2).GetComponent().sprite = crop.CropStates[i]; component.CropStates.Add(((Component)val2).gameObject); } component.CropStates.Add(((Component)child).gameObject); ((Object)val).hideFlags = (HideFlags)61; CropObjectList.Add(crop.ItemType, val.GetComponent()); } public static void InitiateCustomCrops() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) LogHelper.LogInfo("Getting Crop Asset"); AsyncOperationHandle op = Addressables.Instance.LoadAssetAsync((object)"Prefabs/Structures/Crops/Berry Crop"); op.Completed += delegate(AsyncOperationHandle handle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)op.Status != 1) { throw new NullReferenceException("Couldn't Find Berry Crop Object, Send a bug report!"); } CropPrefab = handle.Result; CropPrefab.SetActive(false); CollectionExtensions.Do>((IEnumerable>)CustomCropList, (Action>)delegate(KeyValuePair x) { CreateCropObject(x.Value); }); }; } [HarmonyPatch(typeof(CropController), "CropStatesForSeedType")] [HarmonyPostfix] private static void CropController_CropStatesForSeedType(ITEM_TYPE seedType, ref int __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomCropList.TryGetValue(seedType, out CustomCrop value)) { __result = value.CropStatesCount; } } [HarmonyPatch(typeof(CropController), "CropGrowthTimes")] [HarmonyPostfix] private static void CropController_CropGrowthTimes(ITEM_TYPE seedType, ref float __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomCropList.TryGetValue(seedType, out CustomCrop value)) { __result = value.CropGrowthTime; } } [HarmonyPatch(typeof(StructuresData), "GetInfoByType")] [HarmonyPostfix] private static void StructureData_GetInfoByType(TYPES Type, ref StructuresData __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_007e: 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_0085: 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_0090: Expected O, but got Unknown if (!CustomCropList.Values.All((CustomCrop x) => x.StructureType != Type)) { CustomCrop customCrop = CustomCropList.Values.First((CustomCrop x) => x.StructureType == Type); __result = new StructuresData { PrefabPath = "Prefabs/Structures/Other/Berry Bush", DontLoadMe = true, ProgressTarget = customCrop.PickingTime, MultipleLootToDrop = customCrop.HarvestResult, LootCountToDropRange = customCrop.CropCountToDropRange, Type = customCrop.StructureType }; } } [HarmonyPatch(typeof(StructureBrain), "CreateBrain")] [HarmonyPostfix] private static void StructureBrain_CreateBrain(StructuresData data, ref StructureBrain __result) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown StructuresData data2 = data; if (!CustomCropList.Values.All((CustomCrop x) => x.StructureType != data2.Type)) { __result = (StructureBrain)new Structures_BerryBush(); } } [HarmonyPatch(typeof(FarmPlot), "Awake")] [HarmonyPostfix] private static void FarmPlot_Awake(FarmPlot __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair cropObject in CropObjectList) { __instance._cropPrefabsBySeedType.Add(cropObject.Key, cropObject.Value); } } [HarmonyPatch(typeof(Interaction_Berries), "OnBrainAssigned")] [HarmonyPostfix] private static void Interaction_Berries_OnBrainAssigned(Interaction_Berries __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) CropController componentInParent = ((Component)__instance).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && CustomCropList.TryGetValue(componentInParent.SeedType, out CustomCrop value)) { ((StructureBrain)__instance.StructureBrain).Data.MultipleLootToDrop = value.HarvestResult; ((StructureBrain)__instance.StructureBrain).Data.LootCountToDropRange = value.CropCountToDropRange; __instance.BerryPickingIncrements = 1.25f / value.PickingTime; } } [HarmonyPatch(typeof(Interaction_Berries), "UpdateLocalisation")] [HarmonyPostfix] private static void Interaction_Berries_UpdateLocalisation(Interaction_Berries __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) CropController componentInParent = ((Component)__instance).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null) && CustomCropList.TryGetValue(componentInParent.SeedType, out CustomCrop value)) { __instance.sLabelName = value.HarvestText; } } public static ITEM_TYPE Add(CustomDrink drink) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) if (!ArrayExtensions.Contains(CookingData.GetAllDrinks(), drink.ItemPickUpToImitate)) { throw new ArgumentException("Custom Drink Imitation Item is not a Drink!", drink.InternalName); } ITEM_TYPE val = Add((CustomFood)drink); string modPrefix = CustomItemList[val].ModPrefix; drink.PleasureAction = GuidManager.GetEnumValue(modPrefix, drink.InternalName); FollowerBrain.PleasureAndActions.Add(drink.PleasureAction, drink.Pleasure); CustomDrinkList.Add(val, drink); return val; } private static ITEM_TYPE Add(CustomFood food) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) ITEM_TYPE val = Add((CustomInventoryItem)food); string modPrefix = CustomItemList[val].ModPrefix; food.FollowerCommand = GuidManager.GetEnumValue(modPrefix, food.InternalName); TYPES item = (food.StructureType = GuidManager.GetEnumValue(modPrefix, food.InternalName)); if (!StructuresData.AllStructures.Contains(item)) { StructuresData.AllStructures.Add(item); } CustomFoodList.Add(val, food); return val; } public static ITEM_TYPE Add(CustomMeal meal) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!ArrayExtensions.Contains(CookingData.GetAllMeals(), meal.ItemPickUpToImitate)) { throw new ArgumentException("Custom Meal Imitation Item is not a meal!", meal.InternalName); } ITEM_TYPE val = Add((CustomFood)meal); CustomMealList.Add(val, meal); return val; } [HarmonyPatch(typeof(CookingData), "GetAllDrinks")] [HarmonyPostfix] private static void CookingData_GetAllDrinks(ref ITEM_TYPE[] __result) { CustomDrink[] array = CustomDrinkList.Values.ToArray(); ITEM_TYPE[] array2 = CustomDrinkList.Keys.ToArray(); ITEM_TYPE[] array3 = (ITEM_TYPE[])(object)new ITEM_TYPE[__result.Length + array.Length]; for (int i = 0; i < __result.Length; i++) { array3[i] = __result[i]; } for (int j = 0; j < array.Length; j++) { array3[__result.Length + j] = array2[j]; } __result = array3; } [HarmonyPatch(typeof(FollowerCommandGroups), "DrinkCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_DrinkCommands(ref List availableDrinks, ref List __result) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0046: Expected O, but got Unknown foreach (ITEM_TYPE key in CustomDrinkList.Keys) { if (availableDrinks.Contains(key)) { __result.Add((CommandItem)new FoodCommandItem { Command = CustomDrinkList[key].FollowerCommand }); } } } [HarmonyPatch(typeof(CookingData), "GetPleasure")] [HarmonyPostfix] private static void CookingData_GetPleasure(ref PleasureActions __result, ref ITEM_TYPE item) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown if (CustomDrinkList.TryGetValue(item, out CustomDrink value)) { __result = (PleasureActions)(int)value.PleasureAction; } } [HarmonyPatch(typeof(CookingData), "GetLocalizedName")] [HarmonyPostfix] private static void CookingData_GetLocalizedName(ITEM_TYPE mealType, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomFoodList.TryGetValue(mealType, out CustomFood value)) { __result = value.LocalizedName(); } } [HarmonyPatch(typeof(CookingData), "GetLocalizedDescription")] [HarmonyPostfix] private static void CookingData_GetLocalizedDescription(ITEM_TYPE mealType, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomFoodList.TryGetValue(mealType, out CustomFood value)) { __result = value.Description(); } } [HarmonyPatch(typeof(CookingData), "GetRecipe")] [HarmonyPostfix] private static void CookingData_GetRecipe(ref List> __result, ITEM_TYPE mealType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomFoodList.TryGetValue(mealType, out CustomFood value)) { __result = value.Recipe; } } [HarmonyPatch(typeof(CookingData), "GetMealEffects")] [HarmonyPostfix] private static void CookingData_GetMealEffects(ref MealEffect[] __result, ITEM_TYPE mealType) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomFoodList.TryGetValue(mealType, out CustomFood value)) { __result = value.MealEffects; } } [HarmonyPatch(typeof(CookingData), "GetSatationLevel")] [HarmonyPostfix] private static void CookingData_GetSatationLevel(ref int __result, ITEM_TYPE meal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomFoodList.TryGetValue(meal, out CustomFood value)) { __result = value.SatiationLevel; } } [HarmonyPatch(typeof(CookingData), "GetSatationAmount")] [HarmonyPostfix] private static void CookingData_GetSatationAmount(ref int __result, ITEM_TYPE meal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomFoodList.TryGetValue(meal, out CustomFood value)) { __result = value.FoodSatitation; } } [HarmonyPatch(typeof(CookingData), "GetMealFromStructureType")] [HarmonyPostfix] private static void CookingData_GetMealFromStructureType(TYPES structureType, ref ITEM_TYPE __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_002f: Expected I4, but got Unknown ITEM_TYPE val = ((IEnumerable)CustomFoodList.Keys).FirstOrDefault((Func)((ITEM_TYPE x) => CustomFoodList[x].StructureType == structureType)); if ((int)val != 0) { __result = (ITEM_TYPE)(int)val; } } [HarmonyPatch(typeof(RecipeInfoCard), "Configure")] [HarmonyPostfix] private static void RecipeInfoCard_Configure(RecipeInfoCard __instance, ITEM_TYPE config) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomItemList.TryGetValue(config, out CustomInventoryItem value)) { ((TMP_Text)__instance._itemDescription).text = value.Description(); ((TMP_Text)__instance._itemHeader).text = value.LocalizedName(); } } [HarmonyPatch(typeof(FoodCommandItem), "GetTitle")] [HarmonyPostfix] private static void FoodCommandItem_GetTitle(ref FoodCommandItem __instance, ref string __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) FollowerCommands command = ((CommandItem)__instance).Command; if (CustomFoodList.Values.Any((CustomFood x) => x.FollowerCommand == command)) { __result = CustomFoodList.Values.First((CustomFood x) => x.FollowerCommand == command).LocalizedName(); } } [HarmonyPatch(typeof(FoodCommandItem), "GetDescription")] [HarmonyPostfix] private static void FoodCommandItem_GetDescription(ref FoodCommandItem __instance, ref string __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) FollowerCommands command = ((CommandItem)__instance).Command; if (CustomFoodList.Values.Any((CustomFood x) => x.FollowerCommand == command)) { __result = CustomFoodList.Values.First((CustomFood x) => x.FollowerCommand == command).LocalizedDescription(); } } [HarmonyPatch(typeof(StructuresData), "GetMealStructureType")] [HarmonyPostfix] private static void StructuresData_GetMealStructureType(ITEM_TYPE mealType, ref TYPES __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected I4, but got Unknown if (CustomFoodList.Keys.Contains(mealType)) { __result = (TYPES)(int)CustomFoodList.Values.First((CustomFood x) => x.ItemType == mealType).StructureType; } } [HarmonyPatch(typeof(interaction_FollowerInteraction), "OnFollowerCommandFinalized")] [HarmonyPrefix] private static void interaction_FollowerInteraction_OnFollowerCommandFinalized(ref FollowerCommands[] followerCommands, ref interaction_FollowerInteraction __instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) FollowerCommands command = followerCommands[0]; if (!CustomFoodList.Values.All((CustomFood x) => x.FollowerCommand != command)) { CustomFood customFood = CustomFoodList.Values.First((CustomFood x) => x.FollowerCommand == command); __instance.follower.Brain.CancelTargetedMeal(customFood.StructureType); __instance.eventListener.PlayFollowerVO(__instance.generalAcknowledgeVO); __instance.follower.Brain.SetPersonalOverrideTask((FollowerTaskType)6, customFood.StructureType); __instance.follower.Brain.CompleteCurrentTask(); } } [HarmonyPatch(typeof(InventoryItemDisplay), "DoScale")] [HarmonyPrefix] private static bool InventoryItemDisplay_DoScale(ref InventoryItemDisplay __instance) { Sprite sprite = __instance.spriteRenderer.sprite; return CustomFoodList.Values.All((CustomFood x) => (Object)(object)x.Sprite != (Object)(object)sprite); } [HarmonyPatch(typeof(InventoryItemDisplay), "SetImage", new Type[] { typeof(ITEM_TYPE), typeof(bool) })] [HarmonyPostfix] private static void InventoryItemDisplay_SetImage(ref InventoryItemDisplay __instance, ref ITEM_TYPE Type) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)__instance.spriteRenderer).transform; transform.localPosition = ((Component)__instance).GetComponent().localPosition; if (CustomFoodList.TryGetValue(Type, out CustomFood value)) { transform.localScale = value.LocalScale; transform.localPosition += value.ItemDisplayOffset; } else { transform.localScale = Vector3.one; } } [HarmonyPatch(typeof(InventoryItemDisplay), "Awake")] [HarmonyPostfix] private static void InventoryItemDisplay_Awake(ref InventoryItemDisplay __instance) { ((Component)__instance).gameObject.AddComponent(); } [HarmonyPatch(typeof(CookingData), "GetTummyRating")] [HarmonyPostfix] private static void CookingData_GetTummyRating(ref float __result, ITEM_TYPE meal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (CustomMealList.TryGetValue(meal, out CustomMeal value)) { __result = value.TummyRating; } } [HarmonyPatch(typeof(CookingData), "GetAllMeals")] [HarmonyPostfix] private static void CookingData_GetAllMeals(ref ITEM_TYPE[] __result) { CustomMeal[] array = CustomMealList.Values.ToArray(); ITEM_TYPE[] array2 = CustomMealList.Keys.ToArray(); ITEM_TYPE[] array3 = (ITEM_TYPE[])(object)new ITEM_TYPE[__result.Length + array.Length]; for (int i = 0; i < __result.Length; i++) { array3[i] = __result[i]; } for (int j = 0; j < array.Length; j++) { array3[__result.Length + j] = array2[j]; } __result = array3; } [HarmonyPatch(typeof(Meal), "MealSafeToEat")] [HarmonyPostfix] private static void Meal_MealSafeToEat(Meal __instance, ref bool __result) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (__instance.StructureInfo != null) { ITEM_TYPE mealFromStructureType = CookingData.GetMealFromStructureType(__instance.StructureInfo.Type); if (CustomMealList.TryGetValue(mealFromStructureType, out CustomMeal value)) { __result = value.MealSafeToEat; } } } [HarmonyPatch(typeof(StructuresData), "GetInfoByType")] [HarmonyPostfix] private static void StructuresData_GetInfoByType(TYPES Type, ref StructuresData __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //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) if (CustomMealList.Values.Any((CustomMeal x) => x.StructureType == Type)) { StructuresData val = new StructuresData { PrefabPath = "Prefabs/Structures/Other/Meal", IgnoreGrid = true, Location = (FollowerLocation)1 }; val.Type = Type; __result = val; } } [HarmonyPatch(typeof(StructureBrain), "CreateBrain")] [HarmonyPrefix] private static bool StructureBrain_CreateBrain(ref StructuresData data, ref StructureBrain __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0036: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) TYPES type = data.Type; if (CustomMealList.Values.Any((CustomMeal x) => x.StructureType == type)) { StructureBrain val = (StructureBrain)new Structures_Meal(); StructureBrain.ApplyConfigToData(data); val.Init(data); StructureBrain.TryAddBrain(ref data.ID, ref val); StructureManager.StructuresAtLocation(data.Location).Add(val); __result = val; return false; } return true; } [HarmonyPatch(typeof(FollowerCommandGroups), "MealCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_MealCommands(ref List availableMeals, ref List __result) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0046: Expected O, but got Unknown foreach (ITEM_TYPE key in CustomMealList.Keys) { if (availableMeals.Contains(key)) { __result.Add((CommandItem)new FoodCommandItem { Command = CustomMealList[key].FollowerCommand }); } } } [HarmonyPatch(typeof(FollowerTask_EatMeal), "GetMealReaction")] [HarmonyPostfix] public static void FollowerTask_EatMeal_GetMealReaction(TYPES type, ref string __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!CustomMealList.Values.All((CustomMeal x) => x.StructureType != type)) { __result = CustomMealList.Values.First((CustomMeal x) => x.StructureType == type).Quality switch { MealQuality.BAD => "Food/food-finish-bad", MealQuality.NORMAL => "Food/food-finish", MealQuality.GOOD => "Food/Food-finish-good", _ => "Food/Food-finish", }; } } [HarmonyPatch(typeof(StructuresData), "GetMealType")] [HarmonyPostfix] private static void StructuresData_GetMealType(TYPES structureType, ref ITEM_TYPE __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown if (CustomMealList.Values.Any((CustomMeal x) => x.StructureType == structureType)) { __result = (ITEM_TYPE)(int)CustomMealList.Values.First((CustomMeal x) => x.StructureType == structureType).ItemType; } } public static ITEM_TYPE Add(CustomInventoryItem item) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); ITEM_TYPE val = (item.ItemType = GuidManager.GetEnumValue(modIdFromCallstack, item.InternalName)); item.ModPrefix = modIdFromCallstack; item.InternalObjectName = "CustomItem_" + item.InternalName; CustomItemList.Add(val, item); return val; } public static bool DropLoot(CustomInventoryItem customInventoryItem, float customChance = 0f) { float num = Random.Range(0, 101); float num2 = ((customChance > 0f) ? customChance : ((float)customInventoryItem.DungeonChestSpawnChance + (float)customInventoryItem.DungeonChestSpawnChance * DataManager.Instance.GetLuckMultiplier())); LogHelper.LogDebug($"{customInventoryItem.InternalObjectName} Roll/Chance: {num} / {num2}: Win? {num <= num2}"); return num <= num2; } public static KeyValuePair GetItemObjectByInternalObjectName(string name) { string name2 = name; return CustomItemList.Where>(delegate(KeyValuePair item) { KeyValuePair keyValuePair = item; return keyValuePair.Value.InternalObjectName == name2; }).FirstOrDefault(); } public static void AddGift(ITEM_TYPE item) { //IL_0005: 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) if (!DataManager.AllGifts.Contains(item)) { DataManager.AllGifts.Add(item); } } public static void RemoveGift(ITEM_TYPE item) { //IL_0005: 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) if (DataManager.AllGifts.Contains(item)) { DataManager.AllGifts.Remove(item); } } public static void AddNecklace(ITEM_TYPE item) { //IL_0005: 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) if (!DataManager.AllNecklaces.Contains(item)) { DataManager.AllNecklaces.Add(item); } } public static void RemoveNecklace(ITEM_TYPE item) { //IL_0005: 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) if (DataManager.AllNecklaces.Contains(item)) { DataManager.AllNecklaces.Remove(item); } } [HarmonyPatch(typeof(ItemInfoCard), "Configure")] [HarmonyPostfix] private static void ItemInfoCard_Configure(ItemInfoCard __instance, ITEM_TYPE config) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (CustomItemList.TryGetValue(config, out CustomInventoryItem value)) { ((TMP_Text)__instance._itemHeader).text = value.Name(); ((TMP_Text)__instance._itemLore).text = CustomItemList[config].Lore(); ((TMP_Text)__instance._itemDescription).text = CustomItemList[config].Description(); } } [HarmonyPatch(typeof(Interaction_AddFuel), "Update")] [HarmonyPrefix] private static void Interaction_AddFuel_Update(Interaction_AddFuel __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0040: 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) foreach (ITEM_TYPE key in CustomItemList.Keys) { if (!CustomItemList[key].IsBurnableFuel && __instance.fuel.Contains(key)) { __instance.fuel.Remove(key); } if (CustomItemList[key].IsBurnableFuel && !__instance.fuel.Contains(key)) { __instance.fuel.Add(key); } } } [HarmonyPatch(typeof(Inventory), "HasGift")] [HarmonyPostfix] private static void Inventory_HasGift(Inventory __instance, ref bool __result) { if (!__result && Inventory.items.Where((InventoryItem item) => CustomItemList.ContainsKey((ITEM_TYPE)item.type)).Any((InventoryItem item) => CustomItemList[(ITEM_TYPE)item.type].CanBeGivenToFollower)) { __result = true; } } [HarmonyPatch(typeof(FollowerCommandGroups), "GiftCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_GiftCommands(ref List __result) { __result.AddRange((IEnumerable)(from item in CustomItemList.Values where item.CanBeGivenToFollower where 0 < Inventory.GetItemQuantity(item.ItemType) select item).Select((Func)((CustomInventoryItem item) => new GiftCommandItem(item.ItemType) { Command = item.GiftCommand }))); } [HarmonyPatch(typeof(GiftCommandItem), "GetTitle")] [HarmonyPrefix] private static bool FollowerCommandItems_GiftCommandItem_GetTitle(GiftCommandItem __instance, Follower follower, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(__instance._itemType, out CustomInventoryItem value)) { return true; } __result = value.GiftTitle(follower); return false; } [HarmonyPatch(typeof(FontImageNames), "GetIconByType")] [HarmonyPrefix] private static bool FontImageNames_GetIconByType(ITEM_TYPE Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.InventoryStringIcon(); return false; } [HarmonyPatch(typeof(InventoryIconMapping), "GetImage", new Type[] { typeof(ITEM_TYPE) })] [HarmonyPrefix] private static bool InventoryIconMapping_GetImage(ITEM_TYPE type, ref Sprite __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(type, out CustomInventoryItem value)) { return true; } __result = value.InventoryIcon; return false; } [HarmonyPatch(typeof(InventoryItem), "Name")] [HarmonyPrefix] private static bool InventoryItem_Name(ITEM_TYPE Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.Name(); return false; } [HarmonyPatch(typeof(InventoryItem), "LocalizedName")] [HarmonyPrefix] private static bool InventoryItem_LocalizedName(ITEM_TYPE Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.LocalizedName(); return false; } [HarmonyPatch(typeof(InventoryItem), "Description")] [HarmonyPrefix] private static bool InventoryItem_Description(ITEM_TYPE Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.Description(); return false; } [HarmonyPatch(typeof(InventoryItem), "LocalizedDescription")] [HarmonyPrefix] private static bool InventoryItem_LocalizedDescription(ITEM_TYPE Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.LocalizedDescription(); return false; } [HarmonyPatch(typeof(InventoryItem), "Lore")] [HarmonyPrefix] private static bool InventoryItem_Lore(ITEM_TYPE Type, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.Lore(); return false; } [HarmonyPatch(typeof(InventoryItem), "GetItemCategory")] [HarmonyPrefix] private static bool InventoryItem_ItemCategory(ITEM_TYPE type, ref ITEM_CATEGORIES __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected I4, but got Unknown if (!CustomItemList.TryGetValue(type, out CustomInventoryItem value)) { return true; } __result = (ITEM_CATEGORIES)(int)value.ItemCategory; return false; } [HarmonyPatch(typeof(InventoryItem), "GetSeedType")] [HarmonyPrefix] private static bool InventoryItem_GetSeedType(ITEM_TYPE type, ref ITEM_TYPE __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected I4, but got Unknown if (!CustomItemList.TryGetValue(type, out CustomInventoryItem value)) { return true; } __result = (ITEM_TYPE)(int)value.SeedType; return false; } [HarmonyPatch(typeof(InventoryItem), "FuelWeight", new Type[] { typeof(ITEM_TYPE) })] [HarmonyPrefix] private static bool InventoryItem_FuelWeight(ITEM_TYPE type, ref int __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(type, out CustomInventoryItem value)) { return true; } __result = value.FuelWeight; return false; } [HarmonyPatch(typeof(InventoryItem), "FoodSatitation")] [HarmonyPrefix] private static bool InventoryItem_FoodSatitation(ITEM_TYPE Type, ref int __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.FoodSatitation; return false; } [HarmonyPatch(typeof(InventoryItem), "IsFish")] [HarmonyPrefix] private static bool InventoryItem_IsFish(ITEM_TYPE Type, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.IsFish; return false; } [HarmonyPatch(typeof(InventoryItem), "IsFood")] [HarmonyPrefix] private static bool InventoryItem_IsFood(ITEM_TYPE Type, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.IsFood; return false; } [HarmonyPatch(typeof(InventoryItem), "IsBigFish")] [HarmonyPrefix] private static bool InventoryItem_IsBigFish(ITEM_TYPE Type, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.IsBigFish; return false; } [HarmonyPatch(typeof(InventoryItem), "CanBeGivenToFollower")] [HarmonyPrefix] private static bool InventoryItem_CanBeGivenToFollower(ITEM_TYPE Type, ref bool __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(Type, out CustomInventoryItem value)) { return true; } __result = value.CanBeGivenToFollower; return false; } [HarmonyPatch(typeof(InventoryItem), "CapacityString")] [HarmonyPrefix] private static bool InventoryItem_CapacityString(ITEM_TYPE type, int minimum, ref string __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(type, out CustomInventoryItem value)) { return true; } __result = value.CapacityString(minimum); return false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void InventoryItem_AllPlantables(ref List __result) { __result.AddRange(CustomCropList.Select, ITEM_TYPE>((KeyValuePair x) => x.Key)); } [HarmonyPatch(typeof(InventoryItem), "GiveToFollowerCallbacks")] [HarmonyPrefix] private static bool InventoryItem_GiveToFollowerCallbacks(ITEM_TYPE Type, ref Action __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.ContainsKey(Type)) { return true; } __result = delegate(Follower follower, ITEM_TYPE type, Action callback) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!CustomItemList.TryGetValue(type, out CustomInventoryItem value)) { InventoryItem.GiveToFollowerCallbacks(type)(follower, type, callback); } else { value.OnGiftTo(follower, callback); } }; return false; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void InventoryItem_AllSeeds(ref List __result) { __result.AddRange(CustomCropList.Select, ITEM_TYPE>((KeyValuePair x) => x.Key)); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static void InventoryItem_AllBurnableFuel(ref List __result) { __result.AddRange(from x in CustomItemList where x.Value.IsBurnableFuel select x.Key); } [HarmonyPatch(typeof(CookingData), "GetAllFoods")] [HarmonyPostfix] private static void CookingData_GetAllFoods(ref ITEM_TYPE[] __result) { ITEM_TYPE[] copy = __result; List list = new List(); list.AddRange(__result); list.AddRange(from i in CustomItemList where !ArrayExtensions.Contains(copy, i.Key) && i.Value.IsFood select i.Key); __result = list.ToArray(); } [HarmonyPostfix] [HarmonyPatch(typeof(Structures_Refinery), "GetCost")] public static void Structures_Refinery_GetCost(Structures_Refinery __instance, ITEM_TYPE Item, ref List __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (CustomItemList.ContainsKey(Item)) { __result = new List(1) { new ItemCost(CustomItemList[Item].RefineryInput, CustomItemList[Item].RefineryInputQty) }; } } [HarmonyPostfix] [HarmonyPatch(typeof(Structures_Refinery), "RefineryDuration")] public static void Structures_Refinery_RefineryDuration(Structures_Refinery __instance, ITEM_TYPE ItemType, ref float __result) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (CustomItemList.ContainsKey(ItemType) && CustomItemList[ItemType].CustomRefineryDuration > 0f) { __result = CustomItemList[ItemType].CustomRefineryDuration; } } [HarmonyPrefix] [HarmonyPatch(typeof(UIMenuBase), "Show", new Type[] { typeof(bool) })] public static void UIRefineryMenuController_Show(ref UIMenuBase __instance) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) UIMenuBase obj = __instance; UIRefineryMenuController val = (UIRefineryMenuController)(object)((obj is UIRefineryMenuController) ? obj : null); if (val == null) { return; } foreach (KeyValuePair item in CustomItemList.Where>((KeyValuePair item) => item.Value.CanBeRefined)) { RefineryItem val2 = Object.Instantiate(val.refineryIconPrefab, val.Container); val2.OnItemSelected = (Action)Delegate.Combine(val2.OnItemSelected, new Action(val.OnItemSelected)); MMButton button = ((UIInventoryItem)val2).Button; button.OnSelected = (Action)Delegate.Combine(button.OnSelected, new Action(val.OnQueueableItemSelected)); val2.Configure(item.Key, false, 0, true, 0); ((UIInventoryItem)val2).FadeIn((float)val._refineryItems.Count * 0.03f, (Action)null); val._refineryItems.Add(val2); } } [HarmonyPostfix] [HarmonyPatch(typeof(RefineryInfoCard), "Configure")] public static void RefineryInfoCard_Configure(ref RefineryInfoCard __instance, ref RefineryItem config) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) ITEM_TYPE type = ((UIInventoryItem)config).Type; if (CustomItemList.TryGetValue(type, out CustomInventoryItem value)) { ((TMP_Text)__instance._descriptionText).text = value.LocalizedDescription(); ((TMP_Text)__instance._headerText).text = CustomItemList[type].LocalizedName(); } } [HarmonyPatch(typeof(InventoryItemDisplay), "GetItemImages")] [HarmonyPrefix] private static void InventoryItemDisplay_GetItemImages(ref InventoryItemDisplay __instance) { //IL_0065: 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) foreach (MyDictionaryEntry item in CustomItemList.Select, MyDictionaryEntry>((KeyValuePair type) => new MyDictionaryEntry { key = type.Key, value = type.Value.InventoryIcon })) { if (!__instance.ItemImages.Contains(item)) { __instance.ItemImages.Add(item); } if (__instance.myDictionary != null && !__instance.myDictionary.ContainsKey(item.key)) { __instance.myDictionary.Add(item.key, item.value); } } } [HarmonyPrefix] [HarmonyPatch(typeof(Interaction_OfferingShrine), "OnInteract")] public static bool OnInteract(ref Interaction_OfferingShrine __instance, ref StateMachine state) { //IL_0080: 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) if (!CustomItemList.ContainsKey((ITEM_TYPE)__instance.StructureInfo.Inventory[0].type)) { return true; } OnInteractHelper.Interaction_OnInteract((Interaction)(object)__instance, state); if (__instance.StructureInfo.Inventory.Count <= 0) { return false; } int type = __instance.StructureInfo.Inventory[0].type; int quantity = __instance.StructureInfo.Inventory[0].quantity; InventoryItem.Spawn((ITEM_TYPE)type, quantity, ((Component)__instance.Item).transform.position, 0f, (Action)null).SetInitialSpeedAndDiraction(4f + Random.Range(-0.5f, 1f), (float)(270 + Random.Range(-90, 90))); __instance.StructureInfo.Inventory.Clear(); __instance.StructureInfo.LastPrayTime = TimeManager.TotalElapsedGameTime; __instance.ShowItem(); AudioManager.Instance.PlayOneShot("event:/Stings/generic_positive", ((Component)__instance).transform.position); MMVibrate.Haptic((HapticTypes)4, (PlayerFarming)null, false, true, (MonoBehaviour)null, -1); return false; } } public abstract class CustomDrink : CustomFood { internal PleasureActions PleasureAction { get; set; } public sealed override ITEM_TYPE ItemPickUpToImitate { get; } = (ITEM_TYPE)156; public virtual int Pleasure { get; } public override int FoodSatitation { get; } } public abstract class CustomFood : CustomInventoryItem { internal TYPES StructureType { get; set; } internal FollowerCommands FollowerCommand { get; set; } public abstract List> Recipe { get; } public abstract int SatiationLevel { get; } public virtual MealEffect[] MealEffects { get; } = Array.Empty(); public virtual Vector3 ItemDisplayOffset { get; } = Vector3.zero; public override bool IsFood => true; } public abstract class CustomFoodEffect { internal string InternalObjectName = ""; internal MealEffectType MealEffect; internal string ModPrefix = ""; public abstract string InternalName { get; } public abstract Action Effect { get; } public virtual bool EffectEnabled() { return true; } public virtual string Description() { return LocalizationManager.GetTranslation("CookingData/" + ModPrefix + "." + InternalName + "/Description", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string DescriptionSuffix() { return string.Empty; } public virtual bool Positive() { return true; } } [HarmonyPatch] public static class CustomFoodEffectManager { public static Dictionary CustomEffectList { get; } = new Dictionary(); public static MealEffectType Add(CustomFoodEffect effect) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); MealEffectType val = (effect.MealEffect = GuidManager.GetEnumValue(modIdFromCallstack, effect.InternalName)); effect.ModPrefix = modIdFromCallstack; effect.InternalObjectName = "CustomMealEffect_" + effect.InternalName; CustomEffectList.Add(val, effect); return val; } [HarmonyPatch(typeof(CookingData), "DoMealEffect")] [HarmonyPostfix] public static void CookingData_DoMealEffect(ITEM_TYPE meal, FollowerBrain follower) { //IL_0000: 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_0038: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) foreach (MealEffect item in from x in CookingData.GetMealEffects(meal) where CustomEffectList.Keys.Contains(x.MealEffectType) select x) { if (Random.Range(0, 100) < item.Chance) { CustomEffectList[item.MealEffectType].Effect(follower); } } } [HarmonyPatch(typeof(CookingData), "GetEffectDescription")] [HarmonyPostfix] private static void CookingData_GetEffectDescription(ref MealEffect mealEffect, ref string __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (CustomEffectList.Keys.Contains(mealEffect.MealEffectType)) { CustomFoodEffect customFoodEffect = CustomEffectList[mealEffect.MealEffectType]; string arg = customFoodEffect.Description(); string text = customFoodEffect.DescriptionSuffix(); string arg2 = (customFoodEffect.Positive() ? "" : ""); bool num = customFoodEffect.EffectEnabled(); string text2 = $"{arg2} {mealEffect.Chance}% {arg}"; if (!num) { text2 = "" + text2 + ""; } __result = text2 + text; } } } public abstract class CustomMeal : CustomFood { public abstract float TummyRating { get; } public sealed override ITEM_TYPE ItemPickUpToImitate { get; } = (ITEM_TYPE)32; public virtual MealQuality Quality { get; } = MealQuality.NORMAL; public virtual bool MealSafeToEat { get; } = true; } public enum MealQuality { BAD, NORMAL, GOOD } public abstract class CustomInventoryItem { internal string InternalObjectName = ""; internal ITEM_TYPE ItemType; internal string ModPrefix = ""; public abstract string InternalName { get; } public virtual CustomInventoryItemType InventoryItemType { get; } public virtual Sprite InventoryIcon { get; } = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual ITEM_CATEGORIES ItemCategory => (ITEM_CATEGORIES)0; public virtual ITEM_TYPE SeedType => (ITEM_TYPE)0; public virtual int FuelWeight => 1; public virtual int FoodSatitation => 75; public virtual bool IsFish => false; public virtual bool IsFood => false; public virtual bool IsBigFish => false; public virtual bool IsCurrency => false; public virtual bool IsBurnableFuel => false; public virtual bool CanBeGivenToFollower => false; public virtual FollowerCommands GiftCommand => (FollowerCommands)0; public virtual bool CanBeRefined { get; set; } public virtual ITEM_TYPE RefineryInput { get; set; } = (ITEM_TYPE)1; public virtual int RefineryInputQty { get; set; } = 15; public virtual float CustomRefineryDuration { get; set; } public virtual Sprite Sprite { get; } = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual CustomItemManager.ItemRarity Rarity => CustomItemManager.ItemRarity.COMMON; public virtual Vector3 LocalScale { get; } = new Vector3(0.5f, 0.5f, 0.5f); public virtual bool AddItemToOfferingShrine => false; public virtual ITEM_TYPE ItemPickUpToImitate => (ITEM_TYPE)1; public virtual bool AddItemToDungeonChests => false; public virtual int DungeonChestSpawnChance => 100; public virtual int DungeonChestMinAmount => 1; public virtual int DungeonChestMaxAmount => 1; public virtual string InventoryStringIcon() { return ""; } public virtual string Name() { return LocalizedName(); } public virtual string Lore() { return LocalizedLore(); } public virtual string Description() { return LocalizedDescription(); } public virtual string LocalizedName() { return LocalizationManager.GetTranslation("Inventory/" + ModPrefix + "." + InternalName, true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string LocalizedLore() { return LocalizationManager.GetTranslation("Inventory/" + ModPrefix + "." + InternalName + "/Lore", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string LocalizedDescription() { return LocalizationManager.GetTranslation("Inventory/" + ModPrefix + "." + InternalName + "/Description", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual string GiftTitle(Follower follower) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return $"{Name()} ({Inventory.GetItemQuantity(ItemType)})"; } public virtual void OnGiftTo(Follower follower, Action onFinish) { onFinish(); } public virtual string CapacityString(int minimum) { //IL_0001: 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) int itemQuantity = Inventory.GetItemQuantity(ItemType); string text = $"{InventoryStringIcon()} {itemQuantity}/{minimum}"; if (itemQuantity >= minimum) { return text; } return StringExtensions.Colour(text, StaticColors.RedColor); } } public enum CustomInventoryItemType { ITEM, CURRENCY, FOOD } } namespace COTL_API.CustomFollowerCommand { public abstract class CustomFollowerCommand : CommandItem { internal string ModPrefix = ""; public abstract string InternalName { get; } public virtual List Categories { get; } = new List(1) { FollowerCommandCategory.DEFAULT_COMMAND }; public virtual Sprite CommandIcon { get; } = TextureHelper.CreateSpriteFromPath(PluginPaths.ResolveAssetPath("placeholder.png")); public virtual string CommandStringIcon() { return ""; } public override string GetTitle(Follower follower) { return LocalizationManager.GetTranslation("FollowerInteractions/" + ModPrefix + "." + InternalName, true, 0, true, false, (GameObject)null, (string)null, true); } public override string GetDescription(Follower follower) { return LocalizationManager.GetTranslation("FollowerInteractions/" + ModPrefix + "." + InternalName + "/Description", true, 0, true, false, (GameObject)null, (string)null, true); } public override string GetLockedDescription(Follower follower) { return LocalizationManager.GetTranslation("FollowerInteractions/" + ModPrefix + "." + InternalName + "/NotAvailable", true, 0, true, false, (GameObject)null, (string)null, true); } public virtual bool ShouldAppearFor(Follower follower) { return true; } public override bool IsAvailable(Follower follower) { return true; } public virtual void Execute(interaction_FollowerInteraction interaction, FollowerCommands finalCommand = 0) { interaction.Close(true, true, false); } } [HarmonyPatch] public static class CustomFollowerCommandManager { public static Dictionary CustomFollowerCommandList { get; } = new Dictionary(); public static FollowerCommands Add(CustomFollowerCommand command) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) string modIdFromCallstack = TypeManager.GetModIdFromCallstack(Assembly.GetCallingAssembly()); FollowerCommands val = (((CommandItem)command).Command = GuidManager.GetEnumValue(modIdFromCallstack, command.InternalName)); command.ModPrefix = modIdFromCallstack; CustomFollowerCommandList.Add(val, command); return val; } [HarmonyPatch(typeof(CommandItem), "GetTitle")] [HarmonyPrefix] private static bool CommandItem_GetTitle(CommandItem __instance, Follower follower, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out CustomFollowerCommand value)) { return true; } __result = ((CommandItem)value).GetTitle(follower); return false; } [HarmonyPatch(typeof(CommandItem), "IsAvailable", new Type[] { typeof(Follower) })] [HarmonyPrefix] private static bool CommandItem_IsAvailable(CommandItem __instance, Follower follower, ref bool __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out CustomFollowerCommand value)) { return true; } __result = ((CommandItem)value).IsAvailable(follower); return false; } [HarmonyPatch(typeof(CommandItem), "GetDescription")] [HarmonyPrefix] private static bool CommandItem_GetDescription(CommandItem __instance, Follower follower, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out CustomFollowerCommand value)) { return true; } __result = ((CommandItem)value).GetDescription(follower); return false; } [HarmonyPatch(typeof(CommandItem), "GetLockedDescription")] [HarmonyPrefix] private static bool CommandItem_GetLockedDescription(CommandItem __instance, Follower follower, ref string __result) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (!CustomFollowerCommandList.TryGetValue(__instance.Command, out CustomFollowerCommand value)) { return true; } __result = ((CommandItem)value).GetLockedDescription(follower); return false; } [HarmonyPatch(typeof(FollowerCommandGroups), "DefaultCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_DefaultCommands(Follower follower, List __result) { Follower follower2 = follower; List __result2 = __result; CollectionExtensions.Do((IEnumerable)CustomFollowerCommandList.Values, (Action)delegate(CustomFollowerCommand c) { if (c.Categories.Contains(FollowerCommandCategory.DEFAULT_COMMAND) && c.ShouldAppearFor(follower2)) { __result2.Add((CommandItem)(object)c); } }); } [HarmonyPatch(typeof(FollowerCommandGroups), "GiveWorkerCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_GiveWorkerCommands(Follower follower, List __result) { Follower follower2 = follower; List __result2 = __result; CollectionExtensions.Do((IEnumerable)CustomFollowerCommandList.Values, (Action)delegate(CustomFollowerCommand c) { if (c.Categories.Contains(FollowerCommandCategory.GIVE_WORKER_COMMAND) && c.ShouldAppearFor(follower2)) { __result2.Add((CommandItem)(object)c); } }); } [HarmonyPatch(typeof(FollowerCommandGroups), "MakeDemandCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_MakeDemandCommands(Follower follower, List __result) { Follower follower2 = follower; List __result2 = __result; CollectionExtensions.Do((IEnumerable)CustomFollowerCommandList.Values, (Action)delegate(CustomFollowerCommand c) { if (c.Categories.Contains(FollowerCommandCategory.MAKE_DEMAND_COMMAND) && c.ShouldAppearFor(follower2)) { __result2.Add((CommandItem)(object)c); } }); } [HarmonyPatch(typeof(FollowerCommandGroups), "WakeUpCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_WakeUpCommands(List __result) { List __result2 = __result; CollectionExtensions.Do((IEnumerable)CustomFollowerCommandList.Values, (Action)delegate(CustomFollowerCommand c) { if (c.Categories.Contains(FollowerCommandCategory.WAKE_UP_COMMAND)) { __result2.Add((CommandItem)(object)c); } }); } [HarmonyPatch(typeof(FollowerCommandGroups), "OldAgeCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_OldAgeCommands(Follower follower, List __result) { Follower follower2 = follower; List __result2 = __result; CollectionExtensions.Do((IEnumerable)CustomFollowerCommandList.Values, (Action)delegate(CustomFollowerCommand c) { if (c.Categories.Contains(FollowerCommandCategory.OLD_AGE_COMMAND) && c.ShouldAppearFor(follower2)) { __result2.Add((CommandItem)(object)c); } }); } [HarmonyPatch(typeof(FollowerCommandGroups), "DissenterCommands")] [HarmonyPostfix] private static void FollowerCommandGroups_DissenterCommands(Follower follower, List __result) { Follower follower2 = follower; List __result2 = __result; CollectionExtensions.Do((IEnumerable)CustomFollowerCommandList.Values, (Action)delegate(CustomFollowerCommand c) { if (c.Categories.Contains(FollowerCommandCategory.DISSENTER_COMMAND) && c.ShouldAppearFor(follower2)) { __result2.Add((CommandItem)(object)c); } }); } [HarmonyPatch(typeof(interaction_FollowerInteraction), "OnFollowerCommandFinalized")] [HarmonyPrefix] private static bool interaction_FollowerInteraction_OnFollowerCommandFinalized(interaction_FollowerInteraction __instance, FollowerCommands[] followerCommands) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) FollowerCommands val = followerCommands[0]; FollowerCommands key = (FollowerCommands)((followerCommands.Length > 1) ? ((int)followerCommands[1]) : 0); if (!CustomFollowerCommandList.ContainsKey(val) && !CustomFollowerCommandList.ContainsKey(key)) { return true; } if (CustomFollowerCommandList.TryGetValue(key, out CustomFollowerCommand value)) { value.Execute(__instance, val); } else { CustomFollowerCommandList[val].Execute(__instance, (FollowerCommands)0); } return false; } [HarmonyPatch(typeof(FontImageNames), "IconForCommand")] [HarmonyPrefix] private static bool FontImageNames_IconForCommand(FollowerCommands followerCommands, ref string __result) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (CustomFollowerCommandList.TryGetValue(followerCommands, out CustomFollowerCommand value)) { __result = value.CommandStringIcon(); return false; } FollowerCommands command0 = followerCommands; if (CustomItemManager.CustomFoodList.Values.Any((CustomFood x) => x.FollowerCommand == command0)) { __result = CustomItemManager.CustomFoodList.Values.First((CustomFood x) => x.FollowerCommand == command0).InventoryStringIcon(); return false; } return true; } } public enum FollowerCommandCategory { DEFAULT_COMMAND, DISSENTER_COMMAND, GIVE_WORKER_COMMAND, MAKE_DEMAND_COMMAND, OLD_AGE_COMMAND, WAKE_UP_COMMAND } } namespace COTL_API.CustomEnemy { public abstract class CustomEnemy { internal string ModPrefix = ""; public Enemy enemyType; public SkeletonDataAsset? SpineOverride; public string SpineSkinName = ""; public abstract string InternalName { get; } public virtual string EnemyToMimic => "Assets/Prefabs/Enemies/DLC/Enemy Swordsman Wolf.prefab"; public virtual Type? EnemyController => null; public virtual float maxHealth => 1f; } public class CustomEnemyController : UnitObject, IAttackResilient { public enum State { WaitAndTaunt, Teleporting, Attacking } [CompilerGenerated] private sealed class d__66 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CustomEnemyController <>4__this; public GameObject Attacker; private float