Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WiggyUpdates v1.5.0
WiggyUpdates.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace AshlandsFeast; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("local.claude.ashlandsfeast", "Ashlands Feast", "1.5.0")] public class AshlandsFeastPlugin : BaseUnityPlugin { internal class Ing { public string Item; public int Amount; public Ing(string item, int amount) { Item = item; Amount = amount; } } internal class FoodDef { public string Id; public string Base; public string Name; public string Description; public float Health; public float Stamina; public float Eitr; public int Yield; public string Effect; public Ing[] Ingredients; } public const string PluginGuid = "local.claude.ashlandsfeast"; internal const float Duration = 3000f; internal const float HealthRegen = 4f; internal const float CarryWeightBonus = 75f; internal const float DamageBonusPercent = 10f; internal const float EitrRegenBonusPercent = 15f; internal static ManualLogSource Log; internal static readonly FoodDef[] Foods = new FoodDef[12] { new FoodDef { Id = "AF_FieryKebab", Base = "rk_kabob", Name = "Fiery Kebab", Description = "Asksvin tail, smoke puffs and vineberries on a skewer. Hits hard and lasts.", Health = 110f, Stamina = 85f, Eitr = 0f, Yield = 1, Effect = null, Ingredients = new Ing[4] { new Ing("rk_kabob", 1), new Ing("CookedAsksvinMeat", 1), new Ing("MushroomSmokePuff", 2), new Ing("Vineberry", 1) } }, new FoodDef { Id = "AF_AsksvinBurger", Base = "rk_burger", Name = "Asksvin Burger", Description = "A thick Asksvin patty with bacon. Heavy enough to let you carry more.", Health = 105f, Stamina = 95f, Eitr = 0f, Yield = 2, Effect = "weight", Ingredients = new Ing[3] { new Ing("rk_burger", 1), new Ing("CookedAsksvinMeat", 2), new Ing("rk_bacon", 1) } }, new FoodDef { Id = "AF_MagmaFishStew", Base = "rk_fishstew", Name = "Magma Fish Stew", Description = "Magmafish stewed with fiddleheads and smoke puffs. You feel fireproof.", Health = 105f, Stamina = 100f, Eitr = 0f, Yield = 2, Effect = "fire", Ingredients = new Ing[4] { new Ing("rk_fishstew", 1), new Ing("Fish11", 2), new Ing("Fiddleheadfern", 2), new Ing("MushroomSmokePuff", 1) } }, new FoodDef { Id = "AF_FieryPizza", Base = "rk_pizza", Name = "Fiery Pizza", Description = "Pizza with Asksvin tail, smoke puffs, fiddleheads and vineberries. Hot enough to shrug off flames.", Health = 115f, Stamina = 90f, Eitr = 0f, Yield = 1, Effect = "fire", Ingredients = new Ing[5] { new Ing("rk_pizza", 1), new Ing("CookedAsksvinMeat", 1), new Ing("MushroomSmokePuff", 1), new Ing("Fiddleheadfern", 1), new Ing("Vineberry", 2) } }, new FoodDef { Id = "AF_EmberOmelette", Base = "rk_omlette", Name = "Ember Omelette", Description = "A bacon omelette with fiddleheads and vineberries that keeps you running.", Health = 100f, Stamina = 115f, Eitr = 0f, Yield = 2, Effect = null, Ingredients = new Ing[4] { new Ing("rk_omlette", 1), new Ing("rk_bacon", 1), new Ing("Fiddleheadfern", 1), new Ing("Vineberry", 1) } }, new FoodDef { Id = "AF_ScorchedEitrBroth", Base = "rk_broth", Name = "Scorched Eitr Broth", Description = "Bone broth boiled with Eitr, vineberries and fiddleheads. Fills your Eitr.", Health = 100f, Stamina = 75f, Eitr = 110f, Yield = 4, Effect = null, Ingredients = new Ing[4] { new Ing("rk_broth", 1), new Ing("Eitr", 2), new Ing("Vineberry", 2), new Ing("Fiddleheadfern", 1) } }, new FoodDef { Id = "AF_FrostbiteKebab", Base = "rk_kabob", Name = "Frostbite Kebab", Description = "Moose meat, kale and lingonberries on a skewer. Warms you against the cold.", Health = 125f, Stamina = 90f, Eitr = 0f, Yield = 1, Effect = "frostres", Ingredients = new Ing[4] { new Ing("rk_kabob", 1), new Ing("CookedMooseMeat", 1), new Ing("Kale", 2), new Ing("Lingonberry", 1) } }, new FoodDef { Id = "AF_MooseBurger", Base = "rk_burger", Name = "Moose Burger", Description = "A thick moose patty with bacon and poteitr. Heavy enough to let you carry more.", Health = 120f, Stamina = 100f, Eitr = 0f, Yield = 2, Effect = "weight", Ingredients = new Ing[4] { new Ing("rk_burger", 1), new Ing("CookedMooseMeat", 2), new Ing("Poteitr", 1), new Ing("rk_bacon", 1) } }, new FoodDef { Id = "AF_NorthernSalmonStew", Base = "rk_fishstew", Name = "Northern Salmon Stew", Description = "Northern salmon stewed with kale and seal blubber. Your fire, frost, lightning, poison and spirit attacks hit harder.", Health = 115f, Stamina = 105f, Eitr = 0f, Yield = 2, Effect = "elemdmg", Ingredients = new Ing[4] { new Ing("rk_fishstew", 1), new Ing("Fish10", 2), new Ing("Kale", 2), new Ing("CookedSealBlubber", 1) } }, new FoodDef { Id = "AF_LingonberryFrostPizza", Base = "rk_pizza", Name = "Lingonberry Frost Pizza", Description = "Pizza with moose meat, kale and lingonberries. Cold stops bothering you.", Health = 130f, Stamina = 95f, Eitr = 0f, Yield = 1, Effect = "frostres", Ingredients = new Ing[4] { new Ing("rk_pizza", 1), new Ing("CookedMooseMeat", 1), new Ing("Kale", 1), new Ing("Lingonberry", 2) } }, new FoodDef { Id = "AF_HeartyOatPorridge", Base = "rk_porridge", Name = "Hearty Oat Porridge", Description = "Oats, lingonberries and seal blubber boiled thick. Fills your Eitr and brings it back faster.", Health = 90f, Stamina = 70f, Eitr = 120f, Yield = 2, Effect = "eitrregen", Ingredients = new Ing[4] { new Ing("rk_porridge", 1), new Ing("Oat", 2), new Ing("Lingonberry", 2), new Ing("CookedSealBlubber", 1) } }, new FoodDef { Id = "AF_BlubberBroth", Base = "rk_broth", Name = "Blubber Broth", Description = "Seal blubber boiled with kale and poteitr. Fills your Eitr and makes your fire hit harder.", Health = 105f, Stamina = 80f, Eitr = 125f, Yield = 4, Effect = "firedmg", Ingredients = new Ing[4] { new Ing("rk_broth", 1), new Ing("CookedSealBlubber", 2), new Ing("Kale", 2), new Ing("Poteitr", 1) } } }; internal static Harmony HarmonyInstance; internal static ConfigEntry<float> SizePerStar; internal static ConfigEntry<float> TissuePerStar; internal static ConfigEntry<int> KeyPrice; internal static ConfigEntry<int> CastPrice; internal static ConfigEntry<int> MouldPrice; internal static ConfigEntry<bool> StatsShow; internal static ConfigEntry<KeyCode> StatsKey; internal static ConfigEntry<int> StatsFont; internal static ConfigEntry<float> StatsX; internal static ConfigEntry<float> StatsY; internal static readonly Dictionary<string, StatusEffect> FoodEffects = new Dictionary<string, StatusEffect>(); private static readonly Dictionary<string, int> KeyPricesApplied = new Dictionary<string, int>(); private static readonly Dictionary<string, int> GroupLogged = new Dictionary<string, int>(); private static readonly string[] CastIds = new string[31] { "ArmorGoldHeavyChestUncooked", "ArmorGoldMediumChestUncooked", "StaffOrbofAhriUncooked", "ArmorGoldMageHelmetUncooked", "ArmorGoldHeavyHelmetUncooked", "ArmorGoldMediumHelmetUncooked", "KeysGoldUncooked", "StaffThunderbloodUncooked", "AtgeirGoldUncooked", "AxeGoldUncooked", "BowGoldUncooked", "ShieldBucklerGoldUncooked", "CrossbowGoldUncooked", "KnifeGoldUncooked", "BattleaxeGoldUncooked", "ShieldTowerGoldUncooked", "THSwordGoldUncooked", "FistGoldUncooked", "MaceGoldUncooked", "ShieldRoundGoldUncooked", "SledgeGoldUncooked", "SpearGoldUncooked", "SwordGoldUncooked", "StaffFrostOrbsUncooked", "ArmorGoldMageChestUncooked", "StaffSpiritCallerUncooked", "ArmorGoldMageLegsUncooked", "ArmorGoldHeavyLegsUncooked", "ArmorGoldMediumLegsUncooked", "GenericMoldUncooked", "SmallPartsGoldUncooked" }; private static readonly string[] MouldIds = new string[30] { "MoldArmorGoldChest", "MoldArmormediumChest", "MoldStaffOrbofAhri", "MoldArmorMageHelmet", "MoldArmorGoldHelmet", "MoldArmorMediumHelmet", "MoldKeys", "MoldStaffthunderblood", "MoldAtgeir", "MoldAxe", "MoldBow", "MoldShieldBuckler", "MoldCrossbow", "MoldKnife", "MoldAxe2H", "MoldShieldTower", "MoldSword2H", "MoldFistweapon", "MoldMace", "MoldShieldRound", "MoldMace2H", "MoldSpear", "MoldSword", "MoldStafffrostorbs", "MoldArmorMageChest", "MoldStaffspiritcaller", "MoldArmorMageLegs", "MoldArmorGoldLegs", "MoldArmorMediumLegs", "MoldSmallParts" }; private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Expected O, but got Unknown //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Expected O, but got Unknown //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigFile config = ((BaseUnityPlugin)this).Config; AcceptableValueRange<float> obj = new AcceptableValueRange<float>(0f, 1f); object[] array = new object[1]; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes(); val.IsAdminOnly = true; array[0] = val; SizePerStar = config.Bind<float>("Size", "SizeIncreasePerStar", 0.15f, new ConfigDescription("How much bigger a creature gets with every star above the game's own star visuals (levels 4 and up). 0.15 means a 4-star creature (level 5) is 1.6 times its normal size. Tamed creatures only grow in looks (their body and collider stay normal size, so they can still breed); wild ones grow completely. 0 turns it off. The server's value is used. Keep ServersideQoL CreatureLevelUp's own SizeIncreasePerStar at 0 so the two do not both resize.", (AcceptableValueBase)(object)obj, array)); ConfigFile config2 = ((BaseUnityPlugin)this).Config; AcceptableValueRange<float> obj2 = new AcceptableValueRange<float>(0f, 5f); object[] array2 = new object[1]; ConfigurationManagerAttributes val2 = new ConfigurationManagerAttributes(); val2.IsAdminOnly = true; array2[0] = val2; TissuePerStar = config2.Bind<float>("Troll", "TissueIncreasePerStar", 0.5f, new ConfigDescription("How much more Petrified Tissue the statue of a starred Frost Troll gives, per star. 0.5 means +50% per star: a 1-star troll (level 2) gives 1.5 times the tissue, a 3-star troll (level 4) 2.5 times. 0 turns it off. Only statues made after this mod was installed carry the troll's level; older statues give the normal amount. The server's value is used.", (AcceptableValueBase)(object)obj2, array2)); ConfigFile config3 = ((BaseUnityPlugin)this).Config; AcceptableValueRange<int> obj3 = new AcceptableValueRange<int>(0, 10000); object[] array3 = new object[1]; ConfigurationManagerAttributes val3 = new ConfigurationManagerAttributes(); val3.IsAdminOnly = true; array3[0] = val3; KeyPrice = config3.Bind<int>("Traders", "IntricateKeyPrice", 100, new ConfigDescription("Coins a trader (Haldor, Hildir, the Bog Witch) pays for an Intricate Key. The game lets you sell an item only if it has a coin value above 0, and the key has none, so this gives it one. 0 = back to the game's own value (cannot be sold). Applied when the game loads; the server's value is used.", (AcceptableValueBase)(object)obj3, array3)); ConfigFile config4 = ((BaseUnityPlugin)this).Config; AcceptableValueRange<int> obj4 = new AcceptableValueRange<int>(0, 10000); object[] array4 = new object[1]; ConfigurationManagerAttributes val4 = new ConfigurationManagerAttributes(); val4.IsAdminOnly = true; array4[0] = val4; CastPrice = config4.Bind<int>("Traders", "CastPrice", 50, new ConfigDescription("Coins a trader pays for each Cast (the unfired Deep North weapons, armor, staves, keys and small parts: 'Cast: ...', Small Parts Gold Uncooked, Generic Mold Uncooked). 0 = back to the game's own value (cannot be sold). Applied when the game loads; the server's value is used.", (AcceptableValueBase)(object)obj4, array4)); ConfigFile config5 = ((BaseUnityPlugin)this).Config; AcceptableValueRange<int> obj5 = new AcceptableValueRange<int>(0, 10000); object[] array5 = new object[1]; ConfigurationManagerAttributes val5 = new ConfigurationManagerAttributes(); val5.IsAdminOnly = true; array5[0] = val5; MouldPrice = config5.Bind<int>("Traders", "MouldPrice", 25, new ConfigDescription("Coins a trader pays for each Mould (the Deep North 'Mould: ...' items and Mold Small Parts). 0 = back to the game's own value (cannot be sold). Applied when the game loads; the server's value is used.", (AcceptableValueBase)(object)obj5, array5)); KeyPrice.SettingChanged += delegate { ApplyKeyPrice(ObjectDB.instance); }; CastPrice.SettingChanged += delegate { ApplyKeyPrice(ObjectDB.instance); }; MouldPrice.SettingChanged += delegate { ApplyKeyPrice(ObjectDB.instance); }; StatsShow = ((BaseUnityPlugin)this).Config.Bind<bool>("Stats panel", "Show", true, "Show the character stats panel next to the inventory (only on your own game, the server does not use it)."); StatsKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Stats panel", "ToggleKey", (KeyCode)289, "Key that hides or shows the stats panel (None = no key)."); StatsFont = ((BaseUnityPlugin)this).Config.Bind<int>("Stats panel", "FontSize", 17, new ConfigDescription("Text size of the stats panel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 40), new object[0])); StatsX = ((BaseUnityPlugin)this).Config.Bind<float>("Stats panel", "PositionX", -1f, new ConfigDescription("Left edge of the panel as a fraction of the screen width. -1 = automatic (left of the inventory). Drag the panel with the mouse to set this and PositionY.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), new object[0])); StatsY = ((BaseUnityPlugin)this).Config.Bind<float>("Stats panel", "PositionY", -1f, new ConfigDescription("Top edge of the panel as a fraction of the screen height, measured from the bottom. -1 = automatic.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), new object[0])); PrefabManager.OnVanillaPrefabsAvailable += AddFoods; ItemManager.OnItemsRegistered += RegisterRecipesNow; ItemManager.OnItemsRegisteredFejd += RegisterRecipesNow; HarmonyInstance = new Harmony("local.claude.ashlandsfeast"); HarmonyInstance.PatchAll(); } private void Update() { try { StatsPanel.Tick(); } catch (Exception) { } } private void Start() { BetterTamesCap.Apply(HarmonyInstance); } private void AddFoods() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= AddFoods; try { FoodDef[] foods = Foods; foreach (FoodDef foodDef in foods) { GameObject val = PrefabManager.Instance.GetPrefab(foodDef.Base); if ((Object)(object)val == (Object)null) { CustomItem item = ItemManager.Instance.GetItem(foodDef.Base); if (item != null) { val = item.ItemPrefab; } } if ((Object)(object)val == (Object)null) { Log.LogError((object)("Base food '" + foodDef.Base + "' was not found (is Bone Appetit loaded?). Skipping " + foodDef.Id)); continue; } GameObject val2 = PrefabManager.Instance.CreateClonedPrefab(foodDef.Id, val); CustomItem val3 = ((!((Object)(object)val2 != (Object)null)) ? ((CustomItem)null) : new CustomItem(val2, false, new ItemConfig())); if (val3 == null || (Object)(object)val3.ItemDrop == (Object)null || (Object)(object)val3.ItemPrefab == (Object)null) { Log.LogError((object)("Could not create " + foodDef.Id)); continue; } SharedData shared = val3.ItemDrop.m_itemData.m_shared; shared.m_name = foodDef.Name; shared.m_description = foodDef.Description; shared.m_food = foodDef.Health; shared.m_foodStamina = foodDef.Stamina; shared.m_foodEitr = foodDef.Eitr; shared.m_foodBurnTime = 3000f; shared.m_foodRegen = 4f; shared.m_itemType = (ItemType)2; shared.m_maxStackSize = 20; if (foodDef.Effect == "fire") { shared.m_consumeStatusEffect = GetFireEffect(shared, foodDef.Id); } else if (foodDef.Effect == "weight") { shared.m_consumeStatusEffect = GetWeightEffect(shared, foodDef.Id); } else if (foodDef.Effect == "frostres") { shared.m_consumeStatusEffect = GetFrostResEffect(shared, foodDef.Id); } else if (foodDef.Effect == "elemdmg") { shared.m_consumeStatusEffect = GetElementalDamageEffect(shared, foodDef.Id); } else if (foodDef.Effect == "firedmg") { shared.m_consumeStatusEffect = GetFireDamageEffect(shared, foodDef.Id); } else if (foodDef.Effect == "eitrregen") { shared.m_consumeStatusEffect = GetEitrRegenEffect(shared, foodDef.Id); } else if (foodDef.Effect != null) { Log.LogError((object)("Unknown effect '" + foodDef.Effect + "' on " + foodDef.Id + "; the food has no extra effect.")); } ItemManager.Instance.AddItem(val3); } } catch (Exception ex) { Log.LogError((object)("Adding foods failed: " + ex)); } } private static GameObject FindItem(ObjectDB db, string name) { return db.m_items.Find((GameObject go) => (Object)(object)go != (Object)null && ((Object)go).name == name); } private static void RegisterRecipesNow() { AddRecipes(ObjectDB.instance); } private static Sprite IconOf(SharedData sd) { if (sd.m_icons == null || sd.m_icons.Length <= 0) { return null; } return sd.m_icons[0]; } private static StatusEffect GetFireEffect(SharedData sd, string id) { //IL_0062: 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_0074: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (FoodEffects.TryGetValue(id, out var value)) { return value; } SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_AshlandsFeast_FireRes_" + id; ((StatusEffect)val).m_name = "Fire resistance"; ((StatusEffect)val).m_tooltip = "Take less fire damage."; ((StatusEffect)val).m_icon = IconOf(sd); ((StatusEffect)val).m_ttl = 3000f; val.m_mods = new List<DamageModPair>(); DamageModPair item = new DamageModPair { m_type = (DamageType)32, m_modifier = (DamageModifier)1 }; val.m_mods.Add(item); ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); FoodEffects[id] = (StatusEffect)(object)val; return (StatusEffect)(object)val; } private static StatusEffect GetWeightEffect(SharedData sd, string id) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown if (FoodEffects.TryGetValue(id, out var value)) { return value; } SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_AshlandsFeast_CarryWeight_" + id; ((StatusEffect)val).m_name = "Hearty meal"; ((StatusEffect)val).m_tooltip = "Carry " + 75f + " more weight."; ((StatusEffect)val).m_icon = IconOf(sd); ((StatusEffect)val).m_ttl = 3000f; val.m_addMaxCarryWeight = 75f; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); FoodEffects[id] = (StatusEffect)(object)val; return (StatusEffect)(object)val; } private static StatusEffect GetFrostResEffect(SharedData sd, string id) { //IL_0062: 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_0074: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (FoodEffects.TryGetValue(id, out var value)) { return value; } SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_AshlandsFeast_FrostRes_" + id; ((StatusEffect)val).m_name = "Frost resistance"; ((StatusEffect)val).m_tooltip = "Take less frost damage."; ((StatusEffect)val).m_icon = IconOf(sd); ((StatusEffect)val).m_ttl = 3000f; val.m_mods = new List<DamageModPair>(); DamageModPair item = new DamageModPair { m_type = (DamageType)64, m_modifier = (DamageModifier)1 }; val.m_mods.Add(item); ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); FoodEffects[id] = (StatusEffect)(object)val; return (StatusEffect)(object)val; } private static StatusEffect GetElementalDamageEffect(SharedData sd, string id) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown if (FoodEffects.TryGetValue(id, out var value)) { return value; } float num = 0.1f; SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_AshlandsFeast_ElementalDamage_" + id; ((StatusEffect)val).m_name = "Elemental damage +" + 10f + "%"; ((StatusEffect)val).m_tooltip = "Fire, frost, lightning, poison and spirit damage you deal is " + 10f + "% higher."; ((StatusEffect)val).m_icon = IconOf(sd); ((StatusEffect)val).m_ttl = 3000f; val.m_percentigeDamageModifiers = new DamageTypes { m_fire = num, m_frost = num, m_lightning = num, m_poison = num, m_spirit = num }; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); FoodEffects[id] = (StatusEffect)(object)val; return (StatusEffect)(object)val; } private static StatusEffect GetFireDamageEffect(SharedData sd, string id) { //IL_0086: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown if (FoodEffects.TryGetValue(id, out var value)) { return value; } float fire = 0.1f; SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_AshlandsFeast_FireDamage_" + id; ((StatusEffect)val).m_name = "Fire damage +" + 10f + "%"; ((StatusEffect)val).m_tooltip = "Fire damage you deal is " + 10f + "% higher."; ((StatusEffect)val).m_icon = IconOf(sd); ((StatusEffect)val).m_ttl = 3000f; val.m_percentigeDamageModifiers = new DamageTypes { m_fire = fire }; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); FoodEffects[id] = (StatusEffect)(object)val; return (StatusEffect)(object)val; } private static StatusEffect GetEitrRegenEffect(SharedData sd, string id) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown if (FoodEffects.TryGetValue(id, out var value)) { return value; } SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>(); ((Object)val).name = "SE_AshlandsFeast_EitrRegen_" + id; ((StatusEffect)val).m_name = "Eitr regeneration +" + 15f + "%"; ((StatusEffect)val).m_tooltip = "Your Eitr regenerates " + 15f + "% faster."; ((StatusEffect)val).m_icon = IconOf(sd); ((StatusEffect)val).m_ttl = 3000f; val.m_eitrRegenMultiplier = 1.15f; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false)); FoodEffects[id] = (StatusEffect)(object)val; return (StatusEffect)(object)val; } private static void ApplyPrice(ObjectDB db, string prefabName, string label, ConfigEntry<int> entry, bool log) { if (entry == null) { return; } GameObject itemPrefab = db.GetItemPrefab(prefabName); ItemDrop val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null || val.m_itemData == null || val.m_itemData.m_shared == null) { return; } val.m_itemData.m_shared.m_value = entry.Value; if (!KeyPricesApplied.TryGetValue(prefabName, out var value) || value != entry.Value) { KeyPricesApplied[prefabName] = entry.Value; if (log) { Log.LogInfo((object)(label + " (" + prefabName + ") is worth " + entry.Value + " coins to traders" + ((entry.Value <= 0) ? " (not sellable)." : "."))); } } } private static void LogGroup(string label, ConfigEntry<int> entry, int count) { if (entry != null && (!GroupLogged.TryGetValue(label, out var value) || value != entry.Value)) { GroupLogged[label] = entry.Value; Log.LogInfo((object)(label + " (" + count + " items) are worth " + entry.Value + " coins each to traders" + ((entry.Value <= 0) ? " (not sellable)." : "."))); } } internal static void ApplyKeyPrice(ObjectDB db) { try { if (!((Object)(object)db == (Object)null)) { ApplyPrice(db, "BloodGoldKey", "Intricate Key", KeyPrice, log: true); string[] castIds = CastIds; foreach (string prefabName in castIds) { ApplyPrice(db, prefabName, "Cast", CastPrice, log: false); } string[] mouldIds = MouldIds; foreach (string prefabName2 in mouldIds) { ApplyPrice(db, prefabName2, "Mould", MouldPrice, log: false); } LogGroup("Casts", CastPrice, CastIds.Length); LogGroup("Moulds", MouldPrice, MouldIds.Length); } } catch (Exception) { } } internal static void AddRecipes(ObjectDB db) { //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown ApplyKeyPrice(db); if ((Object)(object)db == (Object)null || db.m_items == null || db.m_items.Count == 0 || db.m_recipes == null) { return; } bool flag = db.m_recipes.Exists((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item != (Object)null && ((Object)((Component)r.m_item).gameObject).name.StartsWith("rk_")); FoodDef[] foods = Foods; foreach (FoodDef f in foods) { GameObject val = FindItem(db, f.Id); if ((Object)(object)val == (Object)null) { Log.LogDebug((object)("Food prefab " + f.Id + " is not in the item database (yet); no recipe for it.")); continue; } ItemDrop component = val.GetComponent<ItemDrop>(); string recipeName = "Recipe_" + f.Id; if (db.m_recipes.Exists((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name == recipeName)) { continue; } Recipe val2 = db.m_recipes.Find((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item != (Object)null && ((Object)((Component)r.m_item).gameObject).name == f.Base); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.m_craftingStation == (Object)null) { if (flag) { Log.LogError((object)("No crafting station found for base food '" + f.Base + "'; recipe for " + f.Id + " not added.")); } else { Log.LogDebug((object)("Bone Appetit recipes are not there yet; recipe for " + f.Id + " will be added on a later pass.")); } continue; } List<Requirement> list = new List<Requirement>(); bool flag2 = true; Ing[] ingredients = f.Ingredients; foreach (Ing ing in ingredients) { GameObject val3 = FindItem(db, ing.Item); ItemDrop val4 = (((Object)(object)val3 != (Object)null) ? val3.GetComponent<ItemDrop>() : null); if ((Object)(object)val4 == (Object)null) { Log.LogError((object)("Ingredient '" + ing.Item + "' not found; recipe for " + f.Id + " not added.")); flag2 = false; break; } Requirement val5 = new Requirement(); val5.m_resItem = val4; val5.m_amount = ing.Amount; val5.m_amountPerLevel = 0; val5.m_recover = true; list.Add(val5); } if (flag2) { Recipe val6 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val6).name = recipeName; val6.m_item = component; val6.m_amount = f.Yield; val6.m_craftingStation = val2.m_craftingStation; val6.m_minStationLevel = val2.m_minStationLevel; val6.m_enabled = true; val6.m_resources = list.ToArray(); db.m_recipes.Add(val6); Log.LogInfo((object)("Recipe added: " + f.Name + " x" + f.Yield + " at " + ((Object)val2.m_craftingStation).name)); } } } } internal static class BetterTamesCap { internal const int CapLevel = 6; private static int replaced; private static int eggReplaced; private static FieldInfo chanceField; private static bool chanceLooked; internal static void Apply(Harmony harmony) { try { Type type = AccessTools.TypeByName("BetterTames.Scripts.Breeding.Offspring"); Type type2 = AccessTools.TypeByName("BetterTames.Scripts.Leveling.Leveling"); if (type == null || type2 == null) { AshlandsFeastPlugin.Log.LogInfo((object)"BetterTames is not loaded; tame star limit left as it is."); return; } int num = 0; if (PatchOne(harmony, type, "AdjustNewbornLevel")) { num++; } if (PatchOne(harmony, type2, "OnDeath")) { num++; } AshlandsFeastPlugin.Log.LogInfo((object)("BetterTames star limit raised to " + 5 + " stars (" + num + " of 2 places patched).")); PatchEggs(harmony); } catch (Exception ex) { AshlandsFeastPlugin.Log.LogWarning((object)("Could not change the BetterTames star limit: " + ex.Message)); } } private static bool PatchOne(Harmony harmony, Type type, string method) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null); if (methodInfo == null) { AshlandsFeastPlugin.Log.LogWarning((object)("BetterTames method " + type.Name + "." + method + " not found; its star limit is unchanged.")); return false; } replaced = 0; harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(BetterTamesCap), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); if (replaced != 1) { AshlandsFeastPlugin.Log.LogWarning((object)("BetterTames " + type.Name + "." + method + " does not look like version 0.9.0; its star limit is unchanged.")); return false; } return true; } private static void PatchEggs(Harmony harmony) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(EggGrow), "GrowUpdate", (Type[])null, (Type[])null); if (methodInfo == null) { AshlandsFeastPlugin.Log.LogWarning((object)"EggGrow.GrowUpdate not found; egg layers get no bonus star."); return; } eggReplaced = 0; harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(BetterTamesCap), "EggTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); if (eggReplaced != 1) { AshlandsFeastPlugin.Log.LogWarning((object)"EggGrow.GrowUpdate does not look as expected; egg layers get no bonus star."); } else { AshlandsFeastPlugin.Log.LogInfo((object)("Tamed egg layers can hatch with a bonus star (chance " + Chance() + "%, BetterTames' Offspring Star Chance).")); } } internal static IEnumerable<CodeInstruction> EggTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<int> list2 = new List<int>(); for (int i = 0; i + 1 < list.Count; i++) { FieldInfo fieldInfo = list[i].operand as FieldInfo; MethodInfo methodInfo = list[i + 1].operand as MethodInfo; if (list[i].opcode == OpCodes.Ldfld && fieldInfo != null && fieldInfo.Name == "m_quality" && fieldInfo.FieldType == typeof(int) && list[i + 1].opcode == OpCodes.Callvirt && methodInfo != null && methodInfo.Name == "SetLevel") { list2.Add(i); } } if (list2.Count != 1) { return list; } list.Insert(list2[0] + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Insert(list2[0] + 2, new CodeInstruction(OpCodes.Call, (object)typeof(BetterTamesCap).GetMethod("HatchLevel", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))); eggReplaced = 1; return list; } internal static int HatchLevel(int quality, EggGrow egg) { try { if ((Object)(object)egg == (Object)null || !egg.m_tamed || quality < 1 || quality >= 6) { return quality; } int num = Chance(); if (num > 0 && Random.Range(0f, 100f) < (float)num) { AshlandsFeastPlugin.Log.LogInfo((object)("An egg hatched with a bonus star: " + (quality - 1) + " -> " + quality + " stars.")); return quality + 1; } } catch (Exception ex) { AshlandsFeastPlugin.Log.LogWarning((object)("Egg bonus star failed: " + ex.Message)); } return quality; } private static int Chance() { try { if (!chanceLooked) { chanceLooked = true; Type type = AccessTools.TypeByName("BetterTames.Plugin"); if (type != null) { chanceField = AccessTools.Field(type, "offspringStarChance"); } } if (chanceField != null) { object value = chanceField.GetValue(null); if (value != null) { PropertyInfo property = value.GetType().GetProperty("Value"); if (property != null) { return Convert.ToInt32(property.GetValue(value, null)); } } } } catch (Exception) { } return 25; } internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<int> list2 = new List<int>(); for (int i = 0; i + 1 < list.Count; i++) { OpCode opcode = list[i + 1].opcode; if (list[i].opcode == OpCodes.Ldc_I4_3 && (opcode == OpCodes.Blt || opcode == OpCodes.Blt_S)) { list2.Add(i); } } if (list2.Count != 1) { return list; } list[list2[0]].opcode = OpCodes.Ldc_I4_6; replaced = 1; return list; } } internal class SizeState { public LevelEffects Effects; public int Level; public bool Tamed; } internal static class StarSize { internal static readonly ConditionalWeakTable<Character, SizeState> Tracked = new ConditionalWeakTable<Character, SizeState>(); private static readonly ConditionalWeakTable<Procreation, object> OriginalRange = new ConditionalWeakTable<Procreation, object>(); private static readonly HashSet<string> Logged = new HashSet<string>(); private static string PathOf(Transform root, Transform t) { if ((Object)(object)t == (Object)(object)root) { return ""; } string text = ((Object)t).name; Transform parent = t.parent; while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)root) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } private static Vector3 BaseScale(GameObject prefab, Transform root, Transform t) { //IL_0009: 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_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null) { return Vector3.one; } string text = PathOf(root, t); Transform val = ((text.Length == 0) ? prefab.transform : prefab.transform.Find(text)); if (!((Object)(object)val != (Object)null)) { return Vector3.one; } return val.localScale; } private static Transform ModelOf(Character ch, LevelEffects le) { Transform transform = ((Component)ch).transform; if ((Object)(object)le != (Object)null && (Object)(object)((Component)le).transform != (Object)(object)transform) { return ((Component)le).transform; } Animator componentInChildren = ((Component)ch).GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Component)componentInChildren).transform != (Object)(object)transform) { return ((Component)componentInChildren).transform; } return null; } internal static void Apply(Character ch, LevelEffects le, int level, bool tamed) { //IL_006d: 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_0072: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) float value = AshlandsFeastPlugin.SizePerStar.Value; if (value <= 0f || level <= 1) { return; } float num = 1f + (float)(level - 1) * value; GameObject gameObject = ((Component)ch).gameObject; Transform transform = gameObject.transform; GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(Utils.GetPrefabName(gameObject)) : null); Vector3 val2 = (((Object)(object)val != (Object)null) ? val.transform.localScale : Vector3.one); Transform val3 = ModelOf(ch, le); if (tamed && (Object)(object)val3 != (Object)null) { transform.localScale = val2; val3.localScale = BaseScale(val, transform, val3) * num; SetMateRange(gameObject, 1f); LogOnce(gameObject, "tamed: model scaled " + num.ToString("0.##") + "x, body and collider left at normal size"); return; } transform.localScale = val2 * num; if ((Object)(object)val3 != (Object)null) { val3.localScale = BaseScale(val, transform, val3); } SetMateRange(gameObject, num); } private static void SetMateRange(GameObject go, float factor) { try { Procreation component = go.GetComponent<Procreation>(); if (!((Object)(object)component == (Object)null)) { if (!OriginalRange.TryGetValue(component, out var value)) { value = component.m_partnerCheckRange; OriginalRange.Add(component, value); } component.m_partnerCheckRange = (float)value * factor; } } catch (Exception) { } } private static void LogOnce(GameObject go, string what) { string item = Utils.GetPrefabName(go) + " " + what.Substring(0, what.IndexOf(':')); if (Logged.Add(item)) { AshlandsFeastPlugin.Log.LogInfo((object)("Star size, " + Utils.GetPrefabName(go) + " (" + what + ").")); } } } [HarmonyPatch(typeof(LevelEffects), "SetupLevelVisualization")] internal static class LevelEffects_SetupLevelVisualization_Patch { private static readonly FieldInfo SetupsField = AccessTools.Field(typeof(LevelEffects), "m_levelSetups"); private static readonly FieldInfo CharacterField = AccessTools.Field(typeof(LevelEffects), "m_character"); [HarmonyPostfix] private static void Postfix(LevelEffects __instance, int __0) { try { if (__0 <= 1 || AshlandsFeastPlugin.SizePerStar == null || AshlandsFeastPlugin.SizePerStar.Value <= 0f) { return; } IList list = ((SetupsField != null) ? (SetupsField.GetValue(__instance) as IList) : null); if (list == null || __0 - 1 <= list.Count) { return; } Character val = (Character)((CharacterField != null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val == (Object)null)) { bool tamed = val.IsTamed(); if (!StarSize.Tracked.TryGetValue(val, out var value)) { value = new SizeState(); StarSize.Tracked.Add(val, value); } value.Effects = __instance; value.Level = __0; value.Tamed = tamed; StarSize.Apply(val, __instance, __0, tamed); } } catch (Exception) { } } } [HarmonyPatch(typeof(Character), "RPC_SetTamed")] internal static class Character_RPC_SetTamed_Patch { [HarmonyPostfix] private static void Postfix(Character __instance, bool __1) { try { if (AshlandsFeastPlugin.SizePerStar != null && StarSize.Tracked.TryGetValue(__instance, out var value) && value.Tamed != __1) { value.Tamed = __1; StarSize.Apply(__instance, value.Effects, value.Level, __1); } } catch (Exception) { } } } internal static class TrollTissue { internal const string LevelKey = "AF_TrollLevel"; internal static int PendingTroll; internal static int PendingStatue; internal static MineRock5 CurrentRock; private static readonly FieldInfo DestructibleView = AccessTools.Field(typeof(Destructible), "m_nview"); private static readonly FieldInfo RockView = AccessTools.Field(typeof(MineRock5), "m_nview"); internal static string Name(Component c) { if (!((Object)(object)c == (Object)null)) { return Utils.GetPrefabName(c.gameObject); } return ""; } internal static ZDO Zdo(object view) { ZNetView val = (ZNetView)((view is ZNetView) ? view : null); if (!((Object)(object)val != (Object)null) || !val.IsValid()) { return null; } return val.GetZDO(); } internal static ZDO StatueZdo(Destructible d) { if (!(DestructibleView == null)) { return Zdo(DestructibleView.GetValue(d)); } return null; } internal static ZDO RockZdo(MineRock5 r) { if (!(RockView == null)) { return Zdo(RockView.GetValue(r)); } return null; } internal static float Factor(int level) { if (AshlandsFeastPlugin.TissuePerStar == null || level <= 1) { return 1f; } float value = AshlandsFeastPlugin.TissuePerStar.Value; if (!(value <= 0f)) { return 1f + value * (float)(level - 1); } return 1f; } } [HarmonyPatch(typeof(Character), "OnDeath")] internal static class Character_OnDeath_TrollPatch { [HarmonyPrefix] private static void Prefix(Character __instance) { try { TrollTissue.PendingTroll = 0; if (!(TrollTissue.Name((Component)(object)__instance) != "TrollFrost")) { int level = __instance.GetLevel(); if (level > 1) { TrollTissue.PendingTroll = level; } } } catch (Exception) { } } [HarmonyFinalizer] private static void Finalizer() { TrollTissue.PendingTroll = 0; } } [HarmonyPatch(typeof(Destructible), "Awake")] internal static class Destructible_Awake_TrollPatch { [HarmonyPostfix] private static void Postfix(Destructible __instance) { try { if (TrollTissue.PendingTroll > 1 && !(TrollTissue.Name((Component)(object)__instance) != "TrollFrost_Dead")) { ZDO val = TrollTissue.StatueZdo(__instance); if (val != null) { val.Set("AF_TrollLevel", TrollTissue.PendingTroll); AshlandsFeastPlugin.Log.LogInfo((object)("Frost Troll statue marked with troll level " + TrollTissue.PendingTroll + " (tissue x" + TrollTissue.Factor(TrollTissue.PendingTroll).ToString("0.##") + ").")); } } } catch (Exception) { } } } [HarmonyPatch(typeof(Destructible), "Destroy")] internal static class Destructible_Destroy_TrollPatch { [HarmonyPrefix] private static void Prefix(Destructible __instance) { try { TrollTissue.PendingStatue = 0; if (TrollTissue.Name((Component)(object)__instance) != "TrollFrost_Dead") { return; } ZDO val = TrollTissue.StatueZdo(__instance); if (val != null) { int num = val.GetInt("AF_TrollLevel", 0); if (num > 1) { TrollTissue.PendingStatue = num; } } } catch (Exception) { } } [HarmonyFinalizer] private static void Finalizer() { TrollTissue.PendingStatue = 0; } } [HarmonyPatch(typeof(MineRock5), "Awake")] internal static class MineRock5_Awake_TrollPatch { [HarmonyPostfix] private static void Postfix(MineRock5 __instance) { try { if (TrollTissue.PendingStatue > 1 && TrollTissue.Name((Component)(object)__instance).StartsWith("TrollFrost_Frac")) { ZDO val = TrollTissue.RockZdo(__instance); if (val != null) { val.Set("AF_TrollLevel", TrollTissue.PendingStatue); } } } catch (Exception) { } } } [HarmonyPatch(typeof(MineRock5), "DamageArea")] internal static class MineRock5_DamageArea_TrollPatch { [HarmonyPrefix] private static void Prefix(MineRock5 __instance) { TrollTissue.CurrentRock = __instance; } [HarmonyFinalizer] private static void Finalizer() { TrollTissue.CurrentRock = null; } } [HarmonyPatch(typeof(DropTable), "GetDropList", new Type[] { typeof(int) })] internal static class DropTable_GetDropList_TrollPatch { [HarmonyPostfix] private static void Postfix(ref List<GameObject> __result) { try { MineRock5 currentRock = TrollTissue.CurrentRock; if ((Object)(object)currentRock == (Object)null || __result == null) { return; } ZDO val = TrollTissue.RockZdo(currentRock); if (val == null) { return; } int level = val.GetInt("AF_TrollLevel", 0); float num = TrollTissue.Factor(level); if (num <= 1f) { return; } GameObject item = null; int num2 = 0; foreach (GameObject item2 in __result) { if ((Object)(object)item2 != (Object)null && ((Object)item2).name == "GoldOre") { item = item2; num2++; } } if (num2 != 0) { float num3 = (float)num2 * num; int num4 = (int)Mathf.Floor(num3); if (Random.value < num3 - (float)num4) { num4++; } for (int i = num2; i < num4; i++) { __result.Add(item); } } } catch (Exception) { } } } public class StatsPanelDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IEventSystemHandler { public void OnBeginDrag(PointerEventData e) { StatsPanel.Dragging = true; } public void OnDrag(PointerEventData e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) StatsPanel.DragBy(e.delta); } public void OnEndDrag(PointerEventData e) { StatsPanel.Dragging = false; StatsPanel.SaveDrag(); } } internal static class StatsPanel { private const string Good = "#7CE57C"; private const string Bad = "#FF7766"; private const string Dim = "#9A9A9A"; internal static bool Dragging; private static GameObject Root; private static Canvas RootCanvas; private static RectTransform Box; private static TMP_Text Label; private static float NextRefresh; private static bool UserHidden; private static bool Failed; private static string LastText = ""; private static readonly FieldInfo PlayerPanelField = AccessTools.Field(typeof(InventoryGui), "m_player"); private static readonly FieldInfo ArmorField = AccessTools.Field(typeof(InventoryGui), "m_armor"); private static readonly string[] TypeNames = new string[8] { "Blunt", "Slash", "Pierce", "Fire", "Frost", "Lightning", "Poison", "Spirit" }; private static bool ElLooked; private static MethodInfo ElModifyIncoming; private static MethodInfo ElCapMethod; private static bool ElCapLooked; private static readonly string[] ElEffectNames = new string[8] { "AddBluntResistancePercentage", "AddSlashingResistancePercentage", "AddPiercingResistancePercentage", "AddFireResistancePercentage", "AddFrostResistancePercentage", "AddLightningResistancePercentage", "AddPoisonResistancePercentage", "AddSpiritResistancePercentage" }; internal static void Tick() { //IL_0046: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) if (Failed) { return; } if ((Object)(object)Player.m_localPlayer == (Object)null) { if ((Object)(object)Root != (Object)null && Root.activeSelf) { Root.SetActive(false); } return; } try { if (AshlandsFeastPlugin.StatsKey != null && (int)AshlandsFeastPlugin.StatsKey.Value != 0 && Input.GetKeyDown(AshlandsFeastPlugin.StatsKey.Value)) { UserHidden = !UserHidden; } Player localPlayer = Player.m_localPlayer; InventoryGui instance = InventoryGui.instance; if (!((Object)(object)localPlayer != (Object)null) || !((Object)(object)instance != (Object)null) || !InventoryGui.IsVisible() || UserHidden || AshlandsFeastPlugin.StatsShow == null || !AshlandsFeastPlugin.StatsShow.Value) { if ((Object)(object)Root != (Object)null && Root.activeSelf) { Root.SetActive(false); } return; } if ((Object)(object)Root == (Object)null) { Build(instance); } if ((Object)(object)Root == (Object)null) { return; } bool flag = !Root.activeSelf; if (flag) { Root.SetActive(true); NextRefresh = 0f; } if (Time.unscaledTime >= NextRefresh) { NextRefresh = Time.unscaledTime + 0.4f; string text = BuildText(localPlayer); if (text != LastText || flag) { LastText = text; Label.fontSize = ((AshlandsFeastPlugin.StatsFont != null) ? AshlandsFeastPlugin.StatsFont.Value : 17); Label.text = text; Label.ForceMeshUpdate(false, false); Vector2 preferredValues = Label.GetPreferredValues(text); Box.sizeDelta = new Vector2(preferredValues.x + 24f, preferredValues.y + 20f); } if (!Dragging) { Place(instance); } } } catch (Exception ex) { Failed = true; if ((Object)(object)Root != (Object)null) { Root.SetActive(false); } AshlandsFeastPlugin.Log.LogWarning((object)("Stats panel switched off, it hit an error: " + ex.GetType().Name + " " + ex.Message)); } } private static void Build(InventoryGui gui) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) TMP_Text val = (TMP_Text)((ArmorField != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null) { Failed = true; AshlandsFeastPlugin.Log.LogWarning((object)"Stats panel: the inventory's armor text was not found, panel switched off."); return; } Root = new GameObject("AF_StatsPanel"); Object.DontDestroyOnLoad((Object)(object)Root); RootCanvas = Root.AddComponent<Canvas>(); RootCanvas.renderMode = (RenderMode)0; RootCanvas.sortingOrder = 50; CanvasScaler val2 = Root.AddComponent<CanvasScaler>(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.matchWidthOrHeight = 0.5f; Root.AddComponent<GraphicRaycaster>(); GameObject val3 = new GameObject("Box", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(Root.transform, false); Box = val3.GetComponent<RectTransform>(); Box.anchorMin = Vector2.zero; Box.anchorMax = Vector2.zero; Box.pivot = new Vector2(0f, 1f); Image component = val3.GetComponent<Image>(); ((Graphic)component).color = new Color(0.05f, 0.05f, 0.05f, 0.82f); ((Graphic)component).raycastTarget = true; val3.AddComponent<StatsPanelDrag>(); GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject); ((Object)val4).name = "Label"; val4.transform.SetParent(val3.transform, false); MonoBehaviour[] components = val4.GetComponents<MonoBehaviour>(); foreach (MonoBehaviour val5 in components) { if (!(val5 is TMP_Text)) { Object.Destroy((Object)(object)val5); } } Label = val4.GetComponent<TMP_Text>(); RectTransform rectTransform = Label.rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.offsetMin = new Vector2(12f, 10f); rectTransform.offsetMax = new Vector2(-12f, -10f); Label.alignment = (TextAlignmentOptions)257; Label.richText = true; Label.textWrappingMode = (TextWrappingModes)0; Label.overflowMode = (TextOverflowModes)0; ((Graphic)Label).color = Color.white; ((Graphic)Label).raycastTarget = false; Label.fontStyle = (FontStyles)0; AshlandsFeastPlugin.Log.LogInfo((object)string.Concat("Stats panel built (drag it to move it; toggle key ", AshlandsFeastPlugin.StatsKey.Value, ").")); } private static void Place(InventoryGui gui) { //IL_0028: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) float num = ((RootCanvas.scaleFactor <= 0f) ? 1f : RootCanvas.scaleFactor); float num2 = Box.sizeDelta.x * num; float num3 = Box.sizeDelta.y * num; float num4 = ((AshlandsFeastPlugin.StatsX != null) ? AshlandsFeastPlugin.StatsX.Value : (-1f)); float num5 = ((AshlandsFeastPlugin.StatsY != null) ? AshlandsFeastPlugin.StatsY.Value : (-1f)); float num6; float num7; if (num4 >= 0f && num5 >= 0f) { num6 = num4 * (float)Screen.width; num7 = num5 * (float)Screen.height; } else { num6 = 10f; num7 = (float)Screen.height - 140f; RectTransform val = (RectTransform)((PlayerPanelField != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val != (Object)null) { Vector3[] array = (Vector3[])(object)new Vector3[4]; val.GetWorldCorners(array); Canvas componentInParent = ((Component)val).GetComponentInParent<Canvas>(); Camera val2 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); Vector2 val3 = RectTransformUtility.WorldToScreenPoint(val2, array[1]); num7 = val3.y; num6 = val3.x - 10f - num2; if (num6 < 5f) { num6 = 10f; } } } num6 = Mathf.Clamp(num6, 0f, Mathf.Max(0f, (float)Screen.width - num2)); num7 = Mathf.Clamp(num7, num3, (float)Screen.height); Box.anchoredPosition = new Vector2(num6 / num, num7 / num); } internal static void DragBy(Vector2 deltaPixels) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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 (!((Object)(object)Box == (Object)null) && !((Object)(object)RootCanvas == (Object)null)) { float num = ((RootCanvas.scaleFactor <= 0f) ? 1f : RootCanvas.scaleFactor); RectTransform box = Box; box.anchoredPosition += deltaPixels / num; } } internal static void SaveDrag() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Box == (Object)null) && !((Object)(object)RootCanvas == (Object)null) && AshlandsFeastPlugin.StatsX != null) { float num = ((RootCanvas.scaleFactor <= 0f) ? 1f : RootCanvas.scaleFactor); AshlandsFeastPlugin.StatsX.Value = Mathf.Clamp01(Box.anchoredPosition.x * num / (float)Screen.width); AshlandsFeastPlugin.StatsY.Value = Mathf.Clamp01(Box.anchoredPosition.y * num / (float)Screen.height); } } private static void ApplyEpicLootResistance(Player p, HitData hit) { if (!ElLooked) { ElLooked = true; try { Type type = AccessTools.TypeByName("EpicLoot.MagicItemEffects.ModifyResistance"); if (type != null) { ElModifyIncoming = AccessTools.Method(type, "ModifyIncoming", (Type[])null, (Type[])null); ParameterInfo[] array = ((ElModifyIncoming != null) ? ElModifyIncoming.GetParameters() : null); if (array == null || array.Length != 2 || !ElModifyIncoming.IsStatic || !array[1].ParameterType.IsAssignableFrom(typeof(HitData)) || !array[0].ParameterType.IsAssignableFrom(typeof(Player))) { ElModifyIncoming = null; } } AshlandsFeastPlugin.Log.LogInfo((object)("Stats panel: Epic Loot resistance enchants " + ((ElModifyIncoming != null) ? "are included." : "could not be found, so only the game's own resistances are shown."))); } catch (Exception) { ElModifyIncoming = null; } } if (ElModifyIncoming == null) { return; } try { ElModifyIncoming.Invoke(null, new object[2] { p, hit }); } catch (Exception) { ElModifyIncoming = null; } } private static string Pct(float multiplier) { float num = (multiplier - 1f) * 100f; if (Mathf.Abs(num) < 0.5f) { return "<color=#9A9A9A>normal</color>"; } string text = ((num < 0f) ? "#7CE57C" : "#FF7766"); return "<color=" + text + ">x" + multiplier.ToString("0.##") + " (" + ((num > 0f) ? "+" : "") + num.ToString("0") + "%)</color>"; } private static string Bonus(float fraction) { float num = fraction * 100f; string text = ((num >= 0f) ? "#7CE57C" : "#FF7766"); return "<color=" + text + ">" + ((num > 0f) ? "+" : "") + num.ToString("0.#") + "%</color>"; } private static float ElCap(int typeIndex) { try { if (!ElCapLooked) { ElCapLooked = true; Type type = AccessTools.TypeByName("EpicLoot.MagicItemEffects.ModifyResistance"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "GetResistanceCap", (Type[])null, (Type[])null) : null); if (methodInfo != null && methodInfo.IsStatic && methodInfo.GetParameters().Length == 1 && methodInfo.GetParameters()[0].ParameterType == typeof(string) && methodInfo.ReturnType == typeof(float)) { ElCapMethod = methodInfo; } } if (ElCapMethod == null) { return -1f; } return (float)ElCapMethod.Invoke(null, new object[1] { ElEffectNames[typeIndex] }); } catch (Exception) { return -1f; } } private static string Dmg(float v) { return v.ToString((v >= 100f) ? "0" : "0.#"); } private static string BuildText(Player p) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Expected O, but got Unknown //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Expected O, but got Unknown //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<b>Character stats</b>\n"); stringBuilder.Append("<b>Damage taken</b> <color=#9A9A9A>(game x Epic Loot)</color>\n"); DamageModifiers damageModifiers = ((Character)p).GetDamageModifiers((WeakSpot)null); HitData val = new HitData(); val.m_damage.m_blunt = 100f; val.m_damage.m_slash = 100f; val.m_damage.m_pierce = 100f; val.m_damage.m_fire = 100f; val.m_damage.m_frost = 100f; val.m_damage.m_lightning = 100f; val.m_damage.m_poison = 100f; val.m_damage.m_spirit = 100f; DamageModifier val2 = default(DamageModifier); val.ApplyResistance(damageModifiers, ref val2); float[] array = new float[8] { val.m_damage.m_blunt, val.m_damage.m_slash, val.m_damage.m_pierce, val.m_damage.m_fire, val.m_damage.m_frost, val.m_damage.m_lightning, val.m_damage.m_poison, val.m_damage.m_spirit }; ApplyEpicLootResistance(p, val); float[] array2 = new float[8] { val.m_damage.m_blunt, val.m_damage.m_slash, val.m_damage.m_pierce, val.m_damage.m_fire, val.m_damage.m_frost, val.m_damage.m_lightning, val.m_damage.m_poison, val.m_damage.m_spirit }; for (int i = 0; i < array2.Length; i++) { float num = array[i] / 100f; float num2 = array2[i] / 100f; float num3 = ((num > 0.0001f) ? (1f - num2 / num) : 0f); stringBuilder.Append("<color=#9A9A9A>").Append(TypeNames[i]).Append("</color> ") .Append(Pct(num2)); string text = ""; if (Mathf.Abs(num - 1f) >= 0.005f) { text = text + "game x" + num.ToString("0.##"); } if (num3 >= 0.0005f) { string text2 = text; text = text2 + ((text.Length > 0) ? ", " : "") + "Epic Loot -" + (num3 * 100f).ToString("0.#") + "%"; float num4 = ElCap(i); if (num4 > 0f && num3 >= num4 - 0.0005f) { text += " (at its limit)"; } } if (text.Length > 0) { stringBuilder.Append(" <color=#9A9A9A>").Append(text).Append("</color>"); } stringBuilder.Append("\n"); } float bodyArmor = ((Character)p).GetBodyArmor(); HitData val3 = new HitData(); val3.m_damage.m_slash = 100f; val3.ApplyArmor(bodyArmor); float slash = val3.m_damage.m_slash; stringBuilder.Append("<color=#9A9A9A>Armor </color><b>").Append(bodyArmor.ToString("0.#")).Append("</b> <color=#9A9A9A>a hit of 100 becomes </color>") .Append(slash.ToString("0.#")) .Append("<color=#9A9A9A> after armor</color>\n"); stringBuilder.Append("\n<b>Damage dealt</b>\n"); SEMan sEMan = ((Character)p).GetSEMan(); ItemData currentWeapon = ((Humanoid)p).GetCurrentWeapon(); DamageTypes damage = default(DamageTypes); bool flag = currentWeapon != null && currentWeapon.m_shared != null; if (flag) { damage = currentWeapon.GetDamage(); stringBuilder.Append("<color=#9A9A9A>").Append(Localization.instance.Localize(currentWeapon.m_shared.m_name)).Append("</color>\n"); } else { stringBuilder.Append("<color=#9A9A9A>no weapon in hand, bonuses shown on a base of 100</color>\n"); damage.m_blunt = 100f; damage.m_slash = 100f; damage.m_pierce = 100f; damage.m_fire = 100f; damage.m_frost = 100f; damage.m_lightning = 100f; damage.m_poison = 100f; damage.m_spirit = 100f; } HitData val4 = new HitData(); val4.m_damage = damage; if (sEMan != null) { sEMan.ModifyAttack((SkillType)0, ref val4); } float[] array3 = new float[8] { damage.m_blunt, damage.m_slash, damage.m_pierce, damage.m_fire, damage.m_frost, damage.m_lightning, damage.m_poison, damage.m_spirit }; float[] array4 = new float[8] { val4.m_damage.m_blunt, val4.m_damage.m_slash, val4.m_damage.m_pierce, val4.m_damage.m_fire, val4.m_damage.m_frost, val4.m_damage.m_lightning, val4.m_damage.m_poison, val4.m_damage.m_spirit }; bool flag2 = false; float num5 = 0f; float num6 = 0f; for (int j = 0; j < array3.Length; j++) { if (!(array3[j] < 0.05f) || !(array4[j] < 0.05f)) { flag2 = true; num5 += array3[j]; num6 += array4[j]; stringBuilder.Append("<color=#9A9A9A>").Append(TypeNames[j]).Append("</color> "); if (flag) { stringBuilder.Append(Dmg(array4[j])); } float num7 = ((array3[j] > 0.0001f) ? (array4[j] / array3[j] - 1f) : 0f); if (Mathf.Abs(num7) >= 0.0005f) { stringBuilder.Append(flag ? " " : "").Append(Bonus(num7)).Append(flag ? " <color=#9A9A9A>from buffs</color>" : ""); } stringBuilder.Append("\n"); } } if (flag && flag2) { stringBuilder.Append("<color=#9A9A9A>Total </color>").Append(Dmg(num6)).Append("\n"); } if (!flag2) { stringBuilder.Append("<color=#9A9A9A>none</color>\n"); } stringBuilder.Append("\n<b>Vitals</b>\n"); float num8 = 1f; float num9 = 1f; float num10 = 1f + p.GetEquipmentEitrRegenModifier(); if (sEMan != null) { sEMan.ModifyHealthRegen(ref num8); sEMan.ModifyStaminaRegen(ref num9); sEMan.ModifyEitrRegen(ref num10); } stringBuilder.Append("<color=#9A9A9A>Health </color>").Append(((Character)p).GetMaxHealth().ToString("0")).Append(" regen x") .Append(num8.ToString("0.##")) .Append("\n"); stringBuilder.Append("<color=#9A9A9A>Stamina </color>").Append(((Character)p).GetMaxStamina().ToString("0")).Append(" regen x") .Append(num9.ToString("0.##")) .Append("\n"); float maxEitr = ((Character)p).GetMaxEitr(); if (maxEitr > 0.5f) { stringBuilder.Append("<color=#9A9A9A>Eitr </color>").Append(maxEitr.ToString("0")).Append(" regen x") .Append(num10.ToString("0.##")) .Append("\n"); } stringBuilder.Append("<color=#9A9A9A>Carry weight </color>").Append(p.GetMaxCarryWeight().ToString("0")).Append("\n"); float multiplier = 1f + ((Character)p).GetEquipmentMovementModifier(); stringBuilder.Append("<color=#9A9A9A>Move speed (gear) </color>").Append(Pct(multiplier)).Append("\n"); return stringBuilder.ToString().TrimEnd(new char[1] { '\n' }); } } internal static class FishChoice { internal static string Chosen = ""; internal static string Shown = ""; private static FieldInfo selField; private static PropertyInfo recProp; private static bool recLooked; internal static bool IsRawFishRecipe(Recipe r) { if ((Object)(object)r != (Object)null && r.m_requireOnlyOneIngredient && (Object)(object)r.m_item != (Object)null && ((Object)r.m_item).name == "FishRaw" && r.m_resources != null) { return r.m_resources.Length > 1; } return false; } internal static Recipe SelectedRecipe(InventoryGui gui) { if ((Object)(object)gui == (Object)null) { return null; } if (selField == null) { selField = AccessTools.Field(typeof(InventoryGui), "m_selectedRecipe"); } if (selField == null) { return null; } object value = selField.GetValue(gui); if (value == null) { return null; } if (!recLooked) { recLooked = true; recProp = value.GetType().GetProperty("Recipe", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (recProp == null) { return null; } object? value2 = recProp.GetValue(value, null); return (Recipe)((value2 is Recipe) ? value2 : null); } internal static Requirement Find(Recipe r, string prefabName) { if (prefabName.Length == 0) { return null; } for (int i = 0; i < r.m_resources.Length; i++) { Requirement val = r.m_resources[i]; if (val != null && (Object)(object)val.m_resItem != (Object)null && ((Object)val.m_resItem).name == prefabName) { return val; } } return null; } internal static int Held(Player p, Requirement q) { if ((Object)(object)p == (Object)null || q == null || (Object)(object)q.m_resItem == (Object)null) { return 0; } return ((Humanoid)p).GetInventory().CountItems(q.m_resItem.m_itemData.m_shared.m_name, -1, true); } internal static List<Requirement> Carried(Recipe r, Player p) { List<Requirement> list = new List<Requirement>(); for (int i = 0; i < r.m_resources.Length; i++) { Requirement val = r.m_resources[i]; if (val != null && (Object)(object)val.m_resItem != (Object)null && Held(p, val) > 0) { list.Add(val); } } return list; } internal static Requirement[] Reordered(Recipe r) { if (Chosen.Length == 0) { return null; } Requirement[] resources = r.m_resources; int num = -1; for (int i = 0; i < resources.Length; i++) { if (resources[i] != null && (Object)(object)resources[i].m_resItem != (Object)null && ((Object)resources[i].m_resItem).name == Chosen) { num = i; break; } } if (num <= 0) { return null; } Requirement[] array = (Requirement[])(object)new Requirement[resources.Length]; array[0] = resources[num]; int num2 = 1; for (int j = 0; j < resources.Length; j++) { if (j != num) { array[num2++] = resources[j]; } } return array; } internal static void Step(int dir) { try { InventoryGui instance = InventoryGui.instance; Player localPlayer = Player.m_localPlayer; Recipe r = SelectedRecipe(instance); if ((Object)(object)localPlayer == (Object)null || !IsRawFishRecipe(r)) { return; } List<Requirement> list = Carried(r, localPlayer); if (list.Count < 2) { return; } string text = ((Chosen.Length > 0) ? Chosen : Shown); int num = -1; for (int i = 0; i < list.Count; i++) { if (((Object)list[i].m_resItem).name == text) { num = i; break; } } int index = ((num >= 0) ? (((num + dir) % list.Count + list.Count) % list.Count) : 0); Chosen = ((Object)list[index].m_resItem).name; } catch (Exception ex) { AshlandsFeastPlugin.Log.LogWarning((object)("Raw Fish choice: " + ex.Message)); } } } public class FishPickClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public void OnPointerClick(PointerEventData e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 FishChoice.Step(((int)e.button != 1) ? 1 : (-1)); } } [HarmonyPatch(typeof(Player), "GetFirstRequiredItem")] internal static class Player_GetFirstRequiredItem_FishPatch { [HarmonyPrefix] private static void Prefix(object[] __args, ref Requirement[] __state) { __state = null; try { object obj = __args[1]; Recipe val = (Recipe)((obj is Recipe) ? obj : null); if (FishChoice.IsRawFishRecipe(val)) { Requirement[] array = FishChoice.Reordered(val); if (array != null) { __state = val.m_resources; val.m_resources = array; } } } catch (Exception) { __state = null; } } [HarmonyFinalizer] private static Exception Finalizer(object[] __args, Requirement[] __state, Exception __exception) { try { if (__state != null) { object obj = __args[1]; Recipe val = (Recipe)((obj is Recipe) ? obj : null); if ((Object)(object)val != (Object)null) { val.m_resources = __state; } } } catch (Exception) { } return __exception; } } [HarmonyPatch(typeof(InventoryGui), "SetupRequirement")] internal static class InventoryGui_SetupRequirement_FishPatch { private const string Hint = "\n<color=#c8c8c8>Click: use the next fish you carry (right click: the one before)</color>"; [HarmonyPrefix] private static void Prefix(object[] __args) { try { object obj = __args[0]; Transform val = (Transform)((obj is Transform) ? obj : null); object obj2 = __args[1]; Requirement val2 = (Requirement)((obj2 is Requirement) ? obj2 : null); if ((Object)(object)val == (Object)null || val2 == null || (Object)(object)val2.m_resItem == (Object)null) { return; } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || !val.IsChildOf(((Component)instance).transform)) { return; } Recipe r = FishChoice.SelectedRecipe(instance); if (!FishChoice.IsRawFishRecipe(r) || FishChoice.Chosen.Length == 0 || ((Object)val2.m_resItem).name == FishChoice.Chosen) { return; } Requirement val3 = FishChoice.Find(r, FishChoice.Chosen); object obj3 = __args[2]; Player val4 = (Player)((obj3 is Player) ? obj3 : null); if (val3 != null && !((Object)(object)val4 == (Object)null)) { int num = (int)__args[4]; int num2 = (int)__args[5]; if (FishChoice.Held(val4, val3) >= val3.GetAmount(num) * num2) { __args[1] = val3; } } } catch (Exception) { } } [HarmonyPostfix] private static void Postfix(object[] __args) { try { object obj = __args[0]; Transform val = (Transform)((obj is Transform) ? obj : null); object obj2 = __args[1]; Requirement val2 = (Requirement)((obj2 is Requirement) ? obj2 : null); if ((Object)(object)val == (Object)null || val2 == null || (Object)(object)val2.m_resItem == (Object)null) { return; } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || !val.IsChildOf(((Component)instance).transform)) { return; } Recipe r = FishChoice.SelectedRecipe(instance); if (FishChoice.IsRawFishRecipe(r)) { FishChoice.Shown = ((Object)val2.m_resItem).name; if ((Object)(object)((Component)val).GetComponent<FishPickClick>() == (Object)null) { ((Component)val).gameObject.AddComponent<FishPickClick>(); } UITooltip component = ((Component)val).GetComponent<UITooltip>(); object obj3 = __args[2]; Player val3 = (Player)((obj3 is Player) ? obj3 : null); if ((Object)(object)component != (Object)null && (Object)(object)val3 != (Object)null && FishChoice.Carried(r, val3).Count > 1) { component.m_text += "\n<color=#c8c8c8>Click: use the next fish you carry (right click: the one before)</color>"; } } } catch (Exception) { } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDB_Awake_Patch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ObjectDB __instance) { AshlandsFeastPlugin.AddRecipes(__instance); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class ObjectDB_CopyOtherDB_Patch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(ObjectDB __instance) { AshlandsFeastPlugin.AddRecipes(__instance); } }