In progress work for Chariot
This commit is contained in:
@@ -62,6 +62,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
_enemyLogic.Set(this as IEnemy);
|
||||
_enemyLogic.Set(_player);
|
||||
_damageCalculator = new DamageCalculator();
|
||||
SetPhysicsProcess(true);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
@@ -86,7 +87,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
_lineOfSight.BodyEntered += LineOfSight_BodyEntered;
|
||||
}
|
||||
|
||||
public void OnPhysicsProcess(double delta)
|
||||
public void OnProcess(double delta)
|
||||
{
|
||||
if (CurrentHP.Value <= 0)
|
||||
return;
|
||||
@@ -95,9 +96,15 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
if (!lookDir.IsEqualApprox(GlobalPosition))
|
||||
LookAt(lookDir, Vector3.Up, true);
|
||||
|
||||
var isWalking = _enemyLogic.Value is EnemyLogic.State.Patrolling or EnemyLogic.State.FollowPlayer;
|
||||
_enemyModelView.SetCurrentDirection(GlobalBasis, _player.CurrentBasis);
|
||||
|
||||
if (_enemyModelView is EnemyModelView2D enemyModelView2D)
|
||||
enemyModelView2D.RotateModel(GlobalTransform.Basis, -_player.CurrentBasis.Z, isWalking);
|
||||
{
|
||||
if (_enemyLogic.Value is EnemyLogic.State.Patrolling or EnemyLogic.State.FollowPlayer)
|
||||
_enemyModelView.PlayWalkAnimation();
|
||||
else
|
||||
_enemyModelView.PlayIdleAnimation();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -138,6 +145,9 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
_enemyModelView.PlayHitAnimation();
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Alerted());
|
||||
|
||||
if (this is ICanActivate activatable)
|
||||
activatable.Activate();
|
||||
|
||||
if (((Weapon)_player.EquippedWeapon.Value).WeaponTag == WeaponTag.SelfDamage)
|
||||
_player.Stats.SetCurrentHP(_player.Stats.CurrentHP.Value - 5);
|
||||
}
|
||||
@@ -151,6 +161,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
|
||||
public void Die()
|
||||
{
|
||||
SetProcess(false);
|
||||
CurrentHP.OnNext(0);
|
||||
_enemyLogic.Input(new EnemyLogic.Input.EnemyDefeated());
|
||||
_collisionShape.SetDeferred("disabled", true);
|
||||
|
||||
Reference in New Issue
Block a user