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 FeedingTroughs v1.0.0
plugins/FeedingTroughs.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FeedingTroughs.Core; using FeedingTroughs.Dev; using FeedingTroughs.Gameplay; using FeedingTroughs.Visual; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [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 FeedingTroughs { public enum GroundFood { Never, WhenFollowing, Always } public static class Cfg { public sealed class PerTier { public ConfigEntry<int> Capacity; public ConfigEntry<float> Reach; } public static readonly PerTier[] Tiers = new PerTier[3]; public static ConfigEntry<string> Station; public static ConfigEntry<GroundFood> GroundFeeding; public static ConfigEntry<bool> WildEatFromTroughs; public static ConfigEntry<bool> ShowFoodInTrough; private static readonly string[] HerdSections = new string[8] { "Hens", "Boars", "Wolves", "Bears", "Asksvin", "Lox", "Moose", "Dragons" }; public static PerTier For(Tier t) { return Tiers[(int)t]; } public static void Bind(ConfigFile c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; Station = c.Bind<string>("01 - General", "Station", "piece_workbench", new ConfigDescription("Crafting station that has to be near to build the feeding stations (prefab name, empty for none).", (AcceptableValueBase)null, new object[1] { val })); GroundFeeding = c.Bind<GroundFood>("01 - General", "TameAnimalsEatFromGround", GroundFood.Always, new ConfigDescription("Where tame animals still eat food lying on the ground. Always: like vanilla, as well as at their filled feeding stations. WhenFollowing: only companions that follow you, animals at home eat at their stations only. Never: only at their feeding stations. Wild animals are always tamed with food on the ground.", (AcceptableValueBase)null, new object[1] { val })); WildEatFromTroughs = c.Bind<bool>("01 - General", "WildAnimalsEatFromStations", false, new ConfigDescription("Wild animals being tamed also eat at feeding stations. Off: taming needs food thrown on the ground, stations are for your herd.", (AcceptableValueBase)null, new object[1] { val })); Tiers[0] = BindTier(c, "Small", "the bowls (lox, moose and dragons: the tubs)", 20, 12f, val); Tiers[1] = BindTier(c, "Medium", "the large bowls (lox, moose and dragons: the troughs)", 40, 16f, val); Tiers[2] = BindTier(c, "Large", "troughs, silos and mangers", 80, 22f, val); for (int i = 0; i < Herd.All.Length; i++) { Herd herd = Herd.All[i]; string text = (i + 3).ToString("00") + " - " + HerdSections[i]; herd.Animals = c.Bind<string>(text, "Animals", herd.DefaultAnimals, new ConfigDescription("Prefab names of the animals that eat at these stations, comma separated, '*' as wildcard. Herds are checked in the order of this file; animals of no herd eat at any station that holds food they like.", (AcceptableValueBase)null, new object[1] { val })); herd.Animals.SettingChanged += delegate { Diet.Invalidate(); }; herd.Portions = c.Bind<int>(text, "PortionsPerMeal", herd.DefaultPortions, new ConfigDescription("Food items one meal takes.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), new object[1] { val })); Tier[] array = new Tier[3] { Tier.Small, Tier.Medium, Tier.Large }; for (int num = 0; num < array.Length; num++) { Tier tier = array[num]; herd.Recipes[(int)tier] = c.Bind<string>(text, "Recipe" + tier, herd.DefaultRecipes[(int)tier], new ConfigDescription("Build cost of the " + tier.ToString().ToLowerInvariant() + " station, \"Item:amount,Item:amount\".", (AcceptableValueBase)null, new object[1] { val })); } } ShowFoodInTrough = c.Bind<bool>("11 - Client", "ShowFoodInStation", true, "Show the stored food lying in the station (off: only the straw bed rises and falls)."); } private static PerTier BindTier(ConfigFile c, string tier, string what, int capacity, float reach, ConfigurationManagerAttributes admin) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown PerTier perTier = new PerTier(); perTier.Capacity = c.Bind<int>("02 - Sizes", tier + "Capacity", capacity, new ConfigDescription("How many food items fit in " + what + ".", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), new object[1] { admin })); perTier.Reach = c.Bind<float>("02 - Sizes", tier + "Reach", reach, new ConfigDescription("Hungry animals within this distance (m) come to eat at " + what + ".", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 60f), new object[1] { admin })); return perTier; } } public static class Lang { private static readonly (string herd, string en, string de, string stationsEn, string stationsDe, string[] namesEn, string[] namesDe)[] Herds = new(string, string, string, string, string, string[], string[])[8] { ("hen", "hens", "Hühner", "hen stations", "Hühner-Futterstellen", new string[3] { "Hen Bowl", "Large Hen Bowl", "Grain Silo" }, new string[3] { "Hühnernapf", "Großer Hühnernapf", "Körnersilo" }), ("boar", "boars", "Eber", "boar stations", "Eber-Futterstellen", new string[3] { "Boar Bowl", "Large Boar Bowl", "Boar Feed Silo" }, new string[3] { "Ebernapf", "Großer Ebernapf", "Eber-Futtersilo" }), ("wolf", "wolves and Wolfborn", "Wölfe und Wolfborn", "wolf stations", "Wolfs-Futterstellen", new string[3] { "Wolf Bowl", "Large Wolf Bowl", "Wolf Trough" }, new string[3] { "Wolfsnapf", "Großer Wolfsnapf", "Wolfstrog" }), ("bear", "bears", "Bären", "bear stations", "Bären-Futterstellen", new string[3] { "Bear Bowl", "Large Bear Bowl", "Bear Trough" }, new string[3] { "Bärennapf", "Großer Bärennapf", "Bärentrog" }), ("asksvin", "asksvin", "Asksvin", "asksvin stations", "Asksvin-Futterstellen", new string[3] { "Asksvin Bowl", "Large Asksvin Bowl", "Asksvin Trough" }, new string[3] { "Asksvin-Napf", "Großer Asksvin-Napf", "Asksvin-Trog" }), ("lox", "lox", "Lox", "lox stations", "Lox-Futterstellen", new string[3] { "Lox Tub", "Lox Trough", "Lox Manger" }, new string[3] { "Lox-Zuber", "Lox-Trog", "Lox-Krippe" }), ("moose", "moose", "Elche", "moose stations", "Elch-Futterstellen", new string[3] { "Moose Tub", "Moose Trough", "Moose Manger" }, new string[3] { "Elch-Zuber", "Elchtrog", "Elchkrippe" }), ("dragon", "dragons", "Drachen", "dragon stations", "Drachen-Futterstellen", new string[3] { "Dragon Tub", "Dragon Trough", "Great Dragon Trough" }, new string[3] { "Drachenzuber", "Drachentrog", "Großer Drachentrog" }) }; private static readonly (string en, string de)[] TierText = new(string, string)[3] { ("Fill it, and hungry tame animals nearby come to eat.", "Liegt Futter darin, kommen hungrige zahme Tiere aus der Nähe zum Fressen."), ("Holds more than the small one, and animals come from further away.", "Fasst mehr als die kleine Futterstelle, und die Tiere kommen von weiter her."), ("Holds the most, and animals come from furthest away.", "Fasst am meisten, und die Tiere kommen aus der größten Entfernung.") }; private static readonly (string key, string en, string de)[] Texts = new(string, string, string)[17] { ("jotunn_cat_feeding", "Feeding", "Fütterung"), ("ft_for", "for {0}", "für {0}"), ("ft_eats_at", "eats at {0}", "frisst an {0}"), ("ft_empty", "Empty", "Leer"), ("ft_stock", "Food {0}/{1}", "Futter {0}/{1}"), ("ft_portions", "{0} per meal", "{0} pro Mahlzeit"), ("ft_nearby", "Nearby", "In der Nähe"), ("ft_hungry", "{0} hungry", "{0} hungrig"), ("ft_fed", "fed", "satt"), ("ft_nothing_for", "nothing they eat", "nichts, was sie fressen"), ("ft_fill", "Fill with fodder", "Futter einfüllen"), ("ft_fill_all", "also cooked food", "auch Gekochtes"), ("ft_msg_added", "Put in: {0} ({1}/{2})", "Eingefüllt: {0} ({1}/{2})"), ("ft_msg_full", "The {0} is full.", "{0}: voll."), ("ft_msg_nofodder", "You only carry cooked food for this – it goes in with {0}.", "Du trägst dafür nur Gekochtes – das füllst du mit {0} ein."), ("ft_msg_nofood", "You carry nothing {0} eat.", "Du trägst nichts, was {0} fressen."), ("ft_msg_wrongfood", "No animal that eats here likes {0}.", "Kein Tier, das hier frisst, mag {0}.") }; private static (string en, string de) StyleText(Style style, bool tub) { switch (style) { case Style.Bowl: if (!tub) { return (en: "A small staved bowl for {0}.", de: "Ein kleiner Napf aus Dauben für {0}."); } return (en: "A staved wooden tub for {0}.", de: "Ein Holzzuber aus Dauben für {0}."); case Style.WideBowl: return (en: "A wide bowl with iron handles for {0}.", de: "Ein breiter Napf mit Eisengriffen für {0}."); case Style.Trough: return (en: "A plank trough on trestles for {0}.", de: "Ein Bohlentrog auf Böcken für {0}."); case Style.Silo: return (en: "A feed silo for {0}: the feed trickles out into the tray at its foot.", de: "Ein Futtersilo für {0}: Das Futter rieselt unten in die Schale nach."); case Style.Manger: return (en: "A heavy double-sided manger with a hay rack for {0}.", de: "Eine schwere, beidseitige Krippe mit Heuraufe für {0}."); default: return (en: "A heavy iron-bound meat trough for {0}.", de: "Ein schwerer, eisenbeschlagener Fleischtrog für {0}."); } } public static void Register() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); Dictionary<string, string> dictionary = new Dictionary<string, string>(); Dictionary<string, string> dictionary2 = new Dictionary<string, string>(); (string, string, string)[] texts = Texts; for (int i = 0; i < texts.Length; i++) { (string, string, string) tuple = texts[i]; string item = tuple.Item1; string item2 = tuple.Item2; string item3 = tuple.Item3; dictionary[item] = item2; dictionary2[item] = item3; } (string, string, string, string, string, string[], string[])[] herds = Herds; for (int i = 0; i < herds.Length; i++) { (string, string, string, string, string, string[], string[]) tuple2 = herds[i]; Herd herd = Herd.Get(tuple2.Item1); dictionary["ft_herd_" + tuple2.Item1] = tuple2.Item2; dictionary2["ft_herd_" + tuple2.Item1] = tuple2.Item3; dictionary["ft_stations_" + tuple2.Item1] = tuple2.Item4; dictionary2["ft_stations_" + tuple2.Item1] = tuple2.Item5; for (int j = 0; j < 3; j++) { string text = herd.Token((Tier)j); dictionary[text] = tuple2.Item6[j]; dictionary2[text] = tuple2.Item7[j]; (string, string) tuple3 = StyleText(herd.StyleOf((Tier)j), tuple2.Item6[j].EndsWith("Tub")); dictionary[text + "_desc"] = string.Format(tuple3.Item1, tuple2.Item2) + " " + TierText[j].en; dictionary2[text + "_desc"] = string.Format(tuple3.Item2, tuple2.Item3) + " " + TierText[j].de; } } string text2 = "English"; localization.AddTranslation(ref text2, dictionary); text2 = "German"; localization.AddTranslation(ref text2, dictionary2); } public static string T(string token, params object[] args) { string text = ((Localization.instance != null) ? Localization.instance.Localize("$" + token) : token); if (args == null || args.Length == 0) { return text; } try { return string.Format(text, args); } catch (FormatException) { return text; } } public static string L(string token) { if (Localization.instance == null) { return token; } return Localization.instance.Localize(token); } } public static class Pieces { [HarmonyPatch(typeof(Game), "Start")] private static class ApplyOnWorldStart { private static void Postfix() { ApplyConfig(); } } private const string BasePrefab = "wood_beam"; public const string Category = "Feeding"; public static readonly Tier[] Tiers = new Tier[3] { Tier.Small, Tier.Medium, Tier.Large }; public static readonly Dictionary<string, Sprite> Icons = new Dictionary<string, Sprite>(); private static readonly List<(GameObject prefab, Herd herd, Tier tier)> Registered = new List<(GameObject, Herd, Tier)>(); public static void Init() { PrefabManager.OnVanillaPrefabsAvailable += Add; SynchronizationManager.OnConfigurationSynchronized += delegate { ApplyConfig(); Diet.Invalidate(); }; Cfg.Station.SettingChanged += delegate { ApplyConfig(); }; Herd[] all = Herd.All; for (int num = 0; num < all.Length; num++) { ConfigEntry<string>[] recipes = all[num].Recipes; for (int num2 = 0; num2 < recipes.Length; num2++) { recipes[num2].SettingChanged += delegate { ApplyConfig(); }; } } } public static void ApplyConfig() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items.Count == 0) { return; } foreach (var (val, herd, tier) in Registered) { try { Piece val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Piece>() : null); if ((Object)(object)val2 == (Object)null) { continue; } List<Requirement> list = new List<Requirement>(); foreach (RequirementConfig item in RecipeOf(herd, tier)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item.Item); ItemDrop val3 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val3 == (Object)null) { FeedingTroughsPlugin.Log.LogWarning((object)(((Object)val).name + " recipe: unknown item '" + item.Item + "'.")); continue; } list.Add(new Requirement { m_resItem = val3, m_amount = item.Amount, m_recover = true }); } if (list.Count > 0) { val2.m_resources = list.ToArray(); } string text = (Cfg.Station.Value ?? "").Trim(); if (text.Length == 0) { val2.m_craftingStation = null; continue; } object obj; if (!((Object)(object)ZNetScene.instance != (Object)null)) { obj = null; } else { GameObject prefab = ZNetScene.instance.GetPrefab(text); obj = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null); } CraftingStation val4 = (CraftingStation)obj; if ((Object)(object)val4 != (Object)null) { val2.m_craftingStation = val4; } else { FeedingTroughsPlugin.Log.LogWarning((object)(((Object)val).name + ": unknown crafting station '" + text + "'.")); } } catch (Exception ex) { FeedingTroughsPlugin.Log.LogWarning((object)("Could not apply the recipe of " + ((val != null) ? ((Object)val).name : null) + ": " + ex.Message)); } } if ((Object)(object)Player.m_localPlayer != (Object)null) { Player.m_localPlayer.UpdateAvailablePiecesList(); } } private static List<RequirementConfig> RecipeOf(Herd herd, Tier tier) { string text = herd.Token(tier); List<RequirementConfig> list = ParseRecipe(herd.Recipes[(int)tier].Value, text); if (list.Count > 0) { return list; } FeedingTroughsPlugin.Log.LogWarning((object)("No valid entry in the recipe of " + text + "; using the default.")); return ParseRecipe(herd.DefaultRecipes[(int)tier], text); } private static void Add() { try { Mats.Init(); Effects.Init(); Herd[] all = Herd.All; foreach (Herd herd in all) { Tier[] tiers = Tiers; foreach (Tier tier in tiers) { AddOne(herd, tier); } } } catch (Exception ex) { FeedingTroughsPlugin.Log.LogError((object)("Could not register the feeding stations: " + ex)); } finally { PrefabManager.OnVanillaPrefabsAvailable -= Add; } } internal static TroughModel Model(Herd herd, Tier tier) { return TroughModel.Create(herd.StyleOf(tier), herd.Scales[(int)tier], herd.Dark); } private static void AddOne(Herd herd, Tier tier) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown string text = herd.Token(tier); TroughModel troughModel = Model(herd, tier); Icons[herd.Prefab(tier)] = RenderIcon(troughModel, herd, 128); PieceConfig val = new PieceConfig { Name = "$" + text, Description = "$" + text + "_desc", PieceTable = "Hammer", Category = "Feeding", CraftingStation = (Cfg.Station.Value ?? "").Trim(), Icon = Icons[herd.Prefab(tier)] }; foreach (RequirementConfig item in RecipeOf(herd, tier)) { val.AddRequirement(item); } CustomPiece val2 = new CustomPiece(herd.Prefab(tier), "wood_beam", val); if ((Object)(object)val2.PiecePrefab == (Object)null) { FeedingTroughsPlugin.Log.LogError((object)("Cloning wood_beam failed; no " + text + ".")); Object.Destroy((Object)(object)((Component)troughModel).gameObject); return; } Reskin(val2.PiecePrefab, troughModel, herd, tier); if (string.IsNullOrWhiteSpace(Cfg.Station.Value)) { val2.Piece.m_craftingStation = null; } PieceManager.Instance.AddPiece(val2); Registered.Add((val2.PiecePrefab, herd, tier)); } private static void Reskin(GameObject prefab, TroughModel visual, Herd herd, Tier tier) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Transform transform = prefab.transform; for (int num = transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)transform.GetChild(num)).gameObject); } Collider[] components = prefab.GetComponents<Collider>(); for (int i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } ((Component)visual).transform.SetParent(transform, false); ((Component)visual).transform.localPosition = Vector3.zero; ((Component)visual).transform.localRotation = Quaternion.identity; SetLayer(((Component)visual).gameObject, prefab.layer); TroughShape troughShape = herd.Shape(tier); Bounds[] colliders = troughShape.Colliders; for (int i = 0; i < colliders.Length; i++) { Bounds val = colliders[i]; BoxCollider obj = prefab.AddComponent<BoxCollider>(); obj.center = ((Bounds)(ref val)).center; obj.size = ((Bounds)(ref val)).size; } WearNTear component = prefab.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_new = ((Component)visual).gameObject; component.m_worn = ((Component)visual).gameObject; component.m_broken = ((Component)visual).gameObject; component.m_health = troughShape.Health; component.m_noRoofWear = true; component.m_fragmentRoots = null; } Piece component2 = prefab.GetComponent<Piece>(); if ((Object)(object)component2 != (Object)null) { component2.m_groundOnly = false; component2.m_noInWater = true; component2.m_allowedInDungeons = false; } FeedingStation feedingStation = prefab.AddComponent<FeedingStation>(); feedingStation.HerdId = herd.Id; feedingStation.Tier = tier; } private static void SetLayer(GameObject go, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) go.layer = layer; foreach (Transform item in go.transform) { SetLayer(((Component)item).gameObject, layer); } } internal static Sprite RenderIcon(TroughModel visual, Herd herd, int px) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown if (GUIManager.IsHeadless()) { return null; } GameObject val = null; try { val = Object.Instantiate<GameObject>(((Component)visual).gameObject); val.transform.position = Vector3.zero; val.transform.rotation = Quaternion.identity; val.transform.localScale = Vector3.one; TroughModel component = val.GetComponent<TroughModel>(); component.Bind(); List<Larder.Entry> list = new List<Larder.Entry>(); string[] iconFood = herd.IconFood; foreach (string item in iconFood) { list.Add(new Larder.Entry(item, 5)); } component.ShowFill(0.7f, list); return RenderManager.Instance.Render(new RenderRequest(val) { Rotation = Quaternion.Euler(28f, 0f, 0f) * Quaternion.Euler(0f, 150f, 0f), Width = px, Height = px, ParticleSimulationTime = -1f, UseCache = false }); } catch (Exception ex) { FeedingTroughsPlugin.Log.LogWarning((object)("Icon rendering failed: " + ex.Message)); return null; } finally { if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } } public static List<RequirementConfig> ParseRecipe(string recipe, string what) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown List<RequirementConfig> list = new List<RequirementConfig>(); if (string.IsNullOrWhiteSpace(recipe)) { return list; } string[] array = recipe.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { string[] array2 = text.Split(new char[1] { ':' }); if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result) && result > 0 && array2[0].Trim().Length > 0) { list.Add(new RequirementConfig(array2[0].Trim(), result, 0, true)); continue; } FeedingTroughsPlugin.Log.LogWarning((object)("Ignoring invalid recipe entry '" + text + "' for " + what + ".")); } return list; } } [BepInPlugin("jan.feedingtroughs", "FeedingTroughs", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class FeedingTroughsPlugin : BaseUnityPlugin { public const string PluginGuid = "jan.feedingtroughs"; public const string PluginName = "FeedingTroughs"; public const string PluginVersion = "1.0.0"; private Harmony _harmony; public static FeedingTroughsPlugin Instance { get; private set; } public static string PluginDir { get; private set; } public static ManualLogSource Log { get; private set; } public static string AssetPath(string fileName) { return Path.Combine(PluginDir ?? "", "Assets", fileName); } private void Awake() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Cfg.Bind(((BaseUnityPlugin)this).Config); Lang.Register(); Pieces.Init(); _harmony = new Harmony("jan.feedingtroughs"); _harmony.PatchAll(typeof(FeedingTroughsPlugin).Assembly); SelfTest.TryStart(((Component)this).gameObject); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace FeedingTroughs.Visual { internal static class ItemLook { private static readonly Dictionary<string, GameObject> Templates = new Dictionary<string, GameObject>(); private static readonly Dictionary<string, float> Misses = new Dictionary<string, float>(); private static Transform _holder; public static GameObject Template(string item) { if (Templates.TryGetValue(item, out var value) && (Object)(object)value != (Object)null) { return value; } if (Misses.TryGetValue(item, out var value2) && Time.realtimeSinceStartup < value2) { return null; } value = Build(item); if ((Object)(object)value != (Object)null) { Templates[item] = value; Misses.Remove(item); } else { Misses[item] = Time.realtimeSinceStartup + 10f; } return value; } private static GameObject Build(string item) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00b5: 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) //IL_00dc: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(item) : null); if ((Object)(object)val == (Object)null) { val = PrefabManager.Instance.GetPrefab(item); } if ((Object)(object)val == (Object)null) { return null; } Transform val2 = val.transform.Find("attach"); Transform val3 = (((Object)(object)val2 != (Object)null) ? val2 : val.transform); if ((Object)(object)_holder == (Object)null) { GameObject val4 = new GameObject("FeedingTroughs_ItemLooks"); val4.SetActive(false); Object.DontDestroyOnLoad((Object)val4); _holder = val4.transform; } GameObject val5 = new GameObject("look_" + item); val5.transform.SetParent(_holder, false); Transform transform = new GameObject("pivot").transform; transform.SetParent(val5.transform, false); Matrix4x4 worldToLocalMatrix = val3.worldToLocalMatrix; bool flag = false; Bounds val6 = default(Bounds); MeshRenderer[] componentsInChildren = ((Component)val3).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val7 in componentsInChildren) { if (!((Renderer)val7).enabled || !ActiveUpTo(((Component)val7).transform, val3)) { continue; } MeshFilter component = ((Component)val7).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { continue; } Matrix4x4 val8 = worldToLocalMatrix * ((Component)val7).transform.localToWorldMatrix; GameObject val9 = new GameObject(((Object)((Component)val7).gameObject).name); val9.transform.SetParent(transform, false); val9.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val8)).GetColumn(3)); val9.transform.localRotation = ((Matrix4x4)(ref val8)).rotation; val9.transform.localScale = ((Matrix4x4)(ref val8)).lossyScale; val9.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh; MeshRenderer obj = val9.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterials = ((Renderer)val7).sharedMaterials; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)obj).receiveShadows = true; Bounds bounds = component.sharedMesh.bounds; for (int j = 0; j < 8; j++) { Vector3 val10 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1)))); Vector3 val11 = ((Matrix4x4)(ref val8)).MultiplyPoint3x4(val10); if (!flag) { ((Bounds)(ref val6))..ctor(val11, Vector3.zero); flag = true; } else { ((Bounds)(ref val6)).Encapsulate(val11); } } } if (!flag) { Object.Destroy((Object)(object)val5); return null; } float num = Mathf.Max(((Bounds)(ref val6)).size.x, Mathf.Max(((Bounds)(ref val6)).size.y, ((Bounds)(ref val6)).size.z)); float num2 = ((num > 0.0001f) ? (1f / num) : 1f); transform.localScale = Vector3.one * num2; transform.localPosition = new Vector3(0f - ((Bounds)(ref val6)).center.x, 0f - ((Bounds)(ref val6)).min.y, 0f - ((Bounds)(ref val6)).center.z) * num2; return val5; } private static bool ActiveUpTo(Transform t, Transform top) { while ((Object)(object)t != (Object)null) { if (!((Component)t).gameObject.activeSelf) { return false; } if ((Object)(object)t == (Object)(object)top) { return true; } t = t.parent; } return true; } } internal static class Mats { public static Material Wood; public static Material DarkWood; public static Material Iron; public static Material Straw; public static Material Hay; public static Material Thatch; private static bool _vanilla; private static readonly int Metallic = Shader.PropertyToID("_Metallic"); private static readonly int Glossiness = Shader.PropertyToID("_Glossiness"); public static void Init() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) if (_vanilla) { return; } Material val = FindMat("wood_beam", "woodwall"); Material val2 = FindMat("iron_grate", "metalwall"); Material val3 = FindMat("wood_roof", "straw_roof"); Material val4 = FindMat("darkwood_beam", "DarkWood_mat"); Wood = val ?? Wood ?? Std("Wood", new Color(0.55f, 0.4f, 0.26f), 0f, 0.1f); DarkWood = val4 ?? DarkWood ?? Std("DarkWood", new Color(0.3f, 0.22f, 0.16f), 0f, 0.1f); Iron = val2 ?? Iron ?? Std("Iron", new Color(0.32f, 0.32f, 0.33f), 0.8f, 0.4f); Thatch = val3 ?? Thatch ?? Std("Thatch", new Color(0.66f, 0.56f, 0.36f), 0f, 0.05f); if ((Object)(object)val3 != (Object)null) { if ((Object)(object)Straw == (Object)null || ((Object)Straw).name != "Troughs_Straw_v") { Straw = new Material(val3) { name = "Troughs_Straw_v", hideFlags = (HideFlags)32 }; } Straw.color = val3.color * new Color(0.78f, 0.68f, 0.5f, 1f); if ((Object)(object)Hay == (Object)null || ((Object)Hay).name != "Troughs_Hay_v") { Hay = new Material(val3) { name = "Troughs_Hay_v", hideFlags = (HideFlags)32 }; } Hay.color = val3.color * new Color(0.95f, 0.9f, 0.62f, 1f); } else if ((Object)(object)Straw == (Object)null) { Straw = Std("Straw", new Color(0.7f, 0.58f, 0.32f), 0f, 0.05f); } if ((Object)(object)Hay == (Object)null) { Hay = Straw; } _vanilla = (Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null; } private static Material FindMat(string prefabName, string matName) { GameObject val = null; try { val = PrefabManager.Instance.GetPrefab(prefabName); } catch (Exception) { } if ((Object)(object)val == (Object)null) { return null; } Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null || val2 is ParticleSystemRenderer) { continue; } Material[] sharedMaterials = val2.sharedMaterials; foreach (Material val3 in sharedMaterials) { if (!((Object)(object)val3 == (Object)null) && (((Object)val3).name == matName || ((Object)val3).name.StartsWith(matName + " ", StringComparison.Ordinal))) { return val3; } } } return null; } private static Material Std(string name, Color c, float metallic, float gloss) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown Material val = new Material(Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse")) { name = "Troughs_" + name, hideFlags = (HideFlags)32, color = c }; if (val.HasProperty(Metallic)) { val.SetFloat(Metallic, metallic); } if (val.HasProperty(Glossiness)) { val.SetFloat(Glossiness, gloss); } return val; } } internal sealed class MeshBuilder { public readonly List<Vector3> Vertices = new List<Vector3>(256); public readonly List<Vector3> Normals = new List<Vector3>(256); public readonly List<Vector2> UVs = new List<Vector2>(256); public readonly List<int> Triangles = new List<int>(512); private readonly Stack<Matrix4x4> _stack = new Stack<Matrix4x4>(); private Matrix4x4 _base = Matrix4x4.identity; private Matrix4x4 _local = Matrix4x4.identity; private Matrix4x4 _m = Matrix4x4.identity; private Matrix4x4 _n = Matrix4x4.identity; private bool _flip; public bool IsEmpty => Triangles.Count == 0; public void SetBase(Matrix4x4 m) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!(m == _base)) { _base = m; Recalc(); } } public void Push(Matrix4x4 m) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) _stack.Push(_local); _local *= m; Recalc(); } public void Push(Vector3 pos, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Push(Matrix4x4.TRS(pos, rot, Vector3.one)); } public void Pop() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) _local = ((_stack.Count > 0) ? _stack.Pop() : Matrix4x4.identity); Recalc(); } private void Recalc() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) _m = _base * _local; Matrix4x4 inverse = ((Matrix4x4)(ref _m)).inverse; _n = ((Matrix4x4)(ref inverse)).transpose; _flip = ((Matrix4x4)(ref _m)).determinant < 0f; } public int Add(Vector3 p, Vector3 n, Vector2 uv) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Vertices.Add(((Matrix4x4)(ref _m)).MultiplyPoint3x4(p)); Vector3 val = ((Matrix4x4)(ref _n)).MultiplyVector(n); float magnitude = ((Vector3)(ref val)).magnitude; Normals.Add((magnitude > 1E-08f) ? (val / magnitude) : Vector3.up); UVs.Add(uv); return Vertices.Count - 1; } public void Tri(int a, int b, int c) { Triangles.Add(a); if (_flip) { Triangles.Add(c); Triangles.Add(b); } else { Triangles.Add(b); Triangles.Add(c); } } public void Quad(int a, int b, int c, int d) { Tri(a, b, c); Tri(a, c, d); } public Mesh ToMesh(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown Mesh val = new Mesh { name = name }; if (Vertices.Count > 65000) { val.indexFormat = (IndexFormat)1; } val.SetVertices(Vertices); val.SetNormals(Normals); val.SetUVs(0, UVs); val.SetTriangles(Triangles, 0, true); val.RecalculateTangents(); return val; } public void Clear() { Vertices.Clear(); Normals.Clear(); UVs.Clear(); Triangles.Clear(); } } internal sealed class PartSet { private readonly List<Material> _mats = new List<Material>(); private readonly List<MeshBuilder> _builders = new List<MeshBuilder>(); private readonly Stack<Matrix4x4> _stack = new Stack<Matrix4x4>(); private Matrix4x4 _current = Matrix4x4.identity; public MeshBuilder this[Material mat] { get { //IL_0059: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = null; for (int i = 0; i < _mats.Count; i++) { if (_mats[i] == mat) { meshBuilder = _builders[i]; break; } } if (meshBuilder == null) { meshBuilder = new MeshBuilder(); _mats.Add(mat); _builders.Add(meshBuilder); } meshBuilder.SetBase(_current); return meshBuilder; } } public void Push(Matrix4x4 m) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) _stack.Push(_current); _current *= m; } public void Push(Vector3 pos, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Push(Matrix4x4.TRS(pos, rot, Vector3.one)); } public void Push(Vector3 pos, Quaternion rot, Vector3 scale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) Push(Matrix4x4.TRS(pos, rot, scale)); } public void Pop() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) _current = ((_stack.Count > 0) ? _stack.Pop() : Matrix4x4.identity); } public void Emit(Transform parent, string name) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown for (int i = 0; i < _builders.Count; i++) { MeshBuilder meshBuilder = _builders[i]; Material val = _mats[i]; if (!meshBuilder.IsEmpty) { string text = (((Object)(object)val != (Object)null) ? ((Object)val).name.Replace("Troughs_", "") : "Mat"); GameObject val2 = new GameObject(name + "_" + text); val2.transform.SetParent(parent, false); val2.AddComponent<MeshFilter>().sharedMesh = meshBuilder.ToMesh(((Object)val2).name); MeshRenderer obj = val2.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = val; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)obj).receiveShadows = true; } } _mats.Clear(); _builders.Clear(); _stack.Clear(); _current = Matrix4x4.identity; } } internal static class MeshKit { private const float Tau = (float)Math.PI * 2f; public static Quaternion AlongX => Quaternion.Euler(0f, 0f, -90f); public static Quaternion AlongZ => Quaternion.Euler(90f, 0f, 0f); public static void ProfileNormals(IList<Vector2> p, Vector2[] result) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) int count = p.Count; for (int i = 0; i < count; i++) { Vector2 val = Vector2.zero; Vector2 val4; if (i > 0) { Vector2 val2 = p[i] - p[i - 1]; if (((Vector2)(ref val2)).sqrMagnitude > 1E-12f) { Vector2 val3 = val; val4 = new Vector2(val2.y, 0f - val2.x); val = val3 + ((Vector2)(ref val4)).normalized; } } if (i < count - 1) { Vector2 val5 = p[i + 1] - p[i]; if (((Vector2)(ref val5)).sqrMagnitude > 1E-12f) { Vector2 val6 = val; val4 = new Vector2(val5.y, 0f - val5.x); val = val6 + ((Vector2)(ref val4)).normalized; } } result[i] = (Vector2)((((Vector2)(ref val)).sqrMagnitude > 1E-12f) ? ((Vector2)(ref val)).normalized : new Vector2(1f, 0f)); } } public static void Lathe(MeshBuilder mb, IList<Vector2> prof, int seg, float uTiles = 1f, float vPerMeter = 1f, IList<Vector2> normals = null, bool swapUV = false) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) int count = prof.Count; if (count < 2 || seg < 3) { return; } Vector2[] array = (Vector2[])(object)new Vector2[count]; if (normals != null) { for (int i = 0; i < count; i++) { array[i] = normals[i]; } } else { ProfileNormals(prof, array); } float[] array2 = new float[count]; for (int j = 1; j < count; j++) { array2[j] = array2[j - 1] + Vector2.Distance(prof[j], prof[j - 1]); } int num = seg + 1; int num2 = -1; Vector2 val = default(Vector2); for (int k = 0; k < count; k++) { for (int l = 0; l <= seg; l++) { float num3 = (float)l * ((float)Math.PI * 2f / (float)seg); float num4 = Mathf.Cos(num3); float num5 = Mathf.Sin(num3); ((Vector2)(ref val))..ctor((float)l / (float)seg * uTiles, array2[k] * vPerMeter); if (swapUV) { ((Vector2)(ref val))..ctor(val.y, val.x); } int num6 = mb.Add(new Vector3(prof[k].x * num4, prof[k].y, prof[k].x * num5), new Vector3(array[k].x * num4, array[k].y, array[k].x * num5), val); if (num2 < 0) { num2 = num6; } } } for (int m = 0; m < count - 1; m++) { Vector2 val2 = prof[m + 1] - prof[m]; if (!(((Vector2)(ref val2)).sqrMagnitude < 1E-12f) && (!(prof[m].x <= 0f) || !(prof[m + 1].x <= 0f))) { for (int n = 0; n < seg; n++) { int num7 = num2 + m * num + n; int d = num7 + 1; int num8 = num7 + num; int c = num8 + 1; mb.Quad(num7, num8, c, d); } } } } public static void LatheX(MeshBuilder mb, Vector3 origin, IList<Vector2> prof, int seg, float uTiles = 1f, float vPerMeter = 1f, bool swapUV = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) mb.Push(origin, AlongX); Lathe(mb, prof, seg, uTiles, vPerMeter, null, swapUV); mb.Pop(); } public static void LatheZ(MeshBuilder mb, Vector3 origin, IList<Vector2> prof, int seg, float uTiles = 1f, float vPerMeter = 1f, bool swapUV = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) mb.Push(origin, AlongZ); Lathe(mb, prof, seg, uTiles, vPerMeter, null, swapUV); mb.Pop(); } public static float Tiles(float radius, float perMeter) { return Mathf.Max(1f, Mathf.Round((float)Math.PI * 2f * radius * perMeter)); } public static void Arc(List<Vector2> list, Vector2 center, float radius, float fromDeg, float toDeg, int steps) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i <= steps; i++) { float num = Mathf.Lerp(fromDeg, toDeg, (float)i / (float)steps) * ((float)Math.PI / 180f); list.Add(center + new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * radius); } } public static void Cylinder(MeshBuilder mb, Vector3 a, Vector3 b, float ra, float rb, int seg, bool capA = true, bool capB = true, float uTiles = 1f, float vPerMeter = 1f, bool swapUV = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 1E-06f)) { List<Vector2> list = new List<Vector2>(6); if (capA) { list.Add(new Vector2(0f, 0f)); list.Add(new Vector2(ra, 0f)); } list.Add(new Vector2(ra, 0f)); list.Add(new Vector2(rb, magnitude)); if (capB) { list.Add(new Vector2(rb, magnitude)); list.Add(new Vector2(0f, magnitude)); } mb.Push(a, Quaternion.FromToRotation(Vector3.up, val / magnitude)); Lathe(mb, list, seg, uTiles, vPerMeter, null, swapUV); mb.Pop(); } } public static void Cylinder(MeshBuilder mb, Vector3 a, Vector3 b, float r, int seg, bool caps = true, float uTiles = 1f, float vPerMeter = 1f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Cylinder(mb, a, b, r, r, seg, caps, caps, uTiles, vPerMeter); } public static void Sphere(MeshBuilder mb, Vector3 c, float r, int seg = 12, int rings = 8) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Ellipsoid(mb, c, new Vector3(r, r, r), Quaternion.identity, seg, rings); } public static void Ellipsoid(MeshBuilder mb, Vector3 c, Vector3 radii, Quaternion rot, int seg = 12, int rings = 8) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) Vector2[] array = (Vector2[])(object)new Vector2[rings + 1]; Vector2[] array2 = (Vector2[])(object)new Vector2[rings + 1]; for (int i = 0; i <= rings; i++) { float num = (float)i / (float)rings * (float)Math.PI; array2[i] = new Vector2(Mathf.Sin(num), 0f - Mathf.Cos(num)); array[i] = array2[i]; } mb.Push(Matrix4x4.TRS(c, rot, radii)); Lathe(mb, array, seg, 1f, 0.5f, array2); mb.Pop(); } public static void Torus(MeshBuilder mb, Vector3 c, Quaternion rot, float majorR, float minorR, int seg, int tubeSeg, float uTiles = 1f, float vPerMeter = 1f) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0073: Unknown result type (might be due to invalid IL or missing references) Vector2[] array = (Vector2[])(object)new Vector2[tubeSeg + 1]; Vector2[] array2 = (Vector2[])(object)new Vector2[tubeSeg + 1]; for (int i = 0; i <= tubeSeg; i++) { float num = -(float)Math.PI + (float)i * ((float)Math.PI * 2f) / (float)tubeSeg; array2[i] = new Vector2(Mathf.Cos(num), Mathf.Sin(num)); array[i] = new Vector2(majorR, 0f) + array2[i] * minorR; } mb.Push(c, rot); Lathe(mb, array, seg, uTiles, vPerMeter, array2); mb.Pop(); } public static void Box(MeshBuilder mb, Vector3 center, Vector3 size, Quaternion rot, float uvPerMeter = 2f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) mb.Push(center, rot); Vector3 val = size * 0.5f; int num = ((!(size.x >= size.y) || !(size.x >= size.z)) ? ((size.y >= size.z) ? 1 : 2) : 0); for (int i = 0; i < 3; i++) { for (int j = -1; j <= 1; j += 2) { int num2 = (i + 1) % 3; int num3 = (i + 2) % 3; if (num3 == num) { int num4 = num2; num2 = num3; num3 = num4; } Vector3 val2 = Axis(i) * (float)j; Vector3 val3 = val2 * ((Vector3)(ref val))[i]; Vector3 val4 = Axis(num2) * ((Vector3)(ref val))[num2]; Vector3 val5 = Axis(num3) * ((Vector3)(ref val))[num3]; float num5 = ((Vector3)(ref val))[num2] * uvPerMeter; float num6 = ((Vector3)(ref val))[num3] * uvPerMeter; FlatQuad(mb, val3 - val4 - val5, val3 - val4 + val5, val3 + val4 + val5, val3 + val4 - val5, val2, new Vector2(0f - num5, 0f - num6), new Vector2(0f - num5, num6), new Vector2(num5, num6), new Vector2(num5, 0f - num6)); } } mb.Pop(); } private static Vector3 Axis(int k) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(k switch { 1 => Vector3.up, 0 => Vector3.right, _ => Vector3.forward, }); } public static void Disc(MeshBuilder mb, Vector3 c, float r, int seg, float uvRadius = 0.5f, float uvRotDeg = 0f) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Cos(uvRotDeg * ((float)Math.PI / 180f)); float num2 = Mathf.Sin(uvRotDeg * ((float)Math.PI / 180f)); int a = mb.Add(c, Vector3.up, new Vector2(0.5f, 0.5f)); int num3 = -1; Vector2 uv = default(Vector2); for (int i = 0; i <= seg; i++) { float num4 = (float)i * ((float)Math.PI * 2f) / (float)seg; float num5 = Mathf.Cos(num4); float num6 = Mathf.Sin(num4); ((Vector2)(ref uv))..ctor(0.5f + uvRadius * (num5 * num - num6 * num2), 0.5f + uvRadius * (num5 * num2 + num6 * num)); int num7 = mb.Add(c + new Vector3(num5 * r, 0f, num6 * r), Vector3.up, uv); if (num3 < 0) { num3 = num7; } } for (int j = 0; j < seg; j++) { mb.Tri(a, num3 + j + 1, num3 + j); } } public static void Sector(MeshBuilder mb, float rIn, float rOut, float phi0Deg, float phi1Deg, float thickness, int seg, float uvPerMeter) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: 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) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) float num = thickness * 0.5f; float num2 = phi0Deg * ((float)Math.PI / 180f); float num3 = phi1Deg * ((float)Math.PI / 180f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0f, num); Vector3 val4 = default(Vector3); for (int i = 0; i < seg; i++) { float num4 = Mathf.Lerp(num2, num3, (float)i / (float)seg); float num5 = Mathf.Lerp(num2, num3, (float)(i + 1) / (float)seg); Vector3 val2 = SectorDir(num4); Vector3 val3 = SectorDir(num5); for (int j = -1; j <= 1; j += 2) { ((Vector3)(ref val4))..ctor(0f, 0f, (float)j); Vector3 val5 = val * (float)j; Vector3 val6 = val2 * rOut + val5; Vector3 val7 = val3 * rOut + val5; if (rIn <= 1E-05f) { TriN(mb, val5, val6, val7, val4, val4, val4, PlanarXY(val5, uvPerMeter), PlanarXY(val6, uvPerMeter), PlanarXY(val7, uvPerMeter), val4); continue; } Vector3 val8 = val2 * rIn + val5; Vector3 val9 = val3 * rIn + val5; FlatQuad(mb, val8, val6, val7, val9, val4, PlanarXY(val8, uvPerMeter), PlanarXY(val6, uvPerMeter), PlanarXY(val7, uvPerMeter), PlanarXY(val9, uvPerMeter)); } float num6 = num * uvPerMeter; float num7 = num4 * rOut * uvPerMeter; float num8 = num5 * rOut * uvPerMeter; QuadN(mb, val2 * rOut - val, val2 * rOut + val, val3 * rOut + val, val3 * rOut - val, val2, val2, val3, val3, new Vector2(num7, 0f - num6), new Vector2(num7, num6), new Vector2(num8, num6), new Vector2(num8, 0f - num6), val2 + val3); if (rIn > 1E-05f) { float num9 = num4 * rIn * uvPerMeter; float num10 = num5 * rIn * uvPerMeter; QuadN(mb, val2 * rIn - val, val2 * rIn + val, val3 * rIn + val, val3 * rIn - val, -val2, -val2, -val3, -val3, new Vector2(num9, 0f - num6), new Vector2(num9, num6), new Vector2(num10, num6), new Vector2(num10, 0f - num6), -(val2 + val3)); } } for (int k = 0; k < 2; k++) { float num11 = ((k == 0) ? num2 : num3); Vector3 val10 = SectorDir(num11); Vector3 n = new Vector3(Mathf.Cos(num11), Mathf.Sin(num11), 0f) * ((k == 0) ? (-1f) : 1f); float num12 = rIn * uvPerMeter; float num13 = rOut * uvPerMeter; float num14 = num * uvPerMeter; FlatQuad(mb, val10 * rIn - val, val10 * rOut - val, val10 * rOut + val, val10 * rIn + val, n, new Vector2(num12, 0f - num14), new Vector2(num13, 0f - num14), new Vector2(num13, num14), new Vector2(num12, num14)); } } public static Vector3 SectorDir(float phiRad) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Mathf.Sin(phiRad), 0f - Mathf.Cos(phiRad), 0f); } private static Vector2 PlanarXY(Vector3 p, float s) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return new Vector2(p.x * s, p.y * s); } public static void ExtrudeXZ(MeshBuilder mb, IList<Vector2> poly, float y0, float y1, float uvPerMeter = 20f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00c6: 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) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) int count = poly.Count; Vector2 val = Vector2.zero; for (int i = 0; i < count; i++) { val += poly[i]; } val /= (float)count; Vector3 p = default(Vector3); Vector3 p2 = default(Vector3); Vector3 p3 = default(Vector3); for (int j = 0; j < 2; j++) { float num = ((j == 0) ? y1 : y0); Vector3 val2 = ((j == 0) ? Vector3.up : Vector3.down); ((Vector3)(ref p))..ctor(val.x, num, val.y); for (int k = 0; k < count; k++) { Vector2 val3 = poly[k]; Vector2 val4 = poly[(k + 1) % count]; ((Vector3)(ref p2))..ctor(val3.x, num, val3.y); ((Vector3)(ref p3))..ctor(val4.x, num, val4.y); TriN(mb, p, p2, p3, val2, val2, val2, val * uvPerMeter, val3 * uvPerMeter, val4 * uvPerMeter, val2); } } Vector3 n = default(Vector3); for (int l = 0; l < count; l++) { Vector2 val5 = poly[l]; Vector2 val6 = poly[(l + 1) % count]; Vector2 val7 = val6 - val5; Vector2 val8 = new Vector2(val7.y, 0f - val7.x); Vector2 val9 = ((Vector2)(ref val8)).normalized; if (Vector2.Dot(val9, (val5 + val6) * 0.5f - val) < 0f) { val9 = -val9; } ((Vector3)(ref n))..ctor(val9.x, 0f, val9.y); float num2 = ((Vector2)(ref val7)).magnitude * uvPerMeter; float num3 = (y1 - y0) * uvPerMeter; FlatQuad(mb, new Vector3(val5.x, y0, val5.y), new Vector3(val5.x, y1, val5.y), new Vector3(val6.x, y1, val6.y), new Vector3(val6.x, y0, val6.y), n, new Vector2(0f, 0f), new Vector2(0f, num3), new Vector2(num2, num3), new Vector2(num2, 0f)); } } public static void HelicalFin(MeshBuilder mb, float z0, float z1, float rIn, float rOut0, float rOut1, float angle0Deg, float twistDeg, float thickness, int steps, float uvPerMeter = 10f) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due