Decompiled source of blue0k37 Functional Avatar v1.2.0
Mods/blue0k37FunctionalAvatar.dll
Decompiled a day 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Blue0k37; using BoneLib; using BoneLib.BoneMenu; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Combat; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Audio; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.PuppetMasta; using Il2CppSLZ.Marrow.Warehouse; using Il2CppSLZ.VRMK; using Il2CppSystem; using Il2CppTMPro; using LabFusion.Entities; using LabFusion.Marrow.Extenders; using LabFusion.Network; using LabFusion.Network.Serialization; using LabFusion.Player; using LabFusion.RPC; using LabFusion.SDK.Modules; using LabFusion.Senders; using MelonLoader; using MelonLoader.Preferences; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Blue0k37Mod), "blue0k37 Functional Avatar", "1.2.0", "blue0k37", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: MelonOptionalDependencies(new string[] { "LabFusion" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("blue0k37FunctionalAvatar")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("blue0k37FunctionalAvatar")] [assembly: AssemblyTitle("blue0k37FunctionalAvatar")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int version) { Version = version; } } } namespace Blue0k37 { public class Blue0k37Mod : MelonMod { public const string SwordBarcode = "blue0k37.blue0k37FunctionalAvatar.Spawnable.blue0k37Sword"; public const string AvatarMatch = "blue0k37"; public const string SwordName = "blue0k37_Sword"; private const float SpeedMult = 2.5f; private const float StrengthUpperMult = 20f; private const float StrengthLowerMult = 20f; private const float AgilityMult = 4f; private const float VitalityMult = 4.5f; private const float MyHandNearDistance = 0.35f; private const float StealConfirmSeconds = 0.15f; private const float StealRespawnInterval = 1.5f; private const float DefaultStabDamage = 2.5f; private const float DefaultSlashDamage = 2f; private const float DefaultSwordMass = 1.9f; private const float DefaultBluntMult = 1f; internal static MelonPreferences_Category Cat; internal static MelonPreferences_Entry<bool> SwordEnabled; internal static MelonPreferences_Entry<float> SwordX; internal static MelonPreferences_Entry<float> SwordY; internal static MelonPreferences_Entry<float> SwordZ; internal static MelonPreferences_Entry<float> SwordTilt; internal static MelonPreferences_Entry<float> SwordReturnDelay; internal static MelonPreferences_Entry<bool> SwordReturnAnim; internal static MelonPreferences_Entry<float> SwordReturnAnimTime; internal static MelonPreferences_Entry<bool> SwordOwnerOnlyDraw; internal static MelonPreferences_Entry<float> SwordStabDamage; internal static MelonPreferences_Entry<float> SwordSlashDamage; internal static MelonPreferences_Entry<float> SwordMass; internal static MelonPreferences_Entry<float> SwordBluntMult; internal static MelonPreferences_Entry<float> SwordHipSnap; private static GameObject _sword; private static Rigidbody[] _swordRbs; private static InteractableHost _swordHost; private static bool _spawning; private static bool _wantSword; private static bool _holstered; private static float _nextSpawnTime; private static float _spawnStartTime; private static PhysicsRig _ignoredRig; private static float _nextAvatarCheck; private static float _nextScan; private static float _nextExtraScan; private static float _releaseTime = -1f; private static WeaponSlot _swordSlot; private static Collider[] _swordCols; private static InventorySlotReceiver[] _rigReceivers; private static PhysicsRig _receiversRig; private static bool _returning; private static float _returnStart; private static float _returnDur; private static Vector3 _returnFromPos; private static Quaternion _returnFromRot; private static bool _physReturn; private static bool[] _returnGrav; private static float[] _returnMaxAng; private static bool _swordNetworked; private static float _nextOwnLog; private static float _stealSince = -1f; private static float _nextStealRespawn; private static float _nextOwnReq; private static float _nextOwnReqLog; private static Collider[] _swordSolidCols; private static int _lastSentHolster = -1; private static float _nextStateSend; private const float HipSnapWindow = 0.6f; internal const int SwordSolidLayer = 10; private static FloatElement _stabEl; private static FloatElement _slashEl; private static FloatElement _massEl; private static FloatElement _bluntEl; internal static GameObject MySwordObject => _sword; internal static GameObject CurrentSword => _sword; public override void OnInitializeMelon() { Cat = MelonPreferences.CreateCategory("blue0k37Sword", "blue0k37 Functional Avatar - Sword"); SwordEnabled = Cat.CreateEntry<bool>("Enabled", true, "Sword enabled", "Attach sword to left hip when wearing the blue0k37 avatar", false, false, (ValueValidator)null, (string)null); SwordX = Cat.CreateEntry<float>("OffsetX", -0.27f, "Offset X", "Left/right from pelvis (negative = left, positive = right)", false, false, (ValueValidator)null, (string)null); SwordY = Cat.CreateEntry<float>("OffsetY", -0.02f, "Offset Y", "Up/down from pelvis", false, false, (ValueValidator)null, (string)null); SwordZ = Cat.CreateEntry<float>("OffsetZ", 0.1f, "Offset Z", "Forward/back from pelvis (positive = forward)", false, false, (ValueValidator)null, (string)null); SwordTilt = Cat.CreateEntry<float>("Tilt", 30f, "Tilt", "Handle tilt up, degrees", false, false, (ValueValidator)null, (string)null); SwordReturnDelay = Cat.CreateEntry<float>("ReturnDelay", 5f, "Return delay", "Seconds before a dropped sword returns to the hip", false, false, (ValueValidator)null, (string)null); SwordReturnAnim = Cat.CreateEntry<bool>("ReturnAnimation", true, "Return animation", "Sword flies back to the hip instead of teleporting", false, false, (ValueValidator)null, (string)null); SwordReturnAnimTime = Cat.CreateEntry<float>("ReturnAnimationTime", 0.6f, "Return animation time", "Seconds the fly-back takes", false, false, (ValueValidator)null, (string)null); SwordOwnerOnlyDraw = Cat.CreateEntry<bool>("OwnerOnlyDraw", true, "Only I can draw", "Multiplayer: if another player grabs the sword from your hip, it is taken back to your hip", false, false, (ValueValidator)null, (string)null); SwordStabDamage = Cat.CreateEntry<float>("StabDamage", 2.5f, "Stab damage", "Damage of the sword tip (stab)", false, false, (ValueValidator)null, (string)null); SwordSlashDamage = Cat.CreateEntry<float>("SlashDamage", 2f, "Slash damage", "Damage of the sword edges (slash)", false, false, (ValueValidator)null, (string)null); SwordMass = Cat.CreateEntry<float>("Mass", 1.9f, "Weight (kg)", "Sword weight. Heavier hits harder but swings slower", false, false, (ValueValidator)null, (string)null); SwordBluntMult = Cat.CreateEntry<float>("BluntMult", 1f, "Blunt damage mult", "Damage multiplier when hitting with the flat/handle", false, false, (ValueValidator)null, (string)null); SwordHipSnap = Cat.CreateEntry<float>("HipSnapDistance", 0.3f, "Hip snap distance", "Let go of the sword within this distance (m) of its hip spot and it goes straight back to the hip (0 = off)", false, false, (ValueValidator)null, (string)null); Cat.SaveToFile(false); Dropkick.Init(); Jump.Init(); Railgun.Init(); WeaponWheel.Init(); FingerGesture.Init(); FistPower.Init(); FusionRailgun.TryRegister(); FusionSwordNet.TryRegister(); BuildMenu(); Hooking.OnSwitchAvatarPostfix += OnAvatarSwitched; Hooking.OnLevelUnloaded += OnLevelUnloaded; ((MelonBase)this).LoggerInstance.Msg("loaded"); } internal static void DLog(string s) { try { if (Dropkick.DebugLog != null && Dropkick.DebugLog.Value) { Melon<Blue0k37Mod>.Logger.Msg(s); } } catch { } } internal static PhysicsRig GetPhysRig() { try { RigManager rigManager = Player.RigManager; if ((Object)(object)rigManager == (Object)null) { return null; } return rigManager.physicsRig; } catch { return null; } } internal static bool IsTarget(Avatar avatar) { if ((Object)(object)avatar == (Object)null) { return false; } string name = ((Object)((Component)avatar).gameObject).name; if (name != null) { return name.IndexOf("blue0k37", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } internal static void ApplyStats(Avatar a) { if (IsTarget(a)) { a._speed *= 2.5f; a._strengthUpper *= 20f; a._strengthLower *= 20f; a._agility *= 4f; a._vitality *= 4.5f; } } private static void OnAvatarSwitched(Avatar avatar) { try { if ((Object)(object)Player.RigManager == (Object)null || (Object)(object)avatar == (Object)null || (Object)(object)Player.Avatar == (Object)null || ((Il2CppObjectBase)Player.Avatar).Pointer != ((Il2CppObjectBase)avatar).Pointer) { return; } } catch { return; } _wantSword = SwordEnabled.Value && IsTarget(avatar); if (!_wantSword) { DespawnSword(); } if (!IsTarget(avatar)) { Dropkick.ForceStandUp(); } _ignoredRig = null; } private static void OnLevelUnloaded() { try { bool flag = FusionSword.InServer && FusionSword.HasMyEntity; Melon<Blue0k37Mod>.Logger.Msg("[sword] level unloaded" + (flag ? (" (networked sword id=" + FusionSword.MyEntityId + ")") : "")); if (flag && !FusionSword.EntityGone(out var _)) { Melon<Blue0k37Mod>.Logger.Msg("[fusion] sword still registered after level unload, despawning it"); FusionSword.Despawn(); } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("level unload sword cleanup: " + ex); } RestoreSolid(); _sword = null; _swordRbs = null; _swordHost = null; _spawning = false; _ignoredRig = null; _releaseTime = -1f; _swordSlot = null; _swordCols = null; _rigReceivers = null; _receiversRig = null; _returning = false; _physReturn = false; _returnGrav = null; _returnMaxAng = null; _swordNetworked = false; _stealSince = -1f; _swordSolidCols = null; _lastSentHolster = -1; FusionSword.Clear(); FusionSwordNet.OnLevelUnloaded(); Dropkick.OnLevelUnloaded(); Railgun.OnLevelUnloaded(); FusionNpc.OnLevelUnloaded(); RailNetFx.OnLevelUnloaded(); Jump.OnLevelUnloaded(); WeaponWheel.OnLevelUnloaded(); FingerGesture.OnLevelUnloaded(); FistPower.OnLevelUnloaded(); } public override void OnUpdate() { try { FusionSword.LogNetState(); } catch { } try { Dropkick.Update(); } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("dropkick update: " + ex); } try { Railgun.Update(); } catch (Exception ex2) { Melon<Blue0k37Mod>.Logger.Error("railgun update: " + ex2); } try { WeaponWheel.Update(); } catch (Exception ex3) { Melon<Blue0k37Mod>.Logger.Error("weapon wheel update: " + ex3); } try { FingerGesture.Update(); } catch (Exception ex4) { Melon<Blue0k37Mod>.Logger.Error("finger gesture update: " + ex4); } try { FistPower.Update(); } catch (Exception ex5) { Melon<Blue0k37Mod>.Logger.Error("fist update: " + ex5); } try { FusionNpc.Update(); } catch (Exception ex6) { Melon<Blue0k37Mod>.Logger.Error("fusion npc update: " + ex6); } try { FusionRailgun.TryRegister(); } catch { } try { FusionSwordNet.TryRegister(); FusionSwordNet.Update(); } catch (Exception ex7) { Melon<Blue0k37Mod>.Logger.Error("sword net update: " + ex7); } } public override void OnFixedUpdate() { try { Dropkick.FixedUpdate(); } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("dropkick fixed: " + ex); } try { Jump.FixedUpdate(); } catch (Exception ex2) { Melon<Blue0k37Mod>.Logger.Error("jump fixed: " + ex2); } try { FixedReturn(); } catch (Exception ex3) { Melon<Blue0k37Mod>.Logger.Error("sword fixed return: " + ex3); } try { RailNetFx.FixedUpdate(); } catch (Exception ex4) { Melon<Blue0k37Mod>.Logger.Error("railgun net fx fixed: " + ex4); } try { FingerGesture.FixedUpdate(); } catch (Exception ex5) { Melon<Blue0k37Mod>.Logger.Error("finger fixed: " + ex5); } try { FistPower.FixedUpdate(); } catch (Exception ex6) { Melon<Blue0k37Mod>.Logger.Error("fist fixed: " + ex6); } } public override void OnLateUpdate() { //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) try { FistPower.LateUpdate(); } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("fist trail: " + ex); } if ((Object)(object)Player.RigManager == (Object)null) { return; } PhysicsRig physRig = GetPhysRig(); if (Time.time >= _nextAvatarCheck) { _nextAvatarCheck = Time.time + 1f; bool flag = false; try { flag = SwordEnabled.Value && (Object)(object)Player.Avatar != (Object)null && IsTarget(Player.Avatar); } catch { } if (!flag && _wantSword) { DespawnSword(); } _wantSword = flag; } if (!_wantSword || (Object)(object)physRig == (Object)null || FusionSword.Connecting) { return; } bool inServer = FusionSword.InServer; if ((Object)(object)_sword != (Object)null && inServer != _swordNetworked) { Melon<Blue0k37Mod>.Logger.Msg("[fusion] server state changed (inServer=" + inServer + "), respawning sword"); DespawnSword(); _spawning = false; _nextSpawnTime = 0f; } if (inServer && (Object)(object)_sword != (Object)null && FusionSword.EntityGone(out var why)) { Melon<Blue0k37Mod>.Logger.Msg("[fusion] my sword is gone (" + why + "), respawning"); _sword = null; _returning = false; _physReturn = false; FusionSword.Clear(); } if (!SwordAlive()) { if (inServer) { if (_spawning && Time.time - _spawnStartTime > 8f) { _spawning = false; } bool flag2 = false; try { flag2 = HelperMethods.IsLoading(); } catch { } if (!_spawning && Time.time >= _nextSpawnTime && !flag2) { SpawnSword(physRig); } return; } if (Time.time >= _nextScan) { _nextScan = Time.time + 0.25f; GameObject val = FindNearestSword(physRig); if ((Object)(object)val != (Object)null) { Adopt(val, physRig); DespawnExtras(val); } } if ((Object)(object)_sword == (Object)null) { if (_spawning && Time.time - _spawnStartTime > 8f) { _spawning = false; } bool flag3 = false; try { flag3 = HelperMethods.IsLoading(); } catch { } if (!_spawning && Time.time >= _nextSpawnTime && !flag3) { SpawnSword(physRig); } return; } } if (!inServer && Time.time >= _nextExtraScan) { _nextExtraScan = Time.time + 15f; DespawnExtras(_sword); } if ((Object)(object)_ignoredRig == (Object)null || ((Il2CppObjectBase)_ignoredRig).Pointer != ((Il2CppObjectBase)physRig).Pointer) { IgnoreRigCollisions(physRig); } bool flag4 = (Object)(object)_swordHost != (Object)null && _swordHost.HandCount() > 0; bool flag5 = FusionSword.IsOwner(); if (inServer && _swordNetworked && FusionSword.HasMyEntity) { int num = ((_holstered || _returning) ? 1 : 0); if (num != _lastSentHolster || Time.time >= _nextStateSend) { _lastSentHolster = num; _nextStateSend = Time.time + 1f; FusionSwordNet.SendState(FusionSword.MyEntityId, num == 1); } } if (inServer) { bool flag6 = flag4 && HeldByMe(); bool flag7 = flag4 && !flag6; if (SwordOwnerOnlyDraw.Value && (_holstered || _returning) && flag7) { if (_stealSince < 0f) { _stealSince = Time.time; } if (Time.time - _stealSince >= 0.15f && Time.time >= _nextStealRespawn) { Melon<Blue0k37Mod>.Logger.Msg("[fusion] another player grabbed the sword from my hip (owner=" + flag5 + "), taking it back"); _stealSince = -1f; _nextStealRespawn = Time.time + 1.5f; DespawnSword(); _spawning = false; _nextSpawnTime = 0f; } return; } _stealSince = -1f; if (flag6) { if (!flag5) { RequestOwnership("held by me"); } _releaseTime = -1f; if (_returning) { EndReturn(arrived: false); } if (_holstered) { SetHolstered(holstered: false); } return; } if (flag4) { _releaseTime = -1f; if (_returning) { EndReturn(arrived: false); } if (_holstered) { SetHolstered(holstered: false); } return; } if (!flag5 && (_holstered || _returning)) { RequestOwnership("on hip"); } } else if (flag4) { _releaseTime = -1f; if (_returning) { EndReturn(arrived: false); } if (_holstered) { SetHolstered(holstered: false); } return; } if (_returning) { UpdateReturn(physRig); return; } if (_holstered) { SnapToHip(physRig); return; } if (IsInSlot(physRig)) { _releaseTime = -1f; return; } if (_releaseTime < 0f) { _releaseTime = Time.time; } if (SwordHipSnap.Value > 0f && Time.time - _releaseTime <= 0.6f) { GetHipPose(physRig, out var pos, out var _); float num2 = Vector3.Distance(_sword.transform.position, pos); if (num2 <= SwordHipSnap.Value) { if (!flag5) { RequestOwnership("hip snap"); return; } DLog("[sword] released near hip (" + num2.ToString("0.00") + "m), holstering"); _releaseTime = -1f; if (SwordReturnAnim.Value && SwordReturnAnimTime.Value > 0.01f) { BeginReturn(physRig); return; } SetHolstered(holstered: true); SnapToHip(physRig); return; } } if (!(Time.time - _releaseTime >= Mathf.Max(0f, SwordReturnDelay.Value))) { return; } if (!flag5) { if (Time.time >= _nextOwnLog) { _nextOwnLog = Time.time + 0.5f; FusionSword.TakeOwnership(); Melon<Blue0k37Mod>.Logger.Msg("[fusion] taking sword ownership back"); } } else { _releaseTime = -1f; if (SwordReturnAnim.Value && SwordReturnAnimTime.Value > 0.01f) { BeginReturn(physRig); return; } SetHolstered(holstered: true); SnapToHip(physRig); } } private static void RequestOwnership(string why) { if (!(Time.time < _nextOwnReq)) { _nextOwnReq = Time.time + 0.5f; FusionSword.TakeOwnership(); if (Time.time >= _nextOwnReqLog) { _nextOwnReqLog = Time.time + 3f; DLog("[fusion] requesting sword ownership (" + why + ", owner now=" + FusionSword.OwnerId() + ")"); } } } private static bool IsPartOfSword(GameObject g) { try { if ((Object)(object)g == (Object)null || (Object)(object)_sword == (Object)null) { return false; } return ((Il2CppObjectBase)g).Pointer == ((Il2CppObjectBase)_sword).Pointer || g.transform.IsChildOf(_sword.transform); } catch { return false; } } private static bool HeldByMe() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) try { if (IsPartOfSword(Player.GetObjectInHand(Player.LeftHand))) { return true; } if (IsPartOfSword(Player.GetObjectInHand(Player.RightHand))) { return true; } } catch { } try { Vector3 position = _sword.transform.position; float num = 0.122499995f; Hand leftHand = Player.LeftHand; Hand rightHand = Player.RightHand; Vector3 val; if ((Object)(object)leftHand != (Object)null) { val = ((Component)leftHand).transform.position - position; if (((Vector3)(ref val)).sqrMagnitude <= num) { return true; } } if ((Object)(object)rightHand != (Object)null) { val = ((Component)rightHand).transform.position - position; if (((Vector3)(ref val)).sqrMagnitude <= num) { return true; } } } catch { } return false; } private static bool IsInSlot(PhysicsRig phys) { try { if ((Object)(object)_sword.transform.parent != (Object)null && (Object)(object)_sword.GetComponentInParent<InventorySlotReceiver>() != (Object)null) { return true; } if ((Object)(object)_swordSlot == (Object)null) { return false; } if (_rigReceivers == null || (Object)(object)_receiversRig == (Object)null || ((Il2CppObjectBase)_receiversRig).Pointer != ((Il2CppObjectBase)phys).Pointer) { _receiversRig = phys; RigManager rigManager = Player.RigManager; _rigReceivers = (InventorySlotReceiver[])(((Object)(object)rigManager != (Object)null) ? ((Array)Il2CppArrayBase<InventorySlotReceiver>.op_Implicit(((Component)rigManager).GetComponentsInChildren<InventorySlotReceiver>(true))) : ((Array)new InventorySlotReceiver[0])); } InventorySlotReceiver[] rigReceivers = _rigReceivers; foreach (InventorySlotReceiver val in rigReceivers) { if (!((Object)(object)val == (Object)null)) { WeaponSlot slottedWeapon = val._slottedWeapon; if ((Object)(object)slottedWeapon != (Object)null && ((Il2CppObjectBase)slottedWeapon).Pointer == ((Il2CppObjectBase)_swordSlot).Pointer) { return true; } } } } catch { } return false; } private static void BeginReturn(PhysicsRig phys) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) _returning = true; _returnStart = Time.time; _returnFromPos = _sword.transform.position; _returnFromRot = _sword.transform.rotation; GetHipPose(phys, out var pos, out var _); float num = Vector3.Distance(_returnFromPos, pos); _returnDur = SwordReturnAnimTime.Value * Mathf.Clamp(0.6f + num / 6f, 0.6f, 2f); _physReturn = _swordNetworked; if (_physReturn) { SetReturnPhysics(on: true); } else { SetKinematic(k: true); } SetCollidersEnabled(on: false); } private static void ComputeReturnPose(PhysicsRig phys, float time, out Vector3 pos, out Quaternion rot) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_0076: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_0098: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) GetHipPose(phys, out var pos2, out var rot2); float num = Mathf.Clamp01((time - _returnStart) / Mathf.Max(0.01f, _returnDur)); float num2 = 1f - Mathf.Pow(1f - num, 3f); float num3 = Mathf.Clamp(Vector3.Distance(_returnFromPos, pos2) * 0.25f, 0.15f, 1.5f) * Mathf.Sin((float)Math.PI * num); pos = Vector3.Lerp(_returnFromPos, pos2, num2) + Vector3.up * num3; Quaternion val = Quaternion.Slerp(_returnFromRot, rot2, num2); Quaternion val2 = Quaternion.AngleAxis(360f * (1f - num2), Vector3.up); rot = val * val2; } private static void UpdateReturn(PhysicsRig phys) { //IL_0036: 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) float num = Mathf.Clamp01((Time.time - _returnStart) / Mathf.Max(0.01f, _returnDur)); if (!_physReturn) { ComputeReturnPose(phys, Time.time, out var pos, out var rot); SetPose(pos, rot); } if (num >= 1f) { EndReturn(arrived: true); } } private static void FixedReturn() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0104: Unknown result type (might be due to invalid IL or missing references) if (!_returning || !_physReturn || (Object)(object)_sword == (Object)null || _swordRbs == null) { return; } PhysicsRig physRig = GetPhysRig(); if ((Object)(object)physRig == (Object)null || (Object)(object)((Rig)physRig).m_pelvis == (Object)null) { return; } Rigidbody val = MainSwordRb(); if (!((Object)(object)val == (Object)null) && !val.isKinematic) { ComputeReturnPose(physRig, Time.time + Time.fixedDeltaTime, out var pos, out var rot); float num = Mathf.Max(Time.fixedDeltaTime, 0.0001f); val.velocity = (pos - val.position) / num; Quaternion val2 = rot * Quaternion.Inverse(val.rotation); float num2 = default(float); Vector3 val3 = default(Vector3); ((Quaternion)(ref val2)).ToAngleAxis(ref num2, ref val3); if (num2 > 180f) { num2 -= 360f; } if (float.IsNaN(val3.x) || ((Vector3)(ref val3)).sqrMagnitude < 1E-06f) { val.angularVelocity = Vector3.zero; } else { val.angularVelocity = ((Vector3)(ref val3)).normalized * (num2 * ((float)Math.PI / 180f) / num); } } } private static Rigidbody MainSwordRb() { if (_swordRbs == null || (Object)(object)_sword == (Object)null) { return null; } Rigidbody val = null; Rigidbody[] swordRbs = _swordRbs; foreach (Rigidbody val2 in swordRbs) { if (!((Object)(object)val2 == (Object)null)) { if ((Object)(object)val == (Object)null) { val = val2; } if ((Object)(object)((Component)val2).transform == (Object)(object)_sword.transform) { return val2; } } } return val; } private static void SetReturnPhysics(bool on) { //IL_0079: 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) if (_swordRbs == null) { return; } if (on) { _returnGrav = new bool[_swordRbs.Length]; _returnMaxAng = new float[_swordRbs.Length]; for (int i = 0; i < _swordRbs.Length; i++) { Rigidbody val = _swordRbs[i]; if (!((Object)(object)val == (Object)null)) { _returnGrav[i] = val.useGravity; _returnMaxAng[i] = val.maxAngularVelocity; val.isKinematic = false; val.useGravity = false; val.maxAngularVelocity = 100f; val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } } return; } for (int j = 0; j < _swordRbs.Length; j++) { Rigidbody val2 = _swordRbs[j]; if (!((Object)(object)val2 == (Object)null)) { if (_returnGrav != null && j < _returnGrav.Length) { val2.useGravity = _returnGrav[j]; } if (_returnMaxAng != null && j < _returnMaxAng.Length) { val2.maxAngularVelocity = _returnMaxAng[j]; } } } _returnGrav = null; _returnMaxAng = null; } private static void EndReturn(bool arrived) { _returning = false; if (_physReturn) { SetReturnPhysics(on: false); _physReturn = false; } SetCollidersEnabled(on: true); _ignoredRig = null; if (arrived) { SetHolstered(holstered: true); PhysicsRig physRig = GetPhysRig(); if ((Object)(object)physRig != (Object)null) { SnapToHip(physRig); } } else { SetHolstered(holstered: false); } } private static void SetKinematic(bool k) { //IL_0023: 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) if (_swordRbs == null) { return; } Rigidbody[] swordRbs = _swordRbs; foreach (Rigidbody val in swordRbs) { if (!((Object)(object)val == (Object)null)) { if (k) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } val.isKinematic = k; } } } private static void SetCollidersEnabled(bool on) { if (_swordCols == null) { return; } Collider[] swordCols = _swordCols; foreach (Collider val in swordCols) { if ((Object)(object)val != (Object)null) { val.enabled = on; } } } private static void SetPose(Vector3 pos, Quaternion rot) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) Transform transform = _sword.transform; transform.SetPositionAndRotation(pos, rot); if (_swordRbs == null) { return; } Rigidbody[] swordRbs = _swordRbs; foreach (Rigidbody val in swordRbs) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).transform != (Object)(object)transform)) { val.position = pos; val.rotation = rot; } } } private static bool SwordAlive() { if ((Object)(object)_sword == (Object)null) { return false; } try { if (!_sword.activeInHierarchy) { Melon<Blue0k37Mod>.Logger.Msg("[sword] sword became inactive (despawned?), respawning"); _sword = null; _returning = false; _physReturn = false; return false; } } catch { _sword = null; return false; } return true; } private static bool IsSwordObject(GameObject go) { try { if ((Object)(object)go == (Object)null || !go.activeInHierarchy) { return false; } string name = ((Object)go).name; return name != null && name.IndexOf("blue0k37_Sword", StringComparison.OrdinalIgnoreCase) >= 0; } catch { return false; } } private static GameObject[] AllSwordObjects() { List<GameObject> list = new List<GameObject>(); foreach (InteractableHost item in Object.FindObjectsOfType<InteractableHost>()) { if (!((Object)(object)item == (Object)null)) { GameObject root = ((Component)item).gameObject; if (IsSwordObject(root) && !list.Exists((GameObject x) => ((Il2CppObjectBase)x).Pointer == ((Il2CppObjectBase)root).Pointer)) { list.Add(root); } } } return list.ToArray(); } private static GameObject FindNearestSword(PhysicsRig phys) { //IL_0023: 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_0028: 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_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) GameObject result = null; float num = float.MaxValue; Vector3 val = (((Object)(object)((Rig)phys).m_pelvis != (Object)null) ? ((Rig)phys).m_pelvis.position : Vector3.zero); GameObject[] array = AllSwordObjects(); foreach (GameObject val2 in array) { Vector3 val3 = val2.transform.position - val; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val2; } } return result; } private static void DespawnExtras(GameObject keep) { try { GameObject[] array = AllSwordObjects(); foreach (GameObject val in array) { if (!((Object)(object)keep != (Object)null) || !(((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)keep).Pointer)) { Poolee component = val.GetComponent<Poolee>(); if ((Object)(object)component != (Object)null) { component.Despawn(); } else { Object.Destroy((Object)(object)val); } } } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("despawn extras: " + ex); } } private static void Adopt(GameObject go, PhysicsRig phys) { _spawning = false; _sword = go; _swordNetworked = FusionSword.InServer && FusionSword.HasMyEntity; _swordRbs = Il2CppArrayBase<Rigidbody>.op_Implicit(go.GetComponentsInChildren<Rigidbody>(true)); _swordHost = go.GetComponentInChildren<InteractableHost>(true); _swordSlot = go.GetComponentInChildren<WeaponSlot>(true); _swordCols = Il2CppArrayBase<Collider>.op_Implicit(go.GetComponentsInChildren<Collider>(true)); _swordSolidCols = SolidSwordColliders(go); _lastSentHolster = -1; _holstered = false; _returning = false; _physReturn = false; _returnGrav = null; _returnMaxAng = null; _ignoredRig = null; _releaseTime = -1f; SetCollidersEnabled(on: true); SetHolstered(holstered: true); SnapToHip(phys); ApplySwordStats(log: true); } internal static void ApplySwordStats(bool log) { if ((Object)(object)_sword == (Object)null) { return; } string text = ""; try { StabSlash componentInChildren = _sword.GetComponentInChildren<StabSlash>(true); if ((Object)(object)componentInChildren != (Object)null) { int num = 0; int num2 = 0; float num3 = -1f; float num4 = -1f; float num5 = -1f; Il2CppReferenceArray<StabPoint> stabPoints = componentInChildren.stabPoints; if (stabPoints != null) { foreach (StabPoint item in (Il2CppArrayBase<StabPoint>)(object)stabPoints) { if (item != null) { if (num3 < 0f) { num3 = item.damage; } item.damage = Mathf.Max(0f, SwordStabDamage.Value); num++; } } } Il2CppReferenceArray<SlashBlade> slashBlades = componentInChildren.slashBlades; if (slashBlades != null) { foreach (SlashBlade item2 in (Il2CppArrayBase<SlashBlade>)(object)slashBlades) { if (item2 != null) { if (num4 < 0f) { num4 = item2.damage; } item2.damage = Mathf.Max(0f, SwordSlashDamage.Value); num2++; } } } BladeAudio bladeAudio = componentInChildren.bladeAudio; if (bladeAudio != null) { num5 = bladeAudio.bluntDamageMult; bladeAudio.bluntDamageMult = Mathf.Max(0f, SwordBluntMult.Value); } text = text + "stab x" + num + " " + num3.ToString("0.##") + "->" + SwordStabDamage.Value.ToString("0.##") + " slash x" + num2 + " " + num4.ToString("0.##") + "->" + SwordSlashDamage.Value.ToString("0.##") + " blunt " + num5.ToString("0.##") + "->" + SwordBluntMult.Value.ToString("0.##"); } else { text += "no StabSlash"; } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("sword stats (damage): " + ex); } try { Rigidbody val = MainSwordRb(); if ((Object)(object)val != (Object)null) { float mass = val.mass; val.mass = Mathf.Max(0.1f, SwordMass.Value); text = text + " mass " + mass.ToString("0.##") + "->" + val.mass.ToString("0.##"); } } catch (Exception ex2) { Melon<Blue0k37Mod>.Logger.Error("sword stats (mass): " + ex2); } if (log) { DLog("[sword] stats " + text); } } private static void GetHipPose(PhysicsRig phys, out Vector3 pos, out Quaternion rot) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) Transform pelvis = ((Rig)phys).m_pelvis; float num = SwordTilt.Value * ((float)Math.PI / 180f); Quaternion val = Quaternion.LookRotation(Vector3.right, new Vector3(0f, Mathf.Sin(num), Mathf.Cos(num))); pos = pelvis.TransformPoint(new Vector3(SwordX.Value, SwordY.Value, SwordZ.Value)); rot = pelvis.rotation * val; } private static void SpawnSword(PhysicsRig phys) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0050: Unknown result type (might be due to invalid IL or missing references) _spawning = true; _spawnStartTime = Time.time; _nextSpawnTime = Time.time + 3f; try { if ((Object)(object)((Rig)phys).m_pelvis == (Object)null) { _spawning = false; return; } GetHipPose(phys, out var pos, out var rot); if (FusionSword.InServer) { FusionSword.Spawn("blue0k37.blue0k37FunctionalAvatar.Spawnable.blue0k37Sword", pos, rot, delegate(GameObject go, ushort id) { if ((Object)(object)go == (Object)null) { _spawning = false; FusionSword.DespawnId(id); } else { PhysicsRig physRig = GetPhysRig(); if ((Object)(object)_sword != (Object)null || !_wantSword || (Object)(object)physRig == (Object)null) { Melon<Blue0k37Mod>.Logger.Msg("[fusion] extra sword id=" + id + ", despawning it"); FusionSword.DespawnId(id); _spawning = false; } else { FusionSword.Adopt(id); Adopt(go, physRig); _swordNetworked = true; } } }); return; } HelperMethods.SpawnCrate("blue0k37.blue0k37FunctionalAvatar.Spawnable.blue0k37Sword", pos, rot, Vector3.one, true, (Action<GameObject>)delegate(GameObject go) { if (!((Object)(object)go == (Object)null) && !((Object)(object)_sword != (Object)null)) { PhysicsRig physRig = GetPhysRig(); if (_wantSword && !((Object)(object)physRig == (Object)null)) { Adopt(go, physRig); _swordNetworked = false; } } }, (Action<GameObject>)null); } catch (Exception ex) { _spawning = false; Melon<Blue0k37Mod>.Logger.Error("sword spawn failed: " + ex); } } private static void DespawnSword() { RestoreSolid(); if (_swordNetworked || FusionSword.HasMyEntity) { try { if ((Object)(object)_swordHost != (Object)null && _swordHost.HandCount() > 0) { _swordHost.ForceDetach(false); } } catch { } FusionSword.Despawn(); _sword = null; _swordRbs = null; _swordHost = null; _swordSlot = null; _swordCols = null; _returning = false; _physReturn = false; _returnGrav = null; _returnMaxAng = null; _swordNetworked = false; return; } if (!FusionSword.InServer) { DespawnExtras(_sword); } if ((Object)(object)_sword == (Object)null) { return; } try { if ((Object)(object)_swordHost != (Object)null && _swordHost.HandCount() > 0) { _swordHost.ForceDetach(false); } Poolee component = _sword.GetComponent<Poolee>(); if ((Object)(object)component != (Object)null) { component.Despawn(); } else { Object.Destroy((Object)(object)_sword); } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("sword despawn: " + ex); } _sword = null; _swordRbs = null; _swordHost = null; _swordSlot = null; _swordCols = null; _returning = false; _physReturn = false; _returnGrav = null; _returnMaxAng = null; } internal static Collider[] SolidSwordColliders(GameObject go) { List<Collider> list = new List<Collider>(); try { foreach (Collider componentsInChild in go.GetComponentsInChildren<Collider>(true)) { if ((Object)(object)componentsInChild != (Object)null && ((Component)componentsInChild).gameObject.layer == 10) { list.Add(componentsInChild); } } } catch { } return list.ToArray(); } private static void RestoreSolid() { if (_swordSolidCols == null) { return; } Collider[] swordSolidCols = _swordSolidCols; foreach (Collider val in swordSolidCols) { try { if ((Object)(object)val != (Object)null) { val.isTrigger = false; } } catch { } } } private static void SetHolstered(bool holstered) { //IL_006a: 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) _holstered = holstered; if (_swordSolidCols != null) { Collider[] swordSolidCols = _swordSolidCols; foreach (Collider val in swordSolidCols) { try { if ((Object)(object)val != (Object)null) { val.isTrigger = holstered; } } catch { } } } if (_swordRbs == null) { return; } Rigidbody[] swordRbs = _swordRbs; foreach (Rigidbody val2 in swordRbs) { if (!((Object)(object)val2 == (Object)null)) { if (!holstered) { val2.isKinematic = false; continue; } val2.velocity = Vector3.zero; val2.angularVelocity = Vector3.zero; val2.isKinematic = true; } } } private static void SnapToHip(PhysicsRig phys) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) GetHipPose(phys, out var pos, out var rot); SetPose(pos, rot); } private static void IgnoreRigCollisions(PhysicsRig phys) { _ignoredRig = phys; try { Il2CppArrayBase<Collider> componentsInChildren = _sword.GetComponentsInChildren<Collider>(true); Il2CppArrayBase<Collider> componentsInChildren2 = ((Component)phys).GetComponentsInChildren<Collider>(true); foreach (Collider item in componentsInChildren) { foreach (Collider item2 in componentsInChildren2) { if ((Object)(object)item != (Object)null && (Object)(object)item2 != (Object)null) { Physics.IgnoreCollision(item, item2, true); } } } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("ignore collisions: " + ex); } } private static void BuildMenu() { //IL_000a: 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_0052: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: 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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) Page obj = Page.Root.CreatePage("blue0k37 Avatar", Color.cyan, 0, true); Page val = obj.CreatePage("Sword", Color.white, 0, true); Dropkick.BuildMenu(obj); Railgun.BuildMenu(obj); WeaponWheel.BuildMenu(obj); FingerGesture.BuildMenu(obj); FistPower.BuildMenu(obj); Jump.BuildMenu(obj); val.CreateBool("Sword enabled", Color.white, SwordEnabled.Value, (Action<bool>)delegate(bool v) { SwordEnabled.Value = v; Save(); _wantSword = v && (Object)(object)Player.Avatar != (Object)null && IsTarget(Player.Avatar); _nextAvatarCheck = 0f; if (!_wantSword) { DespawnSword(); } }); val.CreateFloat("Left/Right (X)", Color.white, SwordX.Value, 0.01f, -1f, 1f, (Action<float>)delegate(float v) { SwordX.Value = (float)Math.Round(v, 3); Save(); }); val.CreateFloat("Up/Down (Y)", Color.white, SwordY.Value, 0.01f, -1f, 1f, (Action<float>)delegate(float v) { SwordY.Value = (float)Math.Round(v, 3); Save(); }); val.CreateFloat("Fwd/Back (Z)", Color.white, SwordZ.Value, 0.01f, -1f, 1f, (Action<float>)delegate(float v) { SwordZ.Value = (float)Math.Round(v, 3); Save(); }); val.CreateFloat("Tilt (deg)", Color.white, SwordTilt.Value, 5f, -90f, 90f, (Action<float>)delegate(float v) { SwordTilt.Value = (float)Math.Round(v, 1); Save(); }); val.CreateFloat("Return delay (sec)", Color.white, SwordReturnDelay.Value, 0.5f, 0f, 30f, (Action<float>)delegate(float v) { SwordReturnDelay.Value = (float)Math.Round(v, 1); Save(); }); val.CreateBool("Return animation", Color.white, SwordReturnAnim.Value, (Action<bool>)delegate(bool v) { SwordReturnAnim.Value = v; Save(); }); val.CreateFloat("Return anim time (sec)", Color.white, SwordReturnAnimTime.Value, 0.1f, 0.1f, 3f, (Action<float>)delegate(float v) { SwordReturnAnimTime.Value = (float)Math.Round(v, 2); Save(); }); val.CreateFloat("Hip snap distance (m)", Color.white, SwordHipSnap.Value, 0.05f, 0f, 1f, (Action<float>)delegate(float v) { SwordHipSnap.Value = (float)Math.Round(v, 2); Save(); }); val.CreateBool("Only I can draw (multi)", Color.yellow, SwordOwnerOnlyDraw.Value, (Action<bool>)delegate(bool v) { SwordOwnerOnlyDraw.Value = v; Save(); }); val.CreateFunction("Respawn sword", Color.green, (Action)delegate { DespawnSword(); _spawning = false; _nextSpawnTime = 0f; }); Page obj2 = val.CreatePage("Sword stats", Color.yellow, 0, true); _stabEl = obj2.CreateFloat("Stab damage", Color.white, SwordStabDamage.Value, 0.5f, 0f, 100f, (Action<float>)delegate(float v) { SwordStabDamage.Value = (float)Math.Round(v, 2); Save(); ApplySwordStats(log: true); }); _slashEl = obj2.CreateFloat("Slash damage", Color.white, SwordSlashDamage.Value, 0.5f, 0f, 100f, (Action<float>)delegate(float v) { SwordSlashDamage.Value = (float)Math.Round(v, 2); Save(); ApplySwordStats(log: true); }); _massEl = obj2.CreateFloat("Weight (kg)", Color.white, SwordMass.Value, 0.1f, 0.1f, 20f, (Action<float>)delegate(float v) { SwordMass.Value = (float)Math.Round(v, 2); Save(); ApplySwordStats(log: true); }); _bluntEl = obj2.CreateFloat("Blunt damage mult", Color.white, SwordBluntMult.Value, 0.25f, 0f, 20f, (Action<float>)delegate(float v) { SwordBluntMult.Value = (float)Math.Round(v, 2); Save(); ApplySwordStats(log: true); }); obj2.CreateFunction("Reset to default", Color.green, (Action)delegate { SwordStabDamage.Value = 2.5f; SwordSlashDamage.Value = 2f; SwordMass.Value = 1.9f; SwordBluntMult.Value = 1f; Save(); ApplySwordStats(log: true); try { _stabEl.Value = 2.5f; _slashEl.Value = 2f; _massEl.Value = 1.9f; _bluntEl.Value = 1f; } catch { } }); } private static void Save() { Cat.SaveToFile(false); } } [HarmonyPatch(typeof(Avatar), "ComputeBaseStats")] internal static class ComputeBaseStatsPatch { [HarmonyPostfix] private static void Postfix(Avatar __instance) { try { Blue0k37Mod.ApplyStats(__instance); } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("ApplyStats: " + ex); } } } internal enum KickBind { RightB_Tap, RightA_Tap, LeftY_Tap, LeftX_Tap, RightStickClick_Tap, LeftStickClick_Tap, BothSticksClick } internal static class Dropkick { private class Limp { public PuppetMaster Pm; public AIBrain Brain; public float OrigMuscleWeight; public float Until; } private class GravAssist { public IntPtr BrainPtr; public Rigidbody[] Rbs; public float Until; } internal static MelonPreferences_Category Cat; internal static MelonPreferences_Entry<bool> Enabled; internal static MelonPreferences_Entry<bool> LieDown; internal static MelonPreferences_Entry<bool> InstantLie; internal static MelonPreferences_Entry<float> Damage; internal static MelonPreferences_Entry<float> Knockback; internal static MelonPreferences_Entry<float> LungeSpeed; internal static MelonPreferences_Entry<float> PoseStrength; internal static MelonPreferences_Entry<float> LieAngle; internal static MelonPreferences_Entry<float> KickTime; internal static MelonPreferences_Entry<float> RagdollTime; internal static MelonPreferences_Entry<float> Cooldown; internal static MelonPreferences_Entry<bool> GravityAssist; internal static MelonPreferences_Entry<bool> PunchSound; internal static MelonPreferences_Entry<float> PunchVolume; private static AudioClip[] _punchClips; private static float _nextPunchSound; internal static MelonPreferences_Entry<bool> HitPlayers; internal static MelonPreferences_Entry<float> PlayerDamage; internal static MelonPreferences_Entry<bool> AllowHitOnMe; private const float MaxReceivedRagdoll = 6f; private static bool _pendingHit; private static Vector3 _pendingVel; private static float _pendingRagdoll; private static byte _pendingSender; private static float _knockApplyAt = -1f; private static Vector3 _knockVel; private static float _selfRagdollUntil = -1f; internal static MelonPreferences_Entry<bool> DebugLog; internal static MelonPreferences_Entry<bool> GroundKick; internal static MelonPreferences_Entry<bool> GroundKickLeft; internal static MelonPreferences_Entry<float> GroundKickTime; internal static MelonPreferences_Entry<float> GroundKickCooldown; internal static MelonPreferences_Entry<float> GroundKickHeight; private static bool _groundKick; private static float _gkStart; private static PhysLimb _gkLeg; private static float _gkServo = -1f; private static bool _gkMadePhysical; private static PhysicsRig _gkRig; private const float GroundKickMaxUpSpeed = 0.3f; private static Rigidbody[] _gkBodyRbs; private static float _gkMaxVy; private const float GroundKickExtend = 0.12f; private const float GroundKickGain = 30f; internal static MelonPreferences_Entry<string> Bind; private static KickBind _bind = KickBind.RightB_Tap; private static float _leftStickDownTime = -10f; private static float _rightStickDownTime = -10f; private const float TapMaxSeconds = 0.3f; private const float FootRadius = 0.22f; private const float ShinRadius = 0.15f; private const float FallbackRadius = 0.3f; private const float NewDefaultKnockback = 5f; private const float DentSearchRadius = 0.35f; private const float MinGravityAssistSeconds = 1.5f; private static float _bDownTime = -1f; private static float _cooldownEnd; private static bool _kicking; private static float _kickStart; private static Vector3 _kickDir; private static bool _playerRagdolled; private static PhysicsRig _ragdollRig; private static readonly HashSet<IntPtr> _hitThisKick = new HashSet<IntPtr>(); private static Rigidbody[] _poseRbs; private static Quaternion[] _poseTargets; private static PhysLimb _legL; private static PhysLimb _legR; private static float _legLForce = -1f; private static float _legRForce = -1f; private static bool _madeLegsPhysical; private static readonly List<Limp> _limp = new List<Limp>(); private static readonly List<GravAssist> _grav = new List<GravAssist>(); internal static bool IsKicking { get { if (!_kicking) { return _groundKick; } return true; } } internal static void Init() { Cat = MelonPreferences.CreateCategory("blue0k37Dropkick", "blue0k37 Functional Avatar - Dropkick"); Enabled = Cat.CreateEntry<bool>("Enabled", true, "Dropkick enabled", "In the air, tap the bound button (default B) to dropkick", false, false, (ValueValidator)null, (string)null); LieDown = Cat.CreateEntry<bool>("LieDown", true, "Lie down", "Your body falls back (ragdoll) with feet forward while kicking", false, false, (ValueValidator)null, (string)null); InstantLie = Cat.CreateEntry<bool>("InstantLie", true, "Instant lie down", "Snap the body into the lying pose the moment the kick starts", false, false, (ValueValidator)null, (string)null); Damage = Cat.CreateEntry<float>("Damage", 2f, "Damage", "Damage dealt to each enemy hit", false, false, (ValueValidator)null, (string)null); Knockback = Cat.CreateEntry<float>("Knockback", 5f, "Knockback", "Velocity (m/s) added to enemies hit", false, false, (ValueValidator)null, (string)null); LungeSpeed = Cat.CreateEntry<float>("LungeSpeed", 7f, "Lunge speed", "Forward speed (m/s) added to you when kicking", false, false, (ValueValidator)null, (string)null); PoseStrength = Cat.CreateEntry<float>("PoseStrength", 20f, "Pose strength", "How strongly your body is held in the lying pose", false, false, (ValueValidator)null, (string)null); LieAngle = Cat.CreateEntry<float>("LieAngle", 15f, "Lie angle", "Degrees your head is raised above horizontal while lying (0 = flat)", false, false, (ValueValidator)null, (string)null); KickTime = Cat.CreateEntry<float>("KickTime", 0.9f, "Kick time", "Seconds the kick hits and you stay lying down", false, false, (ValueValidator)null, (string)null); RagdollTime = Cat.CreateEntry<float>("RagdollTime", 3f, "Ragdoll time", "Seconds enemies stay limp after being hit", false, false, (ValueValidator)null, (string)null); Cooldown = Cat.CreateEntry<float>("Cooldown", 1.5f, "Cooldown", "Seconds between dropkicks", false, false, (ValueValidator)null, (string)null); GravityAssist = Cat.CreateEntry<bool>("GravityAssist", true, "Gravity assist", "Apply gravity to hit enemies while they are limp (fixes enemies floating away)", false, false, (ValueValidator)null, (string)null); PunchSound = Cat.CreateEntry<bool>("PunchSound", true, "Punch sound", "Play the game's punch sound when the dropkick hits", false, false, (ValueValidator)null, (string)null); PunchVolume = Cat.CreateEntry<float>("PunchVolume", 1f, "Punch volume", "Volume of the punch sound (0~2)", false, false, (ValueValidator)null, (string)null); HitPlayers = Cat.CreateEntry<bool>("HitPlayers", true, "Hit players (multi)", "Multiplayer: dropkick also hits other Fusion players", false, false, (ValueValidator)null, (string)null); PlayerDamage = Cat.CreateEntry<float>("PlayerDamagePercent", 25f, "Player damage (%)", "Damage dealt to other players, in % of their max health (follows the server's friendly-fire setting)", false, false, (ValueValidator)null, (string)null); AllowHitOnMe = Cat.CreateEntry<bool>("AllowHitOnMe", true, "Players can dropkick me", "Multiplayer: get knocked back/knocked out when another player with this mod dropkicks you", false, false, (ValueValidator)null, (string)null); GroundKick = Cat.CreateEntry<bool>("GroundKick", true, "Ground kick", "On the ground, the same button does a normal kick (no lying down)", false, false, (ValueValidator)null, (string)null); GroundKickLeft = Cat.CreateEntry<bool>("GroundKickLeft", false, "Ground kick with left leg", "Kick with the left leg instead of the right", false, false, (ValueValidator)null, (string)null); GroundKickTime = Cat.CreateEntry<float>("GroundKickTime", 0.45f, "Ground kick time", "Seconds the leg stays out and can hit", false, false, (ValueValidator)null, (string)null); GroundKickCooldown = Cat.CreateEntry<float>("GroundKickCooldown", 0.5f, "Ground kick cooldown", "Seconds between ground kicks", false, false, (ValueValidator)null, (string)null); GroundKickHeight = Cat.CreateEntry<float>("GroundKickHeight", 0.2f, "Ground kick height", "How high the leg is raised: 0 = straight forward, 1 = straight up, negative = lower", false, false, (ValueValidator)null, (string)null); DebugLog = Cat.CreateEntry<bool>("DebugLog", false, "Debug log", "Write debug info (dropkick hits, sword, multiplayer) to the MelonLoader log", false, false, (ValueValidator)null, (string)null); Bind = Cat.CreateEntry<string>("Bind", KickBind.RightB_Tap.ToString(), "Bind", "RightB_Tap, RightA_Tap, LeftY_Tap, LeftX_Tap, RightStickClick_Tap, LeftStickClick_Tap, BothSticksClick", false, false, (ValueValidator)null, (string)null); if (!Enum.TryParse<KickBind>(Bind.Value, out _bind)) { _bind = KickBind.RightB_Tap; } if (Mathf.Approximately(Knockback.Value, 18f) || Mathf.Approximately(Knockback.Value, 12f)) { Knockback.Value = 5f; } Cat.SaveToFile(false); FusionDropkick.TryRegister(); } private static void Log(string s) { if (DebugLog.Value) { Melon<Blue0k37Mod>.Logger.Msg("[dropkick] " + s); } } internal static void BuildMenu(Page root) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_00c6: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) Page obj = root.CreatePage("Dropkick", Color.white, 0, true); obj.CreateBool("Dropkick enabled", Color.white, Enabled.Value, (Action<bool>)delegate(bool v) { Enabled.Value = v; Cat.SaveToFile(false); }); obj.CreateEnum("Bind", Color.yellow, (Enum)_bind, (Action<Enum>)delegate(Enum v) { _bind = (KickBind)(object)v; Bind.Value = _bind.ToString(); _bDownTime = -1f; Cat.SaveToFile(false); }); obj.CreateBool("Lie down", Color.white, LieDown.Value, (Action<bool>)delegate(bool v) { LieDown.Value = v; Cat.SaveToFile(false); }); obj.CreateBool("Instant lie down", Color.white, InstantLie.Value, (Action<bool>)delegate(bool v) { InstantLie.Value = v; Cat.SaveToFile(false); }); obj.CreateFloat("Damage", Color.white, Damage.Value, 0.5f, 0f, 50f, (Action<float>)delegate(float v) { Damage.Value = (float)Math.Round(v, 1); Cat.SaveToFile(false); }); obj.CreateFloat("Knockback", Color.white, Knockback.Value, 1f, 0f, 60f, (Action<float>)delegate(float v) { Knockback.Value = (float)Math.Round(v, 1); Cat.SaveToFile(false); }); obj.CreateFloat("Lunge speed", Color.white, LungeSpeed.Value, 0.5f, 0f, 20f, (Action<float>)delegate(float v) { LungeSpeed.Value = (float)Math.Round(v, 1); Cat.SaveToFile(false); }); obj.CreateFloat("Pose strength", Color.white, PoseStrength.Value, 1f, 1f, 60f, (Action<float>)delegate(float v) { PoseStrength.Value = (float)Math.Round(v, 1); Cat.SaveToFile(false); }); obj.CreateFloat("Lie angle (deg)", Color.white, LieAngle.Value, 5f, -30f, 60f, (Action<float>)delegate(float v) { LieAngle.Value = (float)Math.Round(v, 1); Cat.SaveToFile(false); }); obj.CreateFloat("Kick time (sec)", Color.white, KickTime.Value, 0.1f, 0.2f, 3f, (Action<float>)delegate(float v) { KickTime.Value = (float)Math.Round(v, 2); Cat.SaveToFile(false); }); obj.CreateFloat("Ragdoll time (sec)", Color.white, RagdollTime.Value, 0.5f, 0f, 10f, (Action<float>)delegate(float v) { RagdollTime.Value = (float)Math.Round(v, 1); Cat.SaveToFile(false); }); obj.CreateFloat("Cooldown (sec)", Color.white, Cooldown.Value, 0.25f, 0f, 10f, (Action<float>)delegate(float v) { Cooldown.Value = (float)Math.Round(v, 2); Cat.SaveToFile(false); }); obj.CreateBool("Punch sound", Color.white, PunchSound.Value, (Action<bool>)delegate(bool v) { PunchSound.Value = v; Cat.SaveToFile(false); }); obj.CreateFloat("Punch volume", Color.white, PunchVolume.Value, 0.1f, 0f, 2f, (Action<float>)delegate(float v) { PunchVolume.Value = (float)Math.Round(v, 2); Cat.SaveToFile(false); }); obj.CreateBool("Hit players (multi)", Color.yellow, HitPlayers.Value, (Action<bool>)delegate(bool v) { HitPlayers.Value = v; Cat.SaveToFile(false); }); obj.CreateFloat("Player damage (%)", Color.yellow, PlayerDamage.Value, 5f, 0f, 100f, (Action<float>)delegate(float v) { PlayerDamage.Value = (float)Math.Round(v, 1); Cat.SaveToFile(false); }); obj.CreateBool("Players can dropkick me", Color.yellow, AllowHitOnMe.Value, (Action<bool>)delegate(bool v) { AllowHitOnMe.Value = v; Cat.SaveToFile(false); }); obj.CreateBool("Ground kick", Color.cyan, GroundKick.Value, (Action<bool>)delegate(bool v) { GroundKick.Value = v; Cat.SaveToFile(false); }); obj.CreateBool("Ground kick left leg", Color.cyan, GroundKickLeft.Value, (Action<bool>)delegate(bool v) { GroundKickLeft.Value = v; Cat.SaveToFile(false); }); obj.CreateFloat("Ground kick time (sec)", Color.cyan, GroundKickTime.Value, 0.05f, 0.2f, 1.5f, (Action<float>)delegate(float v) { GroundKickTime.Value = (float)Math.Round(v, 2); Cat.SaveToFile(false); }); obj.CreateFloat("Ground kick cooldown", Color.cyan, GroundKickCooldown.Value, 0.1f, 0f, 5f, (Action<float>)delegate(float v) { GroundKickCooldown.Value = (float)Math.Round(v, 2); Cat.SaveToFile(false); }); obj.CreateFloat("Ground kick height", Color.cyan, GroundKickHeight.Value, 0.05f, -0.5f, 1f, (Action<float>)delegate(float v) { GroundKickHeight.Value = (float)Math.Round(v, 2); Cat.SaveToFile(false); }); obj.CreateBool("Debug log", Color.gray, DebugLog.Value, (Action<bool>)delegate(bool v) { DebugLog.Value = v; Cat.SaveToFile(false); }); obj.CreateBool("Gravity assist", Color.white, GravityAssist.Value, (Action<bool>)delegate(bool v) { GravityAssist.Value = v; if (!v) { _grav.Clear(); } Cat.SaveToFile(false); }); } internal static void OnLevelUnloaded() { EndGroundKick(restoreLegs: false); _kicking = false; _playerRagdolled = false; _ragdollRig = null; _hitThisKick.Clear(); _limp.Clear(); _grav.Clear(); _bDownTime = -1f; _punchClips = null; _pendingHit = false; _knockApplyAt = -1f; _selfRagdollUntil = -1f; } internal static void ForceStandUp() { EndGroundKick(restoreLegs: true); _kicking = false; EndPlayerRagdoll(); } internal static void Update() { UpdateLimp(); FusionDropkick.TryRegister(); if (_selfRagdollUntil > 0f && Time.time >= _selfRagdollUntil) { _selfRagdollUntil = -1f; try { PhysicsRig physRig = Blue0k37Mod.GetPhysRig(); if ((Object)(object)physRig != (Object)null && !_kicking) { physRig.UnRagdollRig(); } } catch { } } if (!Enabled.Value) { return; } BaseController val = null; BaseController val2 = null; try { val = Player.RightController; val2 = Player.LeftController; } catch { return; } if (_bind == KickBind.BothSticksClick) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val == (Object)null)) { if (val2.GetThumbStickDown()) { _leftStickDownTime = Time.time; } if (val.GetThumbStickDown()) { _rightStickDownTime = Time.time; } if (Mathf.Abs(_leftStickDownTime - _rightStickDownTime) <= 0.25f && Time.time - Mathf.Max(_leftStickDownTime, _rightStickDownTime) < 0.05f) { _leftStickDownTime = -10f; _rightStickDownTime = -20f; TryStart(); } } return; } KickBind bind = _bind; BaseController val3 = (((uint)(bind - 2) > 1u && bind != KickBind.LeftStickClick_Tap) ? val : val2); if ((Object)(object)val3 == (Object)null) { return; } bool flag; bool flag2; switch (_bind) { case KickBind.RightA_Tap: case KickBind.LeftX_Tap: flag = val3.GetAButtonDown(); flag2 = val3.GetAButtonUp(); break; case KickBind.RightStickClick_Tap: case KickBind.LeftStickClick_Tap: flag = val3.GetThumbStickDown(); flag2 = val3.GetThumbStickUp(); break; default: flag = val3.GetBButtonDown(); flag2 = val3.GetBButtonUp(); break; } if (flag) { _bDownTime = Time.time; } if (flag2) { bool num = _bDownTime >= 0f && Time.time - _bDownTime <= 0.3f; _bDownTime = -1f; if (num) { TryStart(); } } } private unsafe static void TryStart() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_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_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_01e2: Unknown result type (might be due to invalid IL or missing references) if (_kicking || _groundKick || Time.time < _cooldownEnd) { return; } Avatar avatar = null; try { avatar = Player.Avatar; } catch { } if (!Blue0k37Mod.IsTarget(avatar)) { return; } PhysicsRig physRig = Blue0k37Mod.GetPhysRig(); if ((Object)(object)physRig == (Object)null || (Object)(object)((Rig)physRig).m_pelvis == (Object)null) { return; } bool flag = true; try { flag = (Object)(object)physRig.physG != (Object)null && physRig.physG.isGrounded; } catch { } Vector3 val = Vector3.zero; try { val = Player.Head.forward; } catch { } val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Rig)physRig).m_pelvis.forward; val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return; } ((Vector3)(ref val)).Normalize(); if (flag) { if (GroundKick.Value) { StartGroundKick(physRig, val); } return; } _kickDir = val; _kicking = true; _kickStart = Time.time; _cooldownEnd = Time.time + Mathf.Max(0f, Cooldown.Value) + KickTime.Value; _hitThisKick.Clear(); if (LieDown.Value) { try { physRig.RagdollRig(); _playerRagdolled = true; _ragdollRig = physRig; } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("dropkick ragdoll player: " + ex); } } if (_playerRagdolled) { SetupPose(physRig, val); } try { Vector3 val2 = val * LungeSpeed.Value + Vector3.up * 1f; foreach (Rigidbody componentsInChild in ((Component)physRig).GetComponentsInChildren<Rigidbody>()) { if (!((Object)(object)componentsInChild == (Object)null) && !componentsInChild.isKinematic) { componentsInChild.velocity += val2; } } } catch (Exception ex2) { Melon<Blue0k37Mod>.Logger.Error("dropkick lunge: " + ex2); } Vector3 val3 = val; Log("start dir=" + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString() + " lieDown=" + _playerRagdolled); } private static bool IsUnder(Transform t, Transform parent) { try { return (Object)(object)parent != (Object)null && (Object)(object)t != (Object)null && t.IsChildOf(parent); } catch { return false; } } private static void SetupPose(PhysicsRig phys, Vector3 dir) { //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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_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_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) _madeLegsPhysical = false; try { if (((Object)(object)phys.legLf != (Object)null && (Object)(object)phys.legLf.rbUpper != (Object)null && phys.legLf.rbUpper.isKinematic) || ((Object)(object)phys.legRt != (Object)null && (Object)(object)phys.legRt.rbUpper != (Object)null && phys.legRt.rbUpper.isKinematic)) { phys.PhysicalLegs(); _madeLegsPhysical = true; } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("dropkick physical legs: " + ex); } try { Quaternion val = Quaternion.LookRotation(dir, Vector3.up); float num = LieAngle.Value * ((float)Math.PI / 180f); Vector3 val2 = -dir * Mathf.Cos(num) + Vector3.up * Mathf.Sin(num); Vector3 normalized = ((Vector3)(ref val2)).normalized; val2 = Vector3.up - normalized * Vector3.Dot(Vector3.up, normalized); Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, normalized) * Quaternion.Inverse(val); Transform parent = null; Transform parent2 = null; try { if ((Object)(object)phys.leftHand != (Object)null) { parent = ((Component)phys.leftHand).transform; } } catch { } try { if ((Object)(object)phys.rightHand != (Object)null) { parent2 = ((Component)phys.rightHand).transform; } } catch { } if (InstantLie.Value) { int num2 = 0; try { Vector3 position = ((Rig)phys).m_pelvis.position; foreach (Rigidbody componentsInChild in ((Component)phys).GetComponentsInChildren<Rigidbody>()) { if (!((Object)(object)componentsInChild == (Object)null) && !componentsInChild.isKinematic && !IsUnder(((Component)componentsInChild).transform, parent) && !IsUnder(((Component)componentsInChild).transform, parent2)) { Vector3 val4 = position + val3 * (componentsInChild.position - position); Quaternion val5 = val3 * componentsInChild.rotation; componentsInChild.position = val4; componentsInChild.rotation = val5; ((Component)componentsInChild).transform.SetPositionAndRotation(val4, val5); componentsInChild.angularVelocity = Vector3.zero; num2++; } } } catch (Exception ex2) { Melon<Blue0k37Mod>.Logger.Error("dropkick instant lie: " + ex2); } Log("instant lie snapped=" + num2); } List<Rigidbody> list = new List<Rigidbody>(); List<Quaternion> list2 = new List<Quaternion>(); foreach (Rigidbody componentsInChild2 in ((Component)phys).GetComponentsInChildren<Rigidbody>()) { if (!((Object)(object)componentsInChild2 == (Object)null) && !componentsInChild2.isKinematic && !IsUnder(((Component)componentsInChild2).transform, parent) && !IsUnder(((Component)componentsInChild2).transform, parent2)) { list.Add(componentsInChild2); list2.Add(InstantLie.Value ? componentsInChild2.rotation : (val3 * componentsInChild2.rotation)); } } Vector3 legDir = -normalized; string text = ""; try { text = text + "L:" + StraightenLeg(phys.legLf, legDir, list, list2); } catch (Exception ex3) { Melon<Blue0k37Mod>.Logger.Error("dropkick leg L: " + ex3); } try { text = text + " R:" + StraightenLeg(phys.legRt, legDir, list, list2); } catch (Exception ex4) { Melon<Blue0k37Mod>.Logger.Error("dropkick leg R: " + ex4); } try { _legL = phys.legLf; _legR = phys.legRt; if ((Object)(object)_legL != (Object)null) { _legLForce = _legL.forceMultiplier; _legL.forceMultiplier = 0f; } if ((Object)(object)_legR != (Object)null) { _legRForce = _legR.forceMultiplier; _legR.forceMultiplier = 0f; } text = text + " servoL=" + _legLForce.ToString("0.##") + " servoR=" + _legRForce.ToString("0.##"); } catch (Exception ex5) { Melon<Blue0k37Mod>.Logger.Error("dropkick leg servo: " + ex5); } Log("pose rbs=" + list.Count + " madePhysical=" + _madeLegsPhysical + " " + text); _poseRbs = list.ToArray(); _poseTargets = list2.ToArray(); } catch (Exception ex6) { _poseRbs = null; _poseTargets = null; Melon<Blue0k37Mod>.Logger.Error("dropkick pose setup: " + ex6); } } private static void SetTarget(List<Rigidbody> rbs, List<Quaternion> tg, Rigidbody rb, Quaternion target) { //IL_0049: 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) if (!((Object)(object)rb == (Object)null)) { int num = rbs.FindIndex((Rigidbody x) => (Object)(object)x != (Object)null && ((Il2CppObjectBase)x).Pointer == ((Il2CppObjectBase)rb).Pointer); if (num >= 0) { tg[num] = target; return; } rbs.Add(rb); tg.Add(target); } } private static string StraightenLeg(PhysLimb leg, Vector3 legDir, List<Rigidbody> rbs, List<Quaternion> tg) { //IL_00bc: 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) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f2: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0147: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)leg == (Object)null) { return "noLeg"; } Rigidbody rbUpper = leg.rbUpper; Rigidbody rbLower = leg.rbLower; Rigidbody rbEnd = leg.rbEnd; string result = "up=" + ((Object)(object)rbUpper != (Object)null) + "/k=" + ((Object)(object)rbUpper != (Object)null && rbUpper.isKinematic) + " low=" + ((Object)(object)rbLower != (Object)null) + " end=" + ((Object)(object)rbEnd != (Object)null); if ((Object)(object)rbUpper == (Object)null || (Object)(object)rbLower == (Object)null) { return result; } Vector3 val = rbLower.position - rbUpper.position; if (((Vector3)(ref val)).sqrMagnitude > 1E-06f) { SetTarget(rbs, tg, rbUpper, Quaternion.FromToRotation(((Vector3)(ref val)).normalized, legDir) * rbUpper.rotation); } _ = rbLower.rotation; if ((Object)(object)rbEnd != (Object)null) { Vector3 val2 = rbEnd.position - rbLower.position; if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { Quaternion val3 = Quaternion.FromToRotation(((Vector3)(ref val2)).normalized, legDir); SetTarget(rbs, tg, rbLower, val3 * rbLower.rotation); SetTarget(rbs, tg, rbEnd, val3 * rbEnd.rotation); } } return result; } private static void RestoreLegServos() { try { if ((Object)(object)_legL != (Object)null && _legLForce >= 0f) { _legL.forceMultiplier = _legLForce; } } catch { } try { if ((Object)(object)_legR != (Object)null && _legRForce >= 0f) { _legR.forceMultiplier = _legRForce; } } catch { } _legL = null; _legR = null; _legLForce = -1f; _legRForce = -1f; } private static void HoldPose() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0051: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00af: 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_00c6: 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_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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (_poseRbs == null || _poseRbs.Length == 0) { return; } float num = Mathf.Max(1f, PoseStrength.Value); Vector3 val = Vector3.zero; int num2 = 0; for (int i = 0; i < _poseRbs.Length; i++) { Rigidbody val2 = _poseRbs[i]; if (!((Object)(object)val2 == (Object)null)) { val += val2.velocity; num2++; } } if (num2 == 0) { return; } val /= (float)num2; float num3 = default(float); Vector3 val5 = default(Vector3); for (int j = 0; j < _poseRbs.Length; j++) { Rigidbody val3 = _poseRbs[j]; if ((Object)(object)val3 == (Object)null || val3.isKinematic) { continue; } Quaternion val4 = _poseTargets[j] * Quaternion.Inverse(val3.rotation); ((Quaternion)(ref val4)).ToAngleAxis(ref num3, ref val5); if (!float.IsNaN(val5.x) && !(((Vector3)(ref val5)).sqrMagnitude < 1E-06f)) { if (num3 > 180f) { num3 -= 360f; } Vector3 angularVelocity = val5 * (num3 * ((float)Math.PI / 180f) * num); if (((Vector3)(ref angularVelocity)).magnitude > 50f) { angularVelocity = ((Vector3)(ref angularVelocity)).normalized * 50f; } val3.angularVelocity = angularVelocity; val3.velocity = Vector3.Lerp(val3.velocity, val, 0.5f); } } } private static void EndPlayerRagdoll() { _poseRbs = null; _poseTargets = null; RestoreLegServos(); if (!_playerRagdolled) { return; } _playerRagdolled = false; try { PhysicsRig val = (((Object)(object)_ragdollRig != (Object)null) ? _ragdollRig : Blue0k37Mod.GetPhysRig()); if ((Object)(object)val != (Object)null) { val.UnRagdollRig(); } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("dropkick stand up: " + ex); } if (_madeLegsPhysical) { try { PhysicsRig val2 = (((Object)(object)_ragdollRig != (Object)null) ? _ragdollRig : Blue0k37Mod.GetPhysRig()); if ((Object)(object)val2 != (Object)null) { val2.KinematicLegs(); } } catch (Exception ex2) { Melon<Blue0k37Mod>.Logger.Error("dropkick kinematic legs: " + ex2); } _madeLegsPhysical = false; } _ragdollRig = null; } internal static void FixedUpdate() { ApplyGravAssist(); ProcessHitByPlayer(); if (_groundKick) { GroundKickFixed(); } else { if (!_kicking) { return; } PhysicsRig physRig = Blue0k37Mod.GetPhysRig(); if ((Object)(object)physRig == (Object)null || (Object)(object)((Rig)physRig).m_pelvis == (Object)null) { _kicking = false; EndPlayerRagdoll(); return; } float num = Time.time - _kickStart; if (num > KickTime.Value) { _kicking = false; EndPlayerRagdoll(); return; } if (!_playerRagdolled) { bool flag = false; try { flag = (Object)(object)physRig.physG != (Object)null && physRig.physG.isGrounded; } catch { } if (flag && num > 0.15f) { _kicking = false; return; } } if (_playerRagdolled) { HoldPose(); } ProcessHits(physRig, null); } } private static void StartGroundKick(PhysicsRig phys, Vector3 dir) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) PhysLimb val = null; try { val = (GroundKickLeft.Value ? phys.legLf : phys.legRt); } catch { } if ((Object)(object)val == (Object)null || (Object)(object)val.rbUpper == (Object)null || (Object)(object)val.rbLower == (Object)null) { Log("ground kick: leg not found"); return; } _kickDir = dir; _groundKick = true; _gkStart = Time.time; _gkLeg = val; _gkRig = phys; _hitThisKick.Clear(); _cooldownEnd = Time.time + Mathf.Max(0.2f, GroundKickTime.Value) + Mathf.Max(0f, GroundKickCooldown.Value); _gkMadePhysical = false; try { if (val.rbUpper.isKinematic) { phys.PhysicalLegs(); _gkMadePhysical = true; } } catch (Exception ex) { Melon<Blue0k37Mod>.Logger.Error("ground kick physical legs: " + ex); } try { _gkServo = val.forceMultiplier; val.forceMultiplier = 0f; } catch { _gkServo = -1f; } _gkBodyRbs = null; _gkMaxVy = 0f; try { IntPtr pointer = ((Il2CppObjectBase)val.rbUpper).Pointer; IntPtr pointer2 = ((Il2CppObjectBase)val.rbLower).Pointer; IntPtr intPtr = (((Object)(object)val.rbEnd != (Object)null) ? ((Il2CppObjectBase)val.rbEnd).Pointer : IntPtr.Zero); Il2CppArrayBase<Rigidbody> componentsInChildren = ((Component)phys).GetComponentsInChildren<Rigidbody>(); List<Rigidbody> list = new List<Rigidbody>(); for (int i = 0; i < componentsInChildren.Length; i++) { Rigidbody val2 = componentsInChildren[i]; if (!((Object)(object)val2 == (Object)null)) { IntPtr pointer3 = ((Il2CppObjectBase)val2).Pointer; if (!(pointer3 == pointer) && !(pointer3 == pointer2) && !(pointer3 == intPtr)) { list.Add(val2); } } } _gkBodyRbs = list.ToArray(); } catch (Exception ex2) { _gkBodyRbs = null; Melon<Blue0k37Mod>.Logger.Error("ground kick body rbs: " + ex2); } Log("ground kick start leg=" + (GroundKickLeft.Value ? "L" : "R") + " madePhysical=" + _gkMadePhysical + " servo=" + _gkServo.ToString("0.##")); } private static void GroundKickFixed() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) float num = Time.time - _gkStart; PhysicsRig physRig = Blue0k37Mod.GetPhysRig(); PhysLimb gkLeg = _gkLeg; if ((Object)(object)physRig == (Object)null || (Object)(object)gkLeg == (Object)null || num > Mathf.Max(0.2f, GroundKickTime.Value)) { EndGroundKick(restoreLegs: true); return; } Rigidbody val = null; Rigidbody val2 = null; Rigidbody val3 = null; try { val = gkLeg.rbUpper; val2 = gkLeg.rbLower; val3 = gkLeg.rbEnd; } catch { } if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { EndGroundKick(restoreLegs: true); return; } float num2 = Mathf.Clamp(GroundKickHeight.Value, -0.5f, 1f); Vector3 val4 = _kickDir + Vector3.up * num2; Vector3 normalized = ((Vector3)(ref val4)).normalized; float num3 = Mathf.Clamp01(num / 0.12f); num3 = num3 * num3 * (3f - 2f * num3); val4 = Vector3.Slerp(Vector3.down, normalized, num3); Vector3 normalized2 = ((Vector3)(ref val4)).normalized; try { Vector3 val5 = (val.angularVelocity = TurnToward(val2.position - val.position, normalized2)); Vector3 angularVelocity = val5; if ((Object)(object)val3 != (Object)null) { angularVelocity = TurnToward(val3.position - val2.position, normalized2); } val2.angularVelocity = angularVelocity; if ((Object)(object)val3 != (Object)null) { val3.angularVelocity = angularVelocity; } } catch { } GroundKickHoldDown(); if (num >= 0.06f) { ProcessHits(physRig, gkLeg); } } private static void GroundKickHoldDown() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) Rigidbody[] gkBodyRbs = _gkBodyRbs; if (gkBodyRbs