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 VikingsFeast v1.4.0
VikingFoodPlus.dll
Decompiled 30 minutes agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("VikingFoodPlus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("VikingFoodPlus")] [assembly: AssemblyTitle("VikingFoodPlus")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 VikingFoodPlus { public static class ModelLoader { private struct MatDef { public Color Kd; public Color Ke; } private static string ReadResource(string name) { using Stream stream = typeof(ModelLoader).Assembly.GetManifestResourceStream("VikingFoodPlus.Models." + name); if (stream == null) { throw new Exception("Modell-Ressource fehlt: " + name); } using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } private static float F(string s) { return float.Parse(s, CultureInfo.InvariantCulture); } private static Dictionary<string, MatDef> ParseMtl(string text) { //IL_008c: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, MatDef> dictionary = new Dictionary<string, MatDef>(); string text2 = null; MatDef value = default(MatDef); string[] array = text.Split('\n'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Trim().Split(' '); if (array2[0] == "newmtl") { if (text2 != null) { dictionary[text2] = value; } text2 = array2[1]; value = default(MatDef); } else if (array2[0] == "Kd") { value.Kd = new Color(F(array2[1]), F(array2[2]), F(array2[3])); } else if (array2[0] == "Ke") { value.Ke = new Color(F(array2[1]), F(array2[2]), F(array2[3])); } } if (text2 != null) { dictionary[text2] = value; } return dictionary; } public static GameObject Build(GameObject parent, string model, Material baseMat) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, MatDef> mats = ParseMtl(ReadResource(model + ".mtl")); GameObject root = new GameObject("VFP_CustomGeometry"); root.transform.SetParent(parent.transform, false); List<Vector3> list = new List<Vector3>(); string name = null; string mat = null; List<int> tris = new List<int>(); Dictionary<int, int> dictionary = new Dictionary<int, int>(); List<Vector3> pv = new List<Vector3>(); Action action = delegate { //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_0038: Expected O, but got Unknown //IL_007f: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (name != null && tris.Count != 0) { Mesh val = new Mesh { name = model + "_" + name }; val.SetVertices(pv); val.SetTriangles(tris, 0); val.SetUVs(0, new List<Vector2>((IEnumerable<Vector2>)(object)new Vector2[pv.Count])); val.RecalculateNormals(); val.RecalculateBounds(); GameObject val2 = new GameObject(name); val2.transform.SetParent(root.transform, false); val2.AddComponent<MeshFilter>().sharedMesh = val; MeshRenderer obj = val2.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = MakeMaterial(baseMat, mats.ContainsKey(mat) ? mats[mat] : new MatDef { Kd = Color.gray }); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)obj).receiveShadows = true; } }; string[] array = ReadResource(model + ".obj").Split('\n'); for (int num = 0; num < array.Length; num++) { string text = array[num].Trim(); if (text.Length < 2) { continue; } string[] array2 = text.Split(' '); switch (array2[0]) { case "v": list.Add(new Vector3(0f - F(array2[1]), F(array2[2]), F(array2[3]))); break; case "o": action(); name = array2[1]; tris.Clear(); dictionary.Clear(); pv.Clear(); break; case "usemtl": mat = array2[1]; break; case "f": { int[] array3 = new int[3]; for (int num2 = 0; num2 < 3; num2++) { int num3 = int.Parse(array2[num2 + 1].Split('/')[0], CultureInfo.InvariantCulture) - 1; if (!dictionary.TryGetValue(num3, out var value)) { value = (dictionary[num3] = pv.Count); pv.Add(list[num3]); } array3[num2] = value; } tris.Add(array3[0]); tris.Add(array3[2]); tris.Add(array3[1]); break; } } } action(); return root; } private static Material MakeMaterial(Material baseMat, MatDef def) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0130: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(baseMat); if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture); } string[] array = new string[5] { "_BumpMap", "_MetallicGlossMap", "_EmissionMap", "_ChitinTex", "_TerrainColorTex" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)null); } } if (val.HasProperty("_Color")) { val.SetColor("_Color", def.Kd); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", def.Kd); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.12f); } bool flag = def.Ke.r + def.Ke.g + def.Ke.b > 0.35f; if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", flag ? (def.Ke * 1.6f) : Color.black); if (flag) { val.EnableKeyword("_EMISSION"); } } return val; } } public abstract class StageSwitcher : MonoBehaviour { private readonly List<KeyValuePair<int, GameObject>> stageParts = new List<KeyValuePair<int, GameObject>>(); private int shown = -1; private float timer; protected abstract int DefaultStage { get; } protected abstract int CurrentStage(); protected virtual void Awake() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown Transform val = ((Component)this).transform.Find("VFP_CustomGeometry"); if ((Object)(object)val == (Object)null) { return; } foreach (Transform item in val) { Transform val2 = item; if (((Object)val2).name.Length > 3 && ((Object)val2).name[0] == 'S' && char.IsDigit(((Object)val2).name[1]) && ((Object)val2).name[2] == '_') { stageParts.Add(new KeyValuePair<int, GameObject>(((Object)val2).name[1] - 48, ((Component)val2).gameObject)); } } Apply(DefaultStage); } private void Update() { timer -= Time.deltaTime; if (!(timer > 0f)) { timer = 0.5f; int stage; try { stage = CurrentStage(); } catch (Exception) { stage = DefaultStage; } Apply(stage); } } private void Apply(int stage) { if (stage == shown) { return; } shown = stage; foreach (KeyValuePair<int, GameObject> stagePart in stageParts) { stagePart.Value.SetActive(stagePart.Key == stage); } } } public class CauldronStageVisuals : StageSwitcher { public static readonly List<CauldronStageVisuals> All = new List<CauldronStageVisuals>(); public int Level = 1; public bool Valid; private CraftingStation station; private MethodInfo getLevel; protected override int DefaultStage => 1; protected override void Awake() { station = ((Component)this).GetComponent<CraftingStation>(); try { if ((Object)(object)station != (Object)null) { getLevel = typeof(CraftingStation).GetMethod("GetLevel"); } } catch (Exception) { getLevel = null; } base.Awake(); } private void OnEnable() { if (!All.Contains(this)) { All.Add(this); } } private void OnDisable() { All.Remove(this); } protected override int CurrentStage() { Valid = false; if (getLevel == null || (Object)(object)station == (Object)null) { return 1; } object[] parameters = ((getLevel.GetParameters().Length == 0) ? new object[0] : new object[1] { true }); int result = (Level = Mathf.Clamp((int)getLevel.Invoke(station, parameters), 1, 4)); Valid = true; return result; } } public class ExtensionStageVisuals : StageSwitcher { public int OwnTier = 2; private const float SearchRadius = 40f; protected override int DefaultStage => OwnTier; protected override int CurrentStage() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) CauldronStageVisuals cauldronStageVisuals = null; float num = 40f; foreach (CauldronStageVisuals item in CauldronStageVisuals.All) { if (!((Object)(object)item == (Object)null) && item.Valid) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position); if (num2 < num) { num = num2; cauldronStageVisuals = item; } } } if (!((Object)(object)cauldronStageVisuals == (Object)null)) { return Mathf.Clamp(cauldronStageVisuals.Level, 2, 4); } return OwnTier; } } [BepInPlugin("de.vikingfoodplus.mod", "Viking's Feast", "1.4.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class VikingFoodPlus : BaseUnityPlugin { private sealed class FoodSpec { public readonly string Id; public readonly string German; public readonly string English; public readonly string Model; public readonly string Ingredients; public readonly float Hp; public readonly float Stamina; public readonly float Eitr; public readonly float Duration; public readonly float Regen; public readonly int Level; public FoodSpec(string id, string german, string english, string model, float hp, float stamina, int level, string ingredients, float eitr = 0f, float duration = 0f, float regen = 0f) { Id = id; German = german; English = english; Model = model; Hp = hp; Stamina = stamina; Eitr = eitr; Level = level; Ingredients = ingredients; Duration = ((duration > 0f) ? duration : ((float)(level switch { 2 => 1500, 1 => 1200, _ => 1800, }))); Regen = regen; } } public const string Guid = "de.vikingfoodplus.mod"; private const string Station = "VFP_RuneCauldron"; private ConfigEntry<bool> enabledMod; private ConfigEntry<string> distilleryCost; private readonly Dictionary<string, ConfigEntry<float>> health = new Dictionary<string, ConfigEntry<float>>(); private readonly Dictionary<string, ConfigEntry<float>> eitr = new Dictionary<string, ConfigEntry<float>>(); private readonly Dictionary<string, ConfigEntry<float>> stamina = new Dictionary<string, ConfigEntry<float>>(); private readonly Dictionary<string, ConfigEntry<float>> duration = new Dictionary<string, ConfigEntry<float>>(); private readonly Dictionary<string, ConfigEntry<float>> regen = new Dictionary<string, ConfigEntry<float>>(); private readonly Dictionary<string, ConfigEntry<string>> ingredients = new Dictionary<string, ConfigEntry<string>>(); private readonly Dictionary<string, ConfigEntry<bool>> foodEnabled = new Dictionary<string, ConfigEntry<bool>>(); private readonly Dictionary<string, ConfigEntry<int>> portions = new Dictionary<string, ConfigEntry<int>>(); private static readonly HashSet<string> DisabledByDefault = new HashSet<string> { "DeerThistleRoast", "ForestHerbRagout", "FrostSealStew", "FrostberryBake", "IcefjordFishPot", "LoxHerbRoast", "LoxMushroomPan", "MistMushroomStew", "MountainMushroomBroth", "MushroomHoneyStew", "NordicMooseRoast", "NordicWildRoast", "SeekerHerbRoast", "SwampHerbSoup", "VolcanicMeatStew" }; private static readonly FoodSpec[] Foods = new FoodSpec[39] { new FoodSpec("BoarHerbRoast", "Wildschwein-Kräuterbraten", "Boar herb roast", "CookedMeat", 30f, 12f, 1, "TrophyBoar:1,Dandelion:5,Honey:3"), new FoodSpec("BerryMash", "Waldbeerenmus", "Forest berry mash", "QueensJam", 12f, 40f, 1, "Raspberry:8,Dandelion:4,Honey:3"), new FoodSpec("MushroomHoneyStew", "Pilz-Honig-Eintopf", "Mushroom honey stew", "DeerStew", 25f, 25f, 1, "Mushroom:6,RawMeat:2,Honey:3"), new FoodSpec("DeerThistleRoast", "Hirsch-Distelbraten", "Deer thistle roast", "CookedDeerMeat", 45f, 17f, 1, "DeerMeat:4,Thistle:5,Blueberries:4"), new FoodSpec("YellowMushroomSoup", "Gelbe Pilzsuppe", "Yellow mushroom soup", "CarrotSoup", 17f, 55f, 1, "MushroomYellow:8,Carrot:4,Blueberries:4"), new FoodSpec("ForestHerbRagout", "Waldkräuter-Ragout", "Forest herb ragout", "DeerStew", 35f, 35f, 1, "DeerMeat:3,MushroomYellow:5,Thistle:4"), new FoodSpec("DraugrStew", "Draugr-Fleischtopf", "Draugr meat stew", "Sausages", 65f, 22f, 2, "Entrails:5,Turnip:4,Thistle:5"), new FoodSpec("SwampHerbSoup", "Sumpfkräuter-Suppe", "Swamp herb soup", "TurnipStew", 22f, 75f, 2, "Thistle:8,MushroomYellow:5,Turnip:4"), new FoodSpec("BloodThistleStew", "Blut-Seetang-Eintopf", "Blood seaweed stew", "BlackSoup", 45f, 45f, 2, "Bloodbag:4,Entrails:4,Thistle:5"), new FoodSpec("WolfHerbRoast", "Wolfsbraten mit Kräutern", "Wolf herb roast", "CookedWolfMeat", 75f, 25f, 2, "TrophyWolf:1,WolfMeat:4,Onion:4"), new FoodSpec("MountainMushroomBroth", "Bergpilz-Brühe", "Mountain mushroom broth", "OnionSoup", 25f, 90f, 2, "MushroomYellow:6,Onion:5,FreezeGland:3"), new FoodSpec("WolfThistleStew", "Drachenbrühe", "Dragon broth", "WolfMeatSkewer", 55f, 65f, 2, "DragonEggshellPowder:2,Onion:4,FreezeGland:2"), new FoodSpec("LoxHerbRoast", "Lox-Kräuterbraten", "Lox herb roast", "CookedLoxMeat", 85f, 30f, 2, "LoxMeat:4,Thistle:5,Cloudberry:5"), new FoodSpec("GoldenBarleyPorridge", "Goldener Gerstenbrei", "Golden barley porridge", "Bread", 30f, 100f, 2, "BarleyFlour:8,Cloudberry:6,Honey:4"), new FoodSpec("LoxMushroomPan", "Lox-Pilz-Pfanne", "Lox mushroom pan", "LoxPie", 65f, 65f, 2, "LoxMeat:4,MushroomYellow:6,BarleyFlour:5"), new FoodSpec("SeekerHerbRoast", "Sucher-Kräuterbraten", "Seeker herb roast", "CookedBugMeat", 95f, 32f, 3, "BugMeat:4,MushroomJotunPuffs:6,RoyalJelly:4"), new FoodSpec("MagicMushroomCream", "Magische Pilzcreme", "Magic mushroom cream", "Salad", 32f, 110f, 3, "MushroomMagecap:6,MushroomJotunPuffs:6,RoyalJelly:4"), new FoodSpec("MistMushroomStew", "Nebelpilz-Eintopf", "Mist mushroom stew", "MisthareSupreme", 70f, 70f, 3, "BugMeat:4,MushroomMagecap:5,MushroomJotunPuffs:5"), new FoodSpec("AsksvinFireRoast", "Vulkangierbraten", "Volcanic vulture roast", "CookedAsksvinMeat", 110f, 35f, 3, "VoltureMeat:4,Vineberry:6,SmokePuff:4"), new FoodSpec("EmberHerbSoup", "Glutkräuter-Suppe", "Ember herb soup", "MashedMeat", 35f, 120f, 3, "Vineberry:7,SmokePuff:6,MushroomMagecap:4"), new FoodSpec("VolcanicMeatStew", "Vulkanischer Fleischtopf", "Volcanic meat stew", "PiquantPie", 80f, 80f, 3, "VoltureMeat:4,AsksvinMeat:4,Vineberry:6"), new FoodSpec("HerbFish", "Gebratener Kräuterfisch", "Grilled herb fish", "FishRaw", 35f, 15f, 1, "FishRaw:6,Dandelion:3,Honey:2"), new FoodSpec("ForestFishPan", "Waldpilz-Fischpfanne", "Forest mushroom fish pan", "FishWraps", 40f, 40f, 1, "FishRaw:6,MushroomYellow:4,Thistle:3"), new FoodSpec("SwampFishStew", "Sumpffisch-Eintopf", "Swamp fish stew", "SerpentStew", 25f, 80f, 2, "FishRaw:6,Thistle:4,Turnip:3"), new FoodSpec("FrostFishRoast", "Frostfischbraten", "Frost fish roast", "FishRaw", 95f, 30f, 2, "Fish11:3,Onion:4,FreezeGland:2"), new FoodSpec("PufferBarleyPan", "Kugelfisch-Gerstenpfanne", "Pufferfish barley pan", "FishWraps", 80f, 80f, 2, "Fish8:3,BarleyFlour:5,Cloudberry:4"), new FoodSpec("AnglerMistSoup", "Anglerfisch-Nebelsuppe", "Anglerfish mist soup", "FishAndBread", 40f, 135f, 3, "Fish9:3,MushroomMagecap:5,RoyalJelly:3"), new FoodSpec("RoyalMistRagout", "Königliches Nebelragout", "Royal mist ragout", "MisthareSupreme", 95f, 30f, 2, "RoyalJelly:4,MushroomMagecap:5,HareMeat:3", 90f, 1800f, 5f), new FoodSpec("AsksvinEmberFeast", "Asksvin-Glutmahl", "Asksvin ember feast", "CookedAsksvinMeat", 45f, 115f, 3, "CelestialFeather:3,ProustitePowder:5,AsksvinMeat:4", 115f, 1800f, 6f), new FoodSpec("EternalFrostEssence", "Essenz des Ewigen Frosts", "Essence of eternal frost", "SerpentStew", 55f, 45f, 4, "LiquidFrost:6,Kale:2,Lingonberry:5", 165f, 1800f, 7f), new FoodSpec("TickSud", "Zecken-Sud", "Tick broth", "BlackSoup", 60f, 40f, 3, "Bloodbag:4,MeadowsHerbHarvest:2,Sap:2", 0f, 1800f, 3f), new FoodSpec("HeartyFlatbread", "Herzhaftes Fladenbrot", "Hearty flatbread", "Bread", 45f, 70f, 2, "BarleyFlour:10,Onion:3,LoxMeat:2", 0f, 1800f, 3f), new FoodSpec("MooseBurger", "Elchburger", "Moose burger", "CookedLoxMeat", 105f, 45f, 4, "MooseMeat:2,BarleyFlour:4,Onion:2,Lingonberry:3", 0f, 1800f, 5f), new FoodSpec("NordicMooseRoast", "Nordischer Elchbraten", "Nordic moose roast", "CookedLoxMeat", 125f, 40f, 4, "MooseMeat:5,Poteitr:5,Kale:4,Lingonberry:3"), new FoodSpec("NorthernOatPorridge", "Nordlicht-Haferbrei", "Northern lights oat porridge", "QueensJam", 40f, 140f, 4, "Oats:8,Lingonberry:5,OatMilk:4,Poteitr:3"), new FoodSpec("FrostSealStew", "Frostiger Robbeneintopf", "Frosty seal stew", "SerpentStew", 95f, 95f, 4, "SealBlubber:4,MooseMeat:4,Kale:5,Poteitr:4"), new FoodSpec("NordicWildRoast", "Nordischer Wildschmorbraten", "Nordic game stew roast", "CookedLoxMeat", 110f, 60f, 4, "MooseMeat:6,Kale:4,Poteitr:4,Lingonberry:3", 120f, 1800f, 7f), new FoodSpec("IcefjordFishPot", "Eisfjord-Fischeintopf", "Icefjord fish pot", "SerpentStew", 85f, 90f, 4, "Fish11:3,SealBlubber:3,Kale:4,Poteitr:3", 140f, 1800f, 6f), new FoodSpec("FrostberryBake", "Frostbeeren-Auflauf", "Frostberry bake", "QueensJam", 70f, 40f, 4, "Lingonberry:8,OatMilk:4,Oats:5,Honey:3", 120f, 1800f, 6f) }; private void Awake() { //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown enabledMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable mod content; restart required."); FoodSpec[] foods = Foods; foreach (FoodSpec foodSpec in foods) { foodEnabled[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<bool>("Food - " + foodSpec.Id, "Enabled", !DisabledByDefault.Contains(foodSpec.Id), "Enable this dish; restart required."); health[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<float>("Food - " + foodSpec.Id, "Health", foodSpec.Hp, "Health per portion; restart required."); stamina[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<float>("Food - " + foodSpec.Id, "Stamina", foodSpec.Stamina, "Stamina per portion; restart required."); eitr[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<float>("Food - " + foodSpec.Id, "Eitr", foodSpec.Eitr, "Eitr per portion; restart required."); duration[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<float>("Food - " + foodSpec.Id, "Duration", foodSpec.Duration, "Food duration in seconds; restart required."); regen[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<float>("Food - " + foodSpec.Id, "Regen", foodSpec.Regen, "Food healing per tick; restart required."); ingredients[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<string>("Food - " + foodSpec.Id, "Ingredients", foodSpec.Ingredients, "Prefab:count comma-separated; restart required."); portions[foodSpec.Id] = ((BaseUnityPlugin)this).Config.Bind<int>("Food - " + foodSpec.Id, "Portions", 2, new ConfigDescription("Output portions; restart required.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); } distilleryCost = ((BaseUnityPlugin)this).Config.Bind<string>("Piece - IceDistillery", "Requirements", "Crystal:20,DragonTear:5,BlackMetalScrap:10,YggdrasilWood:2", "Baukosten der Eisdestillerie als Prefab:Anzahl, kommagetrennt. Unbekannte Prefabs werden uebersprungen (Warnung im Log). Namen per Konsole 'spawn' + Autovervollstaendigung pruefen; Neustart noetig."); if (enabledMod.Value) { PrefabManager.OnVanillaPrefabsAvailable += Register; } } private void Register() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00f7: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= Register; try { RegisterStation(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Runenkessel: " + ex)); } try { RegisterExtension("VFP_FermentBarrel", "piece_workbench_ext1", "Gärfass", "Fermentation barrel", 2, (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("FineWood", 15, 0, true), new RequirementConfig("Iron", 8, 0, true), new RequirementConfig("ElderBark", 5, 0, true) }); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Gärfass: " + ex2)); } try { RegisterExtension("VFP_RuneDryingRack", "piece_workbench_ext1", "Runen-Trockengestell", "Runic drying rack", 3, (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("YggdrasilWood", 15, 0, true), new RequirementConfig("BlackMetal", 10, 0, true), new RequirementConfig("BlackMarble", 5, 0, true) }); } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("Trockengestell: " + ex3)); } try { RegisterExtension("VFP_IceDistillery", "piece_workbench_ext1", "Eisdestillerie", "Ice distillery", 4, ParseRequirements(distilleryCost.Value)); } catch (Exception ex4) { ((BaseUnityPlugin)this).Logger.LogError((object)("Eisdestillerie: " + ex4)); } FoodSpec[] foods = Foods; foreach (FoodSpec foodSpec in foods) { try { if (foodEnabled[foodSpec.Id].Value) { RegisterFood(foodSpec); } } catch (Exception ex5) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Rezept " + foodSpec.Id + " übersprungen: " + ex5.Message)); } } try { if (foodEnabled["HeartyFlatbread"].Value) { RegisterFlatbreadBaking(); } } catch (Exception ex6) { ((BaseUnityPlugin)this).Logger.LogError((object)("Fladenbrot-Kochofen: " + ex6)); } try { RegisterTranslations(); } catch (Exception ex7) { ((BaseUnityPlugin)this).Logger.LogError((object)("Localization: " + ex7)); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Viking's Feast 1.4 registration complete."); } private void RegisterStation() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown GameObject val = PrefabManager.Instance.CreateClonedPrefab("VFP_RuneCauldron", "piece_cauldron"); if ((Object)(object)val == (Object)null) { throw new Exception("piece_cauldron missing"); } CraftingStation component = val.GetComponent<CraftingStation>(); if ((Object)(object)component == (Object)null) { throw new Exception("CraftingStation missing"); } component.m_name = "$vfp_station"; Piece component2 = val.GetComponent<Piece>(); component2.m_name = "$vfp_station"; component2.m_description = "$vfp_station_desc"; Decorate(val, 1); PieceManager instance = PieceManager.Instance; PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_HammerPieceTable"; val2.Category = "Crafting"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig("Wood", 15, 0, true), new RequirementConfig("Stone", 10, 0, true), new RequirementConfig("Bronze", 5, 0, true) }; instance.AddPiece(new CustomPiece(val, true, val2)); } private RequirementConfig[] ParseRequirements(string spec) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown List<RequirementConfig> list = new List<RequirementConfig>(); string[] array = spec.Split(','); foreach (string text in array) { string[] array2 = text.Trim().Split(':'); if (array2.Length != 2 || !int.TryParse(array2[1], out var result)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Ungueltige Baukosten: " + text)); } else if ((Object)(object)PrefabManager.Instance.GetPrefab(array2[0]) == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Baukosten: Prefab nicht gefunden, uebersprungen: " + array2[0])); } else { list.Add(new RequirementConfig(array2[0], result, 0, true)); } } if (list.Count == 0) { throw new Exception("Keine gueltigen Baukosten in der Config"); } return list.ToArray(); } private void RegisterExtension(string id, string basePrefab, string de, string en, int style, RequirementConfig[] requirements) { //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown GameObject val = PrefabManager.Instance.CreateClonedPrefab(id, basePrefab); if ((Object)(object)val == (Object)null) { throw new Exception(basePrefab + " missing"); } Piece component = val.GetComponent<Piece>(); if ((Object)(object)component == (Object)null) { throw new Exception("Piece missing"); } component.m_name = "$vfp_" + id.Substring(4).ToLowerInvariant(); component.m_description = "$vfp_" + id.Substring(4).ToLowerInvariant() + "_desc"; try { ApplyPieceIcon(component, style switch { 3 => "BuildRuneDryingRack", 2 => "BuildFermentBarrel", _ => "BuildIceDistillery", }); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Baumenü-Icon " + id + ": " + ex.Message)); } StationExtension component2 = val.GetComponent<StationExtension>(); if ((Object)(object)component2 == (Object)null) { throw new Exception("StationExtension missing"); } FieldInfo field = typeof(StationExtension).GetField("m_craftingStation"); if (field == null) { throw new Exception("StationExtension.m_craftingStation missing"); } GameObject prefab = PrefabManager.Instance.GetPrefab("VFP_RuneCauldron"); if ((Object)(object)prefab == (Object)null) { throw new Exception("Runenkessel prefab missing"); } CraftingStation component3 = prefab.GetComponent<CraftingStation>(); if (field.FieldType == typeof(CraftingStation)) { field.SetValue(component2, component3); } else { if (!(field.FieldType == typeof(string))) { throw new Exception("Unsupported crafting station field: " + field.FieldType); } field.SetValue(component2, "VFP_RuneCauldron"); } Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Decorate(val, style); PieceManager.Instance.AddPiece(new CustomPiece(val, true, new PieceConfig { PieceTable = "_HammerPieceTable", Category = "Crafting", Requirements = requirements })); } private void Decorate(GameObject parent, int style) { string text = style switch { 3 => "VFP_RuneDryingRack", 2 => "VFP_FermentBarrel", 1 => "VFP_RuneCauldron", _ => "VFP_IceDistillery", }; Material val = null; MeshRenderer[] componentsInChildren = parent.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val2 in componentsInChildren) { if ((Object)(object)((Renderer)val2).sharedMaterial != (Object)null) { val = ((Renderer)val2).sharedMaterial; break; } } if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"No source material for custom geometry"); return; } try { ModelLoader.Build(parent, text, val); if (style == 1 && (Object)(object)parent.GetComponent<CauldronStageVisuals>() == (Object)null) { parent.AddComponent<CauldronStageVisuals>(); } if (style >= 2 && (Object)(object)parent.GetComponent<ExtensionStageVisuals>() == (Object)null) { parent.AddComponent<ExtensionStageVisuals>().OwnTier = style; } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Modell " + text + ": " + ex)); } } private void RegisterFood(FoodSpec food) { //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Expected O, but got Unknown string text = "VFP_" + food.Id; GameObject val = PrefabManager.Instance.CreateClonedPrefab(text, food.Model); if ((Object)(object)val == (Object)null) { throw new Exception("Missing item model: " + food.Model); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new Exception("Missing ItemDrop on " + food.Model); } SharedData shared = component.m_itemData.m_shared; shared.m_name = "$vfp_" + food.Id.ToLowerInvariant(); shared.m_description = "$vfp_" + food.Id.ToLowerInvariant() + "_desc"; shared.m_food = health[food.Id].Value; shared.m_foodStamina = stamina[food.Id].Value; shared.m_foodEitr = eitr[food.Id].Value; shared.m_foodBurnTime = duration[food.Id].Value; if (food.Regen > 0f) { shared.m_foodRegen = regen[food.Id].Value; } try { ApplyEmbeddedIcon(component, food.Id); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Icon " + food.Id + ": " + ex.Message)); } ItemManager.Instance.AddItem(new CustomItem(val, true)); List<RequirementConfig> list = new List<RequirementConfig>(); string[] array = ingredients[food.Id].Value.Split(','); foreach (string text2 in array) { string[] array2 = text2.Split(':'); if (array2.Length != 2) { throw new Exception("Invalid ingredient " + text2); } string text3 = array2[0]; if ((Object)(object)PrefabManager.Instance.GetPrefab(text3) == (Object)null) { throw new Exception("Missing ingredient prefab: " + text3); } list.Add(new RequirementConfig(text3, int.Parse(array2[1]), 0, true)); } if (food.Id == "HeartyFlatbread") { RegisterFlatbreadDough(); } ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig { Item = ((food.Id == "HeartyFlatbread") ? "VFP_HeartyFlatbreadDough" : text), CraftingStation = "VFP_RuneCauldron", MinStationLevel = food.Level, Amount = portions[food.Id].Value, Requirements = list.ToArray() })); } private void RegisterFlatbreadDough() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown GameObject val = PrefabManager.Instance.CreateClonedPrefab("VFP_HeartyFlatbreadDough", "BreadDough"); if ((Object)(object)val == (Object)null) { throw new Exception("Vanilla BreadDough prefab not found"); } ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { throw new Exception("BreadDough has no ItemDrop"); } component.m_itemData.m_shared.m_name = "$vfp_flatbreaddough"; component.m_itemData.m_shared.m_description = "$vfp_flatbreaddough_desc"; component.m_itemData.m_shared.m_food = 0f; component.m_itemData.m_shared.m_foodStamina = 0f; component.m_itemData.m_shared.m_foodEitr = 0f; ItemManager.Instance.AddItem(new CustomItem(val, true)); } private void RegisterFlatbreadBaking() { GameObject prefab = PrefabManager.Instance.GetPrefab("piece_oven"); if ((Object)(object)prefab == (Object)null) { throw new Exception("Vanilla piece_oven not found"); } CookingStation component = prefab.GetComponent<CookingStation>(); if ((Object)(object)component == (Object)null) { throw new Exception("Oven CookingStation not found"); } FieldInfo? field = typeof(CookingStation).GetField("m_conversion", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { throw new Exception("CookingStation.m_conversion not found"); } if (!(field.GetValue(component) is IList list)) { throw new Exception("Oven conversion list unavailable"); } GameObject prefab2 = PrefabManager.Instance.GetPrefab("VFP_HeartyFlatbread"); GameObject prefab3 = PrefabManager.Instance.GetPrefab("VFP_HeartyFlatbreadDough"); if ((Object)(object)prefab2 == (Object)null || (Object)(object)prefab3 == (Object)null) { throw new Exception("Flatbread item or dough missing"); } object obj = null; foreach (object item in list) { object? obj2 = item.GetType().GetField("m_from")?.GetValue(item); ItemDrop val = (ItemDrop)((obj2 is ItemDrop) ? obj2 : null); object? obj3 = item.GetType().GetField("m_to")?.GetValue(item); ItemDrop val2 = (ItemDrop)((obj3 is ItemDrop) ? obj3 : null); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && ((Object)val).name.Contains("BreadDough") && ((Object)val2).name.Contains("Bread")) { obj = item; break; } } if (obj == null) { throw new Exception("Vanilla bread oven conversion not found"); } object obj4 = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(obj, null); obj4.GetType().GetField("m_from").SetValue(obj4, prefab3.GetComponent<ItemDrop>()); obj4.GetType().GetField("m_to").SetValue(obj4, prefab2.GetComponent<ItemDrop>()); list.Add(obj4); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Fladenbrot: Teig am Runenkessel, Backen im Kochofen registriert."); } private void ApplyPieceIcon(Piece piece, string id) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) Assembly assembly = typeof(VikingFoodPlus).Assembly; string text = "VikingFoodPlus.Icons." + id + ".png"; using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { throw new Exception("Icon resource missing: " + text); } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { throw new Exception("Unable to read icon: " + text); } } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { throw new Exception("Invalid PNG: " + text); } ((Object)val).name = "VFP_PieceIcon_" + id; piece.m_icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } private void ApplyEmbeddedIcon(ItemDrop item, string id) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) Assembly assembly = typeof(VikingFoodPlus).Assembly; string text = "VikingFoodPlus.Icons." + id + ".png"; using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Eigenes Icon fehlt: " + text)); return; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { throw new Exception("Could not read embedded icon"); } } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { throw new Exception("PNG decode failed"); } ((Object)val).name = "VFP_Icon_" + id; item.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)) }; } private void RegisterTranslations() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown CustomLocalization val = new CustomLocalization(((BaseUnityPlugin)this).Info.Metadata); Dictionary<string, string> dictionary = new Dictionary<string, string> { { "vfp_flatbreaddough", "Herzhafter Fladenbrot-Teig" }, { "vfp_flatbreaddough_desc", "Im Kochofen zu herzhaftem Fladenbrot backen." }, { "vfp_station", "Runenkessel" }, { "vfp_station_desc", "Runenkessel für besondere Gerichte." }, { "vfp_fermentbarrel", "Gärfass" }, { "vfp_fermentbarrel_desc", "Erweiterung für den Runenkessel. Erhöht die Kochstufe auf 2. In der Nähe des Runenkessels aufstellen." }, { "vfp_runedryingrack", "Runen-Trockengestell" }, { "vfp_runedryingrack_desc", "Erweiterung für den Runenkessel. Erhöht die Kochstufe auf 3. In der Nähe des Runenkessels aufstellen." }, { "vfp_icedistillery", "Eisdestillerie" }, { "vfp_icedistillery_desc", "Erweiterung für den Runenkessel. Erhöht die Kochstufe auf 4 und schaltet die Gerichte des Nordens frei. In der Nähe des Runenkessels aufstellen." } }; Dictionary<string, string> dictionary2 = new Dictionary<string, string> { { "vfp_flatbreaddough", "Hearty flatbread dough" }, { "vfp_flatbreaddough_desc", "Bake in an oven to make hearty flatbread." }, { "vfp_station", "Runic Cauldron" }, { "vfp_station_desc", "A runic cauldron for preparing special dishes." }, { "vfp_fermentbarrel", "Fermentation Barrel" }, { "vfp_fermentbarrel_desc", "Runic Cauldron upgrade. Raises the cooking station level to 2. Place near the Runic Cauldron." }, { "vfp_runedryingrack", "Runic Drying Rack" }, { "vfp_runedryingrack_desc", "Runic Cauldron upgrade. Raises the cooking station level to 3. Place near the Runic Cauldron." }, { "vfp_icedistillery", "Ice Distillery" }, { "vfp_icedistillery_desc", "Runic Cauldron upgrade. Raises the cooking station level to 4 and unlocks the dishes of the North. Place near the Runic Cauldron." } }; FoodSpec[] foods = Foods; foreach (FoodSpec foodSpec in foods) { string text = "vfp_" + foodSpec.Id.ToLowerInvariant(); dictionary[text] = foodSpec.German; dictionary2[text] = foodSpec.English; dictionary[text + "_desc"] = "Kräftiges Wikingergericht. Ergibt zwei Portionen."; dictionary2[text + "_desc"] = "A hearty Viking dish. Makes two portions."; } string text2 = "German"; val.AddTranslation(ref text2, dictionary); text2 = "English"; val.AddTranslation(ref text2, dictionary2); LocalizationManager.Instance.AddLocalization(val); } } }