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 Digi Modpack v1.2.2
plugins/AnimalFeedingTrough/AnimalFeedingTrough.dll
Decompiled 6 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: Guid("55912d84-4458-440a-b4d5-ee0eb383d22e")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: CompilationRelaxations(8)] [assembly: ComVisible(false)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyTitle("Animal Feeding Trough")] [assembly: AssemblyDescription("Adds a functional animal feeding trough to Valheim.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("xNeliox")] [assembly: AssemblyProduct("Animal Feeding Trough")] [assembly: AssemblyCopyright("Copyright © 2026 xNeliox")] [assembly: AssemblyTrademark("")] [assembly: AssemblyVersion("1.0.5.0")] namespace AnimalFeedingTrough; internal enum TroughVariant { Standard, Compact, Small, Curved, CurvedCompact, CurvedTiny, Corner, CornerCompact, CornerTiny, ChickenBowl } [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [BepInPlugin("xneliox.animalfeedingtrough", "Animal Feeding Trough", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class AnimalFeedingTroughPlugin : BaseUnityPlugin { public const string PluginGuid = "xneliox.animalfeedingtrough"; public const string PluginName = "Animal Feeding Trough"; public const string PluginVersion = "1.0.5"; internal const string PrefabName = "xneliox_FeedingTrough"; internal const string CompactPrefabName = "xneliox_FeedingTroughCompact"; internal const string SmallPrefabName = "xneliox_FeedingTroughSmall"; internal const string CurvedPrefabName = "xneliox_FeedingTroughCurved"; internal const string CurvedCompactPrefabName = "xneliox_FeedingTroughCurvedCompact"; internal const string CurvedTinyPrefabName = "xneliox_FeedingTroughCurvedTiny"; internal const string CornerPrefabName = "xneliox_FeedingTroughCorner"; internal const string ChickenBowlPrefabName = "xneliox_ChickenFeedingBowl"; internal const string CornerCompactPrefabName = "xneliox_FeedingTroughCornerCompact"; internal const string CornerTinyPrefabName = "xneliox_FeedingTroughCornerTiny"; private void Awake() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) TroughTranslations.Register(); new Harmony("xneliox.animalfeedingtrough").PatchAll(typeof(AnimalFeedingTroughPlugin).Assembly); PrefabManager.OnVanillaPrefabsAvailable += RegisterTrough; } private void OnDestroy() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("xneliox.animalfeedingtrough").UnpatchSelf(); PrefabManager.OnVanillaPrefabsAvailable -= RegisterTrough; } private void RegisterTrough() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= RegisterTrough; try { RegisterTroughPiece("xneliox_FeedingTrough", "$xneliox_trough_name", "$xneliox_trough_description", TroughVariant.Standard, 6, new RequirementConfig("Wood", 20, 0, true), new RequirementConfig("BronzeNails", 4, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughCompact", "$xneliox_trough_compact_name", "$xneliox_trough_compact_description", TroughVariant.Compact, 6, new RequirementConfig("Wood", 14, 0, true), new RequirementConfig("BronzeNails", 3, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughSmall", "$xneliox_trough_small_name", "$xneliox_trough_small_description", TroughVariant.Small, 6, new RequirementConfig("Wood", 8, 0, true), new RequirementConfig("BronzeNails", 2, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughCurved", "$xneliox_trough_curved_name", "$xneliox_trough_curved_description", TroughVariant.Curved, 6, new RequirementConfig("Wood", 18, 0, true), new RequirementConfig("BronzeNails", 4, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughCurvedCompact", "$xneliox_trough_curved_compact_name", "$xneliox_trough_curved_compact_description", TroughVariant.CurvedCompact, 6, new RequirementConfig("Wood", 12, 0, true), new RequirementConfig("BronzeNails", 3, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughCurvedTiny", "$xneliox_trough_curved_tiny_name", "$xneliox_trough_curved_tiny_description", TroughVariant.CurvedTiny, 6, new RequirementConfig("Wood", 8, 0, true), new RequirementConfig("BronzeNails", 2, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughCorner", "$xneliox_trough_corner_name", "$xneliox_trough_corner_description", TroughVariant.Corner, 6, new RequirementConfig("Wood", 18, 0, true), new RequirementConfig("BronzeNails", 4, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughCornerCompact", "$xneliox_trough_corner_compact_name", "$xneliox_trough_corner_compact_description", TroughVariant.CornerCompact, 6, new RequirementConfig("Wood", 12, 0, true), new RequirementConfig("BronzeNails", 3, 0, true)); RegisterTroughPiece("xneliox_FeedingTroughCornerTiny", "$xneliox_trough_corner_tiny_name", "$xneliox_trough_corner_tiny_description", TroughVariant.CornerTiny, 6, new RequirementConfig("Wood", 8, 0, true), new RequirementConfig("BronzeNails", 2, 0, true)); RegisterTroughPiece("xneliox_ChickenFeedingBowl", "$xneliox_chicken_bowl_name", "$xneliox_chicken_bowl_description", TroughVariant.ChickenBowl, 6, new RequirementConfig("Wood", 6, 0, true), new RequirementConfig("BronzeNails", 2, 0, true)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered ten networked animal feeding trough variants with six storage slots each."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not register feeding troughs: " + ex)); } } private static void RegisterTroughPiece(string prefabName, string nameToken, string descriptionToken, TroughVariant variant, int storageSlots, params RequirementConfig[] requirements) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) PieceConfig val = new PieceConfig(); val.Name = nameToken; val.Description = descriptionToken; val.PieceTable = "_HammerPieceTable"; val.Category = "Furniture"; val.CraftingStation = "piece_workbench"; val.Icon = TroughVariantIcons.Create(variant); val.Requirements = requirements; PieceConfig val2 = val; CustomPiece val3 = new CustomPiece(prefabName, "piece_chest_wood", val2); GameObject piecePrefab = val3.PiecePrefab; ((Object)piecePrefab).name = prefabName; Renderer componentInChildren = piecePrefab.GetComponentInChildren<Renderer>(true); Material val4 = (Object.op_Implicit((Object)(object)componentInChildren) ? componentInChildren.sharedMaterial : null); if (!Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("No Valheim piece material was available."); } Renderer[] componentsInChildren = piecePrefab.GetComponentsInChildren<Renderer>(true); foreach (Renderer val5 in componentsInChildren) { val5.enabled = false; } Collider[] componentsInChildren2 = piecePrefab.GetComponentsInChildren<Collider>(true); foreach (Collider val6 in componentsInChildren2) { val6.enabled = false; } AssetBundleTroughModel.Instantiate(piecePrefab.transform, variant); BoxCollider val7 = piecePrefab.GetComponent<BoxCollider>(); if (!Object.op_Implicit((Object)(object)val7)) { val7 = piecePrefab.AddComponent<BoxCollider>(); } if (variant == TroughVariant.Corner || variant == TroughVariant.CornerCompact || variant == TroughVariant.CornerTiny) { float num = variant switch { TroughVariant.CornerCompact => 2.55f, TroughVariant.Corner => 3.5f, _ => 1.85f, }; float num2 = variant switch { TroughVariant.CornerCompact => 0.82f, TroughVariant.Corner => 1.15f, _ => 0.58f, }; float num3 = variant switch { TroughVariant.CornerCompact => 0.85f, TroughVariant.Corner => 1f, _ => 0.68f, }; float num4 = variant switch { TroughVariant.CornerCompact => 1.05f, TroughVariant.Corner => 1.34f, _ => 0.8f, }; val7.center = new Vector3(0f - num2, 0.5f, 0f); val7.size = new Vector3(num, num3, num4); BoxCollider val8 = piecePrefab.AddComponent<BoxCollider>(); val8.center = new Vector3(0f, 0.5f, num2); val8.size = new Vector3(num4, num3, num); ((Collider)val8).enabled = true; } else { val7.center = TroughVariantGeometry.ColliderCenter(variant); val7.size = TroughVariantGeometry.ColliderSize(variant); } ((Collider)val7).enabled = true; Container component = piecePrefab.GetComponent<Container>(); component.m_name = nameToken; component.m_width = storageSlots; component.m_height = 1; component.m_privacy = (PrivacySetting)2; Piece component2 = piecePrefab.GetComponent<Piece>(); component2.m_name = nameToken; component2.m_description = descriptionToken; TroughFeeder troughFeeder = piecePrefab.GetComponent<TroughFeeder>(); if (!Object.op_Implicit((Object)(object)troughFeeder)) { troughFeeder = piecePrefab.AddComponent<TroughFeeder>(); } troughFeeder.SetVariant(variant); PieceManager.Instance.AddPiece(val3); } } [HarmonyPatch(typeof(ZNetScene), "CreateObject")] internal static class TroughPrefabHashMigration { private const int PreviousPrefabHash = 160077371; private static void Prefix(ZDO zdo) { if (zdo != null && zdo.GetPrefab() == 160077371) { zdo.SetPrefab(StringExtensionMethods.GetStableHashCode("xneliox_FeedingTrough")); } } } [HarmonyPatch(typeof(ZNetScene), "GetPrefab", new Type[] { typeof(int) })] internal static class TroughPrefabHashLookup { private const int PreviousPrefabHash = 160077371; private static void Prefix(ref int hash) { if (hash == 160077371) { hash = StringExtensionMethods.GetStableHashCode("xneliox_FeedingTrough"); } } } internal static class AssetBundleTroughModel { private const string BundleResource = "animalfeedingtrough_v4"; private const string PrefabAsset = "Assets/AnimalFeedingTrough/FeedingTroughV4.prefab"; private static AssetBundle _bundle; private static GameObject _prefab; internal static GameObject Instantiate(Transform parent, TroughVariant variant) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_bundle)) { Assembly assembly = typeof(AnimalFeedingTroughPlugin).Assembly; using Stream stream = assembly.GetManifestResourceStream("animalfeedingtrough_v4"); if (stream == null) { throw new InvalidOperationException("The embedded feeding trough AssetBundle resource is missing."); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); _bundle = AssetBundle.LoadFromMemory(memoryStream.ToArray()); } if (!Object.op_Implicit((Object)(object)_bundle)) { throw new InvalidOperationException("The embedded feeding trough AssetBundle could not be loaded."); } if (!Object.op_Implicit((Object)(object)_prefab)) { _prefab = _bundle.LoadAsset<GameObject>("Assets/AnimalFeedingTrough/FeedingTroughV4.prefab"); } if (!Object.op_Implicit((Object)(object)_prefab)) { throw new InvalidOperationException("The feeding trough prefab is missing from the AssetBundle."); } GameObject val = Object.Instantiate<GameObject>(_prefab, parent, false); ((Object)val).name = "AnimalFeedingTroughModelV3"; TroughVariantGeometry.Apply(val, variant); Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (variant == TroughVariant.ChickenBowl) { break; } if (((Object)val2).name.EndsWith(" foot", StringComparison.Ordinal)) { Vector3 localPosition = val2.localPosition; localPosition.y = 0.16f; val2.localPosition = localPosition; Vector3 localScale = val2.localScale; localScale.y = 0.36f; val2.localScale = localScale; } } return val; } } internal static class TroughVariantGeometry { internal static Vector3 ColliderCenter(TroughVariant variant) { //IL_0014: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(variant switch { TroughVariant.ChickenBowl => new Vector3(0f, 0.17f, 0f), TroughVariant.Corner => new Vector3(-0.55f, 0.42f, 0.55f), _ => new Vector3(0f, (variant == TroughVariant.Small) ? 0.34f : 0.5f, 0f), }); } internal static Vector3 ColliderSize(TroughVariant variant) { //IL_0042: 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_006c: 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_00ab: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(variant switch { TroughVariant.Compact => new Vector3(3.41f, 1f, 1.12f), TroughVariant.Small => new Vector3(2.05f, 0.65f, 1.06f), TroughVariant.Curved => new Vector3(4.55f, 1f, 2.05f), TroughVariant.Corner => new Vector3(3.55f, 1f, 3.55f), TroughVariant.CurvedCompact => new Vector3(3.35f, 1f, 1.72f), TroughVariant.CurvedTiny => new Vector3(2.3f, 0.72f, 1.26f), TroughVariant.ChickenBowl => new Vector3(1.55f, 0.34f, 1.55f), _ => new Vector3(5.24f, 1f, 1.34f), }); } internal static float LengthScale(TroughVariant variant) { return variant switch { TroughVariant.Compact => 0.65f, TroughVariant.Small => 0.38f, TroughVariant.Corner => 0.48f, TroughVariant.CornerCompact => 0.34f, TroughVariant.CornerTiny => 0.23f, TroughVariant.Curved => 1f, TroughVariant.CurvedCompact => 0.7f, TroughVariant.CurvedTiny => 0.46f, _ => 1f, }; } internal static void Apply(GameObject model, TroughVariant variant) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0112: 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) float num = LengthScale(variant); Vector3 one = default(Vector3); ((Vector3)(ref one))..ctor(num, 1f, 1f); if (variant == TroughVariant.Compact) { ((Vector3)(ref one))..ctor(num, 1f, 0.82f); } if (variant == TroughVariant.Small) { ((Vector3)(ref one))..ctor(num, 0.6f, 0.78f); } if (variant == TroughVariant.CurvedCompact) { one = Vector3.one; } if (variant == TroughVariant.CurvedTiny) { ((Vector3)(ref one))..ctor(1f, 0.72f, 0.8f); } model.transform.localScale = one; if (variant == TroughVariant.Small || variant == TroughVariant.CurvedTiny) { RemoveMiddleSupportPair(model.transform); } switch (variant) { case TroughVariant.Curved: case TroughVariant.CurvedCompact: case TroughVariant.CurvedTiny: switch (variant) { case TroughVariant.CurvedCompact: ShortenAlongX(model.transform, 0.7f); break; case TroughVariant.CurvedTiny: ShortenAlongX(model.transform, 0.46f); break; } Bend(model.transform, variant switch { TroughVariant.CurvedCompact => 4.8f, TroughVariant.CurvedTiny => 3.25f, _ => 6.5f, }); break; case TroughVariant.Corner: case TroughVariant.CornerCompact: case TroughVariant.CornerTiny: MakeCorner(model); switch (variant) { case TroughVariant.CornerCompact: model.transform.localScale = new Vector3(0.72f, 0.85f, 0.72f); break; case TroughVariant.CornerTiny: model.transform.localScale = new Vector3(0.52f, 0.68f, 0.52f); break; } break; case TroughVariant.ChickenBowl: MakeChickenBowl(model); break; } } private static void MakeChickenBowl(GameObject model) { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) Transform transform = model.transform; Material val = null; Material val2 = null; Material val3 = null; Material val4 = null; Transform[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Transform>(true); foreach (Transform val5 in componentsInChildren) { Renderer component = ((Component)val5).GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMaterial)) { if (((Object)val5).name.EndsWith(" outward rim", StringComparison.Ordinal)) { val = component.sharedMaterial; } else if (((Object)val5).name == "Basin bottom") { val2 = component.sharedMaterial; } else if (((Object)val5).name.EndsWith(" iron leg and band", StringComparison.Ordinal)) { val3 = component.sharedMaterial; } else if (((Object)val5).name == "VisibleFeed") { val4 = component.sharedMaterial; } } } if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4)) { return; } List<GameObject> list = new List<GameObject>(); Transform[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<Transform>(true); foreach (Transform val6 in componentsInChildren2) { if ((Object)(object)val6 != (Object)(object)transform && (Object)(object)val6.parent == (Object)(object)transform) { list.Add(((Component)val6).gameObject); } } foreach (GameObject item in list) { Object.DestroyImmediate((Object)(object)item); } transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)val7).name = "Round chicken bowl bottom"; val7.transform.SetParent(transform, false); val7.transform.localPosition = new Vector3(0f, 0.105f, 0f); val7.transform.localScale = new Vector3(1.2f, 0.035f, 1.2f); Object.DestroyImmediate((Object)(object)val7.GetComponent<Collider>()); val7.GetComponent<Renderer>().sharedMaterial = val2; float num = 1.3f * Mathf.Sin((float)Math.PI / 20f) + 0.025f; for (int k = 0; k < 20; k++) { float num2 = (float)k * (float)Math.PI * 2f / 20f; AddJointCube(transform, "Round wooden wall", new Vector3(Mathf.Sin(num2) * 0.65f, 0.19f, Mathf.Cos(num2) * 0.65f), new Vector3(num, 0.2f, 0.16f), Quaternion.Euler(0f, num2 * 57.29578f, 0f), val); } for (int l = 0; l < 4; l++) { float num3 = (float)l * (float)Math.PI * 0.5f; AddJointCube(transform, "Round bowl iron band", new Vector3(Mathf.Sin(num3) * 0.735f, 0.19f, Mathf.Cos(num3) * 0.735f), new Vector3(0.1f, 0.22f, 0.035f), Quaternion.Euler(0f, num3 * 57.29578f, 0f), val3); } Vector3 position = default(Vector3); for (int m = 0; m < 4; m++) { float num4 = (45f + (float)m * 90f) * ((float)Math.PI / 180f); ((Vector3)(ref position))..ctor(Mathf.Sin(num4) * 0.737f, 0.19f, Mathf.Cos(num4) * 0.737f); float num5 = num4 * 57.29578f; AddJointCube(transform, "Round bowl X brace A", position, new Vector3(0.045f, 0.19f, 0.025f), Quaternion.Euler(0f, num5, 38f), val3); AddJointCube(transform, "Round bowl X brace B", position, new Vector3(0.045f, 0.19f, 0.025f), Quaternion.Euler(0f, num5, -38f), val3); } for (int n = 0; n < 4; n++) { float num6 = (45f + (float)n * 90f) * ((float)Math.PI / 180f); AddJointCube(transform, "Chicken bowl foot", new Vector3(Mathf.Sin(num6) * 0.48f, 0.055f, Mathf.Cos(num6) * 0.48f), new Vector3(0.22f, 0.11f, 0.22f), Quaternion.identity, val2); } GameObject val8 = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)val8).name = "VisibleFeed"; val8.transform.SetParent(transform, false); val8.transform.localPosition = new Vector3(0f, 0.255f, 0f); val8.transform.localScale = new Vector3(1.08f, 0.018f, 1.08f); Object.DestroyImmediate((Object)(object)val8.GetComponent<Collider>()); val8.GetComponent<Renderer>().sharedMaterial = val4; val8.SetActive(false); } private static void RemoveMiddleSupportPair(Transform root) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)(object)root) && !((Object)(object)val.parent != (Object)(object)root) && !(Mathf.Abs(val.localPosition.x) > 0.01f) && (((Object)val).name == "Front foot" || ((Object)val).name == "Rear foot" || ((Object)val).name == "Front iron leg and band" || ((Object)val).name == "Rear iron leg and band" || ((Object)val).name == "Cross support")) { ((Component)val).gameObject.SetActive(false); } } } private static void Bend(Transform root, float radius) { //IL_0052: 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_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_009d: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) ConvertLongTimbersToContinuousCurves(root, radius); Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)(object)root) && !((Object)(object)val.parent != (Object)(object)root) && !((Object)val).name.EndsWith(" continuous curved", StringComparison.Ordinal)) { float x = val.localPosition.x; float z = val.localPosition.z; float num = x / radius; Vector3 localPosition = val.localPosition; float num2 = radius - z; localPosition.x = Mathf.Sin(num) * num2; localPosition.z = radius - Mathf.Cos(num) * num2; val.localPosition = localPosition; val.localRotation = Quaternion.Euler(0f, (0f - num) * 57.29578f, 0f) * val.localRotation; MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (((Object)val).name == "VisibleFeed" && Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMesh)) { component.sharedMesh = BendMesh(component.sharedMesh, radius); } } } } private static void ShortenAlongX(Transform root, float factor) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val == (Object)(object)root || (Object)(object)val.parent != (Object)(object)root) { continue; } Vector3 localPosition = val.localPosition; localPosition.x *= factor; val.localPosition = localPosition; if (((Object)val).name.EndsWith(" outward rim", StringComparison.Ordinal) || ((Object)val).name == "Basin bottom") { Vector3 localScale = val.localScale; localScale.x *= factor; val.localScale = localScale; } if (!(((Object)val).name == "VisibleFeed")) { continue; } MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMesh)) { Mesh val2 = Object.Instantiate<Mesh>(component.sharedMesh); Vector3[] vertices = val2.vertices; for (int j = 0; j < vertices.Length; j++) { ref Vector3 reference = ref vertices[j]; reference.x *= factor; } val2.vertices = vertices; val2.RecalculateBounds(); component.sharedMesh = val2; } } } private static void ConvertLongTimbersToContinuousCurves(Transform root, float radius) { //IL_0085: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) List<Transform> list = new List<Transform>(); Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if ((Object)(object)val.parent == (Object)(object)root && (((Object)val).name.EndsWith(" outward rim", StringComparison.Ordinal) || ((Object)val).name == "Basin bottom")) { list.Add(val); } } foreach (Transform item in list) { MeshFilter component = ((Component)item).GetComponent<MeshFilter>(); if (Object.op_Implicit((Object)(object)component)) { component.sharedMesh = CreateContinuousCurvedBeam(item.localPosition, item.localScale, radius, 32, ((Object)item).name); ((Object)item).name = ((Object)item).name + " continuous curved"; item.localPosition = Vector3.zero; item.localRotation = Quaternion.identity; item.localScale = Vector3.one; } } } private static Mesh CreateContinuousCurvedBeam(Vector3 center, Vector3 size, float radius, int sections, string sourceName) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown List<Vector3> vertices = new List<Vector3>((sections + 1) * 8 + 8); List<Vector2> list = new List<Vector2>((sections + 1) * 8 + 8); List<int> list2 = new List<int>(sections * 24 + 12); float num = center.x - size.x * 0.5f; float y = center.y - size.y * 0.5f; float y2 = center.y + size.y * 0.5f; float z = center.z - size.z * 0.5f; float z2 = center.z + size.z * 0.5f; Vector3[,] array = new Vector3[sections + 1, 4]; for (int i = 0; i <= sections; i++) { float num2 = (float)i / (float)sections; float x = Mathf.Lerp(num, num + size.x, num2); ref Vector3 reference = ref array[i, 0]; reference = BendPoint(x, y, z, radius); ref Vector3 reference2 = ref array[i, 1]; reference2 = BendPoint(x, y2, z, radius); ref Vector3 reference3 = ref array[i, 2]; reference3 = BendPoint(x, y2, z2, radius); ref Vector3 reference4 = ref array[i, 3]; reference4 = BendPoint(x, y, z2, radius); } AddCurvedBeamStrip(vertices, list, list2, array, sections, 0, 1); AddCurvedBeamStrip(vertices, list, list2, array, sections, 1, 2); AddCurvedBeamStrip(vertices, list, list2, array, sections, 2, 3); AddCurvedBeamStrip(vertices, list, list2, array, sections, 3, 0); AddBeamCap(vertices, list, list2, array[0, 0], array[0, 3], array[0, 2], array[0, 1]); AddBeamCap(vertices, list, list2, array[sections, 0], array[sections, 1], array[sections, 2], array[sections, 3]); Mesh val = new Mesh(); ((Object)val).name = sourceName + " continuous curved mesh"; Mesh val2 = val; val2.SetVertices(vertices); val2.SetUVs(0, list); val2.SetTriangles(list2, 0); val2.RecalculateNormals(); val2.RecalculateBounds(); return val2; } private static Vector3 BendPoint(float x, float y, float z, float radius) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) float num = x / radius; float num2 = radius - z; return new Vector3(Mathf.Sin(num) * num2, y, radius - Mathf.Cos(num) * num2); } private static void AddCurvedBeamStrip(List<Vector3> vertices, List<Vector2> uv, List<int> triangles, Vector3[,] rings, int sections, int first, int second) { //IL_001c: 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_0041: 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) int count = vertices.Count; for (int i = 0; i <= sections; i++) { float num = (float)i / (float)sections; vertices.Add(rings[i, first]); vertices.Add(rings[i, second]); uv.Add(new Vector2(num, 0f)); uv.Add(new Vector2(num, 1f)); } for (int j = 0; j < sections; j++) { int num2 = count + j * 2; int num3 = num2 + 2; AddQuad(triangles, num2, num2 + 1, num3 + 1, num3); } } private static void AddBeamCap(List<Vector3> vertices, List<Vector2> uv, List<int> triangles, Vector3 a, Vector3 b, Vector3 c, Vector3 d) { //IL_0008: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.Add(a); vertices.Add(b); vertices.Add(c); vertices.Add(d); uv.Add(new Vector2(0f, 0f)); uv.Add(new Vector2(1f, 0f)); uv.Add(new Vector2(1f, 1f)); uv.Add(new Vector2(0f, 1f)); AddQuad(triangles, count, count + 1, count + 2, count + 3); } private static void AddQuad(List<int> triangles, int a, int b, int c, int d) { triangles.Add(a); triangles.Add(b); triangles.Add(c); triangles.Add(a); triangles.Add(c); triangles.Add(d); } private static Mesh BendMesh(Mesh source, float radius) { Mesh val = Object.Instantiate<Mesh>(source); ((Object)val).name = ((Object)source).name + " curved"; Vector3[] vertices = val.vertices; for (int i = 0; i < vertices.Length; i++) { float num = vertices[i].x / radius; float z = vertices[i].z; vertices[i].x = Mathf.Sin(num) * (radius - z); vertices[i].z = radius - Mathf.Cos(num) * (radius - z); } val.vertices = vertices; val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void MakeCorner(GameObject first) { BuildFinalCornerModel(first.transform); } private static void BuildFinalCornerModel(Transform root) { //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_06cd: Unknown result type (might be due to invalid IL or missing references) Material val = null; Material val2 = null; Material val3 = null; Material val4 = null; Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val5 in componentsInChildren) { Renderer component = ((Component)val5).GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMaterial)) { if (((Object)val5).name.EndsWith(" outward rim", StringComparison.Ordinal)) { val = component.sharedMaterial; } else if (((Object)val5).name == "Basin bottom") { val2 = component.sharedMaterial; } else if (((Object)val5).name.EndsWith(" foot", StringComparison.Ordinal)) { val3 = component.sharedMaterial; } else if (((Object)val5).name == "VisibleFeed") { val4 = component.sharedMaterial; } } } if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4)) { return; } List<GameObject> list = new List<GameObject>(); Transform[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val6 in componentsInChildren2) { if ((Object)(object)val6 != (Object)(object)root && (Object)(object)val6.parent == (Object)(object)root) { list.Add(((Component)val6).gameObject); } } foreach (GameObject item in list) { Object.DestroyImmediate((Object)(object)item); } root.localPosition = Vector3.zero; root.localRotation = Quaternion.identity; root.localScale = Vector3.one; float num = 2.6f; float num2 = num - 0.65f; float num3 = 2.5f; AddJointCube(root, "Corner floor X", new Vector3(-1.375f, 0.385f, 0f), new Vector3(2.75f, 0.16f, 0.79f), Quaternion.identity, val2); AddJointCube(root, "Corner floor Z", new Vector3(0f, 0.385f, 1.375f), new Vector3(0.79f, 0.16f, 2.75f), Quaternion.identity, val2); AddJointCube(root, "Corner floor elbow", new Vector3(0.1975f, 0.385f, -0.1975f), new Vector3(0.395f, 0.16f, 0.395f), Quaternion.identity, val2); AddJointCube(root, "Outer wall X", new Vector3((0f - num) * 0.5f, 0.625f, -0.505f), new Vector3(num, 0.55f, 0.23f), Quaternion.identity, val); AddJointCube(root, "Outer wall Z", new Vector3(0.505f, 0.625f, num * 0.5f), new Vector3(0.23f, 0.55f, num), Quaternion.identity, val); AddJointCube(root, "Inner wall X", new Vector3((0f - (num + 0.65f)) * 0.5f, 0.625f, 0.505f), new Vector3(num2, 0.55f, 0.23f), Quaternion.identity, val); AddJointCube(root, "Inner wall Z", new Vector3(-0.505f, 0.625f, (num + 0.65f) * 0.5f), new Vector3(0.23f, 0.55f, num2), Quaternion.identity, val); AddJointCube(root, "Inner elbow structural post", new Vector3(-0.52f, 0.405f, 0.52f), new Vector3(0.26f, 0.99f, 0.26f), Quaternion.identity, val); AddJointCube(root, "Closed end X", new Vector3(-2.75f, 0.62f, 0f), new Vector3(0.3f, 0.58f, 1.3f), Quaternion.identity, val); AddJointCube(root, "Closed end Z", new Vector3(0f, 0.62f, 2.75f), new Vector3(1.3f, 0.58f, 0.3f), Quaternion.identity, val); AddMiteredOuterElbow(root, val); AddCornerSupportX(root, new Vector3(0f - num3, 0f, -0.39f), val3, val2, "Left end"); AddCornerSupportZ(root, new Vector3(0.39f, 0f, num3), val3, val2, "Right end"); AddCornerSupportElbow(root, val3, val2); AddJointCube(root, "Left inner end foot", new Vector3(0f - num3, 0.16f, 0.39f), new Vector3(0.34f, 0.36f, 0.27f), Quaternion.identity, val2); AddJointCube(root, "Left end cross support", new Vector3(0f - num3, 0.25f, 0f), new Vector3(0.25f, 0.16f, 1.05f), Quaternion.identity, val2); AddJointCube(root, "Left inner end iron band", new Vector3(0f - num3, 0.6f, 0.626f), new Vector3(0.1f, 0.58f, 0.025f), Quaternion.identity, val3); AddJointCube(root, "Right inner end foot", new Vector3(-0.39f, 0.16f, num3), new Vector3(0.27f, 0.36f, 0.34f), Quaternion.identity, val2); AddJointCube(root, "Right end cross support", new Vector3(0f, 0.25f, num3), new Vector3(1.05f, 0.16f, 0.25f), Quaternion.identity, val2); AddJointCube(root, "Right inner end iron band", new Vector3(-0.626f, 0.6f, num3), new Vector3(0.025f, 0.58f, 0.1f), Quaternion.identity, val3); float[] array = new float[2] { -0.65f, -2.05f }; foreach (float num4 in array) { AddExteriorCrossX(root, new Vector3(num4, 0.66f, -0.626f), val3, "Outer X wall brace"); } float[] array2 = new float[2] { -1.1f, -1.92f }; foreach (float num5 in array2) { AddExteriorCrossX(root, new Vector3(num5, 0.66f, 0.626f), val3, "Inner wall outer-face brace"); } float[] array3 = new float[2] { 0.65f, 2.05f }; foreach (float num6 in array3) { AddExteriorCrossZ(root, new Vector3(0.626f, 0.66f, num6), val3, "Outer Z wall brace"); } float[] array4 = new float[2] { 1.1f, 1.92f }; foreach (float num7 in array4) { AddExteriorCrossZ(root, new Vector3(-0.626f, 0.66f, num7), val3, "Inner wall outer-face brace"); } CreateLFeedSurface(root, val4).SetActive(false); } private static GameObject CreateLFeedSurface(Transform root, Material material) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_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_0145: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown GameObject val = new GameObject("VisibleFeed"); val.transform.SetParent(root, false); Vector3[] vertices = (Vector3[])(object)new Vector3[8] { new Vector3(-2.6f, 0.75f, -0.37f), new Vector3(0.37f, 0.75f, -0.37f), new Vector3(0.37f, 0.75f, 0.37f), new Vector3(-2.6f, 0.75f, 0.37f), new Vector3(-0.37f, 0.75f, 0.37f), new Vector3(0.37f, 0.75f, 0.37f), new Vector3(0.37f, 0.75f, 2.6f), new Vector3(-0.37f, 0.75f, 2.6f) }; Vector2[] uv = (Vector2[])(object)new Vector2[8] { new Vector2(0f, 0f), new Vector2(4f, 0f), new Vector2(4f, 1f), new Vector2(0f, 1f), new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 4f), new Vector2(0f, 4f) }; int[] triangles = new int[12] { 0, 2, 1, 0, 3, 2, 4, 6, 5, 4, 7, 6 }; Mesh val2 = new Mesh(); ((Object)val2).name = "AFT continuous L-shaped feed surface"; Mesh val3 = val2; val3.vertices = vertices; val3.uv = uv; val3.triangles = triangles; val3.RecalculateNormals(); val3.RecalculateBounds(); val.AddComponent<MeshFilter>().sharedMesh = val3; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material; return val; } private static GameObject AddMiteredOuterElbow(Transform root, Material material) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) //IL_0052: 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_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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0141: 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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Expected O, but got Unknown Vector2[] array = (Vector2[])(object)new Vector2[5] { new Vector2(0f, -0.62f), new Vector2(0.62f, -0.62f), new Vector2(0.62f, 0f), new Vector2(0.39f, 0f), new Vector2(0f, -0.39f) }; List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); for (int i = 0; i < array.Length; i++) { list.Add(new Vector3(array[i].x, 0.35f, array[i].y)); list2.Add(new Vector2(array[i].x / 0.62f, (array[i].y + 0.62f) / 0.62f)); } for (int j = 0; j < array.Length; j++) { list.Add(new Vector3(array[j].x, 0.9f, array[j].y)); list2.Add(new Vector2(array[j].x / 0.62f, (array[j].y + 0.62f) / 0.62f)); } for (int k = 1; k < array.Length - 1; k++) { list3.Add(0); list3.Add(k); list3.Add(k + 1); list3.Add(array.Length); list3.Add(array.Length + k + 1); list3.Add(array.Length + k); } for (int l = 0; l < array.Length; l++) { int num = (l + 1) % array.Length; int count = list.Count; list.Add(new Vector3(array[l].x, 0.9f, array[l].y)); list.Add(new Vector3(array[num].x, 0.9f, array[num].y)); list.Add(new Vector3(array[num].x, 0.35f, array[num].y)); list.Add(new Vector3(array[l].x, 0.35f, array[l].y)); list2.Add(new Vector2(0f, 1f)); list2.Add(new Vector2(1f, 1f)); list2.Add(new Vector2(1f, 0f)); list2.Add(new Vector2(0f, 0f)); AddQuad(list3, count, count + 1, count + 2, count + 3); } Mesh val = new Mesh(); ((Object)val).name = "AFT mitered outer elbow mesh"; Mesh val2 = val; val2.SetVertices(list); val2.SetUVs(0, list2); val2.SetTriangles(list3, 0); val2.RecalculateNormals(); val2.RecalculateBounds(); GameObject val3 = new GameObject("Mitered outer elbow timber"); val3.transform.SetParent(root, false); val3.AddComponent<MeshFilter>().sharedMesh = val2; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = material; return val3; } private static void AddCornerSupportX(Transform root, Vector3 anchor, Material iron, Material support, string label) { //IL_001e: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_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) AddJointCube(root, label + " foot", new Vector3(anchor.x, 0.16f, -0.39f), new Vector3(0.34f, 0.36f, 0.27f), Quaternion.identity, support); AddJointCube(root, label + " flush iron band", new Vector3(anchor.x, 0.6f, -0.626f), new Vector3(0.1f, 0.58f, 0.025f), Quaternion.identity, iron); } private static void AddCornerSupportZ(Transform root, Vector3 anchor, Material iron, Material support, string label) { //IL_001e: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_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) AddJointCube(root, label + " foot", new Vector3(0.39f, 0.16f, anchor.z), new Vector3(0.27f, 0.36f, 0.34f), Quaternion.identity, support); AddJointCube(root, label + " flush iron band", new Vector3(0.626f, 0.6f, anchor.z), new Vector3(0.025f, 0.58f, 0.1f), Quaternion.identity, iron); } private static void AddCornerSupportElbow(Transform root, Material iron, Material support) { //IL_0015: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0089: 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_00a2: Unknown result type (might be due to invalid IL or missing references) AddJointCube(root, "Elbow foot", new Vector3(0.46f, 0.14f, -0.46f), new Vector3(0.28f, 0.34f, 0.28f), Quaternion.identity, iron); AddJointCube(root, "Elbow flush band X", new Vector3(0.39f, 0.6f, -0.626f), new Vector3(0.1f, 0.58f, 0.025f), Quaternion.identity, iron); AddJointCube(root, "Elbow flush band Z", new Vector3(0.626f, 0.6f, -0.39f), new Vector3(0.025f, 0.58f, 0.1f), Quaternion.identity, iron); } private static void AddExteriorCrossX(Transform root, Vector3 center, Material iron, string label) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) AddJointCube(root, label + " A", center, new Vector3(0.055f, 0.36f, 0.018f), Quaternion.Euler(0f, 0f, 38f), iron); AddJointCube(root, label + " B", center, new Vector3(0.055f, 0.36f, 0.018f), Quaternion.Euler(0f, 0f, -38f), iron); } private static void AddExteriorCrossZ(Transform root, Vector3 center, Material iron, string label) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) AddJointCube(root, label + " A", center, new Vector3(0.018f, 0.36f, 0.055f), Quaternion.Euler(38f, 0f, 0f), iron); AddJointCube(root, label + " B", center, new Vector3(0.018f, 0.36f, 0.055f), Quaternion.Euler(-38f, 0f, 0f), iron); } private static GameObject AddJointCube(Transform parent, string name, Vector3 position, Vector3 scale, Quaternion rotation, Material material) { //IL_0021: 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_0039: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)val).name = name; val.transform.SetParent(parent, false); val.transform.localPosition = position; val.transform.localScale = scale; val.transform.localRotation = rotation; Object.DestroyImmediate((Object)(object)val.GetComponent<Collider>()); val.GetComponent<Renderer>().sharedMaterial = material; return val; } } internal static class TroughVariantIcons { private static readonly Dictionary<TroughVariant, Sprite> Icons = new Dictionary<TroughVariant, Sprite>(); internal static Sprite Create(TroughVariant variant) { //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) if (Icons.TryGetValue(variant, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } switch (variant) { case TroughVariant.Standard: return Icons[variant] = TroughModelV3.CreateIcon(); case TroughVariant.Compact: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconCompact", "Compact Feeding Trough build icon"); case TroughVariant.Small: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconSmall", "Small Animal Feeding Trough build icon"); case TroughVariant.Curved: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconCurved", "Curved Feeding Trough build icon"); case TroughVariant.CurvedCompact: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconCurvedCompact", "Compact Curved Feeding Trough build icon"); case TroughVariant.CurvedTiny: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconCurvedTiny", "Tiny Curved Feeding Trough build icon"); case TroughVariant.Corner: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconCorner", "Corner Feeding Trough build icon"); case TroughVariant.CornerCompact: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconCornerCompact", "Compact Corner Feeding Trough build icon"); case TroughVariant.CornerTiny: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconCornerTiny", "Tiny Corner Feeding Trough build icon"); case TroughVariant.ChickenBowl: return Icons[variant] = TroughModelV3.CreateIcon("AnimalFeedingTroughV3.IconChickenBowl", "Chicken Feeding Bowl build icon"); default: { try { value = RenderModelIcon(variant); if (Object.op_Implicit((Object)(object)value)) { Icons[variant] = value; return value; } } catch (Exception ex) { Debug.LogWarning((object)string.Concat("[Animal Feeding Trough] Could not render the ", variant, " build icon; using the safe embedded fallback. ", ex.Message)); } Sprite val = TroughModelV3.CreateIcon(); Texture2D texture = val.texture; int width = ((Texture)texture).width; int height = ((Texture)texture).height; Texture2D val2 = new Texture2D(width, height, (TextureFormat)4, false); ((Object)val2).name = string.Concat("Animal Feeding Trough ", variant, " build icon"); Color[] pixels = texture.GetPixels(); Color val3 = default(Color); ((Color)(ref val3))..ctor(0f, 0f, 0f, 0f); float num = TroughVariantGeometry.LengthScale(variant); float num2 = ((variant == TroughVariant.Small) ? 0.74f : 1f); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { float num3 = ((float)j - (float)width * 0.5f) / Mathf.Max(0.01f, num) + (float)width * 0.5f; float num4 = ((float)i - (float)height * 0.5f) / num2 + (float)height * 0.5f; Color val4 = val3; if (num3 >= 0f && num3 < (float)width && num4 >= 0f && num4 < (float)height) { val4 = pixels[Mathf.Clamp((int)num4, 0, height - 1) * width + Mathf.Clamp((int)num3, 0, width - 1)]; } val2.SetPixel(j, i, val4); } } val2.Apply(false, false); ((Texture)val2).wrapMode = (TextureWrapMode)1; value = Sprite.Create(val2, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), (float)width); Icons[variant] = value; return value; } } } private static Sprite RenderModelIcon(TroughVariant variant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Expected O, but got Unknown //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Expected O, but got Unknown //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Expected O, but got Unknown //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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_0454: Expected O, but got Unknown //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) if ((int)SystemInfo.graphicsDeviceType == 4) { return null; } GameObject val = new GameObject("xneliox_IconStage_" + variant); AssetBundleTroughModel.Instantiate(val.transform, variant); Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { ((Component)val2).gameObject.layer = 31; if (((Object)val2).name == "VisibleFeed") { ((Component)val2).gameObject.SetActive(true); } } Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(true); if (componentsInChildren2.Length == 0) { Object.DestroyImmediate((Object)(object)val); return null; } Bounds bounds = componentsInChildren2[0].bounds; for (int j = 1; j < componentsInChildren2.Length; j++) { ((Bounds)(ref bounds)).Encapsulate(componentsInChildren2[j].bounds); } GameObject val3 = new GameObject("xneliox_IconCamera"); Camera val4 = val3.AddComponent<Camera>(); val4.cullingMask = int.MinValue; val4.clearFlags = (CameraClearFlags)2; val4.backgroundColor = new Color(0f, 0f, 0f, 0f); val4.orthographic = true; switch (variant) { case TroughVariant.ChickenBowl: val4.orthographicSize = Mathf.Max(((Bounds)(ref bounds)).extents.y * 2.1f, Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z) * 0.88f) + 0.1f; ((Component)val4).transform.position = ((Bounds)(ref bounds)).center + new Vector3(6f, 4f, -7f); ((Component)val4).transform.LookAt(((Bounds)(ref bounds)).center + Vector3.up * 0.015f); break; case TroughVariant.Corner: case TroughVariant.CornerCompact: case TroughVariant.CornerTiny: val4.orthographicSize = Mathf.Max(((Bounds)(ref bounds)).extents.y * 1.9f, Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z) * 0.96f) + 0.24f; ((Component)val4).transform.position = ((Bounds)(ref bounds)).center + new Vector3(-6f, 4f, 7f); ((Component)val4).transform.LookAt(((Bounds)(ref bounds)).center + Vector3.up * 0.035f); break; default: val4.orthographicSize = Mathf.Max(((Bounds)(ref bounds)).extents.y * 1.7f, Mathf.Max(((Bounds)(ref bounds)).extents.x, ((Bounds)(ref bounds)).extents.z) * 0.72f) + 0.18f; ((Component)val4).transform.position = ((Bounds)(ref bounds)).center + new Vector3(6f, 4f, -7f); ((Component)val4).transform.LookAt(((Bounds)(ref bounds)).center + Vector3.up * 0.04f); break; } GameObject val5 = new GameObject("xneliox_IconLight"); Light val6 = val5.AddComponent<Light>(); val6.type = (LightType)1; val6.intensity = 1.25f; val6.cullingMask = int.MinValue; val5.transform.rotation = Quaternion.Euler(42f, -35f, 0f); RenderTexture val7 = new RenderTexture(256, 256, 24, (RenderTextureFormat)0); val7.antiAliasing = 4; val4.targetTexture = val7; RenderTexture active = RenderTexture.active; val4.Render(); RenderTexture.active = val7; Texture2D val8 = new Texture2D(256, 256, (TextureFormat)4, false); ((Object)val8).name = string.Concat("Animal Feeding Trough ", variant, " current model icon v2"); val8.ReadPixels(new Rect(0f, 0f, 256f, 256f), 0, 0); val8.Apply(false, false); bool[] array = new bool[componentsInChildren2.Length]; for (int k = 0; k < componentsInChildren2.Length; k++) { array[k] = componentsInChildren2[k].enabled; componentsInChildren2[k].enabled = array[k] && IsDarkIconDetail(((Object)((Component)componentsInChildren2[k]).transform).name); } val4.Render(); RenderTexture.active = val7; Texture2D val9 = new Texture2D(256, 256, (TextureFormat)4, false); val9.ReadPixels(new Rect(0f, 0f, 256f, 256f), 0, 0); val9.Apply(false, false); for (int l = 0; l < componentsInChildren2.Length; l++) { componentsInChildren2[l].enabled = array[l]; } MatchNormalTroughIconColors(val8, val9); Object.DestroyImmediate((Object)(object)val9); ((Texture)val8).wrapMode = (TextureWrapMode)1; RenderTexture.active = active; val4.targetTexture = null; Object.DestroyImmediate((Object)(object)val7); Object.DestroyImmediate((Object)(object)val5); Object.DestroyImmediate((Object)(object)val3); Object.DestroyImmediate((Object)(object)val); return Sprite.Create(val8, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f), 256f); } private static bool IsDarkIconDetail(string name) { string text = name.ToLowerInvariant(); if (!text.Contains("foot") && !text.Contains("iron") && !text.Contains("band") && !text.Contains("brace") && !text.Contains("rune")) { return text.Contains("cross support"); } return true; } private static void MatchNormalTroughIconColors(Texture2D texture, Texture2D detailMask) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Color[] pixels = texture.GetPixels(); Color[] pixels2 = detailMask.GetPixels(); for (int i = 0; i < pixels.Length; i++) { Color val = pixels[i]; if (!(val.a <= 0.01f)) { float num = Mathf.Clamp01(val.r * 0.3f + val.g * 0.59f + val.b * 0.11f); if (pixels2[i].a > 0.02f) { pixels[i] = val; continue; } float num2 = Mathf.Pow(num, 0.98f); ref Color reference = ref pixels[i]; reference = new Color(Mathf.Clamp01(0.055f + num2 * 0.76f), Mathf.Clamp01(0.035f + num2 * 0.46f), Mathf.Clamp01(0.02f + num2 * 0.25f), val.a); } } texture.SetPixels(pixels); texture.Apply(false, false); } } public sealed class TroughFeeder : MonoBehaviour { private const float AttractionRange = 16f; private const string ServingMarker = "xneliox_trough_serving"; private static readonly MethodInfo CanConsumeMethod = AccessTools.Method(typeof(MonsterAI), "CanConsume", (Type[])null, (Type[])null); private static readonly MethodInfo InventoryChangedMethod = AccessTools.Method(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null); private static readonly MethodInfo ContainerSaveMethod = AccessTools.Method(typeof(Container), "Save", (Type[])null, (Type[])null); private static readonly FieldInfo ConsumeTargetField = AccessTools.Field(typeof(MonsterAI), "m_consumeTarget"); private static readonly FieldInfo ConsumeSearchTimerField = AccessTools.Field(typeof(MonsterAI), "m_consumeSearchTimer"); private Container _container; private ZNetView _view; private readonly List<GameObject> _visibleFeeds = new List<GameObject>(); private float _nextSearch; private float _nextVisualRefresh; private TroughVariant _variant; private float _lengthScale = 1f; private ItemDrop _currentServing; internal void SetVariant(TroughVariant variant) { _variant = variant; _lengthScale = TroughVariantGeometry.LengthScale(variant); } private void Awake() { _container = ((Component)this).GetComponent<Container>(); _view = ((Component)this).GetComponent<ZNetView>(); _visibleFeeds.Clear(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "VisibleFeed") { _visibleFeeds.Add(((Component)val).gameObject); } } } private void Update() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) RefreshFeedVisual(); if (!Object.op_Implicit((Object)(object)_container) || !Object.op_Implicit((Object)(object)_view) || !_view.IsValid() || Time.time < _nextSearch) { return; } _nextSearch = Time.time + 2f; EnableTroughSearchForOwnedAnimals(); if (!_view.IsOwner()) { return; } if (Object.op_Implicit((Object)(object)_currentServing)) { ZNetView component = ((Component)_currentServing).GetComponent<ZNetView>(); if (_currentServing.m_itemData != null && _currentServing.m_itemData.m_stack > 0 && Object.op_Implicit((Object)(object)component) && component.IsValid()) { return; } _currentServing = null; } List<Character> allCharacters = Character.GetAllCharacters(); foreach (Character item in allCharacters) { if (!Object.op_Implicit((Object)(object)item)) { continue; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position); if (num > 16f) { continue; } Tameable component2 = ((Component)item).GetComponent<Tameable>(); MonsterAI component3 = ((Component)item).GetComponent<MonsterAI>(); if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component3) && CanUseTrough(item, component2)) { ItemData val = FindFood(component3); if (val != null) { SpawnServing(val, item); break; } } } } private void EnableTroughSearchForOwnedAnimals() { //IL_002c: 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) List<Character> allCharacters = Character.GetAllCharacters(); foreach (Character item in allCharacters) { if (!Object.op_Implicit((Object)(object)item)) { continue; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)item).transform.position); if (num > 16f) { continue; } Tameable component = ((Component)item).GetComponent<Tameable>(); MonsterAI component2 = ((Component)item).GetComponent<MonsterAI>(); ZNetView component3 = ((Component)item).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component3) && component3.IsValid() && CanUseTrough(item, component) && component3.IsOwner()) { ItemData val = FindFood(component2); if (val != null && component2.m_consumeSearchRange < 16f) { component2.m_consumeSearchRange = 16f; } } } } private static bool CanUseTrough(Character character, Tameable tameable) { if (!Object.op_Implicit((Object)(object)character) || !Object.op_Implicit((Object)(object)tameable) || !tameable.IsHungry()) { return false; } return true; } private void SpawnServing(ItemData food, Character animal) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) if (food == null || (Object)(object)animal == (Object)null || (Object)(object)_container == (Object)null || _container.GetInventory() == null) { return; } Vector3 val = ((Component)this).transform.InverseTransformPoint(((Component)animal).transform.position); float[] array = ((_variant == TroughVariant.Small || _variant == TroughVariant.CurvedTiny) ? new float[3] { -0.65f * _lengthScale, 0f, 0.65f * _lengthScale } : new float[4] { -1.65f * _lengthScale, -0.55f * _lengthScale, 0.55f * _lengthScale, 1.65f * _lengthScale }); float num = array[0]; float num2 = Mathf.Abs(val.x - num); float[] array2 = array; foreach (float num3 in array2) { float num4 = Mathf.Abs(val.x - num3); if (num4 < num2) { num2 = num4; num = num3; } } float num5 = ((!(val.z < 0f)) ? 1f : (-1f)); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(num, 0.12f, num5 * 0.95f); if (_variant == TroughVariant.Compact) { val2.z = num5 * 0.78f; } if (_variant == TroughVariant.Small) { val2.z = num5 * 0.7f; } if (_variant == TroughVariant.Curved || _variant == TroughVariant.CurvedCompact || _variant == TroughVariant.CurvedTiny) { float num6 = ((_variant == TroughVariant.CurvedTiny) ? 3.25f : ((_variant == TroughVariant.CurvedCompact) ? 4.8f : 6.5f)); if (_variant == TroughVariant.CurvedTiny) { val2.z = num5 * 0.68f; } float num7 = num / num6; val2.x = Mathf.Sin(num7) * (num6 - val2.z); val2.z = num6 - Mathf.Cos(num7) * (num6 - val2.z); } if (_variant == TroughVariant.Corner || _variant == TroughVariant.CornerCompact || _variant == TroughVariant.CornerTiny) { float num8 = ((_variant == TroughVariant.Corner) ? 0.95f : ((_variant == TroughVariant.CornerCompact) ? 0.68f : 0.49f)); float num9 = ((_variant == TroughVariant.Corner) ? 1.25f : ((_variant == TroughVariant.CornerCompact) ? 0.9f : 0.65f)); val2.z = num5 * num8; if (Mathf.Abs(val.z) > Mathf.Abs(val.x)) { ((Vector3)(ref val2))..ctor(num5 * num8, 0.12f, num + num9); } } if (_variant == TroughVariant.ChickenBowl) { Vector3 forward = default(Vector3); ((Vector3)(ref forward))..ctor(val.x, 0f, val.z); if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); val2 = forward * 0.78f; val2.y = 0.08f; } Vector3 val3 = ((Component)this).transform.TransformPoint(val2); ItemData val4 = food.Clone(); val4.m_stack = 1; ItemDrop val5 = ItemDrop.DropItem(val4, 1, val3, Quaternion.identity); if (!Object.op_Implicit((Object)(object)val5)) { Debug.LogWarning((object)"[Animal Feeding Trough] Could not create a food serving."); return; } _currentServing = val5; MonsterAI component = ((Component)animal).GetComponent<MonsterAI>(); ZNetView component2 = ((Component)animal).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && component2.IsValid() && component2.IsOwner()) { component.m_consumeSearchRange = Mathf.Max(component.m_consumeSearchRange, 16f); if (ConsumeTargetField != null) { ConsumeTargetField.SetValue(component, val5); } if (ConsumeSearchTimerField != null) { ConsumeSearchTimerField.SetValue(component, 0f); } } ZNetView component3 = ((Component)val5).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component3) && component3.IsValid() && component3.IsOwner()) { component3.GetZDO().Set("xneliox_trough_serving", true); } Renderer[] componentsInChildren = ((Component)val5).GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren) { val6.enabled = false; } ParticleSystem[] componentsInChildren2 = ((Component)val5).GetComponentsInChildren<ParticleSystem>(true); foreach (ParticleSystem val7 in componentsInChildren2) { val7.Stop(true, (ParticleSystemStopBehavior)0); Renderer component4 = ((Component)val7).GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component4)) { component4.enabled = false; } } Light[] componentsInChildren3 = ((Component)val5).GetComponentsInChildren<Light>(true); foreach (Light val8 in componentsInChildren3) { ((Behaviour)val8).enabled = false; } Inventory inventory = _container.GetInventory(); inventory.RemoveItem(food, 1); if (InventoryChangedMethod != null) { InventoryChangedMethod.Invoke(inventory, new object[2] { false, false }); } if (ContainerSaveMethod != null) { ContainerSaveMethod.Invoke(_container, null); } } private void RefreshFeedVisual() { if (_visibleFeeds.Count == 0 || Time.time < _nextVisualRefresh) { return; } _nextVisualRefresh = Time.time + 0.35f; bool active = false; if (Object.op_Implicit((Object)(object)_container) && _container.GetInventory() != null) { foreach (ItemData allItem in _container.GetInventory().GetAllItems()) { if (allItem != null && allItem.m_stack > 0 && TroughFoodRules.IsFood(allItem)) { active = true; break; } } } if (Object.op_Implicit((Object)(object)_currentServing) && _currentServing.m_itemData != null && _currentServing.m_itemData.m_stack > 0) { active = true; } foreach (GameObject visibleFeed in _visibleFeeds) { if (Object.op_Implicit((Object)(object)visibleFeed)) { visibleFeed.SetActive(active); } } } private ItemData FindFood(MonsterAI ai) { if ((Object)(object)ai == (Object)null || (Object)(object)_container == (Object)null) { return null; } Inventory inventory = _container.GetInventory(); if (inventory == null) { return null; } foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem != null && allItem.m_stack > 0 && !(CanConsumeMethod == null)) { object obj = CanConsumeMethod.Invoke(ai, new object[1] { allItem }); if (obj is bool && (bool)obj) { return allItem; } } } return null; } } internal static class TroughModelV3 { internal const string RootName = "AnimalFeedingTroughModelV3"; internal const string FeedName = "VisibleFeed"; private const string WoodResource = "AnimalFeedingTroughV3.Wood"; private const string MetalResource = "AnimalFeedingTroughV3.Metal"; private const string FeedResource = "AnimalFeedingTroughV3.Feed"; private const string IconResource = "AnimalFeedingTroughV3.Icon"; private static Material _wood; private static Material _darkWood; private static Material _iron; private static Material _feed; internal static void Build(Transform parent, Shader fallbackShader) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001b: 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_0031: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: 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_0272: 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_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("AnimalFeedingTroughModelV3"); Transform transform = val.transform; transform.SetParent(parent, false); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; Shader val2 = Shader.Find("Standard") ?? fallbackShader; if (!Object.op_Implicit((Object)(object)val2)) { throw new InvalidOperationException("No supported shader is available for the feeding trough."); } _wood = CreateMaterial("AFT V3 - aged oak", val2, "AnimalFeedingTroughV3.Wood", Color.white, 0f, 0.22f, new Vector2(2.15f, 0.135f), new Vector2(0f, 0.335f)); _darkWood = CreateMaterial("AFT V3 - carved oak", val2, "AnimalFeedingTroughV3.Wood", new Color(0.47f, 0.39f, 0.31f, 1f), 0f, 0.16f, new Vector2(2.15f, 0.135f), new Vector2(0f, 0.335f)); _iron = CreateMaterial("AFT V3 - forged iron", val2, "AnimalFeedingTroughV3.Metal", new Color(0.58f, 0.6f, 0.61f, 1f), 0.72f, 0.28f, Vector2.one, Vector2.zero); _feed = CreateMaterial("AFT V3 - straw vegetables and berries", val2, "AnimalFeedingTroughV3.Feed", Color.white, 0f, 0.12f, Vector2.one, Vector2.zero); CreateBeam(transform, "Front solid oak wall", new Vector3(0f, 0.625f, -0.505f), 4.92f, 0.55f, 0.23f, 0.045f, Quaternion.identity, _wood, 3.6f); CreateBeam(transform, "Rear solid oak wall", new Vector3(0f, 0.625f, 0.505f), 4.92f, 0.55f, 0.23f, 0.045f, Quaternion.identity, _wood, 3.6f); CreateBeam(transform, "Solid basin floor", new Vector3(0f, 0.385f, 0f), 4.72f, 0.16f, 0.79f, 0.035f, Quaternion.identity, _darkWood, 3.5f); Quaternion rotation = Quaternion.Euler(0f, 90f, 0f); CreateBeam(transform, "Closed left end", new Vector3(-2.48f, 0.62f, 0f), 1.18f, 0.58f, 0.3f, 0.05f, rotation, _wood, 0.9f); CreateBeam(transform, "Closed right end", new Vector3(2.48f, 0.62f, 0f), 1.18f, 0.58f, 0.3f, 0.05f, rotation, _wood, 0.9f); CreateBeam(transform, "Left wooden locking peg", new Vector3(-2.665f, 0.61f, 0f), 0.13f, 0.17f, 0.17f, 0.025f, Quaternion.identity, _darkWood, 0.25f); CreateBeam(transform, "Right wooden locking peg", new Vector3(2.665f, 0.61f, 0f), 0.13f, 0.17f, 0.17f, 0.025f, Quaternion.identity, _darkWood, 0.25f); float[] array = new float[3] { -2.02f, 0f, 2.02f }; foreach (float num in array) { CreateBeam(transform, "Cross support", new Vector3(num, 0.255f, 0f), 1.17f, 0.15f, 0.23f, 0.025f, rotation, _darkWood, 0.9f); CreateBeam(transform, "Front foot", new Vector3(num, 0.13f, -0.4f), 0.43f, 0.28f, 0.31f, 0.035f, Quaternion.Euler(-7f, 0f, 0f), _wood, 0.7f); CreateBeam(transform, "Rear foot", new Vector3(num, 0.13f, 0.4f), 0.43f, 0.28f, 0.31f, 0.035f, Quaternion.Euler(7f, 0f, 0f), _wood, 0.7f); CreateBeam(transform, "Front flush iron band", new Vector3(num, 0.625f, -0.626f), 0.54f, 0.105f, 0.028f, 0.012f, Quaternion.Euler(0f, 0f, 90f), _iron, 0.55f); CreateBeam(transform, "Rear flush iron band", new Vector3(num, 0.625f, 0.626f), 0.54f, 0.105f, 0.028f, 0.012f, Quaternion.Euler(0f, 0f, 90f), _iron, 0.55f); CreateBeam(transform, "Top flush iron band", new Vector3(num, 0.905f, 0f), 1.15f, 0.055f, 0.105f, 0.012f, rotation, _iron, 0.9f); } AddCarvedRunes(transform, -0.626f, reverse: false); AddCarvedRunes(transform, 0.626f, reverse: true); GameObject val3 = CreateFeedSurface(transform); val3.SetActive(false); } private static void AddCarvedRunes(Transform root, float z, bool reverse) { //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_0087: 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) float[] array = new float[6] { -1.54f, -1.12f, -0.7f, 0.7f, 1.12f, 1.54f }; foreach (float num in array) { float num2 = (reverse ? (-1f) : 1f); CreateBeam(root, "Shallow carved rune", new Vector3(num, 0.61f, z), 0.26f, 0.042f, 0.016f, 0.006f, Quaternion.Euler(0f, 0f, 38f * num2), _darkWood, 0.25f); CreateBeam(root, "Shallow carved rune", new Vector3(num, 0.61f, z), 0.26f, 0.042f, 0.016f, 0.006f, Quaternion.Euler(0f, 0f, -38f * num2), _darkWood, 0.25f); } } private static GameObject CreateFeedSurface(Transform root) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown GameObject val = new GameObject("VisibleFeed"); val.transform.SetParent(root, false); int num = 49; List<Vector3> list = new List<Vector3>(539); List<Vector3> list2 = new List<Vector3>(539); List<Vector2> list3 = new List<Vector2>(539); List<int> list4 = new List<int>(2880); for (int i = 0; i <= 10; i++) { float num2 = (float)i / 10f; for (int j = 0; j <= 48; j++) { float num3 = (float)j / 48f; float num4 = Mathf.Sin(num3 * (float)Math.PI) * Mathf.Sin(num2 * (float)Math.PI); float num5 = 0.012f * num4 * (Mathf.Sin((float)j * 1.31f + (float)i * 0.73f) + Mathf.Sin((float)j * 0.43f - (float)i * 1.19f)); list.Add(new Vector3((num3 - 0.5f) * 4.53f, 0.76f + 0.1f * num4 + num5, (num2 - 0.5f) * 0.69f)); list2.Add(Vector3.up); list3.Add(new Vector2(num3 * 6.55f, num2)); } } for (int k = 0; k < 10; k++) { for (int l = 0; l < 48; l++) { int num6 = k * num + l; int num7 = num6 + num; list4.Add(num6); list4.Add(num7); list4.Add(num6 + 1); list4.Add(num6 + 1); list4.Add(num7); list4.Add(num7 + 1); } } Mesh val2 = new Mesh(); ((Object)val2).name = "AFT V3 continuous feed surface"; Mesh val3 = val2; val3.SetVertices(list); val3.SetNormals(list2); val3.SetUVs(0, list3); val3.SetTriangles(list4, 0); val3.RecalculateNormals(); val3.RecalculateBounds(); val.AddComponent<MeshFilter>().sharedMesh = val3; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = _feed; return val; } private static GameObject CreateBeam(Transform parent, string name, Vector3 position, float length, float height, float depth, float bevel, Quaternion rotation, Material material, float uvLength) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = position; val.transform.localRotation = rotation; val.AddComponent<MeshFilter>().sharedMesh = BuildBevelledBeamMesh(name + " mesh", length, height, depth, bevel, uvLength); ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material; return val; } private static Mesh BuildBevelledBeamMesh(string name, float length, float height, float depth, float bevel, float uvLength) { //IL_0045: 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_005d: 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) //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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown float num =
plugins/Build_Camera/Build Camera.dll
Decompiled 6 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Atze's Build Camera")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Atze Tools")] [assembly: AssemblyProduct("Atze's Build Camera")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3302621-009c-4bfc-872c-e1107b202d3d")] [assembly: AssemblyFileVersion("2.4.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("2.4.1.0")] namespace Valheim_Build_Camera; [HarmonyPatch] public class cam { [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] [HarmonyPrefix] public static void updateCamera(ref GameCamera __instance, ref bool __runOriginal) { if (gosub.isInBuildMode()) { gosub.updateBuildCamera(Time.unscaledDeltaTime, ref __instance); __runOriginal = false; } else { __runOriginal = true; } } } [HarmonyPatch] public class drop { [HarmonyPatch(typeof(Piece), "DropResources")] [HarmonyPrefix] public static void dropToPlayer(ref Piece __instance) { //IL_0031: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) if (gosub.isInBuildMode() && (Object)(object)Player.m_localPlayer != (Object)null && load.getCfg.boolResourceToPlayer) { Vector3 position = ((Component)Player.m_localPlayer).transform.position; float num = 0.2f; Vector3 position2 = default(Vector3); ((Vector3)(ref position2))..ctor(position.x + Random.Range(0f - num, num), position.y + 0.1f, position.z + Random.Range(0f - num, num)); ((Component)__instance).transform.position = position2; } } } public class gosub { private struct BuildCameraView { public float x; public float y; } public struct nearbyCraftingStation { public Vector3 position; public float distance; public float rangeBuild; } public static bool isBuildMode = false; private static GameObject gadgetBuildCamera; private static BuildCameraView viewCam = new BuildCameraView { x = 0f, y = 0f }; public static bool isInBuildMode() { return Object.op_Implicit((Object)(object)Player.m_localPlayer) && isBuildMode; } public static void disableBuildMode(bool showInfo) { isBuildMode = false; GameCamera gc = GameCamera.instance; if ((Object)(object)GameCamera.instance != (Object)null) { setBuildGadget(ref gc); } if (showInfo && (Object)(object)Player.m_localPlayer != (Object)null) { ui.stateMessage.disableBuildCam(); } } public static void enableBuildMode() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_009b: Unknown result type (might be due to invalid IL or missing references) isBuildMode = true; GameCamera gc = GameCamera.instance; if ((Object)(object)GameCamera.instance != (Object)null) { setBuildGadget(ref gc); } if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((Character)Player.m_localPlayer).m_eye != (Object)null) { Quaternion rotation = ((Component)((Character)Player.m_localPlayer).m_eye).transform.rotation; float x = ((((Quaternion)(ref rotation)).eulerAngles.x > 180f) ? (-360f) : ((Quaternion)(ref rotation)).eulerAngles.x); viewCam.x = x; viewCam.y = ((Quaternion)(ref rotation)).eulerAngles.y; } if ((Object)(object)Player.m_localPlayer != (Object)null) { ui.stateMessage.enableBuildCam(); } } public static bool isLocalPlayer(in Player player) { return Object.op_Implicit((Object)(object)Player.m_localPlayer) && (Object)(object)player == (Object)(object)Player.m_localPlayer; } private static bool isTool(in ItemData itemData) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 int result; if (tools.toolSet.Contains(itemData?.m_shared.m_name)) { ItemData obj = itemData; result = ((obj != null && (int)obj.m_shared.m_itemType == 19) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } public static bool isToolEquipped(in Player player) { FieldInfo field = typeof(Player).GetField("m_rightItem", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy); object? value = field.GetValue(player); return isTool((ItemData)((value is ItemData) ? value : null)); } public static bool noToolEquipped(in Player player) { return !isToolEquipped(in player); } private static nearbyCraftingStation? getNearestBuildStation(in Vector3 playerOrCamera) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) FieldInfo field = typeof(CraftingStation).GetField("m_allStations", BindingFlags.Static | BindingFlags.NonPublic); if (!(field.GetValue(null) is List<CraftingStation> { Count: not 0 } list)) { return null; } List<nearbyCraftingStation> list2 = new List<nearbyCraftingStation>(); foreach (CraftingStation item in list) { list2.Add(new nearbyCraftingStation { position = ((Component)item).transform.position, distance = Vector3.Distance(((Component)item).transform.position, playerOrCamera), rangeBuild = item.m_rangeBuild }); } return list2.OrderBy((nearbyCraftingStation x) => x.distance).First(); } public static bool isBuildStationInRange(in Player player) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) nearbyCraftingStation? nearestBuildStation = getNearestBuildStation(((Component)player).transform.position); if (nearestBuildStation.HasValue) { nearbyCraftingStation valueOrDefault = nearestBuildStation.GetValueOrDefault(); if (true) { return valueOrDefault.distance <= valueOrDefault.rangeBuild; } } return false; } private static void stayNearWorkbench(ref GameCamera __instance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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) nearbyCraftingStation? nearestBuildStation = getNearestBuildStation(((Component)__instance).transform.position); if (nearestBuildStation.HasValue) { nearbyCraftingStation valueOrDefault = nearestBuildStation.GetValueOrDefault(); if (true) { if (valueOrDefault.distance > valueOrDefault.rangeBuild * load.getCfg.floatCamRangeMultier) { float num = valueOrDefault.distance - valueOrDefault.rangeBuild * load.getCfg.floatCamRangeMultier; Vector3 val = valueOrDefault.position - ((Component)__instance).transform.position; Vector3 val2 = num * ((Vector3)(ref val)).normalized; ((Component)__instance).transform.position = ((Component)__instance).transform.position + val2; } return; } } disableBuildMode(showInfo: true); } private static void stayNearGround(ref GameCamera __instance) { //IL_000d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) float num = default(float); if (ZoneSystem.instance.GetGroundHeight(((Component)__instance).transform.position, ref num) && ((Component)__instance).transform.position.y < num - load.getCfg.floatMaxGroundDive) { Vector3 position = ((Component)__instance).transform.position; position.y = num - load.getCfg.floatMaxGroundDive; ((Component)__instance).transform.position = position; } } private static Quaternion updateBuildCameraViewDirection(float dt) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (ZInput.IsMouseActive()) { float num = PlatformPrefs.GetFloat("MouseSensitivity", PlayerController.m_mouseSens); bool flag = PlatformPrefs.GetInt("InvertMouse", 0) == 1; Vector2 mouseDelta = ZInput.GetMouseDelta(); viewCam.y += num * mouseDelta.x; float num2 = ((!flag) ? 1 : (-1)); float num3 = viewCam.x - num2 * (num * mouseDelta.y); viewCam.x = Mathf.Clamp(num3, -89f, 89f); } if (ZInput.IsGamepadActive()) { PlayerController.cameraDirectionLock = Vector2.zero; if (ZInput.GetButton("JoyRotate")) { return Quaternion.Euler(0f, viewCam.y, 0f) * Quaternion.Euler(viewCam.x, 0f, 0f); } float num4 = PlatformPrefs.GetFloat("GamepadSensitivity", PlayerController.m_gamepadSens); bool flag2 = PlatformPrefs.GetInt("InvertMouse", 0) == 1; bool flag3 = PlatformPrefs.GetInt("InvertCameraX", 0) == 1; bool flag4 = PlatformPrefs.GetInt("InvertCameraY", flag2 ? 1 : 0) == 1; float num5 = (flag3 ? (-1f) : 1f); float num6 = (flag4 ? 1f : (-1f)); viewCam.y += ZInput.GetJoyRightStickX() * 110f * dt * num4 * num5; float num7 = viewCam.x - ZInput.GetJoyRightStickY() * 110f * dt * num4 * num6; viewCam.x = Mathf.Clamp(num7, -89f, 89f); } return Quaternion.Euler(0f, viewCam.y, 0f) * Quaternion.Euler(viewCam.x, 0f, 0f); } private static Vector3 untransformedMovementVector(float dt) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_0095: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0087: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; Vector3 forward = ((Component)GameCamera.instance).transform.forward; Vector3 right = ((Component)GameCamera.instance).transform.right; Vector3 up = Vector3.up; if (ZInput.GetButton("Left")) { val -= right; } if (ZInput.GetButton("Right")) { val += right; } if (ZInput.GetButton("Forward")) { val += forward; } if (ZInput.GetButton("Backward")) { val -= forward; } ((Vector3)(ref val)).Normalize(); val += right * ZInput.GetJoyLeftStickX(); val -= forward * ZInput.GetJoyLeftStickY(); if (ZInput.GetButton("Jump") || ZInput.GetButton("JoyJump")) { val += up; } if (ZInput.GetButton("Crouch") || ZInput.GetButton("JoyCrouch")) { val -= up; } float num = ((ZInput.GetButton("Run") || ZInput.GetButton("JoyRun")) ? ((Character)Player.m_localPlayer).m_runSpeed : ((Character)Player.m_localPlayer).m_walkSpeed); return val * (dt * num * load.getCfg.floatCamSpeedMultiplier); } public static void updateBuildCamera(float dt, ref GameCamera __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!ui.windowConfigs.isOpen && !Game.IsPaused() && !Menu.IsActive() && !Menu.IsVisible() && !Console.IsVisible() && !Hud.IsPieceSelectionVisible()) { Vector3 val = untransformedMovementVector(dt); Transform transform = ((Component)__instance).transform; transform.position += val; stayNearWorkbench(ref __instance); stayNearGround(ref __instance); ((Component)__instance).transform.rotation = updateBuildCameraViewDirection(dt); } } public static bool playerIsBlocked(Player p) { return ((Character)p).IsTeleporting() || p.IsSleeping() || ((Character)p).IsDead() || ((Character)p).InCutscene(); } private static void setBuildGadget(ref GameCamera gc) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (isBuildMode && (load.getCfg.boolBuildLight || load.getCfg.boolBuildDemist)) { if ((Object)(object)gadgetBuildCamera == (Object)null) { gadgetBuildCamera = new GameObject("BuildCamGadget"); gadgetBuildCamera.transform.SetParent(((Component)gc).transform, false); if (load.getCfg.boolBuildLight) { Light val = gadgetBuildCamera.AddComponent<Light>(); val.type = (LightType)0; val.spotAngle = load.getCfg.floatBuildLightFOV; val.intensity = load.getCfg.floatBuildLightIntensity; val.range = load.getCfg.floatBuildLightRange; } if (load.getCfg.boolBuildDemist) { GameObject val2 = new GameObject("BuildCamDemist"); val2.transform.SetParent(gadgetBuildCamera.transform, false); val2.transform.localPosition = new Vector3(0f, 0f, 1.5f); ParticleSystemForceField val3 = val2.AddComponent<ParticleSystemForceField>(); val3.shape = (ParticleSystemForceFieldShape)0; val3.startRange = Mathf.Clamp(load.getCfg.floatBuildDemistRange, 5f, 255f); val3.endRange = Mathf.Clamp(load.getCfg.floatBuildDemistRange, 5f, 255f) + 5f; val3.gravityFocus = 0.5f; Demister val4 = val2.AddComponent<Demister>(); val4.m_disableForcefieldDelay = 0f; } } } else if ((Object)(object)gadgetBuildCamera != (Object)null) { Object.Destroy((Object)(object)gadgetBuildCamera); gadgetBuildCamera = null; } } } [HarmonyPatch] public class menu { [HarmonyPatch(typeof(Menu), "IsVisible")] [HarmonyPrefix] public static bool isVisible(ref bool __result, ref bool __runOriginal) { if (ui.windowConfigs.isOpen) { __result = true; __runOriginal = false; return false; } return true; } [HarmonyPatch(typeof(Menu), "IsActive")] [HarmonyPrefix] public static bool isActive(ref bool __result, ref bool __runOriginal) { if (ui.windowConfigs.isOpen) { __result = true; __runOriginal = false; return false; } return true; } } public class pad { public class stateController { public static bool switchByController => (ZInput.GetButtonDown("JoyLBumper") && ZInput.GetButton("JoyLTrigger")) || (ZInput.GetButtonDown("JoyLTrigger") && ZInput.GetButton("JoyLBumper")); public static string txtButton => ((int)ZInput.CurrentGlyph == 2) ? "L1 + L2" : (((int)ZInput.CurrentGlyph == 3) ? "L + ZL" : (((int)ZInput.CurrentGlyph == 1) ? "LB + LT" : (((int)ZInput.ConnectedGamepadType == 5 || (int)ZInput.ConnectedGamepadType == 4) ? "L1 + L2" : (((int)ZInput.ConnectedGamepadType == 6) ? "L + ZL" : "LB + LT")))); } [HarmonyPatch] public class gameController { [HarmonyPatch(typeof(ZInput), "GetButtonDown")] [HarmonyPrefix] public static bool menuControllerHandle(string name, ref bool __result) { if (ui.windowConfigs.isOpen && name.StartsWith("Joy")) { __result = false; return false; } if (gosub.isInBuildMode() && (name == "JoyHide" || name == "JoyCrouch")) { __result = false; return false; } return true; } [HarmonyPatch(typeof(ZInput), "GetButton")] [HarmonyPrefix] public static bool blockHoldButtonsInBuildMode(string name, ref bool __result) { if (gosub.isInBuildMode() && (name == "JoyHide" || name == "JoyCrouch")) { __result = false; return false; } return true; } } } [HarmonyPatch] public class player { [HarmonyPrefix] [HarmonyPatch(typeof(Player), "UpdatePlacement")] public static void setRangePlayer(ref Player __instance) { __instance.m_maxPlaceDistance = load.getCfg.floatRangeBuildAvatar; } [HarmonyPatch(typeof(Player), "Update")] [HarmonyPrefix] public static void getPlayerItem(ref Player __instance, ref bool __runOriginal) { //IL_01c2: 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_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) if (gosub.isLocalPlayer(in __instance) && gosub.isInBuildMode()) { if (gosub.noToolEquipped(in __instance)) { gosub.disableBuildMode(showInfo: true); __runOriginal = true; return; } __runOriginal = false; if (!Traverse.Create((object)__instance).Method("TakeInput", Array.Empty<object>()).GetValue<bool>()) { return; } for (int i = 1; i <= 8; i++) { if (ZInput.GetButtonDown($"Hotbar{i}") || ZInput.GetButtonDown($"Hotbar{i}Alt")) { __instance.UseHotbarItem(i); } } if (ZInput.GetButton("Hide")) { MethodInfo methodInfo = AccessTools.Method(typeof(Player), "GetRightItem", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Player), "GetLeftItem", (Type[])null, (Type[])null); object? obj = methodInfo.Invoke(__instance, null); ItemData val = (ItemData)((obj is ItemData) ? obj : null); object? obj2 = methodInfo2.Invoke(__instance, null); ItemData val2 = (ItemData)((obj2 is ItemData) ? obj2 : null); if ((val != null || val2 != null) && !((Character)__instance).InAttack()) { ((Humanoid)__instance).HideHandItems(false, true); } } if (load.getCfg.boolCamInteractEnable && (Object)(object)GameCamera.instance != (Object)null) { Traverse<GameObject> val3 = Traverse.Create((object)__instance).Field<GameObject>("m_hovering"); Traverse<Character> val4 = Traverse.Create((object)__instance).Field<Character>("m_hoveringCreature"); int value = Traverse.Create((object)__instance).Field<int>("m_interactMask").Value; val3.Value = null; val4.Value = null; Transform transform = ((Component)GameCamera.instance).transform; RaycastHit val5 = default(RaycastHit); if (Physics.Raycast(transform.position, transform.forward, ref val5, 50f, value) && (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val5)).collider.attachedRigidbody) || (Object)(object)((Component)((RaycastHit)(ref val5)).collider.attachedRigidbody).gameObject != (Object)(object)((Component)__instance).gameObject)) { GameObject gameObject = ((Component)((RaycastHit)(ref val5)).collider).gameObject; if ((Object)(object)gameObject.GetComponentInParent<Pickable>() != (Object)null || (Object)(object)gameObject.GetComponentInParent<ItemDrop>() != (Object)null) { Hoverable componentInParent = gameObject.GetComponentInParent<Hoverable>(); if (componentInParent != null) { float floatCamInteractDistance = load.getCfg.floatCamInteractDistance; float hoverOffset = componentInParent.GetHoverOffset(); if (Vector3.Distance(transform.position, ((RaycastHit)(ref val5)).point) < floatCamInteractDistance + hoverOffset) { if (((Component)((RaycastHit)(ref val5)).collider).GetComponent<Hoverable>() != null) { val3.Value = ((Component)((RaycastHit)(ref val5)).collider).gameObject; } else if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val5)).collider.attachedRigidbody)) { val3.Value = ((Component)((RaycastHit)(ref val5)).collider.attachedRigidbody).gameObject; } else { val3.Value = ((Component)((RaycastHit)(ref val5)).collider).gameObject; } } } } } } if ((ZInput.GetButtonDown("Use") || ZInput.GetButtonDown("JoyUse")) && !Hud.InRadial() && load.getCfg.boolCamInteractEnable) { GameObject hoverObject = ((Humanoid)__instance).GetHoverObject(); if ((Object)(object)hoverObject != (Object)null) { bool flag = ZInput.GetButton("AltPlace") || ZInput.GetButton("JoyAltPlace"); Interactable componentInParent2 = hoverObject.GetComponentInParent<Interactable>(); if (componentInParent2 != null && componentInParent2.Interact((Humanoid)(object)__instance, false, flag)) { AccessTools.Method(typeof(Player), "DoInteractAnimation", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { ((Component)((componentInParent2 is MonoBehaviour) ? componentInParent2 : null)).gameObject }); } } } if (load.getCfg.boolCamAutoPickupEnable && (Object)(object)GameCamera.instance != (Object)null && !((Character)__instance).IsTeleporting()) { Vector3 position = ((Component)GameCamera.instance).transform.position; float floatCamAutoPickupRadius = load.getCfg.floatCamAutoPickupRadius; int mask = LayerMask.GetMask(new string[1] { "item" }); Collider[] array = Physics.OverlapSphere(position, floatCamAutoPickupRadius, mask); Collider[] array2 = array; Collider[] array3 = array2; foreach (Collider val6 in array3) { if (!Object.op_Implicit((Object)(object)val6.attachedRigidbody)) { continue; } ItemDrop component = ((Component)val6.attachedRigidbody).GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null || !component.m_autoPickup || component.IsPiece()) { continue; } if (!component.CanPickup(true)) { component.RequestOwn(); continue; } component.Load(); if (((Humanoid)__instance).GetInventory().CanAddItem(component.m_itemData, -1) && component.m_itemData.GetWeight(-1) + ((Humanoid)__instance).GetInventory().GetTotalWeight() <= __instance.GetMaxCarryWeight()) { ((Humanoid)__instance).Pickup(((Component)component).gameObject, true, true); } } } AccessTools.Method(typeof(Player), "UpdatePlacement", (Type[])null, (Type[])null).Invoke(__instance, new object[2] { true, Time.deltaTime }); } else { __runOriginal = true; } } [HarmonyPatch(typeof(Player), "Update")] [HarmonyPostfix] public static void switchController(ref Player __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!gosub.isLocalPlayer(in __instance)) { return; } KeyboardShortcut val; if ((!((Object)(object)Menu.instance != (Object)null) || !((Component)Menu.instance.m_root).gameObject.activeSelf) && !gosub.playerIsBlocked(__instance)) { val = load.getCfg.ksKeyBuildModeSettings; if (((KeyboardShortcut)(ref val)).IsDown()) { ui.windowConfigs.toggleMenu(); return; } } ui.windowHint.hintBuildCamera.setBuildCamHint(gosub.isToolEquipped(in __instance), __instance); if (ui.windowConfigs.isOpen) { return; } val = load.getCfg.ksKeyBuildModeSwitch; if ((((KeyboardShortcut)(ref val)).IsDown() || pad.stateController.switchByController) && Traverse.Create((object)__instance).Method("TakeInput", Array.Empty<object>()).GetValue<bool>()) { if (!gosub.isInBuildMode() && gosub.isToolEquipped(in __instance) && gosub.isBuildStationInRange(in __instance)) { gosub.enableBuildMode(); } else if (gosub.isInBuildMode()) { gosub.disableBuildMode(showInfo: true); } } } [HarmonyPatch(typeof(Player), "OnDamaged")] [HarmonyPostfix] public static void OnPlayerDamaged(Player __instance) { if (gosub.isLocalPlayer(in __instance) && gosub.isInBuildMode()) { gosub.disableBuildMode(showInfo: true); ui.stateMessage.warnAttack(); } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] [HarmonyPrefix] public static bool inputPlayerController(ref bool __result, ref bool __runOriginal) { if (ui.windowConfigs.isOpen) { __result = false; __runOriginal = false; return false; } if (gosub.isInBuildMode()) { __result = false; __runOriginal = false; return false; } __runOriginal = true; return true; } } [BepInPlugin("AtzesBuildCamMod", "Atze's Build Camera", "2.4.1")] [BepInProcess("valheim.exe")] [HarmonyPatch] public class Atzes_Build_Camera : BaseUnityPlugin { private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown values.getValues(); ((Component)this).gameObject.AddComponent<ui.windowConfigs>(); Harmony val = new Harmony("AtzesBuildCamMod"); val.PatchAll(Assembly.GetExecutingAssembly()); } } public class config { public float floatRangeBuildAvatar { get; set; } public float floatRangeBuildWorkbench { get; set; } public float floatCamRangeMultier { get; set; } public float floatCamSpeedMultiplier { get; set; } public float floatMaxGroundDive { get; set; } public KeyboardShortcut ksKeyBuildModeSwitch { get; set; } public KeyboardShortcut ksKeyBuildModeSettings { get; set; } public bool boolBuildLight { get; set; } public bool boolBuildDemist { get; set; } public float floatBuildLightIntensity { get; set; } public float floatBuildLightRange { get; set; } public float floatBuildLightFOV { get; set; } public float floatBuildDemistRange { get; set; } public bool boolResourceToPlayer { get; set; } public bool boolCamInteractEnable { get; set; } public bool boolCamAutoPickupEnable { get; set; } public float floatCamAutoPickupRadius { get; set; } public float floatCamInteractDistance { get; set; } public config(float _floatRangeBuildAvatar, float _floatRangeBuildWorkbench, float _floatCamRangeMultier, float _floatCamSpeedMultiplier, float _floatMaxGroundDive, KeyboardShortcut _ksKeyBuildModeSwitch, KeyboardShortcut _ksKeyBuildModeSettings, bool _boolBuildLight, bool _boolBuildDemist, float _floatBuildLightIntensity, float _floatBuildLightRange, float _floatBuildLightFOV, float _floatBuildDemistRange, bool _boolResourceToPlayer, bool _boolCamInteractEnable, bool _boolCamAutoPickupEnable, float _floatCamAutoPickupRadius, float _floatCamInteractDistance) { //IL_0033: 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) floatRangeBuildAvatar = _floatRangeBuildAvatar; floatRangeBuildWorkbench = _floatRangeBuildWorkbench; floatCamRangeMultier = _floatCamRangeMultier; floatCamSpeedMultiplier = _floatCamSpeedMultiplier; floatMaxGroundDive = _floatMaxGroundDive; ksKeyBuildModeSwitch = _ksKeyBuildModeSwitch; ksKeyBuildModeSettings = _ksKeyBuildModeSettings; boolBuildLight = _boolBuildLight; boolBuildDemist = _boolBuildDemist; floatBuildLightIntensity = _floatBuildLightIntensity; floatBuildLightRange = _floatBuildLightRange; floatBuildLightFOV = _floatBuildLightFOV; floatBuildDemistRange = _floatBuildDemistRange; boolResourceToPlayer = _boolResourceToPlayer; boolCamInteractEnable = _boolCamInteractEnable; boolCamAutoPickupEnable = _boolCamAutoPickupEnable; floatCamAutoPickupRadius = _floatCamAutoPickupRadius; floatCamInteractDistance = _floatCamInteractDistance; } } public static class load { public static config getCfg = kernal.sys64738._(getCfg); public static uitext txtUI = kernal.sys64738._(txtUI); public static ConfigFile configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "Atze's Build Camera.cfg"), true); public static ConfigEntry<float> distanceCanBuildFromAvatar = configFile.Bind<float>(kernal.sys52.sectionGeneral, kernal.sys53.keyCharBuildRange, getCfg.floatRangeBuildAvatar, new ConfigDescription(kernal.sys54.strCharBuildRange, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeBuildChar, kernal.sys47.max.RangeBuildChar), Array.Empty<object>())); public static ConfigEntry<float> distanceCanBuildFromWorkbench = configFile.Bind<float>(kernal.sys52.sectionGeneral, kernal.sys53.keyBenchBuildRange, getCfg.floatRangeBuildWorkbench, new ConfigDescription(kernal.sys54.strBenchBuildRange, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeBuildBench, kernal.sys47.max.RangeBuildBench), Array.Empty<object>())); public static ConfigEntry<bool> recourceToPlayer = configFile.Bind<bool>(kernal.sys52.sectionGeneral, kernal.sys53.keyResourceToPlayer, getCfg.boolResourceToPlayer, kernal.sys54.strResourceToPlayer); public static ConfigEntry<float> cameraMaxGroundDive = configFile.Bind<float>(kernal.sys52.sectionCamera, kernal.sys53.keyGroundDive, getCfg.floatMaxGroundDive, new ConfigDescription(kernal.sys54.strGroundDive, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeDive, kernal.sys47.max.RangeDive), Array.Empty<object>())); public static ConfigEntry<float> cameraRangeMultiplier = configFile.Bind<float>(kernal.sys52.sectionCamera, kernal.sys53.keyCamRangeMulti, getCfg.floatCamRangeMultier, new ConfigDescription(kernal.sys54.strCamRangeMulti, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeCamMulti, kernal.sys47.max.RangeCamMulti), Array.Empty<object>())); public static ConfigEntry<float> cameraMoveSpeedMultiplier = configFile.Bind<float>(kernal.sys52.sectionCamera, kernal.sys53.keyCamSpeedMulti, getCfg.floatCamSpeedMultiplier, new ConfigDescription(kernal.sys54.strCamSpeedMulti, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.IntensityLight, kernal.sys47.max.IntensityLight), Array.Empty<object>())); public static ConfigEntry<KeyboardShortcut> keyBuildMode = configFile.Bind<KeyboardShortcut>(kernal.sys52.sectionHotkeys, kernal.sys53.keySwitchBuildCam, getCfg.ksKeyBuildModeSwitch, kernal.sys54.strSwitchBuildCam); public static ConfigEntry<KeyboardShortcut> keyBuildModeSet = configFile.Bind<KeyboardShortcut>(kernal.sys52.sectionHotkeys, kernal.sys53.keySwitchCamSet, getCfg.ksKeyBuildModeSettings, kernal.sys54.strSwitchCamSet); public static ConfigEntry<string> txtuiBuildModeOff = configFile.Bind<string>(kernal.sys52.sectionTextUI, kernal.sys53.keyTextCamOff, txtUI.txtIsDisabled, kernal.sys54.strTextCamOff); public static ConfigEntry<string> txtuiBuildModeOn = configFile.Bind<string>(kernal.sys52.sectionTextUI, kernal.sys53.keyTextCamOn, txtUI.txtIsEnabled, kernal.sys54.strTextCamOn); public static ConfigEntry<string> txtuiWarnDangerNearby = configFile.Bind<string>(kernal.sys52.sectionTextUI, kernal.sys53.keyTextDanger, txtUI.txtWarnDangerNearby, kernal.sys54.strTextDanger); public static ConfigEntry<string> txtuiWarnBeingAttacked = configFile.Bind<string>(kernal.sys52.sectionTextUI, kernal.sys53.keyTextAttacked, txtUI.txtWarnBeingAttacked, kernal.sys54.strTextAttacked); public static ConfigEntry<string> txtuiWarnOutOfRange = configFile.Bind<string>(kernal.sys52.sectionTextUI, kernal.sys53.keyTextNoBench, txtUI.txtWarnOutOfRange, kernal.sys54.strTextNoBench); public static ConfigEntry<bool> wantBuildLight = configFile.Bind<bool>(kernal.sys52.sectionBuildLight, kernal.sys53.keySwitchBuildLight, getCfg.boolBuildLight, kernal.sys54.strSwitchBuildLight); public static ConfigEntry<float> fovBuildLight = configFile.Bind<float>(kernal.sys52.sectionBuildLight, kernal.sys53.keyFOVBuildLight, getCfg.floatBuildLightFOV, new ConfigDescription(kernal.sys54.strFOVBuildLight, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.FOVLight, kernal.sys47.max.FOVLight), Array.Empty<object>())); public static ConfigEntry<float> rangeBuildLight = configFile.Bind<float>(kernal.sys52.sectionBuildLight, kernal.sys53.keyRangeBuildLight, getCfg.floatBuildLightRange, new ConfigDescription(kernal.sys54.strRangeBuildLight, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeLight, kernal.sys47.max.RangeLight), Array.Empty<object>())); public static ConfigEntry<float> intesityBuildLight = configFile.Bind<float>(kernal.sys52.sectionBuildLight, kernal.sys53.keyIntensityBuildLight, getCfg.floatBuildLightIntensity, new ConfigDescription(kernal.sys54.strIntensityBuildLight, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.IntensityLight, kernal.sys47.max.IntensityLight), Array.Empty<object>())); public static ConfigEntry<bool> wantBuildDemist = configFile.Bind<bool>(kernal.sys52.sectionBuildDemist, kernal.sys53.keySwitchDemist, getCfg.boolBuildDemist, kernal.sys54.strSwitchDemist); public static ConfigEntry<float> rangeBuildDemist = configFile.Bind<float>(kernal.sys52.sectionBuildDemist, kernal.sys53.keyRangeDemist, getCfg.floatBuildDemistRange, new ConfigDescription(kernal.sys54.strRangeDemist, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeDemist, kernal.sys47.max.RangeDemist), Array.Empty<object>())); public static ConfigEntry<bool> isPickable = configFile.Bind<bool>(kernal.sys52.sectionPickUp, kernal.sys53.keySwitchInteract, getCfg.boolCamInteractEnable, kernal.sys54.strSwitchInteract); public static ConfigEntry<bool> isAutoPick = configFile.Bind<bool>(kernal.sys52.sectionPickUp, kernal.sys53.keySwitchAutoPickUp, getCfg.boolCamAutoPickupEnable, kernal.sys54.strSwitchAutoPickUp); public static ConfigEntry<float> rangeAutoPick = configFile.Bind<float>(kernal.sys52.sectionPickUp, kernal.sys53.keyRangeAutoPickUp, getCfg.floatCamAutoPickupRadius, new ConfigDescription(kernal.sys54.strRangeAutoPickUp, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeAutoPick, kernal.sys47.max.RangeAutoPick), Array.Empty<object>())); public static ConfigEntry<float> rangeInteract = configFile.Bind<float>(kernal.sys52.sectionPickUp, kernal.sys53.keyRangeInteract, getCfg.floatCamInteractDistance, new ConfigDescription(kernal.sys54.strRangeInteract, (AcceptableValueBase)(object)new AcceptableValueRange<float>(kernal.sys47.min.RangeInteract, kernal.sys47.max.RangeInteract), Array.Empty<object>())); } internal class values { public static void getValues() { //IL_0074: 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) load.getCfg.floatRangeBuildAvatar = load.distanceCanBuildFromAvatar.Value; load.getCfg.floatRangeBuildWorkbench = load.distanceCanBuildFromWorkbench.Value; load.getCfg.floatCamSpeedMultiplier = load.cameraMoveSpeedMultiplier.Value; load.getCfg.floatCamRangeMultier = load.cameraRangeMultiplier.Value; load.getCfg.floatMaxGroundDive = load.cameraMaxGroundDive.Value; load.getCfg.ksKeyBuildModeSwitch = load.keyBuildMode.Value; load.getCfg.ksKeyBuildModeSettings = load.keyBuildModeSet.Value; load.getCfg.boolBuildLight = load.wantBuildLight.Value; load.getCfg.boolBuildDemist = load.wantBuildDemist.Value; load.getCfg.floatBuildLightIntensity = load.intesityBuildLight.Value; load.getCfg.floatBuildLightRange = load.rangeBuildLight.Value; load.getCfg.floatBuildLightFOV = load.fovBuildLight.Value; load.getCfg.floatBuildDemistRange = load.rangeBuildDemist.Value; load.getCfg.boolResourceToPlayer = load.recourceToPlayer.Value; load.txtUI.txtIsEnabled = load.txtuiBuildModeOn.Value; load.txtUI.txtIsDisabled = load.txtuiBuildModeOff.Value; load.txtUI.txtWarnBeingAttacked = load.txtuiWarnBeingAttacked.Value; load.txtUI.txtWarnDangerNearby = load.txtuiWarnDangerNearby.Value; load.txtUI.txtWarnOutOfRange = load.txtuiWarnOutOfRange.Value; load.getCfg.boolCamInteractEnable = load.isPickable.Value; load.getCfg.boolCamAutoPickupEnable = load.isAutoPick.Value; load.getCfg.floatCamAutoPickupRadius = load.rangeAutoPick.Value; load.getCfg.floatCamInteractDistance = load.rangeInteract.Value; } public static void setValue() { load.distanceCanBuildFromAvatar.Value = load.getCfg.floatRangeBuildAvatar; load.distanceCanBuildFromWorkbench.Value = load.getCfg.floatRangeBuildWorkbench; load.cameraMoveSpeedMultiplier.Value = load.getCfg.floatCamSpeedMultiplier; load.cameraRangeMultiplier.Value = load.getCfg.floatCamRangeMultier; load.cameraMaxGroundDive.Value = load.getCfg.floatMaxGroundDive; load.wantBuildLight.Value = load.getCfg.boolBuildLight; load.wantBuildDemist.Value = load.getCfg.boolBuildDemist; load.intesityBuildLight.Value = load.getCfg.floatBuildLightIntensity; load.rangeBuildLight.Value = load.getCfg.floatBuildLightRange; load.fovBuildLight.Value = load.getCfg.floatBuildLightFOV; load.rangeBuildDemist.Value = load.getCfg.floatBuildDemistRange; load.recourceToPlayer.Value = load.getCfg.boolResourceToPlayer; load.txtuiBuildModeOn.Value = load.txtUI.txtIsEnabled; load.txtuiBuildModeOff.Value = load.txtUI.txtIsDisabled; load.txtuiWarnDangerNearby.Value = load.txtUI.txtWarnDangerNearby; load.txtuiWarnBeingAttacked.Value = load.txtUI.txtWarnBeingAttacked; load.txtuiWarnOutOfRange.Value = load.txtUI.txtWarnOutOfRange; load.isPickable.Value = load.getCfg.boolCamInteractEnable; load.isAutoPick.Value = load.getCfg.boolCamAutoPickupEnable; load.rangeAutoPick.Value = load.getCfg.floatCamAutoPickupRadius; load.rangeInteract.Value = load.getCfg.floatCamInteractDistance; } public static void resetValues() { load.getCfg.floatRangeBuildAvatar = kernal.sys49.rangeBuildAvatar; load.getCfg.floatRangeBuildWorkbench = kernal.sys49.rangeBuildWorkbench; load.getCfg.boolResourceToPlayer = kernal.sys49.resourceToPlayer; load.getCfg.floatMaxGroundDive = kernal.sys49.maxGroundDive; load.getCfg.floatCamRangeMultier = kernal.sys49.camRangeMultier; load.getCfg.floatCamSpeedMultiplier = kernal.sys49.camSpeedMultiplier; load.getCfg.boolBuildLight = kernal.sys49.buildLight; load.getCfg.floatBuildLightFOV = kernal.sys49.buildLightFOV; load.getCfg.floatBuildLightRange = kernal.sys49.buildLightRange; load.getCfg.floatBuildLightIntensity = kernal.sys49.buildLightIntensity; load.getCfg.boolBuildDemist = kernal.sys49.buildDemist; load.getCfg.floatBuildDemistRange = kernal.sys49.buildDemistRange; load.txtUI.txtIsEnabled = kernal.sys51.isEnabled; load.txtUI.txtIsDisabled = kernal.sys51.isDisabled; load.txtUI.txtWarnDangerNearby = kernal.sys51.warnDangerNearby; load.txtUI.txtWarnBeingAttacked = kernal.sys51.warnBeingAttacked; load.txtUI.txtWarnOutOfRange = kernal.sys51.warnOutOfRange; load.getCfg.boolCamInteractEnable = kernal.sys49.camInteractEnable; load.getCfg.boolCamAutoPickupEnable = kernal.sys49.camAutoPickupEnable; load.getCfg.floatCamAutoPickupRadius = kernal.sys49.camAutoPickupRadius; load.getCfg.floatCamInteractDistance = kernal.sys49.camInteractDistance; } } public class kernal { public class sys17 { public static readonly string lblHeader = "[ Atze's Build-Camera Settings ]"; public static readonly string lblGeneral = "[ General ]"; public static readonly string lblRangeChar = "Avatar Build Range:"; public static readonly string lblRangeBench = "Station Build Range:"; public static readonly string lblCamControl = "[ Camera Controls ]"; public static readonly string lblCamDive = "Camera Ground Level:"; public static readonly string lblCamRangeMulti = "Camera Range Multiplier:"; public static readonly string lblCamSpeedMulti = "Camera Speed Multiplier:"; public static readonly string lblCamLight = "[ Camera Build-Light ]"; public static readonly string lblFOVLight = "Light Scattering Angle (FOV):"; public static readonly string lblDistLight = "Light Distance/Range:"; public static readonly string lblIntenseLight = "Light Brightness/Intensity:"; public static readonly string lblDemist = "[ Demister / Fog Clearer ]"; public static readonly string lblRangeDemist = "De-Misting Range:"; public static readonly string lblPickUp = "[ Camera Interaction & Auto-Pickup ]"; public static readonly string lblDistPickUp = "PickUp Distance:"; public static readonly string lblRadiusAutoPick = "Auto-Pickup Radius:"; public static readonly string lblTextSet = "[ Text UI Settings ]"; public static readonly string lblAttacked = "Attacked:"; public static readonly string lblDanger = "Danger:"; public static readonly string lblBenchRange = "Range:"; public static readonly string lblCamOn = "Cam On:"; public static readonly string lblCamOff = "Cam Off:"; public static readonly string cbxResToPlayer = "Drop Resources To Player"; public static readonly string cbxBuildLight = "Enable Extra Light on Camera"; public static readonly string cbxDemist = "Enable De-Misting (Clear Fog)"; public static readonly string cbxInteract = "Enable Camera Interaction"; public static readonly string cbxAutoPickUp = "Enable Camera Auto-Pickup"; public static readonly string btnReset = "RESET"; public static readonly string btnSave = "SAVE & CLOSE"; } public class sys47 { public class min { public static readonly float RangeInteract = 1f; public static readonly float RangeAutoPick = 1f; public static readonly float RangeDemist = 5f; public static readonly float FOVLight = 15f; public static readonly float RangeLight = 5f; public static readonly float IntensityLight = 0.1f; public static readonly float RangeBuildChar = 5f; public static readonly float RangeBuildBench = 5f; public static readonly float RangeDive = -5f; public static readonly float RangeCamMulti = 0.5f; public static readonly float SpeedCamMulti = 0.5f; } public class max { public static readonly float RangeInteract = 10f; public static readonly float RangeAutoPick = 25f; public static readonly float RangeDemist = 150f; public static readonly float FOVLight = 135f; public static readonly float RangeLight = 150f; public static readonly float IntensityLight = 5f; public static readonly float RangeBuildChar = 150f; public static readonly float RangeBuildBench = 150f; public static readonly float RangeDive = 2f; public static readonly float RangeCamMulti = 5f; public static readonly float SpeedCamMulti = 5f; } } public class sys49 { public static readonly float rangeBuildAvatar = 100f; public static readonly float rangeBuildWorkbench = 100f; public static readonly float camRangeMultier = 1f; public static readonly float camSpeedMultiplier = 1.5f; public static readonly float maxGroundDive = 2f; public static readonly KeyboardShortcut keyBuildModeSwitch = new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()); public static readonly KeyboardShortcut keyBuildModeSettings = new KeyboardShortcut((KeyCode)303, (KeyCode[])(object)new KeyCode[1] { (KeyCode)8 }); public static readonly bool buildLight = true; public static readonly bool buildDemist = true; public static readonly float buildLightIntensity = 2f; public static readonly float buildLightRange = 40f; public static readonly float buildLightFOV = 90f; public static readonly float buildDemistRange = 100f; public static readonly bool resourceToPlayer = true; public static readonly bool camInteractEnable = true; public static readonly bool camAutoPickupEnable = true; public static readonly float camAutoPickupRadius = 10f; public static readonly float camInteractDistance = 5f; } public class sys51 { public static readonly string isEnabled = "Build-Camera enabled"; public static readonly string isDisabled = "Build-Camera disabled"; public static readonly string warnDangerNearby = "Be careful, danger nearby!"; public static readonly string warnBeingAttacked = "Build Mode off: Under Attack!"; public static readonly string warnOutOfRange = "No workbench nearby"; } public class sys52 { public static readonly string sectionGeneral = "General"; public static readonly string sectionCamera = "Camera"; public static readonly string sectionHotkeys = "Hotkeys"; public static readonly string sectionTextUI = "Text UI"; public static readonly string sectionBuildLight = "BuildLight"; public static readonly string sectionBuildDemist = "BuildDemist"; public static readonly string sectionPickUp = "PickUp"; } public class sys53 { public static readonly string keyCharBuildRange = "Build_Range_Avatar"; public static readonly string keyBenchBuildRange = "Build_Range_Workbench"; public static readonly string keyResourceToPlayer = "Drop_Resources_Near_Player"; public static readonly string keyGroundDive = "Camera_Ground_Dive_Limiter"; public static readonly string keyCamRangeMulti = "Camera_Range_Multiplier"; public static readonly string keyCamSpeedMulti = "Camera_Speed_Multiplier"; public static readonly string keySwitchBuildCam = "Switch_Build_Camera"; public static readonly string keySwitchCamSet = "Switch_Settings"; public static readonly string keyTextCamOff = "Text_Build_Camera_Off"; public static readonly string keyTextCamOn = "Text_Build_Camera_On"; public static readonly string keyTextDanger = "Text_Warn_Danger_Nearby"; public static readonly string keyTextAttacked = "Text_Warn_Being_Attacked"; public static readonly string keyTextNoBench = "Text_Warn_Out_Of_Range"; public static readonly string keySwitchBuildLight = "Switch_Build_Light"; public static readonly string keyFOVBuildLight = "FOV_Build_Light"; public static readonly string keyRangeBuildLight = "Distance_Build_Light"; public static readonly string keyIntensityBuildLight = "Intensity_Build_Light"; public static readonly string keySwitchDemist = "Switch_Build_Demist"; public static readonly string keyRangeDemist = "Range_Build_Demist"; public static readonly string keySwitchInteract = "Switch_Interactibility_PickUp"; public static readonly string keyRangeInteract = "Switch_Auto_PickUp"; public static readonly string keySwitchAutoPickUp = "Range_Auto_PickUp"; public static readonly string keyRangeAutoPickUp = "Distance_To_PickUp"; } public class sys54 { public static readonly string strCharBuildRange = "Distance from your avatar that you can build or repair. (Valheim default is 8)"; public static readonly string strBenchBuildRange = "Distance from nearest workbench/stonecutter/etc. that you can build or repair. (Valheim default is 20)"; public static readonly string strResourceToPlayer = "Drops the resources near player from destroying build-items."; public static readonly string strGroundDive = "This allows to you dive into the ground by given value."; public static readonly string strCamRangeMulti = "Changes maximum range camera can move away from the build station. 1 means the build station's range, 2 means twice the build station range, etc."; public static readonly string strCamSpeedMulti = "Multiplies the speed at which the build camera pans (i.e. moves around WASD). Lower values make it slower."; public static readonly string strSwitchBuildCam = "Hotkey to toggle build camera. See also: https://docs.unity.com/en-us/engine/6000.6/script-reference/unityengine/keycode#fields"; public static readonly string strSwitchCamSet = "Hotkey(s) to toggle build camera settings. See also: https://docs.unity.com/en-us/engine/6000.6/script-reference/unityengine/keycode#fields"; public static readonly string strTextCamOff = "Info Text Build Camera Off"; public static readonly string strTextCamOn = "Info Text Build Camera On"; public static readonly string strTextDanger = "Info Text For Nearby Danger"; public static readonly string strTextAttacked = "Info Text For Being Attacked"; public static readonly string strTextNoBench = "Info Text For Workbench Range"; public static readonly string strSwitchBuildLight = "Enabled gives an extra light attached to the camera."; public static readonly string strFOVBuildLight = "Sets the light-scattering angle"; public static readonly string strRangeBuildLight = "Sets the distance of camera light."; public static readonly string strIntensityBuildLight = "Sets the brighness of camera light."; public static readonly string strSwitchDemist = "Enabled will de-mist a given range in Mistland"; public static readonly string strRangeDemist = "Sets the range of de-misting"; public static readonly string strSwitchInteract = "Sets the ability to pickup items while using build-camera"; public static readonly string strRangeInteract = "Sets auto-pickup arround the camera to on/off"; public static readonly string strSwitchAutoPickUp = "Range of auto-pickup arround the camera."; public static readonly string strRangeAutoPickUp = "Defines how far you can interact with items (pickup)"; } public class sys58260 { public const string appMID = "AtzesBuildCamMod"; public const string appVER = "2.4.1"; public const string appPLN = "Atze's Build Camera"; public const string keyPage = "https://docs.unity.com/en-us/engine/6000.6/script-reference/unityengine/keycode#fields"; public const string objHintText = "BuildCamHintText"; public const string objHintFrame = "BuildCamHintFrame"; public const string objGadget = "BuildCamGadget"; public const string objDemist = "BuildCamDemist"; } public static class sys64738 { public static config _(config _) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) return _ = new config(sys49.rangeBuildAvatar, sys49.rangeBuildWorkbench, sys49.camRangeMultier, sys49.camSpeedMultiplier, sys49.maxGroundDive, sys49.keyBuildModeSwitch, sys49.keyBuildModeSettings, sys49.buildLight, sys49.buildDemist, sys49.buildLightIntensity, sys49.buildLightRange, sys49.buildLightFOV, sys49.buildDemistRange, sys49.resourceToPlayer, sys49.camInteractEnable, sys49.camAutoPickupEnable, sys49.camAutoPickupRadius, sys49.camInteractDistance); } public static uitext _(uitext _) { return _ = new uitext(sys51.isEnabled, sys51.isDisabled, sys51.warnDangerNearby, sys51.warnBeingAttacked, sys51.warnOutOfRange); } } } public class uitext { public string txtIsEnabled { get; set; } public string txtIsDisabled { get; set; } public string txtWarnDangerNearby { get; set; } public string txtWarnBeingAttacked { get; set; } public string txtWarnOutOfRange { get; set; } public uitext(string _txtIsEnabled, string _txtIsDisabled, string _txtWarnDangerNearby, string _txtWarnBeingAttacked, string _warnOutOfRange) { txtIsEnabled = _txtIsEnabled; txtIsDisabled = _txtIsDisabled; txtWarnDangerNearby = _txtWarnDangerNearby; txtWarnBeingAttacked = _txtWarnBeingAttacked; txtWarnOutOfRange = _warnOutOfRange; } } public class tools { public static readonly string[] toolSet = new string[6] { "$item_hammer", "$item_cultivator", "$item_hoe", "$PlumgaPlantItShovel", "$PlumgaClutterTool", "$ImprovedHammer" }; } public class ui { public class windowHint { public class hintBuildCamera { public static void setBuildCamHint(bool isToolEquipped, Player p) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (isToolEquipped && hintConditions(p)) { setHint.setComponents(); if (!((Object)(object)wndHint != (Object)null)) { return; } Text componentInChildren = wndHint.GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = "Press '"; if (ZInput.IsGamepadActive()) { componentInChildren.text += pad.stateController.txtButton; } else { componentInChildren.text += $"{load.getCfg.ksKeyBuildModeSwitch}"; } Text val = componentInChildren; val.text = val.text + "' to <color=" + (gosub.isBuildMode ? "#E65100" : "#00D700") + ">" + (gosub.isBuildMode ? "dis" : "en") + "able</color> Build-Camera"; componentInChildren.text += $" or '{load.getCfg.ksKeyBuildModeSettings}' for settings."; } if (!gosub.isBuildStationInRange(in p)) { componentInChildren.text = "<color=#9F9F00>" + load.txtUI.txtWarnOutOfRange + "</color>"; } if (p.IsSensed() && p.IsTargeted()) { componentInChildren.text = "<color=#FFFF00><b>" + load.txtUI.txtWarnDangerNearby + "</b></color>"; } } else if ((Object)(object)wndHint != (Object)null) { Object.Destroy((Object)(object)wndHint); wndHint = null; } } } private class setHint { public static void setComponents() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00c1: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)wndHint == (Object)null) { wndHint = new GameObject("BuildCamHintFrame"); wndHint.transform.SetParent(((Component)Hud.instance).transform, false); Image val = wndHint.AddComponent<Image>(); ((Graphic)val).color = new Color(0f, 0f, 0f, 0.5f); RectTransform component = wndHint.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0f); component.anchorMax = new Vector2(0.5f, 0f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = new Vector2(0f, 287f); component.sizeDelta = new Vector2(510f, 20f); GameObject val2 = new GameObject("BuildCamHintText"); val2.transform.SetParent(wndHint.transform, false); Text val3 = val2.AddComponent<Text>(); val3.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); val3.fontSize = 12; val3.fontStyle = (FontStyle)1; ((Graphic)val3).color = Color.white; val3.alignment = (TextAnchor)4; RectTransform component2 = val2.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; } } } private static GameObject wndHint; public static bool warnEnemiesNearBy { get; set; } private static bool hintConditions(Player p) { return (Object)(object)Hud.instance != (Object)null && Hud.instance.IsVisible() && !gosub.playerIsBlocked(p) && !Minimap.IsOpen() && !windowConfigs.isOpen; } } public class windowConfigs : MonoBehaviour { public static bool isOpen; private const float winWidth = 650f; private const float winHeight = 675f; private static Rect windowRect; private const int windowID = 9999; public static void toggleMenu() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) isOpen = !isOpen; if (isOpen) { windowRect = new Rect((float)Screen.width / 2f - 325f, (float)Screen.height / 2.4f - 337.5f, 650f, 675f); if (gosub.isInBuildMode()) { gosub.disableBuildMode(showInfo: true); } Game.Pause(); return; } Game.Unpause(); if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return; } FieldInfo field = typeof(CraftingStation).GetField("m_allStations", BindingFlags.Static | BindingFlags.NonPublic); if (field.GetValue(null) is List<CraftingStation> list) { foreach (CraftingStation item in list) { if (item.m_rangeBuild < load.getCfg.floatRangeBuildWorkbench) { item.m_rangeBuild = load.getCfg.floatRangeBuildWorkbench; } Traverse.Create((object)item).Field("m_buildRange").SetValue((object)load.getCfg.floatRangeBuildWorkbench); } } if ((Object)(object)Hud.instance != (Object)null) { MethodInfo method = typeof(Hud).GetMethod("UpdateBuild", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(Hud.instance, new object[2] { Player.m_localPlayer, true }); } } } private void OnGUI() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_0081: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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) if (isOpen) { if (((int)Event.current.type == 4 && (int)Event.current.keyCode == 27) || Console.IsVisible()) { Event.current.Use(); load.configFile.Reload(); values.getValues(); toggleMenu(); return; } Color backgroundColor = GUI.backgroundColor; Color contentColor = GUI.contentColor; GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 1f); GUI.contentColor = Color.white; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; windowRect = GUI.Window(9999, windowRect, new WindowFunction(setComponents), "<color=yellow>" + kernal.sys17.lblHeader + "</color>"); GUI.FocusWindow(9999); GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; } } private void setComponents(int id) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0254: 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_026b: Expected O, but got Unknown //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Expected O, but got Unknown //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Expected O, but got Unknown //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Expected O, but got Unknown //IL_0ac6: Unknown result type (might be due to invalid IL or missing references) //IL_0acb: Unknown result type (might be due to invalid IL or missing references) //IL_0ad3: Unknown result type (might be due to invalid IL or missing references) //IL_0b00: Expected O, but got Unknown //IL_0b37: Unknown result type (might be due to invalid IL or missing references) //IL_0b3c: Unknown result type (might be due to invalid IL or missing references) //IL_0b44: Unknown result type (might be due to invalid IL or missing references) //IL_0b71: Expected O, but got Unknown int fontSize = GUI.skin.label.fontSize; int fontSize2 = GUI.skin.toggle.fontSize; int fontSize3 = GUI.skin.textField.fontSize; GUI.skin.label.fontSize = 11; GUI.skin.toggle.fontSize = 11; GUI.skin.textField.fontSize = 11; if (GUI.Button(new Rect(625f, 1f, 20f, 18f), "X")) { load.configFile.Reload(); values.getValues(); toggleMenu(); GUI.skin.label.fontSize = fontSize; GUI.skin.toggle.fontSize = fontSize2; GUI.skin.textField.fontSize = fontSize3; return; } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.Label("<color=yellow><b>" + kernal.sys17.lblGeneral + "</b></color>", new GUIStyle(GUI.skin.label) { richText = true }, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.Label($"{kernal.sys17.lblRangeChar} {load.getCfg.floatRangeBuildAvatar:F1} (Default: 8.0)", Array.Empty<GUILayoutOption>()); load.getCfg.floatRangeBuildAvatar = GUILayout.HorizontalSlider(load.getCfg.floatRangeBuildAvatar, kernal.sys47.min.RangeBuildChar, kernal.sys47.max.RangeBuildChar, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label($"{kernal.sys17.lblRangeBench} {load.getCfg.floatRangeBuildWorkbench:F1} (Default: 20.0)", Array.Empty<GUILayoutOption>()); load.getCfg.floatRangeBuildWorkbench = GUILayout.HorizontalSlider(load.getCfg.floatRangeBuildWorkbench, kernal.sys47.min.RangeBuildBench, kernal.sys47.max.RangeBuildBench, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); load.getCfg.boolResourceToPlayer = GUILayout.Toggle(load.getCfg.boolResourceToPlayer, " " + kernal.sys17.cbxResToPlayer, Array.Empty<GUILayoutOption>()); GUILayout.Space(20f); GUILayout.Label("<color=yellow><b>" + kernal.sys17.lblCamControl + "</b></color>", new GUIStyle(GUI.skin.label) { richText = true }, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.Label(kernal.sys17.lblCamDive + " " + (0f - load.getCfg.floatMaxGroundDive).ToString("+0.0;-0.0;0.0"), Array.Empty<GUILayoutOption>()); load.getCfg.floatMaxGroundDive = 0f - GUILayout.HorizontalSlider(0f - load.getCfg.floatMaxGroundDive, kernal.sys47.min.RangeDive, kernal.sys47.max.RangeDive, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label($"{kernal.sys17.lblCamRangeMulti} {load.getCfg.floatCamRangeMultier:F1}x", Array.Empty<GUILayoutOption>()); load.getCfg.floatCamRangeMultier = GUILayout.HorizontalSlider(load.getCfg.floatCamRangeMultier, kernal.sys47.min.RangeCamMulti, kernal.sys47.max.RangeCamMulti, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label($"{kernal.sys17.lblCamSpeedMulti} {load.getCfg.floatCamSpeedMultiplier:F1}x", Array.Empty<GUILayoutOption>()); load.getCfg.floatCamSpeedMultiplier = GUILayout.HorizontalSlider(load.getCfg.floatCamSpeedMultiplier, kernal.sys47.min.SpeedCamMulti, kernal.sys47.max.SpeedCamMulti, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.Space(25f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.Label("<color=yellow><b>" + kernal.sys17.lblCamLight + "</b></color>", new GUIStyle(GUI.skin.label) { richText = true }, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); load.getCfg.boolBuildLight = GUILayout.Toggle(load.getCfg.boolBuildLight, " " + kernal.sys17.cbxBuildLight, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.Label($"{kernal.sys17.lblFOVLight} {load.getCfg.floatBuildLightFOV:F0}°", Array.Empty<GUILayoutOption>()); load.getCfg.floatBuildLightFOV = GUILayout.HorizontalSlider(load.getCfg.floatBuildLightFOV, kernal.sys47.min.FOVLight, kernal.sys47.max.FOVLight, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label($"{kernal.sys17.lblDistLight} {load.getCfg.floatBuildLightRange:F1}", Array.Empty<GUILayoutOption>()); load.getCfg.floatBuildLightRange = GUILayout.HorizontalSlider(load.getCfg.floatBuildLightRange, kernal.sys47.min.RangeLight, kernal.sys47.max.RangeLight, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label($"{kernal.sys17.lblIntenseLight} {load.getCfg.floatBuildLightIntensity:F1}", Array.Empty<GUILayoutOption>()); load.getCfg.floatBuildLightIntensity = GUILayout.HorizontalSlider(load.getCfg.floatBuildLightIntensity, kernal.sys47.min.IntensityLight, kernal.sys47.max.IntensityLight, Array.Empty<GUILayoutOption>()); GUILayout.Space(20f); GUILayout.Label("<color=yellow><b>" + kernal.sys17.lblDemist + "</b></color>", new GUIStyle(GUI.skin.label) { richText = true }, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); load.getCfg.boolBuildDemist = GUILayout.Toggle(load.getCfg.boolBuildDemist, " " + kernal.sys17.cbxDemist, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.Label($"{kernal.sys17.lblRangeDemist} {load.getCfg.floatBuildDemistRange:F1}", Array.Empty<GUILayoutOption>()); load.getCfg.floatBuildDemistRange = GUILayout.HorizontalSlider(load.getCfg.floatBuildDemistRange, kernal.sys47.min.RangeDemist, kernal.sys47.max.RangeDemist, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(15f); GUILayout.Label("<color=yellow><b>" + kernal.sys17.lblPickUp + "</b></color>", new GUIStyle(GUI.skin.label) { richText = true }, Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); load.getCfg.boolCamInteractEnable = GUILayout.Toggle(load.getCfg.boolCamInteractEnable, " " + kernal.sys17.cbxInteract, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); GUILayout.Label($"{kernal.sys17.lblDistPickUp} {load.getCfg.floatCamInteractDistance:F1} (Default: 5.0)", Array.Empty<GUILayoutOption>()); load.getCfg.floatCamInteractDistance = GUILayout.HorizontalSlider(load.getCfg.floatCamInteractDistance, kernal.sys47.min.RangeInteract, kernal.sys47.max.RangeInteract, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.Space(25f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); load.getCfg.boolCamAutoPickupEnable = GUILayout.Toggle(load.getCfg.boolCamAutoPickupEnable, " " + kernal.sys17.cbxAutoPickUp, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); GUILayout.Label($"{kernal.sys17.lblRadiusAutoPick} {load.getCfg.floatCamAutoPickupRadius:F1} (Default: 2.0)", Array.Empty<GUILayoutOption>()); load.getCfg.floatCamAutoPickupRadius = GUILayout.HorizontalSlider(load.getCfg.floatCamAutoPickupRadius, kernal.sys47.min.RangeAutoPick, kernal.sys47.max.RangeAutoPick, Array.Empty<GUILayoutOption>()); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(15f); GUILayout.Label("<color=yellow><b>" + kernal.sys17.lblTextSet + "</b></color>", Array.Empty<GUILayoutOption>()); GUILayout.Space(5f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(kernal.sys17.lblAttacked + " ", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); load.txtUI.txtWarnBeingAttacked = GUILayout.TextField(load.txtUI.txtWarnBeingAttacked, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(210f) }); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(kernal.sys17.lblDanger + " ", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); load.txtUI.txtWarnDangerNearby = GUILayout.TextField(load.txtUI.txtWarnDangerNearby, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(210f) }); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(kernal.sys17.lblBenchRange + " ", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); load.txtUI.txtWarnOutOfRange = GUILayout.TextField(load.txtUI.txtWarnOutOfRange, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(210f) }); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(25f); GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(kernal.sys17.lblCamOff + " ", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); load.txtUI.txtIsDisabled = GUILayout.TextField(load.txtUI.txtIsDisabled, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) }); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(kernal.sys17.lblCamOn + " ", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); load.txtUI.txtIsEnabled = GUILayout.TextField(load.txtUI.txtIsEnabled, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(230f) }); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.Button("<color=#AAAA00><b>" + kernal.sys17.btnReset + "</b></color>", new GUIStyle(GUI.skin.button) { richText = true, fontStyle = (FontStyle)1 }, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(180f), GUILayout.Height(30f) })) { values.resetValues(); } GUILayout.Space(40f); if (GUILayout.Button("<color=green><b>" + kernal.sys17.btnSave + "</b></color>", new GUIStyle(GUI.skin.button) { richText = true, fontStyle = (FontStyle)1 }, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(180f), GUILayout.Height(30f) })) { values.setValue(); values.getValues(); load.configFile.Save(); toggleMenu(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUI.skin.label.fontSize = fontSize; GUI.skin.toggle.fontSize = fontSize2; GUI.skin.textField.fontSize = fontSize3; } } public class stateMessage { public static void disableBuildCam() { ((Character)Player.m_localPlayer).Message((MessageType)2, load.txtUI.txtIsDisabled, 0, (Sprite)null, false); } public static void enableBuildCam() { ((Character)Player.m_localPlayer).Message((MessageType)2, load.txtUI.txtIsEnabled, 0, (Sprite)null, false); } public static void warnAttack() { MessageHud.instance.ShowMessage((MessageType)1, "<color=red>" + load.txtUI.txtWarnBeingAttacked + "</color>", 0, (Sprite)null, false, true); } } } [HarmonyPatch] public class wbench { [HarmonyPrefix] [HarmonyPatch(typeof(CraftingStation), "Start")] public static void setRangeWorkbench_(ref CraftingStation __instance, ref float ___m_rangeBuild) { if (___m_rangeBuild < load.getCfg.floatRangeBuildWorkbench) { ___m_rangeBuild = load.getCfg.floatRangeBuildWorkbench; } } [HarmonyPrefix] [HarmonyPatch(typeof(CraftingStation), "GetStationBuildRange")] public static void setRangeWorkbench(ref CraftingStation __instance) { __instance.m_rangeBuild = load.getCfg.floatRangeBuildWorkbench; } }
plugins/NordicRugs/NordicRugs.dll
Decompiled 6 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NordicRugs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0")] [assembly: AssemblyProduct("NordicRugs")] [assembly: AssemblyTitle("NordicRugs")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 NordicRugs { [BepInPlugin("sosal.nordicrugs", "Nordic Rugs", "1.1.0")] [BepInDependency("com.jotunn.jotunn", "2.30.2")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class NordicRugsPlugin : BaseUnityPlugin { public const string Guid = "sosal.nordicrugs"; public const string Version = "1.1.0"; private void Awake() { AddLocalization(); PrefabManager.OnVanillaPrefabsAvailable += RegisterRugs; PieceManager.OnPiecesRegistered += VerifyRecipes; ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Nordic Rugs {0}: {1} independent decorative rugs in Furniture.", "1.1.0", RugCatalog.All.Length)); } private void AddLocalization() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); Dictionary<string, string> dictionary = new Dictionary<string, string> { ["nr_description"] = "Декоративный тканевый ковёр. Комфорт: 1 (общая категория ковров).", ["nr_fur_description"] = "Меховой ковёр с объёмным ворсом. Комфорт: 1 (общая категория ковров)." }; Dictionary<string, string> dictionary2 = new Dictionary<string, string> { ["nr_description"] = "A decorative woven rug. Comfort: 1 (shared carpet group).", ["nr_fur_description"] = "A thick fur rug. Comfort: 1 (shared carpet group)." }; RugDefinition[] all = RugCatalog.All; foreach (RugDefinition rugDefinition in all) { dictionary[rugDefinition.NameToken] = rugDefinition.NameRu; dictionary2[rugDefinition.NameToken] = rugDefinition.NameEn; } string text = "English"; localization.AddTranslation(ref text, dictionary2); text = "Russian"; localization.AddTranslation(ref text, dictionary); } private void RegisterRugs() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= RegisterRugs; int num = 0; RugDefinition[] all = RugCatalog.All; foreach (RugDefinition rugDefinition in all) { try { PieceConfig val = new PieceConfig(); val.Name = "$" + rugDefinition.NameToken; val.Description = (rugDefinition.Fur ? "$nr_fur_description" : "$nr_description"); val.PieceTable = "Hammer"; val.Category = "Furniture"; val.Usage = new string[1] { "Furniture" }; val.CraftingStation = "piece_workbench"; PieceConfig val2 = val; foreach (KeyValuePair<string, int> item in rugDefinition.Recipe) { val2.AddRequirement(item.Key, item.Value, true); } CustomPiece val3 = new CustomPiece(rugDefinition.PrefabName, "rug_deer", val2); if (!Object.op_Implicit((Object)(object)val3.PiecePrefab)) { throw new InvalidOperationException("Vanilla rug_deer is unavailable."); } SetVisuals(val3, rugDefinition); val3.Piece.m_enabled = true; val3.Piece.m_comfort = 1; val3.Piece.m_comfortGroup = (ComfortGroup)6; val3.Piece.m_comfortObject = null; val3.Piece.m_groundOnly = false; val3.Piece.m_notOnWood = false; val3.Piece.m_notOnFloor = false; val3.Piece.m_noClipping = false; val3.Piece.m_clipEverything = true; val3.Piece.m_noInWater = true; val3.Piece.m_canBeRemoved = true; val3.PiecePrefab.GetComponent<ZNetView>().m_persistent = true; if (!PieceManager.Instance.AddPiece(val3)) { throw new InvalidOperationException("Piece registration rejected."); } num++; } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to register {rugDefinition.PrefabName}: {arg}"); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Registered {num}/{RugCatalog.All.Length} Nordic Rugs in Furniture."); } private void SetVisuals(CustomPiece custom, RugDefinition rug) { //IL_0130: 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_014c: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) GameObject piecePrefab = custom.PiecePrefab; Material sharedMaterial = (PrefabManager.Instance.GetPrefab("jute_carpet") ?? PrefabManager.Instance.GetPrefab("rug_deer")).GetComponentsInChildren<Renderer>(true).First((Renderer r) => Object.op_Implicit((Object)(object)r.sharedMaterial)).sharedMaterial; LODGroup[] componentsInChildren = piecePrefab.GetComponentsInChildren<LODGroup>(true); for (int num = 0; num < componentsInChildren.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num]); } Transform[] array = ((IEnumerable)piecePrefab.transform).Cast<Transform>().ToArray(); for (int num = 0; num < array.Length; num++) { Object.DestroyImmediate((Object)(object)((Component)array[num]).gameObject); } Renderer[] components = piecePrefab.GetComponents<Renderer>(); for (int num = 0; num < components.Length; num++) { Object.DestroyImmediate((Object)(object)components[num]); } MeshFilter[] components2 = piecePrefab.GetComponents<MeshFilter>(); for (int num = 0; num < components2.Length; num++) { Object.DestroyImmediate((Object)(object)components2[num]); } Collider[] components3 = piecePrefab.GetComponents<Collider>(); for (int num = 0; num < components3.Length; num++) { Object.DestroyImmediate((Object)(object)components3[num]); } Texture2D val = LoadTexture(rug.Id); Material val2 = new Material(sharedMaterial) { name = "nr_material_" + rug.Id }; val2.mainTexture = (Texture)(object)val; val2.mainTextureScale = Vector2.one; val2.mainTextureOffset = Vector2.zero; SetColor(val2, "_Color", Color.white); SetColor(val2, "_EmissionColor", Color.black); string[] array2 = new string[6] { "_BumpMap", "_MetallicGlossMap", "_EmissionMap", "_OcclusionMap", "_DetailAlbedoMap", "_DetailNormalMap" }; foreach (string text in array2) { if (val2.HasProperty(text)) { val2.SetTexture(text, (Texture)null); } } SetFloat(val2, "_Glossiness", 0.03f); SetFloat(val2, "_Metallic", 0f); SetFloat(val2, "_Cutoff", 0.45f); SetFloat(val2, "_BumpScale", 0f); val2.DisableKeyword("_NORMALMAP"); val2.DisableKeyword("_METALLICGLOSSMAP"); val2.DisableKeyword("_EMISSION"); val2.EnableKeyword("_ALPHATEST_ON"); GameObject val3 = new GameObject("NordicRugMesh"); val3.layer = piecePrefab.layer; val3.transform.SetParent(piecePrefab.transform, false); RugMeshData rugMeshData = RugGeometry.Build(rug); Mesh val4 = new Mesh { name = rug.PrefabName + "_mesh" }; val4.SetVertices(((IEnumerable<RugVertex>)rugMeshData.Vertices).Select((Func<RugVertex, Vector3>)((RugVertex v) => new Vector3(v.X, v.Y, v.Z))).ToList()); val4.SetUVs(0, ((IEnumerable<RugVertex>)rugMeshData.Vertices).Select((Func<RugVertex, Vector2>)((RugVertex v) => new Vector2(v.U, v.V))).ToList()); val4.SetColors(Enumerable.Repeat<Color>(Color.white, rugMeshData.Vertices.Count).ToList()); val4.SetTriangles(rugMeshData.Indices, 0); val4.RecalculateNormals(); val4.RecalculateTangents(); val4.RecalculateBounds(); val3.AddComponent<MeshFilter>().sharedMesh = val4; MeshRenderer obj = val3.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = val2; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)obj).receiveShadows = true; BoxCollider obj2 = piecePrefab.AddComponent<BoxCollider>(); obj2.center = new Vector3(0f, 0.025f, 0f); obj2.size = new Vector3(rug.Width * 0.9f, 0.05f, rug.Length * 0.9f); WearNTear component = piecePrefab.GetComponent<WearNTear>(); component.m_new = val3; component.m_worn = val3; component.m_broken = val3; component.m_wet = null; component.m_snow = null; component.m_snowWorn = null; component.m_snowBroken = null; component.m_fragmentRoots = (GameObject[])(object)new GameObject[1] { val3 }; component.m_nonSolidRenderers = new List<Renderer>(); component.m_health = 50f; component.m_noRoofWear = false; component.m_supports = true; custom.Piece.m_icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{rug.PrefabName}: {rugMeshData.Indices.Count / 3} triangles; {((Texture)val).width}x{((Texture)val).height}; shader={((Object)val2.shader).name}"); } private Texture2D LoadTexture(string id) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NordicRugs.Textures." + id + ".png") ?? throw new FileNotFoundException("Missing embedded rug texture: " + id); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, false) { name = "nr_texture_" + id, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)2, anisoLevel = 4 }; if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { throw new InvalidDataException("Invalid PNG: " + id); } if (SystemInfo.SupportsTextureFormat((TextureFormat)12)) { val.Compress(true); } val.Apply(true, true); return val; } private void VerifyRecipes() { int num = 0; RugDefinition[] all = RugCatalog.All; foreach (RugDefinition rug in all) { CustomPiece piece = PieceManager.Instance.GetPiece(rug.PrefabName); Piece val = ((piece != null) ? piece.Piece : null); if (Object.op_Implicit((Object)(object)val)) { if (val.m_resources.Length != rug.Recipe.Count || !val.m_resources.All((Requirement r) => Object.op_Implicit((Object)(object)r.m_resItem) && rug.Recipe.TryGetValue(((Object)((Component)r.m_resItem).gameObject).name, out var value) && value == r.m_amount && (Object)(object)ObjectDB.instance.GetItemPrefab(((Object)((Component)r.m_resItem).gameObject).name) == (Object)(object)((Component)r.m_resItem).gameObject) || !Object.op_Implicit((Object)(object)val.m_craftingStation) || !((Object)val.m_craftingStation).name.StartsWith("piece_workbench", StringComparison.Ordinal)) { val.m_enabled = false; ((BaseUnityPlugin)this).Logger.LogError((object)("Disabled " + rug.PrefabName + ": unresolved crafting resources or workbench. Target Valheim 1.0.16.")); } else { num++; } } } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Validated {num}/{RugCatalog.All.Length} rug recipes and workbench references."); } private static void SetFloat(Material mat, string key, float value) { if (mat.HasProperty(key)) { mat.SetFloat(key, value); } } private static void SetColor(Material mat, string key, Color value) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (mat.HasProperty(key)) { mat.SetColor(key, value); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterRugs; PieceManager.OnPiecesRegistered -= VerifyRecipes; } } public sealed class RugDefinition { public string Id { get; } public string NameRu { get; } public string NameEn { get; } public float Width { get; } public float Length { get; } public bool Fur { get; } public IReadOnlyDictionary<string, int> Recipe { get; } public string PrefabName => "nr_rug_" + Id; public string NameToken => "nr_" + Id; public RugDefinition(string id, string ru, string en, float width, float length, bool fur, Dictionary<string, int> recipe) { Id = id; NameRu = ru; NameEn = en; Width = width; Length = length; Fur = fur; Recipe = recipe; } } public static class RugCatalog { public static readonly RugDefinition[] All = new RugDefinition[17] { new RugDefinition("forest", "Дремучий бор", "Ancient Woodland", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["DeerHide"] = 4, ["Thistle"] = 2, ["Resin"] = 2 }), new RugDefinition("raven", "Вороны Одина", "Odin's Ravens", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["DeerHide"] = 4, ["Feathers"] = 6, ["Coal"] = 2 }), new RugDefinition("meadows", "Летнее цветение", "Summer Bloom", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["DeerHide"] = 4, ["Dandelion"] = 4 }), new RugDefinition("swamp", "Шёпот трясины", "Whisper of the Mire", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["LeatherScraps"] = 6, ["Root"] = 2, ["Guck"] = 2 }), new RugDefinition("sea", "Путь драккара", "Path of the Longship", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["DeerHide"] = 4, ["Blueberries"] = 4, ["Chitin"] = 2 }), new RugDefinition("plains", "Золотая жатва", "Golden Harvest", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["LinenThread"] = 6, ["Barley"] = 4, ["LoxPelt"] = 1 }), new RugDefinition("mistlands", "Завеса туманов", "Veil of Mist", 1.5f, 3.2f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["JuteBlue"] = 4, ["Sap"] = 2 }), new RugDefinition("mountain", "Волчья лежанка", "Wolf's Rest", 1.8f, 3f, fur: true, new Dictionary<string, int> { ["Flax"] = 5, ["WolfPelt"] = 6, ["JuteRed"] = 2 }), new RugDefinition("ashlands", "Пепельное солнце", "Ashen Sun", 1.6f, 3.2f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["AskHide"] = 4, ["LinenThread"] = 2, ["SulfurStone"] = 2 }), new RugDefinition("north", "Полярная ночь", "Polar Night", 1.8f, 3f, fur: true, new Dictionary<string, int> { ["Flax"] = 5, ["SealHide"] = 4, ["WolfPelt"] = 2 }), new RugDefinition("hunter", "Зов охоты", "Call of the Hunt", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["DeerHide"] = 6, ["BoneFragments"] = 4, ["Feathers"] = 4 }), new RugDefinition("witch", "Ковёр ведьмы", "Witch Rug", 1.8f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["TrollHide"] = 4, ["Crystal"] = 2, ["Dandelion"] = 4 }), new RugDefinition("feast", "Ковёр празднества", "Feast Rug", 1.8f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["JuteRed"] = 4, ["Dandelion"] = 4, ["Coins"] = 10 }), new RugDefinition("runic", "Рунический круг", "Runic Circle", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["DeerHide"] = 4, ["Feathers"] = 4, ["Coal"] = 2 }), new RugDefinition("blue", "Синяя вязь", "Blue Interlace", 2f, 3f, fur: false, new Dictionary<string, int> { ["Flax"] = 5, ["JuteBlue"] = 4, ["Crystal"] = 2 }), new RugDefinition("yggdrasil", "Древо туманов", "Tree of Mists", 4.5f, 3f, fur: false, new Dictionary<string, int> { ["LinenThread"] = 15, ["Wisp"] = 1 }), new RugDefinition("rings", "Кольца туманов", "Rings of Mist", 4.5f, 3f, fur: false, new Dictionary<string, int> { ["LinenThread"] = 15, ["Wisp"] = 1 }) }; } public readonly struct RugVertex { public readonly float X; public readonly float Y; public readonly float Z; public readonly float U; public readonly float V; public RugVertex(float x, float y, float z, float u, float v) { X = x; Y = y; Z = z; U = u; V = v; } } public sealed class RugMeshData { public readonly List<RugVertex> Vertices = new List<RugVertex>(); public readonly List<int> Indices = new List<int>(); public void Triangle(RugVertex a, RugVertex b, RugVertex c, bool twoSided = false) { int count = Vertices.Count; Vertices.Add(a); Vertices.Add(b); Vertices.Add(c); Indices.Add(count); Indices.Add(count + 1); Indices.Add(count + 2); if (twoSided) { Vertices.Add(c); Vertices.Add(b); Vertices.Add(a); Indices.Add(count + 3); Indices.Add(count + 4); Indices.Add(count + 5); } } public void Quad(RugVertex a, RugVertex b, RugVertex c, RugVertex d) { Triangle(a, b, c); Triangle(a, c, d); } } public static class RugGeometry { public static RugMeshData Build(RugDefinition rug) { RugMeshData rugMeshData = new RugMeshData(); float thickness = (rug.Fur ? 0.038f : 0.016f); for (int i = 0; i < 18; i++) { for (int j = 0; j < 12; j++) { rugMeshData.Quad(Point(j, i, top: true), Point(j, i + 1, top: true), Point(j + 1, i + 1, top: true), Point(j + 1, i, top: true)); rugMeshData.Quad(Point(j, i, top: false), Point(j + 1, i, top: false), Point(j + 1, i + 1, top: false), Point(j, i + 1, top: false)); } } for (int k = 0; k < 12; k++) { rugMeshData.Quad(Point(k, 0, top: false), Point(k, 0, top: true), Point(k + 1, 0, top: true), Point(k + 1, 0, top: false)); rugMeshData.Quad(Point(k, 18, top: false), Point(k + 1, 18, top: false), Point(k + 1, 18, top: true), Point(k, 18, top: true)); } for (int l = 0; l < 18; l++) { rugMeshData.Quad(Point(0, l, top: false), Point(0, l + 1, top: false), Point(0, l + 1, top: true), Point(0, l, top: true)); rugMeshData.Quad(Point(12, l, top: false), Point(12, l, top: true), Point(12, l + 1, top: true), Point(12, l + 1, top: false)); } if (rug.Fur) { AddFur(rugMeshData, rug, thickness); } return rugMeshData; RugVertex Point(int x, int z, bool top) { float num = (float)x / 12f; float num2 = (float)z / 18f; float num3 = 0.0025f * (float)(Math.Sin((double)num * 17.0) * Math.Sin((double)num2 * 13.0)); return new RugVertex((num - 0.5f) * rug.Width, top ? (thickness + num3) : 0.002f, (num2 - 0.5f) * rug.Length, num, num2); } } private static void AddFur(RugMeshData mesh, RugDefinition rug, float baseY) { Random random = new Random((rug.Id == "north") ? 7197 : 2217); int num = (int)(rug.Width * rug.Length * 70f); float num2 = ((rug.Id == "north") ? 0.105f : 0.065f); for (int i = 0; i < num; i++) { float num3 = 0.075f + (float)random.NextDouble() * 0.85f; float num4 = 0.075f + (float)random.NextDouble() * 0.85f; float num5 = (num3 - 0.5f) * rug.Width; float num6 = (num4 - 0.5f) * rug.Length; float num7 = 0.012f + (float)random.NextDouble() * 0.025f; float num8 = num2 * (0.45f + (float)random.NextDouble() * 0.55f); float num9 = 0.03f + (float)random.NextDouble() * 0.045f; RugVertex a = new RugVertex(num5 - num7, baseY, num6, num3 - num7 / rug.Width, num4); RugVertex b = new RugVertex(num5, baseY + num8, num6 + num9, num3, num4 + num9 / rug.Length); RugVertex c = new RugVertex(num5 + num7, baseY, num6, num3 + num7 / rug.Width, num4); mesh.Triangle(a, b, c, twoSided: true); mesh.Triangle(new RugVertex(num5, baseY, num6 - num7, num3, num4 - num7 / rug.Length), b, new RugVertex(num5, baseY, num6 + num7, num3, num4 + num7 / rug.Length), twoSided: true); } } } }