Decompiled source of ViltrumiteMod v1.0.1

Mods/ViltrumiteMod.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Combat;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using ViltrumiteMod;
using ViltrumiteMod.Abilities;
using ViltrumiteMod.Abilities.Impl;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "ViltrumiteMod", "1.0.0", "notnotnotswipez", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ViltrumiteMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ViltrumiteMod")]
[assembly: AssemblyTitle("ViltrumiteMod")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ViltrumiteMod
{
	public class Core : MelonMod
	{
		public static float strengthMultiplier = 5f;

		public static float speedMultiplier = 5f;

		public static float flightSpeed = 10f;

		public static bool flightEnabled = true;

		public static bool chopEnabled = true;

		public static float chopDamage = 1f;

		private static AbilityManager activeAbilityManager;

		private static MelonPreferences_Category mainCategory = MelonPreferences.CreateCategory("ViltrumiteMod");

		private static MelonPreferences_Entry<float> strengthMultiplierEntry = mainCategory.CreateEntry<float>("StrengthMultiplier", 5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<float> speedMultiplierEntry = mainCategory.CreateEntry<float>("SpeedMultiplier", 5f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<float> flightSpeedEntry = mainCategory.CreateEntry<float>("FlightSpeed", 10f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> flightEnabledEntry = mainCategory.CreateEntry<bool>("FlightEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		private static MelonPreferences_Entry<bool> chopEnabledEntry = mainCategory.CreateEntry<bool>("ChopEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);

		public override void OnInitializeMelon()
		{
			//IL_007b: 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_00d2: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			strengthMultiplier = strengthMultiplierEntry.Value;
			speedMultiplier = speedMultiplierEntry.Value;
			flightSpeed = flightSpeedEntry.Value;
			flightEnabled = flightEnabledEntry.Value;
			chopEnabled = chopEnabledEntry.Value;
			Hooking.OnUIRigCreated += delegate
			{
				activeAbilityManager = new AbilityManager(Player.RigManager);
			};
			Page val = Page.Root.CreatePage("Viltrumite", Color.yellow, 0, true);
			val.CreateFloat("Strength Multiplier", Color.yellow, strengthMultiplier, 5f, 1f, 100f, (Action<float>)delegate(float v)
			{
				strengthMultiplier = v;
				strengthMultiplierEntry.Value = v;
				mainCategory.SaveToFile(false);
				Player.RigManager.SwapAvatarCrate(((ScannableReference)Player.RigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			});
			val.CreateFloat("Speed Multiplier", Color.yellow, speedMultiplier, 0.5f, 1f, 100f, (Action<float>)delegate(float v)
			{
				speedMultiplier = v;
				speedMultiplierEntry.Value = v;
				mainCategory.SaveToFile(false);
				Player.RigManager.SwapAvatarCrate(((ScannableReference)Player.RigManager.AvatarCrate).Barcode, false, (Action<bool>)null);
			});
			val.CreateFloat("Flight Speed", Color.yellow, flightSpeed, 0.5f, 1f, 100f, (Action<float>)delegate(float v)
			{
				flightSpeed = v;
				flightSpeedEntry.Value = v;
				mainCategory.SaveToFile(false);
			});
			val.CreateBool("Flight Enabled", Color.green, flightEnabled, (Action<bool>)delegate(bool b)
			{
				flightEnabled = b;
				flightEnabledEntry.Value = b;
				mainCategory.SaveToFile(false);
			});
			val.CreateBool("Chop Enabled", Color.green, chopEnabled, (Action<bool>)delegate(bool b)
			{
				chopEnabled = b;
				chopEnabledEntry.Value = b;
				mainCategory.SaveToFile(false);
			});
		}

		public override void OnUpdate()
		{
			activeAbilityManager?.UpdateLoop();
		}

		public override void OnFixedUpdate()
		{
			activeAbilityManager?.FixedUpdateLoop();
		}
	}
	[HarmonyPatch(typeof(Avatar), "RefreshBodyMeasurements", new Type[] { })]
	public class AvatarComputeStats
	{
		public static void Postfix(Avatar __instance)
		{
			if (Object.op_Implicit((Object)(object)Player.RigManager))
			{
				RigManager componentInParent = ((Component)__instance).GetComponentInParent<RigManager>();
				if (Object.op_Implicit((Object)(object)componentInParent) && ((Object)componentInParent).GetInstanceID() == ((Object)Player.RigManager).GetInstanceID() && !Object.op_Implicit((Object)(object)((Il2CppObjectBase)__instance).TryCast<RealHeptaAvatar>()))
				{
					__instance._strengthUpper *= Core.strengthMultiplier;
					__instance._agility *= Core.speedMultiplier;
				}
			}
		}
	}
	public static class JointExtensions
	{
		public static void SetLinearDrive(this ConfigurableJoint joint, float drive, float damp)
		{
			//IL_0004: 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)
			SoftJointLimitSpring linearLimitSpring = default(SoftJointLimitSpring);
			((SoftJointLimitSpring)(ref linearLimitSpring)).spring = drive;
			((SoftJointLimitSpring)(ref linearLimitSpring)).damper = damp;
			joint.linearLimitSpring = linearLimitSpring;
		}

		public static void SetConnectedPoint(this ConfigurableJoint joint, Vector3 pos)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			((Joint)joint).autoConfigureConnectedAnchor = false;
			if (Object.op_Implicit((Object)(object)((Joint)joint).connectedBody))
			{
				((Joint)joint).connectedAnchor = ((Component)((Joint)joint).connectedBody).transform.InverseTransformPoint(pos);
			}
			else
			{
				((Joint)joint).connectedAnchor = pos;
			}
		}

		public static Vector3 GetConnectedPoint(this ConfigurableJoint joint)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)((Joint)joint).connectedBody))
			{
				return ((Component)((Joint)joint).connectedBody).transform.TransformPoint(((Joint)joint).connectedAnchor);
			}
			return ((Joint)joint).connectedAnchor;
		}

		public static void SetLinearLimit(this ConfigurableJoint joint, float distance)
		{
			//IL_0004: 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)
			SoftJointLimit linearLimit = default(SoftJointLimit);
			((SoftJointLimit)(ref linearLimit)).limit = distance;
			joint.linearLimit = linearLimit;
		}

		public static void SetMotion(this ConfigurableJoint joint, ConfigurableJointMotion motion)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			joint.xMotion = motion;
			joint.yMotion = motion;
			joint.zMotion = motion;
		}

		public static void SetRotation(this ConfigurableJoint joint, ConfigurableJointMotion motion)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			joint.angularXMotion = motion;
			joint.angularYMotion = motion;
			joint.angularZMotion = motion;
		}

		public static void SetRotDrives(this ConfigurableJoint joint, float spring, float damp)
		{
			//IL_0004: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			JointDrive angularXDrive = default(JointDrive);
			((JointDrive)(ref angularXDrive)).positionSpring = spring;
			((JointDrive)(ref angularXDrive)).positionDamper = damp;
			((JointDrive)(ref angularXDrive)).maximumForce = float.PositiveInfinity;
			joint.angularXDrive = angularXDrive;
			joint.angularYZDrive = joint.angularXDrive;
		}

		public static void SetPosDrives(this ConfigurableJoint joint, float spring, float damp, float maxForce)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			JointDrive xDrive = default(JointDrive);
			((JointDrive)(ref xDrive)).positionSpring = spring;
			((JointDrive)(ref xDrive)).positionDamper = damp;
			((JointDrive)(ref xDrive)).maximumForce = maxForce;
			joint.xDrive = xDrive;
			joint.yDrive = joint.xDrive;
			joint.zDrive = joint.xDrive;
		}
	}
}
namespace ViltrumiteMod.Abilities
{
	public abstract class Ability
	{
		public bool active = false;

		public RigManager activeManager { get; private set; }

		public Ability(RigManager rigManager)
		{
			activeManager = rigManager;
		}

		public abstract void Update();

		public abstract void FixedUpdate();

		public abstract void OnActivate();

		public abstract void OnDeactivate();

		public abstract bool ShouldActivate();

		public abstract bool ShouldDeactivate();
	}
	public class AbilityManager
	{
		private RigManager mainManager;

		private List<Ability> abilities;

		public AbilityManager(RigManager rigManager)
		{
			mainManager = rigManager;
			RegisterAbilities(rigManager);
		}

		public void RegisterAbilities(RigManager rigManager)
		{
			mainManager = rigManager;
			abilities = new List<Ability>
			{
				new FlightAbility(rigManager),
				new ChopAbility(rigManager)
			};
		}

		public void UpdateLoop()
		{
			if (!Object.op_Implicit((Object)(object)mainManager))
			{
				return;
			}
			foreach (Ability ability in abilities)
			{
				ability.Update();
				if (ability.active)
				{
					if (ability.ShouldDeactivate())
					{
						ability.OnDeactivate();
						ability.active = false;
					}
				}
				else if (ability.ShouldActivate())
				{
					ability.OnActivate();
					ability.active = true;
				}
			}
		}

		public void FixedUpdateLoop()
		{
			if (!Object.op_Implicit((Object)(object)mainManager))
			{
				return;
			}
			foreach (Ability ability in abilities)
			{
				ability.FixedUpdate();
			}
		}
	}
}
namespace ViltrumiteMod.Abilities.Impl
{
	public class ChopAbility : Ability
	{
		private ChoppingHand leftChoppingHand;

		private ChoppingHand rightChoppingHand;

		public ChopAbility(RigManager rigManager)
			: base(rigManager)
		{
			leftChoppingHand = new ChoppingHand(rigManager.physicsRig, rigManager.controllerRig, (Handedness)1);
			rightChoppingHand = new ChoppingHand(rigManager.physicsRig, rigManager.controllerRig, (Handedness)2);
		}

		public override void FixedUpdate()
		{
		}

		public override void OnActivate()
		{
		}

		public override void OnDeactivate()
		{
		}

		public override bool ShouldActivate()
		{
			return true;
		}

		public override bool ShouldDeactivate()
		{
			return false;
		}

		public override void Update()
		{
			if (active && Core.chopEnabled)
			{
				float deltaTime = Time.deltaTime;
				rightChoppingHand.Update(deltaTime);
				leftChoppingHand.Update(deltaTime);
			}
		}
	}
	public class ChoppingHand
	{
		private Hand hand;

		private Transform shoulder;

		private Transform elbow;

		private TriggerRefProxy refProxy;

		private Vector3 lastHandPositionForDamage = Vector3.zero;

		private BaseController controller;

		private Rigidbody handBody;

		private List<MarrowBody> entireArm = new List<MarrowBody>();

		private MarrowBody[] ignoredBodies;

		private List<Collider> ignoredColliders = new List<Collider>();

		private ConfigurableJoint resistanceJoint;

		private Dictionary<int, IAttackReceiver[]> attackReceiverCache = new Dictionary<int, IAttackReceiver[]>();

		private bool activelyChopping = false;

		private bool waitingForDebounce = false;

		private float timeOutsideBody = 0f;

		private const float _maxTimeOutsideBody = 0.2f;

		private float _triggerDistance = 0.1f;

		private float _handMagnitudeMin = 2f;

		private float resistanceSpring = 50000f;

		private float resistanceDamp = 400f;

		public ChoppingHand(PhysicsRig physicsRig, ControllerRig controllerRig, Handedness handedness)
		{
			//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_008a: 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_008c: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Invalid comparison between Unknown and I4
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			refProxy = ((Component)((Rig)physicsRig).manager).GetComponentInChildren<TriggerRefProxy>();
			if ((int)handedness != 1)
			{
				if ((int)handedness == 2)
				{
					hand = physicsRig.rightHand;
					entireArm.Add(((Component)((Rig)physicsRig).m_shoulderRt).GetComponent<MarrowBody>());
					entireArm.Add(((Component)((Rig)physicsRig).m_elbowRt).GetComponent<MarrowBody>());
					shoulder = ((Rig)physicsRig).m_shoulderRt;
					elbow = ((Rig)physicsRig).m_elbowRt;
					controller = controllerRig.rightController;
				}
			}
			else
			{
				hand = physicsRig.leftHand;
				entireArm.Add(((Component)((Rig)physicsRig).m_shoulderLf).GetComponent<MarrowBody>());
				entireArm.Add(((Component)((Rig)physicsRig).m_elbowLf).GetComponent<MarrowBody>());
				shoulder = ((Rig)physicsRig).m_shoulderLf;
				elbow = ((Rig)physicsRig).m_elbowLf;
				controller = controllerRig.leftController;
			}
			handBody = ((Component)hand).GetComponent<Rigidbody>();
			entireArm.Add(((Component)hand).GetComponent<MarrowBody>());
		}

		public void Update(float deltaTime)
		{
			//IL_0017: 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_0196: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (waitingForDebounce)
			{
				if (((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Component)hand).transform.position, _triggerDistance + 0.02f, 4096)).Length == 0)
				{
					waitingForDebounce = false;
				}
			}
			else
			{
				Vector3 val;
				if (!activelyChopping)
				{
					if (hand.HasAttachedObject() || controller.isBelowGripThreshold)
					{
						return;
					}
					val = handBody.velocity;
					if (!(((Vector3)(ref val)).magnitude > _handMagnitudeMin))
					{
						return;
					}
					{
						foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Component)hand).transform.position, _triggerDistance, 4096))
						{
							MarrowEntity componentInParent = ((Component)item).GetComponentInParent<MarrowEntity>();
							if (Object.op_Implicit((Object)(object)componentInParent))
							{
								ignoredBodies = Il2CppArrayBase<MarrowBody>.op_Implicit((Il2CppArrayBase<MarrowBody>)(object)componentInParent._bodies);
								ignoredColliders.Clear();
								MarrowBody[] array = ignoredBodies;
								foreach (MarrowBody val2 in array)
								{
									ignoredColliders.AddRange((IEnumerable<Collider>)val2._colliders);
								}
								IgnoreCapturedBodies(ignore: true);
								activelyChopping = true;
								MakeResistanceJoint();
								break;
							}
						}
						return;
					}
				}
				UpdateResistanceJoint();
				val = lastHandPositionForDamage - ((Component)hand).transform.position;
				if (((Vector3)(ref val)).magnitude > 0.2f)
				{
					DamageNearbyReceiver();
					lastHandPositionForDamage = ((Component)hand).transform.position;
				}
				if (IsArmOutsideBody())
				{
					timeOutsideBody += deltaTime;
				}
				if (timeOutsideBody >= 0.2f)
				{
					attackReceiverCache.Clear();
					IgnoreCapturedBodies(ignore: false);
					Object.Destroy((Object)(object)resistanceJoint);
					waitingForDebounce = true;
					activelyChopping = false;
					timeOutsideBody = 0f;
				}
			}
		}

		public void MakeResistanceJoint()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			resistanceJoint = ((Component)hand).gameObject.AddComponent<ConfigurableJoint>();
			((Joint)resistanceJoint).autoConfigureConnectedAnchor = false;
			((Joint)resistanceJoint).anchor = Vector3.zero;
			resistanceJoint.SetConnectedPoint(((Component)hand).transform.position);
			resistanceJoint.SetPosDrives(resistanceSpring, resistanceDamp, float.PositiveInfinity);
		}

		public void UpdateResistanceJoint()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)resistanceJoint))
			{
				resistanceJoint.SetConnectedPoint(((Component)hand).transform.position);
			}
		}

		public void DamageNearbyReceiver()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00bd: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			MarrowBody val = null;
			float num = float.MaxValue;
			MarrowBody[] array = ignoredBodies;
			foreach (MarrowBody val2 in array)
			{
				float num2 = Vector3.Distance(((Component)val2).transform.position, ((Component)hand).transform.position);
				if (num > num2)
				{
					num = num2;
					val = val2;
				}
			}
			Attack val3 = new Attack
			{
				direction = hand.palmPositionTransform.forward,
				collider = ((Il2CppArrayBase<Collider>)(object)val._colliders)[0],
				attackType = (AttackType)2,
				proxy = refProxy,
				backFacing = false,
				damage = Core.chopDamage,
				normal = Vector3.up,
				OrderInPool = 0,
				origin = ((Component)hand).transform.position
			};
			int instanceID = ((Object)val).GetInstanceID();
			IAttackReceiver[] array2;
			if (attackReceiverCache.ContainsKey(instanceID))
			{
				array2 = attackReceiverCache[instanceID];
			}
			else
			{
				array2 = Il2CppArrayBase<IAttackReceiver>.op_Implicit(((Component)val).GetComponents<IAttackReceiver>());
				attackReceiverCache.Add(instanceID, array2);
			}
			for (int j = 0; j < 3; j++)
			{
				IAttackReceiver[] array3 = array2;
				foreach (IAttackReceiver val4 in array3)
				{
					val4.ReceiveAttack(val3);
				}
			}
		}

		public bool IsArmOutsideBody()
		{
			//IL_0009: 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)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_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_002e: 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_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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			bool result = true;
			Vector3 position = shoulder.position;
			Vector3 position2 = elbow.position;
			Vector3 val = position2 - position;
			Vector3 val2 = ((Component)hand).transform.position - position2;
			if (Physics.Raycast(position, val, ((Vector3)(ref val)).magnitude, 4096))
			{
				result = false;
			}
			if (Physics.Raycast(position2, val2, ((Vector3)(ref val2)).magnitude, 4096))
			{
				result = false;
			}
			return result;
		}

		public void IgnoreCapturedBodies(bool ignore)
		{
			foreach (MarrowBody item in entireArm)
			{
				MarrowBody[] array = ignoredBodies;
				foreach (MarrowBody val in array)
				{
					val.IgnoreCollision(item, ignore);
				}
			}
		}
	}
	public class FlightAbility : Ability
	{
		private BaseController rightController;

		private BaseController leftController;

		private Hand rightHand;

		private Transform head;

		private Rigidbody[] bodies;

		private float lastPressTime = 0f;

		private const float _gapTime = 0.2f;

		private int pressCount = 0;

		private bool activated = false;

		public FlightAbility(RigManager rigManager)
			: base(rigManager)
		{
			rightHand = rigManager.physicsRig.rightHand;
			head = ((Rig)rigManager.physicsRig).m_head;
			rightController = rigManager.controllerRig.rightController;
			leftController = rigManager.controllerRig.leftController;
			bodies = Il2CppArrayBase<Rigidbody>.op_Implicit(((Component)rigManager).GetComponentsInChildren<Rigidbody>());
		}

		public override void OnActivate()
		{
			Rigidbody[] array = bodies;
			foreach (Rigidbody val in array)
			{
				val.useGravity = false;
			}
		}

		public override void OnDeactivate()
		{
			Rigidbody[] array = bodies;
			foreach (Rigidbody val in array)
			{
				val.useGravity = true;
			}
		}

		public override bool ShouldActivate()
		{
			if (!Core.flightEnabled)
			{
				return false;
			}
			return activated;
		}

		public override bool ShouldDeactivate()
		{
			if (!Core.flightEnabled)
			{
				return true;
			}
			return !activated;
		}

		public override void Update()
		{
			if (Core.flightEnabled && rightController.GetBButtonDown() && !rightHand.HasAttachedObject())
			{
				float time = Time.time;
				if (time - lastPressTime < 0.2f)
				{
					pressCount++;
				}
				else
				{
					pressCount = 0;
				}
				lastPressTime = time;
				if (pressCount >= 1)
				{
					activated = !activated;
					pressCount = 0;
				}
			}
		}

		public override void FixedUpdate()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0060: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if (!Core.flightEnabled || !activated)
			{
				return;
			}
			Vector2 thumbStickAxis = leftController.GetThumbStickAxis();
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(thumbStickAxis.x, 0f, thumbStickAxis.y);
			if (((Vector3)(ref val)).magnitude > 0.1f)
			{
				Vector3 val2 = head.rotation * val;
				((Vector3)(ref val2)).Normalize();
				Rigidbody[] array = bodies;
				foreach (Rigidbody val3 in array)
				{
					val3.AddForce(val2 * Core.flightSpeed, (ForceMode)5);
				}
			}
			else
			{
				Rigidbody[] array2 = bodies;
				foreach (Rigidbody val4 in array2)
				{
					val4.AddForce(-val4.velocity, (ForceMode)5);
				}
			}
		}
	}
}