Decompiled source of BetterFlatPlayer DefaultAccess v0.15.1
Mods/BetterFlatPlayer.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BoneLib.BoneMenu; using FlatPlayer; using HarmonyLib; using Il2CppCysharp.Threading.Tasks; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Bonelab; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Input; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.PuppetMasta; using Il2CppSLZ.Marrow.SceneStreaming; using Il2CppSLZ.Marrow.Utilities; using Il2CppSLZ.Marrow.Warehouse; using Il2CppSLZ.VRMK; using Il2CppSystem; using Il2CppSystem.Reflection; using LabFusion.Network; using LabFusion.RPC; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(FlatMod), "Better FlatPlayer", "0.15.1", "guardpost", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("BetterFlatPlayer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7190628efa5dc45b2ed72b4cc09f7797d9c6cc33")] [assembly: AssemblyProduct("BetterFlatPlayer")] [assembly: AssemblyTitle("BetterFlatPlayer")] [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 FlatPlayer { public static class BoneMenuPage { private static bool _made; private static void Save() { MelonPreferences.Save(); } public static void TryCreate() { if (_made || !AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.GetName().Name == "BoneLib")) { return; } try { Create(); _made = true; Log.Msg("[FlatPlayer] BoneMenu: Presets page added"); } catch (Exception e) { Log.Once("bonemenu", e); _made = true; } } private static void Create() { //IL_0019: 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_005b: 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_00b5: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) Page obj = Page.Root.CreatePage("Presets", new Color(1f, 0.6f, 0.1f), 0, true); obj.CreateFunction("Default (Better FlatPlayer)", Color.white, (Action)delegate { Presets.Set("Default"); }); obj.CreateBool("Third person (P)", Color.white, Prefs.ThirdPerson.Value, (Action<bool>)delegate(bool v) { Prefs.ThirdPerson.Value = v; MelonPreferences.Save(); }); Page obj2 = obj.CreatePage("Settings", new Color(0.6f, 0.9f, 1f), 0, true); obj2.CreateFloat("Field of view", Color.white, Prefs.Fov.Value, 5f, 50f, 130f, (Action<float>)delegate(float v) { Prefs.Fov.Value = v; Save(); }); obj2.CreateFloat("Aim (ADS) field of view", Color.white, Prefs.AdsFov.Value, 5f, 20f, 110f, (Action<float>)delegate(float v) { Prefs.AdsFov.Value = v; Save(); }); obj2.CreateFloat("Mouse sensitivity", Color.white, Prefs.Sensitivity.Value, 0.1f, 0.1f, 5f, (Action<float>)delegate(float v) { Prefs.Sensitivity.Value = v; Save(); }); obj2.CreateBool("Menu lock", Color.white, Prefs.MenuLock.Value, (Action<bool>)delegate(bool v) { Prefs.MenuLock.Value = v; Save(); }); obj2.CreateBool("Gun animations", Color.white, Prefs.GunAnims.Value, (Action<bool>)delegate(bool v) { Prefs.GunAnims.Value = v; Save(); }); obj2.CreateBool("Movement addon (slide / dash / mantle)", Color.white, Prefs.Movement.Value, (Action<bool>)delegate(bool v) { Prefs.Movement.Value = v; Save(); }); obj2.CreateBool("Two-handed guns", Color.white, Prefs.TwoHanded.Value, (Action<bool>)delegate(bool v) { Prefs.TwoHanded.Value = v; Save(); }); obj2.CreateFloat("Strength", Color.white, Prefs.Strength.Value, 1f, 1f, 10f, (Action<float>)delegate(float v) { Prefs.Strength.Value = v; Save(); }); } } [HarmonyPatch(typeof(XRApi), "InitializeXRLoader")] internal static class SkipXRLoaderPatch { private static bool Prefix(ref UniTask __result) { if (!Prefs.On) { return true; } MelonLogger.Msg("[FlatPlayer] skipping the OpenXR loader (flat mode)"); __result = UniTask.CompletedTask; return false; } } [HarmonyPatch(typeof(TimeManager), "PAUSE")] internal static class NoHeadsetPausePatch { private static bool _said; private static bool Prefix() { if (!Prefs.On) { return true; } if (!_said) { _said = true; MelonLogger.Msg("[FlatPlayer] ignored a headset-off pause"); } return false; } } public static class Unpause { public static void Check() { if (TimeManager._isPaused || Time.timeScale == 0f) { MelonLogger.Msg("[FlatPlayer] game was paused for the missing headset - resuming"); try { TimeManager.UNPAUSE(); } catch { } if (Time.timeScale == 0f) { Time.timeScale = 1f; } AudioListener.pause = false; } } } public static class Strong { private struct Base { public float U; public float L; public float G; public float S; public float A; } private static readonly Dictionary<IntPtr, Base> _base = new Dictionary<IntPtr, Base>(); private static IntPtr _done; private static float _doneK = -1f; private static float _doneV = -1f; public static float GokuStrength { get { if (Goku.Active) { if (Goku.Form != Form.UltraInstinct) { if (Goku.Form != Form.SuperSaiyan) { return 1.25f; } return 1.6f; } return 2f; } return 1f; } } public static float GokuSpeed { get { if (Goku.Active) { if (Goku.Form != Form.UltraInstinct) { if (Goku.Form != Form.SuperSaiyan) { return 1.15f; } return 1.3f; } return 1.4f; } return 1f; } } public static float GokuToughness { get { if (Goku.Active) { if (Goku.Form != Form.UltraInstinct) { if (Goku.Form != Form.SuperSaiyan) { return 2f; } return 4f; } return 8f; } return 1f; } } public static void Update(RigManager rig) { Avatar val = ((rig != null) ? rig.avatar : null); if ((Object)(object)val == (Object)null || (Object)(object)rig.physicsRig == (Object)null) { return; } float num = Mathf.Min(Mathf.Clamp(Prefs.Strength.Value, 0.25f, 20f) * GokuStrength, 8f); float gokuSpeed = GokuSpeed; if (((Il2CppObjectBase)val).Pointer == _done && Mathf.Approximately(num, _doneK) && Mathf.Approximately(gokuSpeed, _doneV)) { return; } try { if (!_base.TryGetValue(((Il2CppObjectBase)val).Pointer, out var value)) { value = (_base[((Il2CppObjectBase)val).Pointer] = new Base { U = val._strengthUpper, L = val._strengthLower, G = val._strengthGrip, S = val._speed, A = val._agility }); } val._strengthUpper = value.U * num; val._strengthLower = value.L * num; val._strengthGrip = value.G * num; val._speed = value.S * gokuSpeed; val._agility = value.A; rig.physicsRig.CalibrateJoints(val); _done = ((Il2CppObjectBase)val).Pointer; _doneK = num; _doneV = gokuSpeed; Log.Msg($"[FlatPlayer] body: strength x{num:0.#} (upper {val._strengthUpper:0.0} grip {val._strengthGrip:0.0}), speed x{gokuSpeed:0.##} ({val._speed:0.00}), mass {val._massTotal:0.0} kg (arm {val._massArm:0.0}, chest {val._massChest:0.0}) avatar {((Object)val).name}"); } catch (Exception e) { Log.Once("strength", e); _done = ((Il2CppObjectBase)val).Pointer; _doneK = num; _doneV = gokuSpeed; } } } [HarmonyPatch(typeof(Player_Health), "TAKEDAMAGE")] internal static class GokuToughPatch { private static void Prefix(Player_Health __instance, ref float damage) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) try { if (Goku.Active && !((Object)(object)Flat.Rig == (Object)null) && !((Object)(object)((Health)__instance)._rigManager == (Object)null) && !(((Il2CppObjectBase)((Health)__instance)._rigManager).Pointer != ((Il2CppObjectBase)Flat.Rig).Pointer)) { damage /= Strong.GokuToughness; if (Dodge.Immune) { damage = 0f; } if (Goku.Form == Form.UltraInstinct && damage > 0f && Dodge.Do(Vector3.zero)) { damage = 0f; } } } catch { } } } [HarmonyPatch(typeof(PlayerDamageReceiver), "ReceiveAttack")] internal static class GokuDodgeHitPatch { private static bool Prefix(PlayerDamageReceiver __instance, Attack attack) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) try { if (!Goku.Active || Goku.Form != Form.UltraInstinct || (Object)(object)Flat.Rig == (Object)null) { return true; } RigManager componentInParent = ((Component)__instance).GetComponentInParent<RigManager>(); if ((Object)(object)componentInParent == (Object)null || ((Il2CppObjectBase)componentInParent).Pointer != ((Il2CppObjectBase)Flat.Rig).Pointer) { return true; } if (!Dodge.Do(attack.direction)) { return true; } return false; } catch { return true; } } } [HarmonyPatch(typeof(Projectile), "SetBulletObject")] internal static class ProjectileSeen { private static void Postfix(Projectile __instance) { try { if (Goku.Active && Goku.Form == Form.UltraInstinct) { Dodge.Track(__instance); } } catch { } } } public static class Dodge { private static readonly List<Projectile> _live = new List<Projectile>(); private static float _cd; private static float _immune; private static float _scanT; private static readonly HashSet<int> _seen = new HashSet<int>(); public const float MaxStamina = 100f; public const float Cost = 12f; public static float Stamina = 100f; private static float _sinceDodge = 9f; public static bool Immune => _immune > 0f; public static bool Tired { get; private set; } public static void Track(Projectile p) { if ((Object)(object)p != (Object)null && _live.Count < 200) { _live.Add(p); } } public static void Update(RigManager rig, float dt) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_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_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) _cd -= dt; _immune -= dt; _sinceDodge += dt; if (_sinceDodge > 1f || Tired) { Stamina = Mathf.Min(100f, Stamina + 10f * dt); } if (Tired && Stamina >= 100f) { Tired = false; Log.Msg("[FlatPlayer] Ultra Instinct stamina full: dodging again"); } if (!Goku.Active || Goku.Form != Form.UltraInstinct) { _live.Clear(); return; } object obj; if (rig == null) { obj = null; } else { PhysicsRig physicsRig = rig.physicsRig; obj = ((physicsRig != null) ? ((Rig)physicsRig).m_chest : null); } Transform val = (Transform)obj; if ((Object)(object)val == (Object)null) { _live.Clear(); return; } Vector3 position = val.position; Vector3 val5; if ((_scanT -= dt) <= 0f) { _scanT = 0.05f; Rigidbody val2 = null; Rigidbody val3 = null; try { PhysicsRig physicsRig2 = rig.physicsRig; GameObject currentAttachedGO = physicsRig2.leftHand.m_CurrentAttachedGO; val2 = ((currentAttachedGO != null) ? currentAttachedGO.GetComponentInParent<Rigidbody>() : null); GameObject currentAttachedGO2 = physicsRig2.rightHand.m_CurrentAttachedGO; val3 = ((currentAttachedGO2 != null) ? currentAttachedGO2.GetComponentInParent<Rigidbody>() : null); } catch { } Vector3 val4 = Vector3.zero; try { Rigidbody component = ((Component)((Rig)rig.physicsRig).m_chest).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { val4 = component.velocity; } } catch { } _seen.Clear(); foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(position, 3f, -1, (QueryTriggerInteraction)1)) { Rigidbody attachedRigidbody = item.attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)null || attachedRigidbody.isKinematic || !_seen.Add(((Object)attachedRigidbody).GetInstanceID()) || Flat.IsPlayer(item) || (Object)(object)attachedRigidbody == (Object)(object)val2 || (Object)(object)attachedRigidbody == (Object)(object)val3) { continue; } val5 = attachedRigidbody.velocity; if (((Vector3)(ref val5)).sqrMagnitude < 16f) { continue; } Vector3 val6 = attachedRigidbody.velocity - val4; float magnitude = ((Vector3)(ref val6)).magnitude; if (magnitude < 4f) { continue; } Vector3 val7 = position - attachedRigidbody.worldCenterOfMass; float num = Vector3.Dot(val7, val6 / magnitude); if (!(num <= 0f)) { val5 = val7 - val6 / magnitude * num; if (((Vector3)(ref val5)).magnitude < 0.7f && num / magnitude < 0.35f) { Do(val6); break; } } } } for (int num2 = _live.Count - 1; num2 >= 0; num2--) { Projectile val8 = _live[num2]; try { if ((Object)(object)val8 == (Object)null || val8.isFinished || !((Component)val8).gameObject.activeInHierarchy) { _live.RemoveAt(num2); } else { Vector3 direction = val8._direction; float num3 = Mathf.Max(val8.currentSpeed, 1f); if (!(((Vector3)(ref direction)).sqrMagnitude < 0.01f)) { ((Vector3)(ref direction)).Normalize(); Vector3 position2 = ((Component)val8).transform.position; Vector3 val9 = position - position2; float num4 = Vector3.Dot(val9, direction); if (num4 < 0f) { if (((Vector3)(ref val9)).magnitude > 3f) { _live.RemoveAt(num2); } } else { val5 = val9 - direction * num4; float magnitude2 = ((Vector3)(ref val5)).magnitude; if (!(num4 < 2f) && magnitude2 < 0.8f && num4 / num3 < 0.3f) { Do(direction); _live.RemoveAt(num2); } } } } } catch { _live.RemoveAt(num2); } } } public static bool Do(Vector3 bulletDir) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b7: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) if (_immune > 0f) { return true; } if (Tired || Stamina < 12f || (Object)(object)Flat.Rig == (Object)null) { return false; } Stamina -= 12f; _sinceDodge = 0f; if (Stamina < 12f) { Tired = true; Log.Msg("[FlatPlayer] Ultra Instinct out of stamina: no dodging until the bar is full"); } _immune = 0.4f; if (_cd > 0f) { return true; } _cd = 0.35f; Vector3 val = bulletDir; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val) * ((Random.value < 0.5f) ? 1f : (-1f)); PhysicsRig physicsRig = Flat.Rig.physicsRig; Transform val3 = ((physicsRig != null) ? ((Rig)physicsRig).m_chest : null); if ((Object)(object)val3 != (Object)null && Physics.Raycast(val3.position, val2, 1.2f, -1, (QueryTriggerInteraction)1)) { val2 = -val2; } AntiFling.Cancel(); Movement.SincePush = 0f; foreach (Rigidbody item in AntiFling.Bodies(Flat.Rig)) { if ((Object)(object)item != (Object)null) { item.AddForce(val2 * 7f, (ForceMode)2); } } try { if ((Object)(object)val3 != (Object)null) { PalletFx.Spawn("Burst Silver", val3.position, Quaternion.LookRotation(val2), 0.8f); } } catch { } Log.Msg($"[FlatPlayer] Ultra Instinct dodge (stamina {Stamina:0})"); return true; } } public static class GokuHealth { public const float GokuBase = 25f; private static float _gameMax = -1f; private static float _set = -1f; private static IntPtr _for; public static float Mult { get { if (Goku.Active) { if (Goku.Form != Form.UltraInstinct) { if (Goku.Form != Form.SuperSaiyan) { return 10f; } return 20f; } return 40f; } return 1f; } } public static void Update(RigManager rig) { Player_Health val = null; try { object obj; if (rig == null) { obj = null; } else { Health health = rig.health; obj = ((health != null) ? ((Il2CppObjectBase)health).TryCast<Player_Health>() : null); } val = (Player_Health)obj; } catch { } if (!((Object)(object)val == (Object)null)) { if (((Il2CppObjectBase)val).Pointer != _for) { _for = ((Il2CppObjectBase)val).Pointer; _gameMax = ((Health)val).max_Health; _set = -1f; } if (!Mathf.Approximately(((Health)val).max_Health, _set)) { _gameMax = ((Health)val).max_Health; } float num = (Goku.Active ? (25f * Mult) : _gameMax); if (Mathf.Approximately(((Health)val).max_Health, num) || num <= 0f) { _set = ((Health)val).max_Health; return; } float num2 = ((((Health)val).max_Health > 0f) ? Mathf.Clamp01(((Health)val).curr_Health / ((Health)val).max_Health) : 1f); bool flag = num > ((Health)val).max_Health; ((Health)val).max_Health = num; ((Health)val).curr_Health = num * (flag ? 1f : num2); _set = num; Log.Msg($"[FlatPlayer] health: max {num:0.#}{(Goku.Active ? $" (Goku {25f:0} x{Mult:0})" : " (game)")}"); } } } public static class Cameras { public static Camera Main; public static Camera Head; private static Texture2D _dot; private static float _ads; private static float _spread; private static bool _hooked; private static OpenControllerRig _ocr; private static float _recheck; private static int _savedMask; private static int _bodyMask; private static bool _maskSaved; private static float _dist = 2.6f; private static readonly List<(Renderer r, bool en, int layer, ShadowCastingMode sh, bool off)> _head = new List<(Renderer, bool, int, ShadowCastingMode, bool)>(); private static Object _headFor; private static IntPtr _headAvatar; private static bool _headShown; private static IntPtr _boundsFor; private static readonly List<Renderer> _ownHead = new List<Renderer>(); private static IntPtr _ownHeadAvatar; private static float _headLogT; private static Transform _proxy; private static Transform _realHead; private static Vector3 _proxyRest; private static IntPtr _restFor; private static Transform _headBone; private static Vector3 _headRest; private static bool _haveRest; private static Vector3 _steady; private static bool _steadyOn; private static float _steadyLast; public static Vector3 SteadyOffset; public static bool ThirdPerson { get { if (Prefs.ThirdPerson.Value && (Object)(object)Flat.Rig != (Object)null) { return !Flat.Loading; } return false; } } public static void Setup(OpenControllerRig ocr) { //IL_0283: Unknown result type (might be due to invalid IL or missing references) Head = null; Main = null; _ocr = ocr; if ((Object)(object)ocr.headset != (Object)null) { Head = ((Component)ocr.headset).GetComponentInChildren<Camera>(true); } if ((Object)(object)Head == (Object)null && ocr.cameras != null) { foreach (Camera item in (Il2CppArrayBase<Camera>)(object)ocr.cameras) { if ((Object)(object)item != (Object)null) { Head = item; break; } } } Main = PickScreenCamera(); if ((Object)(object)Main == (Object)null) { Main = Head; } if ((Object)(object)Main != (Object)null) { List<Behaviour> list = new List<Behaviour>(); foreach (Behaviour component in ((Component)Main).GetComponents<Behaviour>()) { list.Add(component); } if ((Object)(object)((Component)Main).transform.parent != (Object)null) { foreach (Behaviour component2 in ((Component)((Component)Main).transform.parent).GetComponents<Behaviour>()) { list.Add(component2); } } foreach (Behaviour item2 in list) { if (!((Object)(object)item2 == (Object)null)) { string fullName = ((Object)item2).GetIl2CppType().FullName; Log.Msg($"[FlatPlayer] on {((Object)Main).name}: {fullName} enabled {item2.enabled}"); if (fullName.Contains("TrackedPose") || fullName.Contains("PoseDriver") || fullName.Contains("Spectator") || fullName.Contains("Follow")) { item2.enabled = false; Log.Msg("[FlatPlayer] disabled " + fullName); } } } ((Behaviour)Main).enabled = true; ((Component)Main).gameObject.SetActive(true); Main.stereoTargetEye = (StereoTargetEyeMask)0; Main.rect = new Rect(0f, 0f, 1f, 1f); if ((Object)(object)Head != (Object)null) { Main.nearClipPlane = Head.nearClipPlane; Main.cullingMask = Head.cullingMask; } } foreach (Camera item3 in Object.FindObjectsOfType<Camera>()) { if ((Object)(object)Main != (Object)null && (Object)(object)item3 != (Object)(object)Main && (Object)(object)item3 != (Object)(object)Head && (Object)(object)item3.targetTexture == (Object)null && ((Behaviour)item3).enabled && item3.depth > Main.depth) { ((Behaviour)item3).enabled = false; Log.Msg("[FlatPlayer] turned off overlay camera '" + ((Object)item3).name + "'"); } } DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(46, 2); defaultInterpolatedStringHandler.AppendLiteral("[FlatPlayer] monitor camera '"); Camera main = Main; defaultInterpolatedStringHandler.AppendFormatted((main != null) ? ((Object)main).name : null); defaultInterpolatedStringHandler.AppendLiteral("', head camera '"); Camera head = Head; defaultInterpolatedStringHandler.AppendFormatted((head != null) ? ((Object)head).name : null); defaultInterpolatedStringHandler.AppendLiteral("'"); Log.Msg(defaultInterpolatedStringHandler.ToStringAndClear()); if (_hooked) { return; } _hooked = true; try { RenderPipelineManager.beginCameraRendering += DelegateSupport.ConvertDelegate<Action<ScriptableRenderContext, Camera>>((Delegate)(Action<ScriptableRenderContext, Camera>)delegate(ScriptableRenderContext ctx, Camera cam) { if ((Object)(object)Main != (Object)null && (Object)(object)cam != (Object)null && ((Il2CppObjectBase)cam).Pointer == ((Il2CppObjectBase)Main).Pointer) { Follow(); } }); } catch (Exception e) { Log.Once("render hook", e); } } private static Camera PickScreenCamera() { Camera val = null; foreach (Camera item in (Il2CppArrayBase<Camera>)(object)Camera.allCameras) { if (!((Object)(object)item == (Object)null) && !((Object)(object)item == (Object)(object)Head) && !((Object)(object)item.targetTexture != (Object)null) && !((Object)item).name.Contains("Overlay") && ((Object)(object)val == (Object)null || item.depth > val.depth)) { val = item; } } return val; } public static void Ensure(OpenControllerRig ocr) { _recheck -= Time.unscaledDeltaTime; bool flag = (Object)(object)Main == (Object)null || (Object)(object)Head == (Object)null || !((Behaviour)Main).isActiveAndEnabled || (Object)(object)ocr != (Object)(object)_ocr; if (flag || !(_recheck > 0f)) { _recheck = 1f; Camera val = PickScreenCamera(); if (flag || ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)Main && val.depth > Main.depth)) { _ocr = ocr; Setup(ocr); } } } public static void Update(float ads) { _ads = ads; Follow(); } public static void Follow() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Main == (Object)null || (Object)(object)Head == (Object)null || (Object)(object)Main == (Object)(object)Head) { if ((Object)(object)Main != (Object)null) { Main.fieldOfView = Fov(); } return; } Transform val = (((Object)(object)((Component)Head).transform.parent != (Object)null) ? ((Component)Head).transform.parent : ((Component)Head).transform); if ((Object)(object)((Component)Main).transform.parent != (Object)(object)val) { ((Component)Main).transform.SetParent(val, false); } ((Component)Main).transform.localPosition = Devices.HeadPos; if (!ThirdPerson) { ((Component)Main).transform.position = Steady(((Component)Main).transform.position); } ((Component)Main).transform.rotation = Flat.ViewRotation; if (ThirdPerson) { PlaceBehind(val); } else { FirstPerson(); } try { OwnHead(); } catch (Exception e) { Log.Once("own head", e); } try { KeepBodyDrawn(); } catch (Exception e2) { Log.Once("body bounds", e2); } Main.ResetWorldToCameraMatrix(); Main.ResetProjectionMatrix(); Main.ResetCullingMatrix(); Main.fieldOfView = Fov(); } private static void PlaceBehind(Transform space) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_004d: 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_005b: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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) Vector3 val = space.TransformPoint(Devices.HeadPos); Quaternion viewRotation = Flat.ViewRotation; Vector3 val2 = viewRotation * Vector3.back; Vector3 up = Vector3.up; Vector3 val3 = viewRotation * Vector3.right; Vector3 val4 = val + up * 0.25f + val3 * 0.45f; float num = 2.6f; foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.SphereCastAll(val4, 0.2f, val2, num, -1, (QueryTriggerInteraction)1)) { RaycastHit current = item; if ((Object)(object)((RaycastHit)(ref current)).collider != (Object)null && !Flat.IsPlayer(((RaycastHit)(ref current)).collider) && (Object)(object)((RaycastHit)(ref current)).collider.attachedRigidbody == (Object)null && ((RaycastHit)(ref current)).distance < num) { num = Mathf.Max(0.4f, ((RaycastHit)(ref current)).distance - 0.05f); } } _dist = Mathf.Lerp(_dist, num, (num < _dist) ? 1f : (Time.unscaledDeltaTime * 4f)); ((Component)Main).transform.position = val4 + val2 * _dist; if (!_maskSaved) { _savedMask = Main.cullingMask; _maskSaved = true; StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 32; i++) { if ((_savedMask & (1 << i)) == 0 && LayerMask.LayerToName(i) != "") { StringBuilder stringBuilder2 = stringBuilder; StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(2, 2, stringBuilder2); handler.AppendLiteral(" "); handler.AppendFormatted(i); handler.AppendLiteral(":"); handler.AppendFormatted(LayerMask.LayerToName(i)); stringBuilder2.Append(ref handler); } } if (Prefs.Debug.Value) { Log.Msg($"[FlatPlayer] third person: camera hides layers{stringBuilder}"); } _bodyMask = 0; RigManager rig = Flat.Rig; if ((Object)(object)rig != (Object)null) { foreach (Renderer componentsInChild in ((Component)rig).GetComponentsInChildren<Renderer>(true)) { if ((Object)(object)componentsInChild != (Object)null) { _bodyMask |= 1 << ((Component)componentsInChild).gameObject.layer; } } } if (Prefs.Debug.Value) { Log.Msg($"[FlatPlayer] third person: your body is on layers 0x{_bodyMask:X}"); } } Main.cullingMask = _savedMask | _bodyMask; ShowHead(show: true); Main.nearClipPlane = 0.05f; } private static void ShowHead(bool show) { //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Invalid comparison between Unknown and I4 //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Invalid comparison between Unknown and I4 //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) RigManager rig = Flat.Rig; if (show && (Object)(object)rig != (Object)null && (_headFor == (Object)null || ((Il2CppObjectBase)_headFor).Pointer != ((Il2CppObjectBase)rig).Pointer || _headAvatar != (((Object)(object)rig.avatar != (Object)null) ? ((Il2CppObjectBase)rig.avatar).Pointer : IntPtr.Zero))) { Restore(); _head.Clear(); _headFor = (Object)(object)rig; _headAvatar = (((Object)(object)rig.avatar != (Object)null) ? ((Il2CppObjectBase)rig.avatar).Pointer : IntPtr.Zero); List<Renderer> list = new List<Renderer>(); foreach (Renderer componentsInChild in ((Component)rig).GetComponentsInChildren<Renderer>(true)) { if ((Object)(object)componentsInChild != (Object)null && (int)componentsInChild.shadowCastingMode == 3) { list.Add(componentsInChild); } } foreach (Renderer r in list) { if (!_head.Exists(((Renderer r, bool en, int layer, ShadowCastingMode sh, bool off) h) => ((Il2CppObjectBase)h.r).Pointer == ((Il2CppObjectBase)r).Pointer)) { _head.Add((r, r.enabled, ((Component)r).gameObject.layer, r.shadowCastingMode, r.forceRenderingOff)); if (Prefs.Debug.Value) { Log.Msg($"[FlatPlayer] third person head part {((Object)r).name}: enabled {r.enabled} layer {((Component)r).gameObject.layer} shadows {r.shadowCastingMode} forceOff {r.forceRenderingOff}"); } } } } if (show) { _headShown = true; } if (show) { foreach (var item2 in _head) { Renderer item = item2.r; if (!((Object)(object)item == (Object)null)) { item.enabled = true; item.forceRenderingOff = false; if ((int)item.shadowCastingMode == 3) { item.shadowCastingMode = (ShadowCastingMode)1; } if (((1 << ((Component)item).gameObject.layer) & Main.cullingMask) == 0) { ((Component)item).gameObject.layer = 0; } } } return; } if (_headShown) { Restore(); _headShown = false; } } private static void Restore() { //IL_002a: 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_0055: Unknown result type (might be due to invalid IL or missing references) foreach (var (val, enabled, layer, shadowCastingMode, forceRenderingOff) in _head) { if (!((Object)(object)val == (Object)null)) { val.enabled = enabled; ((Component)val).gameObject.layer = layer; val.shadowCastingMode = shadowCastingMode; val.forceRenderingOff = forceRenderingOff; } } } private static void KeepBodyDrawn() { RigManager rig = Flat.Rig; Avatar val = ((rig != null) ? rig.avatar : null); if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).Pointer == _boundsFor) { return; } _boundsFor = ((Il2CppObjectBase)val).Pointer; int num = 0; foreach (SkinnedMeshRenderer componentsInChild in ((Component)Flat.Rig).GetComponentsInChildren<SkinnedMeshRenderer>(true)) { if ((Object)(object)componentsInChild != (Object)null && !componentsInChild.updateWhenOffscreen) { componentsInChild.updateWhenOffscreen = true; num++; } } Log.Msg($"[FlatPlayer] body stays drawn from any view ({num} body meshes)"); } private static void MakeProxy(Avatar av) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) _proxy = null; _realHead = null; Animator component = ((Component)av).GetComponent<Animator>(); if ((Object)(object)component == (Object)null) { return; } _realHead = component.GetBoneTransform((HumanBodyBones)10); if ((Object)(object)_realHead == (Object)null || (Object)(object)_realHead.parent == (Object)null) { return; } bool flag = false; if ((Object)(object)component.avatar != (Object)null) { foreach (SkeletonBone item in (Il2CppArrayBase<SkeletonBone>)(object)component.avatar.humanDescription.skeleton) { if (item.name == ((Object)_realHead).name) { _proxyRest = item.position; flag = true; break; } } } if (!flag) { return; } _proxy = new GameObject("FlatPlayer head").transform; _proxy.SetParent(_realHead.parent, false); _proxy.localPosition = _proxyRest; _proxy.localRotation = _realHead.localRotation; _proxy.localScale = _realHead.localScale; foreach (Renderer item2 in _ownHead) { SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((item2 is SkinnedMeshRenderer) ? item2 : null); if (val == null) { continue; } Il2CppReferenceArray<Transform> bones = val.bones; bool flag2 = false; for (int i = 0; i < ((Il2CppArrayBase<Transform>)(object)bones).Length; i++) { if ((Object)(object)((Il2CppArrayBase<Transform>)(object)bones)[i] != (Object)null && ((Il2CppObjectBase)((Il2CppArrayBase<Transform>)(object)bones)[i]).Pointer == ((Il2CppObjectBase)_realHead).Pointer) { ((Il2CppArrayBase<Transform>)(object)bones)[i] = _proxy; flag2 = true; } } if (flag2) { val.bones = bones; } if ((Object)(object)val.rootBone != (Object)null && ((Il2CppObjectBase)val.rootBone).Pointer == ((Il2CppObjectBase)_realHead).Pointer) { val.rootBone = _proxy; } } if (Prefs.Debug.Value) { Log.Msg($"[FlatPlayer] own head: stand-in head bone on {((Object)_realHead.parent).name} at {_proxyRest}"); } } private static void UpdateProxy() { //IL_0020: 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) if (!((Object)(object)_proxy == (Object)null) && !((Object)(object)_realHead == (Object)null)) { _proxy.localPosition = _proxyRest; _proxy.localRotation = _realHead.localRotation; } } public static void OwnHead() { //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) RigManager rig = Flat.Rig; Avatar val = ((rig != null) ? rig.avatar : null); if ((Object)(object)val == (Object)null) { return; } if (((Il2CppObjectBase)val).Pointer != _ownHeadAvatar) { _ownHeadAvatar = ((Il2CppObjectBase)val).Pointer; _ownHead.Clear(); if (((Object)val).name.StartsWith("Goku")) { foreach (SkinnedMeshRenderer componentsInChild in ((Component)val).GetComponentsInChildren<SkinnedMeshRenderer>(true)) { string text = (((Object)(object)((Renderer)componentsInChild).sharedMaterial != (Object)null) ? ((Object)((Renderer)componentsInChild).sharedMaterial).name.ToLowerInvariant() : ""); if (text.Contains("hair") || text.Contains("face") || text.Contains("shadeless") || text.Contains("shadless") || text.Contains("material_0")) { _ownHead.Add((Renderer)(object)componentsInChild); } } } if (_ownHead.Count > 0 && Prefs.Debug.Value) { Log.Msg($"[FlatPlayer] own head: {_ownHead.Count} parts on {((Object)val).name}"); } if (_ownHead.Count > 0) { MakeProxy(val); } else { _proxy = null; _realHead = null; } } UpdateProxy(); bool thirdPerson = ThirdPerson; if (Prefs.Debug.Value && (_headLogT -= Time.unscaledDeltaTime) <= 0f) { _headLogT = 2f; try { Animator component = ((Component)val).GetComponent<Animator>(); Transform val2 = (((Object)(object)component != (Object)null) ? component.GetBoneTransform((HumanBodyBones)10) : null); Transform val3 = (((Object)(object)component != (Object)null) ? component.GetBoneTransform((HumanBodyBones)9) : null); if ((Object)(object)val2 != (Object)null) { DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(78, 6); defaultInterpolatedStringHandler.AppendLiteral("[FlatPlayer] head bone local "); defaultInterpolatedStringHandler.AppendFormatted<Vector3>(val2.localPosition); defaultInterpolatedStringHandler.AppendLiteral(" scale "); defaultInterpolatedStringHandler.AppendFormatted<Vector3>(val2.localScale); defaultInterpolatedStringHandler.AppendLiteral(" parent "); Transform parent = val2.parent; defaultInterpolatedStringHandler.AppendFormatted((parent != null) ? ((Object)parent).name : null); defaultInterpolatedStringHandler.AppendLiteral(" dist-to-neck "); defaultInterpolatedStringHandler.AppendFormatted(((Object)(object)val3 != (Object)null) ? Vector3.Distance(val2.position, val3.position) : (-1f), "0.000"); defaultInterpolatedStringHandler.AppendLiteral(" world "); defaultInterpolatedStringHandler.AppendFormatted<Vector3>(val2.position); defaultInterpolatedStringHandler.AppendLiteral(" avatar root "); defaultInterpolatedStringHandler.AppendFormatted<Vector3>(((Component)val).transform.position); Log.Msg(defaultInterpolatedStringHandler.ToStringAndClear()); } } catch (Exception e) { Log.Once("head log", e); } } foreach (Renderer item in _ownHead) { if ((Object)(object)item != (Object)null && item.enabled != thirdPerson) { item.enabled = thirdPerson; } } } public static void HeadBack() { //IL_0145: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (!ThirdPerson) { return; } RigManager rig = Flat.Rig; Avatar val = ((rig != null) ? rig.avatar : null); if ((Object)(object)val == (Object)null) { return; } if (((Il2CppObjectBase)val).Pointer != _restFor) { _restFor = ((Il2CppObjectBase)val).Pointer; _haveRest = false; _headBone = null; Animator component = ((Component)val).GetComponent<Animator>(); _headBone = (((Object)(object)component != (Object)null) ? component.GetBoneTransform((HumanBodyBones)10) : null); if ((Object)(object)_headBone != (Object)null && (Object)(object)component.avatar != (Object)null) { foreach (SkeletonBone item in (Il2CppArrayBase<SkeletonBone>)(object)component.avatar.humanDescription.skeleton) { if (item.name == ((Object)_headBone).name) { _headRest = item.position; _haveRest = true; break; } } } if (Prefs.Debug.Value) { Log.Msg("[FlatPlayer] third person head rest " + (_haveRest ? ((object)Unsafe.As<Vector3, Vector3>(ref _headRest)/*cast due to .constrained prefix*/).ToString() : "unknown") + " for " + ((Object)val).name); } } if (_haveRest && (Object)(object)_headBone != (Object)null) { Vector3 val2 = _headBone.localPosition - _headRest; if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { _headBone.localPosition = _headRest; } } } private static Vector3 Steady(Vector3 target) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) float unscaledTime = Time.unscaledTime; float num = Mathf.Clamp(unscaledTime - _steadyLast, 0f, 0.1f); _steadyLast = unscaledTime; if (!Flat.StandingStill || ThirdPerson) { _steadyOn = false; SteadyOffset = Vector3.zero; return target; } if (_steadyOn) { Vector3 val = target - _steady; if (!(((Vector3)(ref val)).magnitude > 0.35f)) { Vector3 val2 = target - _steady; val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; float num2 = 0.5f + 30f * magnitude * magnitude; Vector3 val3 = val2 * Mathf.Clamp01(num2 * num); _steady = new Vector3(_steady.x + val3.x, target.y, _steady.z + val3.z); SteadyOffset = _steady - target; return _steady; } } _steadyOn = true; _steady = target; SteadyOffset = Vector3.zero; return target; } public static void FirstPerson() { if (_maskSaved && (Object)(object)Main != (Object)null) { Main.cullingMask = _savedMask; _maskSaved = false; } ShowHead(show: false); } private static float Fov() { return Mathf.Lerp(Prefs.Fov.Value, Prefs.AdsFov.Value, _ads * _ads * (3f - 2f * _ads)); } public static void DrawCrosshair() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_00a3: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_dot == (Object)null) { _dot = new Texture2D(1, 1); _dot.SetPixel(0, 0, Color.white); _dot.Apply(); ((Object)_dot).hideFlags = (HideFlags)32; } if (Flat.PadCursor) { Vector2 menuCursor = Flat.MenuCursor; float num = (float)Screen.height - menuCursor.y; Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.7f); GUI.DrawTexture(new Rect(menuCursor.x - 7f, num - 7f, 14f, 14f), (Texture)(object)_dot); GUI.color = new Color(1f, 0.75f, 0.2f, 1f); GUI.DrawTexture(new Rect(menuCursor.x - 5f, num - 5f, 10f, 10f), (Texture)(object)_dot); GUI.color = color; } else { if (!Prefs.Crosshair.Value || (Object)(object)Main == (Object)null || Flat.MenuOpen) { return; } float num2 = 1f - Mathf.Clamp01(_ads * 1.4f); if (!(num2 <= 0.01f)) { float num3 = Mathf.Round((float)Screen.width / 2f); float num4 = Mathf.Round((float)Screen.height / 2f); float num5 = Mathf.Max(1f, (float)Screen.height / 1080f); _spread = Mathf.Lerp(_spread, Flat.Walk, Time.unscaledDeltaTime * 10f); float num6 = Mathf.Round((7f + 14f * _spread) * num5); float num7 = Mathf.Round(10f * num5); float num8 = Mathf.Max(2f, Mathf.Round(2f * num5)); Color color2 = GUI.color; for (int i = 0; i < 2; i++) { float num9 = ((i == 0) ? 1f : 0f); GUI.color = ((i == 0) ? new Color(0f, 0f, 0f, 0.55f * num2) : new Color(1f, 1f, 1f, 0.9f * num2)); GUI.DrawTexture(new Rect(num3 - num8 / 2f - num9, num4 - num6 - num7 - num9, num8 + 2f * num9, num7 + 2f * num9), (Texture)(object)_dot); GUI.DrawTexture(new Rect(num3 - num8 / 2f - num9, num4 + num6 - num9, num8 + 2f * num9, num7 + 2f * num9), (Texture)(object)_dot); GUI.DrawTexture(new Rect(num3 - num6 - num7 - num9, num4 - num8 / 2f - num9, num7 + 2f * num9, num8 + 2f * num9), (Texture)(object)_dot); GUI.DrawTexture(new Rect(num3 + num6 - num9, num4 - num8 / 2f - num9, num7 + 2f * num9, num8 + 2f * num9), (Texture)(object)_dot); GUI.DrawTexture(new Rect(num3 - 1f - num9, num4 - 1f - num9, 2f + 2f * num9, 2f + 2f * num9), (Texture)(object)_dot); } GUI.color = color2; } } } } public class Pad { public Vector3 Pos; public Quaternion Rot = Quaternion.identity; public Vector2 Stick; public bool StickClick; public float Trigger; public float Grip; public bool A; public bool B; public bool Menu; private bool _pStick; private bool _pTrig; private bool _pGrip; private bool _pA; private bool _pB; private bool _pMenu; public void Write(XRController c) { //IL_001d: 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_0040: Unknown result type (might be due to invalid IL or missing references) if (c != null) { WritePose((XRDevice)(object)c, Pos, Rot); c._Type_k__BackingField = (XRControllerType)0; c._Joystick2DAxis_k__BackingField = Stick; c._JoystickTouch_k__BackingField = ((Vector2)(ref Stick)).sqrMagnitude > 0.0001f || StickClick; Btn(StickClick, ref _pStick, delegate(bool v) { c._JoystickButton_k__BackingField = v; }, delegate(bool v) { c._JoystickButtonDown_k__BackingField = v; }, delegate(bool v) { c._JoystickButtonUp_k__BackingField = v; }); c._Trigger_k__BackingField = Trigger; c._TriggerForce_k__BackingField = Trigger; c._TriggerTouched_k__BackingField = Trigger > 0.01f; Btn(Trigger > 0.5f, ref _pTrig, delegate(bool v) { c._TriggerButton_k__BackingField = v; }, delegate(bool v) { c._TriggerButtonDown_k__BackingField = v; }, delegate(bool v) { c._TriggerButtonUp_k__BackingField = v; }); c._Grip_k__BackingField = Grip; c._GripForce_k__BackingField = Grip; c._GripVelocity_k__BackingField = 0f; Btn(Grip > 0.5f, ref _pGrip, delegate(bool v) { c._GripButton_k__BackingField = v; }, delegate(bool v) { c._GripButtonDown_k__BackingField = v; }, delegate(bool v) { c._GripButtonUp_k__BackingField = v; }); Btn(A, ref _pA, delegate(bool v) { c._AButton_k__BackingField = v; }, delegate(bool v) { c._AButtonDown_k__BackingField = v; }, delegate(bool v) { c._AButtonUp_k__BackingField = v; }); Btn(B, ref _pB, delegate(bool v) { c._BButton_k__BackingField = v; }, delegate(bool v) { c._BButtonDown_k__BackingField = v; }, delegate(bool v) { c._BButtonUp_k__BackingField = v; }); Btn(Menu, ref _pMenu, delegate(bool v) { c._MenuButton_k__BackingField = v; }, delegate(bool v) { c._MenuButtonDown_k__BackingField = v; }, delegate(bool v) { c._MenuButtonUp_k__BackingField = v; }); c._ATouch_k__BackingField = A; c._BTouch_k__BackingField = B; c._IndexFinger_k__BackingField = Trigger; c._MiddleFinger_k__BackingField = Grip; c._RingFinger_k__BackingField = Grip; c._PinkyFinger_k__BackingField = Grip; c._ThumbFinger_k__BackingField = ((Grip > 0.5f || A || B) ? 1f : 0f); } } private static void Btn(bool now, ref bool prev, Action<bool> held, Action<bool> down, Action<bool> up) { held(now); down(now && !prev); up(!now & prev); prev = now; } public static bool Valid(Vector3 v) { //IL_0000: 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_001a: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!float.IsNaN(v.x) && !float.IsNaN(v.y) && !float.IsNaN(v.z) && !float.IsInfinity(v.x) && !float.IsInfinity(v.y)) { return !float.IsInfinity(v.z); } return false; } public static bool Valid(Quaternion q) { //IL_0000: 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_001a: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005d: 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) if (!float.IsNaN(q.x) && !float.IsNaN(q.y) && !float.IsNaN(q.z) && !float.IsNaN(q.w)) { return Mathf.Abs(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w - 1f) < 0.1f; } return false; } public static void WritePose(XRDevice d, Vector3 p, Quaternion r) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_005e: Unknown result type (might be due to invalid IL or missing references) d._IsConnected_k__BackingField = true; d._IsTracking_k__BackingField = true; if (!Valid(p) || !Valid(r)) { p = Vector3.up * 1.6f; r = Quaternion.identity; } d._lastPosition = p; d._lastRotation = r; d._Position_k__BackingField = p; d._Rotation_k__BackingField = r; d._Velocity_k__BackingField = Vector3.zero; d._AngularVelocity_k__BackingField = Vector3.zero; d._UpdateTime_k__BackingField = Time.timeAsDouble + 1.0; d._lastUpdateTime = Time.timeAsDouble - 1.0; } } public static class Devices { public static readonly Pad Left = new Pad(); public static readonly Pad Right = new Pad(); public static Vector3 HeadPos = new Vector3(0f, 1.7f, 0f); public static Quaternion HeadRot = Quaternion.identity; private static bool _logged; private static bool _in; public static void Write(XRApi xr) { if (xr == null || _in) { return; } _in = true; try { WriteInner(xr); } finally { _in = false; } } private static void WriteInner(XRApi xr) { //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) if (xr.LeftController != null) { VTable.Apply(xr); } if (xr.HMD != null) { Pad.WritePose((XRDevice)(object)xr.HMD, HeadPos, HeadRot); } Left.Write(xr.LeftController); Right.Write(xr.RightController); if (!_logged) { _logged = true; Log.Msg("[FlatPlayer] fake headset + controllers are live"); } } } [HarmonyPatch(typeof(XRApi), "OnPostNewInputUpdate")] internal static class XRApiPostInputPatch { private static void Postfix(XRApi __instance) { if (!Prefs.On) { return; } try { Devices.Write(__instance); } catch (Exception e) { Log.Once("devices", e); } } } public static class VTable { private const int GetIsConnected = 440; private const int GetIsTracking = 472; private static bool _done; public static void Apply(XRApi xr) { if (_done) { return; } _done = true; HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); XRDevice[] array = (XRDevice[])(object)new XRDevice[3] { (XRDevice)xr.HMD, (XRDevice)xr.LeftController, (XRDevice)xr.RightController }; foreach (XRDevice val in array) { if (val != null) { IntPtr intPtr = IL2CPP.il2cpp_object_get_class(((Il2CppObjectBase)val).Pointer); if (hashSet.Add(intPtr)) { Swap(intPtr, ((Object)val).GetIl2CppType().FullName); } } } } private unsafe static void Swap(IntPtr klass, string name) { if (klass == IntPtr.Zero) { Log.Msg("[FlatPlayer] no class pointer for " + name); return; } byte* ptr = (byte*)(void*)klass; if (*(IntPtr*)(ptr + 472) == IntPtr.Zero) { Log.Msg("[FlatPlayer] " + name + " vtable not ready"); _done = false; } else { *(IntPtr*)(ptr + 440) = *(IntPtr*)(ptr + 472); *(IntPtr*)(ptr + 440 + 8) = *(IntPtr*)(ptr + 472 + 8); Log.Msg("[FlatPlayer] " + name + ".IsConnected now follows IsTracking"); } } } [HarmonyPatch(typeof(OpenControllerRig), "OnEarlyUpdate")] internal static class HeadsetPosePatch { private static bool _unpaused; private static void Prefix(OpenControllerRig __instance) { if (!Prefs.On) { return; } try { if (float.IsNaN(__instance._adaptiveY) || float.IsInfinity(__instance._adaptiveY)) { __instance._adaptiveY = 0f; } } catch { } ForceTracked(__instance); } private static void Postfix(OpenControllerRig __instance) { //IL_0023: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.On) { return; } ForceTracked(__instance); try { Transform headset = __instance.headset; if ((Object)(object)headset == (Object)null || !Pad.Valid(Devices.HeadPos) || !Pad.Valid(Devices.HeadRot)) { return; } headset.SetLocalPositionAndRotation(Devices.HeadPos, Devices.HeadRot); Transform parent = headset.parent; if ((Object)(object)parent == (Object)null || !Pad.Valid(Devices.Left.Pos) || !Pad.Valid(Devices.Right.Pos) || !Pad.Valid(Devices.Left.Rot) || !Pad.Valid(Devices.Right.Rot) || !Pad.Valid(parent.position)) { return; } if ((Object)(object)((ControllerRig)__instance).leftController != (Object)null) { ((Component)((ControllerRig)__instance).leftController).transform.SetPositionAndRotation(parent.TransformPoint(Devices.Left.Pos), parent.rotation * Devices.Left.Rot); } if ((Object)(object)((ControllerRig)__instance).rightController != (Object)null) { ((Component)((ControllerRig)__instance).rightController).transform.SetPositionAndRotation(parent.TransformPoint(Devices.Right.Pos), parent.rotation * Devices.Right.Rot); } } catch (Exception e) { Log.Once("headset", e); } try { if (((ControllerRig)__instance).IsPaused) { ((ControllerRig)__instance).IsPaused = false; AudioListener.pause = false; if (!_unpaused) { _unpaused = true; Log.Msg("[FlatPlayer] undid the headset-off pause"); OpenControllerRig.OnPauseStateChange?.Invoke(false); } } } catch (Exception e2) { Log.Once("unpause", e2); } } private static void ForceTracked(OpenControllerRig r) { try { r._contLfState = (TrackedState)1; r._contRtState = (TrackedState)1; r._contLfBlend = 1f; r._contRtBlend = 1f; } catch (Exception e) { Log.Once("tracked", e); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class UserPresentPatch { private static void Postfix(ref bool __result) { if (Prefs.On) { __result = true; } } } [HarmonyPatch(typeof(OpenControllerRig), "OnBeginCameraRendering")] internal static class CameraRenderPatch { private static bool _said; private static void Postfix(Camera cam) { if (!Prefs.On || (Object)(object)cam == (Object)null || (Object)(object)Cameras.Main == (Object)null || ((Il2CppObjectBase)cam).Pointer != ((Il2CppObjectBase)Cameras.Main).Pointer) { return; } try { if (!_said) { _said = true; Log.Msg("[FlatPlayer] rig render hook reached the monitor camera"); } Cameras.Follow(); } catch (Exception e) { Log.Once("render", e); } } } [HarmonyPatch(typeof(Player_Health), "Death")] internal static class DeathLog { private static void Prefix(Player_Health __instance) { if (!Prefs.Debug.Value) { return; } try { DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(35, 2); defaultInterpolatedStringHandler.AppendLiteral("[FlatPlayer] DEATH: health "); defaultInterpolatedStringHandler.AppendFormatted(((Health)__instance).curr_Health, "0.0"); defaultInterpolatedStringHandler.AppendLiteral(" held R "); RigManager rig = Flat.Rig; object obj; if (rig == null) { obj = null; } else { PhysicsRig physicsRig = rig.physicsRig; if (physicsRig == null) { obj = null; } else { Hand rightHand = physicsRig.rightHand; if (rightHand == null) { obj = null; } else { GameObject currentAttachedGO = rightHand.m_CurrentAttachedGO; obj = ((currentAttachedGO != null) ? ((Object)currentAttachedGO).name : null); } } } if (obj == null) { obj = "-"; } defaultInterpolatedStringHandler.AppendFormatted((string?)obj); Log.Msg(defaultInterpolatedStringHandler.ToStringAndClear()); } catch { } } } public static class GunAnim { private static Vector2 _sway; private static float _kick; private static float _kickSide; private static float _reloadT = -1f; private static float _idleT; public static bool Reloading => _reloadT >= 0f; public static bool Busy { get { if (Prefs.GunAnims.Value) { if (!(_reloadT >= 0f)) { return _kick > 0.05f; } return true; } return false; } } public static void Kick() { if (Prefs.GunAnims.Value) { _kick = Mathf.Min(_kick + 0.9f, 1.6f); _kickSide = Random.Range(-1f, 1f); } } public static void Reload() { if (Prefs.GunAnims.Value) { _reloadT = 0f; } } public static void Update(float dt, Vector2 lookDeg) { //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_0033: 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_003f: 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_004e: 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_0068: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.GunAnims.Value || dt <= 0f) { _sway = Vector2.zero; _kick = 0f; _reloadT = -1f; return; } Vector2 val = Vector2.ClampMagnitude(lookDeg / dt / 900f, 1f); if (((Vector2)(ref val)).magnitude < 0.08f) { val = Vector2.zero; } _sway = Vector2.Lerp(_sway, val, Mathf.Clamp01(dt * 4f)); _kick = Mathf.MoveTowards(_kick, 0f, dt * (3f + _kick * 4f)); if (_reloadT >= 0f) { _reloadT += dt / 0.75f; if (_reloadT >= 1f) { _reloadT = -1f; } } _idleT += dt; } public static float Apply(ref Vector3 muzzle, ref Vector3 aimDir, Vector3 right, Vector3 up, Vector3 fwd, float ads, float walk) { //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_002e: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_019e: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.GunAnims.Value) { return 0f; } float num = 1f - Mathf.Clamp01(ads * 1.5f); muzzle += (-right * _sway.x * 0.025f - up * _sway.y * 0.02f) * num; float num2 = (0f - _sway.x) * 6f * num; float num3 = _kick * Mathf.Lerp(1f, 0.55f, ads); muzzle += -fwd * 0.04f * num3 + up * 0.01f * num3; aimDir = Quaternion.AngleAxis(-5f * num3, right) * Quaternion.AngleAxis(_kickSide * 1.5f * num3, up) * aimDir; if (_reloadT >= 0f) { float num4 = Mathf.Sin((float)Math.PI * _reloadT); muzzle += (-up * 0.09f - right * 0.04f - fwd * 0.06f) * num4; aimDir = Quaternion.AngleAxis(28f * num4, right) * Quaternion.AngleAxis(-25f * num4, up) * aimDir; num2 += 40f * num4; } ((Vector3)(ref aimDir)).Normalize(); return num2; } } [HarmonyPatch(typeof(Gun), "OnFire")] internal static class GunFirePatch { private static void Postfix(Gun __instance) { try { if (Prefs.On && (Object)(object)Flat.HeldGun != (Object)null && (Object)(object)__instance != (Object)null && ((Il2CppObjectBase)__instance).Pointer == ((Il2CppObjectBase)Flat.HeldGun).Pointer) { GunAnim.Kick(); } } catch { } } } [HarmonyPatch(typeof(PopUpMenuView), "Deactivate")] internal static class MenuLockPatch { private static bool Prefix() { if (!Prefs.On || !Prefs.MenuLock.Value || (Object)(object)Flat.Rig == (Object)null || Flat.Loading) { return true; } if (MenuLock.Allowed) { return true; } MenuLock.Blocked++; return false; } } public static class MenuLock { private static float _allowUntil; public static int Blocked; public static bool Allowed => Time.unscaledTime < _allowUntil; public static void Allow(float seconds = 0.4f) { _allowUntil = Time.unscaledTime + seconds; } } public static class AntiFling { private static float _t; private static readonly List<Rigidbody> _bodies = new List<Rigidbody>(); private static IntPtr _for; public static void Guard(float seconds) { _t = Mathf.Max(_t, seconds); } public static void Cancel() { _t = 0f; } public static List<Rigidbody> Bodies(RigManager rig) { PhysicsRig val = ((rig != null) ? rig.physicsRig : null); if ((Object)(object)val == (Object)null) { _bodies.Clear(); return _bodies; } if (_for != ((Il2CppObjectBase)val).Pointer || _bodies.Count == 0) { _for = ((Il2CppObjectBase)val).Pointer; _bodies.Clear(); foreach (Rigidbody componentsInChild in ((Component)val).GetComponentsInChildren<Rigidbody>()) { if ((Object)(object)componentsInChild != (Object)null && !componentsInChild.isKinematic) { _bodies.Add(componentsInChild); } } } return _bodies; } public static void Update(RigManager rig, float dt) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (_t <= 0f || (Object)(object)rig == (Object)null) { return; } _t -= dt; int num = 0; Vector3 val = default(Vector3); foreach (Rigidbody item in Bodies(rig)) { if (!((Object)(object)item == (Object)null)) { Vector3 velocity = item.velocity; ((Vector3)(ref val))..ctor(velocity.x, 0f, velocity.z); bool flag = false; if (((Vector3)(ref val)).magnitude > 6f) { val = ((Vector3)(ref val)).normalized * 3f; flag = true; } float num2 = velocity.y; if (num2 > 4.5f) { num2 = 0.5f; flag = true; } if (float.IsNaN(velocity.x)) { val = Vector3.zero; num2 = 0f; flag = true; } if (flag) { item.velocity = new Vector3(val.x, num2, val.z); item.angularVelocity = Vector3.zero; num++; } } } if (num > 0 && Prefs.Debug.Value) { Log.Msg($"[FlatPlayer] anti-fling slowed {num} body parts"); } } } public static class Movement { private static float _slideT; private static float _dashCd; private static float _mantleCd; private static float _slideCd; private static Vector3 _slideDir; public static float SincePush = 9f; public static bool Sliding => _slideT > 0f; private static bool Grounded(RigManager rig, out Vector3 pelvis) { //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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) pelvis = Vector3.zero; object obj; if (rig == null) { obj = null; } else { PhysicsRig physicsRig = rig.physicsRig; obj = ((physicsRig != null) ? ((Rig)physicsRig).m_pelvis : null); } Transform val = (Transform)obj; if ((Object)(object)val == (Object)null) { return false; } pelvis = val.position; foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(pelvis, Vector3.down, 1.4f, -1, (QueryTriggerInteraction)1)) { RaycastHit current = item; if (!Flat.IsPlayer(((RaycastHit)(ref current)).collider)) { return true; } } return false; } private static void Push(RigManager rig, Vector3 dv) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) SincePush = 0f; foreach (Rigidbody item in AntiFling.Bodies(rig)) { if ((Object)(object)item != (Object)null) { item.AddForce(dv, (ForceMode)2); } } } public static void Update(RigManager rig, float dt, Vector3 moveDir, Vector3 viewFwd, bool sprinting, bool crouchPressed, bool dashPressed, bool jumpHeld) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_014d: 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_01d8: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0303: 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) if (!Prefs.Movement.Value || (Object)(object)rig == (Object)null || dt <= 0f) { _slideT = 0f; return; } _dashCd -= dt; _mantleCd -= dt; _slideCd -= dt; SincePush += dt; Vector3 pelvis; bool flag = Grounded(rig, out pelvis); if (crouchPressed && sprinting && flag && _slideCd <= 0f && ((Vector3)(ref moveDir)).sqrMagnitude > 0.25f) { _slideDir = ((Vector3)(ref moveDir)).normalized; _slideT = 0.75f; _slideCd = 1.2f; AntiFling.Cancel(); Push(rig, _slideDir * 3.2f); Log.Msg("[FlatPlayer] slide"); } if (_slideT > 0f) { _slideT -= dt; if (flag) { Push(rig, _slideDir * 7f * dt * Mathf.Clamp01(_slideT / 0.75f)); } } Vector3 val; if (dashPressed && _dashCd <= 0f) { Vector3 normalized; if (!(((Vector3)(ref moveDir)).sqrMagnitude > 0.04f)) { val = new Vector3(viewFwd.x, 0f, viewFwd.z); normalized = ((Vector3)(ref val)).normalized; } else { normalized = ((Vector3)(ref moveDir)).normalized; } Vector3 val2 = normalized; AntiFling.Cancel(); Push(rig, val2 * (flag ? 5.5f : 3.5f) + Vector3.up * (flag ? 0.8f : 0f)); _dashCd = 1f; Log.Msg("[FlatPlayer] dash"); } if (jumpHeld && _mantleCd <= 0f && ((Vector3)(ref moveDir)).sqrMagnitude > 0.1f) { val = new Vector3(viewFwd.x, 0f, viewFwd.z); Vector3 normalized2 = ((Vector3)(ref val)).normalized; Vector3 val3 = pelvis + Vector3.up * 0.35f; Vector3 val4 = pelvis + Vector3.up * 0.95f; RaycastHit hit; bool num = HitWorld(val3, normalized2, 0.75f, out hit); RaycastHit hit2; bool flag2 = !HitWorld(val4, normalized2, 0.9f, out hit2); if (num && flag2 && HitWorld(((RaycastHit)(ref hit)).point + normalized2 * 0.25f + Vector3.up * 1.2f, Vector3.down, 1.3f, out var hit3) && ((RaycastHit)(ref hit3)).point.y > pelvis.y - 0.4f) { float num2 = ((RaycastHit)(ref hit3)).point.y - pelvis.y + 1f; Push(rig, Vector3.up * Mathf.Clamp(Mathf.Sqrt(19.62f * Mathf.Max(num2, 0.3f)), 3f, 6.5f) + normalized2 * 1.5f); _mantleCd = 0.9f; AntiFling.Cancel(); Log.Msg("[FlatPlayer] mantle"); } } } private static bool HitWorld(Vector3 from, Vector3 dir, float dist, out RaycastHit hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) hit = default(RaycastHit); float num = float.MaxValue; bool result = false; foreach (RaycastHit item in (Il2CppArrayBase<RaycastHit>)(object)Physics.RaycastAll(from, dir, dist, -1, (QueryTriggerInteraction)1)) { RaycastHit current = item; if (!Flat.IsPlayer(((RaycastHit)(ref current)).collider) && (!((Object)(object)((RaycastHit)(ref current)).rigidbody != (Object)null) || ((RaycastHit)(ref current)).rigidbody.isKinematic || !(((RaycastHit)(ref current)).rigidbody.mass < 40f)) && ((RaycastHit)(ref current)).distance < num) { num = ((RaycastHit)(ref current)).distance; hit = current; result = true; } } return result; } } public static class HeldNoCollide { private static IntPtr _gun; private static List<(Collider a, Collider b)> _pairs = new List<(Collider, Collider)>(); private static List<(Collider a, Collider b)> _old = new List<(Collider, Collider)>(); private static float _oldT; private static readonly HashSet<IntPtr> _heldCols = new HashSet<IntPtr>(); public static bool Holds(Collider c) { if ((Object)(object)c != (Object)null) { return _heldCols.Contains(((Il2CppObjectBase)c).Pointer); } return false; } public static void Update(RigManager rig, Gun gun) { if (_old.Count > 0 && (_oldT -= Time.deltaTime) <= 0f) { Restore(_old, keepHeld: true); } IntPtr intPtr = (((Object)(object)gun != (Object)null) ? ((Il2CppObjectBase)gun).Pointer : IntPtr.Zero); if (intPtr == _gun) { return; } if (_pairs.Count > 0) { Restore(_old); _old = _pairs; _pairs = new List<(Collider, Collider)>(); _oldT = 2f; } _gun = intPtr; _heldCols.Clear(); if ((Object)(object)gun == (Object)null || (Object)(object)((rig != null) ? rig.physicsRig : null) == (Object)null) { return; } try { MarrowEntity componentInParent = ((Component)gun).GetComponentInParent<MarrowEntity>(); GameObject val = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)gun).gameObject); List<Collider> list = new List<Collider>(); foreach (Collider componentsInChild in ((Component)rig).GetComponentsInChildren<Collider>(true)) { if ((Object)(object)componentsInChild != (Object)null && !componentsInChild.isTrigger && !((Component)componentsInChild).transform.IsChildOf(val.transform)) { list.Add(componentsInChild); } } InventorySlotReceiver[] array = Slots.All(rig); foreach (InventorySlotReceiver val2 in array) { WeaponSlot val3 = (((Object)(object)val2 != (Object)null) ? val2._slottedWeapon : null); if ((Object)(object)val3 == (Object)null) { continue; } MarrowEntity componentInParent2 = ((Component)val3).GetComponentInParent<MarrowEntity>(); if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent != (Object)null && ((Il2CppObjectBase)componentInParent2).Pointer == ((Il2CppObjectBase)componentInParent).Pointer) { continue; } foreach (Collider componentsInChild2 in (((Object)(object)componentInParent2 != (Object)null) ? ((Component)componentInParent2).gameObject : ((Component)val3).gameObject).GetComponentsInChildren<Collider>()) { if ((Object)(object)componentsInChild2 != (Object)null && !componentsInChild2.isTrigger) { list.Add(componentsInChild2); } } } foreach (Collider componentsInChild3 in val.GetComponentsInChildren<Collider>()) { if ((Object)(object)componentsInChild3 == (Object)null || componentsInChild3.isTrigger) { continue; } _heldCols.Add(((Il2CppObjectBase)componentsInChild3).Pointer); foreach (Collider item in list) { Physics.IgnoreCollision(componentsInChild3, item, true); _pairs.Add((componentsInChild3, item)); } } Log.Msg($"[FlatPlayer] {((Object)gun).name}: your body no longer bumps it ({_pairs.Count} pairs)"); } catch (Exception e) { Log.Once("held no collide", e); } } private static void Restore(List<(Collider a, Collider b)> list, bool keepHeld = false) { HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); if (keepHeld) { hashSet.UnionWith(_heldCols); } foreach (var (val, val2) in list) { try { if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null && !hashSet.Contains(((Il2CppObjectBase)val).Pointer) && !Slots.IsSlotted(val) && !Slots.IsSlotted(val2)) { Physics.IgnoreCollision(val, val2, false); } } catch { } } list.Clear(); } } public static class Plant { private static bool _on; private static Vector3 _anchor; private static float _idleT; public static Vector3 LastPush; private static readonly List<Rigidbody> _core = new List<Rigidbody>(); private static IntPtr _coreFor; public static bool On => _on; public static Vector3 Anchor => _anchor; public static void Update(RigManager rig, float dt, bool idle) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0084: 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_0073: 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_00a0: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f9: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to