Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Flinch v0.1.21
BepInEx/plugins/Flinch/Flinch.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using Flinch.Core; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using REPOLib.Objects.Sdk; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Flinch")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.21.0")] [assembly: AssemblyInformationalVersion("0.1.21")] [assembly: AssemblyProduct("Flinch")] [assembly: AssemblyTitle("Flinch")] [assembly: AssemblyVersion("0.1.21.0")] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Flinch.Core { public sealed class BoneData { public string Name = ""; public int Parent; public float[] Rest = Array.Empty<float>(); } public sealed class MeshData { public string Name = ""; public float[] Vertices = Array.Empty<float>(); public int[] Bones = Array.Empty<int>(); public float[] Weights = Array.Empty<float>(); public int[] Triangles = Array.Empty<int>(); } public sealed class ModelData { public BoneData[] Bones = Array.Empty<BoneData>(); public MeshData[] Meshes = Array.Empty<MeshData>(); } public sealed class ClipData { public string Name = ""; public float Duration; public float Travel; public bool Loop; public int Frames; public float[] Samples = Array.Empty<float>(); } public static class AssetData { private static BinaryReader Open(Stream s) { BinaryReader binaryReader = new BinaryReader(s, Encoding.UTF8, leaveOpen: true); if (Encoding.ASCII.GetString(binaryReader.ReadBytes(8)) != "FLINCH07") { throw new InvalidDataException("Flinch asset header mismatch"); } return binaryReader; } private static int Count(BinaryReader r, int max) { int num = r.ReadInt32(); if (num < 0 || num > max) { throw new InvalidDataException("Asset count outside allowed range"); } return num; } private static string Text(BinaryReader r) { int num = Count(r, 1024); byte[] array = r.ReadBytes(num); if (array.Length != num) { throw new EndOfStreamException(); } return Encoding.UTF8.GetString(array); } private static float[] Floats(BinaryReader r, int n) { float[] array = new float[n]; for (int i = 0; i < n; i++) { array[i] = r.ReadSingle(); if (float.IsNaN(array[i]) || float.IsInfinity(array[i])) { throw new InvalidDataException("Nonfinite asset data"); } } return array; } public static ModelData ReadMesh(Stream stream) { using BinaryReader binaryReader = Open(stream); ModelData modelData = new ModelData(); modelData.Bones = new BoneData[Count(binaryReader, 256)]; ModelData modelData2 = modelData; for (int i = 0; i < modelData2.Bones.Length; i++) { BoneData boneData = new BoneData { Name = Text(binaryReader), Parent = binaryReader.ReadInt32(), Rest = Floats(binaryReader, 10) }; if (boneData.Parent >= i || boneData.Parent < -1) { throw new InvalidDataException("Invalid skeleton hierarchy"); } modelData2.Bones[i] = boneData; } modelData2.Meshes = new MeshData[Count(binaryReader, 32)]; for (int j = 0; j < modelData2.Meshes.Length; j++) { MeshData meshData = new MeshData { Name = Text(binaryReader) }; int num = Count(binaryReader, 200000); int num2 = Count(binaryReader, 600000); if (num2 % 3 != 0) { throw new InvalidDataException("Triangle count invalid"); } meshData.Vertices = new float[num * 8]; meshData.Bones = new int[num * 4]; meshData.Weights = new float[num * 4]; for (int k = 0; k < num; k++) { float[] sourceArray = Floats(binaryReader, 8); Array.Copy(sourceArray, 0, meshData.Vertices, k * 8, 8); for (int l = 0; l < 4; l++) { int num3 = binaryReader.ReadInt32(); if (num3 < 0 || num3 >= modelData2.Bones.Length) { throw new InvalidDataException("Skin bone index invalid"); } meshData.Bones[k * 4 + l] = num3; } sourceArray = Floats(binaryReader, 4); float num4 = 0f; for (int m = 0; m < 4; m++) { if (sourceArray[m] < 0f) { throw new InvalidDataException("Negative skin weight"); } num4 += sourceArray[m]; } if ((double)Math.Abs(num4 - 1f) > 0.001) { throw new InvalidDataException("Skin weights not normalized"); } Array.Copy(sourceArray, 0, meshData.Weights, k * 4, 4); } meshData.Triangles = new int[num2]; for (int n = 0; n < num2; n++) { int num5 = binaryReader.ReadInt32(); if (num5 < 0 || num5 >= num) { throw new InvalidDataException("Mesh index invalid"); } meshData.Triangles[n] = num5; } modelData2.Meshes[j] = meshData; } return modelData2; } public static ClipData[] ReadMotion(Stream stream, int boneCount) { using BinaryReader binaryReader = Open(stream); ClipData[] array = new ClipData[Count(binaryReader, 128)]; if (binaryReader.ReadInt32() != boneCount) { throw new InvalidDataException("Animation skeleton mismatch"); } for (int i = 0; i < array.Length; i++) { ClipData clipData = new ClipData { Name = Text(binaryReader), Duration = binaryReader.ReadSingle(), Travel = binaryReader.ReadSingle(), Loop = binaryReader.ReadBoolean(), Frames = Count(binaryReader, 10000) }; if (clipData.Duration <= 0f || float.IsNaN(clipData.Duration) || float.IsInfinity(clipData.Duration) || clipData.Frames < 2) { throw new InvalidDataException("Animation duration invalid"); } clipData.Samples = Floats(binaryReader, clipData.Frames * boneCount * 10); array[i] = clipData; } return array; } } public enum VoiceCue { None, Detect, Lost, Idle } public readonly struct AudioDecision { public readonly VoiceCue Voice; public readonly bool Step; public AudioDecision(VoiceCue voice, bool step) { Voice = voice; Step = step; } } public sealed class AudioCues { private bool seen; private bool hadTarget; private bool gaitSeeded; private int half; private float absent; private float noticeCooldown; private float lostCooldown; private float idleClock = 45f; private float stepCooldown; public void DelayIdle(float seconds) { idleClock = Math.Max(idleClock, seconds); } public AudioDecision Tick(float dt, bool visible, bool patrol, bool locomotion, float gait, bool voiceBusy, float distance) { if (dt <= 0f || float.IsNaN(dt) || float.IsInfinity(dt)) { return default(AudioDecision); } noticeCooldown = Math.Max(0f, noticeCooldown - dt); stepCooldown = Math.Max(0f, stepCooldown - dt); lostCooldown = Math.Max(0f, lostCooldown - dt); VoiceCue voiceCue = VoiceCue.None; if (visible) { if (!seen && noticeCooldown <= 0f) { voiceCue = VoiceCue.Detect; noticeCooldown = 8f; } hadTarget = true; absent = 0f; } else { absent += dt; if (hadTarget && absent >= 1.1f) { hadTarget = false; if (lostCooldown <= 0f) { voiceCue = VoiceCue.Lost; lostCooldown = 8f; } } } seen = visible; if (patrol && distance > 0.001f) { idleClock -= dt; } if (voiceCue != VoiceCue.None) { idleClock = 35f; } else if (idleClock <= 0f && !voiceBusy) { voiceCue = VoiceCue.Idle; idleClock = 60f; } int num = (int)Math.Floor(gait * 2f); bool flag = false; if (locomotion) { flag = gaitSeeded && num != half && distance > 0.001f && stepCooldown <= 0f; half = num; gaitSeeded = true; } else { gaitSeeded = false; } if (flag) { stepCooldown = 0.12f; } return new AudioDecision(voiceCue, flag); } } public static class CoverAttack { public const float EntryHold = 0.12f; public const float Windup = 0.2f; public const float Duration = 1.25f; public const float Impact = 0.28f; public const float Open = 0.22f; public const float Close = 0.65f; public const float Settle = 0.72f; public const float Commit = 0.14f; public const float Playback = 1.6f; public const float Inspection = 1.25f; } public sealed class EncounterCue { private float unseen = 30f; private float seen; private float cooldown; private bool armed = true; public bool Tick(bool visible, float dt) { if (float.IsNaN(dt) || float.IsInfinity(dt) || dt <= 0f) { return false; } cooldown = Math.Max(0f, cooldown - dt); if (!visible) { unseen += dt; seen = 0f; if (unseen >= 5f && cooldown <= 0f) { armed = true; } return false; } unseen = 0f; seen += dt; if (!armed || seen < 0.12f || cooldown > 0f) { return false; } armed = false; cooldown = 25f; return true; } } public enum State { Patrol, Observe, Stalk, Startle, Panic, RageTransition, Chase, Attack, CalmDown, Exhausted, Stunned, Dead, LookUnder, UnderAttack, Retreat, RoamBurst, InspectUnder } public enum RageCause { None, Neglect, Group, Provocation, Damage } public sealed class BrainSnapshot { public State State; public RageCause Cause; public float StateTime; public float GroupAlarm; public float SoloAlarm; public float RageTime; public float GroupLostTime; public float RearmRemaining; public float AttackRemaining; public int Sequence; public int AttackDamage; public int AttackVariant; public bool HitSent; public bool Encountered; public bool ChaseCommitted; public int CoverFailures; public float LostSight; public float UnreachableTime; public float RetreatRemaining; public float WanderClock = 45f; } public sealed class Settings { public bool SingleplayerRules; public bool StatueRules; public float SingleNeglectSeconds = 4f; public float SingleRageMultiplier = 2.4f; public float GroupRageMultiplier = 1.3f; public float SearchSeconds = 21f; public float UnreachableSeconds = 30f; public float PanicSeconds = 16f; public float NeglectSeconds = 16f; public float AlarmDecay = 2f; public float RageSeconds = 10f; public float GroupExitSeconds = 3f; public float ExhaustedSeconds = 3.5f; public float RearmSeconds = 10f; public float TransitionSeconds = 0.8f; public float StartleSeconds = 0.8f; public float AttackSeconds = 1.1f; public float ImpactSeconds = 0.46f; public float AttackCooldown = 2f; public float LowWindupSeconds = 0.2f; public float LowAttackSeconds = 1.25f; public float LowImpactSeconds = 0.28f; public int CalmDamage = 15; public int RageDamage = 35; } public readonly struct Perception { public readonly int VisiblePlayers; public readonly bool Watched; public readonly bool InReach; public readonly bool Provoked; public readonly bool HasMemory; public readonly bool Stunned; public readonly bool Dead; public readonly bool LowTarget; public readonly bool LowReach; public readonly bool Hidden; public readonly bool RunningChase; public readonly bool Roaming; public readonly bool KnownCover; public readonly bool CoverEntry; public readonly bool Vulnerable; public readonly bool Unreachable; public Perception(int visible = 0, bool watched = false, bool reach = false, bool provoked = false, bool memory = false, bool stunned = false, bool dead = false, bool low = false, bool lowReach = false, bool hidden = false, bool runningChase = false, bool roaming = false, bool knownCover = false, bool coverEntry = false, bool vulnerable = false, bool unreachable = false) { VisiblePlayers = visible; Watched = watched; InReach = reach; Provoked = provoked; HasMemory = memory; Stunned = stunned; Dead = dead; LowTarget = low; LowReach = lowReach; Hidden = hidden; RunningChase = runningChase; Roaming = roaming; KnownCover = knownCover; CoverEntry = coverEntry || lowReach; Vulnerable = vulnerable; Unreachable = unreachable; } } public sealed class FlinchBrain { private bool encountered; private bool hitSent; private int attackDamage; private int coverFailures; private float lostSight; private float unreachableTime; private float retreatRemaining; private bool chaseCommitted; private float wanderClock = 45f; public Settings Config { get; } public State State { get; private set; } = State.Patrol; public RageCause Cause { get; private set; } public float StateTime { get; private set; } public float GroupAlarm { get; private set; } public float SoloAlarm { get; private set; } public float RageTime { get; private set; } public float GroupLostTime { get; private set; } public float RearmRemaining { get; private set; } public float AttackRemaining { get; private set; } public int Sequence { get; private set; } public int DamagePulse { get; private set; } public int AttackVariant { get; private set; } public bool Enraged => Cause != RageCause.None; public bool ForcedPursuit => Cause == RageCause.Damage || Cause == RageCause.Provocation; public float SpeedFraction { get; private set; } public bool CoverScanExpired { get; private set; } public FlinchBrain(Settings? settings = null) { Config = settings ?? new Settings(); } public BrainSnapshot Capture() { return new BrainSnapshot { State = State, Cause = Cause, StateTime = StateTime, GroupAlarm = GroupAlarm, SoloAlarm = SoloAlarm, RageTime = RageTime, GroupLostTime = GroupLostTime, RearmRemaining = RearmRemaining, AttackRemaining = AttackRemaining, Sequence = Sequence, AttackDamage = attackDamage, AttackVariant = AttackVariant, HitSent = hitSent, Encountered = encountered, CoverFailures = coverFailures, LostSight = lostSight, UnreachableTime = unreachableTime, RetreatRemaining = retreatRemaining, ChaseCommitted = chaseCommitted, WanderClock = wanderClock }; } public void Restore(BrainSnapshot snapshot) { if (snapshot == null) { throw new ArgumentNullException("snapshot"); } State = snapshot.State; Cause = snapshot.Cause; StateTime = snapshot.StateTime; GroupAlarm = snapshot.GroupAlarm; SoloAlarm = snapshot.SoloAlarm; RageTime = snapshot.RageTime; GroupLostTime = snapshot.GroupLostTime; RearmRemaining = snapshot.RearmRemaining; AttackRemaining = snapshot.AttackRemaining; Sequence = snapshot.Sequence; attackDamage = snapshot.AttackDamage; AttackVariant = snapshot.AttackVariant; hitSent = snapshot.HitSent; encountered = snapshot.Encountered; DamagePulse = 0; coverFailures = snapshot.CoverFailures; lostSight = snapshot.LostSight; unreachableTime = snapshot.UnreachableTime; retreatRemaining = snapshot.RetreatRemaining; chaseCommitted = snapshot.ChaseCommitted; wanderClock = snapshot.WanderClock; } private void Set(State next) { if (State != next) { State = next; StateTime = 0f; Sequence++; } } private void EndRage(State next) { Cause = RageCause.None; float rageTime = (GroupLostTime = (unreachableTime = 0f)); RageTime = rageTime; chaseCommitted = false; coverFailures = 0; Set(next); } private void BeginRage(RageCause cause) { Cause = cause; float rageTime = (GroupLostTime = 0f); RageTime = rageTime; Set(State.RageTransition); } public void ReceiveDamage() { if (State == State.Dead) { return; } encountered = true; RageCause cause = (Config.StatueRules ? RageCause.Damage : RageCause.Provocation); if (Enraged) { Cause = cause; return; } bool flag = State == State.Stunned; retreatRemaining = 0f; coverFailures = 0; lostSight = 0f; BeginRage(cause); SpeedFraction = 0f; if (flag) { Set(State.Stunned); } } public void ReceiveProvocation() { if (State == State.Dead) { return; } encountered = true; if (Enraged) { if (Cause != RageCause.Damage) { Cause = RageCause.Provocation; } } else { retreatRemaining = 0f; coverFailures = 0; lostSight = 0f; BeginRage(RageCause.Provocation); SpeedFraction = 0f; } } private void BeginAttack() { AttackVariant ^= 1; attackDamage = (Enraged ? Config.RageDamage : Config.CalmDamage); AttackRemaining = Math.Max(Config.AttackCooldown, Config.AttackSeconds); hitSent = false; Set(State.Attack); } public void Tick(float dt, Perception input) { if (Config.StatueRules) { TickStatue(dt, input); return; } DamagePulse = 0; if (float.IsNaN(dt) || float.IsInfinity(dt) || dt <= 0f) { return; } if (State == State.Dead) { StateTime += dt; return; } StateTime += dt; RearmRemaining = Math.Max(0f, RearmRemaining - dt); AttackRemaining = Math.Max(0f, AttackRemaining - dt); if (input.Dead) { EndRage(State.Dead); SpeedFraction = 0f; return; } encountered |= input.VisiblePlayers > 0 || input.Provoked || input.LowTarget; if (input.Provoked && State != State.Exhausted) { if (!Enraged) { BeginRage(RageCause.Provocation); } else { Cause = RageCause.Provocation; } } if (input.Stunned) { Set(State.Stunned); SpeedFraction = 0f; return; } if (State == State.Stunned) { Set(State.CalmDown); } int num = Math.Max(0, input.VisiblePlayers); bool flag = !Config.SingleplayerRules && num >= 2; float num2 = (Config.SingleplayerRules ? Config.SingleNeglectSeconds : Config.NeglectSeconds); GroupAlarm = (flag ? Math.Min(Config.PanicSeconds, GroupAlarm + dt) : Math.Max(0f, GroupAlarm - Config.AlarmDecay * dt)); bool flag2 = !input.Watched && (Config.SingleplayerRules ? encountered : (num == 1)); SoloAlarm = (flag2 ? Math.Min(num2, SoloAlarm + dt) : Math.Max(0f, SoloAlarm - Config.AlarmDecay * dt)); if (State == State.Exhausted) { SpeedFraction = 0f; if (StateTime < Config.ExhaustedSeconds) { return; } Set(State.CalmDown); } if (Enraged && State != State.RageTransition) { RageTime += dt; GroupLostTime = (flag ? 0f : (GroupLostTime + dt)); if (RageTime >= Config.RageSeconds) { RearmRemaining = Config.RearmSeconds; float groupAlarm = (SoloAlarm = 0f); GroupAlarm = groupAlarm; EndRage(State.Exhausted); SpeedFraction = 0f; return; } if (Cause == RageCause.Group && GroupLostTime >= Config.GroupExitSeconds) { EndRage(State.CalmDown); } else if (!Config.SingleplayerRules && Cause == RageCause.Neglect && num == 1 && input.Watched) { EndRage(State.CalmDown); } else if (!Config.SingleplayerRules && num == 0 && !input.HasMemory) { EndRage(State.CalmDown); } } if (State == State.RageTransition) { SpeedFraction = 0f; if (StateTime >= Config.TransitionSeconds) { Set(State.Chase); } return; } if (State == State.Attack) { SpeedFraction = 0f; if (!hitSent && StateTime >= Config.ImpactSeconds) { hitSent = true; DamagePulse = attackDamage; } if (StateTime < Config.AttackSeconds) { return; } Set(Enraged ? State.Chase : State.CalmDown); } if (State == State.LookUnder) { SpeedFraction = 0f; if (Enraged && input.LowTarget) { if (!(StateTime < Config.LowWindupSeconds)) { attackDamage = Config.RageDamage; AttackRemaining = Config.AttackCooldown; hitSent = false; Set(State.UnderAttack); } return; } Set(State.Chase); } if (State == State.UnderAttack) { SpeedFraction = 0f; if (!hitSent && StateTime >= Config.LowImpactSeconds) { hitSent = true; if (Enraged && input.LowTarget && input.LowReach) { DamagePulse = attackDamage; } } if (StateTime < Config.LowAttackSeconds) { return; } Set(Enraged ? State.Chase : State.CalmDown); } if (Enraged) { Set(State.Chase); float num4 = (Config.SingleplayerRules ? Config.SingleRageMultiplier : Config.GroupRageMultiplier); SpeedFraction = ((Cause == RageCause.Group && !flag) ? (num4 * (1f - 0.65f * Math.Min(1f, GroupLostTime / Config.GroupExitSeconds))) : num4); if (input.LowTarget && input.LowReach && AttackRemaining <= 0f) { Set(State.LookUnder); SpeedFraction = 0f; } else if (input.InReach && num > 0 && AttackRemaining <= 0f) { BeginAttack(); } return; } if (RearmRemaining <= 0f) { if (flag && GroupAlarm >= Config.PanicSeconds) { BeginRage(RageCause.Group); SpeedFraction = 0f; return; } if (!flag && flag2 && SoloAlarm >= num2) { BeginRage(RageCause.Neglect); SpeedFraction = 0f; return; } } if (Config.SingleplayerRules) { Set(input.Watched ? State.Observe : (encountered ? State.Stalk : State.Patrol)); SpeedFraction = (input.Watched ? 0f : (encountered ? (0.8f + 0.3f * (SoloAlarm / Math.Max(0.01f, num2))) : 0.7f)); } else if (flag) { if (State != State.Panic && State != State.Startle) { Set(State.Startle); } if (State == State.Startle && StateTime >= Config.StartleSeconds) { Set(State.Panic); } SpeedFraction = -0.18f; } else if (num == 1) { Set(input.Watched ? State.Observe : State.Stalk); float num5 = ((Config.NeglectSeconds > 0f) ? (SoloAlarm / Config.NeglectSeconds) : 1f); SpeedFraction = (input.Watched ? 0.25f : (0.3f + 0.8f * num5)); } else { Set(input.HasMemory ? State.Stalk : State.Patrol); SpeedFraction = (input.HasMemory ? 0.35f : 0.3f); } } public void FinishSearch() { EndRage(State.Patrol); encountered = false; float soloAlarm = (GroupAlarm = 0f); SoloAlarm = soloAlarm; lostSight = 0f; SpeedFraction = 0.7f; } public void CoverResult(bool success) { if (Config.StatueRules && Enraged) { coverFailures = ((!success) ? (coverFailures + 1) : 0); if (coverFailures >= 3) { GiveUp(); } else if (!success) { AttackRemaining = Math.Max(AttackRemaining, 2.2f); } } } private void GiveUp() { EndRage(State.Retreat); float soloAlarm = (GroupAlarm = 0f); SoloAlarm = soloAlarm; encountered = false; retreatRemaining = 10f; RearmRemaining = Math.Max(18f, Config.RearmSeconds); SpeedFraction = 0.7f; } private void TickStatue(float dt, Perception input) { DamagePulse = 0; CoverScanExpired = false; if (float.IsNaN(dt) || float.IsInfinity(dt) || dt <= 0f) { return; } if (State == State.Dead) { StateTime += dt; return; } StateTime += dt; AttackRemaining = Math.Max(0f, AttackRemaining - dt); RearmRemaining = Math.Max(0f, RearmRemaining - dt); retreatRemaining = Math.Max(0f, retreatRemaining - dt); if (input.Dead) { EndRage(State.Dead); SpeedFraction = 0f; return; } bool flag = input.VisiblePlayers > 0 || input.KnownCover; if (retreatRemaining <= 0f) { encountered |= flag; } lostSight = (flag ? 0f : (lostSight + dt)); if (input.Provoked) { ReceiveProvocation(); } if (input.Stunned) { Set(State.Stunned); SpeedFraction = 0f; return; } if (State == State.Stunned) { Set(State.CalmDown); } if (Enraged && State == State.Chase && input.RunningChase) { chaseCommitted = true; } if (input.Hidden && !input.KnownCover && input.VisiblePlayers == 0 && !chaseCommitted && retreatRemaining <= 0f && State != State.Exhausted && (!input.Watched || ForcedPursuit)) { GiveUp(); return; } bool flag2 = input.Watched && !ForcedPursuit; SoloAlarm = (flag2 ? Math.Max(0f, SoloAlarm - Config.AlarmDecay * dt) : (encountered ? Math.Min(Config.SingleNeglectSeconds, SoloAlarm + dt) : 0f)); GroupAlarm = 0f; if (State == State.Exhausted) { SpeedFraction = 0f; if (StateTime < Config.ExhaustedSeconds) { return; } Set(State.CalmDown); } if (Enraged && State != State.RageTransition) { RageTime += dt; bool flag3 = input.Unreachable || (!flag && !input.HasMemory); unreachableTime = (flag3 ? (unreachableTime + dt) : 0f); if (unreachableTime >= Config.UnreachableSeconds) { GiveUp(); return; } } if (flag2) { if (Enraged && SoloAlarm <= 0f) { EndRage(State.Observe); } Set(State.Observe); SpeedFraction = 0f; return; } if (retreatRemaining > 0f) { Set(State.Retreat); SpeedFraction = 0.7f; return; } if (State == State.RageTransition) { SpeedFraction = 0f; if (StateTime >= (ForcedPursuit ? 0.25f : Config.TransitionSeconds)) { Set(State.Chase); } return; } if (State == State.Attack) { SpeedFraction = 0f; if (!hitSent && StateTime >= Config.ImpactSeconds) { hitSent = true; DamagePulse = attackDamage; } if (StateTime < Config.AttackSeconds) { return; } Set(State.Chase); } if (State == State.LookUnder) { SpeedFraction = 0f; if (!input.LowTarget) { Set(State.Chase); } else if (!input.LowReach && !input.CoverEntry) { Set(State.InspectUnder); } else if (!(StateTime < Config.LowWindupSeconds)) { attackDamage = Config.RageDamage; AttackRemaining = Config.AttackCooldown; hitSent = false; Set(State.UnderAttack); } return; } if (State == State.InspectUnder) { SpeedFraction = 0f; if (!input.LowTarget) { Set(State.Chase); return; } bool flag4 = input.KnownCover && input.CoverEntry && StateTime >= 1.25f; if ((input.LowReach || flag4) && AttackRemaining <= 0f) { Set(State.LookUnder); } else { CoverScanExpired = !input.LowReach && StateTime >= 1.25f && StateTime - dt < 1.25f; } return; } if (State == State.UnderAttack) { SpeedFraction = 0f; if (!hitSent && StateTime >= Config.LowImpactSeconds) { hitSent = true; DamagePulse = attackDamage; } if (StateTime < Config.LowAttackSeconds) { return; } if (input.LowTarget) { Set(State.InspectUnder); return; } Set(State.Chase); } if (Enraged) { Set(State.Chase); SpeedFraction = Config.SingleRageMultiplier; if (input.LowTarget && input.LowReach && (chaseCommitted || (ForcedPursuit && input.KnownCover)) && AttackRemaining <= 0f) { Set(State.LookUnder); SpeedFraction = 0f; } else if (input.LowTarget && input.CoverEntry && (chaseCommitted || (ForcedPursuit && input.KnownCover)) && AttackRemaining <= 0f) { Set(State.InspectUnder); SpeedFraction = 0f; } else if (input.InReach && input.VisiblePlayers > 0 && AttackRemaining <= 0f) { BeginAttack(); } return; } if (input.Vulnerable && input.VisiblePlayers > 0 && !input.Hidden && retreatRemaining <= 0f && RearmRemaining <= 0f) { coverFailures = 0; BeginRage(RageCause.Neglect); Set(State.Chase); SpeedFraction = Config.SingleRageMultiplier; return; } if (lostSight >= Config.SearchSeconds) { encountered = false; SoloAlarm = 0f; } if (encountered && SoloAlarm >= Config.SingleNeglectSeconds && RearmRemaining <= 0f) { coverFailures = 0; BeginRage(RageCause.Neglect); SpeedFraction = 0f; return; } if (State == State.RoamBurst && !encountered) { if (StateTime < 2.7f) { SpeedFraction = ((StateTime < 0.55f) ? 0f : 2.6f); return; } Set(State.Patrol); } if (!encountered && input.Roaming) { wanderClock -= dt; if (wanderClock <= 0f) { wanderClock = 55 + Sequence * 17 % 35; Set(State.RoamBurst); SpeedFraction = 0f; return; } } Set(encountered ? State.Stalk : State.Patrol); SpeedFraction = (encountered ? (0.45f + 0.65f * (SoloAlarm / Math.Max(0.01f, Config.SingleNeglectSeconds))) : 0.7f); } } public static class FrontGaze { public static bool FacesViewer(float forwardX, float forwardZ, float viewerX, float viewerZ) { return forwardX * viewerX + forwardZ * viewerZ > 0f; } } public readonly struct GazeCandidate { public readonly int Id; public readonly float Distance; public readonly bool Visible; public readonly bool Alive; public GazeCandidate(int id, float distance, bool visible = true, bool alive = true) { Id = id; Distance = distance; Visible = visible; Alive = alive; } } public sealed class GazeSelector { private float heldUntil; public int Target { get; private set; } = -1; public int Select(IReadOnlyList<GazeCandidate> candidates, float time, int provoker = -1) { int num = -1; float num2 = float.PositiveInfinity; float num3 = float.PositiveInfinity; bool flag = false; for (int i = 0; i < candidates.Count; i++) { GazeCandidate gazeCandidate = candidates[i]; if (!gazeCandidate.Alive || !gazeCandidate.Visible || gazeCandidate.Distance < 0f || float.IsNaN(gazeCandidate.Distance) || float.IsInfinity(gazeCandidate.Distance)) { continue; } if (gazeCandidate.Id == provoker) { if (Target != gazeCandidate.Id) { Target = gazeCandidate.Id; heldUntil = time + 3f; } return Target; } if (gazeCandidate.Id == Target) { flag = true; num3 = gazeCandidate.Distance; } if (gazeCandidate.Distance < num2 || (gazeCandidate.Distance == num2 && (num < 0 || gazeCandidate.Id < num))) { num = gazeCandidate.Id; num2 = gazeCandidate.Distance; } } if (flag && (time < heldUntil || num2 >= num3 * 0.65f)) { return Target; } if (Target != num) { Target = num; heldUntil = time + 3f; } return Target; } } public static class GroundMotor { public static Vector2 Delta(float x, float z, float targetX, float targetZ, float acceleration, float dt) { if (dt <= 0f || float.IsNaN(dt) || float.IsInfinity(dt)) { return Vector2.Zero; } Vector2 vector = new Vector2(targetX - x, targetZ - z); float num = vector.Length(); float num2 = Math.Max(0f, acceleration) * dt; return (num > num2 && num > 0f) ? (vector * (num2 / num)) : vector; } } public sealed class RouteProgress { private float time; private float travel; public bool Tick(bool requested, float distance, float dt) { if (!requested) { time = (travel = 0f); return false; } time += dt; travel += Math.Max(0f, distance); if (travel >= 0.2f) { time = (travel = 0f); return false; } if (time < 3f) { return false; } time = (travel = 0f); return true; } } public static class LiftGate { public static bool Allows(int strengthUpgradeLevel, int requiredLevel) { return strengthUpgradeLevel >= requiredLevel; } } public static class LocomotionRules { public static float Probe(float speed, float dt) { return Math.Min(0.35f, Math.Max(0.12f, Math.Abs(speed) * Math.Min(0.05f, Math.Max(0.01f, dt)) + 0.1f)); } public static bool NavSurface(float horizontalError, float heightError, bool sameFreeSurface) { return horizontalError < 0.65f && Math.Abs(heightError) < 0.25f && sameFreeSurface; } public static float Duck(float freeHeight, float undersideNormalY) { return (undersideNormalY < -0.4f) ? Math.Max(0f, Math.Min(1f, (2.45f - freeHeight) / 0.7f)) : 0f; } } public static class ContactRules { public static bool Provokes(bool explicitGrab) { return explicitGrab; } } public static class DeathRules { public static bool HideBody(bool deathStarted) { return deathStarted; } public static bool Cleanup(float age, bool soulSpawned) { return (soulSpawned && age >= 0.25f) || age >= 3f; } } public static class MeleeWindow { public static bool Active(State state, float previousPhase, float phase) { return state == State.Attack && phase >= 0.36f && previousPhase <= 0.68f && phase >= previousPhase; } } public static class NativeBehaviour { public const float SearchSeconds = 20f; public const float RoamMinimum = 5f; public const float RoamMaximum = 15f; public const float RoamArrival = 2f; public static bool Breathing(State state, float speed, bool present) { return present && state == State.Observe && speed < 0.08f; } public static float PushAcceleration(bool cart, float alongSpeed, float mass, float dt) { float num = (cart ? 0.65f : 1.25f); return Math.Max(0f, Math.Min(cart ? 1.2f : 4f, (num - alongSpeed) / Math.Max(0.01f, dt))); } public static bool ReverseThroughNeck(float facingDot, bool turnFits, bool lowCeiling) { return facingDot < -0.25f && (lowCeiling || !turnFits); } public static float SpawnChance(int level, float first, float early, float middle, float late) { return (level < 1) ? 0f : ((level < 3) ? first : ((level < 6) ? early : ((level < 10) ? middle : late))); } } public sealed class RoamClock { public bool Selected { get; private set; } public float IdleRemaining { get; private set; } public float BlockedRemaining { get; private set; } = 5f; public void Idle(float seconds) { Selected = false; IdleRemaining = seconds; BlockedRemaining = 5f; } public void Select() { Selected = true; IdleRemaining = 0f; BlockedRemaining = 5f; } public float[] Capture() { return new float[3] { Selected ? 1f : 0f, IdleRemaining, BlockedRemaining }; } public void Restore(float selected, float idle, float blocked) { Selected = selected > 0f; IdleRemaining = Math.Max(0f, idle); BlockedRemaining = Math.Max(0f, blocked); } public bool Tick(float dt, float distance, float notMoving, bool frozen, bool spawnPaused, float idleSeconds) { if (frozen) { return false; } if (!Selected) { if (!spawnPaused) { IdleRemaining = Math.Max(0f, IdleRemaining - dt); } return IdleRemaining <= 0f; } if (distance < 2f) { Idle(idleSeconds); return false; } if (notMoving > 1f) { BlockedRemaining -= dt; } if (BlockedRemaining <= 0f) { Idle(idleSeconds); return false; } return false; } } public enum ObstructionAction { None, Warn, Break } public sealed class ObstructionClock { private int blocker; private float age; private float moved; private bool warned; private bool broken; public bool Pending => age >= 0.5f && !broken; public ObstructionAction Tick(int id, bool trying, float progress, float dt) { if (!trying || id != blocker) { blocker = id; age = (moved = 0f); warned = (broken = false); } moved += progress; if (moved > 0.12f) { age = (moved = 0f); warned = (broken = false); return ObstructionAction.None; } if (!trying || id == 0) { return ObstructionAction.None; } age += dt; if (age >= 4f && !broken) { broken = true; return ObstructionAction.Break; } if (age >= 3f && !warned) { warned = true; return ObstructionAction.Warn; } return ObstructionAction.None; } } public sealed class PathCursor { private int next; public int Next => next; public void Reset() { next = 0; } public int Advance(float[] distances, float arrival = 0.25f, float turnArrival = 0.35f) { while (next < distances.Length && distances[next] < ((next == distances.Length - 1) ? arrival : turnArrival)) { next++; } return next; } } public sealed class PcmWave { public int Rate; public int Channels; public float[] Samples = Array.Empty<float>(); public static PcmWave Read(Stream stream) { BinaryReader reader = new BinaryReader(stream, Encoding.ASCII, leaveOpen: true); try { if (stream.Length < 12 || Tag() != "RIFF") { throw new InvalidDataException("Invalid WAV header"); } long num = (long)reader.ReadUInt32() + 8L; if (num > stream.Length || num < 12 || Tag() != "WAVE") { throw new InvalidDataException("Truncated WAV"); } int num2 = 0; int num3 = 0; byte[] array = null; while (stream.Position + 8 <= num) { string text = Tag(); uint num4 = reader.ReadUInt32(); long num5 = stream.Position + num4 + (num4 & 1); if (num5 > num || num4 > 33554432) { throw new InvalidDataException("Invalid WAV chunk"); } if (text == "fmt ") { if (num4 < 16) { throw new InvalidDataException("Invalid WAV format"); } int num6 = reader.ReadUInt16(); num2 = reader.ReadUInt16(); num3 = reader.ReadInt32(); int num7 = reader.ReadInt32(); int num8 = reader.ReadUInt16(); int num9 = reader.ReadUInt16(); if (num6 != 1 || num2 < 1 || num2 > 2 || num3 < 8000 || num3 > 96000 || num9 != 16 || num8 != num2 * 2 || num7 != num3 * num8) { throw new InvalidDataException("Only PCM16 mono/stereo supported"); } } else if (text == "data") { array = reader.ReadBytes((int)num4); } stream.Position = num5; } if (num2 == 0 || array == null || array.Length == 0 || array.Length % (num2 * 2) != 0) { throw new InvalidDataException("Missing WAV samples"); } PcmWave pcmWave = new PcmWave(); pcmWave.Rate = num3; pcmWave.Channels = num2; pcmWave.Samples = new float[array.Length / 2]; PcmWave pcmWave2 = pcmWave; for (int i = 0; i < pcmWave2.Samples.Length; i++) { pcmWave2.Samples[i] = (float)(short)(array[i * 2] | (array[i * 2 + 1] << 8)) / 32768f; } return pcmWave2; } finally { if (reader != null) { ((IDisposable)reader).Dispose(); } } string Tag() { return Encoding.ASCII.GetString(reader.ReadBytes(4)); } } } public static class ReachEnvelope { public static bool Allows(float horizontal, float vertical) { return horizontal >= 0f && horizontal * horizontal + vertical * vertical <= 3.8025002f; } } public sealed class RearSurprise { private float rearMemory; private float cooldown; public bool Tick(float dt, bool closeBehind, bool stoppedByThisViewer) { cooldown = Math.Max(0f, cooldown - dt); rearMemory = Math.Max(0f, rearMemory - dt); if (closeBehind) { rearMemory = 1.2f; } if (!stoppedByThisViewer || rearMemory <= 0f || cooldown > 0f) { return false; } rearMemory = 0f; cooldown = 45f; return true; } } public sealed class ReturnTrail { private readonly List<KnowledgePoint> points = new List<KnowledgePoint>(); public KnowledgePoint[] Capture() { return points.ToArray(); } public void Restore(IEnumerable<KnowledgePoint> saved) { points.Clear(); foreach (KnowledgePoint item in saved) { if (points.Count >= 64) { break; } points.Add(item); } } public void Record(KnowledgePoint point, bool onNavigationSurface) { if (onNavigationSurface) { points.Clear(); points.Add(point); return; } if (points.Count == 0 || points[points.Count - 1].Distance(point) > 0.25f) { points.Add(point); } if (points.Count > 64) { points.RemoveAt(1); } } public KnowledgePoint[] Backtrack(KnowledgePoint current) { List<KnowledgePoint> list = new List<KnowledgePoint>(); for (int num = points.Count - 1; num >= 0; num--) { if (points[num].Distance(current) > 0.15f) { list.Add(points[num]); } } return list.ToArray(); } } public readonly struct SearchPoint { public readonly int Id; public readonly float PathLength; public readonly float ClueDistance; public readonly bool Reachable; public SearchPoint(int id, float pathLength, float clueDistance = 0f, bool reachable = true) { Id = id; PathLength = pathLength; ClueDistance = clueDistance; Reachable = reachable; } } public sealed class SearchRoute { private readonly Dictionary<int, float> visited = new Dictionary<int, float>(); public static bool IsSelected(int id) { return id != -1; } public void Visit(int id, float time) { visited[id] = time; } public float RecentPenalty(int id, float time) { float value; return visited.TryGetValue(id, out value) ? (Math.Max(0f, 45f - (time - value)) * 2f) : 0f; } public int Choose(IReadOnlyList<SearchPoint> points, float time, bool followingClue) { int result = -1; float num = float.PositiveInfinity; for (int i = 0; i < points.Count; i++) { SearchPoint searchPoint = points[i]; if (searchPoint.Reachable && !(searchPoint.PathLength < 0.3f) && !float.IsNaN(searchPoint.PathLength) && !float.IsInfinity(searchPoint.PathLength)) { float num2 = searchPoint.PathLength + RecentPenalty(searchPoint.Id, time) + (followingClue ? (Math.Max(0f, searchPoint.ClueDistance) * 0.3f) : 0f); if (num2 < num) { num = num2; result = searchPoint.Id; } } } return result; } } public static class StandingGaze { public static bool Eligible(bool crouching, bool crawling, bool tumbling) { return !crouching && !crawling && !tumbling; } } public sealed class SharedGaze { private struct Sample { public bool Eligible; public bool Watching; public float At; public float Positive; } private readonly Dictionary<int, Sample> samples = new Dictionary<int, Sample>(); public void Clear() { samples.Clear(); } public void Report(int id, bool watching, bool eligible, float now) { samples.TryGetValue(id, out var value); if (!samples.ContainsKey(id)) { value.Positive = -100f; } value.At = now; value.Eligible = eligible; value.Watching = watching; if (watching && eligible) { value.Positive = now; } samples[id] = value; } public bool Watched(float now) { foreach (Sample value in samples.Values) { if (value.Eligible && now - value.At <= 0.3f && (value.Watching || now - value.Positive < 0.12f)) { return true; } } return false; } } public static class ShelterRules { public static bool CanFreeze(bool crawling, bool overheadCover) { return !(crawling && overheadCover); } public static bool RecognizesLastTarget(bool sameTarget, float age, float displacement) { return sameTarget && age >= 0f && age < 6f && displacement < 2.5f; } } public sealed class SoulReward { private bool claimed; public int Claim(float sample) { if (claimed) { return 0; } claimed = true; if (float.IsNaN(sample)) { sample = 0f; } return 4000 + 100 * Math.Min(30, (int)(Math.Max(0f, Math.Min(1f, sample)) * 31f)); } } public sealed class SoundMemory { public const float SearchSeconds = 2.5f; private const float BlockedSeconds = 5f; private const float ArrivalDistance = 0.55f; private const float ArrivalHeight = 0.4f; private float heardAt = float.NegativeInfinity; private float score; private float blockedRemaining = 5f; public float SearchRemaining { get; private set; } public bool Searching => SearchRemaining > 0f; public bool Active(float now) { return !float.IsNegativeInfinity(heardAt); } public static bool WithinArrival(float horizontalDistance, float elevationDelta) { return horizontalDistance <= 0.55f && Math.Abs(elevationDelta) <= 0.4f; } public void Tick(float dt, float horizontalDistance, float elevationDelta, bool blocked) { if (!Active(0f) || dt <= 0f || float.IsNaN(dt) || float.IsInfinity(dt)) { return; } if (Searching) { SearchRemaining -= dt; if (SearchRemaining <= 0.0001f) { Clear(); } return; } if (WithinArrival(horizontalDistance, elevationDelta)) { SearchRemaining = 2.5f; return; } if (blocked) { blockedRemaining -= dt; } if (blockedRemaining <= 0.0001f) { Clear(); } } public float[] Capture(float now) { return new float[5] { Active(now) ? 1f : 0f, Active(now) ? (now - heardAt) : 0f, score, blockedRemaining, SearchRemaining }; } public void Restore(float now, float active, float age, float strength, float blocked, float search = 0f) { if (active <= 0f) { Clear(); return; } heardAt = now - age; score = strength; blockedRemaining = blocked; SearchRemaining = search; } public bool Hear(float distance, float radius, bool occluded, float now, bool sameSource = false) { if (float.IsNaN(distance) || float.IsNaN(radius) || float.IsInfinity(distance) || radius <= 0f || distance < 0f) { return false; } float num = Math.Min(radius, 35f) * (occluded ? 0.6f : 1f); if (distance >= num) { return false; } float num2 = num - distance; if (Active(now) && (sameSource || (now - heardAt < 2f && num2 < score * 0.45f))) { return false; } heardAt = now; score = num2; blockedRemaining = 5f; SearchRemaining = 0f; return true; } public void Clear() { heardAt = float.NegativeInfinity; score = 0f; blockedRemaining = 5f; SearchRemaining = 0f; } } public static class StairStep { public static float Delta(float rise, float upwardSpeed, float dt, bool clear, bool moving) { if (!clear || !moving || rise < 0.025f || rise > 0.34f || dt <= 0f || float.IsNaN(dt) || float.IsInfinity(dt) || float.IsNaN(rise) || float.IsNaN(upwardSpeed)) { return 0f; } float num = Math.Min(2.1f, 0.35f + rise * 5f); float val = 16f * Math.Min(dt, 0.05f); return Math.Max(0f, Math.Min(val, num - upwardSpeed)); } } public static class StealthAudio { public const float DetectGain = 0.3f; public const float DetectRange = 9f; public static float StepGain(bool pursuit) { return pursuit ? 0.5f : 0.18f; } public static float StepRange(bool pursuit) { return pursuit ? 18f : 5f; } } public sealed class StrideClock { public float Phase { get; private set; } public void Advance(float distance, float travelPerCycle) { if (!float.IsNaN(distance) && !float.IsInfinity(distance) && !(distance <= 0f) && !(travelPerCycle <= 0f)) { Phase = (Phase + distance / travelPerCycle) % 1f; } } } public sealed class StrikeLatch { private bool open; private int openedAt; public bool Tick(State state, int frame, bool requested) { if (state != State.Attack) { open = false; return false; } if (requested && !open) { openedAt = frame; } open = requested || (open && frame <= openedAt + 1); return open; } } public readonly struct KnowledgePoint { public readonly float X; public readonly float Y; public readonly float Z; public KnowledgePoint(float x, float y, float z) { X = x; Y = y; Z = z; } public float Distance(KnowledgePoint p) { return (float)Math.Sqrt((X - p.X) * (X - p.X) + (Y - p.Y) * (Y - p.Y) + (Z - p.Z) * (Z - p.Z)); } } public sealed class TargetKnowledge { public const float TrackingSeconds = 5f; public int Id = -1; public KnowledgePoint LastSeen; public KnowledgePoint CoverPoint; public float SeenAt = -100f; public float CoverUntil = -100f; public float AnchorAt = -100f; public static float ObservationTime(float now, float sentAge, float transitAge) { if (float.IsNaN(now) || float.IsInfinity(now)) { return float.NegativeInfinity; } if (float.IsNaN(sentAge) || float.IsInfinity(sentAge) || float.IsNaN(transitAge) || float.IsInfinity(transitAge)) { return now - 5f; } return now - Math.Max(0f, sentAge) - Math.Max(0f, transitAge); } public void See(int id, KnowledgePoint point, float now, bool frontal = true) { if (Id != id) { AnchorAt = -100f; } Id = id; LastSeen = point; SeenAt = now; CoverUntil = -100f; if (frontal) { AnchorAt = now; } } public bool RecentRear(int id, float now, float distance) { return Id == id && now - AnchorAt < 2.5f && distance <= 3f; } public bool Hide(int id, KnowledgePoint point, float now, bool witnessed) { if (CoverKnown(now) || !witnessed || Id != id || now - SeenAt > 2f || LastSeen.Distance(point) > 3f) { return false; } CoverPoint = point; CoverUntil = now + 22f; return true; } public bool CoverKnown(float now) { return Id >= 0 && now < CoverUntil; } public bool TrackingActive(float now) { return Id >= 0 && now >= SeenAt && now - SeenAt < 5f && !CoverKnown(now); } public bool UpdateTracking(int id, KnowledgePoint point, float now) { if (id < 0 || Id != id || !TrackingActive(now)) { return false; } LastSeen = point; return true; } public bool RecordGrab(int id, KnowledgePoint point, float now, bool verifiedAttempt, bool sheltered) { if (id < 0 || !ContactRules.Provokes(verifiedAttempt)) { return false; } See(id, point, now, frontal: false); if (sheltered) { CoverPoint = point; CoverUntil = now + 22f; } return true; } public bool ObserveCover(int id, KnowledgePoint point, float now, bool visible) { if (!visible || Id != id || !CoverKnown(now)) { return false; } CoverPoint = point; CoverUntil = now + 22f; SeenAt = now; return true; } public void Forget() { Id = -1; SeenAt = (CoverUntil = (AnchorAt = -100f)); } } public sealed class TravelWatch { private KnowledgePoint anchor; private bool anchored; private float age; public void Reset() { anchored = false; age = 0f; } public bool Tick(KnowledgePoint position, bool tryingToTravel, float dt) { if (!tryingToTravel) { Reset(); return false; } if (float.IsNaN(dt) || float.IsInfinity(dt) || dt <= 0f) { return false; } if (!anchored) { anchor = position; anchored = true; age = 0f; } float num = position.X - anchor.X; float num2 = position.Z - anchor.Z; if (num * num + num2 * num2 >= 0.09f) { anchor = position; age = 0f; } else { age += Math.Min(dt, 0.25f); } return age >= 5f; } } public static class VisionLayers { public static int Environment(int gameVisionMask, int playerMask) { return gameVisionMask & ~playerMask; } } } namespace Flinch.Mod { public sealed class AttackStep { private int sequence = -1; private float travelled; private float entrySpeed; private Vector3 previous; private Vector3 heading; public Vector3 Plan(Vector3 position, Quaternion rotation, Vector3 target, float phase, int nextSequence, float dt, Vector3 incoming = default(Vector3)) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) Vector3 val; if (sequence != nextSequence) { sequence = nextSequence; travelled = 0f; previous = position; val = Vector3.ProjectOnPlane(target - position, Vector3.up); heading = ((Vector3)(ref val)).normalized; entrySpeed = Mathf.Clamp(Vector3.Dot(incoming, heading), 0f, 3.2f); } travelled += Mathf.Max(0f, Vector3.Dot(position - previous, heading)); previous = position; if (phase < 0.2f) { val = Vector3.ProjectOnPlane(target - position, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude > 0.1f) { heading = Vector3.RotateTowards(heading, normalized, 2.2f * dt, 0f); } } if (phase > 0.72f || ((Vector3)(ref heading)).sqrMagnitude < 0.1f) { return Vector3.zero; } float num = entrySpeed * 0.1f * Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0f, 0.23f, phase)); float num2 = 0.72f * Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.1f, 0.52f, phase)) + num; float num3 = Mathf.Min(4.5f, Mathf.Max(0f, num2 - travelled) / Mathf.Max(0.04f, dt)); if (phase < 0.18f && travelled < 0.24f) { num3 = Mathf.Max(num3, entrySpeed * (1f - Mathf.InverseLerp(0.05f, 0.18f, phase))); } RaycastHit[] array = Physics.SphereCastAll(position + Vector3.up * 0.55f, 0.3f, heading, 0.9f, WorldQueries.Mask, (QueryTriggerInteraction)1); for (int i = 0; i < array.Length; i++) { RaycastHit val2 = array[i]; if (WallSafety.BlocksMovement(((RaycastHit)(ref val2)).collider) && Mathf.Abs(((RaycastHit)(ref val2)).normal.y) < 0.6f) { num3 = Mathf.Min(num3, Mathf.Sqrt(64f * Mathf.Max(0f, ((RaycastHit)(ref val2)).distance - 0.05f))); } } return heading * num3; } } public sealed class AuthoredAttackPose { private static readonly float[] SillProbes = new float[4] { 0.12f, 0.23f, 0.34f, 0f }; private readonly FlinchMotion motion; private int sequence = -1; private Vector3 lockedTarget; private Vector3 lastTarget; private Vector3 leadFoot; private bool tracking; private bool raised; private bool throughOpening; private float raisedFloor; private float sillHeight; private float exitBlend; public AuthoredAttackPose(FlinchMotion motion) { this.motion = motion; } private static float Ease(float a, float b, float t) { return Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(a, b, t)); } private static bool TrySill(Vector3 body, Vector3 target, float targetFloor, out float height) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00cc: 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) height = 0f; Vector3 val = Vector3.ProjectOnPlane(target - body, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return false; } Vector3 normalized = ((Vector3)(ref val)).normalized; float[] sillProbes = SillProbes; foreach (float num in sillProbes) { Vector3 origin = body; origin.y = target.y - num; if (WorldQueries.Raycast(origin, normalized, ((Vector3)(ref val)).magnitude, out var hit) && !(Mathf.Abs(((RaycastHit)(ref hit)).normal.y) > 0.5f)) { Vector3 point = ((RaycastHit)(ref hit)).point + normalized * 0.07f; if (GroundSupport.Floor(point, 0.4f, 0.1f, out var floor) && !(floor.Position.y <= targetFloor + 0.2f)) { height = floor.Position.y; return true; } } } return false; } public void Pose(State state, float phase, Vector3 target, int nextSequence, int variant, float dt) { //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0311: 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_0318: 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_030a: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_063a: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06c0: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_06fd: Unknown result type (might be due to invalid IL or missing references) //IL_0702: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_0750: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c0: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_07d7: Unknown result type (might be due to invalid IL or missing references) //IL_0805: Unknown result type (might be due to invalid IL or missing references) //IL_0812: Unknown result type (might be due to invalid IL or missing references) //IL_0817: Unknown result type (might be due to invalid IL or missing references) //IL_081c: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_082c: Unknown result type (might be due to invalid IL or missing references) //IL_0881: Unknown result type (might be due to invalid IL or missing references) //IL_0888: Unknown result type (might be due to invalid IL or missing references) //IL_0895: Unknown result type (might be due to invalid IL or missing references) //IL_089a: Unknown result type (might be due to invalid IL or missing references) //IL_089f: Unknown result type (might be due to invalid IL or missing references) //IL_08af: Unknown result type (might be due to invalid IL or missing references) //IL_08be: Unknown result type (might be due to invalid IL or missing references) //IL_091a: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Unknown result type (might be due to invalid IL or missing references) //IL_093f: Unknown result type (might be due to invalid IL or missing references) //IL_0943: Unknown result type (might be due to invalid IL or missing references) //IL_0949: Unknown result type (might be due to invalid IL or missing references) //IL_08fd: Unknown result type (might be due to invalid IL or missing references) //IL_0964: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Unknown result type (might be due to invalid IL or missing references) //IL_096f: Unknown result type (might be due to invalid IL or missing references) //IL_0997: Unknown result type (might be due to invalid IL or missing references) //IL_099c: Unknown result type (might be due to invalid IL or missing references) //IL_09a2: Unknown result type (might be due to invalid IL or missing references) //IL_09bb: Unknown result type (might be due to invalid IL or missing references) //IL_09c0: Unknown result type (might be due to invalid IL or missing references) //IL_09c5: Unknown result type (might be due to invalid IL or missing references) //IL_09c9: Unknown result type (might be due to invalid IL or missing references) //IL_09cb: Unknown result type (might be due to invalid IL or missing references) //IL_0a1b: Unknown result type (might be due to invalid IL or missing references) //IL_0a20: Unknown result type (might be due to invalid IL or missing references) //IL_0a27: Unknown result type (might be due to invalid IL or missing references) //IL_0a2d: Unknown result type (might be due to invalid IL or missing references) //IL_0a33: Unknown result type (might be due to invalid IL or missing references) //IL_0a3d: Unknown result type (might be due to invalid IL or missing references) //IL_0a42: Unknown result type (might be due to invalid IL or missing references) //IL_0a6e: Unknown result type (might be due to invalid IL or missing references) //IL_0a75: Unknown result type (might be due to invalid IL or missing references) //IL_0a7a: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) //IL_0aaa: Unknown result type (might be due to invalid IL or missing references) //IL_0aaf: Unknown result type (might be due to invalid IL or missing references) //IL_0ab1: Unknown result type (might be due to invalid IL or missing references) //IL_0ab5: Unknown result type (might be due to invalid IL or missing references) //IL_0aba: Unknown result type (might be due to invalid IL or missing references) //IL_0abf: Unknown result type (might be due to invalid IL or missing references) //IL_0ac6: Unknown result type (might be due to invalid IL or missing references) //IL_0acb: Unknown result type (might be due to invalid IL or missing references) //IL_0adb: Unknown result type (might be due to invalid IL or missing references) //IL_0b6b: Unknown result type (might be due to invalid IL or missing references) //IL_0b70: Unknown result type (might be due to invalid IL or missing references) //IL_0b74: Unknown result type (might be due to invalid IL or missing references) //IL_0b79: Unknown result type (might be due to invalid IL or missing references) //IL_0b7d: Unknown result type (might be due to invalid IL or missing references) //IL_0b82: Unknown result type (might be due to invalid IL or missing references) //IL_0b8e: Unknown result type (might be due to invalid IL or missing references) //IL_0b93: Unknown result type (might be due to invalid IL or missing references) //IL_0b9d: Unknown result type (might be due to invalid IL or missing references) //IL_0bb2: Unknown result type (might be due to invalid IL or missing references) //IL_0bb7: Unknown result type (might be due to invalid IL or missing references) //IL_0bc1: Unknown result type (might be due to invalid IL or missing references) //IL_0bd6: Unknown result type (might be due to invalid IL or missing references) //IL_0bdb: Unknown result type (might be due to invalid IL or missing references) //IL_0be5: Unknown result type (might be due to invalid IL or missing references) //IL_0c83: Unknown result type (might be due to invalid IL or missing references) //IL_0c89: Unknown result type (might be due to invalid IL or missing references) //IL_0c96: Unknown result type (might be due to invalid IL or missing references) //IL_0c9b: Unknown result type (might be due to invalid IL or missing references) //IL_0ca1: Unknown result type (might be due to invalid IL or missing references) //IL_0cb9: Unknown result type (might be due to invalid IL or missing references) //IL_0cbe: Unknown result type (might be due to invalid IL or missing references) //IL_0cc3: Unknown result type (might be due to invalid IL or missing references) //IL_0db5: Unknown result type (might be due to invalid IL or missing references) //IL_0ce0: Unknown result type (might be due to invalid IL or missing references) //IL_0ce3: Unknown result type (might be due to invalid IL or missing references) //IL_0ce8: Unknown result type (might be due to invalid IL or missing references) //IL_0ced: Unknown result type (might be due to invalid IL or missing references) //IL_0dcc: Unknown result type (might be due to invalid IL or missing references) //IL_0dd7: Unknown result type (might be due to invalid IL or missing references) //IL_0d9a: Unknown result type (might be due to invalid IL or missing references) //IL_0da1: Unknown result type (might be due to invalid IL or missing references) //IL_0da8: Unknown result type (might be due to invalid IL or missing references) //IL_0dad: Unknown result type (might be due to invalid IL or missing references) //IL_0db2: Unknown result type (might be due to invalid IL or missing references) //IL_0d0c: Unknown result type (might be due to invalid IL or missing references) //IL_0d18: Unknown result type (might be due to invalid IL or missing references) //IL_0e20: Unknown result type (might be due to invalid IL or missing references) //IL_0e24: Unknown result type (might be due to invalid IL or missing references) //IL_0e2a: Unknown result type (might be due to invalid IL or missing references) //IL_0df7: Unknown result type (might be due to invalid IL or missing references) //IL_0e00: Unknown result type (might be due to invalid IL or missing references) //IL_0d35: Unknown result type (might be due to invalid IL or missing references) //IL_0d3a: Unknown result type (might be due to invalid IL or missing references) //IL_0d4c: Unknown result type (might be due to invalid IL or missing references) //IL_0e43: Unknown result type (might be due to invalid IL or missing references) //IL_0e48: Unknown result type (might be due to invalid IL or missing references) //IL_0e4e: Unknown result type (might be due to invalid IL or missing references) //IL_0e6a: Unknown result type (might be due to invalid IL or missing references) //IL_0e6f: Unknown result type (might be due to invalid IL or missing references) //IL_0e9f: Unknown result type (might be due to invalid IL or missing references) //IL_0ea6: Unknown result type (might be due to invalid IL or missing references) //IL_0ead: Unknown result type (might be due to invalid IL or missing references) //IL_0ec2: Unknown result type (might be due to invalid IL or missing references) //IL_0ec9: Unknown result type (might be due to invalid IL or missing references) //IL_0ed0: Unknown result type (might be due to invalid IL or missing references) if (state != State.Attack) { tracking = false; motion.UnplantedFoot = null; if (state == State.Observe || state == State.Dead || state == State.Stunned) { exitBlend = 0f; } else { if (!(exitBlend > 0f)) { return; } string[] array = new string[2] { "L", "R" }; foreach (string text in array) { string[] array2 = new string[3] { "upper_arm.", "forearm.", "hand." }; foreach (string text2 in array2) { Transform val = motion.Map[text2 + text]; val.localRotation = Quaternion.RotateTowards(motion.PreviousRotation(val), val.localRotation, 360f * dt); } } exitBlend = Mathf.Max(0f, exitBlend - dt); } return; } exitBlend = 0.24f; Transform parent = motion.Visual.parent; float num = ((variant == 0) ? 1 : (-1)); string text3 = ((variant == 0) ? "R" : "L"); string text4 = ((variant == 0) ? "L" : "R"); if (nextSequence != sequence) { sequence = nextSequence; lockedTarget = (lastTarget = target); leadFoot = motion.PreviousPosition(motion.Map["foot." + text4]); tracking = false; raised = false; raisedFloor = parent.position.y; RaycastHit[] array3 = Physics.RaycastAll(target + Vector3.up * 0.1f, Vector3.down, 2f, WorldQueries.Mask, (QueryTriggerInteraction)1); for (int k = 0; k < array3.Length; k++) { RaycastHit val2 = array3[k]; if (!WorldQueries.Self(((RaycastHit)(ref val2)).collider) && !Object.op_Implicit((Object)(object)WorldQueries.PlayerOwner(((RaycastHit)(ref val2)).collider)) && ((RaycastHit)(ref val2)).normal.y > 0.6f && ((RaycastHit)(ref val2)).point.y > parent.position.y + 0.4f) { raised = true; raisedFloor = Mathf.Max(raisedFloor, ((RaycastHit)(ref val2)).point.y); } } throughOpening = TrySill(parent.position, target, raisedFloor, out sillHeight); } if (phase < 0.32f) { Vector3 val3 = (tracking ? ((target - lastTarget) / Mathf.Max(0.001f, dt)) : Vector3.zero); lockedTarget = target + Vector3.ClampMagnitude(val3 * 0.09f, throughOpening ? 0.08f : 0.25f); lastTarget = target; tracking = true; } float num2 = Ease(0f, 0.23f, phase); float num3 = Ease(raised ? 0.24f : 0.18f, raised ? 0.44f : 0.36f, phase); float num4 = Ease(0.44f, 0.67f, phase); float num5 = Ease(0.68f, 1.04f, phase); float num6 = num3 * (1f - num5); Transform val4 = motion.Map["pelvis"]; Transform val5 = motion.Map["chest"]; Transform val6 = motion.Map["spine_01"]; val4.position += parent.TransformDirection(new Vector3((0f - num) * 0.06f * num6, (raised ? 0.08f : (-0.07f)) * num6, 0.12f * num6)); val4.rotation = Quaternion.AngleAxis(num * ((float)(raised ? (-12) : (-18)) * num2 + (float)(throughOpening ? 16 : (raised ? 25 : 38)) * num3) * (1f - num5), parent.up) * val4.rotation; val5.rotation = Quaternion.AngleAxis(num * ((float)(raised ? (-22) : (-32)) * num2 + (float)(throughOpening ? 29 : (raised ? 48 : 70)) * num3) * (1f - num5), parent.up) * val5.rotation; val6.rotation = Quaternion.AngleAxis(throughOpening ? (-15f * num6) : (raised ? (-8f * num6) : ((-10f * num2 + 24f * num3) * (1f - num5))), parent.right) * val6.rotation; Transform val7 = motion.Map["upper_arm." + text3]; Transform val8 = motion.Map["forearm." + text3]; Transform val9 = motion.Map["hand." + text3]; if (throughOpening) { float num7 = Mathf.Clamp(sillHeight + 0.22f - val7.position.y, 0f, 0.3f); val4.position += Vector3.up * (num7 * Ease(0.12f, 0.38f, phase) * (1f - num5)); } Vector3 val10 = parent.TransformPoint(new Vector3(num * (throughOpening ? 0.48f : (raised ? 0.67f : 0.95f)), (!raised) ? 1.7f : ((variant == 0) ? 1.65f : 1.25f), raised ? (-0.18f) : (-0.28f))); if (raised) { val10.y = Mathf.Max(parent.position.y + 1.75f, lockedTarget.y + 0.2f); val10 += parent.forward * 0.33f; } if (throughOpening) { val10.y = Mathf.Max(sillHeight + 0.16f, lockedTarget.y + 0.12f); } Vector3 val11 = lockedTarget; if (throughOpening) { val11.y = Mathf.Max(val11.y, sillHeight + 0.1f); } Vector3 val12 = val11 - val7.position; Vector3 val13 = val11 - ((Vector3)(ref val12)).normalized * (throughOpening ? 0.3f : (raised ? 0.14f : 0.3f)); Vector3 val14 = Vector3.Lerp(val9.position, val10, num2); val14 = Vector3.Lerp(val14, val13, num3); val14 += parent.right * ((0f - num) * (throughOpening ? 0.12f : (raised ? 0.35f : 0.6f)) * num4) * (1f - num5); if (raised) { val14.y = Mathf.Max(val14.y, lockedTarget.y + 0.1f * num3 * (1f - num5)); } val14 += parent.up * (raised ? (-0.1f) : ((variant == 0) ? (-0.14f) : 0.2f)) * num4 * (1f - num5); if (raised) { val14.y = Mathf.Max(val14.y, raisedFloor + Mathf.Clamp((val7.position.y - raisedFloor) * 1.5f, 0.15f, 0.45f)); } if (throughOpening) { val14.y = Mathf.Max(val14.y, sillHeight + 0.16f); } val14 = Vector3.Lerp(val14, parent.TransformPoint(new Vector3(num * 0.38f, 1.05f, 0.24f)), num5); Vector3 pole = val7.position + parent.right * (num * (throughOpening ? 0.18f : 0.65f)) + parent.up * (throughOpening ? 0.75f : (raised ? 0.9f : 0.18f)) - parent.forward * (raised ? 0.2f : 0f); SolveArm(text3, val14, pole, dt); string text5 = ((variant == 0) ? "L" : "R"); Transform val15 = motion.Map["upper_arm." + text5]; SolveArm(text5, parent.TransformPoint(new Vector3((0f - num) * 0.58f, 1.1f, -0.18f)), val15.position - parent.right * num * 0.55f, dt); Transform val16 = motion.Map["finger_2.03." + text3]; Vector3 val17 = val16.position - val9.position; if (((Vector3)(ref val17)).sqrMagnitude > 0.001f && ((Vector3)(ref val12)).sqrMagnitude > 0.001f) { val9.rotation = Quaternion.Slerp(val9.rotation, Quaternion.FromToRotation(val17, val11 - val9.position) * val9.rotation, num3 * (1f - num5)); } string[] array4 = new string[2] { "L", "R" }; foreach (string text6 in array4) { Transform val18 = motion.Map["upper_arm." + text6]; Transform val19 = motion.Map["forearm." + text6]; Transform val20 = motion.Map["hand." + text6]; Quaternion rotation = val18.rotation; Quaternion rotation2 = val19.rotation; Quaternion rotation3 = val20.rotation; val18.rotation = Quaternion.RotateTowards(motion.PreviousWorldRotation(val18), rotation, 900f * dt); val19.rotation = Quaternion.RotateTowards(motion.PreviousWorldRotation(val19), rotation2, 900f * dt); val20.rotation = Quaternion.RotateTowards(motion.PreviousWorldRotation(val20), rotation3, 900f * dt); } float num8 = Ease(0.08f, 0.64f, phase); motion.UnplantedFoot = ((phase < 0.72f) ? text4 : null); Transform val21 = motion.Map["thigh." + text4]; Transform val22 = motion.Map["shin." + text4]; Transform hand = motion.Map["foot." + text4]; Vector3 val23 = leadFoot + parent.forward * (0.55f * num8) + parent.up * (0.15f * Mathf.Sin(num8 * MathF.PI)); if (raised || throughOpening) { Vector3 val24 = val23 - leadFoot; float num9 = ((Vector3)(ref val24)).magnitude; if (num9 > 0.001f) { RaycastHit[] array5 = Physics.SphereCastAll(leadFoot, 0.34f, ((Vector3)(ref val24)).normalized, num9, WorldQueries.Mask, (QueryTriggerInteraction)1); for (int m = 0; m < array5.Length; m++) { RaycastHit val25 = array5[m]; if (WallSafety.BlocksMovement(((RaycastHit)(ref val25)).collider) && Mathf.Abs(((RaycastHit)(ref val25)).normal.y) < 0.6f) { num9 = Mathf.Min(num9, Mathf.Max(0f, ((RaycastHit)(ref val25)).distance - 0.02f)); } } } val23 = leadFoot + ((Vector3)(ref val24)).normalized * num9; } if (GroundSupport.Floor(val23, 0.34f, 0.4f, out var floor) && floor.Position.y <= parent.position.y + 0.1f) { val23.y = Mathf.Max(val23.y, floor.Position.y + 0.21f); } WallSafety.Solve(val21, val22, hand, val23, val21.position + parent.forward * (raised ? 0.1f : 0.65f) + parent.right * ((0f - num) * (raised ? 0.35f : 0.15f))); float num10 = 1f - Mathf.Exp((0f - dt) / 0.04f); val21.localRotation = Quaternion.Slerp(motion.PreviousRotation(val21), val21.localRotation, num10); val22.localRotation = Quaternion.Slerp(motion.PreviousRotation(val22), val22.localRotation, num10); } private void SolveArm(string side, Vector3 goal, Vector3 pole, float dt) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) Transform val = motion.Map["upper_arm." + side]; Transform val2 = motion.Map["forearm." + side]; Transform hand = motion.Map["hand." + side]; WallSafety.Solve(val, val2, hand, goal, pole); float num = 1f - Mathf.Exp((0f - dt) / 0.035f); val.localRotation = Quaternion.Slerp(motion.PreviousRotation(val), val.localRotation, num); val2.localRotation = Quaternion.Slerp(motion.PreviousRotation(val2), val2.localRotation, num); } } public sealed class BodySteering { private float angularVelocity; public bool Reversing { get; private set; } public void Reset() { angularVelocity = 0f; Reversing = false; } public void Plan(Vector3 body, Quaternion current, ref Vector3 velocity, float duck, bool running, float dt, out Quaternion rotation) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0145: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0197: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) rotation = current; Reversing = false; if (((Vector3)(ref velocity)).sqrMagnitude < 0.001f) { return; } Quaternion q = Quaternion.LookRotation(velocity); bool turnFits = WallSafety.ClearStepPose(body, q, duck); Reversing = NativeBehaviour.ReverseThroughNeck(Vector3.Dot(current * Vector3.forward, ((Vector3)(ref velocity)).normalized), turnFits, duck > 0.1f); if (Reversing) { velocity = Vector3.ClampMagnitude(velocity, 1f); angularVelocity = 0f; return; } float num = Mathf.SmoothDampAngle(((Quaternion)(ref current)).eulerAngles.y, ((Quaternion)(ref q)).eulerAngles.y, ref angularVelocity, 0.28f, (float)(running ? 110 : 75), dt); Quaternion val = Quaternion.Euler(0f, num, 0f); if (WallSafety.ClearStepPose(body, val, duck)) { rotation = val; } else if (Vector3.Dot(current * Vector3.forward, ((Vector3)(ref velocity)).normalized) < 0.3f) { Vector3 delta = ((Vector3)(ref velocity)).normalized * 0.28f; Vector3 val2 = WallSafety.Move(body, current, delta, duck); Vector3 val3 = val2 - body; if (((Vector3)(ref val3)).sqrMagnitude >= 0.0324f && WallSafety.ClearStepPose(val2, current, duck)) { velocity = Vector3.ClampMagnitude(velocity, 0.75f); angularVelocity = 0f; } else { velocity = -(current * Vector3.forward) * 0.45f; Reversing = true; } return; } if (running) { float num2 = Mathf.Clamp01(Vector3.Dot(rotation * Vector3.forward, ((Vector3)(ref velocity)).normalized)); velocity *= Mathf.SmoothStep(0f, 1f, num2); } } } public sealed class CartBypass { public const float MaxLookAhead = 7f; private Component cart; private readonly Transform own; private readonly bool enemies; private Vector3 center; private Vector3 goal; private Quaternion rotation; private Vector3[] route = Array.Empty<Vector3>(); private int cursor; private float retry; public bool Active => Object.op_Implicit((Object)(object)cart); private int QueryMask => enemies ? (-1) : WorldQueries.Mask; public CartBypass() { } public CartBypass(Transform own, bool enemies) { this.own = own; this.enemies = enemies; } public bool BlockedNear(Vector3 body, float distance) { //IL_0032: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)cart) || route.Length != 0 || !BoundsFor(cart, out var bounds)) { return false; } Vector3 val = body; val.y = ((Bounds)(ref bounds)).center.y; Vector3 val2 = Vector3.ProjectOnPlane(((Bounds)(ref bounds)).ClosestPoint(val) - val, Vector3.up); return ((Vector3)(ref val2)).magnitude <= distance; } public void Reset() { cart = null; route = Array.Empty<Vector3>(); cursor = 0; retry = 0f; } private static Vector3 Flat(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return Vector3.ProjectOnPlane(v, Vector3.up); } private Component Obstacle(Collider c) { if (!Object.op_Implicit((Object)(object)c) || (Object.op_Implicit((Object)(object)own) && ((Component)c).transform.IsChildOf(own))) { return null; } if (!enemies) { return (Component)(object)((Component)c).GetComponentInParent<PhysGrabCart>(); } EnemyRigidbody componentInParent = ((Component)c).GetComponentInParent<EnemyRigidbody>(); if (Object.op_Implicit((Object)(object)componentInParent)) { return (Component)(object)componentInParent; } return (Component)(object)((Component)c).GetComponentInParent<Enemy>(); } private static bool BoundsFor(Component cart, out Bounds bounds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_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) bounds = default(Bounds); bool flag = false; Collider[] componentsInChildren = cart.GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { if (val.enabled && !val.isTrigger) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } return flag; } private bool Segment(Vector3 a, Vector3 b, out Vector3[] points) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (mig