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 Lethargique Creatures v1.0.0
plugins/LethargiqueCreatures.dll
Decompiled 20 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Lethargique.Creatures { public sealed class BoxyBrain : CapturingBrain { [SerializeField] private BoxCollider armVolume; private bool armWindow; private static readonly int JumpscareState = Animator.StringToHash("Base Layer.Boxy_Jumpscare"); private AudioSource music; [SerializeField] private InteractTrigger crank; private float closedUntil; private float nextLunge; private float nextReach; private float lungeStartAt; private bool lungeStarted; private const float LungeWaitMax = 0.6f; private bool lunge; private static readonly string[] BoxySounds = new string[24] { "BoxyStepHard1", "BoxySwing1", "BoxyLeap", "BoxySongSlow", "BoxyFullPop1", "BoxyRetractFull", "BoxyGrabLaunch1", "BoxySongFast", "BoxyCreak1", "BoxyCreak2", "BoxyCreak3", "BoxyCreak4", "BoxyCreak5", "BoxyCreak6", "BoxyCreak7", "BoxyCreak8", "BoxyCreak9", "BoxyMetal1", "BoxyCrateLand", "BoxyHitConnect1", "BoxyGrabReady", "BoxyJumpscare", "BoxyRetractPartial", "BoxyCrank1" }; public float RetreatAfterDamage = 8f; private float trackedDamage; private bool damageRetreatPending; private Vector3 damageRetreatFrom; private float nextCrankSound; private bool walkingShown; public float BoxyStride = 2.77f; public float BoxyMinCadence = 0.7f; public float BoxyMaxCadence = 1.8f; public float BoxyBoxStride = 0.68f; public float BoxyBoxMinCadence = 0.6f; public float BoxyBoxMaxCadence = 1.8f; public float BoxyPatrolSpeed = 1.2f; public float EnergyMax = 26f; public float EnergyExit = 21f; public float EnergyStart = 14f; public float ExitDistance = 7f; public float ExitCloseDistance = 2.5f; public float EnergyRise = 1f; public float DrainSearch = 0.4f; public float DrainChase = 0.75f; public float DrainAttack = 1f; public float CrankDrain = 6f; public float CrankWindow = 1.5f; public float CrankRange = 4.2f; public float NoiseBonus = 3f; public float NoiseLoudness = 0.4f; public float NoiseRange = 14f; public string CreakSound = "BoxyCreak"; public int CreakVariants = 4; public float CreakSlow = 6f; public float CreakFast = 1.2f; public string SongSlow = "BoxySongSlow"; public string SongFast = "BoxySongFast"; public float SongFrom = 8f; public float SongFastFrom = 16f; public float SongInterval = 9f; public float RetreatMin = 6f; public float RetreatMax = 10f; public float RetreatSpeed = 3.4f; public float ReturnQuiet = 1.5f; public float ReturnPatience = 8f; public float StuckClose = 1.6f; private float stuckSince = -1f; private float energy; private float energyAt; private float crankUntil; private float nextCreak; private float nextSong; private float nextNoise; private float retreatUntil; private float nextRetreatPick; private float returnSince; private bool cranking; private bool returning; private float lastCrankAt = -1f; private int energyStep = -1; private Vector3 retreatFrom; private Vector3 retreatTarget; private bool hasRetreatTarget; private readonly List<AnimatorClipInfo> clipBuffer = new List<AnimatorClipInfo>(2); private const float BoxHoldMax = 3f; private float boxSince = -1f; private float boxHoldUntil; private int boxShape = -1; private const string IdleClip = "BoxyBooIdle 1"; private const float PlantedToe = 0.27f; private const float IdleFallback = 0.29f; private const float IdleMaxLower = 0.4f; private const float FootSmoothing = 0.12f; private Transform footVisual; private Transform footLeft; private Transform footRight; private bool footSearched; private Vector3 footAnimatedLocal; private Vector3 footWrittenLocal; private bool footApplied; private float footLower; private float footLogAt; protected override Vector3 CaptureAnchorOffset => Vector3.down; protected override float SenseRange => 31f; protected override float HitRange => 2.8f; protected override float AttackWindup { get { if (!lunge) { return 0.48f; } return 0.85f; } } protected override int AttackDamage { get { if (!lunge) { return 25; } return 32; } } protected override int CaptureAnimationState => JumpscareState; protected override string[] SoundNames => BoxySounds; public float Energy => energy; private bool Cornered { get { if (stuckSince >= 0f) { return Time.time - stuckSince > StuckClose; } return false; } } private bool Leaving { get { if (!returning) { return Time.time < retreatUntil; } return true; } } protected override float SpeedCap { get { if (base.State != 0 || (Leaving && !ClipIs("Boxy_BoxWalk"))) { return BoxyStride * BoxyMaxCadence; } return BoxyBoxStride * BoxyBoxMaxCadence; } } protected override bool Ungoverned => base.State == 7; protected override bool StartGate => true; private float HeldCrankWindow { get { float num = 0f; if (Object.op_Implicit((Object)(object)crank) && crank.holdInteraction) { num = crank.timeToHold / Mathf.Max(0.1f, crank.timeToHoldSpeedMultiplier) + (crank.interactCooldown ? crank.cooldownTime : 0f); } return Mathf.Clamp(Mathf.Max(CrankWindow, num * 1.5f), 0.2f, 6f); } } public override void Update() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_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_010f: Unknown result type (might be due to invalid IL or missing references) base.Update(); if (((NetworkBehaviour)this).IsSpawned && base.State == 9 && base.StateAge >= 0.6f) { Bool("Winding", value: false); } if (!((NetworkBehaviour)this).IsSpawned || !((NetworkBehaviour)this).IsServer || base.State != 9) { return; } if (!base.DecisionsHere || base.StateAge >= 2.2f || base.IsStunned) { armWindow = false; Victim = null; if (!((EnemyAI)this).isEnemyDead) { SetState(2); } return; } if (base.StateAge < 0.6f) { Face(Victim); } if (!armWindow || !Object.op_Implicit((Object)(object)armVolume) || !((Collider)armVolume).enabled || !CanStrike(Victim, 4.8f)) { return; } BoxCollider component = ((Component)Victim).GetComponent<BoxCollider>(); Bounds bounds = ((Collider)armVolume).bounds; if (Object.op_Implicit((Object)(object)component)) { Vector3 size = ((Bounds)(ref bounds)).size; if (((Vector3)(ref size)).sqrMagnitude >= 0.01f && ((Bounds)(ref bounds)).Intersects(((Collider)component).bounds) && TryBeginCapture(Victim)) { armWindow = false; } } } internal void SetArmWindow(bool open) { if (((NetworkBehaviour)this).IsServer && base.State == 9) { armWindow = open && !base.IsStunned; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} arm window={armWindow}"); } } } protected override int AttackVariant(PlayerControllerB victim) { return ArmToward(victim, 1); } protected override bool OriginalRoute(string name, out SoundRoute route) { switch (name) { case "BoxyStepHard1": case "BoxyFullPop1": route = new SoundRoute(null, 3f); return true; case "BoxySwing1": case "BoxyHitConnect1": route = new SoundRoute("HitConnectAudio", 2f); return true; case "BoxyJumpscare": route = new SoundRoute("HitConnectAudio", 3f); return true; case "BoxyLeap": route = new SoundRoute("JumpAudio", 4f); return true; case "BoxyGrabReady": route = new SoundRoute("GrabAudio", 2f); return true; case "BoxyGrabLaunch1": route = new SoundRoute("GrabAudio", 3f); return true; case "BoxyCrateLand": case "BoxyMetal1": route = new SoundRoute(null, 1f); return true; case "BoxyCrank1": route = new SoundRoute("CrankAudio", 1f); return true; case "BoxyRetractFull": case "BoxyRetractPartial": route = new SoundRoute("RetractAudio", 2.5f); return true; default: if (name.StartsWith("BoxyCreak", StringComparison.Ordinal)) { route = new SoundRoute("CreakAudio", 3f); return true; } route = default(SoundRoute); return false; } } protected override void OnStrikeLanded(PlayerControllerB victim) { SignalSound("BoxyHitConnect1"); } protected override void OnSurvivingHit(PlayerControllerB attacker) { //IL_003e: 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_0092: 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_0071: 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_0097: Unknown result type (might be due to invalid IL or missing references) if (base.State != 4 && base.State != 6 && !Leaving) { trackedDamage += LastHitForce; if (Object.op_Implicit((Object)(object)attacker)) { damageRetreatFrom = ((Component)attacker).transform.position; } else if (!damageRetreatPending) { damageRetreatFrom = (Object.op_Implicit((Object)(object)base.SeenPlayer) ? ((Component)base.SeenPlayer).transform.position : (((Component)this).transform.position - ((Component)this).transform.forward * 3f)); } bool flag = RetreatAfterDamage > 0f && trackedDamage > RetreatAfterDamage; if (flag) { damageRetreatPending = true; } if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)string.Format("Boxy #{0} coup recu force={1} cumul={2:F0}/{3:F0} retraite={4} etat={5}", ((NetworkBehaviour)this).NetworkObjectId, LastHitForce, trackedDamage, RetreatAfterDamage, flag ? "oui" : "non", base.State)); } } } private void StartRetreat(Vector3 from, string reason) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) retreatUntil = Time.time + Random.Range(RetreatMin, Mathf.Max(RetreatMin, RetreatMax)); retreatFrom = from; nextRetreatPick = 0f; stuckSince = -1f; returning = false; trackedDamage = 0f; damageRetreatPending = false; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} retraite apres {reason} duree={retreatUntil - Time.time:F1}"); } } protected override AudioSource SoundSourceFor(string name) { if (!Object.op_Implicit((Object)(object)music) || !name.StartsWith("BoxySong", StringComparison.Ordinal)) { return null; } return music; } protected override void OnSpeedMeasured() { if (base.State == 4 && !((EnemyAI)this).isEnemyDead && Time.time >= nextCrankSound) { nextCrankSound = Time.time + 0.75f; Sound("BoxyCrank1"); } if (!base.SpeedKnown || !Object.op_Implicit((Object)(object)((EnemyAI)this).creatureAnimator) || !((EnemyAI)this).creatureAnimator.isInitialized) { return; } if (((EnemyAI)this).isEnemyDead || base.State == 4) { if (Mathf.Abs(((EnemyAI)this).creatureAnimator.speed - 1f) > 0.01f) { ((EnemyAI)this).creatureAnimator.speed = 1f; } return; } bool flag = (base.State == 2 || base.State == 0) && base.ShownSpeed > (walkingShown ? 0.15f : 0.3f); if (flag != walkingShown) { walkingShown = flag; Bool("walking", flag); } bool flag2 = base.ClipNow == "Boxy_BoxWalk"; FollowStride(flag2 ? BoxyBoxStride : BoxyStride, walkingShown, flag2 ? BoxyBoxMaxCadence : BoxyMaxCadence, flag2 ? BoxyBoxMinCadence : BoxyMinCadence); } protected override void LoadTuning() { base.LoadTuning(); BoxyStride = Plugin.Tune("Boxy.Foulee", BoxyStride); BoxyMinCadence = Plugin.Tune("Boxy.CadenceMin", BoxyMinCadence); BoxyMaxCadence = Plugin.Tune("Boxy.CadenceMax", BoxyMaxCadence); BoxyBoxStride = Plugin.Tune("Boxy.FouleeBoite", BoxyBoxStride); BoxyBoxMinCadence = Plugin.Tune("Boxy.CadenceMinBoite", BoxyBoxMinCadence); BoxyBoxMaxCadence = Plugin.Tune("Boxy.CadenceMaxBoite", BoxyBoxMaxCadence); BoxyPatrolSpeed = Plugin.Tune("Boxy.VitessePatrouille", BoxyPatrolSpeed); LoadHearing("Boxy", 0.2f, BoxyPatrolSpeed); EnergyMax = Mathf.Max(1f, Plugin.Gameplay("Boxy", "Jauge.Max", EnergyMax)); EnergyExit = Mathf.Max(1f, Plugin.Gameplay("Boxy", "Jauge.SortieJoueur", EnergyExit)); EnergyStart = Plugin.Gameplay("Boxy", "Jauge.Depart", EnergyStart); EnergyRise = Plugin.Gameplay("Boxy", "Jauge.MonteeBoite", EnergyRise); DrainSearch = Plugin.Gameplay("Boxy", "Jauge.BaisseMarche", DrainSearch); DrainChase = Plugin.Gameplay("Boxy", "Jauge.BaissePoursuite", DrainChase); DrainAttack = Plugin.Gameplay("Boxy", "Jauge.BaisseAttaque", DrainAttack); ExitDistance = Plugin.Gameplay("Boxy", "Sortie.Distance", ExitDistance); ExitCloseDistance = Plugin.Gameplay("Boxy", "Sortie.DistanceSansVue", ExitCloseDistance); CrankDrain = Plugin.Gameplay("Boxy", "Manivelle.Baisse", CrankDrain); CrankWindow = Plugin.Gameplay("Boxy", "Manivelle.Fenetre", CrankWindow); CrankRange = Plugin.Gameplay("Boxy", "Manivelle.Portee", CrankRange); NoiseBonus = Plugin.Gameplay("Boxy", "Bruit.Ajout", NoiseBonus); NoiseLoudness = Plugin.Gameplay("Boxy", "Bruit.Intensite", NoiseLoudness); NoiseRange = Plugin.Gameplay("Boxy", "Bruit.Portee", NoiseRange); CreakSound = Plugin.Gameplay("Boxy", "Son.Grincement", CreakSound); CreakVariants = Plugin.Gameplay("Boxy", "Son.GrincementVariantes", CreakVariants); CreakSlow = Plugin.Gameplay("Boxy", "Son.GrincementLent", CreakSlow); CreakFast = Plugin.Gameplay("Boxy", "Son.GrincementRapide", CreakFast); SongSlow = Plugin.Gameplay("Boxy", "Son.AirLent", SongSlow); SongFast = Plugin.Gameplay("Boxy", "Son.AirRapide", SongFast); SongFrom = Plugin.Gameplay("Boxy", "Son.AirDepuis", SongFrom); SongFastFrom = Plugin.Gameplay("Boxy", "Son.AirRapideDepuis", SongFastFrom); SongInterval = Plugin.Gameplay("Boxy", "Son.AirIntervalle", SongInterval); RetreatMin = Plugin.Gameplay("Boxy", "Retraite.Min", RetreatMin); RetreatMax = Plugin.Gameplay("Boxy", "Retraite.Max", RetreatMax); RetreatSpeed = Plugin.Gameplay("Boxy", "Retraite.Vitesse", RetreatSpeed); RetreatAfterDamage = Plugin.Gameplay("Boxy", "Retraite.ApresDegats", RetreatAfterDamage); ReturnQuiet = Plugin.Gameplay("Boxy", "Retour.TempsHorsDeVue", ReturnQuiet); ReturnPatience = Plugin.Gameplay("Boxy", "Retour.Patience", ReturnPatience); } private void UpdateEnergy() { float time = Time.time; float num = Mathf.Min(time - energyAt, 0.5f); energyAt = time; if (num <= 0f) { return; } bool flag = time < crankUntil && base.State == 4; if (flag != cranking) { cranking = flag; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)string.Format("Boxy #{0} manivelle {1} jauge={2:F1}", ((NetworkBehaviour)this).NetworkObjectId, flag ? "tenue" : "lachee", energy)); } } if (flag) { energy -= CrankDrain * num; } else if (base.State == 4) { energy += EnergyRise * num; } else if (base.State == 2) { energy -= DrainChase * num; } else if (base.State == 0) { energy -= DrainSearch * num; } else { energy -= DrainAttack * num; } energy = Mathf.Clamp(energy, 0f, Mathf.Max(1f, EnergyMax)); int num2 = (int)(energy / 5f); if (num2 != energyStep) { energyStep = num2; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} jauge={energy:F1} etat={base.State}"); } } } private void PlayGaugeSounds() { float time = Time.time; if (energy >= 2f && time >= nextCreak) { float num = Mathf.Clamp01(energy / Mathf.Max(1f, EnergyExit)); nextCreak = time + Mathf.Lerp(CreakSlow, CreakFast, num) * Random.Range(0.8f, 1.2f); SignalSound(CreakSound + Random.Range(1, Mathf.Clamp(CreakVariants, 1, 9) + 1)); } if (energy >= SongFrom && time >= nextSong) { nextSong = time + SongInterval; SignalSound((energy >= SongFastFrom) ? SongFast : SongSlow); } } private bool PlayerNearForExit() { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { if (InRange(allPlayerScripts[i], ExitCloseDistance) || CanStrike(allPlayerScripts[i], ExitDistance)) { return true; } } return false; } private void LeaveBox(string reason) { if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} sortie raison={reason} jauge={energy:F1}"); } returning = false; SetState(Object.op_Implicit((Object)(object)base.SeenPlayer) ? 2 : 0); } private void ReturnToBox() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (!returning) { returning = true; returnSince = time; ResetWatched(); } bool flag = HiddenFromAll(ReturnQuiet); bool cornered = Cornered; if (flag || cornered || time - returnSince > ReturnPatience) { if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)string.Format("Boxy #{0} retour-boite raison={1} jauge={2:F1}", ((NetworkBehaviour)this).NetworkObjectId, flag ? "hors-de-vue" : (cornered ? "coince" : "patience"), energy)); } returning = false; stuckSince = -1f; closedUntil = time + 2.6f; SetState(4); } else if (HoldForBox()) { Halt(); } else if (base.SinceSeen < ReturnPatience) { Withdraw(base.LastPlayerPosition, 3.2f); } else { Halt(); } } private void Withdraw(Vector3 from, float speed) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (time >= nextRetreatPick) { nextRetreatPick = time + 1.5f; Vector3 direction = ((Component)this).transform.position - from; direction.y = 0f; if (((Vector3)(ref direction)).sqrMagnitude < 0.01f) { direction = -((Component)this).transform.forward; } hasRetreatTarget = TryFindEscape(direction, from, out retreatTarget, 25f); } if (hasRetreatTarget) { Go(retreatTarget, speed); stuckSince = -1f; return; } Halt(); if (stuckSince < 0f) { stuckSince = time; } } protected override void OnCaptureEnded(PlayerControllerB player, bool strike) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) StartRetreat(((Component)player).transform.position, strike ? "saisie strike=True" : "saisie strike=False"); } public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (base.State != 4) { base.DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID); } else { if (!base.DecisionsHere || noiseID == 941 || noiseLoudness < NoiseLoudness || Time.time < nextNoise) { return; } Vector3 val = noisePosition - ((Component)this).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude > NoiseRange * NoiseRange)) { nextNoise = Time.time + 1f; energy = Mathf.Min(EnergyMax, energy + NoiseBonus); if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} bruit +{NoiseBonus:F0} jauge={energy:F1}"); } } } } protected override bool IsMovingClip(string clip) { if (!(clip == "BoxyBooWalk")) { if (clip == "Boxy_BoxWalk") { return base.State == 0; } return false; } return true; } private bool HoldForBox() { if (Time.time < boxHoldUntil) { return true; } if (!InBoxTransition()) { boxSince = -1f; return false; } if (boxSince < 0f) { boxSince = Time.time; } return Time.time - boxSince < 3f; } private bool InBoxTransition() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)((EnemyAI)this).creatureAnimator) || !((EnemyAI)this).creatureAnimator.isInitialized) { return false; } ((EnemyAI)this).creatureAnimator.GetCurrentAnimatorClipInfo(0, clipBuffer); if (IsBoxClip(clipBuffer)) { AnimatorStateInfo currentAnimatorStateInfo = ((EnemyAI)this).creatureAnimator.GetCurrentAnimatorStateInfo(0); if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime < 1f) { return true; } } if (!((EnemyAI)this).creatureAnimator.IsInTransition(0)) { return false; } ((EnemyAI)this).creatureAnimator.GetNextAnimatorClipInfo(0, clipBuffer); return IsBoxClip(clipBuffer); } private static bool IsBoxClip(List<AnimatorClipInfo> clips) { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (clips.Count != 0) { AnimatorClipInfo val = clips[0]; if (Object.op_Implicit((Object)(object)((AnimatorClipInfo)(ref val)).clip)) { val = clips[0]; string name = ((Object)((AnimatorClipInfo)(ref val)).clip).name; if (!name.StartsWith("Boxy_PartialOpen", StringComparison.Ordinal) && !name.StartsWith("Boxy_PartialToBox", StringComparison.Ordinal) && !name.StartsWith("Boxy_FullPop", StringComparison.Ordinal) && !name.StartsWith("Boxy_FullRetract", StringComparison.Ordinal) && !name.StartsWith("Boxy_Jumpscare", StringComparison.Ordinal) && !name.StartsWith("Boxy_GrabPull", StringComparison.Ordinal) && !name.StartsWith("Boxy_WindUp", StringComparison.Ordinal) && !name.StartsWith("Boxy_WindIdle", StringComparison.Ordinal) && !name.StartsWith("Boxy_AttackRight", StringComparison.Ordinal)) { return name.StartsWith("Boxy_Land", StringComparison.Ordinal); } return true; } } return false; } public override void Start() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { if (((Object)val).name == "MusicAudio") { music = val; break; } } if (Object.op_Implicit((Object)(object)crank)) { if (crank.onInteract == null) { crank.onInteract = new InteractEvent(); } ((UnityEvent<PlayerControllerB>)(object)crank.onInteract).AddListener((UnityAction<PlayerControllerB>)base.SendInteraction); } base.Start(); energy = EnergyStart; energyAt = Time.time; } private void FindFootBones() { footSearched = true; Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); footLeft = Array.Find(componentsInChildren, (Transform t) => ((Object)t).name == "lf_toe_JNT_end") ?? Array.Find(componentsInChildren, (Transform t) => ((Object)t).name == "lf_toe_JNT"); footRight = Array.Find(componentsInChildren, (Transform t) => ((Object)t).name == "rt_toe_JNT_end") ?? Array.Find(componentsInChildren, (Transform t) => ((Object)t).name == "rt_toe_JNT"); Transform val = (Object.op_Implicit((Object)(object)footLeft) ? footLeft : footRight); while (Object.op_Implicit((Object)(object)val) && (Object)(object)val.parent != (Object)(object)((Component)this).transform) { val = val.parent; } footVisual = val; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)string.Format("Boxy #{0} pieds : gauche={1} droit={2} noeud visuel={3}", ((NetworkBehaviour)this).NetworkObjectId, Object.op_Implicit((Object)(object)footLeft) ? ((Object)footLeft).name : "absent", Object.op_Implicit((Object)(object)footRight) ? ((Object)footRight).name : "absent", Object.op_Implicit((Object)(object)footVisual) ? ((Object)footVisual).name : "absent (correction coupee)")); } } private float LowestToeHeight() { StartOfRound instance = StartOfRound.Instance; if (!Object.op_Implicit((Object)(object)instance)) { return float.NaN; } float num = ToeHeight(footLeft, instance); float num2 = ToeHeight(footRight, instance); if (float.IsNaN(num) || num2 < num) { num = num2; } return num; } private static float ToeHeight(Transform toe, StartOfRound round) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0058: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)toe)) { return float.NaN; } Vector3 position = toe.position; RaycastHit val = default(RaycastHit); if (!Physics.Raycast(position + Vector3.up * 0.4f, Vector3.down, ref val, 3f, round.collidersAndRoomMaskAndDefault | 0x10000B01, (QueryTriggerInteraction)1)) { return float.NaN; } return position.y - ((RaycastHit)(ref val)).point.y; } protected override void LateUpdate() { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) base.LateUpdate(); if (!((NetworkBehaviour)this).IsSpawned || !Object.op_Implicit((Object)(object)((EnemyAI)this).creatureAnimator) || !((EnemyAI)this).creatureAnimator.isInitialized) { return; } if (!footSearched) { FindFootBones(); } if (!Object.op_Implicit((Object)(object)footVisual) || (!Object.op_Implicit((Object)(object)footLeft) && !Object.op_Implicit((Object)(object)footRight))) { return; } if (footApplied) { Vector3 val = footVisual.localPosition - footWrittenLocal; if (((Vector3)(ref val)).sqrMagnitude < 1E-10f) { footVisual.localPosition = footAnimatedLocal; } } footApplied = false; footAnimatedLocal = footVisual.localPosition; float num = 0f; if (!((EnemyAI)this).isEnemyDead) { bool flag = base.ClipNow == "BoxyBooIdle 1"; bool flag2 = base.ClipNext == "BoxyBooIdle 1"; if (!string.IsNullOrEmpty(base.ClipNext)) { AnimatorTransitionInfo animatorTransitionInfo = ((EnemyAI)this).creatureAnimator.GetAnimatorTransitionInfo(0); float num2 = Mathf.Clamp01(((AnimatorTransitionInfo)(ref animatorTransitionInfo)).normalizedTime); num = (flag ? (1f - num2) : 0f) + (flag2 ? num2 : 0f); } else { num = (flag ? 1f : 0f); } } if (num <= 0f && footLower <= 0.0005f) { footLower = 0f; return; } float num3 = ((num > 0f) ? LowestToeHeight() : float.NaN); float num4 = 0f; if (num > 0f) { num4 = Mathf.Clamp(float.IsNaN(num3) ? 0.29f : (num3 - 0.27f), 0f, 0.4f) * Mathf.Clamp01(num); } footLower = Mathf.Clamp(Mathf.Lerp(footLower, num4, 1f - Mathf.Exp((0f - Time.deltaTime) / 0.12f)), 0f, 0.4f); if (footLower < 0.0005f) { footLower = 0f; } if (footLower > 0f && Object.op_Implicit((Object)(object)footVisual.parent)) { footVisual.localPosition = footAnimatedLocal + footVisual.parent.InverseTransformVector(Vector3.down * footLower); footWrittenLocal = footVisual.localPosition; footApplied = true; } if (Plugin.ProfileAI && Time.time >= footLogAt && (num > 0f || footLower > 0f)) { footLogAt = Time.time + 1f; Plugin.Log.LogInfo((object)FormattableString.Invariant($"Boxy #{((NetworkBehaviour)this).NetworkObjectId} pieds : orteil bas={num3:F3} m appui={0.27f:F3} m poids={num:F2} correction={footLower:F3} m")); } } internal void ConfigureCrank() { crank = Array.Find(((Component)this).GetComponentsInChildren<InteractTrigger>(true), (InteractTrigger trigger) => ((Object)trigger).name == "Handle_Trigger"); if (!Object.op_Implicit((Object)(object)crank)) { throw new InvalidOperationException("Boxy Boo is missing the handle interaction."); } Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); Transform val = Array.Find(componentsInChildren, (Transform child) => ((Object)child).name == "JumpscarePoint"); armVolume = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<BoxCollider>() : null); captureAnchor = val; captureHead = Array.Find(componentsInChildren, (Transform child) => ((Object)child).name == "head_JNT"); if (!Object.op_Implicit((Object)(object)armVolume)) { Plugin.Log.LogWarning((object)"Boxy Boo is missing the arm collider. Grab disabled."); } crank.interactable = false; crank.disabledHoverTip = string.Empty; crank.disabledHoverIcon = null; } public override void OnDestroy() { if (Object.op_Implicit((Object)(object)crank) && crank.onInteract != null) { ((UnityEvent<PlayerControllerB>)(object)crank.onInteract).RemoveListener((UnityAction<PlayerControllerB>)base.SendInteraction); } base.OnDestroy(); } protected override void OnClientInteraction(PlayerControllerB player) { if (base.DecisionsHere && base.State == 4 && InRange(player, CrankRange)) { float time = Time.time; float heldCrankWindow = HeldCrankWindow; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} manivelle ecart={((lastCrankAt < 0f) ? (-1f) : (time - lastCrankAt)):F2}s fenetre={heldCrankWindow:F2}s"); } lastCrankAt = time; crankUntil = time + heldCrankWindow; } } protected override void Think() { //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) UpdateEnergy(); PlayerControllerB seenPlayer = base.SeenPlayer; if (base.State == 10 || base.State == 9) { Halt(); return; } if (base.State == 5 || base.State == 7) { returning = false; if (base.State == 7) { if (!lungeStarted) { if (ClipIs("Boxy_JumpHop") || base.StateAge >= 0.6f) { lungeStarted = true; lungeStartAt = Time.time; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} bond depart clip={base.ClipNow} attente={base.StateAge:F2}"); } } else { Halt(); } } if (lungeStarted && Time.time - lungeStartAt < 0.72f) { ShortLunge(Victim, 3.7f, 8.5f); } else if (lungeStarted) { Brake(); } else { Halt(); } } if (!ContinueAttack()) { if (base.State == 7 && lungeStarted) { Brake(); } SetState(2); } return; } if (base.State == 4) { Halt(); returning = false; retreatUntil = 0f; trackedDamage = 0f; damageRetreatPending = false; PlayGaugeSounds(); if (!cranking && !(Time.time < closedUntil)) { if (energy >= EnergyMax) { LeaveBox("jauge-pleine"); } else if (energy >= EnergyExit && PlayerNearForExit()) { LeaveBox("joueur-proche"); } } return; } if (damageRetreatPending && Time.time >= retreatUntil && !returning) { StartRetreat(damageRetreatFrom, "degats"); } if (Time.time < retreatUntil) { if (HoldForBox()) { Brake(); } else { Withdraw(retreatFrom, RetreatSpeed); } if (Cornered) { if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} retraite impossible (aucune echappatoire), fin de la retraite"); } retreatUntil = Time.time; } return; } if (retreatUntil > 0f) { retreatUntil = 0f; energy = 0f; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Boxy #{((NetworkBehaviour)this).NetworkObjectId} retraite finie, retour a la boite jauge=0"); } } if (Object.op_Implicit((Object)(object)armVolume) && Time.time >= nextReach && CanStrike(seenPlayer, 4.8f)) { lunge = false; nextReach = Time.time + 11f; BeginAttack(seenPlayer, 9); } else if (CanStrike(seenPlayer, 2.8f)) { lunge = false; BeginAttack(seenPlayer); } else if (Time.time >= nextLunge && CanStrike(seenPlayer, 6.5f)) { lunge = true; lungeStarted = false; nextLunge = Time.time + 8f; BeginAttack(seenPlayer, 7); } else if (energy <= 0f) { ReturnToBox(); } else if (base.SinceSeen < 5f && !base.GivingUp) { if (base.State == 2 && base.RouteStalled) { GiveUp(); SetState(0); Patrol(BoxyPatrolSpeed); return; } SetState(2); if (HoldForBox()) { Brake(); Face(seenPlayer); } else { Go(base.LastPlayerPosition, 4.9f); } } else { SetState(0); if (HoldForBox()) { Brake(); } else if (!TryInvestigate()) { Patrol(BoxyPatrolSpeed); } } } protected override void ApplyPose(int value, bool initial) { Bool("box", value == 4); Bool("full", value == 2 || value == 5 || value == 7 || value == 9 || value == 10); Bool("partial", value == 0); walkingShown = (value == 2 || value == 0) && base.ShownSpeed > 0.3f; Bool("walking", walkingShown); Bool("Winding", value == 9); Bool("GrabbedTarget", value == 10); if (Object.op_Implicit((Object)(object)crank)) { crank.interactable = value == 4; } int num = value switch { 0 => 1, 4 => 0, _ => 2, }; if (num != boxShape) { if (!initial && num != 0) { boxHoldUntil = Time.time + 0.25f; } boxShape = num; } if (initial) { if (value == 10) { PlayInitialCapturePose(); } return; } if (value == 4) { Sound("BoxyRetractFull"); } else if (Object.op_Implicit((Object)(object)music)) { music.Stop(); } if (value == 2) { Sound("BoxyFullPop1"); } if (value == 5) { Trigger((PoseVariant == 1) ? "AttackLeft" : "AttackRight"); Sound("BoxySwing1"); } if (value == 7) { Trigger("JumpHop"); Sound("BoxyLeap"); } if (value == 9) { Trigger("ArmGrab"); } } internal override void Footstep() { Sound("BoxyStepHard1"); } internal override void AnimationSound(string key) { if (key == "PlayRandomLandingSound") { Sound("BoxyMetal1"); } if (key == "PlayRandomBoxLandSound") { Sound("BoxyCrateLand"); } if (key == "PlayRandomGrabLaunchSound" && base.State == 9) { Sound("BoxyGrabLaunch1"); } if (key == "PlayRandomGrabReadySound" && base.State == 9) { Sound("BoxyGrabReady"); } if (key == "PlayRandomJumpscareSound") { Sound("BoxyJumpscare"); } if (key == "PlayRandomPartialRetractSound") { Sound("BoxyRetractPartial"); } } } public sealed class RuinedBrain : CreatureBrain { private sealed class BoneNudge { private readonly Transform bone; internal readonly float Scale; internal readonly bool Jaw; private Quaternion animatedLocal; private Quaternion writtenLocal; private bool applied; internal BoneNudge(Transform bone, float scale, bool jaw) { this.bone = bone; Scale = scale; Jaw = jaw; } internal void Apply(Vector3 axis, float angle) { //IL_000e: 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_004d: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (applied && bone.localRotation == writtenLocal) { bone.localRotation = animatedLocal; } applied = false; if (!(Mathf.Abs(angle) < 0.01f)) { animatedLocal = bone.localRotation; bone.rotation = Quaternion.AngleAxis(angle, axis) * bone.rotation; writtenLocal = bone.localRotation; applied = true; } } } private float nextHunt; private float fleeRetryAt; private int cornered; private int retreats; private Vector3 escape; public float BiteFear = 0.75f; internal const int Shy = 0; internal const int Playful = 1; internal const int Aggressive = 2; private static readonly string[] PersonalityNames = new string[3] { "timide", "joueur", "agressif" }; private const int NoGaze = -1; public bool GazeEnabled = true; public float GazeYawMax = 35f; public float GazePitchMax = 20f; public float GazeTurnSpeed = 240f; public float GazeRange = 30f; public float ShyObserveMin = 8f; public float ShyObserveMax = 14f; public int ShyBites = 1; public int ShyFleeHp = 5; public float PlayfulObserveMin = 5f; public float PlayfulObserveMax = 9f; public int PlayfulBites = 2; public int PlayfulFleeHp = 3; public float AggressiveObserveMin = 3f; public float AggressiveObserveMax = 6f; public float AggressiveChaseMax = 25f; public float ChaseMax = 15f; public int AggressiveBites = 3; public int AggressiveFleeHp = 2; public float ObserveDistanceMin = 4f; public float ObserveDistanceMax = 6f; public float ApproachSpeed = 1.5f; public float ApproachMax = 10f; public float GrowlMin = 7f; public float GrowlMax = 14f; public string PresenceSound = "CritterBite1"; private Random rng; private int personality; private float observeDistance = 5f; private float watchTime = 6f; private float approachSince; private float nextGrowl; private bool approaching; private int bitesDone; private PlayerControllerB gazePlayer; private HeadGaze gaze; private CritterAbility ability = CritterAbility.None; private readonly NetworkVariable<int> gazeTarget = new NetworkVariable<int>(-1, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private BoneNudge[] bitePoseBones; public bool BiteMotion = true; private float biteStartedAt = -1f; private Transform[] biteJaw; private const float BiteArm = 0.4f; private const float BiteSnap = 0.55f; private const float BiteEnd = 0.85f; private const float BiteSnapPitch = 18f; private float nextChaseTrace; public float CatnapHearingFactor = 2.2f; private const float ReferenceStride = 0.7f; public float strideSpeed = 0.7f; public float critterMinCadence = 0.6f; public float critterMaxCadence = 3f; public float CritterPatrolSpeed = 1f; public float CritterChaseSpeed = 2f; public float CritterFleeSpeed = 2f; public float FleeTime = 8f; public bool BondEnabled = true; public float bondRange = 3.5f; public float bondDistance = 2f; public float bondTime = 0.3f; public float bondCooldown = 4f; public float bondAcceleration = 60f; private float bondUntil; private float nextBond; private Vector3 bondTarget; private float bondSpeedNow = 6.67f; internal static readonly List<RuinedBrain> All = new List<RuinedBrain>(16); public string BubbaSound = "CritterInjured1"; public float BubbaRadius = 25f; public float BubbaCooldown = 20f; public float BubbaAngleMin = 50f; public float BubbaAngleMax = 70f; public int BubbaMaxAlerted = 3; public float CraftyNodeMin = 6f; public float CraftyNodeMax = 15f; public float CraftyWaitMax = 20f; public float CraftyTravelMax = 12f; public float CraftyCooldown = 30f; public float CraftyTriggerRange = 4f; public float CraftyBackDot = -0.3f; public float CraftyPounceDistance = 4f; public float CraftyPounceTime = 0.45f; public int DogdayFleeHp = 2; public float DogdayLeadRadius = 20f; public float DogdayLeadFactor = 0.5f; public float DogdayLeadCooldown = 60f; public float HoppyZigMin = 1.5f; public float HoppyZigMax = 2f; public float HoppyZigPeriod = 0.8f; public float HoppyLeapRange = 5f; public float HoppyLeapDistance = 5f; public float HoppyLeapSpeed = 9f; public float HoppyLeapCooldown = 6f; public string PickySound = "CritterBite1"; public float PickyRadius = 15f; public float PickySearchEvery = 2f; public float PickySniffMin = 2f; public float PickySniffMax = 3f; public float PickyWatchTime = 10f; public float PickyCooldown = 20f; public float PickyAngerTime = 30f; public int PickyBites = 2; private string critterProfile = string.Empty; private float angryUntil; private float shortenUntil; private float shortenFactor = 0.5f; private float nextShorten; private float approachPatience = 3f; private int angryBites; private int fleeHpOverride; internal const int StSearch = 0; internal const int StObserve = 1; internal const int StChase = 2; public float HugDuration = 2f; public float HugDivisor = 1f; public float HugCooldown = 10f; public int HugDamage = 5; public string CatnapSound = "CritterInjured1"; public float CatnapRange = 5f; public float CatnapCooldown = 15f; public float CatnapDuration = 4f; public float CatnapDrunk = 0.6f; public float KickSpeed = 3.1f; public float KickLift = 1.5f; public float KickDuration = 0.25f; internal const float MaxEffectSeconds = 5.5f; internal const int StAttack = 5; private const string EyesRedSignal = "@EyesRed"; [SerializeField] private SkinnedMeshRenderer eyes; [SerializeField] private Material whiteEyes; [SerializeField] private Material redEyes; public bool EyesEnabled = true; private int eyesShown = -1; private bool hostEyesRed; public bool StrafeEnabled = true; public float StrafeMinRate = 25f; public float StrafeHold = 0.5f; private bool strafeKnown; private bool strafeLogged; private int strafeSide; private float strafeYaw; private float strafeSince; private float strafeTurn; private float strafeUntil; protected override float SenseRange => 26f; protected override float HalfFieldOfView => 105f; protected override int AttackDamage => 15; protected override string[] SoundNames => new string[5] { "CritterFootstep1", "CritterBite1", "CritterInjured1", "SmilingCritterDeath1", "@EyesRed" }; protected override string HurtSound => "CritterInjured1"; protected override float StrikeFear => BiteFear; internal int Personality => personality; internal float ObserveDistance => observeDistance; private float ChaseLimit { get { if (personality != 2 && !(Time.time < angryUntil)) { return ChaseMax; } return AggressiveChaseMax; } } protected override float EffectiveHearingThreshold { get { if (!(ability is CatnapAbility)) { return HearingThreshold; } return HearingThreshold * CatnapHearingFactor; } } private float FleeLength => Mathf.Min(CritterFleeSpeed, SpeedCap) * FleeTime * 0.9f; private float StrideSpeed { get { if (!(strideSpeed > 0.05f)) { return 0.7f; } return strideSpeed; } } private float BondSpeed => bondSpeedNow; protected override float SpeedCap => StrideSpeed * critterMaxCadence; protected override bool Ungoverned => Time.time < bondUntil; protected override bool StartGate => true; internal int CurState => base.State; internal PlayerControllerB Seen => base.SeenPlayer; internal bool IsApproaching => approaching; internal int Retreats => retreats; internal bool Alive { get { if (!((EnemyAI)this).isEnemyDead) { return ((NetworkBehaviour)this).IsSpawned; } return false; } } internal float PatrolSpeed => CritterPatrolSpeed; internal float ChaseSpeedNow => CritterChaseSpeed; internal float ApproachSpeedNow => ApproachSpeed; internal float StrikeReach => HitRange; internal bool Stalled => base.RouteStalled; internal bool NavReady { get { if (Object.op_Implicit((Object)(object)((EnemyAI)this).agent) && ((Behaviour)((EnemyAI)this).agent).enabled) { return ((EnemyAI)this).agent.isOnNavMesh; } return false; } } internal NavMeshAgent Nav => ((EnemyAI)this).agent; internal GameObject[] Nodes => ((EnemyAI)this).allAINodes; internal int EnemyHp => ((EnemyAI)this).enemyHP; protected override bool OriginalRoute(string name, out SoundRoute route) { switch (name) { case "CritterFootstep1": route = new SoundRoute(null, 0.7f); return true; case "CritterBite1": route = new SoundRoute("BiteSFX", 1f, 0.9f, 1f); return true; case "CritterInjured1": route = new SoundRoute("InjuredSFX", 1f, 0.9f, 1f); return true; case "SmilingCritterDeath1": route = new SoundRoute("CreepySFX", 1.5f); return true; default: route = default(SoundRoute); return false; } } protected override void __initializeVariables() { ((NetworkVariableBase)gazeTarget).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)gazeTarget, "gazeTarget"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)gazeTarget); base.__initializeVariables(); } public override void Start() { base.Start(); rng = new Random((int)((NetworkBehaviour)this).NetworkObjectId * 7919 + 13); string text = (((Object)((EnemyAI)this).enemyType).name.EndsWith("RuinedEnemyType", StringComparison.Ordinal) ? ((Object)((EnemyAI)this).enemyType).name.Substring(0, ((Object)((EnemyAI)this).enemyType).name.Length - "RuinedEnemyType".Length) : ((Object)((EnemyAI)this).enemyType).name); ability = CritterAbility.For(text); critterProfile = text; All.Add(this); if (((NetworkBehaviour)this).IsServer) { personality = rng.Next(3); observeDistance = Between(ObserveDistanceMin, ObserveDistanceMax); ability.OnSpawn(this); if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Critter #{((NetworkBehaviour)this).NetworkObjectId} personnalite={PersonalityNames[personality]} ({text}) observation={ObserveMin():F0}-{ObserveMax():F0} s distance={observeDistance:F1} m morsures={Bites()} fuite<={FleeHp()} PV"); } } string how; Transform val = HeadGaze.Find(((Component)this).transform, out how); if (Object.op_Implicit((Object)(object)val)) { gaze = new HeadGaze(val); Plugin.LogOnce("Critter " + text + " : os de tête « " + ((Object)val).name + " » (" + how + ")."); biteJaw = Array.FindAll(((Component)val).GetComponentsInChildren<Transform>(true), (Transform t) => IsJawBone(t) && (!Object.op_Implicit((Object)(object)t.parent) || !IsJawBone(t.parent))); } else { Plugin.LogOnce("Critter " + text + " : aucun os de tête trouvé, pas de regard pour ce prefab.", warning: true); } } private float Between(float min, float max) { if (!(max <= min)) { return min + (float)rng.NextDouble() * (max - min); } return min; } private float ObserveMin() { if (personality != 0) { if (personality != 1) { return AggressiveObserveMin; } return PlayfulObserveMin; } return ShyObserveMin; } private float ObserveMax() { if (personality != 0) { if (personality != 1) { return AggressiveObserveMax; } return PlayfulObserveMax; } return ShyObserveMax; } private int Bites() { if (!(Time.time < angryUntil)) { if (personality != 0) { if (personality != 1) { return AggressiveBites; } return PlayfulBites; } return ShyBites; } return Mathf.Max(angryBites, 1); } private int FleeHp() { if (fleeHpOverride <= 0) { if (!(Time.time < angryUntil)) { if (personality != 0) { if (personality != 1) { return AggressiveFleeHp; } return PlayfulFleeHp; } return ShyFleeHp; } return AggressiveFleeHp; } return fleeHpOverride; } private static float FlatGap(Vector3 a, Vector3 b) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) float num = a.x - b.x; float num2 = a.z - b.z; return Mathf.Sqrt(num * num + num2 * num2); } private void PublishGaze(PlayerControllerB seen) { int num = -1; if (GazeEnabled && !((EnemyAI)this).isEnemyDead && (base.State == 1 || base.State == 2 || base.State == 5)) { PlayerControllerB val = (gazePlayer = ((base.State == 5 && Object.op_Implicit((Object)(object)Victim)) ? Victim : (Object.op_Implicit((Object)(object)seen) ? seen : gazePlayer))); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; int num2 = 0; while (Object.op_Implicit((Object)(object)val) && num2 < allPlayerScripts.Length) { if ((Object)(object)allPlayerScripts[num2] == (Object)(object)val) { num = num2; break; } num2++; } } else { gazePlayer = null; } if (base.NetLive && gazeTarget.Value != num) { gazeTarget.Value = num; } } private void LateUpdate() { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (gaze == null) { return; } PlayerControllerB val = null; Vector3 val3; if (GazeEnabled && !((EnemyAI)this).isEnemyDead && base.State != 6) { StartOfRound instance = StartOfRound.Instance; int value = gazeTarget.Value; if (Object.op_Implicit((Object)(object)instance) && value >= 0 && value < instance.allPlayerScripts.Length) { PlayerControllerB val2 = instance.allPlayerScripts[value]; if (Object.op_Implicit((Object)(object)val2) && val2.isPlayerControlled && !val2.isPlayerDead && Object.op_Implicit((Object)(object)val2.gameplayCamera)) { val3 = ((Component)val2.gameplayCamera).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val3)).sqrMagnitude <= GazeRange * GazeRange) { val = val2; } } } } BitePose(out var head, out var jaw); gaze.ExtraPitch = head; HeadGaze headGaze = gaze; Transform transform = ((Component)this).transform; bool hasTarget = Object.op_Implicit((Object)(object)val); Vector3 targetPoint; if (!Object.op_Implicit((Object)(object)val)) { val3 = default(Vector3); targetPoint = val3; } else { targetPoint = ((Component)val.gameplayCamera).transform.position; } headGaze.Apply(transform, hasTarget, targetPoint, GazeYawMax, GazePitchMax, GazeTurnSpeed, Time.deltaTime); if (bitePoseBones == null) { List<BoneNudge> list = new List<BoneNudge>(); if (Object.op_Implicit((Object)(object)gaze.Bone.parent) && (Object)(object)gaze.Bone.parent != (Object)(object)((Component)this).transform) { list.Add(new BoneNudge(gaze.Bone.parent, 0.35f, jaw: false)); } if (biteJaw != null) { Transform[] array = biteJaw; foreach (Transform val4 in array) { if (Object.op_Implicit((Object)(object)val4)) { list.Add(new BoneNudge(val4, 1f, jaw: true)); } } } bitePoseBones = list.ToArray(); } if (bitePoseBones != null) { BoneNudge[] array2 = bitePoseBones; foreach (BoneNudge boneNudge in array2) { boneNudge.Apply(((Component)this).transform.right, boneNudge.Jaw ? jaw : (head * boneNudge.Scale)); } } } private static bool IsJawBone(Transform t) { if (((Object)t).name.IndexOf("B_Mouth", StringComparison.OrdinalIgnoreCase) >= 0) { return !((Object)t).name.EndsWith("_end", StringComparison.OrdinalIgnoreCase); } return false; } private static float Ease(float x) { x = Mathf.Clamp01(x); return x * x * (3f - 2f * x); } private void BitePose(out float head, out float jaw) { head = (jaw = 0f); if (!(biteStartedAt < 0f)) { float num = Time.time - biteStartedAt; if (!BiteMotion || ((EnemyAI)this).isEnemyDead || base.State == 6 || num > 0.85f) { biteStartedAt = -1f; } else if (num < 0.4f) { float num2 = Ease(num / 0.4f); head = -14f * num2; jaw = 28f * num2; } else if (num < 0.55f) { float num3 = Ease((num - 0.4f) / 0.15f); head = Mathf.Lerp(-14f, 18f, num3); jaw = Mathf.Lerp(28f, 0f, num3 * num3); } else { float num4 = Ease((num - 0.55f) / 0.3f); head = Mathf.Lerp(18f, 0f, num4); jaw = 0f; } } } private void GrowlTick() { if (base.State != 1 && base.State != 2) { nextGrowl = 0f; return; } float time = Time.time; if (nextGrowl <= 0f) { nextGrowl = time + Between(GrowlMin, GrowlMax); } else if (!(time < nextGrowl)) { nextGrowl = time + Between(GrowlMin, GrowlMax); if (!string.IsNullOrEmpty(PresenceSound)) { SignalSound(PresenceSound); } } } private void BeginEncounter(PlayerControllerB player, float patience = 3f) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) bitesDone = 0; approachPatience = patience; bool custom; Vector3 b = ObserveGoal(player, out custom); if (custom ? (FlatGap(((Component)this).transform.position, b) > 1.5f) : (FlatGap(((Component)this).transform.position, ((Component)player).transform.position) > observeDistance + 1.5f)) { approaching = true; approachSince = Time.time; SetState(2); } else { StartObserving(); } } private void TraceChase(PlayerControllerB player, string branch) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (Plugin.ProfileAI && ability is HoppyAbility hoppyAbility && !(Time.time < nextChaseTrace)) { nextChaseTrace = Time.time + 0.5f; Vector3 b = (Object.op_Implicit((Object)(object)player) ? ((Component)player).transform.position : base.LastPlayerPosition); Plugin.Log.LogInfo((object)string.Format("Critter #{0} poursuite branche={1} vu={2} depuis-vu={3:F1} ecart={4:F1} capacite={5}", ((NetworkBehaviour)this).NetworkObjectId, branch, (Object)(object)player != (Object)null, base.SinceSeen, FlatGap(((Component)this).transform.position, b), Object.op_Implicit((Object)(object)player) ? hoppyAbility.Refusal : "-")); } } private Vector3 ObserveGoal(PlayerControllerB player, out bool custom) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) Vector3 result = ability.ObservePoint(this, player, out custom); if (!custom) { return ((Component)player).transform.position; } return result; } private void StartObserving() { approaching = false; watchTime = Between(ObserveMin(), ObserveMax()); if (Time.time < shortenUntil) { watchTime *= shortenFactor; shortenUntil = 0f; } Brake(); SetState(1); } protected override void Think() { //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: 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_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_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_0327: 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) PlayerControllerB seenPlayer = base.SeenPlayer; PublishGaze(seenPlayer); PublishEyes(); if (ability.Think(this)) { return; } if (retreats >= 3 && HiddenFromAll(6f) && (base.State == 0 || base.State == 3) && ((EnemyAI)this).enemyType.canBeDestroyed) { Plugin.Log.LogInfo((object)$"{((EnemyAI)this).enemyType.enemyName} #{((NetworkBehaviour)this).NetworkObjectId} s'en va : {retreats} fuites, hors de vue de tous depuis 6 s"); ((EnemyAI)this).KillEnemyOnOwnerClient(true); return; } GrowlTick(); switch (base.State) { case 0: if (Object.op_Implicit((Object)(object)seenPlayer) && Time.time >= nextHunt) { BeginEncounter(seenPlayer); } else if (!TryInvestigate()) { Patrol(CritterPatrolSpeed); } break; case 1: if (base.SinceSeen > 5f) { SetState(0); } else if (base.StateAge > watchTime || InRange(seenPlayer, 3.4f)) { approaching = false; SetState(2); } else { Brake(); Face(seenPlayer); } break; case 2: if (approaching) { if (base.SinceSeen > approachPatience) { approaching = false; SetState(0); break; } Vector3 val2 = (Object.op_Implicit((Object)(object)seenPlayer) ? ((Component)seenPlayer).transform.position : base.LastPlayerPosition); bool custom = false; Vector3 val3 = (Object.op_Implicit((Object)(object)seenPlayer) ? ObserveGoal(seenPlayer, out custom) : val2); if (!InRange(seenPlayer, custom ? 2.2f : 3.4f)) { bool flag = (custom ? (FlatGap(((Component)this).transform.position, val3) <= 0.6f) : (FlatGap(((Component)this).transform.position, val2) <= observeDistance)); if (flag || Time.time - approachSince > ApproachMax) { if (custom && Plugin.ProfileAI && Object.op_Implicit((Object)(object)seenPlayer)) { Vector3 val4 = (Object.op_Implicit((Object)(object)seenPlayer.gameplayCamera) ? ((Component)seenPlayer.gameplayCamera).transform.forward : ((Component)seenPlayer).transform.forward); Vector3 val5 = ((Component)this).transform.position - ((Component)seenPlayer).transform.position; val4.y = (val5.y = 0f); Plugin.Log.LogInfo((object)$"Critter #{((NetworkBehaviour)this).NetworkObjectId} observation point propre arrive={flag} ecart-point={FlatGap(((Component)this).transform.position, val3):F1} m angle={Vector3.Angle(val4, val5):F0} distance={((Vector3)(ref val5)).magnitude:F1} m"); } StartObserving(); } else { Go(val3, ApproachSpeed); } break; } approaching = false; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Critter #{((NetworkBehaviour)this).NetworkObjectId} approche annulee : joueur a {FlatGap(((Component)this).transform.position, val2):F1} m (point propre={custom})"); } } if (CanStrike(seenPlayer, HitRange)) { BeginAttack(seenPlayer); break; } if (base.SinceSeen > (base.RouteProgressing ? 7f : 3f) || base.StateAge > ChaseLimit || base.RouteStalled) { Flee(); break; } if (Time.time < bondUntil) { Go(bondTarget, BondSpeed); break; } if (Object.op_Implicit((Object)(object)seenPlayer) && ability.Chase(this, seenPlayer)) { TraceChase(seenPlayer, "capacite"); break; } if (TryBond(seenPlayer)) { TraceChase(seenPlayer, "bond-socle"); break; } TraceChase(seenPlayer, "marche"); Go(base.LastPlayerPosition, CritterChaseSpeed); break; case 5: if (!ContinueAttack()) { AfterBite(); } break; case 3: if (!(base.StateAge > FleeTime)) { Vector3 val = ((Component)this).transform.position - escape; if (!(((Vector3)(ref val)).sqrMagnitude < 4f) && !base.RouteStalled) { Go(escape, CritterFleeSpeed); break; } } nextHunt = Time.time + 2f; bitesDone = 0; SetState(0); break; case 4: break; } } private void AfterBite() { bitesDone++; if (ability.Holding) { approaching = false; SetState(2); } else if (bitesDone < Bites() && ((EnemyAI)this).enemyHP > FleeHp()) { SetState(2); } else { Flee(); } } private void Flee() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) approaching = false; Vector3 val = (CanTarget(base.SeenPlayer) ? ((Component)base.SeenPlayer).transform.position : base.LastPlayerPosition); Vector3 direction = ((Component)this).transform.position - val; direction.y = 0f; if (((Vector3)(ref direction)).sqrMagnitude < 0.1f) { direction = -((Component)this).transform.forward; } if (Time.time < fleeRetryAt || !TryFindEscape(direction, val, out escape, FleeLength)) { if (Time.time >= fleeRetryAt) { fleeRetryAt = Time.time + 1.5f; if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Critter #{((NetworkBehaviour)this).NetworkObjectId} fuite impossible : menace a {Vector3.Distance(((Component)this).transform.position, val):F1} m, defenses={cornered}, morsures={bitesDone} ; refus : {base.EscapeReport}"); } } if (bitesDone > Bites()) { bitesDone = Bites(); } if (CanTarget(base.SeenPlayer) && InRange(base.SeenPlayer, 8f) && !base.RouteStalled && cornered < 2) { cornered++; nextHunt = Time.time; SetState(2); } else { cornered = 0; Halt(); nextHunt = Time.time + 4f; SetState(0); } } else { bitesDone = 0; retreats++; if (retreats == 3) { ResetWatched(); } cornered = 0; SetState(3); } } protected override void OnHeard(Vector3 position, float loudness) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d5: Unknown result type (might be due to invalid IL or missing references) if (ability.Occupied) { HeardReaction = "ignore-capacite"; } else if (base.State != 0 || base.Investigating) { if (base.State == 0 && personality != 0) { BeginInvestigation(position, ApproachSpeed); HeardReaction = "enquete-suivi"; } else { HeardReaction = ((base.State == 0) ? "ignore-en-route" : "ignore-etat"); } } else if (personality == 0 && Time.time >= angryUntil) { Vector3 direction = ((Component)this).transform.position - position; direction.y = 0f; if (((Vector3)(ref direction)).sqrMagnitude < 0.1f) { direction = -((Component)this).transform.forward; } if (TryFindEscape(direction, position, out var destination, FleeLength)) { BeginInvestigation(destination, CritterFleeSpeed); HeardReaction = "fuite"; } else { HeardReaction = "ignore-pas-de-fuite"; } } else { BeginInvestigation(position, ApproachSpeed); HeardReaction = "enquete"; } } protected override void OnStunnedHost() { gazePlayer = null; ability.OnStunned(this); if (base.NetLive && gazeTarget.Value != -1) { gazeTarget.Value = -1; } } protected override void OnSurvivingHit(PlayerControllerB attacker) { if (ability.OnHit(this, attacker)) { return; } if (base.State == 5 && ((EnemyAI)this).enemyHP <= FleeHp() && ((Behaviour)((EnemyAI)this).agent).enabled && ((EnemyAI)this).agent.isOnNavMesh) { CancelPendingAttack(); Flee(); } else if (base.State != 5 && base.State != 3 && ((Behaviour)((EnemyAI)this).agent).enabled && ((EnemyAI)this).agent.isOnNavMesh) { if (((EnemyAI)this).enemyHP <= FleeHp()) { Flee(); } else if ((base.State == 0 || base.State == 1) && CanTarget(base.SeenPlayer)) { approaching = false; SetState(2); } } } protected override void LoadTuning() { base.LoadTuning(); strideSpeed = Plugin.Tune("Critters.Foulee", strideSpeed); critterMinCadence = Plugin.Tune("Critters.CadenceMin", critterMinCadence); critterMaxCadence = Plugin.Tune("Critters.CadenceMax", critterMaxCadence); CritterPatrolSpeed = Plugin.Tune("Critters.VitessePatrouille", CritterPatrolSpeed); CritterChaseSpeed = Plugin.Tune("Critters.VitessePoursuite", CritterChaseSpeed); CritterFleeSpeed = Plugin.Tune("Critters.VitesseFuite", CritterFleeSpeed); BondEnabled = Plugin.TuneFlag("Critters.Bond", BondEnabled); bondRange = Plugin.Tune("Critters.BondPortee", bondRange); bondDistance = Plugin.Tune("Critters.BondDistance", bondDistance); bondTime = Plugin.Tune("Critters.BondDuree", bondTime); FleeTime = Plugin.Tune("Critters.DureeFuite", FleeTime); GazeEnabled = Plugin.Gameplay("Regard.Actif", GazeEnabled); BiteMotion = Plugin.Effect("Critters.MorsureAnimee", BiteMotion, "Morsure animée des Critters (tête et gueule, ajoutée : les mods d'origine n'ont aucun clip de morsure)."); GazeYawMax = Plugin.Gameplay("Regard.LacetMax", GazeYawMax); GazePitchMax = Plugin.Gameplay("Regard.TangageMax", GazePitchMax); GazeTurnSpeed = Plugin.Gameplay("Regard.VitesseTete", GazeTurnSpeed); GazeRange = Plugin.Gameplay("Regard.Portee", GazeRange); ShyObserveMin = Plugin.Gameplay("Timide.ObservationMin", ShyObserveMin); ShyObserveMax = Plugin.Gameplay("Timide.ObservationMax", ShyObserveMax); ShyBites = Plugin.Gameplay("Timide.Morsures", ShyBites); ShyFleeHp = Plugin.Gameplay("Timide.FuiteAPV", ShyFleeHp); PlayfulObserveMin = Plugin.Gameplay("Joueur.ObservationMin", PlayfulObserveMin); PlayfulObserveMax = Plugin.Gameplay("Joueur.ObservationMax", PlayfulObserveMax); PlayfulBites = Plugin.Gameplay("Joueur.Morsures", PlayfulBites); PlayfulFleeHp = Plugin.Gameplay("Joueur.FuiteAPV", PlayfulFleeHp); AggressiveObserveMin = Plugin.Gameplay("Agressif.ObservationMin", AggressiveObserveMin); AggressiveObserveMax = Plugin.Gameplay("Agressif.ObservationMax", AggressiveObserveMax); AggressiveBites = Plugin.Gameplay("Agressif.Morsures", AggressiveBites); AggressiveFleeHp = Plugin.Gameplay("Agressif.FuiteAPV", AggressiveFleeHp); AggressiveChaseMax = Plugin.Gameplay("Agressif.PoursuiteMax", AggressiveChaseMax); ChaseMax = Plugin.Gameplay("Critters.PoursuiteMax", ChaseMax); ObserveDistanceMin = Plugin.Gameplay("Observation.DistanceMin", ObserveDistanceMin); ObserveDistanceMax = Plugin.Gameplay("Observation.DistanceMax", ObserveDistanceMax); ApproachSpeed = Plugin.Gameplay("Observation.VitesseApproche", ApproachSpeed); ApproachMax = Plugin.Gameplay("Observation.ApprocheMax", ApproachMax); GrowlMin = Plugin.Gameplay("Grognement.IntervalleMin", GrowlMin); GrowlMax = Plugin.Gameplay("Grognement.IntervalleMax", GrowlMax); PresenceSound = Plugin.Gameplay("Grognement.Son", PresenceSound); LoadHearing("Critters", 0.2f, ApproachSpeed); CatnapHearingFactor = Plugin.Gameplay("Critters", "Ouie.FacteurCatnap", CatnapHearingFactor); LoadTuningC1(); LoadTuningC2(); LoadTuningEffects(); } protected override bool IsMovingClip(string clip) { return clip.Contains("Forward"); } protected override float AccelerationFor(float speed) { if (!(Time.time < bondUntil)) { return base.AccelerationFor(speed); } return bondAcceleration; } private bool TryBond(PlayerControllerB player) { if (BondEnabled && Time.time >= nextBond) { return StartBond(player, bondRange, bondDistance, bondTime, bondCooldown); } return false; } internal bool StartBond(PlayerControllerB player, float range, float distance, float time, float cooldown) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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) if (!BondEnabled || !CanStrike(player, range)) { return false; } Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; val.y = 0f; float num = Mathf.Min(distance, ((Vector3)(ref val)).magnitude - HitRange * 0.65f); if (num <= 0.2f) { return false; } bondTarget = ((Component)this).transform.position + ((Vector3)(ref val)).normalized * num; bondUntil = Time.time + time; bondSpeedNow = distance / Mathf.Max(0.1f, time); nextBond = Time.time + cooldown; Go(bondTarget, BondSpeed); if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Critter #{((NetworkBehaviour)this).NetworkObjectId} bond: {num:F2} m en {time:F2} s ({bondSpeedNow:F1} m/s)"); } return true; } protected override void OnSpeedMeasured() { bool moving = !((EnemyAI)this).isEnemyDead && (base.State == 0 || base.State == 2 || base.State == 3); FollowStride(StrideSpeed, moving, critterMaxCadence, critterMinCadence); } protected override void ApplyPose(int value, bool initial) { PoseEffects(value, initial); Bool("Idling", value == 1 || value == 4 || value == 5); Bool("Forward", value == 0 || value == 2 || value == 3); if (!initial && value == 5) { Sound("CritterBite1"); biteStartedAt = Time.time; } if (value == 6) { if (((EnemyAI)this).creatureAnimator.layerCount == 2) { ((EnemyAI)this).creatureAnimator.SetLayerWeight(0, 0f); ((EnemyAI)this).creatureAnimator.SetLayerWeight(1, 1f); } Trigger("KillEnemy"); if (!initial) { Sound("SmilingCritterDeath1"); } } } internal override void Footstep() { Sound("CritterFootstep1"); } internal override void AnimationSound(string key) { if (key == "PlayRandomBiteSound" && base.State != 5) { Sound("CritterBite1"); } if (key == "PlayRandomInjuredSound") { Sound("CritterInjured1"); } } private void LoadTuningC1() { BubbaSound = Plugin.Gameplay("Bubba", "Son", BubbaSound); BubbaRadius = Plugin.Gameplay("Bubba", "Rayon", BubbaRadius); BubbaCooldown = Plugin.Gameplay("Bubba", "Delai", BubbaCooldown); BubbaAngleMin = Plugin.Gameplay("Bubba", "AngleMin", BubbaAngleMin); BubbaAngleMax = Plugin.Gameplay("Bubba", "AngleMax", BubbaAngleMax); BubbaMaxAlerted = Plugin.Gameplay("Bubba", "AlertesMax", BubbaMaxAlerted); CraftyNodeMin = Plugin.Gameplay("Crafty", "NoeudMin", CraftyNodeMin); CraftyNodeMax = Plugin.Gameplay("Crafty", "NoeudMax", CraftyNodeMax); CraftyWaitMax = Plugin.Gameplay("Crafty", "AttenteMax", CraftyWaitMax); CraftyTravelMax = Plugin.Gameplay("Crafty", "TrajetMax", CraftyTravelMax); CraftyCooldown = Plugin.Gameplay("Crafty", "Delai", CraftyCooldown); CraftyTriggerRange = Plugin.Gameplay("Crafty", "PorteeDeclenchement", CraftyTriggerRange); CraftyBackDot = Plugin.Gameplay("Crafty", "SeuilDeDos", CraftyBackDot); CraftyPounceDistance = Plugin.Gameplay("Crafty", "BondDistance", CraftyPounceDistance); CraftyPounceTime = Plugin.Gameplay("Crafty", "BondDuree", CraftyPounceTime); DogdayFleeHp = Plugin.Gameplay("Dogday", "FuiteAPV", DogdayFleeHp); DogdayLeadRadius = Plugin.Gameplay("Dogday", "Rayon", DogdayLeadRadius); DogdayLeadFactor = Plugin.Gameplay("Dogday", "Facteur", DogdayLeadFactor); DogdayLeadCooldown = Plugin.Gameplay("Dogday", "Delai", DogdayLeadCooldown); HoppyZigMin = Plugin.Gameplay("Hoppy", "ZigzagMin", HoppyZigMin); HoppyZigMax = Plugin.Gameplay("Hoppy", "ZigzagMax", HoppyZigMax); HoppyZigPeriod = Plugin.Gameplay("Hoppy", "ZigzagPeriode", HoppyZigPeriod); HoppyLeapRange = Plugin.Gameplay("Hoppy", "BondPortee", HoppyLeapRange); HoppyLeapDistance = Plugin.Gameplay("Hoppy", "BondDistance", HoppyLeapDistance); HoppyLeapSpeed = Plugin.Gameplay("Hoppy", "BondVitesse", HoppyLeapSpeed); HoppyLeapCooldown = Plugin.Gameplay("Hoppy", "Delai", HoppyLeapCooldown); PickySound = Plugin.Gameplay("Picky", "Son", PickySound); PickyRadius = Plugin.Gameplay("Picky", "Rayon", PickyRadius); PickySearchEvery = Plugin.Gameplay("Picky", "RechercheToutes", PickySearchEvery); PickySniffMin = Plugin.Gameplay("Picky", "RenifleMin", PickySniffMin); PickySniffMax = Plugin.Gameplay("Picky", "RenifleMax", PickySniffMax); PickyWatchTime = Plugin.Gameplay("Picky", "Surveillance", PickyWatchTime); PickyCooldown = Plugin.Gameplay("Picky", "Delai", PickyCooldown); PickyAngerTime = Plugin.Gameplay("Picky", "DureeColere", PickyAngerTime); PickyBites = Plugin.Gameplay("Picky", "Morsures", PickyBites); } public override void OnDestroy() { ability.OnRemoved(this); All.Remove(this); ((EnemyAI)this).OnDestroy(); } internal float Rand(float min, float max) { return Between(min, max); } internal void MoveTo(Vector3 position, float speed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Go(position, speed); } internal void Stop() { Halt(); } internal void ToState(int state) { SetState(state); } internal void LookAt(PlayerControllerB player) { Face(player); } internal void Say(string sound) { if (!string.IsNullOrEmpty(sound)) { SignalSound(sound); } } internal bool Strikeable(PlayerControllerB player, float range) { return CanStrike(player, range); } internal bool Targetable(PlayerControllerB player) { return CanTarget(player); } internal bool Sample(Vector3 position, float radius, out Vector3 destination) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return TrySampleRoute(position, radius, out destination); } internal void LogAbility(string text) { if (Plugin.ProfileAI) { Plugin.Log.LogInfo((object)$"Critter #{((NetworkBehaviour)this).NetworkObjectId} capacite={text}"); } } internal void AvoidShy() { if (personality == 0) { personality = 1; } } internal void OverrideFleeHp(int hp) { fleeHpOverride = hp; } internal PlayerControllerB Nearest(out float gap) { //IL_002b: 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) PlayerControllerB result = null; gap = float.MaxValue; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (CanTarget(val)) { float num = FlatGap(((Component)this).transform.position, ((Component)val).transform.position); if (num < gap) { gap = num; result = val; } } } return result; } internal void Engage(PlayerControllerB player) { NoteSeen(player); approaching = false; bitesDone = 0; SetState(2); } internal void BecomeAngry(float seconds, int bites) { angryUntil = Time.time + seconds; angryBites = bites; } internal bool Alert(PlayerControllerB target) { if (!Alive || base.State != 0 || retreats >= 3 || !NavReady || !CanTarget(target)) { return false; } NoteSeen(target); BeginEncounter(target, 8f); return true; } internal bool ShortenObservation(float factor, float cooldown) { float time = Time.time; if (!Alive || time < nextShorten) { return false; } if (base.State == 1) { watchTime = base.StateAge + Mathf.Max(0f, watchTime - base.StateAge) * factor; } else { if (base.State != 0 && (base.State != 2 || !approaching)) { return false; } shortenUntil = time + 20f; shortenFactor = factor; } nextShorten = time + cooldown; return true; } private void LoadTuningC2() { HugDuration = Capped("Bobby.CalinDuree", Plugin.Gameplay("Bobby", "CalinDuree", HugDuration)); HugDivisor = Plugin.Gameplay("Bobby", "CalinRalentissement", HugDivisor); HugCooldown = Plugin.Gameplay("Bobby", "Delai", HugCooldown); HugDamage = Plugin.Gameplay("Bobby", "DegatsParSeconde", HugDamage); CatnapSound = Plugin.Gameplay("Catnap", "Son", CatnapSound); CatnapRange = Plugin.Gameplay("Catnap", "Portee", CatnapRange); CatnapCooldown = Plugin.Gameplay("Catnap", "Delai", CatnapCooldown); CatnapDuration = Capped("Catnap.Duree", Plugin.Gameplay("Catnap", "Duree", CatnapDuration)); CatnapDrunk = Plugin.Gameplay("Catnap", "Vertige", CatnapDrunk); KickSpeed = Plugin.Gameplay("Kickin", "Impulsion", KickSpeed); KickLift = Plugin.Gameplay("Kickin", "Saut", KickLift); KickDuration = Plugin.Gameplay("Kickin", "Duree", KickDuration); } private static float Capped(string name, float seconds) { if (seconds <= 5.5f) { return seconds; } Plugin.LogOnce($"Réglage {name} = {seconds:F1} s trop long : ramené à {5.5f:F1} s (le client coupe tout effet à 6 s).", warning: true); return 5.5f; } protected override void OnClientInteraction(PlayerControllerB player) { ability.OnInteract(this, player); } protected override void OnStrikeLanded(PlayerControllerB victim) { ability.OnStrike(this, victim); } protected override void OnDeathHost() { ability.OnDeath(this); } internal void Hurt(PlayerControllerB player, int amount) { Damage(player, amount); } internal void SendFx(PlayerControllerB target, byte kind, float duration, float strength, float strength2) { SendEffect(target, kind, duration, strength, strength2); } internal void Withdraw() { Flee(); } internal void HoldChase() { approaching = false; if (base.State != 2) { SetState(2); } } private void LoadTuningEffects() { EyesEnabled = Plugin.Effect("Critters.YeuxRouges", EyesEnabled, "Les yeux des Critters deviennent rouges pendant la poursuite et la morsure (effet d'origine rendu en 0.1.58)."); StrafeEnabled = Plugin.Effect("Critters.PasDeCote", StrafeEnabled, "Les Critters font des pas de côté (animation) quand leur corps pivote pendant l'observation (effet d'origine rendu en 0.1.58)."); StrafeMinRate = Plugin.EffectValue("Critters.PasDeCoteVitesseMin", StrafeMinRate, "Vitesse de rotation minimale (degrés par seconde) pour déclencher un pas de côté."); } internal void ConfigureEyes(Transform root, AssetBundle bundle, string critterName) { Transform val = root.Find(critterName + "Eyes"); eyes = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<SkinnedMeshRenderer>() : null); if (!Object.op_Implicit((Object)(object)eyes)) { eyes = Array.Find(((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(true), (SkinnedMeshRenderer r) => ((Object)r).name == critterName + "Eyes"); } whiteEyes = bundle.LoadAsset<Material>("RuinedSmallEyeMaterial"); redEyes = bundle.LoadAsset<Material>("RedEyesCritters"); if (!Object.op_Implicit((Object)(object)eyes) || !Object.op_Implicit((Object)(object)whiteEyes) || !Object.op_Implicit((Object)(object)redEyes)) { Plugin.Log.LogWarning((object)("Critter " + critterName + " : yeux rouges impossibles (maillage=" + (Object.op_Implicit((Object)(object)eyes) ? "ok" : "absent") + ", blanc=" + (Object.op_Implicit((Object)(object)whiteEyes) ? "ok" : "absent") + ", rouge=" + (Object.op_Implicit((Object)(object)redEyes) ? "ok" : "absent") + ").")); eyes = null; } } private void SetEyes(bool red) { if (!Object.op_Implicit((Object)(object)eyes) || !EyesEnabled || eyesShown == (red ? 1 : 0)) { return; } eyesShown = (red ? 1 : 0); Material val = (red ? redEyes : whiteEyes); Material[] sharedMaterials = ((Renderer)eyes).sharedMaterials; bool flag = false; for (int i = 0; i < sharedMaterials.Length; i++) { if ((Object)(object)sharedMaterials[i] == (Object)(object)whiteEyes || (Object)(object)sharedMaterials[i] == (Object)(object)redEyes) { sharedMaterials[i] = val; flag = true; } } if (!flag && sharedMaterials.Length != 0) { sharedMaterials[0] = val; } ((Renderer)eyes).sharedMaterials = sharedMaterials; if (red) { Plugin.Log.LogInfo((object)$"Critter {critterProfile} #{((NetworkBehaviour)this).NetworkObjectId} yeux rouges (poursuite) server={((NetworkBehaviour)this).IsServer}"); } } private void PublishEyes() { bool flag = !((EnemyAI)this).isEnemyDead && ((base.State == 2 && !approaching) || base.State == 5); if (flag != hostEyesRed) { hostEyesRed = flag; if (flag && base.State == 2 && base.NetLive) { SignalSound("@EyesRed"); } } } protected override void OnSignal(string name) { if (name == "@EyesRed" && !((EnemyAI)this).isEnemyDead && (base.State == 2 || base.State == 5)) { SetEyes(red: true); } } private void PoseEffects(int value, bool initial) { StopStrafe(); if (value == 5 || (initial && value == 2)) { SetEyes(red: true); } else if (value != 2) { hostEyesRed = false; SetEyes(red: false); } } public override void Update() { base.Update(); StrafeTick(); } private void StopStrafe() { strafeKnown = false; if (strafeSide != 0) { strafeSide = 0; Bool("StrafeLeft", value: false); Bool("StrafeRight", value: false); } } private void ApplyStrafe(int side) { strafeSide = side; Bool("StrafeLeft", side < 0); Bool("StrafeRight", side > 0); Bool("Idling", side == 0); } private void StrafeTick() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!StrafeEnabled || ((EnemyAI)this).isEnemyDead || base.State != 1 || !HasBool("StrafeLeft") || !HasBool("StrafeRight")) { if (strafeSide != 0) { StopStrafe(); if (base.State == 1) { Bool("Idling", value: true); } } strafeKnown = false; return; } float time = Time.time; float y = ((Component)this).transform.eulerAngles.y; if (!strafeKnown) { strafeKnown = true; strafeYaw = y; strafeSince = time; strafeTurn = 0f; return; } float num = Mathf.DeltaAngle(strafeYaw, y); strafeYaw = y; if (Mathf.Abs(num) > 90f) { strafeSince = time; strafeTurn = 0f; return; } strafeTurn += num; if (time - strafeSince < 0.2f) { return; } float num2 = strafeTurn / (time - strafeSince); strafeSince = time; strafeTurn = 0f; int num3 = ((num2 > StrafeMinRate) ? 1 : ((num2 < 0f - StrafeMinRate) ? (-1) : 0)); if (num3 != 0) { strafeUntil = time + StrafeHold; if (num3 != strafeSide) { ApplyStrafe(num3); if (!strafeLogged) { strafeLogged = true; Plugin.Log.LogInfo((object)string.Format("Critter {0} #{1} pas de cote {2} ({3:F0} deg/s) server={4}", critterProfile, ((NetworkBehaviour)this).NetworkObjectId, (num3 > 0) ? "droite" : "gauche", num2, ((NetworkBehaviour)this).IsServer)); } } } else if (strafeSide != 0 && time >= strafeUntil) { ApplyStrafe(0); } } } public sealed class HuggyBrain : CapturingBrain { private const bool HuggyMirrorIsLeft = true; private const int CaptureStateMissing = 0; private int captureStateHash; private bool captureStateTried; private static bool captureStateReported; private const float RoarHold = 5f; private float nextCharge; private float runSince = -1f; private float closeInSince = -1f; public float CloseInMax = 1.2f; private bool roarPending; private float roarPendingSince; private const float RoarCooldown = 30f; private float nextRoar; private float roarCooldownBackup; private bool loudChase; public float StalkMax = 15f; public float StalkCharge = 7f; public float AmbushMax = 25f; public float AmbushArrive = 12f; public float AmbushTrigger = 8f; public float AmbushMinDist = 5f; public float AmbushMaxDist = 18f; public float AmbushIdealDist = 9f; public float ChargeMax = 20f; public float ExhaustTime = 4f; public float ExhaustSpeed = 2f; public float SmashSpeed = 4f; public float GrabDelay = 2f; public float HitStun = 1f; public float HitRecoilDistance = 1.5f; public float HitRecoilTime = 0.3f; public int AmbushNodes = 24; public bool StalkSilentSteps = true; private bool ambushing; private bool ambushWaiting; private bool exhausted; private bool watched; private bool stalkFrozen; private bool stalkWasWatched; private float lastSweep; private Vector3 seenFrom; private Vector3 seenDir; private Vector3 searchPoint; private Vector3 shufflePoint; private bool searching; private bool searchedOnce; private bool shuffling; private float shuffleSign = 1f; private float exhaustUntil; private float ambushUntil; private float ambushArriveBy; private float nextGaze; private float resumeUntil; private float recoilUntil; private float stalkWatchedDist; private float stalkFreeDist; private float nextSmash; private Vector3 ambushNode; private Vector3 stalkLastPosition; private Vector3 recoilVelocity; private DoorLock smashedDoor; private int stalkNumber; public float HeardStalkRange = 15f; public float HeardStalkMax = 12f; public float HeardStalkArrive = 3f; private bool heardStalk; private float heardStalkSince; public bool RoarFear = true; public bool RoarShake = true; public float RoarShakeRange = 25f; private static readonly Dictionary<string, int> ClipStates = new Dictionary<string, int>(); private static readonly string[] StateGuesses = new string[25] { "ChargeHuggy", "Charge", "Run", "Running", "Chase", "Charging", "CrouchWalkHuggy", "CrouchWalk", "Crouch Walk", "Crouch_Walk", "Crouching", "Crouch", "CrouchWalking", "CrouchIdleHuggy", "CrouchIdle", "WalkHuggy", "Walk", "Walking", "IdleHuggy", "Idle", "RoarHuggy", "Roar", "SitIdleHuggy", "SitIdle", "Sitting" }; private static bool statesListed; public float HuggyRunStride = 5.5f; public float HuggyRunMinCadence = 0.8f; public float HuggyRunMaxCadence = 1.3f; public float HuggyWalkStride = 4.5f; public float HuggyWalkMinCadence = 0.75f; public float HuggyWalkMaxCadence = 1.3f; public float HuggyCrouchStride = 2.2f; public float HuggyCrouchMinCadence = 0.7f; public float HuggyCrouchMaxCadence = 1.3f; public float HuggyPatrolSpeed = 3.5f; public float HuggyObserveSpeed = 2.8f; public float RoarStopSpeed = 0.3f; public float RoarStopMax = 1f; private bool HasCaptureState => CaptureAnimationState != 0; protected override float SenseRange => 40f; protected override float HitRange => 3.2f; protected override float AttackWindup => 0.45f; protected override float AttackLength => 1.15f; protected override int AttackDamage => 35; protected override int CaptureRecoveryState => 4; protected override int CaptureAnimationState { get { if (!captureStateTried && Object.op_Implicit((Object)(object)((EnemyAI)this).creatureAnimator) && ((EnemyAI)this).creatureAnimator.isInitialized) { captureStateTried = true; if (ResolveState("JumpscareHuggy", out var hash, "JumpscareHuggy", "Jumpscare")) { captureStateHash = hash; if (Plugin.ProfileAI && !captureStateReported) { captureStateReported = true; Plugin.Log.LogInfo((object)$"Huggy #{((NetworkBehaviour)this).NetworkObjectId} etat de saisie resolu : hash={hash} (Base Layer.JumpscareHuggy ou Jumpscare)"); } } else if (!captureStateReported) { captureStateReported = true; Plugin.Log.LogWarning((object)$"Huggy #{((NetworkBehaviour)this).NetworkObjectId} etat de saisie introuvable (JumpscareHuggy, Jumpscare) : repli sur le declencheur Jumpscare, sans phase de saisie"); } } return captureStateHash; } } protected override bool CaptureFacesVictim => true; protected override float CaptureStrikeAfter => Mathf.Clamp(GrabDelay, 0.5f, 2.3f); protected override string[] SoundNames => new string[12] { "HuggyRoar1", "HuggyStomp1", "HuggyAttack1", "HuggySitDown", "Huggie_Jumpscare", "HuggyAttackVoice1", "HuggySitUp", "HuggyCrouch1", "HuggySlash", "HuggyRoar1Far", "HuggyRoar2Far", "HuggyRoar3Far" }; protected override float SpeedCap { get { if (base.State != 1) { if (base.State != 0) { return HuggyRunStride * HuggyRunMaxCadence; } return HuggyWalkStride * HuggyWalkMaxCadence; } return HuggyCrouchStride * HuggyCrouchMaxCadence; } } protected override bool StartGate => true; protected override int AttackVariant(PlayerControllerB victim) { return ArmToward(victim, 1); } protected override bool OriginalRoute(string name, out SoundRoute route) { switch (name) { case "HuggyStomp1": route = new SoundRoute(null, 0.7f, 13f / 14f, 1f); return true; case "HuggyAttack1": route = new SoundRoute(null, 2f, 13f / 14f, 1f); return true; case "HuggyAttackVoice1": route = new SoundRoute("VoiceAudio", 3f, 13f / 14f, 1f); return true; case "HuggyRoar1": route = new SoundRoute("VoiceAudio", 1f, 13f / 14f, 1f); return true; case "HuggyRoar1Far": case "HuggyRoar2Far": case "HuggyRoar3Far": route = new SoundRoute("VoiceFarAudio", 4f, 13f / 14f, 1f); return true; case "HuggyCrouch1": case "HuggySitDown": case "HuggySitUp": route = new SoundRoute(null, 1f, 13f / 14f, 1f); return true; case "HuggySlash": route = new SoundRoute("SlashAudio", 1f, 13f / 14f, 1f); return true; case "Huggie_Jumpscare": route = new SoundRoute(null, 1.5f); return true; default: route = default(SoundRoute); return false; } } protected override void OnTargetChanged(PlayerControllerB player) { Scare(player, 0.4f); } protected override void OnStrikeLanded(PlayerControllerB victim) { SignalSound("HuggySlash"); } internal void ConfigureGrab() { Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); captureAnchor = Array.Find(componentsInChildren, (Transform child) => ((Object)child).name == "JumpScarePoint"); captureHead = Array.Find(componentsInChildren, (Transform child) => ((Object)child).name == "head_JNT"); if (!Object.op_Implicit((Object)(object)captureAnchor)) { Plugin.Log.LogWarning((object)"Huggy is missing JumpScarePoint. Grab disabled."); } } protected override void Think() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or mi