Decompiled source of MindustryValuables v0.1.2

MindustryValuables.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MindustryValuables
{
	internal enum Blind
	{
		None,
		White
	}
	internal static class GameAudio
	{
		private static AudioMixerGroup group;

		private static bool searched;

		public static AudioMixerGroup Group
		{
			get
			{
				if (!searched)
				{
					searched = true;
					int num = -1;
					AudioMixerGroup[] array = Resources.FindObjectsOfTypeAll<AudioMixerGroup>();
					foreach (AudioMixerGroup val in array)
					{
						string text = ((Object)val).name.ToLowerInvariant();
						int num2 = 0;
						if (text.Contains("effect") || text.Contains("sfx"))
						{
							num2 = 3;
						}
						else if (text.Contains("sound"))
						{
							num2 = 2;
						}
						else if (!text.Contains("music") && !text.Contains("voice") && !text.Contains("master"))
						{
							num2 = 1;
						}
						if (num2 > num)
						{
							num = num2;
							group = val;
						}
					}
				}
				return group;
			}
		}

		public static AudioSource MakeSource(GameObject go, bool loop, float maxDistance)
		{
			AudioSource val = go.AddComponent<AudioSource>();
			val.playOnAwake = false;
			val.loop = loop;
			val.spatialBlend = 1f;
			val.rolloffMode = (AudioRolloffMode)1;
			val.minDistance = 1.5f;
			val.maxDistance = maxDistance;
			val.dopplerLevel = 0f;
			AudioMixerGroup val2 = Group;
			if ((Object)(object)val2 != (Object)null)
			{
				val.outputAudioMixerGroup = val2;
			}
			return val;
		}
	}
	internal class HeldLoop : MonoBehaviour
	{
		public AudioClip clip;

		public float volume = 0.5f;

		public float maxDistance = 18f;

		private AudioSource src;

		private PhysGrabObject pgo;

		private float current;

		private void Awake()
		{
			pgo = ((Component)this).GetComponentInParent<PhysGrabObject>();
			src = GameAudio.MakeSource(((Component)this).gameObject, loop: true, maxDistance);
			src.clip = clip;
		}

		private void Update()
		{
			if (!((Object)(object)src == (Object)null) && !((Object)(object)clip == (Object)null))
			{
				bool flag = (Object)(object)pgo != (Object)null && pgo.grabbed;
				current = Mathf.MoveTowards(current, flag ? 1f : 0f, Time.deltaTime * 4f);
				src.volume = current * volume * Plugin.SoundVolume.Value;
				if (flag && !src.isPlaying)
				{
					src.Play();
				}
				else if (!flag && current <= 0.001f && src.isPlaying)
				{
					src.Stop();
				}
			}
		}
	}
	internal class ImpactSound : MonoBehaviour
	{
		public AudioClip clip;

		public float minSpeed = 2.5f;

		public float maxDistance = 25f;

		private AudioSource src;

		private float cooldown;

		private void Awake()
		{
			src = GameAudio.MakeSource(((Component)this).gameObject, loop: false, maxDistance);
		}

		private void Update()
		{
			if (cooldown > 0f)
			{
				cooldown -= Time.deltaTime;
			}
		}

		private void OnCollisionEnter(Collision c)
		{
			//IL_002b: 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)
			if (!((Object)(object)src == (Object)null) && !((Object)(object)clip == (Object)null) && !(cooldown > 0f))
			{
				Vector3 relativeVelocity = c.relativeVelocity;
				float magnitude = ((Vector3)(ref relativeVelocity)).magnitude;
				if (!(magnitude < minSpeed))
				{
					cooldown = 0.12f;
					float num = Mathf.Clamp01(magnitude / 12f) * Plugin.SoundVolume.Value;
					src.pitch = Random.Range(0.92f, 1.08f);
					src.PlayOneShot(clip, num);
				}
			}
		}
	}
	internal class Spinner : MonoBehaviour
	{
		public Vector3 axis = Vector3.up;

		public float speed = 90f;

		public bool onlyWhenHeld = true;

		private PhysGrabObject pgo;

		private float current;

		private void Awake()
		{
			pgo = ((Component)this).GetComponentInParent<PhysGrabObject>();
		}

		private void Update()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			bool flag = !onlyWhenHeld || ((Object)(object)pgo != (Object)null && pgo.grabbed);
			current = Mathf.MoveTowards(current, flag ? speed : 0f, Mathf.Abs(speed) * Time.deltaTime * 2f);
			if (Mathf.Abs(current) > 0.01f)
			{
				((Component)this).transform.Rotate(axis, current * Time.deltaTime, (Space)1);
			}
		}
	}
	internal class Glow : MonoBehaviour
	{
		public Color color = Color.white;

		public float minIntensity = 0.5f;

		public float maxIntensity = 2f;

		public float speed = 3f;

		public Light lightSource;

		public float lightMax = 1.5f;

		private Material mat;

		private void Awake()
		{
			Renderer component = ((Component)this).GetComponent<Renderer>();
			if ((Object)(object)component != (Object)null)
			{
				mat = component.material;
			}
			if ((Object)(object)mat != (Object)null)
			{
				mat.EnableKeyword("_EMISSION");
				mat.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
			}
		}

		private void Update()
		{
			//IL_006b: 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)
			float num = (Mathf.Sin(Time.time * speed + (float)((Object)this).GetInstanceID() * 0.37f) + 1f) * 0.5f;
			float num2 = Mathf.Lerp(minIntensity, maxIntensity, num);
			if ((Object)(object)mat != (Object)null && mat.HasProperty("_EmissionColor"))
			{
				mat.SetColor("_EmissionColor", color * num2);
			}
			if ((Object)(object)lightSource != (Object)null)
			{
				lightSource.intensity = Mathf.Lerp(lightMax * 0.5f, lightMax, num);
			}
		}
	}
	internal class BlindOnHold : MonoBehaviour
	{
		public Blind kind = Blind.White;

		private PhysGrabObject pgo;

		private void Awake()
		{
			pgo = ((Component)this).GetComponentInParent<PhysGrabObject>();
		}

		private void Update()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pgo == (Object)null || pgo.playerGrabbing == null)
			{
				return;
			}
			bool flag = false;
			foreach (PhysGrabber item in pgo.playerGrabbing)
			{
				if ((Object)(object)item != (Object)null && item.isLocal)
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				float num = 0.88f + 0.12f * Mathf.PerlinNoise(Time.time * 9f, 0.5f);
				BlindOverlay.Request(new Color(1f, 0.97f, 0.85f), 1f * num);
			}
		}
	}
	internal class BlindOverlay : MonoBehaviour
	{
		private static BlindOverlay inst;

		private float heldAlpha;

		private float requested;

		private Color heldColor = Color.white;

		private float flashAlpha;

		private float flashPeak;

		private float flashHold;

		private float flashFade = 1f;

		private Color flashColor = Color.white;

		private AudioSource ringSrc;

		public static void Create()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			if (!((Object)(object)inst != (Object)null))
			{
				GameObject val = new GameObject("MV_BlindOverlay");
				Object.DontDestroyOnLoad((Object)(object)val);
				inst = val.AddComponent<BlindOverlay>();
				inst.ringSrc = val.AddComponent<AudioSource>();
				inst.ringSrc.playOnAwake = false;
				inst.ringSrc.spatialBlend = 0f;
				AudioMixerGroup val2 = GameAudio.Group;
				if ((Object)(object)val2 != (Object)null)
				{
					inst.ringSrc.outputAudioMixerGroup = val2;
				}
			}
		}

		public static void Request(Color c, float strength)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)inst == (Object)null))
			{
				inst.heldColor = c;
				inst.requested = Mathf.Max(inst.requested, strength);
			}
		}

		public static void Flash(Color c, float strength, float hold, float fade)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)inst == (Object)null))
			{
				inst.flashColor = c;
				inst.flashPeak = Mathf.Clamp01(strength);
				inst.flashAlpha = inst.flashPeak;
				inst.flashHold = hold;
				inst.flashFade = Mathf.Max(0.1f, fade);
				if ((Object)(object)inst.ringSrc != (Object)null && (Object)(object)SoundKit.Ring != (Object)null)
				{
					inst.ringSrc.PlayOneShot(SoundKit.Ring, Mathf.Clamp01(strength) * Plugin.SoundVolume.Value);
				}
			}
		}

		private void LateUpdate()
		{
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			float num = ((requested > heldAlpha) ? 3f : 1.5f);
			heldAlpha = Mathf.MoveTowards(heldAlpha, requested, unscaledDeltaTime * num);
			requested = 0f;
			if (flashHold > 0f)
			{
				flashHold -= unscaledDeltaTime;
			}
			else if (flashAlpha > 0f)
			{
				flashAlpha = Mathf.MoveTowards(flashAlpha, 0f, flashPeak / flashFade * unscaledDeltaTime);
			}
		}

		private void OnGUI()
		{
			//IL_0032: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(heldAlpha, flashAlpha);
			if (!(num <= 0.002f))
			{
				Color val = ((flashAlpha >= heldAlpha) ? flashColor : heldColor);
				GUI.depth = -10000;
				Color color = GUI.color;
				GUI.color = new Color(val.r, val.g, val.b, Mathf.Clamp01(num));
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = color;
			}
		}
	}
	internal class LampBurst : MonoBehaviour
	{
		public float maxDistance = 45f;

		public float coneDegrees = 80f;

		public bool requireLineOfSight = true;

		private bool fired;

		private PhysGrabObject pgo;

		private void Awake()
		{
			pgo = ((Component)this).GetComponentInParent<PhysGrabObject>();
		}

		public static void OnDestroying(Component source)
		{
			if (!((Object)(object)source == (Object)null))
			{
				LampBurst componentInParent = source.GetComponentInParent<LampBurst>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					componentInParent.Fire(force: false);
				}
			}
		}

		public void Fire(bool force)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_00a2: 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)
			if (fired && !force)
			{
				return;
			}
			fired = true;
			Vector3 val = ((Component)this).transform.position + Vector3.up * 0.2f;
			SpawnWorldFlash(val);
			Camera val2 = FindPlayerCamera();
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)val2).transform.position;
			Vector3 val3 = val - position;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			if (!(magnitude > maxDistance) && !(magnitude < 0.01f))
			{
				float num = Vector3.Angle(((Component)val2).transform.forward, val3);
				if (!(num > coneDegrees) && (!requireLineOfSight || !IsBlocked(position, val3 / magnitude, magnitude)))
				{
					float num2 = 1f - num / coneDegrees;
					float num3 = Mathf.Clamp01(1.3f - magnitude / maxDistance);
					float strength = Mathf.Clamp01((0.6f + 0.4f * num2) * (0.5f + 0.5f * num3));
					float hold = Mathf.Lerp(0.8f, 3.5f, num2) * Mathf.Lerp(0.6f, 1f, num3);
					float fade = Mathf.Lerp(2f, 6f, num2);
					BlindOverlay.Flash(new Color(1f, 0.97f, 0.85f), strength, hold, fade);
				}
			}
		}

		private bool IsBlocked(Vector3 from, Vector3 dir, float dist)
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.RaycastAll(from, dir, Mathf.Max(0.1f, dist - 0.3f), -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (!(((RaycastHit)(ref val)).distance < 1f) && !((Component)((RaycastHit)(ref val)).collider).transform.IsChildOf(((Component)this).transform))
				{
					return true;
				}
			}
			return false;
		}

		private static Camera FindPlayerCamera()
		{
			Camera main = Camera.main;
			if ((Object)(object)main != (Object)null && ((Behaviour)main).enabled && ((Component)main).gameObject.activeInHierarchy)
			{
				return main;
			}
			main = null;
			Camera[] allCameras = Camera.allCameras;
			foreach (Camera val in allCameras)
			{
				if (!((Object)(object)val == (Object)null) && ((Behaviour)val).enabled && !((Object)(object)val.targetTexture != (Object)null) && ((Object)(object)main == (Object)null || val.depth > main.depth))
				{
					main = val;
				}
			}
			return main;
		}

		private static void SpawnWorldFlash(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_0010: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("MV_LampFlash");
			val.transform.position = pos;
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.range = 30f;
			obj.intensity = 12f;
			obj.color = new Color(1f, 0.95f, 0.8f);
			obj.shadows = (LightShadows)0;
			val.AddComponent<LightFade>();
		}
	}
	internal class LightFade : MonoBehaviour
	{
		private Light l;

		private float start;

		private void Start()
		{
			l = ((Component)this).GetComponent<Light>();
			start = (((Object)(object)l != (Object)null) ? l.intensity : 0f);
		}

		private void Update()
		{
			if ((Object)(object)l == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			l.intensity = Mathf.MoveTowards(l.intensity, 0f, start * Time.deltaTime / 1.2f);
			if (l.intensity <= 0.01f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	internal static class MeshKit
	{
		public static Material BaseMaterial;

		private static readonly Dictionary<string, Mesh> MeshCache = new Dictionary<string, Mesh>();

		private static readonly Dictionary<string, Material> MatCache = new Dictionary<string, Material>();

		private const float BoxR = 0.70710677f;

		public static Mesh Lathe(string key, float[] r, float[] y, int seg, float angOffsetDeg, Vector3 scale)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			if (MeshCache.TryGetValue(key, out var value))
			{
				return value;
			}
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			float num = MathF.PI * 2f / (float)seg;
			float num2 = angOffsetDeg * (MathF.PI / 180f);
			for (int i = 0; i < r.Length - 1; i++)
			{
				for (int j = 0; j < seg; j++)
				{
					float num3 = num2 + (float)j * num;
					float a = num3 + num;
					Vector3 a2 = P(r[i], y[i], num3, scale);
					Vector3 b = P(r[i + 1], y[i + 1], num3, scale);
					Vector3 val = P(r[i + 1], y[i + 1], a, scale);
					Vector3 c = P(r[i], y[i], a, scale);
					AddTri(list, list2, a2, b, val);
					AddTri(list, list2, a2, val, c);
				}
			}
			Mesh val2 = new Mesh
			{
				name = key
			};
			val2.SetVertices(list);
			val2.SetTriangles(list2, 0);
			Vector2[] array = (Vector2[])(object)new Vector2[list.Count];
			for (int k = 0; k < array.Length; k++)
			{
				array[k] = new Vector2(list[k].x, list[k].z);
			}
			val2.uv = array;
			val2.RecalculateNormals();
			val2.RecalculateBounds();
			MeshCache[key] = val2;
			return val2;
		}

		private static Vector3 P(float r, float y, float a, Vector3 scale)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(r * Mathf.Cos(a) * scale.x, y * scale.y, r * Mathf.Sin(a) * scale.z);
		}

		private static void AddTri(List<Vector3> verts, List<int> tris, Vector3 a, Vector3 b, Vector3 c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.Cross(b - a, c - a);
			if (!(((Vector3)(ref val)).sqrMagnitude < 1E-12f))
			{
				int count = verts.Count;
				verts.Add(a);
				verts.Add(b);
				verts.Add(c);
				tris.Add(count);
				tris.Add(count + 1);
				tris.Add(count + 2);
			}
		}

		public static Mesh Box(float w, float h, float d, float topScale = 1f)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			return Lathe($"box_{w:F3}_{h:F3}_{d:F3}_{topScale:F2}", new float[4]
			{
				0f,
				0.70710677f,
				0.70710677f * topScale,
				0f
			}, new float[4] { -0.5f, -0.5f, 0.5f, 0.5f }, 4, 45f, new Vector3(w, h, d));
		}

		public static Mesh Cyl(float radius, float height, int seg = 8, float topScale = 1f)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			return Lathe($"cyl_{radius:F3}_{height:F3}_{seg}_{topScale:F2}", new float[4]
			{
				0f,
				radius,
				radius * topScale,
				0f
			}, new float[4]
			{
				(0f - height) / 2f,
				(0f - height) / 2f,
				height / 2f,
				height / 2f
			}, seg, 0f, Vector3.one);
		}

		public static Mesh Cone(float radius, float height, int seg = 8)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			return Lathe($"cone_{radius:F3}_{height:F3}_{seg}", new float[3] { 0f, radius, 0f }, new float[3]
			{
				(0f - height) / 2f,
				(0f - height) / 2f,
				height / 2f
			}, seg, 0f, Vector3.one);
		}

		public static Mesh Crystal(float radius, float body, float tip, int seg = 6)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			return Lathe($"crystal_{radius:F3}_{body:F3}_{tip:F3}_{seg}", new float[4] { 0f, radius, radius, 0f }, new float[4]
			{
				(0f - body) / 2f - tip,
				(0f - body) / 2f,
				body / 2f,
				body / 2f + tip
			}, seg, 0f, Vector3.one);
		}

		public static Mesh Sphere(float radius, int seg = 10)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			string key = $"sphere_{radius:F3}_{seg}";
			float[] array = new float[7];
			float[] array2 = new float[7];
			for (int i = 0; i < 7; i++)
			{
				float num = (-90f + (float)i * 30f) * (MathF.PI / 180f);
				array[i] = Mathf.Max(0f, radius * Mathf.Cos(num));
				array2[i] = radius * Mathf.Sin(num);
			}
			array[0] = 0f;
			array[6] = 0f;
			return Lathe(key, array, array2, seg, 0f, Vector3.one);
		}

		public static Transform Group(Transform parent, string name, Vector3 pos, Vector3 euler)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = pos;
			val.transform.localEulerAngles = euler;
			return val.transform;
		}

		public static Transform Part(Transform parent, string name, Mesh mesh, Vector3 pos, Vector3 euler, Color color, float emission = 0f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.transform.localPosition = pos;
			val.transform.localEulerAngles = euler;
			val.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = GetMaterial(color, emission);
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
			((Renderer)obj).receiveShadows = true;
			return val.transform;
		}

		public static Transform Part(Transform parent, string name, Mesh mesh, Vector3 pos, Color color, float emission = 0f)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return Part(parent, name, mesh, pos, Vector3.zero, color, emission);
		}

		public static Material GetMaterial(Color color, float emission)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0088: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			string text = $"{color.r:F2}_{color.g:F2}_{color.b:F2}_{emission:F2}";
			if (MatCache.TryGetValue(text, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Material val = CreateBase();
			((Object)val).name = "MV_" + text;
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", color);
			}
			string[] array = new string[7] { "_MainTex", "_BaseMap", "_BumpMap", "_NormalMap", "_MetallicGlossMap", "_OcclusionMap", "_EmissionMap" };
			foreach (string text2 in array)
			{
				if (val.HasProperty(text2))
				{
					val.SetTexture(text2, (Texture)null);
				}
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0.15f);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0.25f);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", 0.25f);
			}
			if (emission > 0f)
			{
				val.EnableKeyword("_EMISSION");
				val.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
				if (val.HasProperty("_EmissionColor"))
				{
					val.SetColor("_EmissionColor", color * emission);
				}
			}
			MatCache[text] = val;
			return val;
		}

		private static Material CreateBase()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			if ((Object)(object)BaseMaterial != (Object)null)
			{
				Material val = new Material(BaseMaterial);
				if (val.HasProperty("_Color") || val.HasProperty("_BaseColor"))
				{
					return val;
				}
			}
			Shader val2 = Shader.Find("Standard") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("HDRP/Lit") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default");
			return ((Object)(object)val2 != (Object)null) ? new Material(val2) : new Material(BaseMaterial);
		}

		public static bool GetModelBounds(Transform root, out Bounds bounds)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00a6: 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_00ad: 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)
			bounds = new Bounds(Vector3.zero, Vector3.zero);
			bool flag = false;
			MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if ((Object)(object)val.sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds2 = val.sharedMesh.bounds;
				for (int j = 0; j < 8; j++)
				{
					Vector3 val2 = ((Bounds)(ref bounds2)).center + Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)(((j & 1) != 0) ? 1 : (-1)), (float)(((j & 2) != 0) ? 1 : (-1)), (float)(((j & 4) != 0) ? 1 : (-1))));
					Vector3 val3 = root.InverseTransformPoint(((Component)val).transform.TransformPoint(val2));
					if (!flag)
					{
						bounds = new Bounds(val3, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val3);
					}
				}
			}
			return flag;
		}
	}
	internal class Def
	{
		public string Id;

		public string Name;

		public string Size;

		public float Value = 1f;

		public float Mass = 1f;

		public float Fragility = 1f;

		public float Durability = 1f;

		public Loop Loop;

		public float LoopVolume = 0.5f;

		public Hit Hit;

		public Blind Blind;

		public int Compound = 1;

		public float Longest;

		public bool AllowTilt;

		public Action<Transform> Build;
	}
	internal static class Models
	{
		private static readonly Color Steel = new Color(0.55f, 0.58f, 0.62f);

		private static readonly Color DarkSteel = new Color(0.28f, 0.3f, 0.34f);

		private static readonly Color Dark = new Color(0.15f, 0.16f, 0.19f);

		private static readonly Color Copper = new Color(0.86f, 0.5f, 0.27f);

		private static readonly Color CopperLight = new Color(0.95f, 0.68f, 0.45f);

		private static readonly Color Yellow = new Color(1f, 0.83f, 0.4f);

		private static readonly Color Gold = new Color(0.95f, 0.78f, 0.3f);

		private static readonly Color Titan = new Color(0.62f, 0.74f, 0.95f);

		private static readonly Color Pink = new Color(0.95f, 0.45f, 0.85f);

		private static readonly Color Cyan = new Color(0.4f, 0.9f, 1f);

		private static readonly Color Red = new Color(1f, 0.25f, 0.2f);

		private static readonly Color Blue = new Color(0.2f, 0.35f, 0.7f);

		private static readonly Color Orange = new Color(1f, 0.6f, 0.2f);

		private static readonly Color Chip = new Color(0.16f, 0.18f, 0.28f);

		public static List<Def> All()
		{
			return new List<Def>
			{
				new Def
				{
					Id = "copper_ingot",
					Name = "Copper Ingot",
					Size = "tiny",
					Value = 0.8f,
					Mass = 1.4f,
					Fragility = 0.5f,
					Longest = 0.26f,
					Hit = Hit.Clang,
					Build = CopperIngot
				},
				new Def
				{
					Id = "silicon_chip",
					Name = "Silicon Chip",
					Size = "tiny",
					Value = 1.3f,
					Mass = 0.8f,
					Fragility = 1.3f,
					Hit = Hit.Plink,
					Longest = 0.26f,
					Build = SiliconChip
				},
				new Def
				{
					Id = "titanium_shard",
					Name = "Titanium Shard",
					Size = "small",
					Value = 1.5f,
					Mass = 1.2f,
					Fragility = 0.8f,
					Hit = Hit.Clang,
					Build = TitaniumShard
				},
				new Def
				{
					Id = "thorium_cell",
					Name = "Thorium Cell",
					Size = "small",
					Value = 2.4f,
					Mass = 1.5f,
					Fragility = 1.1f,
					Loop = Loop.Hum,
					LoopVolume = 0.35f,
					Hit = Hit.Thud,
					Build = ThoriumCell
				},
				new Def
				{
					Id = "twin_turret",
					Name = "Twin Turret",
					Size = "small",
					Value = 1.3f,
					Mass = 1.3f,
					Fragility = 0.9f,
					Hit = Hit.Clang,
					Build = TwinTurret
				},
				new Def
				{
					Id = "scout_drone",
					Name = "Scout Drone",
					Size = "small",
					Value = 1.5f,
					Mass = 0.6f,
					Fragility = 1.4f,
					Loop = Loop.Whirr,
					LoopVolume = 0.35f,
					Hit = Hit.Plink,
					Build = ScoutDrone
				},
				new Def
				{
					Id = "crawler_bot",
					Name = "Crawler Bot",
					Size = "small",
					Value = 1f,
					Mass = 0.8f,
					Fragility = 1.2f,
					Hit = Hit.Thud,
					Build = CrawlerBot
				},
				new Def
				{
					Id = "walker_mech",
					Name = "Walker Mech",
					Size = "medium",
					Value = 1.7f,
					Mass = 1.3f,
					Fragility = 1f,
					Loop = Loop.Servo,
					LoopVolume = 0.5f,
					Hit = Hit.Clang,
					Build = WalkerMech
				},
				new Def
				{
					Id = "mining_drill",
					Name = "Mining Drill",
					Size = "medium",
					Value = 1.4f,
					Mass = 1.5f,
					Fragility = 0.8f,
					Loop = Loop.Drill,
					LoopVolume = 0.45f,
					Hit = Hit.Clang,
					Build = MiningDrill
				},
				new Def
				{
					Id = "overdrive_lamp",
					Name = "Overdrive Lamp",
					Size = "medium",
					Value = 1.8f,
					Mass = 0.8f,
					Fragility = 1.4f,
					Loop = Loop.Hum,
					LoopVolume = 0.3f,
					Hit = Hit.Plink,
					Blind = Blind.White,
					Build = OverdriveLamp
				},
				new Def
				{
					Id = "beam_tower",
					Name = "Beam Tower",
					Size = "tall",
					Value = 2f,
					Mass = 1.2f,
					Fragility = 1.2f,
					Loop = Loop.Beam,
					LoopVolume = 0.4f,
					Hit = Hit.Clang,
					Build = BeamTower
				},
				new Def
				{
					Id = "solar_array",
					Name = "Solar Array",
					Size = "wide",
					Value = 1.2f,
					Mass = 0.9f,
					Fragility = 1.5f,
					Hit = Hit.Plink,
					AllowTilt = true,
					Build = SolarArray
				},
				new Def
				{
					Id = "conveyor_segment",
					Name = "Conveyor Segment",
					Size = "wide",
					Value = 1f,
					Mass = 1.2f,
					Fragility = 0.7f,
					Loop = Loop.Belt,
					LoopVolume = 0.4f,
					Hit = Hit.Clang,
					Build = ConveyorSegment
				},
				new Def
				{
					Id = "storage_vault",
					Name = "Storage Vault",
					Size = "big",
					Value = 1.8f,
					Mass = 1.6f,
					Fragility = 0.6f,
					Hit = Hit.Thud,
					Build = StorageVault
				},
				new Def
				{
					Id = "reactor_core",
					Name = "Reactor Core",
					Size = "big",
					Value = 3f,
					Mass = 1.5f,
					Fragility = 1f,
					Loop = Loop.Hum,
					LoopVolume = 0.55f,
					Hit = Hit.Thud,
					Build = ReactorCore
				}
			};
		}

		private static Transform Bx(Transform p, string n, float w, float h, float d, Vector3 pos, Color c, float em = 0f, float top = 1f, Vector3 rot = default(Vector3))
		{
			//IL_000d: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			return MeshKit.Part(p, n, MeshKit.Box(w, h, d, top), pos, rot, c, em);
		}

		private static Transform Cy(Transform p, string n, float r, float h, Vector3 pos, Color c, int seg = 8, float em = 0f, Vector3 rot = default(Vector3), float top = 1f)
		{
			//IL_000d: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			return MeshKit.Part(p, n, MeshKit.Cyl(r, h, seg, top), pos, rot, c, em);
		}

		private static Transform Cr(Transform p, string n, float r, float body, float tip, Vector3 pos, Vector3 rot, Color c, int seg = 6, float em = 0f)
		{
			//IL_000d: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			return MeshKit.Part(p, n, MeshKit.Crystal(r, body, tip, seg), pos, rot, c, em);
		}

		private static void AddGlow(Transform t, Color c, float min, float max, float speed, Light l = null, float lightMax = 1.5f)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Glow glow = ((Component)t).gameObject.AddComponent<Glow>();
			glow.color = c;
			glow.minIntensity = min;
			glow.maxIntensity = max;
			glow.speed = speed;
			glow.lightSource = l;
			glow.lightMax = lightMax;
		}

		private static void AddSpin(Transform t, Vector3 axis, float speed, bool onlyHeld = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Spinner spinner = ((Component)t).gameObject.AddComponent<Spinner>();
			spinner.axis = axis;
			spinner.speed = speed;
			spinner.onlyWhenHeld = onlyHeld;
		}

		private static void CopperIngot(Transform t)
		{
			//IL_0027: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			Action<Vector3, float, string> obj = delegate(Vector3 pos, float yaw, string name)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: 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)
				Transform p = MeshKit.Group(t, name, pos, new Vector3(0f, yaw, 0f));
				Bx(p, "Body", 0.3f, 0.09f, 0.14f, Vector3.zero, Copper, 0f, 0.78f);
				Bx(p, "Shine", 0.2f, 0.012f, 0.07f, new Vector3(0f, 0.046f, 0f), CopperLight);
			};
			obj(new Vector3(-0.17f, 0.045f, 0f), 0f, "IngotA");
			obj(new Vector3(0.17f, 0.045f, 0f), 0f, "IngotB");
			obj(new Vector3(0f, 0.135f, 0f), 90f, "IngotC");
		}

		private static void SiliconChip(Transform t)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			Bx(t, "Board", 0.26f, 0.035f, 0.26f, Vector3.zero, Chip);
			Bx(t, "Die", 0.14f, 0.02f, 0.14f, new Vector3(0f, 0.0275f, 0f), new Color(0.32f, 0.35f, 0.5f), 0.1f);
			for (int i = 0; i < 5; i++)
			{
				float num = -0.08f + (float)i * 0.04f;
				Bx(t, "PinN" + i, 0.018f, 0.008f, 0.04f, new Vector3(num, 0f, 0.15f), Gold);
				Bx(t, "PinS" + i, 0.018f, 0.008f, 0.04f, new Vector3(num, 0f, -0.15f), Gold);
				Bx(t, "PinE" + i, 0.04f, 0.008f, 0.018f, new Vector3(0.15f, 0f, num), Gold);
				Bx(t, "PinW" + i, 0.04f, 0.008f, 0.018f, new Vector3(-0.15f, 0f, num), Gold);
			}
		}

		private static void TitaniumShard(Transform t)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010d: Unknown result type (might be due to invalid IL or missing references)
			Cy(t, "Base", 0.13f, 0.03f, new Vector3(0f, -0.1f, 0f), DarkSteel, 7);
			Cr(t, "CrystalMain", 0.05f, 0.16f, 0.07f, new Vector3(0f, 0.02f, 0f), Vector3.zero, Titan, 6, 0.15f);
			Cr(t, "CrystalL", 0.04f, 0.11f, 0.055f, new Vector3(-0.07f, -0.02f, 0.02f), new Vector3(8f, 0f, 16f), Titan, 6, 0.12f);
			Cr(t, "CrystalR", 0.04f, 0.1f, 0.05f, new Vector3(0.07f, -0.03f, -0.02f), new Vector3(-8f, 0f, -18f), Titan, 6, 0.12f);
		}

		private static void ThoriumCell(Transform t)
		{
			//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)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			Cy(t, "Canister", 0.08f, 0.22f, Vector3.zero, DarkSteel);
			Cy(t, "CapTop", 0.095f, 0.025f, new Vector3(0f, 0.12f, 0f), Yellow);
			Cy(t, "CapBottom", 0.095f, 0.025f, new Vector3(0f, -0.12f, 0f), Yellow);
			for (int i = 0; i < 4; i++)
			{
				float num = (float)i * 90f * (MathF.PI / 180f) + MathF.PI / 4f;
				AddGlow(Cy(t, "Rod" + i, 0.018f, 0.2f, new Vector3(Mathf.Cos(num) * 0.068f, 0f, Mathf.Sin(num) * 0.068f), Pink, 6, 1f), Pink, 0.6f, 2.2f, 2.5f);
			}
		}

		private static void TwinTurret(Transform t)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0062: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_01c1: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			Cy(t, "Base", 0.13f, 0.05f, new Vector3(0f, -0.06f, 0f), DarkSteel);
			Cy(t, "Pedestal", 0.08f, 0.06f, new Vector3(0f, -0.005f, 0f), Dark);
			Transform val = MeshKit.Group(t, "Head", new Vector3(0f, 0.07f, 0f), Vector3.zero);
			Bx(val, "Body", 0.15f, 0.08f, 0.13f, Vector3.zero, Steel);
			Bx(val, "Armor", 0.12f, 0.03f, 0.1f, new Vector3(0f, 0.05f, -0.005f), Yellow);
			for (int i = -1; i <= 1; i += 2)
			{
				Cy(val, "Barrel" + i, 0.018f, 0.16f, new Vector3((float)i * 0.04f, 0.005f, 0.12f), Copper, 6, 0f, new Vector3(90f, 0f, 0f));
				Cy(val, "Muzzle" + i, 0.024f, 0.02f, new Vector3((float)i * 0.04f, 0.005f, 0.205f), Dark, 6, 0f, new Vector3(90f, 0f, 0f));
			}
			AddSpin(val, Vector3.up, 25f);
		}

		private static void ScoutDrone(Transform t)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			Bx(t, "Body", 0.1f, 0.045f, 0.2f, Vector3.zero, Steel);
			MeshKit.Part(t, "Nose", MeshKit.Cone(0.05f, 0.1f, 4), new Vector3(0f, 0f, 0.14f), new Vector3(90f, 45f, 0f), Steel);
			for (int i = -1; i <= 1; i += 2)
			{
				Bx(t, "Wing" + i, 0.2f, 0.012f, 0.1f, new Vector3((float)i * 0.13f, 0f, -0.03f), Yellow, 0f, 1f, new Vector3(0f, (float)i * -30f, 0f));
				Cy(t, "Thruster" + i, 0.02f, 0.05f, new Vector3((float)i * 0.04f, 0f, -0.115f), Dark, 6, 0f, new Vector3(90f, 0f, 0f));
				AddGlow(Cy(t, "Flame" + i, 0.014f, 0.02f, new Vector3((float)i * 0.04f, 0f, -0.145f), Orange, 6, 1f, new Vector3(90f, 0f, 0f)), Orange, 0.8f, 2.5f, 14f);
			}
			AddGlow(Bx(t, "Eye", 0.05f, 0.015f, 0.03f, new Vector3(0f, 0.03f, 0.05f), Cyan, 1f), Cyan, 0.8f, 1.8f, 3f);
		}

		private static void CrawlerBot(Transform t)
		{
			//IL_0010: 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_002f: 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_0084: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			Cy(t, "Body", 0.09f, 0.07f, Vector3.zero, new Color(0.35f, 0.38f, 0.42f), 6, 0f, Vector3.zero, 0.8f);
			for (int i = 0; i < 6; i++)
			{
				Bx(MeshKit.Group(t, "Leg" + i, new Vector3(0f, -0.01f, 0f), new Vector3(0f, (float)i * 60f + 30f, 0f)), "Seg", 0.016f, 0.016f, 0.1f, new Vector3(0f, -0.01f, 0.11f), DarkSteel, 0f, 1f, new Vector3(35f, 0f, 0f));
			}
			AddGlow(Bx(t, "Eye", 0.05f, 0.02f, 0.02f, new Vector3(0f, 0.01f, 0.085f), Red, 1f), Red, 0.5f, 2.5f, 8f);
			Bx(t, "Stripe", 0.09f, 0.012f, 0.03f, new Vector3(0f, 0.04f, -0.02f), Yellow);
		}

		private static void WalkerMech(Transform t)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: 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_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: 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_0323: 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_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = -1; i <= 1; i += 2)
			{
				Bx(t, "Foot" + i, 0.09f, 0.04f, 0.14f, new Vector3((float)i * 0.1f, -0.3f, 0.02f), DarkSteel);
				Bx(t, "Shin" + i, 0.05f, 0.18f, 0.05f, new Vector3((float)i * 0.1f, -0.19f, 0f), Steel);
				Bx(t, "Thigh" + i, 0.06f, 0.1f, 0.07f, new Vector3((float)i * 0.1f, -0.06f, 0f), DarkSteel);
			}
			Bx(t, "Hip", 0.28f, 0.07f, 0.12f, new Vector3(0f, 0.03f, 0f), Dark);
			Bx(t, "Torso", 0.26f, 0.2f, 0.18f, new Vector3(0f, 0.16f, 0f), Steel, 0f, 0.9f);
			Bx(t, "Stripe", 0.27f, 0.035f, 0.185f, new Vector3(0f, 0.19f, 0f), Yellow, 0f, 0.9f);
			Bx(t, "Head", 0.12f, 0.08f, 0.1f, new Vector3(0f, 0.31f, 0.01f), DarkSteel);
			AddGlow(Bx(t, "Visor", 0.09f, 0.025f, 0.01f, new Vector3(0f, 0.315f, 0.065f), Cyan, 1f), Cyan, 0.8f, 1.6f, 2f);
			Cy(t, "Cannon", 0.03f, 0.22f, new Vector3(0.18f, 0.22f, 0.1f), Copper, 6, 0f, new Vector3(90f, 0f, 0f));
			Bx(t, "CannonMount", 0.06f, 0.08f, 0.08f, new Vector3(0.17f, 0.2f, 0f), DarkSteel);
			Bx(t, "ArmL", 0.05f, 0.16f, 0.05f, new Vector3(-0.17f, 0.15f, 0.02f), Steel);
		}

		private static void MiningDrill(Transform t)
		{
			//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_003a: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00ad: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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_0175: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			Bx(t, "Base", 0.4f, 0.1f, 0.4f, new Vector3(0f, -0.1f, 0f), DarkSteel);
			Bx(t, "Housing", 0.3f, 0.22f, 0.3f, new Vector3(0f, 0.06f, 0f), Steel, 0f, 0.92f);
			Cy(t, "Ring", 0.12f, 0.04f, new Vector3(0f, 0.19f, 0f), Dark, 10);
			for (int i = 0; i < 4; i++)
			{
				float num = (float)i * 90f + 45f;
				Bx(t, "Bolt" + i, 0.04f, 0.04f, 0.04f, new Vector3(Mathf.Cos(num * (MathF.PI / 180f)) * 0.18f, -0.03f, Mathf.Sin(num * (MathF.PI / 180f)) * 0.18f), Yellow);
			}
			Transform val = MeshKit.Group(t, "Rotor", new Vector3(0f, 0.22f, 0f), Vector3.zero);
			Cy(val, "Hub", 0.04f, 0.06f, Vector3.zero, Copper);
			for (int j = 0; j < 4; j++)
			{
				Bx(val, "Blade" + j, 0.14f, 0.02f, 0.04f, Vector3.zero, CopperLight, 0f, 1f, new Vector3(0f, (float)j * 45f, 0f));
			}
			AddSpin(val, Vector3.up, 360f);
		}

		private static void OverdriveLamp(Transform t)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0062: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: 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_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			Cy(t, "Base", 0.16f, 0.06f, new Vector3(0f, -0.15f, 0f), DarkSteel);
			Cy(t, "Stem", 0.04f, 0.14f, new Vector3(0f, -0.06f, 0f), Steel, 6);
			Cy(t, "Collar", 0.075f, 0.025f, new Vector3(0f, 0.015f, 0f), Yellow);
			Transform val = MeshKit.Part(t, "Orb", MeshKit.Sphere(0.13f), new Vector3(0f, 0.15f, 0f), Vector3.zero, new Color(1f, 0.95f, 0.7f), 1f);
			GameObject val2 = new GameObject("LampLight");
			val2.transform.SetParent(val, false);
			Light val3 = val2.AddComponent<Light>();
			val3.type = (LightType)2;
			val3.range = 6f;
			val3.intensity = 1.2f;
			val3.color = new Color(1f, 0.95f, 0.75f);
			val3.shadows = (LightShadows)0;
			AddGlow(val, new Color(1f, 0.95f, 0.7f), 1f, 3f, 5f, val3);
			for (int i = 0; i < 4; i++)
			{
				float num = (float)i * 90f * (MathF.PI / 180f);
				Bx(t, "Cage" + i, 0.014f, 0.3f, 0.014f, new Vector3(Mathf.Cos(num) * 0.15f, 0.15f, Mathf.Sin(num) * 0.15f), Yellow);
			}
			Cy(t, "Cap", 0.11f, 0.03f, new Vector3(0f, 0.31f, 0f), Yellow);
		}

		private static void BeamTower(Transform t)
		{
			//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_003a: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00ad: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_0102: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			Bx(t, "Base", 0.3f, 0.08f, 0.3f, new Vector3(0f, -0.36f, 0f), DarkSteel);
			Bx(t, "Shaft", 0.22f, 0.4f, 0.22f, new Vector3(0f, -0.12f, 0f), Steel, 0f, 0.6f);
			Cy(t, "Neck", 0.05f, 0.12f, new Vector3(0f, 0.14f, 0f), Dark);
			Cy(t, "Ring", 0.12f, 0.03f, new Vector3(0f, 0.22f, 0f), Yellow);
			AddGlow(Cr(t, "Crystal", 0.06f, 0.14f, 0.07f, new Vector3(0f, 0.34f, 0f), Vector3.zero, Cyan, 6, 1f), Cyan, 0.6f, 2.4f, 3.5f);
			for (int i = 0; i < 4; i++)
			{
				float num = (float)i * 90f * (MathF.PI / 180f);
				Bx(t, "Prong" + i, 0.02f, 0.18f, 0.02f, new Vector3(Mathf.Cos(num) * 0.1f, 0.32f, Mathf.Sin(num) * 0.1f), Steel, 0f, 1f, new Vector3(Mathf.Sin(num) * 12f, 0f, (0f - Mathf.Cos(num)) * 12f));
			}
		}

		private static void SolarArray(Transform t)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_005c: 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_0072: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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)
			Bx(t, "Frame", 0.8f, 0.03f, 0.5f, Vector3.zero, DarkSteel);
			Bx(t, "Panel", 0.76f, 0.012f, 0.46f, new Vector3(0f, 0.02f, 0f), Blue, 0.15f);
			for (int i = 1; i < 4; i++)
			{
				Bx(t, "GridX" + i, 0.006f, 0.004f, 0.46f, new Vector3(-0.38f + (float)i * 0.19f, 0.028f, 0f), Titan);
			}
			for (int j = 1; j < 3; j++)
			{
				Bx(t, "GridZ" + j, 0.76f, 0.004f, 0.006f, new Vector3(0f, 0.028f, -0.23f + (float)j * 0.153f), Titan);
			}
			Bx(t, "FootL", 0.06f, 0.05f, 0.4f, new Vector3(-0.3f, -0.04f, 0f), Dark);
			Bx(t, "FootR", 0.06f, 0.05f, 0.4f, new Vector3(0.3f, -0.04f, 0f), Dark);
		}

		private static void ConveyorSegment(Transform t)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			Bx(t, "Bed", 0.7f, 0.05f, 0.22f, Vector3.zero, DarkSteel);
			for (int i = -1; i <= 1; i += 2)
			{
				Bx(t, "Rail" + i, 0.7f, 0.07f, 0.03f, new Vector3(0f, 0.03f, (float)i * 0.125f), Steel);
			}
			for (int j = 0; j < 7; j++)
			{
				AddSpin(Cy(t, "Roller" + j, 0.025f, 0.2f, new Vector3(-0.3f + (float)j * 0.1f, 0.035f, 0f), Dark, 6, 0f, new Vector3(90f, 0f, 0f)), Vector3.up, 400f);
			}
			Bx(t, "Stripe", 0.6f, 0.004f, 0.035f, new Vector3(0f, 0.062f, 0f), Yellow);
		}

		private static void StorageVault(Transform t)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Bx(t, "Body", 0.6f, 0.5f, 0.6f, Vector3.zero, Steel);
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					Bx(t, $"Post{i}{j}", 0.08f, 0.52f, 0.08f, new Vector3((float)i * 0.3f, 0f, (float)j * 0.3f), DarkSteel);
				}
			}
			Bx(t, "TopPlate", 0.64f, 0.04f, 0.64f, new Vector3(0f, 0.27f, 0f), Dark);
			Bx(t, "Stripe", 0.61f, 0.05f, 0.61f, new Vector3(0f, -0.1f, 0f), Yellow);
			Bx(t, "Door", 0.3f, 0.34f, 0.02f, new Vector3(0f, 0.02f, 0.31f), DarkSteel);
			AddSpin(Cy(t, "LockWheel", 0.06f, 0.03f, new Vector3(0f, 0.02f, 0.335f), Yellow, 10, 0f, new Vector3(90f, 0f, 0f)), Vector3.up, 60f);
		}

		private static void ReactorCore(Transform t)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0062: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: 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_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			Cy(t, "Base", 0.32f, 0.12f, new Vector3(0f, -0.18f, 0f), Dark, 6);
			Cy(t, "Rim", 0.335f, 0.025f, new Vector3(0f, -0.11f, 0f), Yellow, 6);
			Cy(t, "Column", 0.15f, 0.3f, new Vector3(0f, 0.04f, 0f), Steel);
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					Bx(t, $"Pylon{i}{j}", 0.06f, 0.3f, 0.06f, new Vector3((float)i * 0.22f, -0.03f, (float)j * 0.22f), DarkSteel);
					AddGlow(Cr(t, $"Tip{i}{j}", 0.025f, 0.03f, 0.04f, new Vector3((float)i * 0.22f, 0.17f, (float)j * 0.22f), Vector3.zero, Yellow, 4, 1f), Yellow, 0.6f, 2f, 3f);
				}
			}
			AddGlow(MeshKit.Part(t, "Orb", MeshKit.Sphere(0.11f), new Vector3(0f, 0.28f, 0f), Vector3.zero, new Color(1f, 0.85f, 0.45f), 1f), new Color(1f, 0.85f, 0.45f), 0.8f, 3f, 2f);
			Transform val = MeshKit.Group(t, "Halo", new Vector3(0f, 0.28f, 0f), Vector3.zero);
			for (int k = 0; k < 6; k++)
			{
				float num = (float)k * 60f * (MathF.PI / 180f);
				Bx(val, "HaloBit" + k, 0.04f, 0.015f, 0.04f, new Vector3(Mathf.Cos(num) * 0.19f, 0f, Mathf.Sin(num) * 0.19f), Gold, 0.5f);
			}
			AddSpin(val, Vector3.up, 120f);
		}
	}
	[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObjectRPC")]
	internal static class DestroyObjectRpcPatch
	{
		[HarmonyPrefix]
		private static void Prefix(PhysGrabObjectImpactDetector __instance)
		{
			try
			{
				LampBurst.OnDestroying((Component)(object)__instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("LampBurst: " + ex));
			}
		}
	}
	[BepInPlugin("mindustry.valuables", "MindustryValuables", "0.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "mindustry.valuables";

		public const string PluginName = "MindustryValuables";

		public const string PluginVersion = "0.1.2";

		internal static ManualLogSource Log;

		internal static ConfigEntry<float> ValueMultiplier;

		internal static ConfigEntry<float> SoundVolume;

		internal static ConfigEntry<float> Fragility;

		private readonly Dictionary<string, ConfigEntry<bool>> enabledMap = new Dictionary<string, ConfigEntry<bool>>();

		private List<Def> defs;

		private static readonly string[] Sizes = new string[7] { "tiny", "small", "medium", "big", "wide", "tall", "veryTall" };

		private static readonly Dictionary<string, string[]> Fallback = new Dictionary<string, string[]>
		{
			{
				"tiny",
				new string[2] { "tiny", "small" }
			},
			{
				"small",
				new string[3] { "small", "medium", "tiny" }
			},
			{
				"medium",
				new string[3] { "medium", "small", "big" }
			},
			{
				"big",
				new string[2] { "big", "medium" }
			},
			{
				"wide",
				new string[3] { "wide", "big", "medium" }
			},
			{
				"tall",
				new string[2] { "tall", "medium" }
			},
			{
				"veryTall",
				new string[3] { "veryTall", "tall", "big" }
			}
		};

		private void Awake()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			ValueMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ValueMultiplier", 1f, "Общий множитель цены всех ценностей мода (1 = как рассчитано, 2 = в два раза дороже).");
			SoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SoundVolume", 1f, new ConfigDescription("Громкость звуков мода (в руках и при ударе).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			Fragility = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FragilityMultiplier", 1.6f, new ConfigDescription("Насколько легко ценности ломаются при ударах (1 = как раньше, 2 = в два раза хрупче). Применяется при запуске игры.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 5f), Array.Empty<object>()));
			defs = Models.All();
			foreach (Def def in defs)
			{
				enabledMap[def.Id] = ((BaseUnityPlugin)this).Config.Bind<bool>("Valuables", def.Id, true, "Включить: " + def.Name);
			}
			SoundKit.Init();
			BlindOverlay.Create();
			try
			{
				new Harmony("mindustry.valuables").PatchAll(typeof(Plugin).Assembly);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Harmony-патчи не применились (Overdrive Lamp не будет слепить при разрушении): " + ex));
			}
			((MonoBehaviour)this).StartCoroutine(RegisterRoutine());
			Log.LogInfo((object)"MindustryValuables v0.1.2 загружен, жду готовности игры и REPOLib...");
		}

		private IEnumerator RegisterRoutine()
		{
			Dictionary<string, GameObject> sources = null;
			float waited = 0f;
			while (waited < 180f)
			{
				if (BundlesReady(waited))
				{
					sources = CollectSources();
					if (sources.Count > 0)
					{
						break;
					}
				}
				waited += Time.unscaledDeltaTime;
				yield return null;
			}
			if (sources == null || sources.Count == 0)
			{
				Log.LogError((object)"Не нашёл ни одной ванильной ценности для образца. Регистрация отменена.");
				yield break;
			}
			Log.LogInfo((object)("Образцы найдены: " + string.Join(", ", new List<string>(sources.Keys))));
			int ok = 0;
			foreach (Def def in defs)
			{
				if (!enabledMap[def.Id].Value)
				{
					continue;
				}
				GameObject val = Pick(sources, def.Size);
				if ((Object)(object)val == (Object)null)
				{
					Log.LogWarning((object)("[" + def.Id + "] нет подходящего образца размера " + def.Size + "."));
					continue;
				}
				try
				{
					GameObject val2 = ValuableFactory.Build(def, val, Log);
					if ((Object)(object)val2 != (Object)null)
					{
						Valuables.RegisterValuable(val2);
						ok++;
						Log.LogInfo((object)("Зарегистрирована ценность: " + def.Name + " (" + def.Size + ", образец " + ((Object)val).name + ")"));
					}
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"[{def.Id}] ошибка: {arg}");
				}
				yield return null;
			}
			Log.LogInfo((object)$"Готово: зарегистрировано ценностей {ok} из {defs.Count}.");
		}

		private static bool BundlesReady(float waited)
		{
			try
			{
				PropertyInfo property = typeof(BundleLoader).GetProperty("AllBundlesLoaded", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null)
				{
					return (bool)property.GetValue(null, null);
				}
			}
			catch (Exception)
			{
			}
			return waited > 15f;
		}

		private static GameObject Pick(Dictionary<string, GameObject> map, string size)
		{
			if (!Fallback.TryGetValue(size, out var value))
			{
				value = new string[1] { size };
			}
			string[] array = value;
			foreach (string key in array)
			{
				if (map.TryGetValue(key, out var value2) && (Object)(object)value2 != (Object)null)
				{
					return value2;
				}
			}
			return null;
		}

		private static Dictionary<string, GameObject> CollectSources()
		{
			Dictionary<string, GameObject> dictionary = new Dictionary<string, GameObject>();
			RunManager instance = RunManager.instance;
			if ((Object)(object)instance == (Object)null || instance.levels == null)
			{
				return dictionary;
			}
			foreach (Level level in instance.levels)
			{
				if ((Object)(object)level == (Object)null || level.ValuablePresets == null)
				{
					continue;
				}
				foreach (LevelValuables valuablePreset in level.ValuablePresets)
				{
					if (!((Object)(object)valuablePreset == (Object)null))
					{
						TryAdd(dictionary, "tiny", valuablePreset.tiny);
						TryAdd(dictionary, "small", valuablePreset.small);
						TryAdd(dictionary, "medium", valuablePreset.medium);
						TryAdd(dictionary, "big", valuablePreset.big);
						TryAdd(dictionary, "wide", valuablePreset.wide);
						TryAdd(dictionary, "tall", valuablePreset.tall);
						TryAdd(dictionary, "veryTall", valuablePreset.veryTall);
					}
				}
			}
			return dictionary;
		}

		private static void TryAdd(Dictionary<string, GameObject> map, string size, IEnumerable<PrefabRef> list)
		{
			if (list == null || map.ContainsKey(size))
			{
				return;
			}
			foreach (PrefabRef item in list)
			{
				GameObject val = null;
				try
				{
					val = ((PrefabRef<GameObject>)(object)item)?.Prefab;
				}
				catch (Exception)
				{
				}
				if (ValuableFactory.IsCleanSource(val))
				{
					map[size] = val;
					break;
				}
			}
		}
	}
	internal enum Loop
	{
		None,
		Servo,
		Hum,
		Beam,
		Whirr,
		Hiss,
		Drill,
		Belt
	}
	internal enum Hit
	{
		None,
		Clang,
		Thud,
		Plink
	}
	internal static class SoundKit
	{
		private const int SR = 44100;

		private static AudioClip[] loops;

		private static AudioClip[] hits;

		public static AudioClip Ring;

		public static void Init()
		{
			loops = (AudioClip[])(object)new AudioClip[Enum.GetValues(typeof(Loop)).Length];
			hits = (AudioClip[])(object)new AudioClip[Enum.GetValues(typeof(Hit)).Length];
			loops[1] = MakeLoop("mv_servo", Servo);
			loops[2] = MakeLoop("mv_hum", HumWave);
			loops[3] = MakeLoop("mv_beam", BeamWave);
			loops[4] = MakeLoop("mv_whirr", WhirrWave);
			loops[5] = MakeNoiseLoop("mv_hiss");
			loops[6] = MakeLoop("mv_drill", DrillWave);
			loops[7] = MakeLoop("mv_belt", BeltWave);
			hits[1] = MakeOneShot("mv_clang", 0.7f, Clang);
			hits[2] = MakeOneShot("mv_thud", 0.5f, Thud);
			hits[3] = MakeOneShot("mv_plink", 0.4f, Plink);
			Ring = MakeOneShot("mv_ring", 3.5f, RingWave);
		}

		public static AudioClip GetLoop(Loop l)
		{
			if (loops == null)
			{
				return null;
			}
			return loops[(int)l];
		}

		public static AudioClip GetHit(Hit h)
		{
			if (hits == null)
			{
				return null;
			}
			return hits[(int)h];
		}

		private static AudioClip MakeLoop(string name, Func<float, float> f)
		{
			float[] array = new float[44100];
			for (int i = 0; i < 44100; i++)
			{
				array[i] = f((float)i / 44100f);
			}
			Normalize(array, 0.5f);
			AudioClip obj = AudioClip.Create(name, 44100, 1, 44100, false);
			obj.SetData(array, 0);
			return obj;
		}

		private static AudioClip MakeOneShot(string name, float seconds, Func<float, float> f)
		{
			int num = (int)(44100f * seconds);
			float[] array = new float[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = f((float)i / 44100f);
			}
			Normalize(array, 0.8f);
			AudioClip obj = AudioClip.Create(name, num, 1, 44100, false);
			obj.SetData(array, 0);
			return obj;
		}

		private static AudioClip MakeNoiseLoop(string name)
		{
			int num = 4000;
			int num2 = 44100 + num;
			float[] array = new float[num2];
			Random random = new Random(1337);
			float num3 = 0f;
			for (int i = 0; i < num2; i++)
			{
				float num4 = (float)(random.NextDouble() * 2.0 - 1.0);
				num3 += (num4 - num3) * 0.35f;
				float num5 = 0.65f + 0.35f * Mathf.Sin(MathF.PI * 6f * ((float)i / 44100f));
				array[i] = num3 * num5;
			}
			float[] array2 = new float[44100];
			for (int j = 0; j < 44100; j++)
			{
				array2[j] = array[j];
				if (j < num)
				{
					float num6 = (float)j / (float)num;
					array2[j] = Mathf.Lerp(array[44100 + j], array[j], num6);
				}
			}
			Normalize(array2, 0.35f);
			AudioClip obj = AudioClip.Create(name, 44100, 1, 44100, false);
			obj.SetData(array2, 0);
			return obj;
		}

		private static void Normalize(float[] d, float peak)
		{
			float num = 0f;
			for (int i = 0; i < d.Length; i++)
			{
				num = Mathf.Max(num, Mathf.Abs(d[i]));
			}
			if (!(num < 1E-05f))
			{
				float num2 = peak / num;
				for (int j = 0; j < d.Length; j++)
				{
					d[j] *= num2;
				}
			}
		}

		private static float Sin(float hz, float t)
		{
			return Mathf.Sin(MathF.PI * 2f * hz * t);
		}

		private static float Servo(float t)
		{
			float num = 0.75f + 0.25f * Sin(7f, t);
			return (0.55f * Sin(110f, t) + 0.3f * Sin(220f, t) + 0.15f * Sin(330f, t)) * num + 0.1f * Sin(880f + 40f * Sin(3f, t), t) * (0.5f + 0.5f * Sin(3f, t));
		}

		private static float HumWave(float t)
		{
			return (0.8f + 0.2f * Sin(2f, t)) * (0.6f * Sin(55f, t) + 0.3f * Sin(110f, t) + 0.15f * Sin(165f, t) + 0.05f * Sin(331f, t));
		}

		private static float BeamWave(float t)
		{
			float num = 0.65f + 0.35f * Mathf.Sign(Sin(120f, t)) * Sin(7f, t);
			return (0.5f * Sin(440f, t) + 0.5f * Sin(441f, t) + 0.25f * Sin(880f, t)) * num;
		}

		private static float WhirrWave(float t)
		{
			return (Mathf.Sin(MathF.PI * 600f * t + 2.5f * Sin(6f, t)) + 0.35f * Mathf.Sin(MathF.PI * 1200f * t + 1.5f * Sin(6f, t))) * (0.8f + 0.2f * Sin(12f, t));
		}

		private static float DrillWave(float t)
		{
			float num = 0.0625f;
			float num2 = t % num;
			float num3 = Mathf.Exp((0f - num2) * 90f);
			float num4 = Sin(1700f, num2) * 0.5f + Sin(2310f, num2) * 0.35f + Sin(930f, num2) * 0.4f;
			return num3 * num4 + 0.25f * Sin(96f, t);
		}

		private static float BeltWave(float t)
		{
			float num = 0.25f;
			float num2 = t % num;
			float num3 = Mathf.Exp((0f - num2) * 55f) * (Sin(180f, num2) * 0.8f + Sin(540f, num2) * 0.3f);
			float num4 = 0.15f * Sin(60f, t) * (0.6f + 0.4f * Sin(4f, t));
			return num3 + num4;
		}

		private static float Clang(float t)
		{
			return 0.55f * Sin(520f, t) * Mathf.Exp((0f - t) * 9f) + 0.4f * Sin(1180f, t) * Mathf.Exp((0f - t) * 14f) + 0.3f * Sin(1960f, t) * Mathf.Exp((0f - t) * 22f) + 0.2f * Sin(3150f, t) * Mathf.Exp((0f - t) * 30f) + 0.6f * (Sin(2200f, t) + Sin(3700f, t)) * Mathf.Exp((0f - t) * 400f);
		}

		private static float Thud(float t)
		{
			float num = 90f * Mathf.Exp((0f - t) * 6f) + 45f;
			return Mathf.Sin(MathF.PI * 2f * num * t) * Mathf.Exp((0f - t) * 11f) + 0.25f * Sin(210f, t) * Mathf.Exp((0f - t) * 35f);
		}

		private static float RingWave(float t)
		{
			float num = Mathf.Exp((0f - t) * 40f) * (Sin(90f, t) + 0.6f * Sin(1400f, t));
			float num2 = (0.55f * Sin(3400f, t) + 0.35f * Sin(5100f, t)) * Mathf.Exp((0f - t) * 0.9f);
			return num + 0.5f * num2;
		}

		private static float Plink(float t)
		{
			return 0.6f * Sin(1800f, t) * Mathf.Exp((0f - t) * 18f) + 0.4f * Sin(2650f, t) * Mathf.Exp((0f - t) * 24f) + 0.2f * Sin(4100f, t) * Mathf.Exp((0f - t) * 40f);
		}
	}
	internal static class ValuableFactory
	{
		private const BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly string[] Allowed = new string[8] { "PhysGrab", "Valuable", "RoomVolume", "Photon", "Impact", "Durab", "NavMesh", "Collider" };

		private static Transform holder;

		public static Transform Holder
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				if ((Object)(object)holder == (Object)null)
				{
					GameObject val = new GameObject("MV_PrefabHolder");
					val.SetActive(false);
					Object.DontDestroyOnLoad((Object)val);
					holder = val.transform;
				}
				return holder;
			}
		}

		public static bool IsCleanSource(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null || (Object)(object)prefab.GetComponent<ValuableObject>() == (Object)null)
			{
				return false;
			}
			MonoBehaviour[] componentsInChildren = prefab.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if ((Object)(object)val == (Object)null)
				{
					return false;
				}
				string name = ((object)val).GetType().Name;
				bool flag = false;
				string[] allowed = Allowed;
				foreach (string value in allowed)
				{
					if (name.Contains(value))
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					return false;
				}
			}
			return true;
		}

		public static GameObject Build(Def def, GameObject source, ManualLogSource log)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_01ff: 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_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: 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_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: 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_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: 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_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: 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_0292: 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_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: 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_0396: 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_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(source, Holder);
			((Object)val).name = "Mindustry " + def.Name;
			ValuableObject component = val.GetComponent<ValuableObject>();
			if ((Object)(object)component == (Object)null)
			{
				log.LogWarning((object)("[" + def.Id + "] у образца нет ValuableObject, пропуск."));
				Object.DestroyImmediate((Object)(object)val);
				return null;
			}
			Bounds acc = default(Bounds);
			((Bounds)(ref acc))..ctor(Vector3.zero, Vector3.zero);
			bool has = false;
			Material val2 = null;
			MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val3 in componentsInChildren)
			{
				MeshFilter component2 = ((Component)val3).GetComponent<MeshFilter>();
				if (!((Object)(object)component2 == (Object)null) && !((Object)(object)component2.sharedMesh == (Object)null))
				{
					if ((Object)(object)val2 == (Object)null && (Object)(object)((Renderer)val3).sharedMaterial != (Object)null)
					{
						val2 = ((Renderer)val3).sharedMaterial;
					}
					Encapsulate(val.transform, ((Component)val3).transform, component2.sharedMesh.bounds, ref acc, ref has);
				}
			}
			SkinnedMeshRenderer[] componentsInChildren2 = val.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val4 in componentsInChildren2)
			{
				if (!((Object)(object)val4.sharedMesh == (Object)null))
				{
					if ((Object)(object)val2 == (Object)null && (Object)(object)((Renderer)val4).sharedMaterial != (Object)null)
					{
						val2 = ((Renderer)val4).sharedMaterial;
					}
					Encapsulate(val.transform, ((Component)val4).transform, val4.sharedMesh.bounds, ref acc, ref has);
				}
			}
			if ((Object)(object)MeshKit.BaseMaterial == (Object)null && (Object)(object)val2 != (Object)null)
			{
				MeshKit.BaseMaterial = val2;
			}
			componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			componentsInChildren2 = val.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			MeshFilter[] componentsInChildren3 = val.GetComponentsInChildren<MeshFilter>(true);
			for (int i = 0; i < componentsInChildr