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 Hourglass Timer v1.0.0
plugins/Hourglass.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 System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Hourglass.Audio; using Hourglass.Core; using Hourglass.Dev; using Hourglass.Gameplay; using Hourglass.Visual; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Audio; 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 Hourglass { public static class Cfg { public static ConfigEntry<string> StationWood; public static ConfigEntry<string> StationBronze; public static ConfigEntry<Readout> ReadoutWood; public static ConfigEntry<Readout> ReadoutBronze; public static ConfigEntry<float> Reach; public static ConfigEntry<bool> Chime; public static ConfigEntry<bool> TurnSound; public static ConfigEntry<float> Volume; 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; StationWood = c.Bind<string>("1 - Building", "StationWood", "piece_workbench", new ConfigDescription("Crafting station that has to be near to build the wooden glasses (prefab name, empty for none).", (AcceptableValueBase)null, new object[1] { val })); StationBronze = c.Bind<string>("1 - Building", "StationBronze", "forge", new ConfigDescription("Crafting station that has to be near to build the bronze glasses (prefab name, empty for none).", (AcceptableValueBase)null, new object[1] { val })); string[] array = new string[4] { "RecipeWood", "RecipeWoodWall", "RecipeBronze", "RecipeBronzeWall" }; string[] array2 = new string[4] { "the wooden hourglass", "the wooden wall hourglass", "the bronze hourglass", "the bronze wall hourglass" }; for (int i = 0; i < Variant.All.Length; i++) { Variant.All[i].Recipe = c.Bind<string>("1 - Building", array[i], Variant.All[i].DefaultRecipe, new ConfigDescription("Build cost of " + array2[i] + ", \"Item:amount,Item:amount\".", (AcceptableValueBase)null, new object[1] { val })); } ReadoutWood = c.Bind<Readout>("2 - Reading", "ReadoutWood", Readout.Glance, new ConfigDescription("What the hover text of a wooden glass says. Glance: no times, you judge the sand by eye. Rough: rounded times (\"about a minute\"). Exact: minutes and seconds.", (AcceptableValueBase)null, new object[1] { val })); ReadoutBronze = c.Bind<Readout>("2 - Reading", "ReadoutBronze", Readout.Exact, new ConfigDescription("What the hover text of a bronze glass says (Glance, Rough or Exact, see ReadoutWood).", (AcceptableValueBase)null, new object[1] { val })); Reach = c.Bind<float>("2 - Reading", "Reach", 4f, new ConfigDescription("A glass watches a station whose nearest side is at most this far away (m).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 12f), new object[1] { val })); TurnSound = c.Bind<bool>("3 - Client", "TurnSound", true, "Play a soft wooden clack when a glass turns over."); Chime = c.Bind<bool>("3 - Client", "Chime", true, "Ring a small bell when a station has finished the last piece of its load."); Volume = c.Bind<float>("3 - Client", "Volume", 0.8f, new ConfigDescription("Volume of the glass sounds (on top of the game's effect volume).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); } } public static class Lang { private static readonly (string key, string en, string de)[] Texts = new(string, string, string)[52] { ("hg_piece_hourglass_wood", "Hourglass", "Sanduhr"), ("hg_piece_hourglass_wood_desc", "A sandglass in a turned wooden cradle. Set it on or next to a smelter, kiln, oven, spit, fermenter, beehive or fire: the sand runs with the work in hand, and the glass turns itself over when a piece is done.", "Eine Sanduhr in einer gedrechselten Holzwiege. Stell sie auf oder neben Schmelzofen, Meiler, Ofen, Bratspieß, Gärbottich, Bienenstock oder Feuer: Der Sand rinnt mit der Arbeit, und das Glas dreht sich um, wenn ein Stück fertig ist."), ("hg_piece_hourglass_wood_wall", "Wall hourglass", "Wandsanduhr"), ("hg_piece_hourglass_wood_wall_desc", "A sandglass hung in a wooden bracket, for a wall or beam beside the work. It watches the nearest station and turns over when a piece is done.", "Eine Sanduhr in einer Holzhalterung, für Wand oder Balken neben der Arbeit. Sie beobachtet die nächste Station und dreht sich um, wenn ein Stück fertig ist."), ("hg_piece_hourglass_bronze", "Bronze hourglass", "Bronzene Sanduhr"), ("hg_piece_hourglass_bronze_desc", "A sandglass in a cast bronze cradle, with quarter marks on the posts. It watches the nearest station and turns over when a piece is done.", "Eine Sanduhr in einer gegossenen Bronzewiege, mit Viertelmarken an den Säulen. Sie beobachtet die nächste Station und dreht sich um, wenn ein Stück fertig ist."), ("hg_piece_hourglass_bronze_wall", "Bronze wall hourglass", "Bronzene Wandsanduhr"), ("hg_piece_hourglass_bronze_wall_desc", "A sandglass with quarter marks, hung in a bronze bracket for a wall or beam. It watches the nearest station and turns over when a piece is done.", "Eine Sanduhr mit Viertelmarken in einer Bronzehalterung, für Wand oder Balken. Sie beobachtet die nächste Station und dreht sich um, wenn ein Stück fertig ist."), ("hg_none", "No station within {0} m", "Keine Station im Umkreis von {0} m"), ("hg_next", "Watch another station ({0} in reach)", "Andere Station beobachten ({0} in Reichweite)"), ("hg_msg_watch", "The glass watches: {0}", "Die Sanduhr beobachtet: {0}"), ("hg_msg_only", "There is no other station in reach.", "Keine andere Station in Reichweite."), ("hg_runs", "the sand runs", "der Sand rinnt"), ("hg_waiting", "{0} more waiting", "danach noch {0}"), ("hg_idle", "run out – nothing to do", "abgelaufen – nichts zu tun"), ("hg_idle_fire", "run out – the fire is out", "abgelaufen – das Feuer ist aus"), ("hg_done", "done – ready to take", "fertig – kann entnommen werden"), ("hg_done_full", "full – ready to take", "voll – kann entnommen werden"), ("hg_stopped", "stands still – {0}", "steht still – {0}"), ("hg_burn", "done – burns {0}", "fertig – brennt {0} an"), ("hg_burn_glance", "done – take it out before it burns", "fertig – herausnehmen, bevor es anbrennt"), ("hg_left", "{0} left", "noch {0}"), ("hg_in", "in {0}", "in {0}"), ("hg_alldone_load", "{0} more, all done {1}", "{0} weitere, alles fertig {1}"), ("hg_alldone_fire", "fire out {1}", "Feuer erlischt {1}"), ("hg_alldone_full", "full {1}", "voll {1}"), ("hg_fuel_short", "{0} runs out {1}", "{0} ist {1} aufgebraucht"), ("hg_fuel", "fuel", "Brennstoff"), ("hg_ready", "{0} done", "{0} fertig"), ("hg_ready_burn", "{0} done, burns {1}", "{0} fertig, brennt {1} an"), ("hg_rough_moment_left", "a few seconds left", "noch wenige Sekunden"), ("hg_rough_moment_in", "in a few seconds", "in wenigen Sekunden"), ("hg_rough_underminute_left", "under a minute left", "noch keine Minute"), ("hg_rough_underminute_in", "in under a minute", "in weniger als einer Minute"), ("hg_rough_aboutminute_left", "about a minute left", "noch etwa eine Minute"), ("hg_rough_aboutminute_in", "in about a minute", "in etwa einer Minute"), ("hg_rough_minutes_left", "about {0} minutes left", "noch etwa {0} Minuten"), ("hg_rough_minutes_in", "in about {0} minutes", "in etwa {0} Minuten"), ("hg_rough_hour_left", "about an hour left", "noch etwa eine Stunde"), ("hg_rough_hour_in", "in about an hour", "in etwa einer Stunde"), ("hg_rough_hours_left", "about {0} hours left", "noch etwa {0} Stunden"), ("hg_rough_hours_in", "in about {0} hours", "in etwa {0} Stunden"), ("hg_stall_nofuel", "no fuel", "kein Brennstoff"), ("hg_stall_nowind", "no wind", "kein Wind"), ("hg_stall_noroof", "it needs a roof", "es braucht ein Dach"), ("hg_stall_smoke", "the smoke cannot get out", "der Rauch zieht nicht ab"), ("hg_stall_nofire", "no fire beneath", "kein Feuer darunter"), ("hg_stall_biome", "the bees do not like this land", "den Bienen gefällt die Gegend nicht"), ("hg_stall_crowded", "too much built around it", "zu eng zugebaut"), ("hg_stall_noroot", "no sap to draw", "kein Saft zu zapfen"), ("hg_stall_off", "put out", "gelöscht"), ("hg_stall_exposed", "too open, it starts over until it has walls around it", "zu offen, es beginnt von vorn, bis es Wände ringsum hat") }; 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 text = "English"; localization.AddTranslation(ref text, dictionary); text = "German"; localization.AddTranslation(ref text, 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 string Left(float seconds, Readout r) { return Span(seconds, r, "left"); } public static string In(float seconds, Readout r) { return Span(seconds, r, "in"); } private static string Span(float seconds, Readout r, string form) { if (float.IsInfinity(seconds) || float.IsNaN(seconds)) { return ""; } if (r == Readout.Exact) { return T("hg_" + form, TimeText.Clock(seconds)); } int count; switch (TimeText.Rough(seconds, out count)) { case RoughSpan.Moment: return T("hg_rough_moment_" + form); case RoughSpan.UnderMinute: return T("hg_rough_underminute_" + form); case RoughSpan.AboutMinute: return T("hg_rough_aboutminute_" + form); case RoughSpan.Minutes: return T("hg_rough_minutes_" + form, count); case RoughSpan.Hours: if (count != 1) { return T("hg_rough_hours_" + form, count); } return T("hg_rough_hour_" + form); default: return ""; } } } public static class Pieces { [HarmonyPatch(typeof(Game), "Start")] private static class ApplyOnWorldStart { private static void Postfix() { ApplyConfig(); } } private const string BasePrefab = "wood_beam"; private const string Category = "Crafting"; public static readonly Dictionary<string, Sprite> Icons = new Dictionary<string, Sprite>(); private static readonly Dictionary<Variant, GameObject> Registered = new Dictionary<Variant, GameObject>(); public static void Init() { PrefabManager.OnVanillaPrefabsAvailable += Add; SynchronizationManager.OnConfigurationSynchronized += delegate { ApplyConfig(); }; Cfg.StationWood.SettingChanged += delegate { ApplyConfig(); }; Cfg.StationBronze.SettingChanged += delegate { ApplyConfig(); }; Variant[] all = Variant.All; for (int num = 0; num < all.Length; num++) { all[num].Recipe.SettingChanged += delegate { ApplyConfig(); }; } } public static void ApplyConfig() { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items.Count == 0) { return; } foreach (KeyValuePair<Variant, GameObject> item in Registered) { Variant key = item.Key; try { Piece val = (((Object)(object)item.Value != (Object)null) ? item.Value.GetComponent<Piece>() : null); if ((Object)(object)val == (Object)null) { continue; } List<Requirement> list = new List<Requirement>(); foreach (RequirementConfig item2 in RecipeOf(key)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item2.Item); ItemDrop val2 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null) { HourglassPlugin.Log.LogWarning((object)(key.Prefab + " recipe: unknown item '" + item2.Item + "'.")); continue; } list.Add(new Requirement { m_resItem = val2, m_amount = item2.Amount, m_recover = true }); } if (list.Count > 0) { val.m_resources = list.ToArray(); } string text = (key.Station.Value ?? "").Trim(); if (text.Length == 0) { val.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 val3 = (CraftingStation)obj; if ((Object)(object)val3 != (Object)null) { val.m_craftingStation = val3; } else { HourglassPlugin.Log.LogWarning((object)(key.Prefab + ": unknown crafting station '" + text + "'.")); } } catch (Exception ex) { HourglassPlugin.Log.LogWarning((object)("Could not apply the recipe of " + key.Prefab + ": " + ex.Message)); } } if ((Object)(object)Player.m_localPlayer != (Object)null) { Player.m_localPlayer.UpdateAvailablePiecesList(); } } private static List<RequirementConfig> RecipeOf(Variant v) { List<RequirementConfig> list = ParseRecipe(v.Recipe.Value, v.Prefab); if (list.Count > 0) { return list; } HourglassPlugin.Log.LogWarning((object)("No valid entry in the recipe of " + v.Prefab + "; using the default.")); return ParseRecipe(v.DefaultRecipe, v.Prefab); } private static void Add() { try { Mats.Init(); Variant[] all = Variant.All; for (int i = 0; i < all.Length; i++) { AddOne(all[i]); } } catch (Exception ex) { HourglassPlugin.Log.LogError((object)("Could not register the hourglasses: " + ex)); } finally { PrefabManager.OnVanillaPrefabsAvailable -= Add; } } private static void AddOne(Variant v) { //IL_0022: 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_003d: 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_0063: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown GameObject val = HourglassModel.Create(v); Icons[v.Prefab] = RenderIcon(val, 128); PieceConfig val2 = new PieceConfig { Name = "$" + v.Token, Description = "$" + v.Token + "_desc", PieceTable = "Hammer", Category = "Crafting", CraftingStation = (v.Station.Value ?? "").Trim(), Icon = Icons[v.Prefab] }; foreach (RequirementConfig item in RecipeOf(v)) { val2.AddRequirement(item); } CustomPiece val3 = new CustomPiece(v.Prefab, "wood_beam", val2); if ((Object)(object)val3.PiecePrefab == (Object)null) { HourglassPlugin.Log.LogError((object)("Cloning wood_beam failed; no " + v.Prefab + ".")); Object.Destroy((Object)(object)val); return; } Reskin(val3.PiecePrefab, val, v); if (string.IsNullOrWhiteSpace(v.Station.Value)) { val3.Piece.m_craftingStation = null; } PieceManager.Instance.AddPiece(val3); Registered[v] = val3.PiecePrefab; } private static void Reskin(GameObject prefab, GameObject visual, Variant v) { //IL_0063: 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_009a: 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_00aa: 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) 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]); } visual.transform.SetParent(transform, false); visual.transform.localPosition = Vector3.zero; visual.transform.localRotation = Quaternion.identity; SetLayer(visual, prefab.layer); foreach (Bounds item in HourglassModel.Colliders(v)) { Bounds current = item; BoxCollider obj = prefab.AddComponent<BoxCollider>(); obj.center = ((Bounds)(ref current)).center; obj.size = ((Bounds)(ref current)).size; } WearNTear component = prefab.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_new = visual; component.m_worn = visual; component.m_broken = visual; component.m_health = 120f; component.m_noRoofWear = true; component.m_noSupportWear = false; component.m_supports = false; 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; } prefab.AddComponent<HourglassPiece>().VariantPrefab = v.Prefab; } 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(GameObject visual, int px) { //IL_0018: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown if (GUIManager.IsHeadless()) { return null; } GameObject val = null; try { val = Object.Instantiate<GameObject>(visual); val.transform.position = Vector3.zero; val.transform.rotation = Quaternion.identity; val.GetComponent<SandglassVisual>()?.SetProgress(0.35f, running: true); return RenderManager.Instance.Render(new RenderRequest(val) { Rotation = Quaternion.Euler(14f, 0f, 0f) * Quaternion.Euler(0f, 200f, 0f), Width = px, Height = px, ParticleSimulationTime = -1f, UseCache = false }); } catch (Exception ex) { HourglassPlugin.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; } HourglassPlugin.Log.LogWarning((object)("Ignoring invalid recipe entry '" + text + "' for " + what + ".")); } return list; } } [BepInPlugin("zap.hourglass", "Hourglass", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class HourglassPlugin : BaseUnityPlugin { public const string PluginGuid = "zap.hourglass"; public const string PluginName = "Hourglass"; public const string PluginVersion = "1.0.0"; private Harmony _harmony; public static HourglassPlugin 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("zap.hourglass"); _harmony.PatchAll(typeof(HourglassPlugin).Assembly); SelfTest.TryStart(((Component)this).gameObject); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace Hourglass.Visual { internal static class HourglassModel { public const float Scale = 1.7f; private static readonly float Sweep = Mathf.Sqrt(0.028506251f); private const float FootH = 0.022f; private const float SideX = 0.097f; public static readonly float[] Marks = new float[3] { 0.75f, 0.5f, 0.25f }; private static float PivotY => 0.022f + Sweep + 0.012f; private static float BoardZ => Sweep + 0.022f; public static Vector3 GlassCenter => new Vector3(0f, PivotY * 1.7f, 0f); public static GameObject Create(Variant v) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00e9: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown Mats.Init(); GameObject val = new GameObject("Hourglass_" + v.Prefab); Transform val2 = MeshKit.Child(val.transform, "Body"); val2.localScale = Vector3.one * 1.7f; PartSet partSet = new PartSet(); if (v.Wall) { BuildBracket(partSet, v.Frame); } else { BuildCradle(partSet, v.Frame); } partSet.Emit(val2, "Mount"); Transform val3 = MeshKit.Child(val2, "Flip", new Vector3(0f, PivotY, 0f), Quaternion.identity); BuildGlass(partSet, v.Frame); partSet.Emit(val3, "Glass"); MeshFilter topU = SandPart(val3, "SandTop", Quaternion.identity); MeshFilter topL = SandPart(val3, "SandTopLower", Quaternion.Euler(180f, 0f, 0f)); MeshFilter pile = SandPart(val3, "SandPile", Quaternion.identity); MeshBuilder meshBuilder = new MeshBuilder(); MeshKit.Cylinder(meshBuilder, Vector3.zero, Vector3.down, 0.0009f, 6, caps: false); Transform transform = ((Component)MeshKit.Part(val3, "Stream", meshBuilder.ToMesh("Hourglass_SandStream"), Mats.Sand, shadows: false)).transform; transform.localPosition = new Vector3(0f, -0.0015f, 0f); val.AddComponent<SandglassVisual>().Setup(val3, topU, topL, pile, transform, 0f); return val; } public static List<Bounds> Colliders(Variant v) { //IL_00c1: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_003f: 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_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_007e: 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_0098: 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 = 1.7f; float num2 = PivotY + 0.155f; List<Bounds> list = new List<Bounds>(); if (v.Wall) { list.Add(new Bounds(new Vector3(0f, PivotY, BoardZ + 0.011f) * num, new Vector3(0.25f, 0.44f, 0.022f) * num)); list.Add(new Bounds(new Vector3(0f, PivotY, BoardZ * 0.5f) * num, new Vector3(0.214f, 0.31f, BoardZ) * num)); } else { list.Add(new Bounds(new Vector3(0f, num2 * 0.5f, 0f) * num, new Vector3(0.234f, num2, 0.14f) * num)); } return list; } private static Material FrameMat(Frame f) { if (f != Frame.Bronze) { return Mats.Wood; } return Mats.Bronze; } private static Material TrimMat(Frame f) { if (f != Frame.Bronze) { return Mats.DarkWood; } return Mats.Bronze; } private static Material PinMat(Frame f) { if (f != Frame.Bronze) { return Mats.Iron; } return Mats.Bronze; } private static void BuildGlass(PartSet s, Frame frame) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0064: 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_008e: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00f7: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_01ba: 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_01e4: 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_020e: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) List<Vector2> prof = new List<Vector2> { new Vector2(0f, -0.15f), new Vector2(0.068f, -0.15f), new Vector2(0.068f, -0.15f), new Vector2(0.073f, -0.1485f), new Vector2(0.075f, -0.145f), new Vector2(0.075f, -0.14f), new Vector2(0.0725f, -0.1385f), new Vector2(0.0725f, -0.1375f), new Vector2(0.0738f, -0.136f), new Vector2(0.0738f, -0.132f), new Vector2(0.0712f, -0.1292f), new Vector2(0.066f, -0.128f), new Vector2(0.066f, -0.128f), new Vector2(0f, -0.128f) }; List<Vector2> prof2 = new List<Vector2> { new Vector2(0f, -0.128f), new Vector2(0.0105f, -0.128f), new Vector2(0.0105f, -0.1215f), new Vector2(0.0088f, -0.1185f), new Vector2(0.0068f, -0.113f), new Vector2(0.0074f, -0.108f), new Vector2(0.009f, -0.1045f), new Vector2(0.0074f, -0.1005f), new Vector2(0.0064f, -0.096f), new Vector2(0.0058f, -0.065f), new Vector2(0.0055f, -0.032f), new Vector2(0.006f, -0.015f), new Vector2(0.0072f, -0.008f), new Vector2(0.0088f, -0.0035f), new Vector2(0.009f, -0.0012f), new Vector2(0.009f, 0f) }; List<Vector2> list = new List<Vector2> { new Vector2(0f, -0.126f), new Vector2(SandShape.OuterR(0.126f) * 0.8f, -0.126f) }; for (int i = 0; i <= 22; i++) { float num = 0.126f * (1f - (float)i / 22f); list.Add(new Vector2(SandShape.OuterR(num), 0f - num)); } List<Vector2> list2 = new List<Vector2>(); for (int num2 = 22; num2 >= 0; num2--) { float num3 = 0.124400005f * (1f - (float)num2 / 22f); list2.Add(new Vector2(SandShape.InnerR(num3), 0f - num3)); } list2.Add(new Vector2(SandShape.InnerR(0.124400005f) * 0.8f, -0.124400005f)); list2.Add(new Vector2(0f, -0.124400005f)); Material mat = FrameMat(frame); Material mat2 = TrimMat(frame); for (int j = 0; j < 2; j++) { s.Push(Vector3.zero, (j == 0) ? Quaternion.identity : Quaternion.Euler(180f, 0f, 0f)); MeshKit.Lathe(s[mat], prof, 40, MeshKit.Tiles(0.075f, 2f), 2f); MeshKit.Torus(s[mat2], new Vector3(0f, -0.125f, 0f), Quaternion.identity, SandShape.OuterR(0.126f) + 0.0024f, 0.0032f, 28, 8, 3f); for (int k = 0; k < 4; k++) { float num4 = (45f + (float)k * 90f) * ((float)Math.PI / 180f); s.Push(new Vector3(Mathf.Cos(num4) * 0.062f, 0f, Mathf.Sin(num4) * 0.062f), Quaternion.identity); MeshKit.Lathe(s[mat], prof2, 14, 1f, 3f, null, swapUV: true); if (frame == Frame.Bronze) { float[] marks = Marks; foreach (float num5 in marks) { float num6 = SandShape.LevelForFill(num5); MeshKit.Torus(s[Mats.Bronze], new Vector3(0f, 0f - num6, 0f), Quaternion.identity, 0.007f, (num5 == 0.5f) ? 0.0028f : 0.0019f, 12, 6); } } s.Pop(); } MeshKit.Lathe(s[Mats.Glass], list2, 32); MeshKit.Lathe(s[Mats.Glass], list, 32); s.Pop(); } MeshKit.Torus(s[mat], Vector3.zero, Quaternion.identity, 0.062f, 0.0042f, 40, 8, 4f); MeshKit.Torus(s[mat2], Vector3.zero, Quaternion.identity, 0.0071f, 0.0027f, 18, 8, 4f); for (int m = -1; m <= 1; m += 2) { MeshKit.Sphere(s[mat], new Vector3((float)m * 0.062f, 0f, 0f), 0.0085f, 10, 6); } } private static void BuildCradle(PartSet s, Frame frame) { //IL_002e: 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_0070: 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_0089: 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_00bd: 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_00e7: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) Material mat = FrameMat(frame); Material m = PinMat(frame); float pivotY = PivotY; MeshKit.Box(s[Mats.DarkWood], new Vector3(0f, 0.0077f, 0f), new Vector3(0.244f, 0.0154f, 0.13f), Quaternion.identity, 6f); MeshKit.Box(s[Mats.DarkWood], new Vector3(0f, 0.0187f, 0f), new Vector3(0.23f, 0.0066000004f, 0.116f), Quaternion.identity, 6f); List<Vector2> prof = new List<Vector2> { new Vector2(0f, 0.022f), new Vector2(0.016f, 0.022f), new Vector2(0.016f, 0.031999998f), new Vector2(0.012f, 0.038000003f), new Vector2(0.0095f, 0.052f), new Vector2(0.0085f, pivotY - 0.06f), new Vector2(0.01f, pivotY - 0.04f), new Vector2(0.0125f, pivotY - 0.012f), new Vector2(0.0125f, pivotY + 0.012f), new Vector2(0.01f, pivotY + 0.022f), new Vector2(0.006f, pivotY + 0.03f), new Vector2(0.0075f, pivotY + 0.036f), new Vector2(0f, pivotY + 0.046f) }; for (int i = -1; i <= 1; i += 2) { s.Push(new Vector3((float)i * 0.097f, 0f, 0f), Quaternion.identity); MeshKit.Lathe(s[mat], prof, 16, 1f, 3f, null, swapUV: true); s.Pop(); Pin(s, m, i); } } private static void BuildBracket(PartSet s, Frame frame) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_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_00b6: 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_00fe: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) Material mat = FrameMat(frame); Material m = PinMat(frame); float pivotY = PivotY; float boardZ = BoardZ; MeshKit.Box(s[Mats.DarkWood], new Vector3(0f, pivotY, boardZ + 0.011f), new Vector3(0.25f, 0.44f, 0.022f), Quaternion.identity, 6f); MeshKit.Box(s[mat], new Vector3(0f, pivotY + 0.185f, boardZ - 0.006f), new Vector3(0.27f, 0.035f, 0.014f), Quaternion.identity, 6f); MeshKit.Box(s[mat], new Vector3(0f, pivotY - 0.185f, boardZ - 0.006f), new Vector3(0.27f, 0.035f, 0.014f), Quaternion.identity, 6f); for (int i = -1; i <= 1; i += 2) { MeshKit.Box(s[mat], new Vector3((float)i * 0.097f, pivotY, boardZ * 0.5f), new Vector3(0.02f, 0.026f, boardZ), Quaternion.identity, 6f); MeshKit.Cylinder(s[mat], new Vector3((float)i * 0.0855f, pivotY, 0f), new Vector3((float)i * 0.108500004f, pivotY, 0f), 0.017f, 18); Pin(s, m, i); float[] array = new float[2] { pivotY + 0.185f, pivotY - 0.185f }; foreach (float num in array) { MeshKit.Sphere(s[Mats.Iron], new Vector3((float)i * 0.105f, num, boardZ - 0.014f), 0.006f, 8, 5); } } } private static void Pin(PartSet s, Material m, int side) { //IL_001b: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) float pivotY = PivotY; MeshKit.Cylinder(s[m], new Vector3((float)side * 0.066f, pivotY, 0f), new Vector3((float)side * 0.11f, pivotY, 0f), 0.0035f, 10); MeshKit.Cylinder(s[m], new Vector3((float)side * 0.109000005f, pivotY, 0f), new Vector3((float)side * 0.11400001f, pivotY, 0f), 0.0065f, 12); } private static MeshFilter SandPart(Transform flip, string name, Quaternion rot) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) MeshRenderer obj = MeshKit.Part(flip, name, null, Mats.Sand); ((Component)obj).transform.localRotation = rot; ((Renderer)obj).enabled = false; return ((Component)obj).GetComponent<MeshFilter>(); } } internal static class Mats { public static Material Wood; public static Material DarkWood; public static Material Bronze; public static Material Iron; public static Material Glass; public static Material Sand; private static bool _vanilla; private static Texture2D _sandTex; private static readonly int ValueNoise = Shader.PropertyToID("_ValueNoise"); private static readonly int MoveableObject = Shader.PropertyToID("_MoveableObject"); private static readonly int Glossiness = Shader.PropertyToID("_Glossiness"); private static readonly int Metallic = Shader.PropertyToID("_Metallic"); private static readonly int MainTex = Shader.PropertyToID("_MainTex"); private static readonly int BumpScale = Shader.PropertyToID("_BumpScale"); private static readonly Color SandColor = new Color(0.68f, 0.48f, 0.25f); private static readonly Color GlassColor = new Color(0.8f, 0.9f, 0.92f, 0.08f); public static void Init() { //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: 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_0331: 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_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0396: 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_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (_vanilla) { return; } try { Material val = FindMat("Cart", "cart_wood") ?? CacheMat("cart_wood"); Material val2 = FindMat("BronzeNails", "bronzenails") ?? CacheMat("bronzenails"); Material val3 = FindMat("iron_grate", "metalwall") ?? FindMat("IronNails", "ironnails"); if ((Object)(object)val != (Object)null) { Adopt(ref Wood, val, "Wood"); Adopt(ref DarkWood, val, "DarkWood"); Tint(DarkWood, new Color(0.5f, 0.4f, 0.32f)); } if ((Object)(object)val2 != (Object)null) { Adopt(ref Bronze, val2, "Bronze"); Tint(Bronze, new Color(0.78f, 0.6f, 0.45f)); SetF(Bronze, Metallic, 0.85f); SetF(Bronze, Glossiness, 0.42f); } if ((Object)(object)val3 != (Object)null) { Adopt(ref Iron, val3, "Iron"); } Material val4 = FindMat("crystal_wall_1x1", "crystal_window"); if ((Object)(object)val4 != (Object)null) { Adopt(ref Glass, val4, "Glass"); Glass.color = GlassColor; if (Glass.HasProperty(MainTex)) { Glass.SetTexture(MainTex, (Texture)null); } SetF(Glass, BumpScale, 0.15f); SetF(Glass, Glossiness, 0.6f); SetF(Glass, Metallic, 0f); } if ((Object)(object)val != (Object)null) { Adopt(ref Sand, val, "Sand"); Sand.color = SandColor; Sand.SetTexture(MainTex, (Texture)(object)SandTexture()); Sand.SetTextureScale(MainTex, Vector2.one); SetF(Sand, BumpScale, 0f); SetF(Sand, Glossiness, 0.06f); SetF(Sand, Metallic, 0f); } _vanilla = (Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null; } catch (Exception ex) { ManualLogSource log = HourglassPlugin.Log; if (log != null) { log.LogWarning((object)("Building materials failed: " + ex.Message)); } } if ((Object)(object)Wood == (Object)null) { Wood = Fallback("Wood", new Color(0.52f, 0.36f, 0.21f), 0f, 0.2f); } if ((Object)(object)DarkWood == (Object)null) { DarkWood = Fallback("DarkWood", new Color(0.28f, 0.18f, 0.11f), 0f, 0.2f); } if ((Object)(object)Bronze == (Object)null) { Bronze = Fallback("Bronze", new Color(0.78f, 0.52f, 0.28f), 1f, 0.6f); } if ((Object)(object)Iron == (Object)null) { Iron = Fallback("Iron", new Color(0.2f, 0.2f, 0.21f), 0.8f, 0.4f); } if ((Object)(object)Glass == (Object)null) { Glass = Fallback("Glass", GlassColor, 0f, 0.9f); } if ((Object)(object)Sand == (Object)null) { Sand = Fallback("Sand", SandColor, 0f, 0.06f); } } 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) { 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 CacheMat(string name) { try { return Cache.GetPrefab<Material>(name); } catch (Exception) { return null; } } private static void Adopt(ref Material slot, Material src, string name) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown if ((Object)(object)slot == (Object)null) { slot = new Material(src); } else { slot.shader = src.shader; slot.CopyPropertiesFromMaterial(src); slot.shaderKeywords = src.shaderKeywords; slot.renderQueue = src.renderQueue; } ((Object)slot).name = "Hourglass_" + name; ((Object)slot).hideFlags = (HideFlags)32; if (slot.HasProperty(ValueNoise)) { slot.SetFloat(ValueNoise, 0f); } if (slot.HasProperty(MoveableObject)) { slot.SetFloat(MoveableObject, 1f); } } private static Material Fallback(string name, Color c, float metallic, float gloss) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0057: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0064: Expected O, but got Unknown Material val = new Material(Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse") ?? Shader.Find("Sprites/Default")) { name = "Hourglass_" + name, hideFlags = (HideFlags)32, color = c }; SetF(val, Metallic, metallic); SetF(val, Glossiness, gloss); return val; } private static void Tint(Material m, Color tint) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0032: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m == (Object)null) && m.HasProperty("_Color")) { Color color = m.color; m.color = new Color(color.r * tint.r, color.g * tint.g, color.b * tint.b, color.a); } } private static void SetF(Material m, int id, float v) { if ((Object)(object)m != (Object)null && m.HasProperty(id)) { m.SetFloat(id, v); } } private static Texture2D SandTexture() { //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_0029: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_00e7: 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) if ((Object)(object)_sandTex != (Object)null) { return _sandTex; } Texture2D val = new Texture2D(64, 64, (TextureFormat)4, true) { name = "Hourglass_SandGrain", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1, hideFlags = (HideFlags)32 }; Random random = new Random(1852); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < array.Length; i++) { double num = random.NextDouble(); float num2 = 0.86f + 0.14f * (float)random.NextDouble(); if (num < 0.06) { num2 *= 0.72f; } else if (num > 0.97) { num2 = 1f; } byte b = (byte)(num2 * 255f); byte b2 = (byte)(Mathf.Min(1f, num2 * 1.02f) * 255f); array[i] = new Color32(b2, b, (byte)(num2 * 0.97f * 255f), byte.MaxValue); } val.SetPixels32(array); val.Apply(true, false); _sandTex = val; 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_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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("Hourglass_", "") : "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)(!((Object)(object)val == (Object)(object)Mats.Glass)); ((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 referenc