Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FeatherguardDrone v1.6.2
FeatherguardDrone.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FeatherguardDrone { public sealed class ConceptDroneVisuals : MonoBehaviour { private sealed class MovingWing { internal Transform Hinge; internal Quaternion ClosedRotation; internal Quaternion OpenRotation; internal Vector3 ClosedPosition; internal Vector3 OpenPosition; } private static readonly FieldInfo AnimationOpenField = AccessTools.Field(typeof(ItemDrone), "animationOpen"); private readonly List<MovingWing> _movingWings = new List<MovingWing>(); private Material _black; private Material _darkMetal; private Material _white; private Material _red; private Material _redGlow; private Transform _shieldRing; private Transform _lensGlow; private Transform _modelRoot; private ItemDrone _itemDrone; private ItemToggle _itemToggle; private Quaternion _worldModelRotation; private Quaternion _inventoryModelRotation; private float _openAmount; internal static void ConfigurePrefabPhysics(GameObject prefab) { //IL_00a7: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab == (Object)null) && !prefab.GetComponentsInChildren<Transform>(true).Any((Transform child) => ((Object)child).name == "Featherguard Compound Physics")) { BoxCollider? obj = (from collider in prefab.GetComponentsInChildren<BoxCollider>(true) where (Object)(object)collider != (Object)null && !((Collider)collider).isTrigger orderby ColliderVolume(collider.size, ((Component)collider).transform.lossyScale) descending select collider).FirstOrDefault(); if ((Object)(object)obj == (Object)null) { throw new InvalidOperationException("The source drone has no physical BoxCollider to replace."); } Transform transform = ((Component)obj).transform; Vector3 center = obj.center; Vector3 size = obj.size; PhysicMaterial sharedMaterial = ((Collider)obj).sharedMaterial; if ((Object)(object)((Component)transform).GetComponent<PhysGrabObjectCollider>() == (Object)null) { ((Component)transform).gameObject.AddComponent<PhysGrabObjectCollider>(); } SphereCollider obj2 = ((Component)transform).gameObject.AddComponent<SphereCollider>(); obj2.center = center; obj2.radius = Mathf.Min(Mathf.Abs(size.x), Mathf.Min(Mathf.Abs(size.y), Mathf.Abs(size.z))) * 0.485f; ((Collider)obj2).sharedMaterial = sharedMaterial; GameObject val = new GameObject("Featherguard Compound Physics"); val.transform.SetParent(transform, false); val.transform.localPosition = center; val.layer = ((Component)transform).gameObject.layer; TryCopyTag(((Component)transform).gameObject, val); float radius = obj2.radius; CreateWingStopCollider(val.transform, "Left Wing Stop", -1f, radius, sharedMaterial); CreateWingStopCollider(val.transform, "Right Wing Stop", 1f, radius, sharedMaterial); CreateCentralKeelCollider(val.transform, radius, sharedMaterial); Object.DestroyImmediate((Object)(object)obj); FeatherguardDronePlugin.Log.LogInfo((object)"Replaced the cubic collider with a registered sphere, two wing stabilisers and a central anti-roll keel."); } } private static void CreateWingStopCollider(Transform parent, string name, float side, float radius, PhysicMaterial material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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 = new Vector3(side * radius * 1.03f, radius * 0.06f, radius * 0.1f); val.transform.localRotation = Quaternion.Euler(0f, 0f, side * -14f); val.layer = ((Component)parent).gameObject.layer; TryCopyTag(((Component)parent).gameObject, val); BoxCollider obj = val.AddComponent<BoxCollider>(); obj.size = new Vector3(radius * 0.34f, radius * 1.22f, radius * 0.54f); ((Collider)obj).sharedMaterial = material; val.AddComponent<PhysGrabObjectCollider>(); } private static void CreateCentralKeelCollider(Transform parent, float radius, PhysicMaterial material) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0032: 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_0085: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Central Invisible Anti-Roll Keel"); val.transform.SetParent(parent, false); val.transform.localPosition = new Vector3(0f, (0f - radius) * 0.94f, radius * 0.04f); val.transform.localRotation = Quaternion.identity; val.layer = ((Component)parent).gameObject.layer; TryCopyTag(((Component)parent).gameObject, val); BoxCollider obj = val.AddComponent<BoxCollider>(); obj.size = new Vector3(radius * 0.42f, radius * 0.3f, radius * 1.08f); ((Collider)obj).sharedMaterial = material; val.AddComponent<PhysGrabObjectCollider>(); } private static float ColliderVolume(Vector3 size, Vector3 scale) { //IL_0000: 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_000d: 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_001b: 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) return Mathf.Abs(size.x * scale.x * size.y * scale.y * size.z * scale.z); } private static void TryCopyTag(GameObject source, GameObject destination) { try { destination.tag = source.tag; } catch (UnityException) { } } private void Start() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020c: 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) if (!((Object)(object)((Component)this).transform.Find("Featherguard Concept 1.3") != (Object)null)) { MeshRenderer[] array = (from renderer in ((Component)this).GetComponentsInChildren<MeshRenderer>(true) where !IsEffectRenderer((Renderer)(object)renderer) select renderer).ToArray(); SkinnedMeshRenderer[] array2 = (from renderer in ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true) where !IsEffectRenderer((Renderer)(object)renderer) select renderer).ToArray(); Bounds bodyBounds = FindBodyBounds(array, array2); _itemDrone = ((Component)this).GetComponentInChildren<ItemDrone>(true); Vector3 val = FindOriginalBeamDirection(bodyBounds); Material fallback = array.Select((MeshRenderer renderer) => ((Renderer)renderer).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material material) => (Object)(object)material != (Object)null)); CreateMaterials(fallback); MeshRenderer[] array3 = array; for (int num = 0; num < array3.Length; num++) { ((Renderer)array3[num]).enabled = false; } SkinnedMeshRenderer[] array4 = array2; for (int num = 0; num < array4.Length; num++) { ((Renderer)array4[num]).enabled = false; } float num2 = Mathf.Max(((Bounds)(ref bodyBounds)).size.x, Mathf.Max(((Bounds)(ref bodyBounds)).size.y, ((Bounds)(ref bodyBounds)).size.z)); GameObject val2 = new GameObject("Featherguard Concept 1.3"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = ((Component)this).transform.InverseTransformPoint(((Bounds)(ref bodyBounds)).center); _modelRoot = val2.transform; _worldModelRotation = Quaternion.LookRotation(-val, Vector3.up); _modelRoot.localRotation = _worldModelRotation; Vector3 val3 = new Vector3(-0.5f, -0.5f, -0.7071068f); Vector3 normalized = ((Vector3)(ref val3)).normalized; _inventoryModelRotation = Quaternion.LookRotation(-normalized, Vector3.up); val2.transform.localScale = Vector3.one * Mathf.Max(0.04f, num2 * 0.535f * FeatherguardDronePlugin.ModelScaleMultiplier); BuildArmouredBody(val2.transform); Transform lineStartPoint = BuildFrontLens(val2.transform); BuildSideHubs(val2.transform); BuildWingFan(val2.transform, -1f, "Left"); BuildWingFan(val2.transform, 1f, "Right"); BuildInternalWiring(val2.transform); BuildShieldRing(val2.transform); if ((Object)(object)_itemDrone != (Object)null) { _itemDrone.lineStartPoint = lineStartPoint; } _itemToggle = ((Component)this).GetComponentInChildren<ItemToggle>(true); int num3 = ((Component)this).GetComponentsInChildren<PhysGrabObjectCollider>(true).Length; FeatherguardDronePlugin.Log.LogInfo((object)("Built Featherguard Concept 1.3.1: armoured sphere, correctly oriented front beam lens, two three-blade wings, visible wiring and compound physics. Registered grab collider markers: " + num3 + ".")); } } private Vector3 FindOriginalBeamDirection(Bounds bodyBounds) { //IL_006f: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0069: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_itemDrone != (Object)null && (Object)(object)_itemDrone.lineStartPoint != (Object)null) { Vector3 val = _itemDrone.lineStartPoint.position - ((Bounds)(ref bodyBounds)).center; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { Vector3 val2 = ((Component)this).transform.InverseTransformDirection(val); if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { return ((Vector3)(ref val2)).normalized; } } } return Vector3.forward; } private void Update() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a7: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) bool flag = ReadAnimationOpen(); _openAmount = Mathf.MoveTowards(_openAmount, flag ? 1f : 0f, Time.deltaTime * 3.3f); float num = _openAmount * _openAmount * (3f - 2f * _openAmount); foreach (MovingWing movingWing in _movingWings) { if (!((Object)(object)movingWing.Hinge == (Object)null)) { movingWing.Hinge.localPosition = Vector3.Lerp(movingWing.ClosedPosition, movingWing.OpenPosition, num); movingWing.Hinge.localRotation = Quaternion.Slerp(movingWing.ClosedRotation, movingWing.OpenRotation, num); } } if ((Object)(object)_lensGlow != (Object)null) { float num2 = 1f + (0.055f + 0.045f * num) * Mathf.Sin(Time.time * (4.5f + num * 2f)); _lensGlow.localScale = new Vector3(0.29f * num2, 0.018f, 0.29f * num2); } if ((Object)(object)_shieldRing != (Object)null) { ((Component)_shieldRing).gameObject.SetActive(num > 0.015f); _shieldRing.Rotate(Vector3.forward, Time.deltaTime * Mathf.Lerp(18f, 42f, num), (Space)1); float num3 = 1f + Mathf.Sin(Time.time * 4.2f) * 0.018f * num; _shieldRing.localScale = Vector3.one * num3; } } internal Quaternion GetExtractionRotation(Quaternion playerViewRotation) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_modelRoot == (Object)null) { return playerViewRotation; } return playerViewRotation * _inventoryModelRotation * Quaternion.Inverse(_worldModelRotation); } private bool ReadAnimationOpen() { if ((Object)(object)_itemDrone != (Object)null && AnimationOpenField != null) { try { return (bool)AnimationOpenField.GetValue(_itemDrone); } catch (Exception) { } } if ((Object)(object)_itemToggle != (Object)null) { return _itemToggle.toggleState; } return false; } private void CreateMaterials(Material fallback) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Universal Render Pipeline/Lit"); } if ((Object)(object)val == (Object)null && (Object)(object)fallback != (Object)null) { val = fallback.shader; } if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("No compatible shader was found for Featherguard Concept 1.3."); } _black = CreateCleanMaterial(val, "Black Chassis", new Color(0.025f, 0.029f, 0.036f, 1f), 0.5f, emissive: false); _darkMetal = CreateCleanMaterial(val, "Gunmetal", new Color(0.24f, 0.27f, 0.31f, 1f), 0.9f, emissive: false); _white = CreateCleanMaterial(val, "White Armour", new Color(0.91f, 0.93f, 0.95f, 1f), 0.15f, emissive: false); _red = CreateCleanMaterial(val, "Red Armour", new Color(0.72f, 0.018f, 0.028f, 1f), 0.3f, emissive: false); _redGlow = CreateCleanMaterial(val, "Red Energy", new Color(1f, 0.008f, 0.012f, 1f), 0.32f, emissive: true); } private static Material CreateCleanMaterial(Shader shader, string name, Color color, float metallic, bool emissive) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001e: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader); ((Object)val).name = "Featherguard " + name; SetColor(val, "_Color", color); SetColor(val, "_BaseColor", color); SetFloat(val, "_Metallic", metallic); SetFloat(val, "_Glossiness", emissive ? 0.82f : 0.72f); SetFloat(val, "_Smoothness", emissive ? 0.82f : 0.72f); SetFloat(val, "_SpecularHighlights", 1f); SetFloat(val, "_GlossyReflections", 1f); if (emissive) { SetColor(val, "_EmissionColor", color * 2.8f); val.EnableKeyword("_EMISSION"); } return val; } private void BuildArmouredBody(Transform parent) { //IL_0007: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023c: 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) CreatePrimitive("Spherical Internal Chassis", (PrimitiveType)0, parent, Vector3.zero, new Vector3(1.68f, 1.66f, 1.68f), Vector3.zero, _black); CreateSpherePatch("Upper Left White Armour", parent, 0.865f, 5f, 69f, -82f, -18f, 14, 9, _white); CreateSpherePatch("Upper Right White Armour", parent, 0.865f, 5f, 69f, 18f, 82f, 14, 9, _white); CreateSpherePatch("Lower Left White Armour", parent, 0.865f, -68f, -5f, -82f, -18f, 14, 9, _white); CreateSpherePatch("Lower Right White Armour", parent, 0.865f, -68f, -5f, 18f, 82f, 14, 9, _white); CreateSpherePatch("Dorsal Red Armour", parent, 0.872f, -70f, 72f, -13f, 13f, 9, 15, _red); CreateSpherePatch("Rear Red Armour", parent, 0.868f, -54f, 58f, 130f, 230f, 16, 12, _red); CreateTorus("Front Recess Ring", parent, 0.57f, 0.052f, 56, 9, new Vector3(0f, 0f, -0.705f), Vector3.zero, _darkMetal); CreateTorus("Outer Chassis Seam", parent, 0.858f, 0.022f, 64, 7, Vector3.zero, new Vector3(90f, 0f, 0f), _darkMetal); for (int i = -1; i <= 1; i += 2) { CreatePrimitive("Upper Armour Fastener", (PrimitiveType)2, parent, new Vector3(0.48f * (float)i, 0.57f, -0.58f), new Vector3(0.055f, 0.018f, 0.055f), new Vector3(90f, 0f, 0f), _redGlow); CreatePrimitive("Lower Armour Fastener", (PrimitiveType)2, parent, new Vector3(0.48f * (float)i, -0.57f, -0.58f), new Vector3(0.045f, 0.018f, 0.045f), new Vector3(90f, 0f, 0f), _darkMetal); } } private Transform BuildFrontLens(Transform parent) { //IL_0016: 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_003e: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0150: 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) CreatePrimitive("Lens Black Housing", (PrimitiveType)2, parent, new Vector3(0f, 0f, -0.805f), new Vector3(0.63f, 0.115f, 0.63f), new Vector3(90f, 0f, 0f), _black); CreatePrimitive("Lens Segmented Metal Ring", (PrimitiveType)2, parent, new Vector3(0f, 0f, -0.93f), new Vector3(0.51f, 0.036f, 0.51f), new Vector3(90f, 0f, 0f), _darkMetal); CreateTorus("Lens White Trim", parent, 0.405f, 0.055f, 48, 9, new Vector3(0f, 0f, -0.985f), Vector3.zero, _white); CreatePrimitive("Lens Red Aperture", (PrimitiveType)2, parent, new Vector3(0f, 0f, -1.01f), new Vector3(0.36f, 0.024f, 0.36f), new Vector3(90f, 0f, 0f), _red); GameObject val = CreatePrimitive("Front Beam Lens", (PrimitiveType)2, parent, new Vector3(0f, 0f, -1.048f), new Vector3(0.29f, 0.018f, 0.29f), new Vector3(90f, 0f, 0f), _redGlow); _lensGlow = val.transform; return val.transform; } private void BuildSideHubs(Transform parent) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00b6: 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_00fa: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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) for (int i = -1; i <= 1; i += 2) { string obj = ((i < 0) ? "Left" : "Right"); CreatePrimitive(obj + " Wing Hinge Housing", (PrimitiveType)2, parent, new Vector3((float)i * 0.79f, 0.02f, 0.1f), new Vector3(0.43f, 0.1f, 0.43f), new Vector3(0f, 0f, 90f), _black); CreatePrimitive(obj + " Wing Hinge Metal", (PrimitiveType)2, parent, new Vector3((float)i * 0.9f, 0.02f, 0.1f), new Vector3(0.31f, 0.035f, 0.31f), new Vector3(0f, 0f, 90f), _darkMetal); CreatePrimitive(obj + " Wing Hinge Light", (PrimitiveType)2, parent, new Vector3((float)i * 1.025f, 0.02f, 0.1f), new Vector3(0.22f, 0.018f, 0.22f), new Vector3(0f, 0f, 90f), _redGlow); CreateTorus(obj + " Wing Lamp Metal Bezel", parent, 0.15f, 0.025f, 40, 8, new Vector3((float)i * 1.01f, 0.02f, 0.1f), new Vector3(0f, 90f, 0f), _darkMetal); CreateTorus(obj + " Wing Lamp Red Ring", parent, 0.115f, 0.012f, 40, 8, new Vector3((float)i * 1.05f, 0.02f, 0.1f), new Vector3(0f, 90f, 0f), _redGlow); } } private void BuildWingFan(Transform parent, float side, string label) { //IL_001a: 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_0082: Unknown result type (might be due to invalid IL or missing references) Vector3 root = default(Vector3); ((Vector3)(ref root))..ctor(side * 0.89f, 0.03f, 0.13f); CreateWingBlade(parent, root, side, label + " Upper Main Wing", 0, 1.12f, 0.46f, _red, -4f, -48f, 0.035f); CreateWingBlade(parent, root, side, label + " Middle Wing", 1, 0.84f, 0.41f, _white, 5f, 7f, 0.012f); CreateWingBlade(parent, root, side, label + " Lower Wing", 2, 0.66f, 0.36f, _white, 14f, 58f, -0.018f); } private void CreateWingBlade(Transform parent, Vector3 root, float side, string name, int order, float length, float width, Material material, float closedAngle, float openAngle, float forwardOffset) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_0108: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name + " Hinge"); val.transform.SetParent(parent, false); Vector3 val2 = root + new Vector3(side * (float)order * 0.014f, (float)(-order) * 0.012f, (float)order * 0.016f); Vector3 openPosition = root + new Vector3(side * (float)order * 0.03f, (float)(-order) * 0.03f, (float)order * 0.035f); Quaternion val3 = Quaternion.Euler(18f, 0f, side * -16f) * Quaternion.Euler(0f, side * 70f, 0f); Quaternion val4 = val3 * Quaternion.Euler(0f, 0f, side * closedAngle); Quaternion openRotation = val3 * Quaternion.Euler(0f, 0f, side * openAngle); val.transform.localPosition = val2; val.transform.localRotation = val4; CreateFeatherMesh(name, val.transform, new Vector3(0f, length * 0.5f, forwardOffset), new Vector3(width, length, 0.4f), material); CreatePrimitive(name + " Root Joint", (PrimitiveType)0, val.transform, Vector3.zero, new Vector3(0.22f, 0.18f, 0.15f), Vector3.zero, _darkMetal); _movingWings.Add(new MovingWing { Hinge = val.transform, ClosedRotation = val4, OpenRotation = openRotation, ClosedPosition = val2, OpenPosition = openPosition }); } private void BuildInternalWiring(Transform parent) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0085: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) for (int i = -1; i <= 1; i += 2) { string text = ((i < 0) ? "Left" : "Right"); CreateWire(text + " Red Power Cable", parent, _redGlow, 0.034f, (Vector3[])(object)new Vector3[4] { new Vector3((float)i * 0.23f, 0.47f, -0.72f), new Vector3((float)i * 0.47f, 0.35f, -0.69f), new Vector3((float)i * 0.7f, 0.19f, -0.48f), new Vector3((float)i * 0.86f, 0.07f, -0.12f) }); CreateWire(text + " White Data Cable", parent, _white, 0.024f, (Vector3[])(object)new Vector3[4] { new Vector3((float)i * 0.18f, -0.46f, -0.74f), new Vector3((float)i * 0.43f, -0.39f, -0.7f), new Vector3((float)i * 0.67f, -0.19f, -0.5f), new Vector3((float)i * 0.84f, -0.04f, -0.16f) }); CreateWire(text + " Black Control Cable", parent, _darkMetal, 0.03f, (Vector3[])(object)new Vector3[4] { new Vector3((float)i * 0.33f, 0.02f, -0.82f), new Vector3((float)i * 0.56f, 0.06f, -0.65f), new Vector3((float)i * 0.75f, 0.08f, -0.39f), new Vector3((float)i * 0.86f, 0.04f, -0.12f) }); } } private void BuildShieldRing(Transform parent) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateTorus("Active Featherguard Shield", parent, 1.23f, 0.025f, 72, 8, Vector3.zero, new Vector3(7f, 0f, 0f), _redGlow); _shieldRing = val.transform; val.SetActive(false); } private Bounds FindBodyBounds(MeshRenderer[] meshes, SkinnedMeshRenderer[] skinned) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0159: Unknown result type (might be due to invalid IL or missing references) SphereCollider val = (from collider in ((Component)this).GetComponentsInChildren<SphereCollider>(true) where ((Collider)collider).enabled && !((Collider)collider).isTrigger select collider).OrderByDescending(delegate(SphereCollider collider) { //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_0009: Unknown result type (might be due to invalid IL or missing references) Bounds bounds2 = ((Collider)collider).bounds; return ((Bounds)(ref bounds2)).size.x; }).FirstOrDefault(); if ((Object)(object)val != (Object)null) { return ((Collider)val).bounds; } Collider val2 = (from collider in ((Component)this).GetComponentsInChildren<Collider>(true) where collider.enabled && !collider.isTrigger select collider).OrderByDescending(delegate(Collider collider) { //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_0009: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0030: Unknown result type (might be due to invalid IL or missing references) Bounds bounds2 = collider.bounds; float x = ((Bounds)(ref bounds2)).size.x; bounds2 = collider.bounds; float num = x * ((Bounds)(ref bounds2)).size.y; bounds2 = collider.bounds; return num * ((Bounds)(ref bounds2)).size.z; }).FirstOrDefault(); if ((Object)(object)val2 != (Object)null) { return val2.bounds; } Renderer val3 = meshes.Cast<Renderer>().Concat(skinned.Cast<Renderer>()).FirstOrDefault(); if ((Object)(object)val3 == (Object)null) { return new Bounds(((Component)this).transform.position, Vector3.one * 0.5f); } Bounds bounds = val3.bounds; foreach (Renderer item in meshes.Cast<Renderer>().Concat(skinned.Cast<Renderer>())) { ((Bounds)(ref bounds)).Encapsulate(item.bounds); } return bounds; } private static bool IsEffectRenderer(Renderer renderer) { if (!((Object)(object)renderer == (Object)null) && !(renderer is ParticleSystemRenderer) && !((Object)(object)((Component)renderer).GetComponentInParent<BatteryVisualLogic>() != (Object)null) && !((Object)(object)((Component)renderer).GetComponent<ParticleSystem>() != (Object)null)) { return (Object)(object)((Component)renderer).GetComponentInParent<ParticleSystem>() != (Object)null; } return true; } private static GameObject CreatePrimitive(string name, PrimitiveType type, Transform parent, Vector3 position, Vector3 scale, Vector3 rotation, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(type); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = position; obj.transform.localScale = scale; obj.transform.localEulerAngles = rotation; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.GetComponent<Renderer>().sharedMaterial = material; return obj; } private static GameObject CreateTorus(string name, Transform parent, float majorRadius, float tubeRadius, int majorSegments, int tubeSegments, Vector3 position, Vector3 rotation, Material material) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = position; val.transform.localEulerAngles = rotation; MeshFilter val2 = val.AddComponent<MeshFilter>(); MeshRenderer obj = val.AddComponent<MeshRenderer>(); val2.sharedMesh = CreateTorusMesh(name + " Mesh", majorRadius, tubeRadius, majorSegments, tubeSegments); ((Renderer)obj).sharedMaterial = material; return val; } private static Mesh CreateTorusMesh(string name, float majorRadius, float tubeRadius, int majorSegments, int tubeSegments) { //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_016c: 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_017a: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_0085: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[majorSegments * tubeSegments]; Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length]; Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length]; int[] array4 = new int[majorSegments * tubeSegments * 6]; Vector3 val = default(Vector3); for (int i = 0; i < majorSegments; i++) { float num = (float)i * (float)Math.PI * 2f / (float)majorSegments; ((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); for (int j = 0; j < tubeSegments; j++) { float num2 = (float)j * (float)Math.PI * 2f / (float)tubeSegments; int num3 = i * tubeSegments + j; Vector3 val2 = val * Mathf.Cos(num2) + Vector3.forward * Mathf.Sin(num2); array[num3] = val * majorRadius + val2 * tubeRadius; array2[num3] = val2; array3[num3] = new Vector2((float)i / (float)majorSegments, (float)j / (float)tubeSegments); int num4 = (i + 1) % majorSegments * tubeSegments; int num5 = (j + 1) % tubeSegments; int num6 = num3 * 6; array4[num6] = num3; array4[num6 + 1] = num4 + j; array4[num6 + 2] = num4 + num5; array4[num6 + 3] = num3; array4[num6 + 4] = num4 + num5; array4[num6 + 5] = i * tubeSegments + num5; } } Mesh val3 = new Mesh { name = name, vertices = array, normals = array2, uv = array3, triangles = array4 }; val3.RecalculateBounds(); return val3; } private static void CreateSpherePatch(string name, Transform parent, float radius, float latitudeMin, float latitudeMax, float longitudeMin, float longitudeMax, int longitudeSegments, int latitudeSegments, Material material) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01c4: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) int num = longitudeSegments + 1; int num2 = latitudeSegments + 1; Vector3[] array = (Vector3[])(object)new Vector3[num * num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[array.Length]; Vector2[] array3 = (Vector2[])(object)new Vector2[array.Length]; int[] array4 = new int[longitudeSegments * latitudeSegments * 6]; Vector3 val = default(Vector3); for (int i = 0; i < num2; i++) { float num3 = (float)i / (float)latitudeSegments; float num4 = Mathf.Lerp(latitudeMin, latitudeMax, num3) * ((float)Math.PI / 180f); for (int j = 0; j < num; j++) { float num5 = (float)j / (float)longitudeSegments; float num6 = Mathf.Lerp(longitudeMin, longitudeMax, num5) * ((float)Math.PI / 180f); ((Vector3)(ref val))..ctor(Mathf.Cos(num4) * Mathf.Sin(num6), Mathf.Sin(num4), (0f - Mathf.Cos(num4)) * Mathf.Cos(num6)); int num7 = i * num + j; array[num7] = val * radius; array2[num7] = val; array3[num7] = new Vector2(num5, num3); } } int num8 = 0; for (int k = 0; k < latitudeSegments; k++) { for (int l = 0; l < longitudeSegments; l++) { int num9 = k * num + l; int num10 = num9 + num; array4[num8++] = num9; array4[num8++] = num10; array4[num8++] = num10 + 1; array4[num8++] = num9; array4[num8++] = num10 + 1; array4[num8++] = num9 + 1; } } GameObject val2 = new GameObject(name); val2.transform.SetParent(parent, false); Mesh val3 = new Mesh { name = name + " Mesh", vertices = array, normals = array2, uv = array3, triangles = array4 }; val3.RecalculateBounds(); val2.AddComponent<MeshFilter>().sharedMesh = val3; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = material; } private void CreateFeatherMesh(string name, Transform parent, Vector3 position, Vector3 scale, Material material) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) Vector2[] polygon = (Vector2[])(object)new Vector2[10] { new Vector2(0f, -0.49f), new Vector2(0.3588f, -0.3f), new Vector2(0.46f, 0.06f), new Vector2(0.4048f, 0.45f), new Vector2(0.24840002f, 0.79f), new Vector2(0f, 1.02f), new Vector2(-0.24840002f, 0.79f), new Vector2(-0.4048f, 0.45f), new Vector2(-0.46f, 0.06f), new Vector2(-0.3588f, -0.3f) }; CreateFeatherPanel(name + " Black Root", parent, position, scale, ClipFeather(polygon, -0.045f, above: false), _black); CreateFeatherPanel(name + " White Panel", parent, position, scale, ClipFeather(ClipFeather(polygon, -0.035f, above: true), 0.495f, above: false), _white); CreateFeatherPanel(name + " Tip", parent, position, scale, ClipFeather(polygon, 0.505f, above: true), material); } private static Vector2[] ClipFeather(Vector2[] polygon, float height, bool above) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0097: 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_00ae: 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) List<Vector2> list = new List<Vector2>(); Vector2 val = polygon[^1]; bool flag = (above ? (val.y >= height) : (val.y <= height)); foreach (Vector2 val2 in polygon) { bool num = (above ? (val2.y >= height) : (val2.y <= height)); if (num != flag) { float num2 = (height - val.y) / (val2.y - val.y); list.Add(new Vector2(val.x + (val2.x - val.x) * num2, height)); } if (num) { list.Add(val2); } val = val2; flag = num; } return list.ToArray(); } private static void CreateFeatherPanel(string name, Transform parent, Vector3 position, Vector3 scale, Vector2[] outline, Material material) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) int num = outline.Length; Vector3[] array = (Vector3[])(object)new Vector3[num * 2]; for (int i = 0; i < num; i++) { array[i] = new Vector3(outline[i].x, outline[i].y, -0.055f); array[i + num] = new Vector3(outline[i].x, outline[i].y, 0.055f); } int[] array2 = new int[(num - 2) * 6 + num * 6]; int num2 = 0; for (int j = 1; j < num - 1; j++) { array2[num2++] = 0; array2[num2++] = j + 1; array2[num2++] = j; array2[num2++] = num; array2[num2++] = num + j; array2[num2++] = num + j + 1; } for (int k = 0; k < num; k++) { int num3 = (k + 1) % num; array2[num2++] = k; array2[num2++] = num3; array2[num2++] = num + num3; array2[num2++] = k; array2[num2++] = num + num3; array2[num2++] = num + k; } Mesh val = new Mesh { name = name + " Mesh", vertices = array, triangles = array2 }; val.RecalculateNormals(); val.RecalculateBounds(); GameObject val2 = new GameObject(name); val2.transform.SetParent(parent, false); val2.transform.localPosition = position; val2.transform.localScale = scale; val2.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = material; } private static void CreateWire(string name, Transform parent, Material material, float width, Vector3[] points) { //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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); LineRenderer obj = val.AddComponent<LineRenderer>(); obj.useWorldSpace = false; obj.positionCount = points.Length; obj.SetPositions(points); obj.startWidth = width; obj.endWidth = width * 0.72f; obj.numCapVertices = 5; obj.numCornerVertices = 4; ((Renderer)obj).sharedMaterial = material; } private static void SetColor(Material material, string property, Color value) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(property)) { material.SetColor(property, value); } } private static void SetFloat(Material material, string property, float value) { if (material.HasProperty(property)) { material.SetFloat(property, value); } } } [HarmonyPatch(typeof(ItemDrone), "Awake")] internal static class ItemDroneWallRecoveryPatch { [HarmonyPostfix] private static void Postfix(ItemDrone __instance) { if (DroneWallRecovery.IsSupportedDrone(__instance) && (Object)(object)((Component)__instance).GetComponent<DroneWallRecovery>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<DroneWallRecovery>(); } } } public sealed class DroneWallRecovery : MonoBehaviour { private const float CastRadius = 0.08f; private const float MinimumCheckDistance = 0.2f; private const float RequiredBlockedTime = 0.08f; private const float RecoveryCooldown = 0.25f; private static readonly FieldInfo MagnetTargetField = AccessTools.Field(typeof(ItemDrone), "magnetTarget"); private static readonly FieldInfo AttachPointField = AccessTools.Field(typeof(ItemDrone), "attachPoint"); private static readonly FieldInfo RayHitPositionField = AccessTools.Field(typeof(ItemDrone), "rayHitPosition"); private static readonly FieldInfo MagnetActiveField = AccessTools.Field(typeof(ItemDrone), "magnetActive"); private static readonly MethodInfo FindTeleportSpotMethod = AccessTools.Method(typeof(ItemDrone), "FindTeleportSpot", (Type[])null, (Type[])null); private readonly RaycastHit[] _hits = (RaycastHit[])(object)new RaycastHit[16]; private ItemDrone _drone; private Rigidbody _droneRigidbody; private float _blockedTime; private float _nextRecoveryTime; internal static bool IsSupportedDrone(ItemDrone drone) { if ((Object)(object)drone == (Object)null) { return false; } if ((Object)(object)((Component)drone).GetComponent<HybridDroneMarker>() != (Object)null) { return true; } ItemAttributes component = ((Component)drone).GetComponent<ItemAttributes>(); string text = (((Object)(object)component != (Object)null && (Object)(object)component.item != (Object)null) ? ((Object)component.item).name : ((Object)((Component)drone).gameObject).name); if (text.EndsWith("(Clone)", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - "(Clone)".Length).TrimEnd(); } if (!string.Equals(text, "Item Drone Feather", StringComparison.Ordinal) || !((Object)(object)((Component)drone).GetComponent<ItemDroneFeather>() != (Object)null)) { if (string.Equals(text, "Item Drone Indestructible", StringComparison.Ordinal)) { return (Object)(object)((Component)drone).GetComponent<ItemDroneIndestructible>() != (Object)null; } return false; } return true; } private void Awake() { _drone = ((Component)this).GetComponent<ItemDrone>(); _droneRigidbody = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)_droneRigidbody == (Object)null) { _droneRigidbody = ((Component)this).GetComponentInChildren<Rigidbody>(true); } } private void FixedUpdate() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 //IL_0077: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0098: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if (!IsSupportedDrone(_drone) || ((int)_drone.currentState != 3 && (int)_drone.currentState != 2) || !SemiFunc.IsMasterClientOrSingleplayer() || !ReadMagnetActive()) { _blockedTime = 0f; return; } Transform val = ReadTarget(); if ((Object)(object)val == (Object)null) { _blockedTime = 0f; return; } Vector3 val2 = (((int)_drone.currentState == 3) ? ReadAttachPoint() : ReadRayHitPosition()); Vector3 val3 = val.TransformPoint(val2); Vector3 val4 = (((Object)(object)_droneRigidbody != (Object)null) ? _droneRigidbody.worldCenterOfMass : ((Component)this).transform.position); Vector3 val5 = val3 - val4; float magnitude = ((Vector3)(ref val5)).magnitude; if (magnitude <= 0.2f) { _blockedTime = 0f; return; } Vector3 val6 = val5 / magnitude; float num = Mathf.Min(0.015f, magnitude * 0.04f); float num2 = Mathf.Min(0.08f, magnitude * 0.12f); float num3 = magnitude - num - num2; if (num3 <= 0f || !HasRealObstacle(val4 + val6 * num, val6, num3, val)) { _blockedTime = 0f; return; } _blockedTime += Time.fixedDeltaTime; if (!(_blockedTime < 0.08f) && !(Time.fixedTime < _nextRecoveryTime)) { _blockedTime = 0f; _nextRecoveryTime = Time.fixedTime + 0.25f; if (FindTeleportSpotMethod == null) { ((Behaviour)this).enabled = false; FeatherguardDronePlugin.Log.LogWarning((object)"Wall recovery was disabled because ItemDrone.FindTeleportSpot is unavailable in this game build."); } else { FindTeleportSpotMethod.Invoke(_drone, null); FeatherguardDronePlugin.Log.LogDebug((object)"A wall interrupted the Featherguard attachment line; requested vanilla safe teleport recovery."); } } } private bool HasRealObstacle(Vector3 origin, Vector3 direction, float distance, Transform target) { //IL_0000: 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_000e: Unknown result type (might be due to invalid IL or missing references) int num = Physics.SphereCastNonAlloc(origin, 0.08f, direction, _hits, distance, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1); Rigidbody componentInParent = ((Component)target).GetComponentInParent<Rigidbody>(); for (int i = 0; i < num; i++) { Collider collider = ((RaycastHit)(ref _hits[i])).collider; if (!((Object)(object)collider == (Object)null)) { Transform transform = ((Component)collider).transform; if (!IsSameHierarchy(transform, ((Component)this).transform) && !IsSameHierarchy(transform, target) && (!((Object)(object)_droneRigidbody != (Object)null) || !((Object)(object)collider.attachedRigidbody == (Object)(object)_droneRigidbody)) && (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)collider.attachedRigidbody == (Object)(object)componentInParent))) { return true; } } } return false; } private static bool IsSameHierarchy(Transform candidate, Transform reference) { if (!((Object)(object)candidate == (Object)(object)reference) && !candidate.IsChildOf(reference)) { return reference.IsChildOf(candidate); } return true; } private Transform ReadTarget() { if (!(MagnetTargetField == null)) { object? value = MagnetTargetField.GetValue(_drone); return (Transform)((value is Transform) ? value : null); } return null; } private Vector3 ReadAttachPoint() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!(AttachPointField == null)) { return (Vector3)AttachPointField.GetValue(_drone); } return Vector3.zero; } private Vector3 ReadRayHitPosition() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!(RayHitPositionField == null)) { return (Vector3)RayHitPositionField.GetValue(_drone); } return Vector3.zero; } private bool ReadMagnetActive() { if (MagnetActiveField != null) { return (bool)MagnetActiveField.GetValue(_drone); } return false; } } [BepInPlugin("uz.cherdak.repo.featherguarddrone", "Featherguard Drone", "1.6.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class FeatherguardDronePlugin : BaseUnityPlugin { public const string PluginGuid = "uz.cherdak.repo.featherguarddrone"; public const string PluginName = "Featherguard Drone"; public const string PluginVersion = "1.6.2"; internal static ManualLogSource Log; internal static bool EnableCustomModel; internal static bool UseOriginalChassis; internal static bool AnimateShield; internal static float ModelScaleMultiplier; private bool _registered; private float _nextAttempt; private void Awake() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; EnableCustomModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "Enable custom model", true, "Use the Featherguard prototype body instead of the vanilla drone body.").Value; UseOriginalChassis = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "Use original chassis", true, "Use the recognisable vanilla drone body as the base of the hybrid model.").Value; AnimateShield = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "Animate shield rings", true, "Rotate and pulse the red shield rings.").Value; ModelScaleMultiplier = Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "Model scale", 1f, "Scale multiplier for the custom body. Useful while testing the prototype.").Value, 0.5f, 1.8f); new Harmony("uz.cherdak.repo.featherguarddrone").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Featherguard Drone 1.6.2 loaded."); } private void Update() { if (_registered || Time.unscaledTime < _nextAttempt) { return; } _nextAttempt = Time.unscaledTime + 1f; if ((Object)(object)StatsManager.instance == (Object)null || StatsManager.instance.itemDictionary.Count == 0) { return; } try { _registered = HybridItemFactory.TryRegister(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not create the Featherguard Drone: " + ex)); _nextAttempt = Time.unscaledTime + 5f; } } } internal static class HybridItemFactory { internal const string HybridItemName = "Item Drone Featherguard"; internal const string HybridPrefabName = "Item Drone Featherguard"; private const string InventoryIconResource = "FeatherguardDrone.InventoryIcon.png"; private static readonly FieldInfo TargetValuablesField = AccessTools.Field(typeof(ItemDrone), "targetValuables"); private static readonly FieldInfo TargetNonValuablesField = AccessTools.Field(typeof(ItemDrone), "targetNonValuables"); private static readonly FieldInfo CustomTargetingConditionField = AccessTools.Field(typeof(ItemDrone), "customTargetingCondition"); private static readonly FieldInfo ItemIconField = AccessTools.Field(typeof(ItemEquippable), "ItemIcon"); private static bool _registered; private static string _lastFailure; private static Sprite _inventoryIcon; internal static void ApplyRuntimeInventoryIcon(ItemAttributes attributes) { if ((Object)(object)_inventoryIcon == (Object)null) { _inventoryIcon = LoadInventoryIcon(); } if (!((Object)(object)_inventoryIcon == (Object)null)) { Sprite val = Object.Instantiate<Sprite>(_inventoryIcon); ((Object)val).name = "Featherguard Inventory Icon 1.6.1"; AccessTools.Field(typeof(ItemAttributes), "icon").SetValue(attributes, val); AccessTools.Field(typeof(ItemAttributes), "hasIcon").SetValue(attributes, true); FeatherguardDronePlugin.Log.LogInfo((object)"Assigned per-instance Featherguard icon to ItemAttributes; vanilla icon cache bypassed."); } } internal static bool TryRegister() { if (_registered) { return true; } Item[] second = Resources.LoadAll<Item>("ScriptableObjects"); IEnumerable<Item> enumerable = Items.AllItems.Concat(second).Distinct(); if ((Object)(object)enumerable.FirstOrDefault((Func<Item, bool>)((Item item) => (Object)(object)item != (Object)null && item.itemName == "Item Drone Featherguard")) != (Object)null) { _registered = true; return true; } Item val = FindVanillaItem<ItemDroneFeather>("Item Drone Feather", enumerable); Item val2 = FindVanillaItem<ItemDroneIndestructible>("Item Drone Indestructible", enumerable); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return RegistrationPending("built-in Feather or Indestructible item data is not ready"); } GameObject prefab = ((PrefabRef<GameObject>)(object)val.prefab).Prefab; GameObject prefab2 = ((PrefabRef<GameObject>)(object)val2.prefab).Prefab; if ((Object)(object)prefab == (Object)null || (Object)(object)prefab2 == (Object)null) { return RegistrationPending("built-in drone prefabs are not ready"); } GameObject val3 = Object.Instantiate<GameObject>(prefab2); ((Object)val3).name = "Item Drone Featherguard"; val3.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val3); Item val4 = ScriptableObject.CreateInstance<Item>(); CopyItem(val2, val4); ((Object)val4).name = "Item Drone Featherguard"; val4.itemName = "Item Drone Featherguard"; val4.description = "Feather and Indestructible hybrid drone with an armoured spherical chassis, folding wings and shield ring."; Value val5 = ScriptableObject.CreateInstance<Value>(); ((Object)val5).name = "Value - Featherguard Drone"; val5.valueMin = val.value.valueMin + val2.value.valueMin; val5.valueMax = val.value.valueMax + val2.value.valueMax; val4.value = val5; ItemAttributes component = val3.GetComponent<ItemAttributes>(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("The Indestructible Drone prefab has no ItemAttributes component."); } component.item = val4; if ((Object)(object)val3.GetComponent<ItemDroneFeather>() == (Object)null) { val3.AddComponent<ItemDroneFeather>(); } ItemDrone component2 = val3.GetComponent<ItemDrone>(); if ((Object)(object)component2 == (Object)null) { throw new InvalidOperationException("The Indestructible Drone prefab has no ItemDrone component."); } SetTargetingOptions(component2, val3); SetInventoryIcon(val3); if ((Object)(object)val3.GetComponent<HybridDroneMarker>() == (Object)null) { val3.AddComponent<HybridDroneMarker>(); } if ((Object)(object)val3.GetComponent<DroneWallRecovery>() == (Object)null) { val3.AddComponent<DroneWallRecovery>(); } if ((Object)(object)val3.GetComponent<HybridBatteryVisualRepair>() == (Object)null) { val3.AddComponent<HybridBatteryVisualRepair>(); } ConceptDroneVisuals.ConfigurePrefabPhysics(val3); if ((Object)(object)val3.GetComponent<ConceptDroneVisuals>() == (Object)null) { val3.AddComponent<ConceptDroneVisuals>(); } if (Items.RegisterItem(component) == null) { throw new InvalidOperationException("REPOLib rejected the hybrid item prefab."); } FeatherguardDronePlugin.Log.LogInfo((object)string.Format("Registered {0}. Price range: {1:0}-{2:0} = Feather ({3:0}-{4:0}) + Indestructible ({5:0}-{6:0}); drain preset copied from Indestructible Drone.", "Item Drone Featherguard", val5.valueMin, val5.valueMax, val.value.valueMin, val.value.valueMax, val2.value.valueMin, val2.value.valueMax)); _registered = true; _lastFailure = null; return true; } private static void SetTargetingOptions(ItemDrone drone, GameObject prefab) { if (TargetValuablesField == null || TargetNonValuablesField == null || CustomTargetingConditionField == null) { throw new MissingFieldException("The current game build does not expose the expected ItemDrone targeting fields."); } TargetValuablesField.SetValue(drone, true); TargetNonValuablesField.SetValue(drone, true); HybridItemTargetingCondition hybridItemTargetingCondition = prefab.GetComponent<HybridItemTargetingCondition>(); if ((Object)(object)hybridItemTargetingCondition == (Object)null) { hybridItemTargetingCondition = prefab.AddComponent<HybridItemTargetingCondition>(); } CustomTargetingConditionField.SetValue(drone, hybridItemTargetingCondition); } private static void SetInventoryIcon(GameObject prefab) { ItemEquippable componentInChildren = prefab.GetComponentInChildren<ItemEquippable>(true); if (componentInChildren == null || ItemIconField == null) { FeatherguardDronePlugin.Log.LogWarning((object)"Could not assign the Featherguard inventory icon."); return; } if ((Object)(object)_inventoryIcon == (Object)null) { _inventoryIcon = LoadInventoryIcon(); } if ((Object)(object)_inventoryIcon != (Object)null) { ItemIconField.SetValue(componentInChildren, _inventoryIcon); } } private static Sprite LoadInventoryIcon() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) using Stream stream = typeof(FeatherguardDronePlugin).Assembly.GetManifestResourceStream("FeatherguardDrone.InventoryIcon.png"); if (stream == null) { FeatherguardDronePlugin.Log.LogWarning((object)"Embedded Featherguard inventory icon was not found."); return null; } byte[] array = new byte[stream.Length]; int num; for (int i = 0; i < array.Length; i += num) { num = stream.Read(array, i, array.Length - i); if (num <= 0) { break; } } Texture2D val = new Texture2D(2, 2, (TextureFormat)5, false); ((Object)val).name = "Featherguard Inventory Icon Texture"; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; if (!ImageConversion.LoadImage(val, array, false)) { Object.Destroy((Object)(object)val); FeatherguardDronePlugin.Log.LogWarning((object)"Embedded Featherguard inventory icon could not be decoded."); return null; } Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); ((Object)obj).name = "Featherguard Inventory Icon"; return obj; } private static bool RegistrationPending(string reason) { if (!string.Equals(_lastFailure, reason, StringComparison.Ordinal)) { _lastFailure = reason; FeatherguardDronePlugin.Log.LogWarning((object)("Featherguard registration pending: " + reason + ".")); } return false; } private static Item FindVanillaItem<T>(string itemName, IEnumerable<Item> loadedItems) where T : Component { Item value = Resources.Load<Item>("Items/" + itemName); if (IsMatchingBuiltIn<T>(value, itemName)) { return value; } if ((Object)(object)StatsManager.instance != (Object)null && StatsManager.instance.itemDictionary.TryGetValue(itemName, out value) && IsMatchingBuiltIn<T>(value, itemName)) { return value; } Item[] source = loadedItems.Where((Item candidate) => HasComponent<T>(candidate) && (Object)(object)candidate.value != (Object)null).ToArray(); value = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item candidate) => string.Equals(((Object)((PrefabRef<GameObject>)(object)candidate.prefab).Prefab).name, itemName, StringComparison.Ordinal))); if ((Object)(object)value != (Object)null) { return value; } value = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item candidate) => string.Equals(candidate.itemName, itemName, StringComparison.Ordinal))); if ((Object)(object)value != (Object)null) { return value; } return null; } private static bool IsMatchingBuiltIn<T>(Item item, string itemName) where T : Component { if (!HasComponent<T>(item) || (Object)(object)item.value == (Object)null) { return false; } if (!string.Equals(item.itemName, itemName, StringComparison.Ordinal)) { return string.Equals(((Object)((PrefabRef<GameObject>)(object)item.prefab).Prefab).name, itemName, StringComparison.Ordinal); } return true; } private static bool HasComponent<T>(Item item) where T : Component { if ((Object)(object)item != (Object)null && item.prefab != null && (Object)(object)((PrefabRef<GameObject>)(object)item.prefab).Prefab != (Object)null) { return (Object)(object)((PrefabRef<GameObject>)(object)item.prefab).Prefab.GetComponentInChildren<T>(true) != (Object)null; } return false; } private static void CopyItem(Item source, Item destination) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) destination.disabled = false; destination.itemNameLocalized = null; destination.itemType = source.itemType; destination.emojiIcon = source.emojiIcon; destination.itemVolume = source.itemVolume; destination.itemSecretShopType = source.itemSecretShopType; destination.colorPreset = source.colorPreset; destination.maxAmount = source.maxAmount; destination.maxAmountInShop = source.maxAmountInShop; destination.minPlayerCount = source.minPlayerCount; destination.maxPurchase = source.maxPurchase; destination.maxPurchaseAmount = source.maxPurchaseAmount; destination.spawnRotationOffset = source.spawnRotationOffset; destination.physicalItem = source.physicalItem; } private static void AddFeatherModelParts(GameObject featherPrefab, GameObject hybridPrefab) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_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_0135: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) HashSet<string> hashSet = new HashSet<string>(from filter in hybridPrefab.GetComponentsInChildren<MeshFilter>(true) where (Object)(object)filter.sharedMesh != (Object)null select ((Object)filter.sharedMesh).name); GameObject val = new GameObject("Feather Model Layer"); val.transform.SetParent(hybridPrefab.transform, false); int num = 0; MeshFilter[] componentsInChildren = featherPrefab.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { if (!((Object)(object)val2.sharedMesh == (Object)null) && !hashSet.Contains(((Object)val2.sharedMesh).name)) { MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>(); if (!((Object)(object)component == (Object)null)) { GameObject val3 = new GameObject("Feather Part - " + ((Object)val2.sharedMesh).name); val3.transform.SetParent(val.transform, false); val3.transform.localPosition = featherPrefab.transform.InverseTransformPoint(((Component)val2).transform.position); val3.transform.localRotation = Quaternion.Inverse(featherPrefab.transform.rotation) * ((Component)val2).transform.rotation; val3.transform.localScale = DivideScale(((Component)val2).transform.lossyScale, featherPrefab.transform.lossyScale); val3.AddComponent<MeshFilter>().sharedMesh = val2.sharedMesh; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)component).sharedMaterials; num++; } } } if (num == 0) { Object.Destroy((Object)(object)val); FeatherguardDronePlugin.Log.LogInfo((object)"The two vanilla drones share the same mesh set; the hybrid uses their common chassis with a new striped material."); } else { FeatherguardDronePlugin.Log.LogInfo((object)("Added " + num + " Feather Drone mesh part(s) to the Indestructible Drone chassis.")); } } private static Vector3 DivideScale(Vector3 value, Vector3 divisor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0066: Unknown result type (might be due to invalid IL or missing references) return new Vector3((divisor.x == 0f) ? value.x : (value.x / divisor.x), (divisor.y == 0f) ? value.y : (value.y / divisor.y), (divisor.z == 0f) ? value.z : (value.z / divisor.z)); } } [HarmonyPatch(typeof(StatsManager), "RunStartStats")] internal static class RunStartRegistrationPatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix() { try { HybridItemFactory.TryRegister(); } catch (Exception ex) { FeatherguardDronePlugin.Log.LogError((object)("Could not register the Featherguard Drone at run start: " + ex)); } } } public sealed class HybridDroneMarker : MonoBehaviour { } [HarmonyPatch(typeof(ItemAttributes), "Start")] internal static class HybridInventoryIconPatch { private static void Prefix(ItemAttributes __instance) { if ((Object)(object)((Component)__instance).GetComponent<HybridDroneMarker>() != (Object)null) { HybridItemFactory.ApplyRuntimeInventoryIcon(__instance); } } } [HarmonyPatch(typeof(ItemEquippable), "RPC_CompleteUnequip")] internal static class HybridInventoryExtractionPosePatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = instructions.ToList(); MethodInfo original = AccessTools.Method(typeof(Quaternion), "LookRotation", new Type[2] { typeof(Vector3), typeof(Vector3) }, (Type[])null); MethodInfo replacement = AccessTools.Method(typeof(HybridInventoryExtractionPosePatch), "ExtractionRotation", (Type[])null, (Type[])null); if (list.Count((CodeInstruction instruction) => CodeInstructionExtensions.Calls(instruction, original)) != 1) { throw new InvalidOperationException("Inventory extraction rotation layout changed; refusing to patch it."); } foreach (CodeInstruction item in list) { if (!CodeInstructionExtensions.Calls(item, original)) { yield return item; continue; } CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null); val.labels.AddRange(item.labels); val.blocks.AddRange(item.blocks); yield return val; yield return new CodeInstruction(OpCodes.Call, (object)replacement); } } private static Quaternion ExtractionRotation(Vector3 forward, Vector3 up, Component item) { //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_0016: 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_002c: 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) Quaternion val = Quaternion.LookRotation(forward, up); if ((Object)(object)item.GetComponent<HybridDroneMarker>() == (Object)null) { return val; } ConceptDroneVisuals component = item.GetComponent<ConceptDroneVisuals>(); if (!((Object)(object)component != (Object)null)) { return val; } return component.GetExtractionRotation(val); } } public sealed class HybridItemTargetingCondition : MonoBehaviour, ITargetingCondition { public bool CustomTargetingCondition(GameObject candidate) { if ((Object)(object)candidate == (Object)null || (Object)(object)candidate.GetComponent<PhysGrabObject>() == (Object)null) { return false; } if ((Object)(object)candidate.GetComponentInChildren<PlayerTumble>(true) != (Object)null || (Object)(object)candidate.GetComponentInChildren<PlayerAvatar>(true) != (Object)null) { return false; } PhysGrabObjectImpactDetector componentInChildren = candidate.GetComponentInChildren<PhysGrabObjectImpactDetector>(true); if (!((Object)(object)componentInChildren == (Object)null)) { return !componentInChildren.isEnemy; } return true; } } public sealed class HybridBatteryVisualRepair : MonoBehaviour { private static readonly FieldInfo VisualLogicField = AccessTools.Field(typeof(ItemBattery), "batteryVisualLogic"); private static readonly FieldInfo BatteryTransformField = AccessTools.Field(typeof(ItemBattery), "batteryTransform"); private static readonly FieldInfo HasBatteryVisualsField = AccessTools.Field(typeof(ItemBattery), "hasBatteryVisuals"); private ItemBattery _battery; private BatteryVisualLogic _visual; private IEnumerator Start() { yield return null; RepairReferences(); } private void Update() { if ((Object)(object)_battery == (Object)null || (Object)(object)_visual == (Object)null) { RepairReferences(); } if ((Object)(object)_battery != (Object)null && (Object)(object)_visual != (Object)null && SemiFunc.RunIsLobby()) { _battery.OverrideBatteryShow(0.25f); } } private void RepairReferences() { if ((Object)(object)_battery == (Object)null) { _battery = ((Component)this).GetComponent<ItemBattery>(); } if ((Object)(object)_battery == (Object)null) { return; } if ((Object)(object)_visual == (Object)null) { _visual = ((Component)this).GetComponentsInChildren<BatteryVisualLogic>(true).FirstOrDefault(); } if (!((Object)(object)_visual == (Object)null)) { if (VisualLogicField != null) { VisualLogicField.SetValue(_battery, _visual); } if (BatteryTransformField != null && BatteryTransformField.GetValue(_battery) == null) { BatteryTransformField.SetValue(_battery, ((Component)_visual).transform); } if (HasBatteryVisualsField != null) { HasBatteryVisualsField.SetValue(_battery, true); } } } } public sealed class HybridDroneVisuals : MonoBehaviour { public GameObject SourceVisualPrefab; private static Texture2D _stripeTexture; private Material _black; private Material _white; private Material _red; private Material _redGlow; private Transform _primaryShield; private Transform _secondaryShield; private Vector3 _primaryShieldScale; private Vector3 _secondaryShieldScale; private void Start() { //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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Expected O, but got Unknown //IL_02e7: 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_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) if (!FeatherguardDronePlugin.EnableCustomModel || (Object)(object)((Component)this).transform.Find("Featherguard Concept Model") != (Object)null) { return; } MeshRenderer[] array = (from renderer in ((Component)this).GetComponentsInChildren<MeshRenderer>(true) where !IsEffectRenderer((Renderer)(object)renderer) select renderer).ToArray(); SkinnedMeshRenderer[] array2 = (from renderer in ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true) where !IsEffectRenderer((Renderer)(object)renderer) select renderer).ToArray(); Bounds targetBounds = CalculatePhysicalBounds(array, array2); Material val = FindTemplateMaterial(array, array2); if ((Object)(object)_stripeTexture == (Object)null) { _stripeTexture = CreateStripeTexture(); } if ((Object)(object)SourceVisualPrefab == (Object)null) { FeatherguardDronePlugin.Log.LogError((object)"The Zero Gravity Orb visual prefab was not assigned."); return; } _black = CreateMaterial(val, new Color(0.012f, 0.014f, 0.018f, 1f), emissive: false); _white = CreateMaterial(val, new Color(0.88f, 0.9f, 0.92f, 1f), emissive: false); _red = CreateMaterial(val, new Color(0.68f, 0.018f, 0.028f, 1f), emissive: false); _redGlow = CreateMaterial(val, new Color(0.7f, 0.015f, 0.022f, 1f), emissive: true); GameObject val2 = new GameObject("Featherguard Concept Model"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = ((Component)this).transform.InverseTransformPoint(((Bounds)(ref targetBounds)).center); int num = CopyZeroGravityOrbVisual(SourceVisualPrefab, val2.transform, targetBounds, val); if (num == 0) { Object.Destroy((Object)(object)val2); FeatherguardDronePlugin.Log.LogError((object)"The Zero Gravity Orb prefab did not contain a compatible mesh."); return; } MeshRenderer[] array3 = array; for (int num2 = 0; num2 < array3.Length; num2++) { ((Renderer)array3[num2]).enabled = false; } SkinnedMeshRenderer[] array4 = array2; for (int num2 = 0; num2 < array4.Length; num2++) { ((Renderer)array4[num2]).enabled = false; } GameObject val3 = new GameObject("Featherguard Wings"); val3.transform.SetParent(((Component)this).transform, false); val3.transform.localPosition = ((Component)this).transform.InverseTransformPoint(((Bounds)(ref targetBounds)).center); float num3 = Mathf.Max(((Bounds)(ref targetBounds)).size.x, Mathf.Max(((Bounds)(ref targetBounds)).size.y, ((Bounds)(ref targetBounds)).size.z)); val3.transform.localScale = Vector3.one * Mathf.Max(0.04f, num3 * 0.46f * FeatherguardDronePlugin.ModelScaleMultiplier); BuildFeatherWing(val3.transform); GameObject val4 = new GameObject("Featherguard Lens"); val4.transform.SetParent(((Component)this).transform, false); val4.transform.localPosition = ((Component)this).transform.InverseTransformPoint(((Bounds)(ref targetBounds)).center); val4.transform.localScale = Vector3.one * Mathf.Max(0.04f, num3 * 0.48f * FeatherguardDronePlugin.ModelScaleMultiplier); BuildLens(val4.transform); int num4 = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>(true).Length; FeatherguardDronePlugin.Log.LogInfo((object)("Built the Featherguard model from " + num + " Zero Gravity Orb mesh(es); left " + num4 + " particle renderer(s) untouched and kept the vanilla box physics.")); FeatherguardDronePlugin.Log.LogInfo((object)("Featherguard body material shader: " + ((Object)val.shader).name)); } private void Update() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (FeatherguardDronePlugin.AnimateShield && !((Object)(object)_primaryShield == (Object)null) && !((Object)(object)_secondaryShield == (Object)null)) { float num = 1f + Mathf.Sin(Time.time * 3.4f) * 0.035f; _primaryShield.Rotate(Vector3.forward, 22f * Time.deltaTime, (Space)1); _secondaryShield.Rotate(Vector3.forward, -31f * Time.deltaTime, (Space)1); _primaryShield.localScale = _primaryShieldScale * num; _secondaryShield.localScale = _secondaryShieldScale * (2f - num); } } private static bool IsEffectRenderer(Renderer renderer) { if ((Object)(object)renderer == (Object)null) { return true; } if (!(renderer is ParticleSystemRenderer) && !((Object)(object)((Component)renderer).GetComponent<ParticleSystem>() != (Object)null)) { return (Object)(object)((Component)renderer).GetComponentInParent<ParticleSystem>() != (Object)null; } return true; } private Bounds CalculatePhysicalBounds(MeshRenderer[] meshes, SkinnedMeshRenderer[] skinned) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = (from box in ((Component)this).GetComponentsInChildren<BoxCollider>(true) where ((Collider)box).enabled && !((Collider)box).isTrigger select box).OrderByDescending(delegate(BoxCollider box) { //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_0009: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0030: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ((Collider)box).bounds; float x = ((Bounds)(ref bounds)).size.x; bounds = ((Collider)box).bounds; float num = x * ((Bounds)(ref bounds)).size.y; bounds = ((Collider)box).bounds; return num * ((Bounds)(ref bounds)).size.z; }).FirstOrDefault(); if (!((Object)(object)val != (Object)null)) { return CalculateBounds(meshes, skinned); } return ((Collider)val).bounds; } private static int CopyZeroGravityOrbVisual(GameObject sourcePrefab, Transform destination, Bounds targetBounds, Material bodyMaterialTemplate) { //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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid I