From c03835c06b268fe7eb2fd8769e3202f2f9006988 Mon Sep 17 00:00:00 2001 From: LTYGUY Date: Mon, 12 Feb 2024 10:29:55 +0800 Subject: [PATCH] fixed enemy teleport to current enemy when possess --- lc-hax/Scripts/Modules/Possession/PossessionMod.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lc-hax/Scripts/Modules/Possession/PossessionMod.cs b/lc-hax/Scripts/Modules/Possession/PossessionMod.cs index b9874a2e..9caa4180 100644 --- a/lc-hax/Scripts/Modules/Possession/PossessionMod.cs +++ b/lc-hax/Scripts/Modules/Possession/PossessionMod.cs @@ -13,7 +13,6 @@ internal sealed class PossessionMod : MonoBehaviour { Possession Possession { get; } = new(); Coroutine? UpdateCoroutine { get; set; } = null; CharacterMovement? CharacterMovement { get; set; } = null; - KeyboardMovement? Keyboard { get; set; } = null; MousePan? MousePan { get; set; } = null; bool FirstUpdate { get; set; } = true; @@ -35,7 +34,6 @@ internal sealed class PossessionMod : MonoBehaviour { void Awake() { this.CharacterMovement = this.gameObject.AddComponent(); - this.Keyboard = this.gameObject.AddComponent(); this.MousePan = this.gameObject.AddComponent(); this.enabled = false; @@ -82,11 +80,9 @@ void ToggleNoClip() { void UpdateComponentsOnCurrentState(bool thisGameObjectIsEnabled) { if (this.MousePan is not MousePan mousePan) return; if (this.CharacterMovement is not CharacterMovement rigidbodyKeyboard) return; - if (this.Keyboard is not KeyboardMovement keyboard) return; mousePan.enabled = thisGameObjectIsEnabled; rigidbodyKeyboard.enabled = !this.NoClipEnabled; - keyboard.enabled = this.NoClipEnabled; } IEnumerator EndOfFrameCoroutine() { @@ -119,9 +115,10 @@ void EndOfFrameUpdate() { agent.updatePosition = false; agent.updateRotation = false; } - - characterMovement.Init(); + characterMovement.enabled = false; this.transform.position = enemy.transform.position; + characterMovement.enabled = true; + characterMovement.Init(); this.UpdateComponentsOnCurrentState(true); } @@ -163,8 +160,8 @@ void SetEnemyColliders(EnemyAI enemy, bool enabled) => internal void Possess(EnemyAI enemy) { this.Unpossess(); - this.Possession.SetEnemy(enemy); this.FirstUpdate = true; + this.Possession.SetEnemy(enemy); } // Releases possession of the current enemy