Decompiled source of ImpactBlackout v1.0.0
Mods/ImpactBlackout.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib; using BoneLib.BoneMenu; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Bonelab; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.VRMK; using ImpactBlackout; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.XR; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Main), "Impact Blackout", "2.2.1", "ImpactBlackout", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ImpactBlackout")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.2.1.0")] [assembly: AssemblyInformationalVersion("2.2.1")] [assembly: AssemblyProduct("ImpactBlackout")] [assembly: AssemblyTitle("ImpactBlackout")] [assembly: AssemblyVersion("2.2.1.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ImpactBlackout { internal readonly record struct LandingEvidence(float DropMeters, float PeakDownwardSpeed) { public bool Landed => PeakDownwardSpeed > 0f; } internal sealed class AirborneLanding { private const float LandingWindow = 0.25f; private float _previousY; private float _airbornePeakY; private float _peakDownwardSpeed; private float _timeSinceFastDescent; private float _touchdownTime; private int _verticalStopFrames; private bool _ready; private bool _airborne; private bool _touchdown; private bool _confirmedSupport; public bool NeedsSupportProbe(float verticalVelocity) { if (_airborne && _peakDownwardSpeed >= 3f) { return verticalVelocity > 0f - _peakDownwardSpeed + 1.5f; } return false; } public LandingEvidence Sample(float y, float verticalVelocity, bool grounded, bool landingContact, float dt) { if (!float.IsFinite(y) || !float.IsFinite(verticalVelocity) || !float.IsFinite(dt) || dt <= 0f) { Reset(); return default(LandingEvidence); } float num = (_ready ? _previousY : y); _ready = true; _previousY = y; if (!_airborne) { if (grounded && verticalVelocity >= -2f && verticalVelocity <= 1.5f) { return default(LandingEvidence); } _airborne = true; _airbornePeakY = Math.Max(num, y); } _airbornePeakY = Math.Max(_airbornePeakY, y); float num2 = 0f - verticalVelocity; float dropMeters = Math.Max(0f, _airbornePeakY - y); if (num2 > 2f) { _peakDownwardSpeed = Math.Max(_peakDownwardSpeed, num2); _timeSinceFastDescent = 0f; } else { _timeSinceFastDescent += dt; } bool flag = landingContact || (grounded && num2 <= 3f && verticalVelocity <= 1f); bool flag2 = num2 <= Math.Max(1f, _peakDownwardSpeed - 1.5f); if (!_touchdown && _peakDownwardSpeed > 2f && flag2 && (flag || num2 <= 1f) && _timeSinceFastDescent <= 0.25f) { _touchdown = true; } if (_touchdown) { _confirmedSupport |= flag; _touchdownTime += dt; bool flag3 = Math.Abs(verticalVelocity) <= 1.2f && Math.Abs(y - num) <= Math.Max(0.06f, 1.2f * dt); _verticalStopFrames = (flag3 ? (_verticalStopFrames + 1) : 0); if (_confirmedSupport && (_verticalStopFrames >= 2 || (landingContact && verticalVelocity > 1.2f))) { LandingEvidence result = new LandingEvidence(dropMeters, _peakDownwardSpeed); ResetFall(); return result; } if (_touchdownTime >= 0.25f) { if (num2 <= 2f) { ResetFall(); } else { ClearTouchdown(); } } } else if (flag && (_peakDownwardSpeed <= 2f || _timeSinceFastDescent > 0.25f)) { ResetFall(); } return default(LandingEvidence); } public void Reset() { _ready = false; _previousY = 0f; ResetFall(); } private void ResetFall() { _airborne = false; _airbornePeakY = (_peakDownwardSpeed = (_timeSinceFastDescent = 0f)); ClearTouchdown(); } private void ClearTouchdown() { _touchdown = (_confirmedSupport = false); _touchdownTime = 0f; _verticalStopFrames = 0; } } internal sealed class AvatarInjuryScope { private int _instance; private string? _avatarId; private bool _awaitingIdentity; public bool Observe(int instance, string? avatarId, bool confirmedSwitch) { if (instance == 0) { return false; } if (string.IsNullOrWhiteSpace(avatarId)) { avatarId = null; } if (instance == _instance) { if (_awaitingIdentity && avatarId != null && _avatarId != null && !string.Equals(_avatarId, avatarId, StringComparison.Ordinal)) { _avatarId = avatarId; _awaitingIdentity = false; return true; } if (_avatarId == null && avatarId != null) { _avatarId = avatarId; _awaitingIdentity = false; } return false; } bool flag = _instance != 0; bool flag2 = flag && ((_avatarId != null && avatarId != null) ? (!string.Equals(_avatarId, avatarId, StringComparison.Ordinal)) : confirmedSwitch); _awaitingIdentity = flag && !flag2; _instance = instance; _avatarId = avatarId ?? (flag2 ? null : _avatarId); return flag2; } public void Reset() { _instance = 0; _avatarId = null; _awaitingIdentity = false; } } internal enum StainKind { Blood, Bruise, Smear, Spatter } internal sealed class WorldStainAssets { private readonly Texture2D?[] _textures = (Texture2D?[])(object)new Texture2D[3]; private readonly Material?[] _materials = (Material?[])(object)new Material[3]; private Shader? _shader; private Mesh? _quadMesh; private bool _searchedShader; public Action<string>? LogUnavailable { get; set; } public Material? MaterialFor(StainKind kind) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown if (UnityLifetime.IsAlive((Object?)(object)_materials[(int)kind])) { return _materials[(int)kind]; } if (!_searchedShader) { _searchedShader = true; _shader = Shader.Find("Unlit/Transparent"); if (!UnityLifetime.IsAlive((Object?)(object)_shader) || !_shader.isSupported) { _shader = Shader.Find("Sprites/Default"); } if (!UnityLifetime.IsAlive((Object?)(object)_shader) || !_shader.isSupported) { LogUnavailable?.Invoke("Neither stock world decal shader is available."); } } if (!UnityLifetime.IsAlive((Object?)(object)_shader) || !_shader.isSupported) { return null; } if (!UnityLifetime.IsAlive((Object?)(object)_textures[(int)kind])) { _textures[(int)kind] = CreateTexture(kind); } Material val = new Material(_shader); _materials[(int)kind] = val; val.mainTexture = (Texture)(object)_textures[(int)kind]; val.renderQueue = 3005; return val; } public GameObject CreateQuad(string name, Material material) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); try { ((Object)val).name = name; val.layer = 0; Collider component = val.GetComponent<Collider>(); if (UnityLifetime.IsAlive((Object?)(object)component)) { component.enabled = false; UnityLifetime.Destroy((Object?)(object)component); } MeshRenderer component2 = val.GetComponent<MeshRenderer>(); if (!UnityLifetime.IsAlive((Object?)(object)component2)) { throw new InvalidOperationException("Stain quad renderer unavailable."); } MeshFilter component3 = val.GetComponent<MeshFilter>(); if (UnityLifetime.IsAlive((Object?)(object)component3)) { if (!UnityLifetime.IsAlive((Object?)(object)_quadMesh) && UnityLifetime.IsAlive((Object?)(object)component3.sharedMesh)) { Mesh val2 = (_quadMesh = Object.Instantiate<Mesh>(component3.sharedMesh)); ((Object)val2).hideFlags = (HideFlags)32; Il2CppStructArray<Color32> val3 = new Il2CppStructArray<Color32>((long)val2.vertexCount); for (int i = 0; i < ((Il2CppArrayBase<Color32>)(object)val3).Length; i++) { ((Il2CppArrayBase<Color32>)(object)val3)[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } val2.colors32 = val3; } if (UnityLifetime.IsAlive((Object?)(object)_quadMesh)) { component3.sharedMesh = _quadMesh; } } ((Renderer)component2).sharedMaterial = material; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component2).receiveShadows = false; ((Renderer)component2).lightProbeUsage = (LightProbeUsage)0; ((Renderer)component2).reflectionProbeUsage = (ReflectionProbeUsage)0; return val; } catch { UnityLifetime.Destroy((Object?)(object)val); throw; } } public static Texture2D CreateTexture(StainKind kind) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); try { ((Object)val).name = $"ImpactBlackout.{kind}"; ((Object)val).hideFlags = (HideFlags)32; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Il2CppStructArray<Color32> val2 = new Il2CppStructArray<Color32>(16384L); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { float num = (2f * (float)j + 1f) / 128f - 1f; float num2 = (2f * (float)i + 1f) / 128f - 1f; float num3 = MathF.Sin(num * 51f + MathF.Cos(num2 * 23f)) * MathF.Sin(num2 * 37f - 7f * num); float num4 = MathF.Sin(num * 16f + MathF.Sin(num2 * 18f)) * MathF.Cos(num2 * 14f + num * 8f); float num5 = MathF.Sqrt(num * num + num2 * num2); float num6 = kind switch { StainKind.Bruise => Lobe(num5 + 0.1f * num4, 0.92f) * 0.72f, StainKind.Smear => Lobe(MathF.Sqrt(3.1f * num * num + 0.83f * num2 * num2) + 0.18f * num4, 0.91f) * (0.65f + 0.18f * num3), StainKind.Spatter => Lobe(MathF.Abs(num5 - 0.79f) + 0.14f * num4, 0.21f) * MotorRecovery.Smooth(0.65f + 0.5f * num3), _ => Lobe(num5 + 0.15f * num4 + 0.04f * num3, 0.84f), } * MotorRecovery.Smooth((1f - MathF.Max(MathF.Abs(num), MathF.Abs(num2))) / 0.17f); ((Il2CppArrayBase<Color32>)(object)val2)[i * 128 + j] = ((kind == StainKind.Bruise) ? new Color32((byte)(71f + 23f * num4), (byte)15, (byte)41, (byte)(255f * Mathf.Clamp01(num6))) : new Color32((byte)(102f + 22f * num4), (byte)7, (byte)19, (byte)(255f * Mathf.Clamp01(num6)))); } } val.SetPixels32(val2); val.Apply(false, true); return val; } catch { UnityLifetime.Destroy((Object?)(object)val); throw; } } private static float Lobe(float r, float edge) { return MotorRecovery.Smooth((edge - r) / (edge * 0.54f)); } public void Dispose() { UnityLifetime.Destroy((Object?)(object)_quadMesh); _quadMesh = null; for (int i = 0; i < _materials.Length; i++) { UnityLifetime.Destroy((Object?)(object)_materials[i]); UnityLifetime.Destroy((Object?)(object)_textures[i]); _materials[i] = null; _textures[i] = null; } } } internal sealed class AvatarWoundVisuals { private static readonly InjuryZone[] Zones = new InjuryZone[7] { InjuryZone.Chest, InjuryZone.Pelvis, InjuryZone.Head, InjuryZone.LeftArm, InjuryZone.RightArm, InjuryZone.LeftLeg, InjuryZone.RightLeg }; private readonly Rigidbody?[] _bones = (Rigidbody?[])(object)new Rigidbody[7]; private readonly GameObject?[] _marks = (GameObject?[])(object)new GameObject[14]; private InjuryZone _bruises; private InjuryZone _blood; public void Bind(PhysicsRig rig) { if (UnityLifetime.IsAlive((Object?)(object)rig)) { PhysTorso torso = rig.torso; if (UnityLifetime.IsAlive((Object?)(object)torso)) { _bones[0] = torso.rbChest; _bones[1] = torso.rbPelvis; _bones[2] = torso.rbHead; } Hand leftHand = rig.leftHand; Hand rightHand = rig.rightHand; PhysHand val = (UnityLifetime.IsAlive((Object?)(object)leftHand) ? leftHand.physHand : null); PhysHand val2 = (UnityLifetime.IsAlive((Object?)(object)rightHand) ? rightHand.physHand : null); _bones[3] = (UnityLifetime.IsAlive((Object?)(object)val) ? val.rbLower : null); _bones[4] = (UnityLifetime.IsAlive((Object?)(object)val2) ? val2.rbLower : null); PhysLimb legLf = rig.legLf; PhysLimb legRt = rig.legRt; _bones[5] = (UnityLifetime.IsAlive((Object?)(object)legLf) ? legLf.rbLower : null); _bones[6] = (UnityLifetime.IsAlive((Object?)(object)legRt) ? legRt.rbLower : null); } } public void Mark(InjuryZone zones, bool blood) { if ((zones & InjuryZone.Legs) != InjuryZone.None) { zones |= InjuryZone.LeftLeg | InjuryZone.RightLeg; } _bruises |= zones; if (blood) { _blood |= zones; } } public void Present(bool visible, WorldStainAssets assets) { if (!visible) { ClearObjects(); return; } for (int i = 0; i < Zones.Length; i++) { if ((_bruises & Zones[i]) != InjuryZone.None && UnityLifetime.IsAlive((Object?)(object)_bones[i])) { Add(i, i, assets, assets.MaterialFor(StainKind.Bruise), blood: false); if ((_blood & Zones[i]) != InjuryZone.None) { Add(i, i + Zones.Length, assets, assets.MaterialFor(StainKind.Blood), blood: true); } } } } private void Add(int boneIndex, int index, WorldStainAssets assets, Material? material, bool blood) { //IL_008f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_009e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) if (UnityLifetime.IsAlive((Object?)(object)_marks[index]) || !UnityLifetime.IsAlive((Object?)(object)material) || !UnityLifetime.IsAlive((Object?)(object)_bones[boneIndex])) { return; } Rigidbody val = _bones[boneIndex]; Transform transform = ((Component)val).transform; bool flag = boneIndex >= 3; Vector3 val3; if (flag) { Vector3 forward = transform.forward; Vector3 right = transform.right; bool flag2 = ((boneIndex == 3 || boneIndex == 5) ? true : false); Vector3 val2 = forward + right * (flag2 ? (-0.8f) : 0.8f); val3 = ((Vector3)(ref val2)).normalized; } else { val3 = transform.forward; } Vector3 val4 = val3; if (boneIndex == 2) { val3 = transform.right + transform.forward * 0.48f; val4 = ((Vector3)(ref val3)).normalized; } if (blood) { val3 = val4 + transform.right * 0.28f; val4 = ((Vector3)(ref val3)).normalized; } float num = (flag ? 0.065f : ((boneIndex == 2) ? 0.12f : 0.18f)); Collider component = ((Component)val).GetComponent<Collider>(); Vector3 val5 = val.worldCenterOfMass + (num + 0.008f) * val4; if (UnityLifetime.IsAlive((Object?)(object)component) && component.enabled) { Vector3 worldCenterOfMass = val.worldCenterOfMass; Vector3 val6 = val4; Bounds bounds = component.bounds; val3 = ((Bounds)(ref bounds)).extents; Vector3 val7 = component.ClosestPoint(worldCenterOfMass + val6 * Math.Max(0.35f, ((Vector3)(ref val3)).magnitude)); val3 = val7 - val.worldCenterOfMass; if (((Vector3)(ref val3)).sqrMagnitude > 0.0004f) { val5 = val7 + 0.008f * val4; } } GameObject val8 = assets.CreateQuad(blood ? "ImpactBlackout.BodyBlood" : "ImpactBlackout.Bruise", material); _marks[index] = val8; Transform transform2 = val8.transform; transform2.SetPositionAndRotation(val5, Quaternion.LookRotation(-val4, transform.up)); float num2 = (flag ? 0.135f : ((boneIndex == 2) ? 0.15f : 0.25f)); if (blood) { num2 *= 0.79f; } transform2.localScale = new Vector3(num2, num2 * (flag ? 1.2f : 0.83f), 1f); transform2.SetParent(transform, true); } private void ClearObjects() { for (int i = 0; i < _marks.Length; i++) { UnityLifetime.Destroy((Object?)(object)_marks[i]); _marks[i] = null; } } public void Unbind() { ClearObjects(); Array.Clear(_bones, 0, _bones.Length); } public void Clear() { Unbind(); _bruises = (_blood = InjuryZone.None); } } internal enum BlackoutStage { Clear, SnapIn, Unconscious, BreathClosing, BreathHeld, FaintProdrome, FaintUnconscious, HeadRush, Groggy } internal readonly record struct BlackoutFrame(float BlackAlpha, float VeilGray, float TunnelAlpha, float TunnelRadius, float GameClarity, float RingGain, float RingPitch, float HeartGain, float HeartBpm, float HeartMuffle) { public float BreathingGain { get; init; } = 0f; public float BreathingRate { get; init; } = 0f; public float PulseThrob { get; init; } = 0f; public float BloodSpatter { get; init; } = 0f; public const float OpenRadius = 1.65f; public const float PinholeRadius = 0.022f; public static readonly BlackoutFrame Clear = new BlackoutFrame(0f, 0f, 0f, 1.65f, 1f, 0f, 1f, 0f, 70f, 0f); } internal sealed class BlackoutController { private const float BuckleSeconds = 1.15f; private double _startedAt; private double _lastTick = -1.0; private double _acceptAfter; private double _nextHeadRush; private double _lastWake = double.NegativeInfinity; private float _faintBudget = NextFaintBudget(); private float _faintWarning; private float _severity; private float _snapDuration; private float _holdDuration; private float _breathDeficit; private float _lockedSeconds; private BlackoutFrame _recoveryOrigin; private bool _fullRecovery; private float _recoveryStrength; private float _recoveryProgress; private float _wakeSeconds; private bool _recoveringFromFaint; private bool _forcedBlackout; private bool _microsleep; private bool _forcePhysical; private bool _physicalCollapseEntered; private bool _cumulativeTrauma; private double _groggyFinishedAt = double.PositiveInfinity; private float _postGroggyHold; public const float WakeDarkSeconds = 1.5f; public BlackoutStage Stage { get; private set; } public BlackoutFrame Frame { get; private set; } = BlackoutFrame.Clear; public int GaspSerial { get; private set; } public int WakeSerial { get; private set; } public int MotorWakeSerial { get; private set; } public float WakeAge => _wakeSeconds; public float SecondsUntilFaint { get; private set; } = float.PositiveInfinity; public float GaspStrength { get; private set; } public bool HasEffect { get { if (Stage == BlackoutStage.Clear && !(Frame.RingGain > 0f)) { return Frame.BreathingGain > 0f; } return true; } } public bool CanHoldBreath(double now) { BlackoutStage stage = Stage; if ((uint)(stage - 3) > 1u) { return CanStart(now); } return true; } public bool CanStart(double now) { BlackoutStage stage = Stage; bool flag = ((stage == BlackoutStage.Clear || stage == BlackoutStage.HeadRush) ? true : false); if (flag && now >= _acceptAfter) { if (_physicalCollapseEntered) { return now >= _groggyFinishedAt + (double)_postGroggyHold; } return true; } return false; } public bool TraumaApneaAt(double now) { if (_cumulativeTrauma && _holdDuration >= 12f && Stage == BlackoutStage.Unconscious && Frame.BlackAlpha >= 0.98f) { return now - _startedAt - (double)_snapDuration >= 3.0; } return false; } public double PauseAt(double now) { double num = ((_lastTick < 0.0 || now <= _lastTick) ? 0.0 : (now - _lastTick)); _lastTick = now; _startedAt += num; _acceptAfter += num; _nextHeadRush += num; if (double.IsFinite(_lastWake)) { _lastWake += num; } if (double.IsFinite(_groggyFinishedAt)) { _groggyFinishedAt += num; } return num; } public void Start(double now, float severity, ModPreferences preferences, bool allowMotorCollapse = false) { if (double.IsFinite(now)) { Reset(); _severity = (float.IsFinite(severity) ? Mathf.Clamp01(severity) : 0f); _startedAt = (_lastTick = now); _acceptAfter = Math.Max(_acceptAfter, now + (double)preferences.RetriggerCooldown); _snapDuration = Mathf.Lerp(0.5f, 0.2f, _severity); if (allowMotorCollapse && preferences.ProgressiveCollapse && IsFullImpact(preferences.MaxBlackoutAlpha)) { _snapDuration = 1.15f; } _holdDuration = Mathf.Lerp(0.5f, 6f, Mathf.Pow(_severity, 1.6f)) * preferences.HoldMultiplier; Stage = BlackoutStage.SnapIn; } } public void StartTrauma(double now, float holdSeconds, ModPreferences preferences, bool allowMotorCollapse = false, bool forcePhysical = false, bool cumulative = false) { Start(now, 1f, preferences); _forcedBlackout = true; _forcePhysical = forcePhysical; _cumulativeTrauma = cumulative; _microsleep = holdSeconds < 1.3f; _holdDuration = holdSeconds; _snapDuration = (_microsleep ? 0.07f : ((forcePhysical || (allowMotorCollapse && preferences.ProgressiveCollapse)) ? 1.15f : 0.24f)); } public void StartFaint(double now) { if (CanStart(now)) { Reset(); _startedAt = (_lastTick = now); _faintWarning = 3f; _faintBudget = NextFaintBudget(); Stage = BlackoutStage.FaintProdrome; } } public void StartHeadRush(double now) { if (CanStart(now)) { Reset(); _startedAt = (_lastTick = now); _nextHeadRush = now + 30.0; Stage = BlackoutStage.HeadRush; } } public void Tick(double now, ModPreferences preferences, BreathFrame breath = default(BreathFrame), PhysiologySample physiology = default(PhysiologySample), bool allowAmbientTriggers = true, float headRushScale = 1f, bool stabilized = false) { if (!double.IsFinite(now) || now < _lastTick) { Reset(); return; } double lastTick = _lastTick; float num = ((lastTick < 0.0) ? 0f : ((float)(now - lastTick))); _lastTick = now; SecondsUntilFaint = float.PositiveInfinity; if (breath.Holding && CanHoldBreath(now)) { TickBreath(breath.Oxygen, num, physiology.Effort); return; } BlackoutStage stage = Stage; if ((uint)(stage - 3) <= 1u) { bool flag = Stage == BlackoutStage.BreathHeld; if (!flag && _breathDeficit < 0.015f) { Reset(); return; } BeginRecovery(Frame, flag, _breathDeficit); if (_breathDeficit > 0.35f) { SignalGasp(Mathf.Lerp(0.35f, 1f, _breathDeficit)); } num = 0f; } else { stage = Stage; if ((uint)(stage - 1) <= 1u) { float maxAlpha = (_forcedBlackout ? 1f : preferences.MaxBlackoutAlpha); double num2 = _startedAt + (double)_snapDuration; double num3 = num2 + (double)_holdDuration; if (now < num2) { Frame = ImpactOnset((float)(now - _startedAt) / _snapDuration, maxAlpha); return; } if (now < num3) { Stage = BlackoutStage.Unconscious; Frame = ImpactHold((float)(now - num2), maxAlpha); return; } BeginRecovery(ImpactHold(_holdDuration, maxAlpha), !_microsleep, Mathf.Lerp(0.38f, 1f, _severity)); if (_forcedBlackout && !_microsleep) { SignalGasp(0.9f); } num = (float)Math.Max(0.0, now - Math.Max(lastTick, num3)); } else { stage = Stage; if ((uint)(stage - 5) <= 1u) { double num4 = _startedAt + (double)_faintWarning; double num5 = num4 + (double)preferences.FaintHoldDuration; if (stabilized && Stage == BlackoutStage.FaintProdrome && now <= num4 && Frame.BlackAlpha < 0.98f) { BeginRecovery(Frame, full: false, 0.55f); _acceptAfter = Math.Max(_acceptAfter, now + 15.0); return; } if (now < num4) { SecondsUntilFaint = (float)(num4 - now); Frame = FaintWarning((float)(now - _startedAt) / _faintWarning); return; } BlackoutFrame blackoutFrame = FaintHold((float)(now - num4)); if (now < num5) { Stage = BlackoutStage.FaintUnconscious; Frame = blackoutFrame; return; } BeginRecovery(blackoutFrame, full: true, 1f); _recoveringFromFaint = true; SignalGasp(0.84f); num = (float)Math.Max(0.0, now - Math.Max(lastTick, num5)); } else if (allowAmbientTriggers && CanStart(now) && physiology.Ready) { if (preferences.RandomFaintEnabled) { float num6 = (float)Math.Clamp(1.0 - (now - _lastWake) / 70.0, 0.0, 1.0); float num7 = (1f + 1.1f * physiology.Fatigue * physiology.Fatigue + 0.65f * physiology.RecentStand + 0.38f * num6) / (60f * preferences.FaintIntervalMinutes); _faintBudget -= Math.Min(num, 0.25f) * num7 * (stabilized ? 0.12f : 1f); if (_faintBudget <= 0f) { StartFaint(now); SecondsUntilFaint = _faintWarning; Frame = FaintWarning(0f); return; } SecondsUntilFaint = _faintBudget / num7 + 3f; } if (physiology.StoodUp && preferences.HeadRushEnabled && preferences.HeadRushIntensity > 0f && now >= _nextHeadRush) { StartHeadRush(now); } } } } if (Stage == BlackoutStage.HeadRush) { float num8 = (float)(now - _startedAt); if (num8 < 27f) { Frame = HeadRush(num8, Mathf.Clamp01(preferences.HeadRushIntensity * headRushScale), physiology); return; } Stage = BlackoutStage.Clear; } if (Stage == BlackoutStage.Groggy || (Stage == BlackoutStage.Clear && Frame.RingGain > 0f && _wakeSeconds > 0f)) { TickRecovery(now, num, preferences); } if (Stage == BlackoutStage.Clear) { BlackoutFrame frame = Frame; float blend = Ramp((float)(now - _lastWake), 0f, 3f); Frame = Exertion(physiology, blend)with { RingGain = frame.RingGain, RingPitch = frame.RingPitch }; } } public CollapseMotor CollapseAt(double now, ModPreferences settings, float oxygenDrainSeconds) { if ((!settings.ProgressiveCollapse && !_forcePhysical) || _microsleep) { _physicalCollapseEntered = false; return default(CollapseMotor); } _postGroggyHold = settings.PostGroggyRagdollHoldSeconds; bool flag = Frame.BlackAlpha >= 0.98f; if (flag) { BlackoutStage stage = Stage; bool flag2 = (uint)(stage - 1) <= 5u; flag = flag2; } if (flag) { _physicalCollapseEntered = true; return new CollapseMotor(1f, Limp: true); } if (_physicalCollapseEntered && now < _groggyFinishedAt + (double)_postGroggyHold) { return new CollapseMotor(1f, Limp: true); } _physicalCollapseEntered = false; switch (Stage) { case BlackoutStage.SnapIn: if (_forcedBlackout || IsFullImpact(settings.MaxBlackoutAlpha)) { return new CollapseMotor(Buckle(_snapDuration - (float)(now - _startedAt)), Limp: false); } break; case BlackoutStage.FaintProdrome: return new CollapseMotor(Buckle(_faintWarning - (float)(now - _startedAt)), Limp: false); case BlackoutStage.BreathClosing: return new CollapseMotor(Buckle((1f - _breathDeficit) * oxygenDrainSeconds), Limp: false); } return default(CollapseMotor); } private static float Buckle(float remaining) { return MotorRecovery.Smooth(1f - remaining / 1.15f); } private bool IsFullImpact(float maxAlpha) { return Mathf.Lerp(0.24f, 1f, _severity) * maxAlpha >= 0.98f; } private BlackoutFrame ImpactOnset(float time, float maxAlpha) { float num = Mathf.Lerp(0.24f, 1f, _severity); float num2 = Ramp(time, 0.66f, 1f); float num3 = 0.38f * Ramp(time, 0f, 0.52f); float num4 = Ramp(time, 0.1f, 0.98f); float num5 = Ramp(time, 0f, 0.9f); BlackoutFrame result = new BlackoutFrame(Mathf.Lerp(num3, 1f, num2) * num * maxAlpha, 0.4f * (1f - num2), Ramp(time, 0.12f, 0.78f) * num * maxAlpha, Mathf.Lerp(1.65f, 0.022f, num4), Mathf.Lerp(1f, 1f - 0.945f * num, num5), 0.68f * num * Ramp(time, 0.22f, 0.98f), 1f, num * num5, Mathf.Lerp(85f, 155f, num5), num2 * 0.85f); result.PulseThrob = num * num5; return result; } private BlackoutFrame ImpactHold(float seconds, float maxAlpha) { float num = Mathf.Lerp(0.24f, 1f, _severity); float num2 = Ramp(seconds, 0f, 0.58f); return new BlackoutFrame(num * maxAlpha, 0f, num * maxAlpha, 0.022f, 1f - 0.945f * num, num * Mathf.Lerp(0.68f, 0.19f, num2), 1f, num * Mathf.Lerp(1f, 0.62f, num2), Mathf.Lerp(155f, 60f, num2), Mathf.Lerp(0.85f, 1f, num2)); } private void TickBreath(float oxygen, float delta, float exertion) { _breathDeficit = 1f - Mathf.Clamp01(oxygen); float num = 115f + 33f * exertion; float num2 = Mathf.Lerp(30f, 12f, exertion); if (oxygen <= 0f) { _lockedSeconds = ((Stage == BlackoutStage.BreathHeld) ? (_lockedSeconds + delta) : 0f); Stage = BlackoutStage.BreathHeld; float num3 = Ramp(_lockedSeconds, 0f, 0.75f); Frame = new BlackoutFrame(1f, 0f, 1f, 0.022f, 0.045f, Mathf.Lerp(0.76f, 0.19f, num3), 1f, Mathf.Lerp(1f, 0.66f, num3), Mathf.Lerp(num - num2, 60f, num3), Mathf.Lerp(0.85f, 1f, num3)); } else { Stage = BlackoutStage.BreathClosing; float breathDeficit = _breathDeficit; float num4 = 0.43f * Ramp(breathDeficit, 0.35f, 0.79f); float num5 = Ramp(breathDeficit, 0.35f, 0.995f); float num6 = Ramp(breathDeficit, 0.9f, 1f); Frame = new BlackoutFrame(Mathf.Lerp(num4, 1f, num6), 0.39f * (1f - num6), Ramp(breathDeficit, 0.35f, 0.88f), Mathf.Lerp(1.65f, 0.022f, num5), 1f - 0.17f * Ramp(breathDeficit, 0.04f, 0.35f) - 0.785f * Ramp(breathDeficit, 0.29f, 1f), 0.76f * Ramp(breathDeficit, 0.35f, 1f), 1f, Ramp(breathDeficit, 0f, 1f), Mathf.Lerp(82f, num, Ramp(breathDeficit, 0.08f, 0.6f)) - num2 * Ramp(breathDeficit, 0.64f, 1f), 0.85f * Ramp(breathDeficit, 0.69f, 1f)) { PulseThrob = Ramp(breathDeficit, 0.2f, 0.73f) }; } } private static BlackoutFrame FaintWarning(float progress) { float num = 0.47f * Ramp(progress, 0.18f, 0.86f); float num2 = Ramp(progress, 0.78f, 1f); float num3 = Ramp(progress, 0f, 0.55f); BlackoutFrame result = new BlackoutFrame(Mathf.Lerp(num, 1f, num2), 0.39f * (1f - num2), Ramp(progress, 0.27f, 0.87f), Mathf.Lerp(1.65f, 0.022f, Ramp(progress, 0.31f, 0.98f)), Mathf.Lerp(1f, 0.065f, Ramp(progress, 0.19f, 1f)), 0.69f * Ramp(progress, 0.48f, 1f), 1f, Ramp(progress, 0f, 0.63f), Mathf.Lerp(78f, 112f, num3) - 57f * Ramp(progress, 0.7f, 1f), num2); result.PulseThrob = num3 * (1f - num2); result.BreathingGain = 0.29f * num3 * (1f - num2); result.BreathingRate = Mathf.Lerp(16f, 26f, num3); return result; } private static BlackoutFrame FaintHold(float seconds) { float num = Ramp(seconds, 0f, 1f); return new BlackoutFrame(1f, 0f, 1f, 0.022f, 0.065f, Mathf.Lerp(0.69f, 0.16f, num), 1f, Mathf.Lerp(1f, 0.51f, num), 55f, 1f); } private static BlackoutFrame HeadRush(float seconds, float intensity, PhysiologySample physiology) { float num = Ramp(seconds, 7f, 10f) * (1f - Ramp(seconds, 10f, 24f)) * intensity; float num2 = Ramp(seconds, 0f, 12f) * (1f - Ramp(seconds, 12f, 27f)) * intensity; BlackoutFrame result = new BlackoutFrame(0.39f * num, 0.42f, 0.54f * num, Mathf.Lerp(1.65f, 0.61f, num), 1f - 0.43f * num, 0.2f * num, 1f, 0.74f * num2, 72f + 38f * num2, 0.3f * num); result.PulseThrob = num2; result.BreathingGain = 0.24f * num2 + 0.28f * physiology.Fatigue; result.BreathingRate = 16f + 11f * num2 + 12f * physiology.Effort; return result; } private static BlackoutFrame Exertion(PhysiologySample motion, float blend) { float num = motion.Fatigue * blend; float num2 = motion.Effort * blend; float num3 = motion.Arousal * blend; float tunnelAlpha = 0.26f * Ramp(num, 0.45f, 1f); return BlackoutFrame.Clear with { TunnelAlpha = tunnelAlpha, TunnelRadius = Mathf.Lerp(1.65f, 0.98f, num), HeartBpm = 70f + 48f * num2 + 39f * num, HeartGain = 0.65f * Ramp(num3, 0.06f, 0.88f), PulseThrob = num3, BreathingRate = 15f + 21f * num2 + 10f * num, BreathingGain = 0.59f * Ramp(0.58f * num2 + 0.72f * num, 0.06f, 1f) }; } private void SignalGasp(float strength) { GaspSerial = ((GaspSerial == int.MaxValue) ? 1 : (GaspSerial + 1)); GaspStrength = strength; } private static float NextFaintBudget() { return 0.55f + 0.45f * (Random.Shared.NextSingle() + Random.Shared.NextSingle()); } private void BeginRecovery(BlackoutFrame origin, bool full, float strength) { _recoveryOrigin = origin; _fullRecovery = full; _recoveryStrength = strength; _recoveryProgress = 0f; _wakeSeconds = 0f; Stage = BlackoutStage.Groggy; if (full) { WakeSerial++; if (origin.BlackAlpha >= 0.98f) { MotorWakeSerial++; } } } private void TickRecovery(double now, float delta, ModPreferences preferences) { _wakeSeconds += delta; float num = (_microsleep ? 0.28f : (_fullRecovery ? preferences.RecoveryDuration : Mathf.Lerp(0.65f, 2.4f, _recoveryStrength))); float num2 = (_recoveryProgress = Mathf.Clamp01(_recoveryProgress + delta / num)); BlackoutFrame recoveryOrigin = _recoveryOrigin; if (preferences.WakeAudio && _fullRecovery && recoveryOrigin.BlackAlpha >= 0.98f && _wakeSeconds < 1.5f) { BlackoutFrame recoveryOrigin2 = _recoveryOrigin; Frame = recoveryOrigin2 with { RingGain = 0f, BreathingGain = 0f }; return; } if (num2 >= 1f) { if (Stage == BlackoutStage.Groggy && _fullRecovery) { _lastWake = now; _acceptAfter = Math.Max(_acceptAfter, now + (_recoveringFromFaint ? 45.0 : Math.Max(3.0, preferences.RetriggerCooldown))); } if (Stage == BlackoutStage.Groggy) { _groggyFinishedAt = now; } Stage = BlackoutStage.Clear; Frame = BlackoutFrame.Clear; } else { if (preferences.WakeAudio && _fullRecovery && recoveryOrigin.BlackAlpha >= 0.98f) { float num3 = Math.Min(0.75f, 1.5f / num); num2 = Mathf.Clamp01((num2 - num3) / (1f - num3)); } float num4 = recoveryOrigin.BlackAlpha * (1f - Ramp(num2, 0f, 0.32f)); float num5 = 0.36f * _recoveryStrength * Ramp(num2, 0f, 0.15f) * (1f - Ramp(num2, 0.28f, 1f)); if (preferences.EyelidBlink && _fullRecovery) { float num6 = Blink(num2, 0.37f, 0.16f) + 0.65f * Blink(num2, 0.68f, 0.18f); num4 += (1f - num4) * 0.54f * _recoveryStrength * num6; } float num7 = num4 + (1f - num4) * num5; float veilGray = ((num7 > 0f) ? ((num4 * recoveryOrigin.VeilGray + (1f - num4) * num5 * 0.48f) / num7) : 0f); float num8 = (_fullRecovery ? (43f * _recoveryStrength * Blink(num2, 0.26f, 0.5f)) : 0f); Frame = new BlackoutFrame(num7, veilGray, recoveryOrigin.TunnelAlpha * (1f - Ramp(num2, 0.47f, 1f)), Mathf.Lerp(recoveryOrigin.TunnelRadius, 1.65f, Ramp(num2, 0f, 0.9f)), Mathf.Lerp(recoveryOrigin.GameClarity, 1f, Ramp(num2, 0f, 1f)), 0f, 1f, recoveryOrigin.HeartGain * (1f - Ramp(num2, 0.16f, 1f)), Mathf.Lerp(recoveryOrigin.HeartBpm, 70f, Ramp(num2, 0f, 1f)) + num8, recoveryOrigin.HeartMuffle * (1f - Ramp(num2, 0f, 0.7f))) { PulseThrob = (_fullRecovery ? (_recoveryStrength * (1f - Ramp(num2, 0.28f, 1f))) : 0f), BreathingGain = 0.66f * _recoveryStrength * (1f - Ramp(num2, 0.06f, 1f)), BreathingRate = Mathf.Lerp(34f, 15f, Ramp(num2, 0f, 1f)) }; } float num9 = (_fullRecovery ? Mathf.Lerp(4f, 7f, _recoveryStrength) : num); float num10 = (_fullRecovery ? Mathf.Max(recoveryOrigin.RingGain, _recoveryStrength * 0.88f) : recoveryOrigin.RingGain); float ringGain = Mathf.Lerp(recoveryOrigin.RingGain, num10, Ramp(_wakeSeconds, 0f, 0.35f)) * (1f - Ramp(_wakeSeconds, 0.35f, num9)); Frame = Frame with { RingGain = ringGain, RingPitch = Mathf.Lerp(recoveryOrigin.RingPitch, 0.88f, Mathf.Clamp01(_wakeSeconds / num9)) }; } public void Interrupt(double now) { if (Stage == BlackoutStage.FaintUnconscious || (Stage == BlackoutStage.Groggy && _recoveringFromFaint)) { _acceptAfter = Math.Max(_acceptAfter, now + 45.0); } else { BlackoutStage stage = Stage; if ((stage == BlackoutStage.Unconscious || stage == BlackoutStage.BreathHeld || stage == BlackoutStage.Groggy) ? true : false) { _acceptAfter = Math.Max(_acceptAfter, now + 3.0); } } Reset(); } public void Reset() { Stage = BlackoutStage.Clear; Frame = BlackoutFrame.Clear; _lastTick = -1.0; _lockedSeconds = 0f; _wakeSeconds = 0f; _recoveringFromFaint = false; _forcedBlackout = (_microsleep = (_forcePhysical = false)); _physicalCollapseEntered = (_cumulativeTrauma = false); _groggyFinishedAt = double.PositiveInfinity; GaspStrength = 0f; SecondsUntilFaint = float.PositiveInfinity; } public void ResetLevel() { Reset(); _acceptAfter = (_nextHeadRush = 0.0); _lastWake = double.NegativeInfinity; _faintBudget = NextFaintBudget(); } private static float Ramp(float value, float from, float to) { float num = Mathf.Clamp01((value - from) / (to - from)); return num * num * (3f - 2f * num); } private static float Blink(float progress, float center, float width) { float num = (progress - center) / width + 0.5f; if (num <= 0f || num >= 1f) { return 0f; } float num2 = Mathf.Sin(num * (float)Math.PI); return num2 * num2; } } internal sealed class BlackoutOverlay { private const float Distance = 0.25f; private const float BlackOffset = 0.01f; private const float QuadSize = 2.5f; private const int UiLayer = 5; private const float NearMargin = 0.015f; private const float ViewportOverscan = 0.05f; private const int TextureSize = 256; private const double FitInterval = 0.25; private GameObject? _blackQuad; private GameObject? _hazeQuad; private MeshRenderer? _blackRenderer; private MeshRenderer? _hazeRenderer; private Material? _blackMaterial; private Material? _hazeMaterial; private Texture2D? _hazeTexture; private Texture2D? _scotoma; private Texture2D? _bloodSpatter; private Mesh? _quadMesh; private Mesh? _tunnelMesh; private Il2CppStructArray<Vector2>? _tunnelUvs; private Vector2[]? _baseUvs; private Vector2 _viewUvHalf; private bool _warnedAboutShader; private float _hazeTint = 1f; private float _lastBlack; private float _lastHaze; private float _lastVeilGray; private float _lastRadius = -1f; private Vector2 _lastUvOffset; private bool _scotomaActive; private bool _spatterActive; private Color _lastHazeTint; private double _nextFit; public int Layer { get { if (!UnityLifetime.IsAlive((Object?)(object)_blackQuad)) { return 5; } return _blackQuad.layer; } } public string ShaderName { get { if (!UnityLifetime.IsAlive((Object?)(object)_blackMaterial) || !UnityLifetime.IsAlive((Object?)(object)_blackMaterial.shader)) { return "unavailable"; } return ((Object)_blackMaterial.shader).name; } } public bool IsBound { get { if (UnityLifetime.IsAlive((Object?)(object)_blackQuad) && UnityLifetime.IsAlive((Object?)(object)_hazeQuad) && UnityLifetime.IsAlive((Object?)(object)_blackRenderer) && UnityLifetime.IsAlive((Object?)(object)_hazeRenderer) && UnityLifetime.IsAlive((Object?)(object)_blackMaterial) && UnityLifetime.IsAlive((Object?)(object)_hazeMaterial) && UnityLifetime.IsAlive((Object?)(object)_hazeTexture) && UnityLifetime.IsAlive((Object?)(object)_quadMesh)) { return UnityLifetime.IsAlive((Object?)(object)_tunnelMesh); } return false; } } public static bool IsLayerVisible(Camera eye) { return (eye.cullingMask & 0x20) != 0; } public bool Bind(Camera eye, Action<string> warn) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Unbind(); if (!UnityLifetime.IsAlive((Object?)(object)eye) || !IsLayerVisible(eye)) { return false; } Transform transform = ((Component)eye).transform; if (!UnityLifetime.IsAlive((Object?)(object)transform)) { return false; } try { Material val = CreateBlackMaterial(warn); if (!UnityLifetime.IsAlive((Object?)(object)val)) { return false; } Material val2 = (_hazeMaterial = new Material(val)); ((Object)val2).name = "ImpactBlackout.Haze"; val2.renderQueue = 4000; val2.mainTexture = (Texture)(object)GetHazeTexture(); _blackQuad = CreateQuad(transform, "ImpactBlackout.Blackout", val, 32767, isTunnel: false, out _blackRenderer); _hazeQuad = CreateQuad(transform, "ImpactBlackout.Haze", val2, 32766, isTunnel: true, out _hazeRenderer); if (IsBound) { return true; } Unbind(); return false; } catch { Unbind(); throw; } } public void Present(Camera eye, double now, BlackoutFrame frame, TraumaPresentation injury = default(TraumaPresentation)) { //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_037e: 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_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.InverseLerp(0.04f, 0.83f, injury.Brain) * 0.93f; bool flag = frame.BloodSpatter > 0.018f && frame.BlackAlpha < 0.98f && frame.TunnelAlpha < 0.7f; float num2 = Mathf.Max(frame.BloodSpatter, Mathf.Max(injury.Pain * 0.56f, Mathf.Max(num, injury.Concussion * 0.24f))); if (frame.BlackAlpha <= 0.001f && frame.TunnelAlpha <= 0.001f && num2 <= 0.001f) { Hide(); return; } if (now >= _nextFit) { _nextFit = now + 0.25; FitToEye(eye); } float num3 = ((frame.BlackAlpha >= 1f) ? 0f : Mathf.Max(frame.TunnelAlpha, num2)); bool flag2 = !flag && injury.Brain > 0.045f && frame.TunnelAlpha < 0.45f && injury.Pain < 0.48f && (injury.Brain > 0.13f || injury.Concussion < 0.08f); if (num3 > 0f && UnityLifetime.IsAlive((Object?)(object)_hazeMaterial)) { if (flag2 && !UnityLifetime.IsAlive((Object?)(object)_scotoma)) { _scotoma = StereoOpticsRenderer.CreateScotoma(); } if (flag && !UnityLifetime.IsAlive((Object?)(object)_bloodSpatter)) { _bloodSpatter = WorldStainAssets.CreateTexture(StainKind.Spatter); } if (flag != _spatterActive || flag2 != _scotomaActive || (flag2 && !UnityLifetime.SameLiving((Object?)(object)_hazeMaterial.mainTexture, (Object?)(object)_scotoma))) { _hazeMaterial.mainTexture = (Texture)(flag ? _bloodSpatter : (flag2 ? ((object)_scotoma) : ((object)GetHazeTexture()))); } _scotomaActive = flag2; _spatterActive = flag; float num4 = (float)now; float num5 = Mathf.Sin(num4 * Mathf.Max(55f, frame.HeartBpm) * (float)Math.PI / 30f); float num6 = (flag2 ? (0.02f * injury.Brain) : 0f) + 0.048f * injury.Concussion; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(num6 * Mathf.Sin(num4 * 6.5f), num6 * 0.52f * Mathf.Cos(num4 * 4.1f)); float num7 = (flag ? 0.9f : (flag2 ? (0.65f + injury.Brain * 0.44f + 0.018f * num5) : Mathf.Min(frame.TunnelRadius, (injury.Pain > 0.01f) ? 0.91f : ((injury.Concussion > 0.01f) ? 1.1f : 2f)))); if (_lastRadius == num7) { Vector2 val2 = _lastUvOffset - val; if (!(((Vector2)(ref val2)).sqrMagnitude > 5E-07f)) { goto IL_0310; } } SetTunnelRadius(num7, val); } goto IL_0310; IL_0310: Color val3 = (Color)(flag ? new Color(0.43f, 0.065f, 0.085f) : Color.Lerp(Color.white * (flag2 ? 0.018f : _hazeTint), new Color(0.57f, 0.05f, 0.032f), injury.Pain)); SetLayer(_hazeQuad, _hazeMaterial, val3, num3, ref _lastHaze, val3 != _lastHazeTint); _lastHazeTint = val3; SetLayer(_blackQuad, _blackMaterial, frame.VeilGray, frame.BlackAlpha, ref _lastBlack, _lastVeilGray != frame.VeilGray); _lastVeilGray = frame.VeilGray; } public void Hide() { HideQuad(_blackQuad, ref _lastBlack); HideQuad(_hazeQuad, ref _lastHaze); _nextFit = 0.0; } public void Unbind() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) Hide(); UnityLifetime.Destroy((Object?)(object)_blackQuad); UnityLifetime.Destroy((Object?)(object)_hazeQuad); UnityLifetime.Destroy((Object?)(object)_blackMaterial); UnityLifetime.Destroy((Object?)(object)_hazeMaterial); _blackQuad = null; _hazeQuad = null; _blackRenderer = null; _hazeRenderer = null; _blackMaterial = null; _hazeMaterial = null; _lastRadius = -1f; _scotomaActive = false; _spatterActive = false; _lastHazeTint = default(Color); } public void Dispose() { Unbind(); UnityLifetime.Destroy((Object?)(object)_hazeTexture); UnityLifetime.Destroy((Object?)(object)_scotoma); UnityLifetime.Destroy((Object?)(object)_bloodSpatter); UnityLifetime.Destroy((Object?)(object)_quadMesh); UnityLifetime.Destroy((Object?)(object)_tunnelMesh); _hazeTexture = null; _scotoma = null; _bloodSpatter = null; _quadMesh = null; _tunnelMesh = null; _tunnelUvs = null; _baseUvs = null; } private GameObject CreateQuad(Transform parent, string name, Material material, int order, bool isTunnel, out MeshRenderer renderer) { //IL_00fe: 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) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); if (!UnityLifetime.IsAlive((Object?)(object)val)) { throw new InvalidOperationException("Unity could not create a stereo quad."); } try { val.SetActive(false); ((Object)val).name = name; int num = LayerMask.NameToLayer("UI"); val.layer = ((num == 5) ? num : 5); MeshCollider component = val.GetComponent<MeshCollider>(); if (UnityLifetime.IsAlive((Object?)(object)component)) { ((Collider)component).enabled = false; UnityLifetime.Destroy((Object?)(object)component); } MeshFilter component2 = val.GetComponent<MeshFilter>(); renderer = val.GetComponent<MeshRenderer>(); if (!UnityLifetime.IsAlive((Object?)(object)component2) || !UnityLifetime.IsAlive((Object?)(object)renderer)) { throw new InvalidOperationException("Unity's quad is missing its mesh or renderer."); } Mesh quadMesh = GetQuadMesh(component2.sharedMesh); component2.sharedMesh = (Mesh)(isTunnel ? ((object)GetTunnelMesh(quadMesh)) : ((object)quadMesh)); ((Renderer)renderer).sharedMaterial = material; ((Renderer)renderer).sortingOrder = order; ((Renderer)renderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)renderer).receiveShadows = false; ((Renderer)renderer).lightProbeUsage = (LightProbeUsage)0; ((Renderer)renderer).reflectionProbeUsage = (ReflectionProbeUsage)0; ((Renderer)renderer).allowOcclusionWhenDynamic = false; Transform transform = val.transform; transform.SetParent(parent, false); transform.localRotation = Quaternion.identity; ApplyGeometry(transform, new Vector3(2.5f, 2.5f, 1f), isTunnel ? 0.25f : 0.24f); return val; } catch { UnityLifetime.Destroy((Object?)(object)val); throw; } } private Mesh GetTunnelMesh(Mesh source) { //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) if (UnityLifetime.IsAlive((Object?)(object)_tunnelMesh)) { return _tunnelMesh; } Mesh val = Object.Instantiate<Mesh>(source); try { Il2CppStructArray<Vector2> uv = val.uv; _baseUvs = (Vector2[]?)(object)new Vector2[((Il2CppArrayBase<Vector2>)(object)uv).Length]; for (int i = 0; i < ((Il2CppArrayBase<Vector2>)(object)uv).Length; i++) { _baseUvs[i] = ((Il2CppArrayBase<Vector2>)(object)uv)[i]; } _tunnelUvs = new Il2CppStructArray<Vector2>((long)((Il2CppArrayBase<Vector2>)(object)uv).Length); val.MarkDynamic(); ((Object)val).hideFlags = (HideFlags)32; _tunnelMesh = val; return val; } catch { UnityLifetime.Destroy((Object?)(object)val); throw; } } private void SetTunnelRadius(float radius, Vector2 offset) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Mesh tunnelMesh = _tunnelMesh; Vector2[] baseUvs = _baseUvs; Il2CppStructArray<Vector2> tunnelUvs = _tunnelUvs; if (UnityLifetime.IsAlive((Object?)(object)tunnelMesh) && baseUvs != null && tunnelUvs != null && !((Il2CppObjectBase)tunnelUvs).WasCollected) { Vector2 tunnelUvScale = GetTunnelUvScale(_viewUvHalf, radius); for (int i = 0; i < baseUvs.Length; i++) { Vector2 val = baseUvs[i]; ((Il2CppArrayBase<Vector2>)(object)tunnelUvs)[i] = new Vector2(0.5f + (val.x - 0.5f) * tunnelUvScale.x + offset.x, 0.5f + (val.y - 0.5f) * tunnelUvScale.y + offset.y); } tunnelMesh.uv = tunnelUvs; _lastRadius = radius; _lastUvOffset = offset; } } internal static Vector2 GetTunnelUvScale(Vector2 eyeHalf, float radius) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) float num = 0.7f / (2f * Mathf.Max(0.015f, radius)); return new Vector2(num / Mathf.Max(0.01f, eyeHalf.x), num / Mathf.Max(0.01f, eyeHalf.y)); } private Mesh GetQuadMesh(Mesh source) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (UnityLifetime.IsAlive((Object?)(object)_quadMesh)) { return _quadMesh; } if (!UnityLifetime.IsAlive((Object?)(object)source)) { throw new InvalidOperationException("Unity did not supply a primitive quad mesh."); } Mesh val = Object.Instantiate<Mesh>(source); try { Il2CppStructArray<Color32> val2 = new Il2CppStructArray<Color32>((long)val.vertexCount); for (int i = 0; i < ((Il2CppArrayBase<Color32>)(object)val2).Length; i++) { ((Il2CppArrayBase<Color32>)(object)val2)[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); } val.colors32 = val2; ((Object)val).hideFlags = (HideFlags)32; _quadMesh = val; return val; } catch { UnityLifetime.Destroy((Object?)(object)val); throw; } } private Material? CreateBlackMaterial(Action<string> warn) { //IL_0012: 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_0083: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) Shader val = FindSupportedShader("Sprites/Default"); Material val2 = (_blackMaterial = ((val == null) ? ((Material)null) : new Material(val))); _hazeTint = 1f; if (UnityLifetime.IsAlive((Object?)(object)val2) && val2.HasProperty("_ZTest") && val2.HasProperty("_ZWrite")) { val2.SetInt("_ZTest", 8); val2.SetInt("_ZWrite", 0); } else { Shader val3 = FindSupportedShader("GUI/Text Shader"); UnityLifetime.Destroy((Object?)(object)val2); val2 = null; if (val3 != null) { val2 = new Material(val3); _hazeTint = 0.055f; } _blackMaterial = val2; } if (!UnityLifetime.IsAlive((Object?)(object)val2)) { if (!_warnedAboutShader) { _warnedAboutShader = true; warn("No compatible stock shader is available for the blackout quads."); } return null; } ((Object)val2).name = "ImpactBlackout.Black"; val2.renderQueue = 4000; val2.mainTexture = (Texture)(object)Texture2D.whiteTexture; val2.color = Color.clear; return val2; } private static Shader? FindSupportedShader(string name) { Shader val = Shader.Find(name); if (!UnityLifetime.IsAlive((Object?)(object)val) || !val.isSupported) { return null; } return val; } private static void SetLayer(GameObject? quad, Material? material, float tint, float alpha, ref float last, bool tintChanged = false) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) SetLayer(quad, material, new Color(tint, tint, tint), alpha, ref last, tintChanged); } private static void SetLayer(GameObject? quad, Material? material, Color tint, float alpha, ref float last, bool tintChanged = false) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) alpha = ((alpha <= 0.001f) ? 0f : alpha); if ((alpha != last || tintChanged) && UnityLifetime.IsAlive((Object?)(object)quad) && UnityLifetime.IsAlive((Object?)(object)material)) { tint.a = alpha; material.color = tint; if (last > 0f != alpha > 0f) { quad.SetActive(alpha > 0f); } last = alpha; } } private static void HideQuad(GameObject? quad, ref float last) { bool num = last > 0f; last = 0f; if (!num || !UnityLifetime.IsAlive((Object?)(object)quad)) { return; } try { quad.SetActive(false); } catch (Exception ex) when (UnityLifetime.IsNativeError(ex)) { UnityLifetime.Destroy((Object?)(object)quad); } } private void FitToEye(Camera eye) { //IL_0126: 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_005c: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) GameObject blackQuad = _blackQuad; GameObject hazeQuad = _hazeQuad; if (!UnityLifetime.IsAlive((Object?)(object)blackQuad) || !UnityLifetime.IsAlive((Object?)(object)hazeQuad)) { return; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(2.5f, 2.5f, 1f); float nearClipPlane = eye.nearClipPlane; float num = Mathf.Abs(((Component)eye).transform.lossyScale.z); float num2 = 0.25f; Vector2 val2 = default(Vector2); if (float.IsFinite(num) && num > 0.0001f && float.IsFinite(nearClipPlane) && nearClipPlane > 0f) { num2 = Mathf.Max(0.25f, (nearClipPlane + 0.015f) / num); try { if (eye.stereoEnabled && TryGetStereoFit(eye, nearClipPlane, num, out var extent, out var depth)) { num2 = depth; val.x = Mathf.Max(2.5f, 2f * extent.x); val.y = Mathf.Max(2.5f, 2f * extent.y); val2 = extent * 0.9090909f; } } catch (Exception ex) when (UnityLifetime.IsNativeError(ex)) { } } if (val2.x <= 0f || val2.y <= 0f) { ((Vector2)(ref val2))..ctor(num2 * 1.17f + 0.038f, num2 * 1.05f); } Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(val2.x / val.x, val2.y / val.y); if (Mathf.Abs(val3.x - _viewUvHalf.x) > 0.0005f || Mathf.Abs(val3.y - _viewUvHalf.y) > 0.0005f) { _viewUvHalf = val3; _lastRadius = -1f; } ApplyGeometry(blackQuad.transform, val, (num2 == 0.25f && (nearClipPlane + 0.015f) / Mathf.Max(num, 0.001f) <= 0.24f) ? (num2 - 0.01f) : num2); ApplyGeometry(hazeQuad.transform, val, num2); } private static void ApplyGeometry(Transform transform, Vector3 scale, float depth) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) transform.localPosition = new Vector3(0f, 0f, depth); transform.localScale = scale; } private unsafe static bool TryGetStereoFit(Camera eye, float near, float scaleZ, out Vector2 extent, out float depth) { //IL_0001: 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_004b: 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_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) //IL_00c4: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) extent = default(Vector2); depth = 0.25f; float farClipPlane = eye.farClipPlane; if (farClipPlane <= near + 0.03f) { return false; } float num = Mathf.Min(farClipPlane - 0.015f, Mathf.Max(2f, near + 1f)); Matrix4x4 worldToLocalMatrix = ((Component)eye).transform.worldToLocalMatrix; Span<Vector3> span = new Span<Vector3>(stackalloc Vector3[8], 8); Span<Vector3> span2 = new Span<Vector3>(stackalloc Vector3[8], 8); for (int i = 0; i < span.Length; i++) { MonoOrStereoscopicEye val = (MonoOrStereoscopicEye)(i >= 4); float num2 = (((i & 1) == 0) ? (-0.05f) : 1.05f); float num3 = (((i & 2) == 0) ? (-0.05f) : 1.05f); span[i] = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint3x4(eye.ViewportToWorldPoint(new Vector3(num2, num3, near), val)); span2[i] = ((Matrix4x4)(ref worldToLocalMatrix)).MultiplyPoint3x4(eye.ViewportToWorldPoint(new Vector3(num2, num3, num), val)); } return TryFitCorners(span, span2, 0.015f / scaleZ, out extent, out depth); } internal static bool TryFitCorners(ReadOnlySpan<Vector3> near, ReadOnlySpan<Vector3> far, float localMargin, out Vector2 halfExtent, out float depth) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_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_0140: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) halfExtent = default(Vector2); depth = 0.25f; if (near.Length == 0 || near.Length != far.Length || !float.IsFinite(localMargin) || localMargin < 0f) { return false; } float num = float.NegativeInfinity; float num2 = float.PositiveInfinity; for (int i = 0; i < near.Length; i++) { if (!float.IsFinite(near[i].z) || !float.IsFinite(far[i].z)) { return false; } num = Mathf.Max(num, near[i].z + localMargin); num2 = Mathf.Min(num2, far[i].z); } if (!(num < num2)) { return false; } depth = Mathf.Clamp(0.25f, num, num2); for (int j = 0; j < near.Length; j++) { float num3 = far[j].z - near[j].z; if (!(num3 > 0f)) { return false; } float num4 = (depth - near[j].z) / num3; Vector3 val = near[j] + (far[j] - near[j]) * num4; if (!float.IsFinite(val.x) || !float.IsFinite(val.y)) { return false; } halfExtent.x = Mathf.Max(halfExtent.x, Mathf.Abs(val.x)); halfExtent.y = Mathf.Max(halfExtent.y, Mathf.Abs(val.y)); } if (halfExtent.x > 0f) { return halfExtent.y > 0f; } return false; } private Texture2D GetHazeTexture() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) if (UnityLifetime.IsAlive((Object?)(object)_hazeTexture)) { return _hazeTexture; } Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false); try { ((Object)val).name = "ImpactBlackout.ProceduralHaze"; ((Object)val).hideFlags = (HideFlags)32; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; Il2CppStructArray<Color32> val2 = new Il2CppStructArray<Color32>(65536L); for (int i = 0; i < 256; i++) { for (int j = 0; j < 256; j++) { float num = (float)j / 255f; float num2 = (float)i / 255f; float num3 = 2f * num - 1f; float num4 = 2f * num2 - 1f; float num5 = Math.Clamp((MathF.Sqrt(num3 * num3 + num4 * num4) - 0.47f) / 0.45f, 0f, 1f); float num6 = num5 * num5 * (3f - 2f * num5); float num7 = 0.5f + 0.31f * MathF.Sin(num * 15f + 1.8f * MathF.Sin(num2 * 11f)) * MathF.Cos(num2 * 12f) + 0.19f * MathF.Sin((num + num2) * 29f + 0.8f * MathF.Sin(num2 * 18f)); float num8 = 92f + 28f * num7; float num9 = 7f + 38f * num7; byte b = (byte)MathF.Round(num8 + (7f + 8f * num7 - num8) * num6); byte b2 = (byte)MathF.Round(num9 + (255f - num9) * num6); ((Il2CppArrayBase<Color32>)(object)val2)[i * 256 + j] = new Color32(b, b, b, b2); } } val.SetPixels32(val2); val.Apply(false, true); _hazeTexture = val; return val; } catch { UnityLifetime.Destroy((Object?)(object)val); throw; } } } internal sealed class BloodLossSystem { public float Volume { get; private set; } = 1f; public float BleedRate { get; private set; } public float Deficit => 1f - Volume; public float WalkScale { get { if (!(Deficit > 0.55f)) { return 1f; } return 0.65f; } } public float HandSoftness => 0.045f * Math.Clamp((Deficit - 0.4f) / 0.35f, 0f, 1f); public void Wound(float strength) { if (float.IsFinite(strength) && strength > 0f) { BleedRate = Math.Clamp(BleedRate + 0.014f * strength, 0f, 0.03f); } } public void Tick(float delta) { Volume = Math.Max(0f, Volume - BleedRate * delta); } public void Bandage() { BleedRate = 0f; } public void Preview() { Volume = Math.Min(Volume, 0.42f); Wound(0.35f); } public void Heal() { Volume = 1f; BleedRate = 0f; } } internal sealed class BrainDamageSystem { private double _hypoxicTime; private bool _alreadyHypoxic; private float _interval; private float _absenceAge; private float _absenceDuration; private float _ringAge; private float _ringCountdown = 2.7f; private uint _random = 2584942101u; public float Damage { get; private set; } public float HandPowerCeiling => PowerAt(Damage); public float Absence { get { if (_absenceDuration <= 0f) { return 0f; } float num = MotorRecovery.Smooth((_absenceDuration - _absenceAge) / 0.38f); float num2 = 0.9f + 0.1f * MathF.Sin(31f * _absenceAge); return MotorRecovery.Smooth(_absenceAge / 0.09f) * num * (1f - (1f - num) * (1f - num2)); } } public float PhantomRing => Math.Clamp(_ringAge / 0.38f, 0f, 1f) * Math.Clamp((1.4f - _ringAge) / 0.85f, 0f, 1f); internal static float PowerAt(float damage) { if (!(damage <= 0.15f)) { if (!(damage <= 0.4f)) { if (damage <= 0.7f) { return Between(damage, 0.4f, 0.7f, 0.84f, 0.72f); } return Between(damage, 0.7f, 1f, 0.72f, 0.6f); } return Between(damage, 0.15f, 0.4f, 0.92f, 0.84f); } return Between(damage, 0f, 0.15f, 1f, 0.92f); } private static float Between(float value, float low, float high, float from, float to) { return from + (to - from) * Math.Clamp((value - low) / (high - low), 0f, 1f); } public void Tick(float seconds, float oxygen, float delay) { if (!(oxygen >= 0f) || !(oxygen <= 0.05f) || !(seconds > 0f) || !float.IsFinite(seconds)) { ResetExposure(); return; } if (!_alreadyHypoxic) { _alreadyHypoxic = true; return; } double hypoxicTime = _hypoxicTime; _hypoxicTime += seconds; double num = Math.Max(0.0, _hypoxicTime - Math.Max(float.IsFinite(delay) ? Math.Max(6f, delay) : 6f, hypoxicTime)); if (!(num < 1E-06)) { Damage = Math.Clamp(Damage + (float)(num / 22.0), 0f, 1f); } } public static float CatastrophicStrike(float closing, float impulse, float arrest) { if (!(closing >= 16f) || !(impulse >= 5f) || !(arrest >= 9f)) { return 0f; } return 0.35f + 0.35f * Math.Clamp(Math.Min((closing - 16f) / 10f, (arrest - 9f) / 6f), 0f, 1f); } public void Strike(float verifiedDamage) { Damage = Math.Max(Damage, verifiedDamage); } public void UpdateSymptoms(float dt, bool canStartAbsence) { if (Damage < 0.43f) { return; } float num = Math.Clamp((Damage - 0.43f) / 0.57f, 0f, 1f); if (_absenceDuration > 0f) { _absenceAge += dt; if (_absenceAge >= _absenceDuration) { _absenceDuration = 0f; } } else if (canStartAbsence) { _interval -= dt; if (_interval <= 0f) { _absenceAge = 0f; _absenceDuration = 1f + 1.5f * (0.7f * num + 0.3f * Next()); _interval = 8f + 15f * (1f - num) + 5f * Next(); } } if (_ringAge > 0f) { _ringAge += dt; if (_ringAge >= 1.4f) { _ringAge = 0f; } } else if ((_ringCountdown -= dt) <= 0f) { _ringAge = dt; _ringCountdown = 2.9f + 6f * (1f - num) + 2f * Next(); } } private float Next() { _random ^= _random << 13; _random ^= _random >> 17; _random ^= _random << 5; return (float)(_random & 0xFFFF) / 65535f; } public void Preview() { Damage = Math.Max(Damage, 0.9f); } public void ClearSymptoms() { _absenceAge = (_absenceDuration = (_ringAge = 0f)); _interval = 3f; _ringCountdown = 2.7f; } public void Heal() { Damage = 0f; ResetExposure(); ClearSymptoms(); } public void ResetExposure() { _hypoxicTime = 0.0; _alreadyHypoxic = false; } } internal enum BreathInput { LeftStickAndTrigger, BothTriggers, BothGripsAndTriggers } internal readonly record struct BreathFrame(bool Holding, float Oxygen); internal sealed class BreathController { private const float PreviewHoldSeconds = 0.85f; private readonly Action<string> _warn; private bool _preview; private float _previewHold; private bool _needsRelease = true; private bool _holdingInput; private bool _reportedInputError; private BreathInput _input; private double _oxygen = 1.0; public bool IsPreview => _preview; public BreathController(Action<string> warn) { _warn = warn; } public void StartPreview() { Reset(); _preview = true; } public BreathFrame Tick(float delta, ModPreferences preferences, bool canHold, float reserve = 1f, bool treating = false) { if (_input != preferences.BreathInput) { _input = preferences.BreathInput; _holdingInput = false; _needsRelease = true; } bool pressed = preferences.BreathEnabled && ReadInput(); return Advance(delta, pressed, canHold && !treating, preferences.BreathHoldDuration * reserve, preferences.RecoveryDuration); } internal BreathFrame Advance(float delta, bool pressed, bool canHold, float depletionSeconds, float recoverySeconds) { double num = (float.IsFinite(delta) ? Math.Clamp(delta, 0f, 0.25f) : 0f); if (!pressed) { _needsRelease = false; } if (pressed && (!canHold || _preview)) { _needsRelease = true; } if (_preview && _oxygen == 0.0) { _previewHold += (float)num; if (_previewHold >= 0.85f) { _preview = false; } } _holdingInput = canHold && pressed && !_needsRelease && !_preview; bool flag = canHold && (_preview || _holdingInput); _oxygen = (flag ? Math.Max(0.0, _oxygen - num / (double)depletionSeconds) : Math.Min(1.0, _oxygen + num / (double)recoverySeconds)); if (flag && _oxygen < 1E-08) { _oxygen = 0.0; } return new BreathFrame(flag, (float)_oxygen); } public void Reset() { _oxygen = 1.0; _preview = false; _previewHold = 0f; _needsRelease = true; _holdingInput = false; } private bool ReadInput() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0091: 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) try { InputDevice deviceAtXRNode = InputDevices.GetDeviceAtXRNode((XRNode)4); float threshold = (_holdingInput ? 0.55f : 0.72f); if (!((InputDevice)(ref deviceAtXRNode)).isValid || !IsDown(deviceAtXRNode, CommonUsages.trigger, CommonUsages.triggerButton, threshold)) { return false; } bool flag = default(bool); if (_input == BreathInput.LeftStickAndTrigger) { return ((InputDevice)(ref deviceAtXRNode)).TryGetFeatureValue(CommonUsages.primary2DAxisClick, ref flag) && flag; } InputDevice deviceAtXRNode2 = InputDevices.GetDeviceAtXRNode((XRNode)5); if (!((InputDevice)(ref deviceAtXRNode2)).isValid || !IsDown(deviceAtXRNode2, CommonUsages.trigger, CommonUsages.triggerButton, threshold)) { return false; } return _input == BreathInput.BothTriggers || (IsDown(deviceAtXRNode, CommonUsages.grip, CommonUsages.gripButton, threshold) && IsDown(deviceAtXRNode2, CommonUsages.grip, CommonUsages.gripButton, threshold)); } catch (Exception ex) when (((Func<bool>)delegate { // Could not convert BlockContainer to single expression bool flag2 = UnityLifetime.IsNativeError(ex); if (!flag2) { flag2 = ((ex is MissingMethodException || ex is TypeLoadException) ? true : false); } return flag2; }).Invoke()) { if (!_reportedInputError) { _reportedInputError = true; _warn("XR controller input could not be read. " + ex.GetType().Name + ": " + ex.Message); } return false; } } private static bool IsDown(InputDevice device, InputFeatureUsage<float> axis, InputFeatureUsage<bool> button, float threshold) { float num = default(float); bool flag = default(bool); if (!((InputDevice)(ref device)).TryGetFeatureValue(axis, ref num)) { return ((InputDevice)(ref device)).TryGetFeatureValue(button, ref flag) && flag; } return num >= threshold; } } internal sealed class BreathingAudio { private const int SampleRate = 44100; private const double CycleSeconds = 2.4; private const double GaspSeconds = 1.1; private readonly Action<string> _warn; private GameObject? _root; private AudioSource? _source; private AudioClip? _cycle; private AudioClip? _gasp; private AudioClip? _chokeGasp; private AudioClip? _wheeze; private AudioClip? _strained; private double _nextCycle; private double _gaspUntil; private float _gaspGain; private int _seenGasp; private bool _playing; private bool _wasStrained; private bool _reportedError; public BreathingAudio(Action<string> warn) { _warn = warn; } public bool IsGaspActive(double now) { return now < _gaspUntil; } public void RefreshBinding(Camera eye) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (UnityLifetime.IsAlive((Object?)(object)_source) && UnityLifetime.IsAlive((Object?)(object)_cycle) && UnityLifetime.IsAlive((Object?)(object)_gasp)) { return; } Unbind(); try { if (!UnityLifetime.IsAlive((Object?)(object)_cycle)) { _cycle = CreateClip(gasp: false); } if (!UnityLifetime.IsAlive((Object?)(object)_gasp)) { _gasp = CreateClip(gasp: true); } if (!UnityLifetime.IsAlive((Object?)(object)_chokeGasp)) { try { _chokeGasp = CreateClip(gasp: true, raspy: true); } catch (Exception ex) { Report(ex); } } GameObject val = (_root = new GameObject("ImpactBlackout.Breathing")); val.transform.SetParent(((Component)eye).transform, false); AudioSource val2 = (_source = val.AddComponent<AudioSource>()); val2.playOnAwake = false; val2.loop = false; val2.spatialBlend = 0f; val2.bypassListenerEffects = true; val2.dopplerLevel = 0f; val2.volume = 0f; } catch (Exception ex2) { Unbind(); Report(ex2); } } public void Present(double now, float master, float gain, float breathsPerMinute, int gaspSerial, float gaspStrength, float rasp = 0f, bool strained = false, bool sharpGasp = false) { bool flag = gaspSerial != _seenGasp && gaspStrength > 0f; _seenGasp = gaspSerial; if (master <= 0f || AudioListener.pause || (!flag && gain <= 0.005f && now >= _gaspUntil)) { Reset(); return; } AudioSource source = _source; AudioClip gasp = _gasp; AudioClip cycle = _cycle; if (!UnityLifetime.IsAlive((Object?)(object)source) || !UnityLifetime.IsAlive((Object?)(object)gasp) || !UnityLifetime.IsAlive((Object?)(object)cycle)) { return; } try { bool flag2 = _wasStrained && !strained; if (strained != _wasStrained) { source.Stop(); _gaspUntil = (_nextCycle = 0.0); _wasStrained = strained; } if (strained && now < _gaspUntil) { source.Stop(); _gaspUntil = (_nextCycle = 0.0); } if (strained) { flag = false; } if (flag) { bool flag3 = (sharpGasp || rasp > 0.54f || flag2) && gaspStrength >= 0.68f; source.Stop(); source.pitch = 1f; _gaspGain = gaspStrength; source.volume = master * _gaspGain; source.PlayOneShot((AudioClip)((flag3 && UnityLifetime.IsAlive((Object?)(object)_chokeGasp)) ? ((object)_chokeGasp) : ((object)gasp)), 1f); _gaspUntil = now + 1.1; _nextCycle = _gaspUntil + 0.09; _playing = true; return; } if (now < _gaspUntil) { source.volume = master * _gaspGain; return; } source.volume = master * gain; if (!(gain <= 0.005f) && !(now < _nextCycle)) { float num = Mathf.Clamp(breathsPerMinute, 10f, 48f); source.pitch = 2.4f * num / 60f; if (strained && !UnityLifetime.IsAlive((Object?)(object)_strained)) { _strained = CreateClip(gasp: false, raspy: true, strained: true); } if (!strained && rasp > 0.18f && !UnityLifetime.IsAlive((Object?)(object)_wheeze)) { _wheeze = CreateClip(gasp: false, raspy: true); } source.PlayOneShot((AudioClip)((strained && UnityLifetime.IsAlive((Object?)(object)_strained)) ? _strained : ((rasp > 0.18f && UnityLifetime.IsAlive((Object?)(object)_wheeze)) ? ((object)_wheeze) : ((object)cycle))), 1f); _nextCycle = now + 60.0 / (double)num; _playing = true; } } catch (Exception ex) when (UnityLifetime.IsNativeError(ex)) { Unbind(); Report(ex); } } public void Reset() { bool playing = _playing; _playing = false; _wasStrained = false; _nextCycle = (_gaspUntil = 0.0); AudioSource source = _source; if (!playing || !UnityLifetime.IsAlive((Object?)(object)source)) { return; } try { source.volume = 0f; source.Stop(); } catch (Exception ex) when (UnityLifetime.IsNativeError(ex)) { } } public void Unbind() { Reset(); UnityLifetime.Destroy((Object?)(object)_root); _source = null; _root = null; } public void Dispose() { Unbind(); UnityLifetime.Destroy((Object?)(object)_gasp); UnityLifetime.Destroy((Object?)(object)_cycle); UnityLifetime.Destroy((Object?)(object)_wheeze); UnityLifetime.Destroy((Object?)(object)_chokeGasp); UnityLifetime.Destroy((Object?)(object)_strained); _gasp = (_cycle = (_wheeze = (_chokeGasp = (_strained = null)))); } private void Report(Exception ex) { if (!_reportedError) { _reportedError = true; _warn("Procedural breathing audio was unavailable. " + ex.GetType().Name + ": " + ex.Message); } } internal static double Envelope(double seconds, bool gasp) { if (!gasp) { return 0.62 * Lobe(seconds, 0.0, 0.96, 0.72) + 0.48 * Lobe(seconds, 1.03, 2.25, 0.47); } return 0.87 * Lobe(seconds, 0.0, 0.48, 0.2) + 0.35 * Lobe(seconds, 0.53, 1.1, 0.65); } private static double Lobe(double seconds, double start, double end, double peak) { double num = (seconds - start) / (end - start); if (num <= 0.0 || num >= 1.0) { return 0.0; } double num2 = ((num < peak) ? (num / peak) : ((1.0 - num) / (1.0 - peak))); return 0.5 - 0.5 * Math.Cos(Math.PI * num2); } private static AudioClip CreateClip(bool gasp, bool raspy = false, bool strained = false) { int num = (int)Math.Round(44100.0 * (gasp ? 1.1 : 2.4)); Il2CppStructArray<float> val = new Il2CppStructArray<float>((long)num); uint num2 = (gasp ? 1568152521u : 608135816u); double num3 = 0.0; double num4 = 0.0; double num5 = 0.0; for (int i = 0; i < num; i++) { double num6 = (double)i / 44100.0; num2 ^= num2 << 13; num2 ^= num2 >> 17; num2 ^= num2 << 5; double num7 = (double)(num2 & 0xFFFFFF) * 1.1920929665620903E-07 - 1.0; double num8 = 1.0 - Math.Clamp((num6 - (gasp ? 0.42 : 0.9)) * 8.0, 0.0, 1.0); num3 += (num7 - num3) * (0.2 + 0.16 * num8 + (gasp ? 0.12 : 0.0)); num4 += (num7 - num4) * 0.018; num5 += (num3 - num4 - num5) * 0.081; double num9 = 0.65 * (num3 - num4) + 0.35 * num5; double num10 = 0.87 + 0.09 * Math.Sin(52.15043804959057 * num6) + 0.04 * Math.Sin(98.6460093227195 * num6); if (raspy) { num9 = 0.75 * num9 * (0.76 + 0.24 * Math.Sin(num6 * 161.0)) + 0.077 * Math.Sin(num6 * 1401.0 + num3 * 3.0); } double num11 = (strained ? (0.25 * Lobe(num6, 0.12, 0.45, 0.47) + 0.21 * Lobe(num6, 1.16, 1.57, 0.32)) : ((gasp && raspy) ? (1.15 * Lobe(num6, 0.0, 0.36, 0.11) + 0.55 * Lobe(num6, 0.38, 0.64, 0.21) + 0.4 * Lobe(num6, 0.66, 1.1, 0.57)) : Envelope(num6, gasp))); ((Il2CppArrayBase<float>)(object)val)[i] = (float)(num11 * num10 * num9); } AudioClip val2 = AudioClip.Create((!gasp) ? (strained ? "ImpactBlackout.StrainedWheeze" : (raspy ? "ImpactBlackout.RibWheeze" : "ImpactBlackout.InhaleExhale")) : (raspy ? "ImpactBlackout.RibChokeGasp" : "ImpactBlackout.Gasp"), num, 1, 44100, false); if (!UnityLifetime.IsAlive((Object?)(object)val2)) { throw new InvalidOperationException("Unity could not create the breathing clip."); } try { if (!val2.SetData(val, 0)) { throw new InvalidOperationException("Unity could not upload the breathing clip."); } ((Object)val2).hideFlags = (HideFlags)32; return val2; } catch { UnityLifetime.Destroy((Object?)(object)val2); throw; } } } internal sealed class DiaphragmSpasmSystem { public float Remaining { get; private set; } public bool Active => Remaining > 0f; public float OxygenDrain { get { if (!Active) { return 0f; } return 0.155f; } } public bool Start(float severity) { if (Active) { return false; } Remaining = 4f + 3f * Math.Clamp(severity, 0f, 1f); return true; } public bool Tick(float dt) { if (!Active) { return false; } Remaining = Math.Max(0f, Remaining - dt); return !Active; } public void Clear() { Remaining = 0f; } } internal sealed class FloorBloodTrails { internal const int Capacity = 40; private readonly GameObject?[] _decals = (GameObject?[])(object)new GameObject[40]; private Il2CppStructArray<RaycastHit>? _hits; private Rigidbody? _pelvis; private Rigidbody? _left; private Rigidbody? _right; private Transform? _rig; private Vector3 _last; private double _next; private int _cursor; private bool _placed; public void Bind(PhysicsRig rig) { if (UnityLifetime.IsAlive((Object?)(object)rig)) { _rig = ((Component)rig).transform; PhysTorso torso = rig.torso; _pelvis = (UnityLifetime.IsAlive((Object?)(object)torso) ? torso.rbPelvis : null); Hand leftHand = rig.leftHand; Hand rightHand = rig.rightHand; PhysHand val = (UnityLifetime.IsAlive((Object?)(object)leftHand) ? leftHand.physHand : null); PhysHand val2 = (UnityLifetime.IsAlive((Object?)(object)rightHand) ? rightHand.physHand : null); _left = (UnityLifetime.IsAlive((Object?)(object)val) ? val.rbLower : null); _right = (UnityLifetime.IsAlive((Object?)(object)val2) ? val2.rbLower : null); } } public void Tick(double now, float bleedRate, bool drag, InjuryZone wounds, WorldStainAssets assets) { //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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) if (bleedRate <= 0f || now < _next || !UnityLifetime.IsAlive((Object?)(object)_pelvis) || !UnityLifetime.IsAlive((Object?)(object)_rig)) { return; } _next = now + (drag ? 0.19 : 0.58); Rigidbody val = _pelvis; if (!drag) { if (_cursor % 3 == 1 && (wounds & InjuryZone.LeftArm) != InjuryZone.None && UnityLifetime.IsAlive((Object?)(object)_left)) { val = _left; } if (_cursor % 3 == 2 && (wounds & InjuryZone.RightArm) != InjuryZone.None && UnityLifetime.IsAlive((Object?)(object)_right)) { val = _right; } } Vector3 val2 = val.worldCenterOfMass + Vector3.up * 0.1f; if (_hits == null) { _hits = new Il2CppStructArray<RaycastHit>(12L); } int num = Physics.RaycastNonAlloc(val2, Vector3.down, _hits, 2.35f, -1, (QueryTriggerInteraction)1); float num2 = float.PositiveInfinity; RaycastHit val3 = default(RaycastHit); for (int i = 0; i < num && i < ((Il2CppArrayBase<RaycastHit>)(object)_hits).Length; i++) { RaycastHit val4 = ((Il2CppArrayBase<RaycastHit>)(object)_hits)[i]; if (UnityLifetime.IsAlive((Object?)(object)((RaycastHit)(ref val4)).collider) && !((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(_rig) && !(((RaycastHit)(ref val4)).normal.y < 0.4f) && !(((RaycastHit)(ref val4)).distance >= num2)) { num2 = ((RaycastHit)(ref val4)).distance; val3 = val4; } } if (!float.IsFinite(num2)) { return; } Vector3 val5 = (Vector3)(_placed ? (((RaycastHit)(ref val3)).point - _last) : default(Vector3)); if (_placed && ((Vector3)(ref val5)).sqrMagnitude < (drag ? 0.0081f : 0.0169f)) { return; } Material val6 = assets.MaterialFor(drag ? StainKind.Smear : StainKind.Blood); if (UnityLifetime.IsAlive((Object?)(object)val6)) { int cursor = _cursor; _cursor = (_cursor + 1) % 40; GameObject val7 = _decals[cursor]; if (!UnityLifetime.IsAlive((Object?)(object)val7)) { val7 = (_decals[cursor] = assets.CreateQuad("ImpactBlackout.FloorBlood", val6)); } MeshRenderer component = val7.GetComponent<MeshRenderer>(); if (UnityLifetime.IsAlive((Object?)(object)component)) { ((Renderer)component).sharedMaterial = val6; } Vector3 val8 = Vector3.ProjectOnPlane(val5, ((RaycastHit)(ref val3)).normal); if (((Vector3)(ref val8)).sqrMagnitude < 0.001f) { val8 = Vector3.ProjectOnPlane(_rig.forward, ((RaycastHit)(ref val3)).normal); } if (((Vector3)(ref val8)).sqrMagnitude < 0.001f) { val8 = Vector3.ProjectOnPlane(Vector3.right, ((RaycastHit)(ref val3)).normal); } val7.transform.SetPositionAndRotation(((RaycastHit)(ref val3)).point + ((RaycastHit)(ref val3)).normal * (0.005f + (float)cursor * 2E-05f), Quaternion.LookRotation(-((RaycastHit)(ref val3)).normal, val8)); float num3 = Mathf.Lerp(0.14f, 0.34f, Mathf.Clamp01(bleedRate / 0.03f)); val7.transform.localScale = new Vector3(num3, drag ? (num3 * 2.15f) : (num3 * 0.82f), 1f); _placed = true; _last = ((RaycastHit)(ref val3)).point; } } public void Unbind() { _rig = null; _pelvis = (_left = (_right = null)); _placed = false; _next = 0.0; } public void Clear() { for (int i = 0; i < _decals.Length; i++) { UnityLifetime.Destroy((Object?)(object)_decals[i]); _decals[i] = null; } _cursor = 0; _placed = false; } } internal sealed class FloorCrawlAssist { private Il2CppReferenceArray<Collider>? _hits; private bool _leftReady; private bool _rightReady; private Vector3 _leftPrior; private Vector3 _rightPrior; private Vector3 _smoothed; private PhysicMaterial? _slide; private Transform? _root; private Transform? _chest; private Hand? _leftController; private Hand? _rightController; private Rigidbody? _ball; private Rigidbody? _leftBody; private Rigidbody? _rightBody; private PhysHand? _leftHand; private PhysHand? _rightHand; private readonly Collider?[] _colliders = (Collider?[])(object)new Collider[3]; private readonly PhysicMaterial?[] _originals = (PhysicMaterial?[])(object)new PhysicMaterial[3]; public bool Pulling { get; private set; } public void Bind(PhysicsRig rig, Transform? chest) { //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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown _colliders[0] = (Collider?)(object)rig.kneePelvisCol; _colliders[1] = (Collider?)(object)rig._football; _colliders[2] = (Collider?)(object)rig._kneeFender; _root = ((Component)rig).transform; _chest = chest; _ball = BallBody(rig); BindHand(rig.leftHand, out _leftHand, out _leftBody, out _leftController); BindHand(rig.rightHand, out _rightHand, out _rightBody, out _rightController); if (_hits == null) { _hits = new Il2CppReferenceArray<Collider>(12L); } _slide = new PhysicMaterial("ImpactBlackout.CrawlSlide") { dynamicFriction = 0.1f, staticFriction = 0.07f, frictionCombine = (PhysicMaterialCombine)2, hideFlags = (HideFlags)32 }; } private static void BindHand(Hand? hand, out PhysHand? physical, out Rigidbody? body, out Hand? controller) { physical = (UnityLifetime.IsAlive((Object?)(object)hand) ? hand.physHand : null); body = (UnityLifetime.IsAlive((Object?)(object)physical) ? physical.rbHand : null); controller = (UnityLifetime.IsAlive((Object?)(object)hand) ? hand : null); } public void Step(Rigidbody pelvis, float leftGrip, float rightGrip, float dt) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00b1: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown resul