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 Conveyor Belts v0.2.0
ConveyorBelts.dll
Decompiled 4 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.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ConveyorBelts")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+42a1d68b865fbbbb09064eaeb6958b6c258616ea")] [assembly: AssemblyProduct("ConveyorBelts")] [assembly: AssemblyTitle("ConveyorBelts")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "Claude Opus 5.5 and Claude Fable 5.1, through Claude Code")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")] [assembly: AssemblyVersion("0.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ConveyorBelts { internal static class AzuAutoStoreCompat { public const string Guid = "Azumatt.AzuAutoStore"; private const string Target = "AzuAutoStore.Util.Functions:CheckItemDropInstanceAndStore"; public static void Apply(Harmony harmony) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown if (!Chainloader.PluginInfos.TryGetValue("Azumatt.AzuAutoStore", out var value)) { return; } Version version = value.Metadata.Version; try { MethodInfo methodInfo = AccessTools.Method("AzuAutoStore.Util.Functions:CheckItemDropInstanceAndStore", new Type[1] { typeof(ItemDrop) }, (Type[])null); if (methodInfo == null) { Logger.LogWarning((object)string.Format("AzuAutoStore {0}: {1} not found. Chests near a belt can take its items.", version, "AzuAutoStore.Util.Functions:CheckItemDropInstanceAndStore")); return; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(AzuAutoStoreCompat), "SkipBeltItems", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Logger.LogInfo((object)$"AzuAutoStore {version} found: belt items are hidden from it"); } catch (Exception arg) { Logger.LogWarning((object)$"AzuAutoStore {version}: patch failed, chests near a belt can take its items. {arg}"); } } private static bool SkipBeltItems(ItemDrop __0) { return !BeltRider.IsOnBelt(__0); } } internal static class BeltLook { public static ConfigEntry<int> ChevronEvery; public static void Bind(ConfigFile config) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown ChevronEvery = config.Bind<int>("Look", "ChevronEvery", 4, new ConfigDescription("Every how many slats one carries a dark chevron that points the way the belt runs. 0 shows none.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 16), Array.Empty<object>())); ChevronEvery.SettingChanged += delegate { foreach (BeltAnimator item in BeltAnimator.Loaded) { item.ShowMarks(); } }; } } public class BeltAnimator : MonoBehaviour { internal static readonly HashSet<BeltAnimator> Loaded = new HashSet<BeltAnimator>(); public Transform[] Slats; public Transform[] Marks; public Transform[] Rollers; public Transform Wheel; public float Span; public float Direction = 1f; private float _travel; private PowerNode _power; private float LoopLength => BeltPiece.LoopLength(Span); private void Awake() { _power = ((Component)this).GetComponent<PowerNode>(); ShowMarks(); } private void OnEnable() { Loaded.Add(this); } private void OnDisable() { Loaded.Remove(this); } public void ShowMarks() { if (Marks != null && Marks.Length != 0) { int num = BeltLook.ChevronEvery?.Value ?? 4; for (int i = 0; i < Marks.Length; i++) { ((Component)Marks[i]).gameObject.SetActive(num > 0 && i % num == 0); } } } private void Update() { if (Object.op_Implicit((Object)(object)_power) && _power.Powered) { _travel = Mathf.Repeat(_travel + Direction * 0.6f * Time.deltaTime, LoopLength); Layout(_travel); } } public void Layout(float travel) { //IL_0090: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00bf: Unknown result type (might be due to invalid IL or missing references) float num = LoopLength / (float)Slats.Length; for (int i = 0; i < Slats.Length; i++) { Place(Slats[i], (travel + (float)i * num) % LoopLength); if (Marks != null && Marks.Length > i) { Marks[i].SetLocalPositionAndRotation(Slats[i].localPosition, Slats[i].localRotation); } } Quaternion localRotation = Quaternion.Euler(travel / 0.17f * 57.29578f, 0f, 0f); Transform[] rollers = Rollers; for (int j = 0; j < rollers.Length; j++) { rollers[j].localRotation = localRotation; } Wheel.localRotation = localRotation; } private void Place(Transform slat, float s) { //IL_00a3: 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) float num = Span / 2f; float num2 = 0.17f; float num3 = 0.25f; float num4 = (float)Math.PI * num2; float num5; float num6; if (s < Span) { num5 = 0f; num6 = 0f - num + s; } else if ((s -= Span) < num4) { num5 = s / num2; num6 = num; } else if ((s -= num4) < Span) { num5 = (float)Math.PI; num6 = num - s; } else { s -= Span; num5 = (float)Math.PI + s / num2; num6 = 0f - num; } slat.localPosition = new Vector3(0f, num3 + num2 * Mathf.Cos(num5), num6 + num2 * Mathf.Sin(num5)); slat.localRotation = Quaternion.Euler(num5 * 57.29578f, 0f, 0f); } } public class BeltMover : MonoBehaviour { private static readonly Vector3 ZoneCenter = new Vector3(0f, 0.74f, 0f); public Transform Frame; public Vector3 HalfSize; public int Turn; public float Direction = 1f; public bool Creatures = true; private const float LanePull = 1.5f; private const float WallSkin = 0.02f; private const float HeadOn = 0.8f; private const float IntoItem = 0.5f; private const float ExitReach = 0.3f; private static readonly Collider[] Hits = (Collider[])(object)new Collider[32]; private static readonly Collider[] Near = (Collider[])(object)new Collider[32]; private static readonly List<Collider> Own = new List<Collider>(); private static int _itemMask; private static int _creatureMask; private static int _groundMask; private static int _touchMask; private static int _terrainLayer; private static readonly HashSet<Character> Pushed = new HashSet<Character>(); private static float _pushedStep = -1f; private static readonly Dictionary<Rigidbody, (BeltMover by, float at)> Turning = new Dictionary<Rigidbody, (BeltMover, float)>(); private static float _pruneAt; private static readonly Dictionary<Rigidbody, (Rigidbody by, float at)> Waits = new Dictionary<Rigidbody, (Rigidbody, float)>(); private static readonly Dictionary<Rigidbody, float> Riding = new Dictionary<Rigidbody, float>(); private ZNetView _nview; private ItemFilter _filter; private PowerNode _power; private void Awake() { _nview = ((Component)this).GetComponent<ZNetView>(); _filter = ((Component)this).GetComponent<ItemFilter>(); _power = ((Component)this).GetComponent<PowerNode>(); if (_itemMask == 0) { _itemMask = LayerMask.GetMask(new string[1] { "item" }); _creatureMask = LayerMask.GetMask(new string[3] { "character", "character_net", "character_noenv" }); _groundMask = LayerMask.GetMask(new string[5] { "piece", "piece_nonsolid", "Default", "static_solid", "terrain" }); _touchMask = LayerMask.GetMask(new string[5] { "item", "piece", "piece_nonsolid", "Default", "static_solid" }); _terrainLayer = LayerMask.NameToLayer("terrain"); } } private void FixedUpdate() { //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_026c: 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_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: 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_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: 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_0479: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || !_power.Powered) { return; } if (Time.fixedTime != _pushedStep) { Pushed.Clear(); _pushedStep = Time.fixedTime; if (Time.fixedTime >= _pruneAt) { _pruneAt = Time.fixedTime + 5f; List<Rigidbody> list = new List<Rigidbody>(); foreach (KeyValuePair<Rigidbody, (BeltMover, float)> item in Turning) { if (!Object.op_Implicit((Object)(object)item.Key) || !Recent(item.Value.Item2)) { list.Add(item.Key); } } foreach (Rigidbody item2 in list) { Turning.Remove(item2); } list.Clear(); foreach (KeyValuePair<Rigidbody, (Rigidbody, float)> wait in Waits) { if (!Object.op_Implicit((Object)(object)wait.Key) || !Recent(wait.Value.Item2)) { list.Add(wait.Key); } } foreach (Rigidbody item3 in list) { Waits.Remove(item3); } list.Clear(); foreach (KeyValuePair<Rigidbody, float> item4 in Riding) { if (!Object.op_Implicit((Object)(object)item4.Key) || !Recent(item4.Value)) { list.Add(item4.Key); } } foreach (Rigidbody item5 in list) { Riding.Remove(item5); } } } Transform val = (Object.op_Implicit((Object)(object)Frame) ? Frame : ((Component)this).transform); Vector3 val2 = val.TransformPoint(ZoneCenter); int num; if (Creatures) { num = Physics.OverlapBoxNonAlloc(val2, HalfSize + new Vector3(0.3f, 0f, 0.3f), Hits, val.rotation, _creatureMask, (QueryTriggerInteraction)1); Character creature = default(Character); for (int i = 0; i < num; i++) { Rigidbody attachedRigidbody = Hits[i].attachedRigidbody; if (Object.op_Implicit((Object)(object)attachedRigidbody) && ((Component)attachedRigidbody).TryGetComponent<Character>(ref creature)) { CarryCreature(val, creature, attachedRigidbody); } } } num = Physics.OverlapBoxNonAlloc(val2, HalfSize, Hits, val.rotation, _itemMask, (QueryTriggerInteraction)1); ItemDrop val3 = default(ItemDrop); for (int j = 0; j < num; j++) { Rigidbody attachedRigidbody2 = Hits[j].attachedRigidbody; if (!Object.op_Implicit((Object)(object)attachedRigidbody2) || !((Component)attachedRigidbody2).TryGetComponent<ItemDrop>(ref val3)) { continue; } ZNetView component = ((Component)val3).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { continue; } BeltRider.Mark(val3); if (!component.IsOwner() || (Turning.TryGetValue(attachedRigidbody2, out (BeltMover, float) value) && (Object)(object)value.Item1 != (Object)(object)this && Object.op_Implicit((Object)(object)value.Item1) && Recent(value.Item2))) { continue; } if (Turn == 0 || (Object.op_Implicit((Object)(object)_filter) && _filter.ItemGoesStraight(val3))) { Carry(attachedRigidbody2, val, val.forward * Direction, StraightPull(val, attachedRigidbody2.position)); } else if (Object.op_Implicit((Object)(object)_filter)) { Turning[attachedRigidbody2] = (this, Time.fixedTime); Vector3 val4 = ((Component)this).transform.InverseTransformPoint(attachedRigidbody2.worldCenterOfMass); if (val4.z < 0f) { Carry(attachedRigidbody2, val, ((Component)this).transform.forward, ((Component)this).transform.right * ((0f - val4.x) * 1.5f)); } else { Carry(attachedRigidbody2, val, ((Component)this).transform.right * (float)Turn, ((Component)this).transform.forward * ((0f - val4.z) * 1.5f)); } } else { Vector3 pull; Vector3 forward = CornerDirection(attachedRigidbody2.position, out pull); Carry(attachedRigidbody2, val, forward, pull); } } } private void CarryCreature(Transform frame, Character creature, Rigidbody body) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_00ba: 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_0103: Unknown result type (might be due to invalid IL or missing references) //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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: 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_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0321: 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_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: 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_0360: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: 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_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) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: 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_038a: 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_0395: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: 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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) if (creature.IsPlayer() || creature.IsDead() || creature.HaveRider() || Pushed.Contains(creature)) { return; } Vector3 val = frame.InverseTransformPoint(((Component)creature).transform.position) - ZoneCenter; float num = Mathf.Abs(val.x) - HalfSize.x; float num2 = Mathf.Abs(val.z) - HalfSize.z; bool flag = num > 0f || num2 > 0f; if ((num > 0f && num2 > 0f) || (!flag && Mathf.Abs(val.y) > HalfSize.y)) { return; } if (flag) { Vector3 val2 = frame.TransformPoint(new Vector3(Mathf.Clamp(val.x, 0f - HalfSize.x, HalfSize.x), 0.44f, Mathf.Clamp(val.z, 0f - HalfSize.z, HalfSize.z))); float num3 = ((Component)creature).transform.position.y - val2.y; if (num3 < -0.3f || num3 > 2f * HalfSize.y) { return; } } ZNetView component = ((Component)creature).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid() || !component.IsOwner()) { return; } Vector3 pull = Vector3.zero; bool flag2 = Turn == 0 || (Object.op_Implicit((Object)(object)_filter) && _filter.CreatureGoesStraight(creature)); Vector3 val3 = (flag2 ? (frame.forward * Direction) : CornerDirection(body.position, out pull)); Vector3 val5; if (flag) { Vector3 val4 = ((num > 0f) ? (frame.right * Mathf.Sign(val.x)) : (frame.forward * Mathf.Sign(val.z))); bool flag3 = Vector3.Dot(val3, val4) >= 0.8f; bool flag4 = Turn == 0 && Mathf.Max(num, num2) <= 0.5f * creature.GetRadius(); if (flag3 ? OtherBeltBelow(((Component)creature).transform.position) : (!flag4)) { return; } if (flag3) { if (val3.y < 0f) { val5 = Vector3.ProjectOnPlane(val3, Vector3.up); val3 = ((Vector3)(ref val5)).normalized; } pull = Vector3.zero; } } Pushed.Add(creature); Vector3 walk = Vector3.ProjectOnPlane(body.linearVelocity, Vector3.up); Vector3 val6 = 0.6f * val3 + pull; if (flag2) { Vector3 val7 = val6; val5 = Vector3.ProjectOnPlane(val3, Vector3.up); val6 = val7 + Back(walk, ((Vector3)(ref val5)).normalized) * ((Vector3)(ref val3)).normalized; } else { val6 += Back(walk, ((Component)this).transform.forward) * ((Component)this).transform.forward; val6 += Back(walk, ((Component)this).transform.right * (float)Turn) * (((Component)this).transform.right * (float)Turn); } val6 *= Time.fixedDeltaTime; val6 = CreatureStep(body, val6); if (!(val6 == Vector3.zero) && !TrashBin.Blocks(body.position, body.position + val6, creature.GetRadius())) { body.position += val6; } } private static float Back(Vector3 walk, Vector3 way) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(0f - Vector3.Dot(walk, way), 0f); } private bool OtherBeltBelow(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (!Physics.Raycast(point + Vector3.up * 0.5f, Vector3.down, ref val, 0.65f, _groundMask, (QueryTriggerInteraction)1)) { return false; } BeltMover componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<BeltMover>(); if (Object.op_Implicit((Object)(object)componentInParent)) { return (Object)(object)componentInParent != (Object)(object)this; } return false; } private static bool Blocked(Rigidbody body, Vector3 step, out RaycastHit hit) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (!body.SweepTest(((Vector3)(ref step)).normalized, ref hit, ((Vector3)(ref step)).magnitude + 0.02f, (QueryTriggerInteraction)1)) { return false; } if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<BeltMover>()) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref hit)).collider).GetComponent<BeltWall>())) { return false; } if (Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).rigidbody)) { return !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref hit)).rigidbody).GetComponent<ItemDrop>()); } return true; } private static bool ItemBlocked(Rigidbody body, Vector3 step, out bool shove) { //IL_0008: 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) shove = false; Rigidbody item = null; RaycastHit val = default(RaycastHit); if (body.SweepTest(((Vector3)(ref step)).normalized, ref val, ((Vector3)(ref step)).magnitude + 0.02f, (QueryTriggerInteraction)1) && (!Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<BeltMover>()) || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<BeltWall>()))) { if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).rigidbody) || !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).rigidbody).GetComponent<ItemDrop>())) { shove = ((Component)((RaycastHit)(ref val)).collider).gameObject.layer == _terrainLayer || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>()); Waits.Remove(body); return true; } if (Rides(((RaycastHit)(ref val)).rigidbody)) { item = ((RaycastHit)(ref val)).rigidbody; } } if (!Object.op_Implicit((Object)(object)item) && Against(body, step, out item) && !Object.op_Implicit((Object)(object)item)) { Waits.Remove(body); return true; } if (!Object.op_Implicit((Object)(object)item) || WaitsOn(item, body)) { Waits.Remove(body); return false; } Waits[body] = (item, Time.fixedTime); return true; } private static bool Rides(Rigidbody body) { if (Riding.TryGetValue(body, out var value)) { return Recent(value); } return false; } private static bool WaitsOn(Rigidbody from, Rigidbody body) { for (int i = 0; i < 32; i++) { if (!Object.op_Implicit((Object)(object)from)) { break; } if ((Object)(object)from == (Object)(object)body) { return true; } if (!Waits.TryGetValue(from, out (Rigidbody, float) value) || !Recent(value.Item2)) { return false; } from = value.Item1; } return false; } private static bool Against(Rigidbody body, Vector3 step, out Rigidbody item) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_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_006e: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) item = null; Vector3 normalized = ((Vector3)(ref step)).normalized; Vector3 val = step + normalized * 0.02f; ((Component)body).GetComponentsInChildren<Collider>(false, Own); Vector3 val3 = default(Vector3); float num2 = default(float); foreach (Collider item2 in Own) { if (item2.isTrigger || !item2.enabled) { continue; } Bounds bounds = item2.bounds; int num = Physics.OverlapBoxNonAlloc(((Bounds)(ref bounds)).center + val, ((Bounds)(ref bounds)).extents, Near, Quaternion.identity, _touchMask, (QueryTriggerInteraction)1); Transform transform = ((Component)item2).transform; for (int i = 0; i < num; i++) { Collider val2 = Near[i]; Rigidbody attachedRigidbody = val2.attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)(object)body) { continue; } bool flag = Object.op_Implicit((Object)(object)attachedRigidbody) && Object.op_Implicit((Object)(object)((Component)attachedRigidbody).GetComponent<ItemDrop>()); if (!(flag ? (!Rides(attachedRigidbody)) : Object.op_Implicit((Object)(object)((Component)val2).GetComponentInParent<BeltMover>())) && Physics.ComputePenetration(item2, transform.position + val, transform.rotation, val2, ((Component)val2).transform.position, ((Component)val2).transform.rotation, ref val3, ref num2) && !(Vector3.Dot(val3, normalized) >= -0.5f)) { if (!flag) { return true; } item = attachedRigidbody; } } } return Object.op_Implicit((Object)(object)item); } private static Vector3 CreatureStep(Rigidbody body, Vector3 step) { //IL_0005: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0045: 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_0055: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 2; i++) { if (!Blocked(body, step, out var hit)) { return step; } Vector3 val = Vector3.ProjectOnPlane(((RaycastHit)(ref hit)).normal, Vector3.up); if (((Vector3)(ref val)).magnitude < 0.5f) { return Vector3.zero; } ((Vector3)(ref val)).Normalize(); float num = 0f - Vector3.Dot(((Vector3)(ref step)).normalized, val); if (num > 0.8f) { return Vector3.zero; } if (num > 0f) { step += num * ((Vector3)(ref step)).magnitude * val; } } return step; } private static bool Recent(float at) { return at >= Time.fixedTime - 1.5f * Time.fixedDeltaTime; } public Vector3 FlowAt(Vector3 worldPos) { //IL_0009: 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_002d: 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) Vector3 pull; if (Turn != 0) { return CornerDirection(worldPos, out pull); } return (Object.op_Implicit((Object)(object)Frame) ? Frame : ((Component)this).transform).forward * Direction; } private Vector3 CornerDirection(Vector3 worldPos, out Vector3 pull) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_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) Vector3 val = ((Component)this).transform.InverseTransformPoint(worldPos); float num = val.x - (float)Turn; float num2 = val.z + 1f; float num3 = Mathf.Max(Mathf.Sqrt(num * num + num2 * num2), 0.2f); pull = ((Component)this).transform.TransformDirection(new Vector3(num, 0f, num2) / num3 * ((1f - num3) * 1.5f)); return ((Component)this).transform.TransformDirection(new Vector3(num2, 0f, 0f - num) * ((float)Turn / num3)); } private static Vector3 StraightPull(Transform frame, Vector3 worldPos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) return frame.right * ((0f - frame.InverseTransformPoint(worldPos).x) * 1.5f); } private void Carry(Rigidbody body, Transform frame, Vector3 forward, Vector3 pull) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) Riding[body] = Time.fixedTime; Vector3 linearVelocity = body.linearVelocity; float num = Vector3.Dot(linearVelocity, forward); bool flag = false; bool shove = false; if (num < 0.6f) { Vector3 val = (0.6f - Mathf.Max(num, 0f)) * Time.fixedDeltaTime * forward; flag = ItemBlocked(body, val, out shove); if (!flag) { body.position += val; } } Vector3 up = frame.up; Vector3 val2 = ((!flag || shove) ? (0.6f * forward + pull) : (Object.op_Implicit((Object)(object)_filter) ? pull : Vector3.zero)); body.linearVelocity = Vector3.Dot(linearVelocity, up) * up + val2; } } public class BeltWall : MonoBehaviour { } internal static class BeltPiece { private enum Kind { Straight, Corner, Ramp, Grinder, Filter, Link } private class Spec { public string Name; public string Label; public string Description = "A wooden conveyor belt. Moves dropped items and creatures."; public Kind Kind; public int Size = 2; public int Turn; public int Rise; public int Dir = 1; public bool Pillars = true; } private class Parts { public Mesh BoxMesh; public Mesh LogMesh; public Mesh WheelMesh; public Mesh StoneMesh; public Mesh StakeMesh; public Mesh WallMesh; public Material Wood; public Material LogMat; public Material Dark; public Material Mark; public Material[] WheelMats; public Material[] StoneMats; public Material[] StakeMats; public Material[] WallMats; public Vector3 WheelCenter; public Vector3 WallScale; public Quaternion WallRot; public Bounds WallBounds; } public const float EndInset = 0.1f; public const float RollerY = 0.25f; public const float RollerRadius = 0.15f; public const float SlatThickness = 0.04f; public const float SlatWidth = 1.6f; public const float SlatDepth = 0.24f; public static readonly float SlatSpacing = LoopLength(1.8f) / 16f; public const float Speed = 0.6f; public const float PathRadius = 0.17f; public const float TopY = 0.44f; public const float WheelRadius = 0.25f; private const float RailX = 0.86f; private const float WheelNotch = 0.3f; public const float SnapDrop = 0.1f; private static readonly PowerKind[] PowerKinds = new PowerKind[6] { PowerKind.Belt, PowerKind.Corner, PowerKind.Ramp, PowerKind.Grinder, PowerKind.ItemFilter, PowerKind.Link }; private const string FilterText = "A conveyor belt with a side exit. What it is set to turns to the side, the rest goes straight on. Set it with a hotbar key; a trophy sets a creature kind. Shift+E swaps: the set kind goes straight, the rest turns."; private static readonly Spec[] Specs = new Spec[17] { new Spec { Name = "piece_conveyorbelt_1m", Label = "Conveyor belt (1 m)", Size = 1 }, new Spec { Name = "piece_conveyorbelt", Label = "Conveyor belt (2 m)" }, new Spec { Name = "piece_conveyorbelt_4m", Label = "Conveyor belt (4 m)", Size = 4 }, new Spec { Name = "piece_conveyorcorner_right", Label = "Conveyor corner (right)", Kind = Kind.Corner, Turn = 1 }, new Spec { Name = "piece_conveyorcorner_left", Label = "Conveyor corner (left)", Kind = Kind.Corner, Turn = -1 }, new Spec { Name = "piece_conveyorramp_up_1m", Label = "Conveyor ramp (up, 1 m rise)", Kind = Kind.Ramp, Rise = 1 }, new Spec { Name = "piece_conveyorramp_down_1m", Label = "Conveyor ramp (down, 1 m rise)", Kind = Kind.Ramp, Rise = 1, Dir = -1 }, new Spec { Name = "piece_conveyorramp_up_2m", Label = "Conveyor ramp (up, 2 m rise)", Kind = Kind.Ramp, Rise = 2 }, new Spec { Name = "piece_conveyorramp_down_2m", Label = "Conveyor ramp (down, 2 m rise)", Kind = Kind.Ramp, Rise = 2, Dir = -1 }, new Spec { Name = "piece_conveyorramp_up_1m_nopillars", Label = "Conveyor ramp (up, 1 m rise, no pillars)", Kind = Kind.Ramp, Rise = 1, Pillars = false }, new Spec { Name = "piece_conveyorramp_down_1m_nopillars", Label = "Conveyor ramp (down, 1 m rise, no pillars)", Kind = Kind.Ramp, Rise = 1, Dir = -1, Pillars = false }, new Spec { Name = "piece_conveyorramp_up_2m_nopillars", Label = "Conveyor ramp (up, 2 m rise, no pillars)", Kind = Kind.Ramp, Rise = 2, Pillars = false }, new Spec { Name = "piece_conveyorramp_down_2m_nopillars", Label = "Conveyor ramp (down, 2 m rise, no pillars)", Kind = Kind.Ramp, Rise = 2, Dir = -1, Pillars = false }, new Spec { Name = "piece_conveyorgrinder", Label = "Conveyor grinder", Kind = Kind.Grinder, Description = "Kills every creature that rides in. Its loot rides on to the next belt. Hurts players who stand in it." }, new Spec { Name = "piece_conveyorfilter_right", Label = "Item filter (right)", Kind = Kind.Filter, Turn = 1, Description = "A conveyor belt with a side exit. What it is set to turns to the side, the rest goes straight on. Set it with a hotbar key; a trophy sets a creature kind. Shift+E swaps: the set kind goes straight, the rest turns." }, new Spec { Name = "piece_conveyorfilter_left", Label = "Item filter (left)", Kind = Kind.Filter, Turn = -1, Description = "A conveyor belt with a side exit. What it is set to turns to the side, the rest goes straight on. Set it with a hotbar key; a trophy sets a creature kind. Shift+E swaps: the set kind goes straight, the rest turns." }, new Spec { Name = "piece_conveyorlink", Label = "Conveyor link", Kind = Kind.Link, Description = "A conveyor belt in a stone box. Smelters, kilns and chests snap on top or beside it. It feeds them what they take and fills or empties chests." } }; private static Mesh _boxMesh; public static readonly string[] PieceNames = Array.ConvertAll(Specs, (Spec s) => s.Name); private static readonly float[] DrumZ = new float[2] { -0.5f, 0.4f }; private const float DrumY = 0.48f; private const float SignStroke = 0.06f; private const float SignHead = 0.16f; private const float MarkThickness = 0.01f; public static float LoopLength(float span) { return 2f * span + (float)Math.PI * 17f / 50f; } public static void Register() { //IL_0140: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_0252: Expected O, but got Unknown //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0299: 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_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: 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_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: 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_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: 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_0302: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_030f: 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_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0338: 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_0344: 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_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) GameObject val = Find("wood_beam", "new"); GameObject val2 = Find("wood_wall_log", "New/log"); GameObject val3 = Find("piece_spinningwheel", "SpinningWheel_Destruction/SpinningWheel_Destruction.002_SpinningWheel_Broken.018"); GameObject val4 = Find("piece_spinningwheel", "New/High/SpinningWheel"); GameObject val5 = Find("windmill", "grindstone/high"); GameObject val6 = Find("piece_sharpstakes", "New/high/Stake"); MeshRenderer val7 = FindRenderer("stone_wall_1x1", "Stone for the link"); MeshRenderer val8 = FindRenderer("darkwood_beam", "Dark wood for the direction marks"); 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) || !Object.op_Implicit((Object)(object)val5) || !Object.op_Implicit((Object)(object)val6) || !Object.op_Implicit((Object)(object)val7)) { Logger.LogError((object)"Belt not registered: a vanilla part is missing (see warnings above)"); return; } _boxMesh = val.GetComponent<MeshFilter>().sharedMesh; Parts obj = new Parts { BoxMesh = val.GetComponent<MeshFilter>().sharedMesh, Wood = ((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial, LogMesh = val2.GetComponent<MeshFilter>().sharedMesh, LogMat = ((Renderer)val2.GetComponent<MeshRenderer>()).sharedMaterial, WheelMesh = val3.GetComponent<MeshFilter>().sharedMesh }; Bounds bounds = val3.GetComponent<MeshFilter>().sharedMesh.bounds; obj.WheelCenter = ((Bounds)(ref bounds)).center; obj.WheelMats = ((Renderer)val4.GetComponent<SkinnedMeshRenderer>()).sharedMaterials; obj.StoneMesh = val5.GetComponent<MeshFilter>().sharedMesh; obj.StoneMats = ((Renderer)val5.GetComponent<MeshRenderer>()).sharedMaterials; obj.StakeMesh = val6.GetComponent<MeshFilter>().sharedMesh; obj.StakeMats = ((Renderer)val6.GetComponent<MeshRenderer>()).sharedMaterials; obj.WallMesh = ((Component)val7).GetComponent<MeshFilter>().sharedMesh; obj.WallMats = ((Renderer)val7).sharedMaterials; Parts parts = obj; parts.Dark = (Material)(Object.op_Implicit((Object)(object)val8) ? ((object)((Renderer)val8).sharedMaterial) : ((object)new Material(parts.Wood) { color = Color.Lerp(Color.black, parts.Wood.color, 0.3f) })); parts.Mark = new Material(parts.Dark) { name = "ConveyorBelts_mark", color = Color.Lerp(Color.black, parts.Dark.color, 0.35f) }; Matrix4x4 val9 = ((Component)val7).transform.root.worldToLocalMatrix * ((Component)val7).transform.localToWorldMatrix; parts.WallRot = ((Matrix4x4)(ref val9)).rotation; parts.WallScale = ((Matrix4x4)(ref val9)).lossyScale; Bounds bounds2 = parts.WallMesh.bounds; Vector3 val10 = Vector3.positiveInfinity; Vector3 val11 = Vector3.negativeInfinity; for (int i = 0; i < 8; i++) { Vector3 val12 = ((Matrix4x4)(ref val9)).MultiplyVector(Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)(i & 1), (float)((i >> 1) & 1), (float)((i >> 2) & 1)) * 2f - Vector3.one) + ((Bounds)(ref bounds2)).center); val10 = Vector3.Min(val10, val12); val11 = Vector3.Max(val11, val12); } parts.WallBounds = new Bounds((val10 + val11) / 2f, val11 - val10); string name = ((Object)parts.WallMesh).name; object arg = parts.WallBounds; Quaternion rotation = ((Matrix4x4)(ref val9)).rotation; Logger.LogDebug((object)($"Stone wall mesh {name}: bounds {arg}, rotation {((Quaternion)(ref rotation)).eulerAngles}, " + $"scale {((Matrix4x4)(ref val9)).lossyScale}, {parts.WallMesh.subMeshCount} submeshes, {parts.WallMats.Length} materials")); Spec[] specs = Specs; for (int j = 0; j < specs.Length; j++) { Add(specs[j], parts); } } private static void Add(Spec spec, Parts parts) { //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_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_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_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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_03f1: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_038a: 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_039c: 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_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) PieceConfig val = new PieceConfig { Name = spec.Label, Description = spec.Description, PieceTable = PieceTables.Hammer, Category = PieceCategories.Misc, CraftingStation = "piece_workbench" }; Recipes.AddTo(val, spec.Name); CustomPiece val2 = new CustomPiece(spec.Name, "wood_floor", val); GameObject piecePrefab = val2.PiecePrefab; Transform transform = piecePrefab.transform; Transform val3 = Strip(piecePrefab); BeltMover beltMover = piecePrefab.AddComponent<BeltMover>(); beltMover.Direction = spec.Dir; switch (spec.Kind) { case Kind.Straight: SetBox(val3, new Vector3(0f, 0.22f, 0f), Quaternion.identity, new Vector3(2f, 0.44f, (float)spec.Size)); AddEdgeSnapPoints(transform, spec.Size); BuildBelt(transform, parts, spec.Size, new float[2] { -1f, 1f }, 1f, spec.Dir, marks: true); beltMover.HalfSize = new Vector3(0.8f, 0.35f, (float)spec.Size / 2f); break; case Kind.Corner: SetBox(val3, new Vector3(0f, 0.22f, 0f), Quaternion.identity, new Vector3(2f, 0.44f, 2f)); AddEdgeSnapPoints(transform, 2); BuildCorner(transform, parts, spec.Turn); beltMover.Turn = spec.Turn; beltMover.HalfSize = new Vector3(1f, 0.35f, 1f); break; case Kind.Grinder: { SetBox(val3, new Vector3(0f, 0.22f, 0f), Quaternion.identity, new Vector3(2f, 0.44f, 2f)); AddEdgeSnapPoints(transform, 2); beltMover.HalfSize = new Vector3(0.8f, 0.35f, 1f); beltMover.Creatures = false; Grinder grinder = piecePrefab.AddComponent<Grinder>(); grinder.HalfSize = beltMover.HalfSize; grinder.Wheels = BuildGrinder(transform, parts); break; } case Kind.Filter: { SetBox(val3, new Vector3(0f, 0.22f, 0f), Quaternion.identity, new Vector3(2f, 0.44f, 2f)); AddEdgeSnapPoints(transform, 2); FilterArm filterArm = piecePrefab.AddComponent<FilterArm>(); filterArm.Arm = BuildFilter(transform, parts, spec.Turn); filterArm.OutAngle = 45f * (float)spec.Turn; beltMover.Turn = spec.Turn; beltMover.HalfSize = new Vector3(1f, 0.35f, 1f); filterArm.HalfSize = beltMover.HalfSize + new Vector3(0f, 0f, 0.2f); piecePrefab.AddComponent<ItemFilter>().Label = spec.Label; break; } case Kind.Link: SetBox(val3, new Vector3(0f, 0.22f, 0f), Quaternion.identity, new Vector3(2f, 0.44f, 2f)); AddEdgeSnapPoints(transform, 2); SnapPoint(transform, new Vector3(0f, 1.1f, 0f)); BuildLink(transform, parts, ((Component)val3).gameObject.layer); beltMover.HalfSize = new Vector3(0.8f, 0.35f, 1f); piecePrefab.AddComponent<Link>().HalfSize = beltMover.HalfSize; piecePrefab.GetComponent<WearNTear>().m_materialType = (MaterialType)2; break; case Kind.Ramp: { beltMover.Frame = BuildRamp(transform, parts, spec.Rise, spec.Dir, spec.Pillars, val3, out var length); beltMover.HalfSize = new Vector3(0.8f, 0.35f, length / 2f); break; } } PowerNode powerNode = PowerNode.AddTo(piecePrefab, PowerKinds[(int)spec.Kind]); if (spec.Kind == Kind.Straight) { powerNode.CostScale = (float)spec.Size / 2f; } piecePrefab.GetComponent<WearNTear>().m_fragmentRoots = (GameObject[])(object)new GameObject[1] { ((Component)transform.Find("Belt")).gameObject }; try { Sprite val4 = RenderManager.Instance.Render(piecePrefab, RenderManager.IsometricRotation); if (Object.op_Implicit((Object)(object)val4)) { piecePrefab.GetComponent<Piece>().m_icon = val4; } } catch (Exception ex) { Logger.LogWarning((object)(spec.Name + ": icon render failed, keeping the floor icon (" + ex.Message + ")")); } PieceManager.Instance.AddPiece(val2); BeltAnimator component = piecePrefab.GetComponent<BeltAnimator>(); int num = piecePrefab.GetComponentsInChildren<Transform>(true).Count((Transform t) => ((Object)t).name == "arrow"); string text = $"Registered {spec.Name}: {component.Marks.Length} chevrons, {num} arrow strokes, "; string text2 = $"drive wheel at {transform.InverseTransformPoint(component.Wheel.position)}"; Transform val5 = transform.Find("Belt/sign_board"); Logger.LogDebug((object)(text + text2 + ((val5 != null) ? $", sign board at {transform.InverseTransformPoint(val5.position)}" : ""))); } internal static Transform Strip(GameObject prefab) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) Transform transform = prefab.transform; string[] array = new string[3] { "New", "Worn", "Broken" }; foreach (string text in array) { Transform val = transform.Find(text); if (Object.op_Implicit((Object)(object)val)) { for (int num = val.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val.GetChild(num)).gameObject); } } } for (int num2 = transform.childCount - 1; num2 >= 0; num2--) { Transform child = transform.GetChild(num2); if (((Object)child).name.StartsWith("$hud_snappoint")) { Object.DestroyImmediate((Object)(object)((Component)child).gameObject); } } LODGroup component = prefab.GetComponent<LODGroup>(); if (Object.op_Implicit((Object)(object)component)) { Object.DestroyImmediate((Object)(object)component); } Transform obj = transform.Find("collider"); BoxCollider component2 = ((Component)obj).GetComponent<BoxCollider>(); component2.center = Vector3.zero; component2.size = Vector3.one; return obj; } internal static void SetBox(Transform col, Vector3 pos, Quaternion rot, Vector3 size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) col.localPosition = pos; col.localRotation = rot; col.localScale = size; } private static void AddEdgeSnapPoints(Transform root, int size) { //IL_0063: 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_003a: Unknown result type (might be due to invalid IL or missing references) float num = (float)size / 2f; for (int i = 0; i <= size; i++) { float[] array = new float[2] { -1f, 1f }; foreach (float num2 in array) { SnapPoint(root, new Vector3(num2, -0.1f, 0f - num + (float)i)); } } SnapPoint(root, new Vector3(0f, -0.1f, 0f - num)); SnapPoint(root, new Vector3(0f, -0.1f, num)); } internal static void SnapPoint(Transform root, Vector3 pos) { //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_001c: 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) GameObject val = new GameObject("$hud_snappoint") { tag = "snappoint" }; val.SetActive(false); val.transform.SetParent(root, false); val.transform.localPosition = pos; } private static Transform BuildBelt(Transform root, Parts p, float size, float[] railSides, float wheelSide, int dir, bool marks) { //IL_001f: 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_007b: 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_00bc: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_02b6: 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_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_040a: 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_0416: 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_046f: 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_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) float num = size - 0.2f; int num2 = Mathf.RoundToInt(LoopLength(num) / SlatSpacing); Transform transform = new GameObject("Belt").transform; transform.SetParent(root, false); float num3 = size / 2f; float[] array = railSides; foreach (float num4 in array) { Box(transform, "rail", p, new Vector3(num4 * 0.86f, 0.26f, 0f), new Vector3(0.08f, 0.28f, size + 0.1f)); for (float num5 = 0f - num3 + 0.05f; num5 < num3 - 0.1f; num5 += 2f) { Box(transform, "post", p, new Vector3(num4 * 0.86f, 0.23f, num5), new Vector3(0.12f, 0.46f, 0.12f)); } Box(transform, "post", p, new Vector3(num4 * 0.86f, 0.23f, num3 - 0.05f), new Vector3(0.12f, 0.46f, 0.12f)); } array = railSides; foreach (float num6 in array) { float num7 = 0f - num3; float num8 = num3; if (num6 == wheelSide) { if (dir > 0) { num8 = num / 2f - 0.3f; } else { num7 = (0f - num) / 2f + 0.3f; } } Box(transform, "side_board", p, new Vector3(num6 * 1.9000001f / 2f, 0.26f, (num7 + num8) / 2f), new Vector3(0.099999964f, 0.28f, num8 - num7)); } Transform[] array2 = (Transform[])(object)new Transform[2]; for (int j = 0; j < 2; j++) { Transform transform2 = new GameObject("roller").transform; transform2.SetParent(transform, false); transform2.localPosition = new Vector3(0f, 0.25f, (float)((j != 0) ? 1 : (-1)) * num / 2f); Transform obj = Mesh(transform2, "log", p.LogMesh, (Material[])(object)new Material[1] { p.LogMat }); obj.localRotation = Quaternion.Euler(0f, 90f, 0f); obj.localScale = new Vector3(0.5660378f, 0.5660378f, 0.78181815f); array2[j] = transform2; } Transform transform3 = new GameObject("slats").transform; transform3.SetParent(transform, false); for (int k = 0; k < num2; k++) { Box(transform3, "slat", p, Vector3.zero, new Vector3(1.6f, 0.04f, 0.24f)); } Transform[] array3 = (Transform[])(object)new Transform[0]; if (marks) { array3 = (Transform[])(object)new Transform[num2]; for (int l = 0; l < num2; l++) { Transform transform4 = new GameObject("chevron").transform; transform4.SetParent(transform3, false); float num9 = 0.02f; array = new float[2] { -1f, 1f }; foreach (float num10 in array) { Bar(transform4, "chevron_arm", p.Dark, new Vector3(0f, num9, (float)dir * 0.07f), new Vector3(num10 * 0.3f, num9, (float)(-dir) * 0.07f), 0.05f); } array3[l] = transform4; } } Transform transform5 = new GameObject("drive_wheel").transform; transform5.SetParent(transform, false); transform5.localPosition = new Vector3(wheelSide * 0.96000004f, 0.25f, (float)dir * num / 2f); float num11 = 0.3915427f; Transform obj2 = Mesh(transform5, "wheel", p.WheelMesh, p.WheelMats); obj2.localScale = Vector3.one * num11; obj2.localPosition = -p.WheelCenter * num11; Transform obj3 = Mesh(transform5, "axle", p.LogMesh, (Material[])(object)new Material[1] { p.LogMat }); obj3.localRotation = Quaternion.Euler(0f, 90f, 0f); obj3.localPosition = new Vector3((0f - wheelSide) * 0.06f, 0f, 0f); obj3.localScale = new Vector3(0.18867926f, 0.18867926f, 1f / 11f); BeltAnimator beltAnimator = ((Component)root).gameObject.AddComponent<BeltAnimator>(); beltAnimator.Span = num; beltAnimator.Direction = dir; beltAnimator.Slats = (Transform[])(object)new Transform[num2]; for (int m = 0; m < num2; m++) { beltAnimator.Slats[m] = transform3.GetChild(m); } beltAnimator.Marks = array3; beltAnimator.Rollers = array2; beltAnimator.Wheel = transform5; beltAnimator.Layout(0f); beltAnimator.ShowMarks(); return transform; } private static void BuildCorner(Transform root, Parts p, int turn) { //IL_002f: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00cd: 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) BuildBelt(root, p, 2f, new float[1] { -turn }, -turn, 1, marks: false).localRotation = Quaternion.Euler(0f, 90f * (float)turn, 0f); Transform parent = SignBoard(root, p, new Vector3(0f, 0f, 0.88f), new Vector3(1.9f, 0f, 0.28f), Vector3.forward); Bar(parent, "arrow", p.Mark, new Vector3((float)(-turn) * 0.72f, 0f, -0.1f), new Vector3((float)(-turn) * 0.72f, 0f, 0.04f), 0.06f); Arrow(parent, p.Mark, new Vector3((float)(-turn) * 0.72f, 0f, 0.04f), new Vector3((float)turn * 0.85f, 0f, 0.04f), 0.16f, 0.06f); } private static Transform BuildFilter(Transform root, Parts p, int turn) { //IL_0023: 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_006a: 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_00b9: 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_00ec: Unknown result type (might be due to invalid IL or missing references) Transform val = BuildBelt(root, p, 2f, new float[1] { -turn }, -turn, 1, marks: false); Transform transform = new GameObject("filter_arm").transform; transform.SetParent(val, false); transform.localPosition = new Vector3((float)(-turn) * 0.86f, 0f, -0.82f); Box(transform, "arm", p, new Vector3(0f, 0.47f, 0.7f), new Vector3(0.06f, 0.12f, 1.4f)); Transform obj = Mesh(transform, "pin", p.LogMesh, (Material[])(object)new Material[1] { p.LogMat }); obj.localRotation = Quaternion.Euler(90f, 0f, 0f); obj.localPosition = new Vector3(0f, 0.46f, 0f); obj.localScale = new Vector3(0.16981134f, 0.16981134f, 17f / 110f); AddForkArrow(root, p, turn); return transform; } private static void AddForkArrow(Transform root, Parts p, int turn) { //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_003b: 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_0077: 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_00bb: Unknown result type (might be due to invalid IL or missing references) Transform parent = SignBoard(root, p, new Vector3((float)(-turn) * 0.86f, 0f, 0.115f), new Vector3(0.32f, 0f, 1.67f), new Vector3((float)(-turn), 0f, 0f)); Arrow(parent, p.Mark, new Vector3((float)(-turn) * 0.07f, 0f, -0.75f), new Vector3((float)(-turn) * 0.07f, 0f, 0.78f), 0.16f, 0.06f); Arrow(parent, p.Mark, new Vector3((float)(-turn) * 0.07f, 0f, -0.5f), new Vector3((float)turn * 0.1f, 0f, -0.2f), 0.12f, 0.06f); } private static void BuildLink(Transform root, Parts p, int layer) { //IL_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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) Transform val = BuildBelt(root, p, 2f, new float[2] { -1f, 1f }, 1f, 1, marks: true); Transform val2 = val.Find("drive_wheel"); val2.localPosition = new Vector3(1.08f, val2.localPosition.y, val2.localPosition.z); float[] array = new float[2] { -1f, 1f }; foreach (float num in array) { float[] array2 = new float[2] { -0.5f, 0.5f }; foreach (float num2 in array2) { StoneBlock(val, p, new Vector3(num * 0.95f, 0.525f, num2), new Vector3(0.1f, 1.05f, 1f)); } Solid(root, layer, new Vector3(num * 0.95f, 0.525f, 0f), new Vector3(0.1f, 1.05f, 2f)); array2 = new float[2] { -1f, 1f }; foreach (float num3 in array2) { Box(val, "corner_post", p, new Vector3(num * 0.92f, 0.525f, num3 * 0.92f), new Vector3(0.16f, 1.05f, 0.16f)); } } Box(val, "roof", p, new Vector3(0f, 1.125f, 0f), new Vector3(2f, 0.1500001f, 2f)); Solid(root, layer, new Vector3(0f, 1.125f, 0f), new Vector3(2f, 0.1500001f, 2f)); array = new float[2] { -1f, 1f }; foreach (float num4 in array) { Transform transform = new GameObject("wall_arrow").transform; transform.SetParent(val, false); transform.localPosition = new Vector3(num4 * 1f, 0.525f, 0f); transform.localRotation = Quaternion.Euler(0f, 0f, (0f - num4) * 90f); Arrow(transform, p.Dark, new Vector3(0f, 0f, -0.6f), new Vector3(0f, 0f, 0.55f), 0.2f, 0.07f); } } private static void StoneBlock(Transform parent, Parts p, Vector3 center, Vector3 size) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_003d: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0067: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) Vector3 size2 = ((Bounds)(ref p.WallBounds)).size; bool flag = size2.x > size2.z; Transform transform = new GameObject("wall").transform; transform.SetParent(parent, false); transform.localPosition = center; transform.localRotation = (flag ? Quaternion.Euler(0f, 90f, 0f) : Quaternion.identity); transform.localScale = (flag ? new Vector3(size.z / size2.x, size.y / size2.y, size.x / size2.z) : new Vector3(size.x / size2.x, size.y / size2.y, size.z / size2.z)); Transform obj = Mesh(transform, "stone", p.WallMesh, p.WallMats); obj.localRotation = p.WallRot; obj.localScale = p.WallScale; obj.localPosition = -((Bounds)(ref p.WallBounds)).center; } private static void Solid(Transform root, int layer, Vector3 pos, Vector3 size) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("collider_link") { layer = layer }; val.transform.SetParent(root, false); val.transform.localPosition = pos; val.transform.localScale = size; val.AddComponent<BoxCollider>(); val.AddComponent<BeltWall>(); } private static Transform BuildRamp(Transform root, Parts p, int rise, int dir, bool pillars, Transform collider, out float length) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00d2: 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_00e6: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Atan2((float)rise, 2f); float num2 = Mathf.Sin(num); float num3 = Mathf.Cos(num); length = 2f / num3; Transform val = BuildBelt(root, p, length, new float[2] { -1f, 1f }, 1f, dir, marks: true); Quaternion val2 = (val.localRotation = Quaternion.Euler((0f - num) * 57.29578f, 0f, 0f)); val.localPosition = new Vector3(0f, (float)rise / 2f + 0.44f - 0.44f * num3, 0.44f * num2); SetBox(collider, val.localPosition + val2 * new Vector3(0f, 0.22f, 0f), val2, new Vector3(2f, 0.44f, length)); GameObject val4 = new GameObject("collider_foot") { layer = ((Component)collider).gameObject.layer }; val4.transform.SetParent(root, false); val4.transform.localPosition = new Vector3(0f, 0.11f, -0.85f); val4.transform.localScale = new Vector3(2f, 0.22f, 0.3f); val4.AddComponent<BoxCollider>(); float[] array; if (pillars) { array = new float[2] { -1f, 1f }; foreach (float num4 in array) { Box(root, "leg", p, new Vector3(num4 * 0.86f, ((float)rise + 0.3f) / 2f, 0.9f), new Vector3(0.12f, (float)rise + 0.3f, 0.12f)).SetParent(val, true); } } array = new float[3] { -1f, 0f, 1f }; foreach (float num5 in array) { SnapPoint(root, new Vector3(num5, -0.1f, -1f)); SnapPoint(root, new Vector3(num5, (float)rise - 0.1f, 1f)); } return val; } private static Transform[] BuildGrinder(Transform root, Parts p) { //IL_002d: 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_0042: 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_009e: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) Transform val = BuildBelt(root, p, 2f, new float[0], 1f, 1, marks: true); Transform val2 = val.Find("drive_wheel"); val2.localPosition = new Vector3(1.08f, val2.localPosition.y, val2.localPosition.z); float[] array = new float[2] { -1f, 1f }; foreach (float num in array) { Box(val, "frame_beam", p, new Vector3(num * 0.92f, 0.22f, 0f), new Vector3(0.16f, 0.36f, 1.6800001f)); float[] array2 = new float[2] { -1f, 1f }; foreach (float num2 in array2) { StoneBlock(val, p, new Vector3(num * 0.92f, 0.25f, num2 * 0.92f), new Vector3(0.16f, 0.5f, 0.16f)); } array2 = DrumZ; foreach (float num3 in array2) { Box(val, "bearing", p, new Vector3(num * 0.9f, 0.48f, num3), new Vector3(0.16f, 0.2f, 0.24f)); } Transform transform = new GameObject("beam_arrow").transform; transform.SetParent(val, false); transform.localPosition = new Vector3(num * 1f, 0.22f, 0f); transform.localRotation = Quaternion.Euler(0f, 0f, (0f - num) * 90f); Arrow(transform, p.Mark, new Vector3(0f, 0f, -0.7f), new Vector3(0f, 0f, 0.6f), 0.2f, 0.07f); Transform transform2 = new GameObject("beam_arrow").transform; transform2.SetParent(val, false); transform2.localPosition = new Vector3(num * 0.92f, 0.4f, 0f); Arrow(transform2, p.Mark, new Vector3(0f, 0f, -0.3f), new Vector3(0f, 0f, 0.22f), 0.1f, 0.05f); } Transform[] array3 = (Transform[])(object)new Transform[DrumZ.Length]; for (int k = 0; k < array3.Length; k++) { array3[k] = BuildGrinderDrum(val, p, DrumZ[k]); } array = new float[6] { -0.785f, -0.44f, -0.12f, 0.12f, 0.44f, 0.785f }; foreach (float num4 in array) { Box(val, "grate", p, new Vector3(num4, 0.45499998f, 0.84f), new Vector3(0.03f, 0.03f, 0.32f)); } array = new float[2] { 0.91f, 0.985f }; foreach (float num5 in array) { Box(val, "grate", p, new Vector3(0f, 0.48499998f, num5), new Vector3(1.6f, 0.03f, 0.03f)); } return array3; } private static Transform BuildGrinderDrum(Transform belt, Parts p, float z) { //IL_0005: 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_005e: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_022f: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: 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_02ee: 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_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_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject("grinder_drum").transform; transform.SetParent(belt, false); transform.localPosition = new Vector3(0f, 0.48f, z); Transform obj = Mesh(transform, "axle", p.LogMesh, (Material[])(object)new Material[1] { p.LogMat }); obj.localRotation = Quaternion.Euler(0f, 90f, 0f); obj.localScale = new Vector3(0.2264151f, 0.2264151f, 0.81818175f); Transform obj2 = Mesh(transform, "core", p.LogMesh, (Material[])(object)new Material[1] { p.LogMat }); obj2.localRotation = Quaternion.Euler(0f, 90f, 0f); obj2.localScale = new Vector3(0.9811321f, 0.9811321f, 15f / 22f); float[] obj3 = new float[5] { 0.32f, 0.18f, 0.32f, 0.18f, 0.32f }; float num = -0.76f; float[] array = obj3; foreach (float num2 in array) { bool flag = num2 == 0.32f; Transform transform2 = new GameObject("ring").transform; transform2.SetParent(transform, false); transform2.localPosition = new Vector3(num + num2 / 2f, 0f, 0f); num += num2 + 0.05f; float num3 = num2 / 0.47f; Transform obj4 = Mesh(transform2, "stone", p.StoneMesh, p.StoneMats); obj4.localRotation = Quaternion.Euler(0f, 0f, -90f); obj4.localScale = new Vector3(32f / 65f, num3, 32f / 65f); obj4.localPosition = obj4.localRotation * new Vector3(0f, -1.375f * num3, 0f); float num4 = (flag ? 0.16f : 0.1f); float num5 = (flag ? 0.12f : 0.08f); for (int j = 0; j < 5; j++) { Vector3 val = Radial(((float)j + (flag ? 0f : 0.5f)) / 5f); Transform obj5 = Mesh(transform2, "spike", p.StakeMesh, p.StakeMats); obj5.localRotation = Quaternion.FromToRotation(Vector3.up, val); obj5.localPosition = val * 0.29999998f; obj5.localScale = new Vector3(num5 / 0.44f, num4 / 3.4f, num5 / 0.44f); } if (!flag) { continue; } float[] array2 = new float[2] { -1f, 1f }; foreach (float num6 in array2) { for (int l = 0; l < 10; l++) { Vector3 val2 = Radial(((float)l + 0.5f) / 10f); Transform obj6 = Mesh(transform2, "rivet", p.BoxMesh, (Material[])(object)new Material[1] { p.Dark }); obj6.localRotation = Quaternion.FromToRotation(Vector3.up, val2); obj6.localPosition = new Vector3(num6 * (num2 / 2f - 0.05f), 0f, 0f) + val2 * 0.32f; obj6.localScale = Vector3.one * 0.035f; } } } return transform; } private static Vector3 Radial(float turn) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) float num = turn * 2f * (float)Math.PI; return new Vector3(0f, Mathf.Cos(num), Mathf.Sin(num)); } private static Transform SignBoard(Transform root, Parts p, Vector3 center, Vector3 size, Vector3 outward) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0034: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_0171: 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) Transform val = root.Find("Belt"); Box(root, "sign_board", p, new Vector3(center.x, 0.565f, center.z), new Vector3(size.x, 0.03f, size.z)).SetParent(val, true); Vector3 val2 = Vector3.Scale(size, Vector3.one - new Vector3(Mathf.Abs(outward.x), 0f, Mathf.Abs(outward.z))) / 2f; Vector3 val3 = Vector3.Scale(size, outward) / 2f - outward * 0.05f; float num = 0.15f; float[] array = new float[2] { -1f, 1f }; foreach (float num2 in array) { Box(root, "sign_post", p, new Vector3(center.x, 0.4f + num / 2f, center.z) + val3 + num2 * (val2 - ((Vector3)(ref val2)).normalized * 0.45f), new Vector3(0.05f, num, 0.05f)).SetParent(val, true); } Transform transform = new GameObject("sign_arrow").transform; transform.SetParent(root, false); transform.localPosition = new