Various additions and fixes
This commit is contained in:
@@ -11,7 +11,7 @@ public partial class Enemy : RigidBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
#region Registration
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
private IEnemyLogic _enemyLogic { get; set; } = default!;
|
||||
protected IEnemyLogic _enemyLogic { get; set; } = default!;
|
||||
|
||||
IEnemyLogic IProvide<IEnemyLogic>.Value() => _enemyLogic;
|
||||
|
||||
@@ -22,7 +22,7 @@ public partial class Enemy : RigidBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
|
||||
[Dependency] IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||
|
||||
[Dependency] IPlayer Player => this.DependOn<IPlayer>();
|
||||
[Dependency] protected IPlayer Player => this.DependOn<IPlayer>();
|
||||
#endregion
|
||||
|
||||
#region Exports
|
||||
@@ -158,18 +158,6 @@ public partial class Enemy : RigidBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
PatrolTimer.WaitTime = rng.RandfRange(5.0f, 10.0f);
|
||||
}
|
||||
|
||||
public void OnPhysicsProcess(double delta)
|
||||
{
|
||||
_enemyLogic.Input(new EnemyLogic.Input.PhysicsTick(delta));
|
||||
|
||||
if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(Player.CurrentPosition) < 2.5f)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.StartAttacking());
|
||||
if (_enemyLogic.Value is EnemyLogic.State.FollowPlayer && GlobalPosition.DistanceTo(Player.CurrentPosition) > 45f)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.LostPlayer());
|
||||
if (_enemyLogic.Value is EnemyLogic.State.Attacking && GlobalPosition.DistanceTo(Player.CurrentPosition) > 2.5f)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Alerted());
|
||||
}
|
||||
|
||||
public void StartAttackTimer()
|
||||
{
|
||||
AttackTimer.Timeout += OnAttackTimeout;
|
||||
|
||||
Reference in New Issue
Block a user