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 Frmr v1.0.5
plugins/Frmr/DarklightCreations.Frmr.dll
Decompiled 2 hours 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.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DarklightCreations.Frmr")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DarklightCreations.Frmr")] [assembly: AssemblyTitle("DarklightCreations.Frmr")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Fred.FieldArtillery { [BepInPlugin("com.darklightcreations.farmer", "Frmr", "1.0.4")] public sealed class FarmerPlugin : BaseUnityPlugin { internal const string Id = "com.darklightcreations.farmer"; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_005e: Expected O, but got Unknown FolderHost modHost = new FolderHost(((BaseUnityPlugin)this).Logger, Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location)); Harmony val = new Harmony("com.darklightcreations.farmer"); CarriageControls.Apply("com.darklightcreations.farmer"); SurtlingTools.Apply("com.darklightcreations.farmer", modHost); FarmWagons.Apply("com.darklightcreations.farmer", modHost, ((BaseUnityPlugin)this).Config); EarlyFishing.Apply(val, modHost); FishingSchools.Apply(val, ((BaseUnityPlugin)this).Config); } } internal static class ArtMaterials { private static readonly Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>(); public static void Apply(IModHost host, params Transform[] parts) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown for (int i = 0; i < parts.Length; i++) { Material[] sharedMaterials = ((Renderer)((Component)parts[i]).GetComponent<MeshRenderer>()).sharedMaterials; foreach (Material val in sharedMaterials) { string name = ((Object)val).name; int num2; object obj; if (!name.EndsWith("_pine", StringComparison.Ordinal) && !name.EndsWith("_oak", StringComparison.Ordinal)) { num2 = (name.EndsWith("_ash", StringComparison.Ordinal) ? 1 : 0); if (num2 == 0) { obj = "surface-grit"; goto IL_0069; } } else { num2 = 1; } obj = "wood-grain"; goto IL_0069; IL_0069: string text = (string)obj; if (!Textures.TryGetValue(text, out var value)) { value = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(value, host.ReadAsset("textures/" + text + ".png"), true)) { throw new FormatException("Cannot load " + text + " texture."); } ((Object)value).name = text; ((Texture)value).wrapMode = (TextureWrapMode)0; ((Texture)value).filterMode = (FilterMode)2; Textures.Add(text, value); } val.mainTexture = (Texture)(object)value; if (num2 != 0 || name.EndsWith("_hemp", StringComparison.Ordinal) || name.EndsWith("_flint", StringComparison.Ordinal)) { if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.14f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.14f); } if (val.HasProperty("_MetallicGlossMap")) { val.SetTexture("_MetallicGlossMap", (Texture)null); } val.DisableKeyword("_METALLICGLOSSMAP"); } } } } } internal interface IModHost { ManualLogSource Log { get; } byte[] ReadAsset(string path); bool HasAsset(string path); void AddPrefabs(ZNetScene scene, IEnumerable<GameObject> prefabs); } internal sealed class FolderHost(ManualLogSource log, string directory) : IModHost { private static readonly FieldRef<ZNetScene, Dictionary<int, GameObject>> KnownPrefabs = AccessTools.FieldRefAccess<ZNetScene, Dictionary<int, GameObject>>("m_namedPrefabs"); public ManualLogSource Log => log; public byte[] ReadAsset(string path) { return File.ReadAllBytes(Path.Combine(directory, path)); } public bool HasAsset(string path) { return File.Exists(Path.Combine(directory, path)); } public void AddPrefabs(ZNetScene scene, IEnumerable<GameObject> prefabs) { foreach (GameObject prefab in prefabs) { if (!((Object)(object)prefab == (Object)null)) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); scene.m_prefabs.RemoveAll((GameObject existing) => (Object)(object)existing != (Object)(object)prefab && (Object)(object)existing != (Object)null && ((Object)existing).name == ((Object)prefab).name); if (!scene.m_prefabs.Contains(prefab)) { scene.m_prefabs.Add(prefab); } if ((Object)(object)scene == (Object)(object)ZNetScene.instance) { KnownPrefabs.Invoke(scene)[stableHashCode] = prefab; } } } } } internal static class Files { internal sealed class Model { public Mesh mesh; public string[] slots; } private static readonly Dictionary<string, Model> Models = new Dictionary<string, Model>(); private static readonly Dictionary<string, Sprite> Icons = new Dictionary<string, Sprite>(); private static readonly Dictionary<string, AudioClip> Audio = new Dictionary<string, AudioClip>(); internal static Model Mesh(IModHost host, string name) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_0179: Expected O, but got Unknown if (Models.TryGetValue(name, out var value)) { return value; } using BinaryReader binaryReader = new BinaryReader(new MemoryStream(host.ReadAsset("meshes/" + name + ".bfm"))); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "BFM5") { throw new InvalidDataException("Unrecognized mesh format for " + name + "."); } string[] array = new string[binaryReader.ReadInt32()]; List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int[]> list4 = new List<int[]>(array.Length); for (int i = 0; i < array.Length; i++) { array[i] = Encoding.UTF8.GetString(binaryReader.ReadBytes(binaryReader.ReadInt32())); int num = binaryReader.ReadInt32(); int count = list.Count; for (int j = 0; j < num; j++) { list.Add(ReadVector(binaryReader)); list2.Add(ReadVector(binaryReader)); list3.Add(new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle())); } int[] array2 = new int[binaryReader.ReadInt32()]; for (int k = 0; k < array2.Length; k++) { array2[k] = count + binaryReader.ReadInt32(); } list4.Add(array2); } Mesh val = new Mesh { name = "gunnr_" + name, indexFormat = (IndexFormat)(list.Count > 65535) }; val.SetVertices(list); val.SetNormals(list2); val.SetUVs(0, list3); val.subMeshCount = list4.Count; for (int l = 0; l < list4.Count; l++) { val.SetTriangles(list4[l], l); } val.RecalculateTangents(); Model model = new Model { mesh = val, slots = array }; Models.Add(name, model); return model; } internal static Sprite Icon(IModHost host, string name) { //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_0020: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (Icons.TryGetValue(name, out var value)) { return value; } Texture2D val = new Texture2D(2, 2) { name = name }; if (!ImageConversion.LoadImage(val, host.ReadAsset("icons/" + name + ".png"), true)) { throw new InvalidDataException("Invalid image for " + name + "."); } value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one * 0.5f); ((Object)value).name = name; Icons.Add(name, value); return value; } internal static Sprite PrefabIcon(IModHost host, string id, Sprite fallback = null) { if (!host.HasAsset("icons/" + id + ".png")) { return fallback; } return Icon(host, id); } internal static AudioClip Sound(IModHost host, string name) { if (string.IsNullOrEmpty(name)) { return null; } if (Audio.TryGetValue(name, out var value)) { return value; } using MemoryStream memoryStream = new MemoryStream(host.ReadAsset("sounds/" + name + ".wav")); using BinaryReader binaryReader = new BinaryReader(memoryStream); if (ReadChunkId(binaryReader) != "RIFF") { throw new InvalidDataException("Invalid WAV for " + name + "."); } binaryReader.ReadInt32(); if (ReadChunkId(binaryReader) != "WAVE") { throw new InvalidDataException("Invalid WAV for " + name + "."); } int num = 0; int num2 = 0; int num3 = 0; while (memoryStream.Length - memoryStream.Position >= 8) { string text = ReadChunkId(binaryReader); int num4 = binaryReader.ReadInt32(); if (num4 < 0 || num4 > memoryStream.Length - memoryStream.Position) { break; } long position = memoryStream.Position + num4 + (num4 & 1); if (text == "fmt ") { short num5 = binaryReader.ReadInt16(); num = binaryReader.ReadInt16(); num2 = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadInt16(); num3 = binaryReader.ReadInt16(); if (num5 != 1) { break; } } if (text == "data" && num > 0 && num3 == 16) { float[] array = new float[num4 / 2]; for (int i = 0; i < array.Length; i++) { array[i] = (float)binaryReader.ReadInt16() / 32768f; } value = AudioClip.Create("Gunnr " + name, array.Length / num, num, num2, false); value.SetData(array, 0); Audio.Add(name, value); return value; } memoryStream.Position = position; } throw new InvalidDataException("No 16-bit PCM audio found for " + name + "."); } private static string ReadChunkId(BinaryReader reader) { return Encoding.ASCII.GetString(reader.ReadBytes(4)); } private static Vector3 ReadVector(BinaryReader reader) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); } } internal static class ItemRegistration { private static readonly Dictionary<string, Recipe> Recipes = new Dictionary<string, Recipe>(); private static readonly Action<ObjectDB> UpdateRegisters = AccessTools.MethodDelegate<Action<ObjectDB>>(AccessTools.Method(typeof(ObjectDB), "UpdateRegisters", (Type[])null, (Type[])null), (object)null, true); private static Transform holder; internal static void Refresh(ObjectDB db) { UpdateRegisters(db); } internal static GameObject CloneItem(GameObject template, string id, out SharedData shared) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if ((Object)(object)holder == (Object)null) { GameObject val = new GameObject("Custom inventory prefabs"); val.SetActive(false); Object.DontDestroyOnLoad((Object)val); holder = val.transform; } GameObject val2 = Object.Instantiate<GameObject>(template, holder, false); ((Object)val2).name = id; ItemData itemData = val2.GetComponent<ItemDrop>().m_itemData; shared = (SharedData)AccessTools.Method(typeof(object), "MemberwiseClone", (Type[])null, (Type[])null).Invoke(itemData.m_shared, null); itemData.m_shared = shared; itemData.m_dropPrefab = val2; return val2; } internal static void RegisterRecipe(ObjectDB db, GameObject item, string stationName, (string Item, int Count)[] cost, List<GameObject> stations, int stationLevel = 1) { if (!Recipes.TryGetValue(((Object)item).name, out var value)) { GameObject? obj = stations.Find((GameObject piece) => ((Object)piece).name == stationName); CraftingStation val = ((obj != null) ? obj.GetComponent<CraftingStation>() : null); Requirement[] array = ((IEnumerable<(string, int)>)cost).Select((Func<(string, int), Requirement>)delegate((string Item, int Count) entry) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown Requirement val2 = new Requirement(); GameObject itemPrefab = db.GetItemPrefab(entry.Item); val2.m_resItem = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); val2.m_amount = entry.Count; val2.m_recover = true; return val2; }).ToArray(); if ((Object)(object)val == (Object)null || array.Any((Requirement resource) => (Object)(object)resource.m_resItem == (Object)null)) { return; } value = ScriptableObject.CreateInstance<Recipe>(); ((Object)value).name = "Recipe_" + ((Object)item).name; value.m_item = item.GetComponent<ItemDrop>(); value.m_amount = 1; value.m_minStationLevel = stationLevel; value.m_craftingStation = val; value.m_resources = array; Recipes.Add(((Object)item).name, value); } if (!db.m_recipes.Contains(value)) { db.m_recipes.Add(value); } } } internal static class ItemModel { private static readonly Dictionary<string, Material> Surfaces = new Dictionary<string, Material>(); internal static GameObject BuildModel(ObjectDB db, IModHost host, Transform parent, string meshName, bool dropCollider = true) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) Files.Model model = Files.Mesh(host, meshName); Mesh val = Object.Instantiate<Mesh>(model.mesh); GameObject val2 = new GameObject("Field Artillery " + meshName) { layer = ((Component)parent).gameObject.layer }; val2.transform.SetParent(parent, false); val2.AddComponent<MeshFilter>().sharedMesh = val; Vector2[] uv = val.uv; Material[] array = (Material[])(object)new Material[model.slots.Length]; for (int i = 0; i < model.slots.Length; i++) { (Material, Rect) tuple = NativeSurface(db, model.slots[i]); array[i] = tuple.Item1; foreach (int item in val.GetTriangles(i).Distinct()) { uv[item] = ((Rect)(ref tuple.Item2)).min + Vector2.Scale(uv[item], ((Rect)(ref tuple.Item2)).size); } } val.uv = uv; val.RecalculateTangents(); ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterials = array; if (dropCollider) { BoxCollider obj = val2.AddComponent<BoxCollider>(); Bounds bounds = val.bounds; obj.center = ((Bounds)(ref bounds)).center; bounds = val.bounds; obj.size = Vector3.Max(((Bounds)(ref bounds)).size, Vector3.one * 0.05f); } return val2; } internal static (Material Material, Rect Region) NativeSurface(ObjectDB db, string key) { //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_08e9: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0569: 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_039b: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_0354: 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_048f: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_044d: 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_02d0: 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_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_084a: Unknown result type (might be due to invalid IL or missing references) //IL_0850: Expected O, but got Unknown //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a3: Unknown result type (might be due to invalid IL or missing references) //IL_07b1: Expected O, but got Unknown //IL_0895: Unknown result type (might be due to invalid IL or missing references) //IL_08cc: Unknown result type (might be due to invalid IL or missing references) (string, string, Rect, Color) tuple; switch (key) { case "wood": case "worked_ash": tuple = ("SpearFlint", "Planks1c", Rect.MinMaxRect(0.035f, 0.18f, 0.965f, 0.79f), new Color(0.82f, 0.77f, 0.69f)); break; case "rawwood": tuple = ("SpearFlint", "Planks1c", Rect.MinMaxRect(0.06f, 0.21f, 0.95f, 0.76f), new Color(0.67f, 0.59f, 0.48f)); break; case "finewood": tuple = ("SpearFlint", "Planks1c", Rect.MinMaxRect(0.041f, 0.24f, 0.951f, 0.73f), new Color(0.58f, 0.43f, 0.36f)); break; case "leather": tuple = ("LeatherScraps", "leatherscraps_d", Rect.MinMaxRect(0.3f, 0.47f, 0.5f, 0.61f), new Color(0.84f, 0.76f, 0.67f)); break; case "flint": case "chipped_flint": tuple = ("SpearFlint", "flint", Rect.MinMaxRect(0.08f, 0.08f, 0.92f, 0.92f), Color.white); break; case "bronze": case "aged_bronze": tuple = ("SpearBronze", "BronzeSpear_d", Rect.MinMaxRect(0.2f, 0.52f, 0.39f, 0.69f), new Color(1.08f, 0.99f, 0.83f)); break; case "ember": tuple = ("SpearBronze", "BronzeSpear_d", Rect.MinMaxRect(0.2f, 0.52f, 0.39f, 0.69f), new Color(0.94f, 0.41f, 0.13f)); break; case "silver": tuple = ("KnifeSilver", "silverknife_d", Rect.MinMaxRect(0.51f, 0.55f, 0.87f, 0.86f), new Color(0.9f, 0.94f, 0.97f)); break; case "blackmetal": tuple = ("BlackMetal", "blackmetal_d", Rect.MinMaxRect(0.11f, 0.3f, 0.58f, 0.71f), new Color(0.91f, 0.95f, 0.88f)); break; case "repeater_blackmetal": tuple = ("BlackMetal", "blackmetal_d", Rect.MinMaxRect(0.11f, 0.3f, 0.58f, 0.71f), new Color(0.57f, 0.67f, 0.54f)); break; case "blackmarble": tuple = ("BlackMarble", "marble_item_d", Rect.MinMaxRect(0.1f, 0.11f, 0.89f, 0.89f), new Color(0.82f, 0.86f, 0.82f)); break; case "blackwood": tuple = ("Blackwood", "blackwood_d", Rect.MinMaxRect(0.2f, 0.13f, 0.83f, 0.82f), new Color(0.88f, 0.72f, 0.64f)); break; case "dark": tuple = ("CrossbowArbalest", "Arbalest_d", Rect.MinMaxRect(0.53f, 0.09f, 0.92f, 0.49f), new Color(0.1f, 0.11f, 0.12f)); break; default: tuple = ("CrossbowArbalest", "Arbalest_d", Rect.MinMaxRect(0.53f, 0.09f, 0.92f, 0.49f), new Color(0.57f, 0.61f, 0.65f)); break; } (string, string, Rect, Color) source = tuple; if (!Surfaces.TryGetValue(key, out var value)) { GameObject itemPrefab = db.GetItemPrefab(source.Item1); Material val = ((itemPrefab != null) ? itemPrefab.GetComponentsInChildren<MeshRenderer>(true).SelectMany((MeshRenderer r) => ((Renderer)r).sharedMaterials).FirstOrDefault((Func<Material, bool>)delegate(Material m) { if ((Object)(object)m != (Object)null) { Texture mainTexture = m.mainTexture; return ((mainTexture != null) ? ((Object)mainTexture).name : null) == source.Item2; } return false; }) : null); if ((Object)(object)val == (Object)null) { val = ((Renderer)((Component)db.GetItemPrefab("CrossbowArbalest").transform.Find("attach/Unloaded")).GetComponent<MeshRenderer>()).sharedMaterial; } bool flag; switch (key) { case "dark": case "iron": case "bronze": case "silver": case "aged_bronze": case "ember": case "blackmetal": case "repeater_blackmetal": flag = true; break; default: flag = false; break; } if (flag) { value = new Material(((Renderer)db.GetItemPrefab("Iron").GetComponentInChildren<MeshRenderer>(true)).sharedMaterial) { mainTexture = val.mainTexture }; Texture texture = val.GetTexture("_BumpMap"); value.SetTexture("_BumpMap", texture); if ((Object)(object)texture == (Object)null) { value.DisableKeyword("_NORMALMAP"); } else { value.EnableKeyword("_NORMALMAP"); } value.SetFloat("_BumpScale", 0.35f); value.SetFloat("_Metallic", (key == "dark") ? 0f : 0.35f); value.SetFloat("_Glossiness", (key == "silver") ? 0.38f : 0.22f); } else { value = new Material(val); if (key == "blackmarble") { value.SetFloat("_Metallic", 0.04f); value.SetFloat("_Glossiness", 0.12f); } } ((Object)value).name = "Field Artillery " + key; value.color = source.Item4; if (key == "ember") { value.EnableKeyword("_EMISSION"); value.SetColor("_EmissionColor", new Color(0.48f, 0.075f, 0.012f)); } Surfaces.Add(key, value); } return (Material: value, Region: source.Item3); } } internal sealed class WagonModel(ObjectDB db, Transform parent) { private static readonly Dictionary<(PrimitiveType, string), Mesh> StockShapes = new Dictionary<(PrimitiveType, string), Mesh>(); private readonly Dictionary<string, List<CombineInstance>> surfaces = new Dictionary<string, List<CombineInstance>>(); internal static Transform Child(Transform parent, string name, Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject(name) { layer = ((Component)parent).gameObject.layer }.transform; transform.SetParent(parent, false); transform.localPosition = point; return transform; } internal void Box(string material, float x, float y, float z, float width, float height, float length, Vector3 rotation = default(Vector3)) { //IL_0007: 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_0017: Unknown result type (might be due to invalid IL or missing references) Part((PrimitiveType)3, material, new Vector3(x, y, z), new Vector3(width, height, length), rotation); } internal void Bearing(float x, float y, float z, float radius, float width, string material = "bronze") { //IL_0019: Unknown result type (might be due to invalid IL or missing references) Cylinder(material, x, y, z, radius, width, new Vector3(0f, 0f, 90f)); } internal void Cylinder(string material, float x, float y, float z, float radius, float height, Vector3 rotation = default(Vector3)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Part((PrimitiveType)2, material, new Vector3(x, y, z), new Vector3(2f * radius, height * 0.5f, 2f * radius), rotation); } internal void Beam(string material, Vector3 start, Vector3 end, float width, float depth) { //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_000b: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; Vector3 point = (start + end) * 0.5f; Vector3 scale = new Vector3(width, depth, ((Vector3)(ref val)).magnitude); Quaternion val2 = Quaternion.LookRotation(val); Part((PrimitiveType)3, material, point, scale, ((Quaternion)(ref val2)).eulerAngles); } private void Part(PrimitiveType shape, string material, Vector3 point, Vector3 scale, Vector3 rotation) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00eb: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (!StockShapes.TryGetValue((shape, material), out var value)) { GameObject val = GameObject.CreatePrimitive(shape); val.SetActive(false); value = Object.Instantiate<Mesh>(val.GetComponent<MeshFilter>().sharedMesh); Rect item = ItemModel.NativeSurface(db, material).Region; Vector2[] uv = value.uv; for (int i = 0; i < uv.Length; i++) { uv[i] = ((Rect)(ref item)).min + Vector2.Scale(uv[i], ((Rect)(ref item)).size); } value.uv = uv; value.RecalculateTangents(); StockShapes.Add((shape, material), value); Object.Destroy((Object)(object)val); } if (!surfaces.TryGetValue(material, out var value2)) { surfaces.Add(material, value2 = new List<CombineInstance>()); } List<CombineInstance> list = value2; CombineInstance item2 = default(CombineInstance); ((CombineInstance)(ref item2)).mesh = value; ((CombineInstance)(ref item2)).transform = Matrix4x4.TRS(point, Quaternion.Euler(rotation), scale); list.Add(item2); } internal void Commit() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown foreach (KeyValuePair<string, List<CombineInstance>> surface in surfaces) { Transform obj = Child(parent, surface.Key, Vector3.zero); Mesh val = new Mesh { name = ((Object)parent).name + " " + surface.Key }; val.CombineMeshes(surface.Value.ToArray(), true, true); ((Component)obj).gameObject.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)((Component)obj).gameObject.AddComponent<MeshRenderer>()).sharedMaterial = ItemModel.NativeSurface(db, surface.Key).Material; } } } internal interface IFurnacePower { bool IsBurning { get; } bool Occupied { get; } bool HasFuel { get; } bool Marine { get; } float EngineLoad { get; } } internal sealed class SurtlingFurnace : MonoBehaviour { [SerializeField] private Container hopper; [SerializeField] private MonoBehaviour powerSource; [SerializeField] private GameObject hot; [SerializeField] private Transform fan; [SerializeField] private AudioSource crackle; private float checkAt; private float angle; private float speed; private bool fueled; internal static bool Fit(Transform parent, Vector3 center, float height, Container hopper, MonoBehaviour powerSource = null) { //IL_0034: 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_009d: 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_00e1: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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_0127: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) ZNetScene instance = ZNetScene.instance; GameObject obj = ((instance != null) ? instance.GetPrefab("smelter") : null); Smelter val = ((obj != null) ? obj.GetComponent<Smelter>() : null); if ((Object)(object)val == (Object)null) { return false; } Transform val2 = WagonModel.Child(parent, "Compact Surtling furnace", center); Transform target = WagonModel.Child(val2, "Vanilla furnace body", Vector3.zero); if (!CopyNativeExterior(val, target, height)) { Object.Destroy((Object)(object)((Component)val2).gameObject); return false; } ObjectDB instance2 = ObjectDB.instance; WagonModel wagonModel = new WagonModel(instance2, val2); wagonModel.Box("finewood", 0f, 0.04f, 0f, height * 0.83f, 0.1f, height * 0.74f); for (int i = -1; i <= 1; i += 2) { wagonModel.Box("iron", (float)i * height * 0.35f, 0.066f, 0f, 0.07f, 0.072f, height * 0.78f); for (int j = -1; j <= 1; j += 2) { wagonModel.Cylinder("bronze", (float)i * height * 0.35f, 0.105f, (float)j * height * 0.31f, 0.026f, 0.019f); } } wagonModel.Cylinder("iron", 0f, height * 0.44f, (0f - height) * 0.43f, height * 0.14f, 0.15f, new Vector3(90f, 0f, 0f)); wagonModel.Commit(); Transform parent2 = WagonModel.Child(val2, "Furnace blower", new Vector3(0f, height * 0.44f, (0f - height) * 0.52f)); WagonModel wagonModel2 = new WagonModel(instance2, parent2); wagonModel2.Cylinder("bronze", 0f, 0f, 0f, height * 0.064f, 0.061f, new Vector3(90f, 0f, 0f)); for (int k = 0; k < 5; k++) { float num = (float)k * 72f; Vector3 val3 = Quaternion.Euler(0f, 0f, num) * Vector3.up * (height * 0.081f); wagonModel2.Box("iron", val3.x, val3.y, 0f, height * 0.07f, height * 0.12f, 0.025f, new Vector3(0f, 0f, num)); } wagonModel2.Commit(); GameObject gameObject = ((Component)WagonModel.Child(val2, "Furnace combustion", Vector3.zero)).gameObject; WagonModel wagonModel3 = new WagonModel(instance2, gameObject.transform); wagonModel3.Cylinder("ember", 0f, height * 0.44f, (0f - height) * 0.49f, height * 0.11f, 0.018f, new Vector3(90f, 0f, 0f)); wagonModel3.Commit(); Light obj2 = ((Component)WagonModel.Child(gameObject.transform, "Coal fire light", new Vector3(0f, height * 0.44f, (0f - height) * 0.55f))).gameObject.AddComponent<Light>(); obj2.type = (LightType)2; obj2.color = new Color(1f, 0.47f, 0.17f); obj2.range = 1.8f; obj2.intensity = 0.65f; ((Component)obj2).gameObject.AddComponent<SurtlingFurnaceGlow>(); SurtlingEffects.AddSmoke(gameObject.transform, new Vector3(0f, height * 0.86f, 0f), "smelter", "charcoal_kiln"); SurtlingEffects.AddKilnLoop(val, gameObject); SurtlingFurnace surtlingFurnace = ((Component)val2).gameObject.AddComponent<SurtlingFurnace>(); surtlingFurnace.hopper = hopper; surtlingFurnace.powerSource = powerSource; surtlingFurnace.hot = gameObject; surtlingFurnace.fan = parent2; surtlingFurnace.crackle = gameObject.GetComponent<AudioSource>(); if ((Object)(object)powerSource != (Object)null && (Object)(object)surtlingFurnace.crackle != (Object)null) { surtlingFurnace.crackle.volume = 0f; } gameObject.SetActive(false); return true; } private static bool CopyNativeExterior(Smelter smelter, Transform target, float height) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0269: 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_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: 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_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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) Transform transform = ((Component)smelter).transform; LODGroup componentInChildren = ((Component)transform).GetComponentInChildren<LODGroup>(true); MeshRenderer[] array = (((Object)(object)componentInChildren == (Object)null) ? ((Component)transform).GetComponentsInChildren<MeshRenderer>(true) : componentInChildren.GetLODs().FirstOrDefault().renderers?.OfType<MeshRenderer>().ToArray()); if (array == null) { return false; } List<(MeshRenderer, Mesh)> list = new List<(MeshRenderer, Mesh)>(); Bounds val = default(Bounds); MeshRenderer[] array2 = array; Vector3 val4 = default(Vector3); foreach (MeshRenderer val2 in array2) { MeshFilter component = ((Component)val2).GetComponent<MeshFilter>(); Mesh val3 = ((component != null) ? component.sharedMesh : null); if ((Object)(object)val3 == (Object)null || (Object)(object)((Renderer)val2).sharedMaterial == (Object)null || (Object)(object)((Renderer)val2).sharedMaterial.mainTexture == (Object)null || ((Object)(object)smelter.m_enabledObject != (Object)null && ((Component)val2).transform.IsChildOf(smelter.m_enabledObject.transform))) { continue; } list.Add((val2, val3)); Bounds bounds = val3.bounds; for (int j = 0; j < 8; j++) { ((Vector3)(ref val4))..ctor(((j & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((j & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((j & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z); Vector3 val5 = transform.InverseTransformPoint(((Component)val2).transform.TransformPoint(val4)); if (list.Count == 1 && j == 0) { ((Bounds)(ref val))..ctor(val5, Vector3.zero); } else { ((Bounds)(ref val)).Encapsulate(val5); } } } if (list.Count == 0 || ((Bounds)(ref val)).size.y < 0.05f) { return false; } float num = height / ((Bounds)(ref val)).size.y; Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(((Bounds)(ref val)).center.x, ((Bounds)(ref val)).min.y, ((Bounds)(ref val)).center.z); foreach (var item3 in list) { MeshRenderer item = item3.Item1; Mesh item2 = item3.Item2; Transform obj = WagonModel.Child(target, ((Object)item).name, (transform.InverseTransformPoint(((Component)item).transform.position) - val6) * num); obj.localRotation = Quaternion.Inverse(transform.rotation) * ((Component)item).transform.rotation; Vector3 lossyScale = transform.lossyScale; Vector3 lossyScale2 = ((Component)item).transform.lossyScale; obj.localScale = num * new Vector3(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z); ((Component)obj).gameObject.AddComponent<MeshFilter>().sharedMesh = item2; ((Renderer)((Component)obj).gameObject.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)item).sharedMaterials; } return true; } private void Update() { //IL_0141: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hopper == (Object)null || (Object)(object)hot == (Object)null) { return; } if (Time.time >= checkAt) { checkAt = Time.time + 0.3f; Inventory inventory = hopper.GetInventory(); fueled = ((inventory != null) ? inventory.GetItem("Coal", -1, true) : null) != null; } IFurnacePower furnacePower = powerSource as IFurnacePower; bool flag = furnacePower?.IsBurning ?? false; float num = furnacePower?.EngineLoad ?? 0f; bool flag2 = fueled || flag || (furnacePower != null && furnacePower.Occupied && furnacePower.HasFuel); if (hot.activeSelf != flag2) { hot.SetActive(flag2); } speed = Mathf.MoveTowards(speed, flag ? Mathf.Lerp(330f, 740f, num) : (flag2 ? 95f : 0f), Time.deltaTime * 1100f); angle = Mathf.Repeat(angle + speed * Time.deltaTime, 360f); fan.localRotation = Quaternion.Euler(0f, 0f, angle); if (!((Object)(object)crackle == (Object)null)) { if (furnacePower == null) { crackle.pitch = 0.87f; return; } float num2 = ((!furnacePower.Marine) ? (flag ? Mathf.Lerp(0.054f, 0.21f, num) : 0.041f) : (flag ? Mathf.Lerp(0.15f, 0.62f, num) : 0.055f)); float num3 = (flag ? Mathf.Lerp(0.81f, 1.23f, num) : 0.76f); crackle.volume = Mathf.MoveTowards(crackle.volume, num2, Time.deltaTime * 1.9f); crackle.pitch = Mathf.MoveTowards(crackle.pitch, num3, Time.deltaTime * 2.1f); } } } internal static class SurtlingEffects { internal static void AddKilnLoop(Smelter kiln, GameObject flame) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) AudioSource val = ((IEnumerable<AudioSource>)(from audio in (((Object)(object)kiln.m_enabledObject != (Object)null) ? kiln.m_enabledObject : ((Component)kiln).gameObject).GetComponentsInChildren<AudioSource>(true) orderby audio.loop descending select audio)).FirstOrDefault((Func<AudioSource, bool>)((AudioSource audio) => (Object)(object)Clip(audio) != (Object)null)); AudioClip val2 = (((Object)(object)val != (Object)null) ? Clip(val) : null); if ((Object)(object)val2 == (Object)null) { val = ((IEnumerable<AudioSource>)((Component)kiln).GetComponentsInChildren<AudioSource>(true)).FirstOrDefault((Func<AudioSource, bool>)((AudioSource audio) => audio.loop && (Object)(object)Clip(audio) != (Object)null)); val2 = (((Object)(object)val != (Object)null) ? Clip(val) : null); } if ((Object)(object)val2 == (Object)null) { ZLog.LogWarning((object)"Surtling furnace: charcoal kiln burn loop was unavailable."); return; } AudioSource obj = flame.AddComponent<AudioSource>(); ZSFX component = ((Component)val).GetComponent<ZSFX>(); obj.clip = val2; obj.loop = true; obj.playOnAwake = true; obj.spatialBlend = val.spatialBlend; obj.volume = (((Object)(object)component != (Object)null) ? ((component.m_minVol + component.m_maxVol) * 0.5f) : val.volume); obj.pitch = val.pitch; obj.rolloffMode = val.rolloffMode; obj.minDistance = val.minDistance; obj.maxDistance = val.maxDistance; obj.outputAudioMixerGroup = val.outputAudioMixerGroup; static AudioClip Clip(AudioSource audio) { AudioClip? obj2 = audio.clip; if (obj2 == null) { ZSFX component2 = ((Component)audio).GetComponent<ZSFX>(); if (component2 == null) { return null; } obj2 = ((IEnumerable<AudioClip>)component2.m_audioClips).FirstOrDefault((Func<AudioClip, bool>)((AudioClip existing) => (Object)(object)existing != (Object)null)); } return obj2; } } internal static void AddSmoke(Transform furnace, Vector3 point, params string[] sources) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00ed: 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_0123: 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_0141: 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_015a: 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_019f: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01da: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0222: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) ZNetScene scene = ZNetScene.instance; ParticleSystemRenderer val = (from id in sources select scene.GetPrefab(id) into prefab where (Object)(object)prefab != (Object)null select prefab).SelectMany((GameObject prefab) => prefab.GetComponentsInChildren<ParticleSystemRenderer>(true)).FirstOrDefault((Func<ParticleSystemRenderer, bool>)((ParticleSystemRenderer part) => ((Object)part).name.IndexOf("smoke", StringComparison.OrdinalIgnoreCase) >= 0 && (Object)(object)((Renderer)part).sharedMaterial != (Object)null)); if (!((Object)(object)val == (Object)null)) { Transform val2 = WagonModel.Child(furnace, "Chimney smoke", point); ParticleSystem val3 = ((Component)val2).gameObject.AddComponent<ParticleSystem>(); MainModule main = val3.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startSize = new MinMaxCurve(0.095f, 0.15f); ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.25f, 2.15f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.34f, 0.52f); ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.34f, 0.3f, 0.26f, 0.29f), new Color(0.48f, 0.45f, 0.4f, 0.37f)); ((MainModule)(ref main)).maxParticles = 14; ShapeModule shape = val3.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).radius = 0.028f; ((ShapeModule)(ref shape)).angle = 14f; val2.localRotation = Quaternion.Euler(-90f, 0f, 0f); EmissionModule emission = val3.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(4f); ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val4 = new Gradient(); val4.colorKeys = (GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }; val4.alphaKeys = (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(0.75f, 0.24f), new GradientAlphaKey(0f, 1f) }; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val4); SizeOverLifetimeModule sizeOverLifetime = val3.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.64f, 1f, 2.8f)); ((Renderer)((Component)val2).GetComponent<ParticleSystemRenderer>()).sharedMaterial = ((Renderer)val).sharedMaterial; } } } public sealed class SurtlingFurnaceGlow : MonoBehaviour { private Light glow; private float phase; private void Awake() { glow = ((Component)this).GetComponent<Light>(); phase = (float)(((Object)this).GetInstanceID() & 0xFF) * (1f / 32f); } private void Update() { glow.intensity = 0.66f + Mathf.Sin(phase + Time.time * 7.1f) * 0.13f + Mathf.Sin(phase + Time.time * 13.8f) * 0.065f; } } public sealed class CarriageControls : MonoBehaviour { private ZNetView view; private Rigidbody body; private Vagon wagon; private readonly List<(Collider Player, Collider Carriage)> ignoredForTow = new List<(Collider, Collider)>(); private readonly List<Collider> raisedSkids = new List<Collider>(); private float originalLinear; private float originalAngular; private float parkingUntil; private bool parked; private HingeJoint[] wheelHinges; private JointMotor[] originalMotors; private bool[] originalMotorUse; private bool wheelsBraked; private Transform[] interactions; private Vector3[] interactionOffsets; private readonly RaycastHit[] groundHits = (RaycastHit[])(object)new RaycastHit[12]; private static Vagon activeTow; private static int consumedUseFrame = -1; private static Action<Vagon> detach; private static int exitMask; internal static void Apply(string id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Harmony val = new Harmony(id); detach = AccessTools.MethodDelegate<Action<Vagon>>(AccessTools.Method(typeof(Vagon), "Detach", (Type[])null, (Type[])null), (object)null, true); exitMask = LayerMask.GetMask(new string[6] { "terrain", "Default", "static_solid", "Default_small", "piece", "vehicle" }); val.Patch((MethodBase)AccessTools.Method(typeof(Vagon), "AttachTo", (Type[])null, (Type[])null), (HarmonyMethod)null, Method("TrackTow"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Vagon), "Detach", (Type[])null, (Type[])null), Method("TowReleaseCue"), Method("ClearTow"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Player), "Update", (Type[])null, (Type[])null), Method("ReleaseInput"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Player), "Interact", (Type[])null, (Type[])null), Method("SuppressInteraction"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); static HarmonyMethod Method(string name) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return new HarmonyMethod(typeof(CarriageControls), name, (Type[])null); } } private void Awake() { view = ((Component)this).GetComponent<ZNetView>(); body = ((Component)this).GetComponent<Rigidbody>(); wagon = ((Component)this).GetComponent<Vagon>(); originalLinear = body.linearDamping; originalAngular = body.angularDamping; wheelHinges = (from wheel in wagon.m_wheels select ((Component)wheel).GetComponent<HingeJoint>() into hinge where (Object)(object)hinge != (Object)null select hinge).ToArray(); originalMotors = wheelHinges.Select((HingeJoint hinge) => hinge.motor).ToArray(); originalMotorUse = wheelHinges.Select((HingeJoint hinge) => hinge.useMotor).ToArray(); interactions = (from control in ((Component)this).GetComponentsInChildren<GroundedHitch>(true) select ((Component)control).transform).ToArray(); interactionOffsets = interactions.Select((Transform control) => control.localPosition).ToArray(); } private void LateUpdate() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0054: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_008b: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 val = ((Component)localPlayer).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 225f) { return; } Quaternion val2 = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f); for (int i = 0; i < interactions.Length; i++) { Vector3 val3 = interactionOffsets[i]; Vector3 val4 = ((Component)this).transform.position + val2 * val3; int num = Physics.RaycastNonAlloc(val4 + Vector3.up * 0.62f, Vector3.down, groundHits, 2.3f, exitMask, (QueryTriggerInteraction)1); for (int j = 0; j < num; j++) { RaycastHit val5 = groundHits[j]; if (((RaycastHit)(ref val5)).normal.y >= 0.42f && !((Component)((RaycastHit)(ref val5)).collider).transform.IsChildOf(((Component)this).transform)) { val4.y = Mathf.Max(val4.y, ((RaycastHit)(ref val5)).point.y + val3.y); } } interactions[i].SetPositionAndRotation(val4, val2); } } private void FixedUpdate() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) if (parked && Time.time >= parkingUntil) { parked = false; ResetDamping(); RestoreSkids(); } Player localPlayer = Player.m_localPlayer; if (!view.IsValid() || !view.IsOwner()) { SetWheelBrake(enabled: false); return; } bool flag = (Object)(object)activeTow == (Object)(object)wagon && (Object)(object)localPlayer != (Object)null && wagon.IsAttached((Character)(object)localPlayer); bool wheelBrake = !flag && parked; SetWheelBrake(wheelBrake); if (!flag && !parked) { return; } Vector3 val = Vector3.ProjectOnPlane(body.angularVelocity, Vector3.up); Vector3 val2 = Vector3.Cross(((Component)this).transform.up, Vector3.up); body.AddTorque(val2 * 22f - val * 6f, (ForceMode)5); if (flag) { Vector3 val3 = ((Component)localPlayer).transform.position + wagon.m_attachOffset - wagon.m_attachPoint.position; val3.y = 0f; float magnitude = ((Vector3)(ref val3)).magnitude; Vector3 val4 = ((magnitude > 0.08f) ? (val3 / magnitude) : Vector3.zero); float num = Vector3.Dot(((Component)localPlayer).GetComponent<Rigidbody>().linearVelocity, val4); float num2 = Mathf.Max(0f, num) * 0.32f * Mathf.InverseLerp(0.1f, 0.38f, magnitude); Vector3 val5 = val4 * Mathf.Clamp((magnitude - 0.08f) * 13f + num2, 0f, 11.5f); Vector3 linearVelocity = body.linearVelocity; Vector3 val6 = Vector3.MoveTowards(Vector3.ProjectOnPlane(linearVelocity, Vector3.up), val5, 78f * Time.fixedDeltaTime); body.linearVelocity = val6 + Vector3.up * linearVelocity.y; if (magnitude > 0.23f) { float num3 = Vector3.SignedAngle(Vector3.ProjectOnPlane(wagon.m_attachPoint.position - ((Component)this).transform.position, Vector3.up), val4, Vector3.up) * (MathF.PI / 180f); float num4 = Vector3.Dot(body.angularVelocity, Vector3.up); body.AddTorque(Vector3.up * Mathf.Clamp(num3 * 15f - num4 * 5.2f, -13f, 13f), (ForceMode)5); } } } private void OnDestroy() { RestoreTowCollisions(); } private void BeginTow(Player player) { parked = false; SetWheelBrake(enabled: false); body.linearDamping = originalLinear; body.angularDamping = Mathf.Max(originalAngular, 0.7f); RestoreTowCollisions(); ConfigurableJoint component = ((Component)wagon).GetComponent<ConfigurableJoint>(); if ((Object)(object)component != (Object)null) { component.xMotion = (ConfigurableJointMotion)2; component.yMotion = (ConfigurableJointMotion)2; component.zMotion = (ConfigurableJointMotion)2; ((Joint)component).breakForce = float.PositiveInfinity; } Collider[] componentsInChildren = ((Component)player).GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Collider>(); foreach (Collider val2 in componentsInChildren2) { if (!val.isTrigger && !val2.isTrigger && val.enabled && val2.enabled && !Physics.GetIgnoreCollision(val, val2)) { Physics.IgnoreCollision(val, val2); ignoredForTow.Add((val, val2)); } } } } private void EndTow() { RestoreRiderCollisions(); if ((Object)(object)body == (Object)null || (Object)(object)view == (Object)null || !view.IsValid() || !view.IsOwner()) { ResetDamping(); RestoreSkids(); return; } parked = true; parkingUntil = Time.time + 0.55f; body.linearDamping = Mathf.Max(originalLinear, 3f); body.angularDamping = Mathf.Max(originalAngular, 4f); SetWheelBrake(enabled: true); } private void SetWheelBrake(bool enabled) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (wheelsBraked == enabled) { return; } wheelsBraked = enabled; for (int i = 0; i < wheelHinges.Length; i++) { HingeJoint val = wheelHinges[i]; if (!((Object)(object)val == (Object)null)) { ? motor; if (!enabled) { motor = originalMotors[i]; } else { JointMotor val2 = default(JointMotor); ((JointMotor)(ref val2)).targetVelocity = 0f; ((JointMotor)(ref val2)).force = body.mass * 10f; motor = val2; } val.motor = (JointMotor)motor; val.useMotor = enabled || originalMotorUse[i]; } } } private void ResetDamping() { if (!((Object)(object)body == (Object)null)) { body.linearDamping = originalLinear; body.angularDamping = originalAngular; } } private void RestoreTowCollisions() { RestoreRiderCollisions(); RestoreSkids(); } private void RestoreRiderCollisions() { foreach (var item in ignoredForTow) { if ((Object)(object)item.Player != (Object)null && (Object)(object)item.Carriage != (Object)null) { Physics.IgnoreCollision(item.Player, item.Carriage, false); } } ignoredForTow.Clear(); } private void RestoreSkids() { foreach (Collider raisedSkid in raisedSkids) { if ((Object)(object)raisedSkid != (Object)null) { raisedSkid.enabled = true; } } raisedSkids.Clear(); } private static void TrackTow(Vagon __instance) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance.IsAttached((Character)(object)localPlayer)) { CarriageControls component = ((Component)__instance).GetComponent<CarriageControls>(); if (!((Object)(object)component == (Object)null)) { VehicleUse.HitchCue(__instance, attached: true); activeTow = __instance; component.BeginTow(localPlayer); ((Character)localPlayer).Message((MessageType)2, Localization.instance.Localize("Towing hauler. $KEY_Use lets go."), 0, (Sprite)null, false); } } } private static void TowReleaseCue(Vagon __instance) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && __instance.IsAttached((Character)(object)localPlayer) && (Object)(object)((Component)__instance).GetComponent<CarriageControls>() != (Object)null) { VehicleUse.HitchCue(__instance, attached: false); } } private static void ClearTow(Vagon __instance) { if (!((Object)(object)activeTow != (Object)(object)__instance)) { activeTow = null; CarriageControls component = ((Component)__instance).GetComponent<CarriageControls>(); if ((Object)(object)component != (Object)null) { component.EndTow(); } } } private static void ReleaseInput(Player __instance) { bool flag = (Object)(object)activeTow != (Object)null; if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && flag && (ZInput.GetButtonDown("Use") || ZInput.GetButtonDown("JoyUse"))) { HandleUsePress(__instance); } } internal static bool InputBlocked() { return VehicleUse.InputBlocked(); } private static void HandleUsePress(Player player) { if (!InputBlocked() && TryReleaseTow(player)) { consumedUseFrame = Time.frameCount; } } internal static bool TryReleaseTow(Player player) { if ((Object)(object)activeTow == (Object)null || !activeTow.IsAttached((Character)(object)player)) { return false; } detach(activeTow); activeTow = null; return true; } internal static Vagon CurrentTow(Player player) { if (!((Object)(object)activeTow != (Object)null) || !activeTow.IsAttached((Character)(object)player)) { return null; } return activeTow; } private static bool SuppressInteraction(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { return Time.frameCount != consumedUseFrame; } return true; } } public sealed class GroundedHitch : MonoBehaviour, Hoverable, Interactable { private Vagon wagon; private void Awake() { wagon = ((Component)this).GetComponentInParent<Vagon>(); } public string GetHoverName() { return wagon.GetHoverName(); } public string GetHoverText() { return wagon.GetHoverText(); } public float GetHoverOffset() { return wagon.GetHoverOffset(); } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!hold && PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return wagon.Interact(user, hold, alt); } return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } internal static void Fit(Vagon wagon) { //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_0025: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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_0088: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)wagon).transform; Vector3 localPosition = wagon.m_attachPoint.localPosition; localPosition.y = 0.98f; wagon.m_attachPoint.localPosition = localPosition; wagon.m_attachOffset.y = 0.98f; Transform obj = WagonModel.Child(transform, "Raised tow handle", Vector3.zero); GroundedHitch control = ((Component)obj).gameObject.AddComponent<GroundedHitch>(); ((Component)obj).gameObject.AddComponent<BoxCollider>(); ConfigureControl((Component)(object)control, transform, localPosition + Vector3.up * 0.22f, new Vector3(1f, 0.88f, 0.76f)); } internal static void ConfigureControl(Component control, Transform root, Vector3 center, Vector3 size) { //IL_0030: 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_004c: 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_0062: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = (((Object)(object)control == (Object)null) ? null : control.GetComponent<BoxCollider>()); if (!((Object)(object)val == (Object)null)) { control.transform.SetParent(root, false); control.transform.localPosition = center; control.transform.localRotation = Quaternion.identity; control.transform.localScale = Vector3.one; val.center = Vector3.zero; val.size = size; ((Collider)val).isTrigger = true; } } } internal static class NativeAudio { internal static AudioClip[] GameAudio(string name) { ZNetScene instance = ZNetScene.instance; GameObject val = (((Object)(object)instance == (Object)null) ? null : instance.GetPrefab(name)); if ((Object)(object)val == (Object)null) { return Array.Empty<AudioClip>(); } AudioClip[] array = val.GetComponentInChildren<ZSFX>(true)?.m_audioClips?.Where((AudioClip clip) => (Object)(object)clip != (Object)null).ToArray(); if (array != null && array.Length != 0) { return array; } AudioSource componentInChildren = val.GetComponentInChildren<AudioSource>(true); if (!((Object)(object)componentInChildren != (Object)null) || !((Object)(object)componentInChildren.clip != (Object)null)) { return Array.Empty<AudioClip>(); } return (AudioClip[])(object)new AudioClip[1] { componentInChildren.clip }; } internal static void Cue(string effect, Vector3 at, float volume) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) AudioClip[] array = GameAudio(effect); if (array.Length != 0) { AudioSource.PlayClipAtPoint(array[Random.Range(0, array.Length)], at, volume); } } } internal static class VehicleUse { private static readonly FieldRef<List<Vagon>> Carts = AccessTools.StaticFieldRefAccess<List<Vagon>>(AccessTools.Field(typeof(Vagon), "m_instances")); internal static bool IsTowing(Player player) { return Carts.Invoke().Any((Vagon wagon) => Object.op_Implicit((Object)(object)wagon) && wagon.IsAttached((Character)(object)player)); } internal static bool InputBlocked() { Chat instance = Chat.instance; if (!Hud.InRadial() && !InventoryGui.IsVisible() && !Menu.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible()) { if ((Object)(object)instance != (Object)null) { return instance.HasFocus(); } return false; } return true; } internal static void HitchCue(Vagon wagon, bool attached) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) NativeAudio.Cue("sfx_build_hammer_wood", wagon.m_attachPoint.position, attached ? 0.31f : 0.19f); } } internal static class LegacyGunnrConfig { private static ConfigFile legacy; internal static T Default<T>(string section, string key, T fallback) { //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_0034: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, "fred.fieldartillery.cfg"); if (!File.Exists(text)) { return fallback; } if (legacy == null) { legacy = new ConfigFile(text, false) { SaveOnConfigSet = false }; } return legacy.Bind<T>(section, key, fallback, (ConfigDescription)null).Value; } } internal sealed class CanoeWater : MonoBehaviour { private const float MissingWater = -900f; private Rigidbody body; private Ship ship; private ZNetView view; private float nextStroke; internal static void Apply(Harmony harmony) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(Ship), "CustomFixedUpdate", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(CanoeWater), "SampleAtWaterline", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } private static IEnumerable<CodeInstruction> SampleAtWaterline(IEnumerable<CodeInstruction> instructions) { MethodInfo stock = AccessTools.Method(typeof(Floating), "GetWaterLevel", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (!CodeInstructionExtensions.Calls(instruction, stock)) { yield return instruction; continue; } yield return new CodeInstruction(instruction) { opcode = OpCodes.Ldarg_0, operand = null }; yield return CodeInstruction.Call(typeof(CanoeWater), "Sample", (Type[])null, (Type[])null); } } internal static float Surface(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) float liquidLevel = Floating.GetLiquidLevel(point, 1f, (LiquidType)0); if (liquidLevel > -900f || (Object)(object)ZoneSystem.instance == (Object)null) { return liquidLevel; } point.y = ZoneSystem.instance.m_waterLevel - 0.45f; return Floating.GetLiquidLevel(point, 1f, (LiquidType)0); } internal static bool Depth(Vector3 point, out float surface, out float depth) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) surface = Surface(point); depth = 0f; if (surface <= -900f || (Object)(object)ZoneSystem.instance == (Object)null) { return false; } point.y = surface; float num = default(float); if (!ZoneSystem.instance.GetGroundHeight(point, ref num)) { return false; } depth = surface - num; return true; } private static float Sample(Vector3 point, ref WaterVolume lastVolume, Ship ship) { //IL_0000: 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_0027: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) float waterLevel = Floating.GetWaterLevel(point, ref lastVolume); CanoeWater canoeWater = default(CanoeWater); if (waterLevel > -900f || !((Component)ship).TryGetComponent<CanoeWater>(ref canoeWater)) { return waterLevel; } Vector3 position = ((Component)ship).transform.position; if (!Depth(position, out var surface, out var depth) || depth < 0.12f || position.y > surface + 2f) { return waterLevel; } if (!Depth(point, out var surface2, out var depth2) || !(depth2 > 0.08f)) { return surface; } return surface2; } private void Awake() { body = ((Component)this).GetComponent<Rigidbody>(); ship = ((Component)this).GetComponent<Ship>(); view = ((Component)this).GetComponent<ZNetView>(); } private void FixedUpdate() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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) if (!((Object)(object)view == (Object)null) && view.IsValid() && view.IsOwner() && !((Object)(object)ZoneSystem.instance == (Object)null)) { Vector3 position = body.position; if ((int)ship.GetSpeedSetting() == 0 && ship.m_shipControlls.HaveValidUser()) { Vector3 linearVelocity = body.linearVelocity; Vector3 val = Vector3.ProjectOnPlane(linearVelocity, Vector3.up); body.linearVelocity = Vector3.MoveTowards(val, Vector3.zero, 0.9f * Time.fixedDeltaTime) + Vector3.up * linearVelocity.y; } if (!(position.y > ZoneSystem.instance.m_waterLevel - 1.65f) && Depth(position, out var surface, out var depth) && !(depth < 0.6f) && !(position.y > surface - 1.65f)) { position.y = surface + 0.08f; body.position = position; body.linearVelocity = Vector3.ProjectOnPlane(body.linearVelocity, Vector3.up); } } } private void Update() { //IL_0040: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_0075: 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_004c: Invalid comparison between Unknown and I4 if (!((Object)(object)view == (Object)null) && view.IsValid() && !(Time.time < nextStroke) && ship.m_shipControlls.HaveValidUser()) { Speed speedSetting = ship.GetSpeedSetting(); if ((int)speedSetting == 1 || (int)speedSetting == 2) { nextStroke = Time.time + 0.92f; NativeAudio.Cue("fx_WaterImpact_Big", ship.m_rudderObject.transform.position, 0.14f); } } } } internal static class EarlyCookedNutrition { private const float Multiplier = 1.25f; private static readonly object Applied = new object(); private static readonly ConditionalWeakTable<SharedData, object> Updated = new ConditionalWeakTable<SharedData, object>(); private static readonly HashSet<string> StockMeals = new HashSet<string>(StringComparer.Ordinal) { "BakedPoteitr", "BlackSoup", "BloodPudding", "BoarJerky", "Bread", "CarrotSoup", "CookedAsksvinMeat", "CookedBjornMeat", "CookedBoneMawSerpentMeat", "CookedBugMeat", "CookedChickenMeat", "CookedDeerMeat", "CookedEgg", "CookedHareMeat", "CookedLoxMeat", "CookedMeat", "CookedMooseMeat", "CookedSealBlubber", "CookedVoltureMeat", "CookedWolfMeat", "DeerStew", "Eyescream", "FeastAshlands", "FeastBlackforest", "FeastDeepNorth", "FeastMeadows", "FeastMistlands", "FeastMountains", "FeastOceans", "FeastPlains", "FeastSwamps", "FierySvinstew", "FishAndBread", "FishCooked", "FishSoup", "FishWraps", "HoneyGlazedChicken", "KaleChips", "Lingondricka", "LoxPie", "MagicallyStuffedShroom", "MarinatedGreens", "MashedMeat", "MeatballsMashedPoteitr", "MeatPlatter", "MinceMeatSauce", "MisthareSupreme", "MooseKebab", "MushroomOmelette", "NeckTailGrilled", "OatMilk", "OatmealLingonberryJam", "OnionSoup", "OvenPancake", "Pancakes", "PiquantPie", "PulledBear", "QueensJam", "RoastedCrustPie", "Salad", "Sausages", "ScorchingMedley", "SealSoup", "SeekerAspic", "SerpentMeatCooked", "SerpentStew", "ShocklateSmoothie", "SizzlingBerryBroth", "SmokedFish", "SmokedMooseMeat", "SparklingShroomshake", "SpicyMarmalade", "TurnipStew", "VikingCupcake", "WolfJerky", "WolfMeatSkewer", "YggdrasilPorridge" }; internal static void Apply(ObjectDB db) { foreach (string stockMeal in StockMeals) { GameObject itemPrefab = db.GetItemPrefab(stockMeal); SharedData val = ((itemPrefab == null) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData.m_shared); if (val != null && !Updated.TryGetValue(val, out var _)) { Updated.Add(val, Applied); val.m_food *= 1.25f; val.m_foodStamina *= 1.25f; val.m_foodEitr *= 1.25f; } } } } internal static class EarlyCropArt { internal enum Stage { Seed, Young, Mature, Produce } private readonly struct Face { internal readonly Vector3 A; internal readonly Vector3 B; internal readonly Vector3 C; internal readonly Vector3 Na; internal readonly Vector3 Nb; internal readonly Vector3 Nc; internal readonly Vector2 Ua; internal readonly Vector2 Ub; internal readonly Vector2 Uc; internal readonly int Color; internal Face(Vector3 a, Vector3 b, Vector3 c, int color) : this(a, b, c, color, SurfaceUv(a), SurfaceUv(b), SurfaceUv(c)) { }//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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0012: 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_0020: 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_0029: 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) internal Face(Vector3 a, Vector3 b, Vector3 c, int color, Vector2 ua, Vector2 ub, Vector2 uc, Vector3 na = default(Vector3), Vector3 nb = default(Vector3), Vector3 nc = default(Vector3)) { //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_0009: 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_0010: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005c: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_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) A = a; B = b; C = c; Color = color; Ua = ua; Ub = ub; Uc = uc; Vector3 val = Vector3.Cross(b - a, c - a); Vector3 normalized = ((Vector3)(ref val)).normalized; val = default(Vector3); Na = ((na == val) ? normalized : na); val = default(Vector3); Nb = ((nb == val) ? normalized : nb); val = default(Vector3); Nc = ((nc == val) ? normalized : nc); } } private enum Surface { Flesh, Leaf, Wood, Stoneware, Broth, Grain, Roast, Root, Radish, Leek, Berry, Mushroom } private static readonly Color[] Foliage = (Color[])(object)new Color[3] { new Color(0.29f, 0.43f, 0.19f), new Color(0.34f, 0.47f, 0.22f), new Color(0.42f, 0.52f, 0.25f) }; private static readonly Color[] Harvest = (Color[])(object)new Color[5] { new Color(0.76f, 0.57f, 0.28f), new Color(0.72f, 0.16f, 0.28f), new Color(0.38f, 0.54f, 0.23f), new Color(0.35f, 0.53f, 0.17f), new Color(0.73f, 0.73f, 0.47f) }; private static readonly Dictionary<(EarlyCrop, bool, bool), Material[]> Materials = new Dictionary<(EarlyCrop, bool, bool), Material[]>(); private static Material nativeCropMaterial; private static Material nativeFoodMaterial; private static readonly Dictionary<Surface, Texture2D> Surfaces = new Dictionary<Surface, Texture2D>(); private const int Vessel = 0; private const int Rim = 1; private const int Base = 2; private const int Accent = 3; private const int LeafGreen = 4; private const int Cream = 5; private const int Roast = 6; private const int Carrot = 7; private const int RadishRed = 8; private const int PeaGreen = 9; private const int Cap = 10; internal static void UseCropMaterials(Material crop, Material food) { nativeCropMaterial = crop; nativeFoodMaterial = food ?? crop; } internal static GameObject Build(Transform parent, EarlyCrop kind, Stage stage, string name, bool wilted = false) { //IL_0032: 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_0043: 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_005e: 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_0063: Unknown result type (might be due to invalid IL or missing references) bool flag = stage == Stage.Seed || stage == Stage.Produce; if (!Materials.TryGetValue((kind, wilted, flag), out var value)) { Color[] array = (Color[])(object)new Color[6]; for (int i = 0; i < array.Length; i++) { Color val = Tint(kind, i); array[i] = (wilted ? Color.Lerp(val, new Color(0.52f, 0.39f, 0.2f), 0.65f) : val); } Materials.Add((kind, wilted, flag), value = MakeMaterials(array, kind.ToString() + " crop", flag, CropSurfaces(kind))); } return BuildMesh(parent, name, Shape(kind, stage), value); } internal static void AttachItemArt(Transform item, Transform visual) { Transform val = item.Find("attach"); if (!((Object)(object)val == (Object)null)) { Transform val2 = val.Find("attachobj"); visual.SetParent(Object.op_Implicit((Object)(object)val2) ? val2 : val, true); } } private static GameObject BuildMesh(Transform parent, string name, List<Face> faces, Material[] materials) { //IL_0002: 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_0123: 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_0136: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00b7: 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_00d1: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)WagonModel.Child(parent, name, Vector3.zero)).gameObject; List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<Vector3> list3 = new List<Vector3>(); List<int>[] array = new List<int>[materials.Length]; for (int i = 0; i < array.Length; i++) { array[i] = new List<int>(); } foreach (Face face in faces) { List<int> list4 = array[face.Color]; for (int j = 0; j < 3; j++) { list4.Add(list.Count + j); } list.Add(face.A); list.Add(face.B); list.Add(face.C); list2.Add(face.Ua); list2.Add(face.Ub); list2.Add(face.Uc); list3.Add(face.Na); list3.Add(face.Nb); list3.Add(face.Nc); } Mesh val = new Mesh { name = name, subMeshCount = array.Length }; val.SetVertices(list); val.SetUVs(0, list2); for (int k = 0; k < array.Length; k++) { val.SetTriangles(array[k], k); } val.SetNormals(list3); gameObject.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)game