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 MorePiles v1.0.0
MorePiles.dll
Decompiled 15 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; 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: InternalsVisibleTo("MorePiles.UnitySmoke")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MorePiles")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MorePiles")] [assembly: AssemblyTitle("MorePiles")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.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 MorePiles { internal sealed class PileEntry { internal PileDefinition Definition; internal GameObject Prefab; internal Bounds Bounds; internal int VisibleItems; } internal sealed class PileBuilder { internal PileEntry Build(PileDefinition definition, GameObject source) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: 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_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0481: 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_04a7: 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) //IL_04bf: Expected O, but got Unknown //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) ItemDrop component = source.GetComponent<ItemDrop>(); GameObject val = PrefabManager.Instance.CreateClonedPrefab(definition.PrefabName, "wood_stack"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Could not clone vanilla wood_stack."); } List<Mesh> list = new List<Mesh>(); try { Transform[] array = ((IEnumerable)val.transform).Cast<Transform>().ToArray(); int i; for (i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)array[i]).gameObject); } Collider[] components = val.GetComponents<Collider>(); for (i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } GameObject val2 = new GameObject("MorePiles_visual"); val2.transform.SetParent(val.transform, false); i = (val.layer = LayerMask.NameToLayer("piece")); val2.layer = i; int visibleItems = PileGeometry.Build(source, definition.Style, definition.HasTray, val2.transform, list); Bounds bounds = PileGeometry.BoundsIn(val2.transform, val.transform); Vector3 size = ((Bounds)(ref bounds)).size; if (((Vector3)(ref size)).sqrMagnitude < 0.01f) { throw new InvalidOperationException("Empty pile geometry."); } BoxCollider obj = val.AddComponent<BoxCollider>(); obj.center = ((Bounds)(ref bounds)).center; obj.size = new Vector3(Mathf.Max(0.2f, ((Bounds)(ref bounds)).size.x), Mathf.Max(0.12f, ((Bounds)(ref bounds)).size.y), Mathf.Max(0.2f, ((Bounds)(ref bounds)).size.z)); Piece component2 = val.GetComponent<Piece>(); component2.m_name = component.m_itemData.m_shared.m_name + " pile"; component2.m_description = "Stores 50 " + component.m_itemData.m_shared.m_name + ". Dismantle with the hammer to recover them."; component2.m_icon = component.m_itemData.GetIcon(); component2.m_enabled = true; component2.m_category = (PieceCategory)0; component2.m_usage = (UsageTagFlags)67072; component2.m_craftingStation = null; component2.m_groundPiece = (component2.m_groundOnly = (component2.m_cultivatedGroundOnly = false)); component2.m_notOnWood = (component2.m_notOnFloor = (component2.m_noInWater = (component2.m_waterPiece = false))); component2.m_clipGround = true; component2.m_clipEverything = false; component2.m_noClipping = false; component2.m_spaceRequirement = 0f; component2.m_comfort = 0; component2.m_canBeRemoved = true; component2.m_allowedInDungeons = (component2.m_allowedInDeepSnow = true); component2.m_returnResourceHeightOffset = Mathf.Min(((Bounds)(ref bounds)).size.y + 0.2f, 1f); component2.m_destroyedLootPrefab = null; List<Requirement> list2 = new List<Requirement> { Requirement(component, 50) }; if (definition.HasTray) { ItemDrop component3 = PrefabManager.Instance.GetPrefab("Wood").GetComponent<ItemDrop>(); list2.Add(Requirement(component3, 2)); component2.m_description += " Includes a wooden tray (2 Wood, also recovered)."; } component2.m_resources = list2.ToArray(); WearNTear component4 = val.GetComponent<WearNTear>(); component4.m_new = (component4.m_worn = (component4.m_broken = (component4.m_wet = null))); component4.m_snow = (component4.m_snowWorn = (component4.m_snowBroken = null)); component4.m_noRoofWear = (component4.m_noSupportWear = true); component4.m_supports = false; component4.m_health = 100f; component4.m_autoCreateFragments = false; component4.m_fragmentRoots = Array.Empty<GameObject>(); val.GetComponent<ZNetView>().m_persistent = true; PileHover pileHover = val.AddComponent<PileHover>(); pileHover.ItemToken = component.m_itemData.m_shared.m_name; pileHover.HasTray = definition.HasTray; Snap(val.transform, new Vector3(0f, 0f, 0f)); Snap(val.transform, new Vector3(((Bounds)(ref bounds)).min.x, 0f, 0f)); Snap(val.transform, new Vector3(((Bounds)(ref bounds)).max.x, 0f, 0f)); Snap(val.transform, new Vector3(0f, 0f, ((Bounds)(ref bounds)).min.z)); Snap(val.transform, new Vector3(0f, 0f, ((Bounds)(ref bounds)).max.z)); Snap(val.transform, new Vector3(0f, ((Bounds)(ref bounds)).max.y, 0f)); CustomPiece val3 = new CustomPiece(val, "Hammer", false); val3.Category = "More Piles"; val3.Usage = new string[3] { "Stacks", "Storage", "Decor" }; CustomPiece val4 = val3; if (!PieceManager.Instance.AddPiece(val4)) { throw new InvalidOperationException("PieceManager rejected the pile."); } return new PileEntry { Definition = definition, Prefab = val, Bounds = bounds, VisibleItems = visibleItems }; } catch { Object.DestroyImmediate((Object)(object)val); foreach (Mesh item in list) { Object.DestroyImmediate((Object)(object)item); } throw; } } private static Requirement Requirement(ItemDrop item, int amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown return new Requirement { m_resItem = item, m_amount = amount, m_amountPerLevel = 0, m_recover = true }; } private static void Snap(Transform parent, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) GameObject val = new GameObject("snap") { tag = "snappoint" }; val.transform.SetParent(parent, false); val.transform.localPosition = position; } } internal enum PileStyle { Heap, Greens, Bundle, Berries, Mushrooms, Seeds, Meat, Eggs, Jars } internal sealed class PileDefinition { internal const int Capacity = 50; internal readonly string Item; internal readonly PileStyle Style; internal bool HasTray { get { if (Style != PileStyle.Seeds && Style != PileStyle.Meat && Style != PileStyle.Eggs) { return Style == PileStyle.Jars; } return true; } } internal string PrefabName => "Dyls123_MorePiles_" + Item; internal PileDefinition(string item, PileStyle style) { Item = item; Style = style; } } internal static class PileDefinitions { internal static readonly IReadOnlyList<PileDefinition> All = Create(); private static List<PileDefinition> Create() { List<PileDefinition> result = new List<PileDefinition>(); Add(PileStyle.Heap, new string[4] { "Carrot", "Turnip", "Onion", "Poteitr" }); Add(PileStyle.Greens, new string[3] { "Kale", "Fiddleheadfern", "FreshSeaweed" }); Add(PileStyle.Bundle, new string[4] { "Barley", "Flax", "Dandelion", "Thistle" }); Add(PileStyle.Berries, new string[5] { "Raspberry", "Blueberries", "Cloudberry", "Vineberry", "Lingonberry" }); Add(PileStyle.Mushrooms, new string[6] { "Mushroom", "MushroomYellow", "MushroomJotunPuffs", "MushroomMagecap", "MushroomSmokePuff", "MushroomBzerker" }); Add(PileStyle.Seeds, new string[16] { "CarrotSeeds", "TurnipSeeds", "OnionSeeds", "PoteitrSeeds", "KaleSeeds", "OatSeeds", "VineberrySeeds", "VineGreenSeeds", "BeechSeeds", "BirchSeeds", "FirCone", "PineCone", "Acorn", "Oat", "BarleyFlour", "OatFlour" }); Add(PileStyle.Eggs, new string[3] { "ChickenEgg", "AsksvinEgg", "VoltureEgg" }); Add(PileStyle.Jars, new string[2] { "Honey", "Sap" }); Add(PileStyle.Meat, new string[16] { "RawMeat", "DeerMeat", "NeckTail", "WolfMeat", "LoxMeat", "SerpentMeat", "FishRaw", "ChickenMeat", "HareMeat", "BugMeat", "AsksvinMeat", "VoltureMeat", "BoneMawSerpentMeat", "BjornMeat", "MooseMeat", "SealBlubber" }); return result; void Add(PileStyle style, string[] items) { foreach (string item in items) { result.Add(new PileDefinition(item, style)); } } } } internal static class PileGeometry { private readonly struct Part { internal readonly Mesh Mesh; internal readonly int Submesh; internal readonly Material Material; internal readonly Matrix4x4 Matrix; internal Part(Mesh mesh, int submesh, Material material, Matrix4x4 matrix) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Mesh = mesh; Submesh = submesh; Material = material; Matrix = matrix; } } internal static int Build(GameObject source, PileStyle style, bool tray, Transform target, List<Mesh> owned) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b1: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0144: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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_0214: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: 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_0467: Unknown result type (might be due to invalid IL or missing references) List<Part> list = Gather(source, owned); if (((Object)source).name == "Turnip") { list.RemoveAll((Part p) => ((Object)p.Material).name == "Turnip"); } if (list.Count == 0) { throw new InvalidOperationException("No usable item mesh: " + ((Object)source).name + "; " + string.Join("; ", from r in source.GetComponentsInChildren<Renderer>(true) select ((object)r).GetType().Name + ":" + ((Object)r).name + " parent=" + (Object.op_Implicit((Object)(object)((Component)r).transform.parent) ? ((Object)((Component)r).transform.parent).name : "root") + " active=" + ((Component)r).gameObject.activeSelf + " mesh=" + (Object.op_Implicit((Object)(object)((Component)r).GetComponent<MeshFilter>()) ? ((Object)((Component)r).GetComponent<MeshFilter>().sharedMesh).name : "none"))); } Bounds val = PartBounds(list); Quaternion val2 = Quaternion.identity; if ((style == PileStyle.Meat || style == PileStyle.Greens) && ((Bounds)(ref val)).size.y > Mathf.Max(((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.z)) { val2 = Quaternion.Euler(90f, 0f, 0f); } if (style == PileStyle.Mushrooms) { val2 = Quaternion.Euler(70f, 0f, 0f); } list = TransformParts(list, Matrix4x4.Rotate(val2)); val = PartBounds(list); float num = Mathf.Max(new float[3] { ((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.y, ((Bounds)(ref val)).size.z }); float num2 = style switch { PileStyle.Bundle => 1.05f, PileStyle.Berries => 0.2f, PileStyle.Seeds => 0.18f, PileStyle.Meat => 0.4f, PileStyle.Eggs => 0.23f, PileStyle.Jars => 0.25f, PileStyle.Greens => 0.42f, PileStyle.Mushrooms => 0.34f, _ => (((Object)source).name == "Carrot") ? 0.48f : 0.4f, } / Mathf.Max(0.01f, num); Matrix4x4 matrix = Matrix4x4.Scale(Vector3.one * num2) * Matrix4x4.Translate(-((Bounds)(ref val)).center); list = TransformParts(list, matrix); Bounds bounds = PartBounds(list); List<Matrix4x4> list2 = Placements(((Object)source).name, style, bounds, tray); Dictionary<Material, List<CombineInstance>> groups = new Dictionary<Material, List<CombineInstance>>(); Dictionary<(Mesh, Matrix4x4), Material[]> dictionary = new Dictionary<(Mesh, Matrix4x4), Material[]>(); foreach (Matrix4x4 item2 in list2) { foreach (Part item3 in list) { if (item3.Mesh.isReadable) { Add(groups, item3, item2); continue; } (Mesh, Matrix4x4) key = (item3.Mesh, item2 * item3.Matrix); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = (Material[])(object)new Material[item3.Mesh.subMeshCount]); } value[item3.Submesh] = item3.Material; } } if (tray) { AddTray(groups, owned, (style == PileStyle.Seeds) ? 0.8f : 1.05f, (style == PileStyle.Seeds) ? 0.68f : 0.85f); } if (style == PileStyle.Bundle) { AddTie(groups, owned); } Emit(groups, target, owned); foreach (KeyValuePair<(Mesh, Matrix4x4), Material[]> item4 in dictionary) { GameObject val3 = new GameObject(((Object)item4.Key.Item1).name) { layer = ((Component)target).gameObject.layer }; val3.transform.SetParent(target, false); Matrix4x4 item = item4.Key.Item2; val3.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref item)).GetColumn(3)); val3.transform.localRotation = ((Matrix4x4)(ref item)).rotation; val3.transform.localScale = ((Matrix4x4)(ref item)).lossyScale; val3.AddComponent<MeshFilter>().sharedMesh = item4.Key.Item1; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterials = item4.Value; } LODGroup val4 = ((Component)target).gameObject.AddComponent<LODGroup>(); val4.SetLODs((LOD[])(object)new LOD[1] { new LOD(0.015f, ((Component)target).GetComponentsInChildren<Renderer>()) }); val4.RecalculateBounds(); return list2.Count; } private static List<Part> Gather(GameObject source, List<Mesh> owned, bool useLod = true) { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_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_0159: Unknown result type (might be due to invalid IL or missing references) Transform val = source.transform.Find("attach"); Transform val2 = (Object.op_Implicit((Object)(object)val) ? val : source.transform); List<Part> list = new List<Part>(); LODGroup componentInChildren = source.GetComponentInChildren<LODGroup>(); HashSet<Renderer> hashSet = ((useLod && Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.GetLODs().Length != 0) ? new HashSet<Renderer>(componentInChildren.GetLODs()[0].renderers) : null); Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { if (val3 is ParticleSystemRenderer || !ActiveBelow(((Component)val3).transform, val2) || (!Object.op_Implicit((Object)(object)val) && hashSet != null && !hashSet.Contains(val3))) { continue; } Mesh val4 = null; if (val3 is MeshRenderer) { MeshFilter component = ((Component)val3).GetComponent<MeshFilter>(); if (Object.op_Implicit((Object)(object)component)) { val4 = component.sharedMesh; } } else { SkinnedMeshRenderer val5 = (SkinnedMeshRenderer)(object)((val3 is SkinnedMeshRenderer) ? val3 : null); if (val5 != null) { val4 = new Mesh(); val5.BakeMesh(val4); owned.Add(val4); } } if (!Object.op_Implicit((Object)(object)val4) || val4.vertexCount == 0) { continue; } Matrix4x4 matrix = source.transform.worldToLocalMatrix * ((Component)val3).transform.localToWorldMatrix; Material[] sharedMaterials = val3.sharedMaterials; for (int j = 0; j < val4.subMeshCount; j++) { if (j < sharedMaterials.Length && Object.op_Implicit((Object)(object)sharedMaterials[j])) { list.Add(new Part(val4, j, sharedMaterials[j], matrix)); } } } if (list.Count == 0 && useLod) { return Gather(source, owned, useLod: false); } return list; } private static bool ActiveBelow(Transform node, Transform root) { Transform val = node; while (Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)root) { if (!((Component)val).gameObject.activeSelf) { return false; } val = val.parent; } return true; } private static List<Part> TransformParts(List<Part> parts, Matrix4x4 matrix) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return parts.Select((Part p) => new Part(p.Mesh, p.Submesh, p.Material, matrix * p.Matrix)).ToList(); } private static List<Matrix4x4> Placements(string item, PileStyle style, Bounds bounds, bool tray) { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) Random random = new Random(StringExtensionMethods.GetStableHashCode(item)); List<Matrix4x4> list = new List<Matrix4x4>(); bool flag = item == "BirchSeeds" || item == "Acorn"; int num; if (flag) { num = 12; } else { int num2 = ((!(item == "Carrot")) ? (style switch { PileStyle.Bundle => 14, PileStyle.Berries => 48, PileStyle.Seeds => 42, PileStyle.Meat => 16, PileStyle.Eggs => 24, PileStyle.Jars => 12, PileStyle.Greens => 26, _ => 32, }) : 50); num = num2; } int num3 = num; switch (style) { case PileStyle.Bundle: { Vector3 val3 = default(Vector3); for (int k = 0; k < num3; k++) { float num9 = (float)k * 2.3999631f; float num10 = 0.19f * Mathf.Sqrt(((float)k + 0.5f) / (float)num3); ((Vector3)(ref val3))..ctor(Mathf.Cos(num9) * num10, ((Bounds)(ref bounds)).extents.y + 0.01f + Noise(0.025f), Mathf.Sin(num9) * num10); Quaternion val4 = Quaternion.Euler(Noise(8f), (float)k * 137.5f, Noise(8f)); list.Add(Matrix4x4.TRS(val3, val4, Vector3.one * (1f + Noise(0.07f)))); } return list; } case PileStyle.Eggs: case PileStyle.Jars: { int num11 = ((style == PileStyle.Jars) ? 4 : 6); int num12 = num3 / num11; Vector3 val5 = default(Vector3); for (int l = 0; l < num3; l++) { ((Vector3)(ref val5))..ctor(((float)(l % num11) - (float)(num11 - 1) / 2f) * 0.15f + Noise(0.008f), 0.075f + ((Bounds)(ref bounds)).extents.y, ((float)(l / num11) - (float)(num12 - 1) / 2f) * 0.16f + Noise(0.008f)); list.Add(Matrix4x4.TRS(val5, Quaternion.Euler(Noise(4f), Noise(180f), Noise(4f)), Vector3.one)); } return list; } default: { int[] array = ((!flag) ? ((!(item == "Carrot")) ? (style switch { PileStyle.Greens => new int[3] { 15, 8, 3 }, PileStyle.Seeds => new int[3] { 24, 12, 6 }, PileStyle.Berries => new int[3] { 25, 16, 7 }, PileStyle.Meat => new int[3] { 9, 5, 2 }, _ => new int[3] { 18, 10, 4 }, }) : new int[3] { 28, 16, 6 }) : new int[3] { 7, 4, 1 }); float num4 = ((item == "Carrot") ? 0.36f : (style switch { PileStyle.Meat => 0.32f, PileStyle.Berries => 0.35f, PileStyle.Seeds => 0.26f, _ => 0.4f, })); float num5 = ((item == "Carrot") ? 0.065f : Mathf.Clamp(((Bounds)(ref bounds)).size.y * 0.6f, style switch { PileStyle.Seeds => 0.05f, PileStyle.Greens => 0.025f, _ => 0.07f, }, 0.15f)); float num6 = (tray ? 0.075f : 0.01f) + ((Bounds)(ref bounds)).extents.y; Vector3 val = default(Vector3); for (int i = 0; i < array.Length; i++) { for (int j = 0; j < array[i]; j++) { float num7 = (float)j * 2.3999631f + (float)i * 0.8f; float num8 = num4 * (1f - (float)i * 0.31f) * Mathf.Sqrt(((float)j + 0.3f) / (float)array[i]); ((Vector3)(ref val))..ctor(Mathf.Cos(num7) * num8 + Noise(0.012f), num6 + (float)i * num5 + Noise(0.008f), Mathf.Sin(num7) * num8 + Noise(0.012f)); if (style == PileStyle.Meat || style == PileStyle.Seeds) { val.z *= 0.75f; } Quaternion val2 = Quaternion.Euler(Noise((style == PileStyle.Meat) ? 6 : 10), Noise(180f), Noise((style == PileStyle.Meat) ? 6 : 10)); list.Add(Matrix4x4.TRS(val, val2, Vector3.one * (1f + Noise(0.06f)))); } } return list; } } float Noise(float range) { return ((float)random.NextDouble() * 2f - 1f) * range; } } private static void Add(Dictionary<Material, List<CombineInstance>> groups, Part part, Matrix4x4 pose) { //IL_0026: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (!groups.TryGetValue(part.Material, out List<CombineInstance> value)) { value = (groups[part.Material] = new List<CombineInstance>()); } List<CombineInstance> list2 = value; CombineInstance item = default(CombineInstance); ((CombineInstance)(ref item)).mesh = part.Mesh; ((CombineInstance)(ref item)).subMeshIndex = part.Submesh; ((CombineInstance)(ref item)).transform = pose * part.Matrix; list2.Add(item); } private static Material WoodMaterial() { return ((Renderer)((Component)PrefabManager.Instance.GetPrefab("wood_pole").transform.Find("New")).GetComponent<MeshRenderer>()).sharedMaterial; } private static void AddTray(Dictionary<Material, List<CombineInstance>> groups, List<Mesh> owned, float width, float depth) { //IL_001e: 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_005f: 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_009a: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) Mesh val = Cube(); owned.Add(val); Part part = new Part(val, 0, WoodMaterial(), Matrix4x4.identity); for (int i = 0; i < 5; i++) { Plank(new Vector3((float)(i - 2) * width / 5f, 0.025f, 0f), new Vector3(width / 5f - 0.005f, 0.05f, depth)); } Plank(new Vector3(0f, 0.075f, depth / 2f), new Vector3(width + 0.05f, 0.1f, 0.035f)); Plank(new Vector3(0f, 0.075f, (0f - depth) / 2f), new Vector3(width + 0.05f, 0.1f, 0.035f)); Plank(new Vector3(width / 2f, 0.075f, 0f), new Vector3(0.035f, 0.1f, depth)); Plank(new Vector3((0f - width) / 2f, 0.075f, 0f), new Vector3(0.035f, 0.1f, depth)); void Plank(Vector3 position, Vector3 size) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Add(groups, part, Matrix4x4.TRS(position, Quaternion.identity, size)); } } private static void AddTie(Dictionary<Material, List<CombineInstance>> groups, List<Mesh> owned) { //IL_002f: 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_004d: Unknown result type (might be due to invalid IL or missing references) Material material = Cache.GetPrefab<Material>("rope") ?? WoodMaterial(); Mesh val = Torus(0.22f, 0.012f); owned.Add(val); Add(groups, new Part(val, 0, material, Matrix4x4.identity), Matrix4x4.Translate(new Vector3(0f, 0.4f, 0f))); } private static void Emit(Dictionary<Material, List<CombineInstance>> groups, Transform target, List<Mesh> owned) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) foreach (KeyValuePair<Material, List<CombineInstance>> group in groups) { Mesh val = new Mesh { name = ((Object)target.parent).name + "_" + ((Object)group.Key).name, indexFormat = (IndexFormat)1 }; owned.Add(val); val.CombineMeshes(group.Value.ToArray(), true, true); if (val.vertexCount == 0) { throw new InvalidOperationException("Mesh combination produced no vertices."); } val.RecalculateBounds(); GameObject val2 = new GameObject(((Object)group.Key).name) { layer = ((Component)target).gameObject.layer }; val2.transform.SetParent(target, false); val2.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = group.Key; } } internal static Bounds BoundsIn(Transform visual, Transform root) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) List<Part> list = new List<Part>(); MeshFilter[] componentsInChildren = ((Component)visual).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren) { list.Add(new Part(val.sharedMesh, 0, ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial, root.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix)); } return PartBounds(list); } private static Bounds PartBounds(List<Part> parts) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_0036: 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_0043: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) bool flag = true; Bounds result = default(Bounds); foreach (Part part in parts) { Bounds bounds = part.Mesh.bounds; for (int i = 0; i < 8; i++) { Matrix4x4 matrix = part.Matrix; Vector3 val = ((Matrix4x4)(ref matrix)).MultiplyPoint3x4(((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1))))); if (flag) { result = new Bounds(val, Vector3.zero); flag = false; } else { ((Bounds)(ref result)).Encapsulate(val); } } } return result; } private static Mesh Cube() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_006b: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_0257: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown Mesh val = new Mesh { name = "MorePiles_tray_plank" }; List<Vector3> vertices = new List<Vector3>(); List<Vector2> uv = new List<Vector2>(); List<int> triangles = new List<int>(); Face(new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f)); Face(new Vector3(0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f)); Face(new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f)); Face(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, -0.5f)); Face(new Vector3(-0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f)); Face(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(-0.5f, -0.5f, 0.5f)); val.SetVertices(vertices); val.SetUVs(0, uv); val.SetTriangles(triangles, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; void Face(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0053: 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_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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.AddRange((IEnumerable<Vector3>)(object)new Vector3[4] { a, b, c, d }); uv.AddRange((IEnumerable<Vector2>)(object)new Vector2[4] { Vector2.zero, Vector2.right, Vector2.one, Vector2.up }); triangles.AddRange(new int[6] { count, count + 1, count + 2, count, count + 2, count + 3 }); } } private static Mesh Torus(float radius, float tube) { //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[231]; Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length]; List<int> list = new List<int>(); for (int i = 0; i <= 32; i++) { for (int j = 0; j <= 6; j++) { float num = (float)(i * 2) * MathF.PI / 32f; float num2 = (float)(j * 2) * MathF.PI / 6f; int num3 = i * 7 + j; array[num3] = new Vector3((radius + tube * Mathf.Cos(num2)) * Mathf.Cos(num), tube * Mathf.Sin(num2), (radius + tube * Mathf.Cos(num2)) * Mathf.Sin(num)); array2[num3] = new Vector2((float)i / 32f * 4f, (float)j / 6f); if (i < 32 && j < 6) { list.AddRange(new int[6] { num3, num3 + 6 + 1, num3 + 1, num3 + 1, num3 + 6 + 1, num3 + 6 + 2 }); } } } Mesh val = new Mesh { name = "MorePiles_bundle_tie", vertices = array, uv = array2, triangles = list.ToArray() }; val.RecalculateNormals(); val.RecalculateBounds(); return val; } } public sealed class PileHover : MonoBehaviour, Hoverable { public string ItemToken = ""; public bool HasTray; public float GetHoverOffset() { return 0.2f; } public string GetHoverName() { return Localization.instance.Localize(ItemToken) + " pile"; } public string GetHoverText() { string text = ((Object.op_Implicit((Object)(object)Plugin.Instance) && Plugin.Instance.ShowStoredAmount.Value) ? (" — " + 50 + " stored") : ""); return GetHoverName() + text + "\nDismantle with the hammer to recover the items" + (HasTray ? " and 2 Wood." : "."); } } [BepInPlugin("Dyls123.MorePiles", "More Piles", "1.0.0")] [BepInDependency("com.jotunn.jotunn", "2.30.2")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "Dyls123.MorePiles"; public const string Version = "1.0.0"; internal static Plugin Instance; internal readonly Dictionary<string, PileEntry> Piles = new Dictionary<string, PileEntry>(); internal ConfigEntry<bool> ShowStoredAmount; private bool registered; private void Awake() { Instance = this; ShowStoredAmount = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowStoredAmount", true, "Show the fixed storage amount in the pile's hover text. This is a local display setting."); PrefabManager.OnVanillaPrefabsAvailable += RegisterPiles; ((BaseUnityPlugin)this).Logger.LogInfo((object)"More Piles 1.0.0 loaded. Required on the server and all clients; each pile stores 50 items."); } internal void RegisterPiles() { if (registered) { return; } PileBuilder pileBuilder = new PileBuilder(); foreach (PileDefinition item in PileDefinitions.All) { try { GameObject prefab = PrefabManager.Instance.GetPrefab(item.Item); if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab.GetComponent<ItemDrop>())) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Skipping item unavailable in this Valheim version: " + item.Item)); continue; } PileEntry value = pileBuilder.Build(item, prefab); Piles.Add(item.Item, value); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not create pile for " + item.Item + ": " + ex)); } } registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Registered " + Piles.Count + " More Piles pieces in the Hammer's More Piles category.")); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiles; if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }