feat: Update enemy AI and movement systems
- Enhanced Physics2D layer collision report with new interactions between Player and Enemy layers. - Refactored BD_InvestigateLastKnown to streamline animation handling and improve readability. - Simplified BD_MaintainCombatDistance by consolidating movement stop logic. - Updated BD_MoveToPlayer to set AI phase on start. - Improved BD_Patrol logic with better handling of stuck states and path failures. - Enhanced BD_PatrolWaypoints to manage stuck conditions and retry logic more effectively. - Refined BD_ReturnToHome to remove unnecessary animation calls. - Updated BD_WalkRandom to ensure AI phase is set correctly on start. - Improved EnemyAbilityBase to delegate target facing to the movement system. - Enhanced EnemyBase with new movement methods for better control. - Refactored EnemyMovement to introduce a new input system for handling movement and facing. - Added EnemyMoveInput struct to encapsulate movement intentions. - Updated Physics2DSettings to reflect new layer collision matrix. - Introduced RTK CLI instructions for optimized command usage.
This commit is contained in:
@@ -54,13 +54,6 @@ namespace BaseGames.Enemies.AI
|
||||
_stepsRemaining = m_RandomStepCount;
|
||||
_pathFailed = false;
|
||||
|
||||
var ac = _enemy.AnimConfig;
|
||||
if (_enemy.Animancer != null)
|
||||
{
|
||||
var clip = ac?.Investigate ?? ac?.Walk;
|
||||
if (clip != null) _enemy.Animancer.Play(clip);
|
||||
}
|
||||
|
||||
if (!_subscribed && _enemy.Nav != null)
|
||||
{
|
||||
_enemy.Nav.OnNavPathFailed += HandlePathFailed;
|
||||
@@ -88,10 +81,8 @@ namespace BaseGames.Enemies.AI
|
||||
public override void OnEnd()
|
||||
{
|
||||
if (_subscribed && _enemy?.Nav != null)
|
||||
{
|
||||
_enemy.Nav.OnNavPathFailed -= HandlePathFailed;
|
||||
_subscribed = false;
|
||||
}
|
||||
_subscribed = false;
|
||||
_enemy?.StopMovement();
|
||||
}
|
||||
|
||||
@@ -147,13 +138,7 @@ namespace BaseGames.Enemies.AI
|
||||
{
|
||||
_step = InvestigateSubStep.LookAround;
|
||||
_stepTimer = 0f;
|
||||
|
||||
var ac = _enemy.AnimConfig;
|
||||
if (_enemy.Animancer != null)
|
||||
{
|
||||
var clip = ac?.Investigate ?? ac?.Idle;
|
||||
if (clip != null) _enemy.Animancer.Play(clip);
|
||||
}
|
||||
_enemy.BeginLookAround();
|
||||
}
|
||||
|
||||
private void EnterRandomWalk()
|
||||
@@ -169,13 +154,6 @@ namespace BaseGames.Enemies.AI
|
||||
_randomTarget = new Vector2(origin.x + dir * dist, origin.y);
|
||||
|
||||
_enemy.MoveTo(_randomTarget);
|
||||
|
||||
var ac = _enemy.AnimConfig;
|
||||
if (_enemy.Animancer != null)
|
||||
{
|
||||
var clip = ac?.Walk;
|
||||
if (clip != null) _enemy.Animancer.Play(clip);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandlePathFailed() => _pathFailed = true;
|
||||
|
||||
Reference in New Issue
Block a user