Eden pillar rotation finally works i'm going to die now
This commit is contained in:
@@ -23,7 +23,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
|
||||
[Dependency] IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||
|
||||
[Dependency] protected IPlayer Player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
||||
[Dependency] protected IPlayer _player => this.DependOn(() => GetParent().GetChildren().OfType<IPlayer>().Single());
|
||||
#endregion
|
||||
|
||||
#region Exports
|
||||
@@ -59,7 +59,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
_enemyLogic = new EnemyLogic();
|
||||
_enemyLogic.Set(_enemyStatResource);
|
||||
_enemyLogic.Set(this as IEnemy);
|
||||
_enemyLogic.Set(Player);
|
||||
_enemyLogic.Set(_player);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
@@ -95,7 +95,7 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
|
||||
var isWalking = _enemyLogic.Value is EnemyLogic.State.Patrolling or EnemyLogic.State.FollowPlayer;
|
||||
if (_enemyModelView is EnemyModelView2D enemyModelView2D)
|
||||
enemyModelView2D.RotateModel(GlobalTransform.Basis, -Player.CurrentBasis.Z, isWalking);
|
||||
enemyModelView2D.RotateModel(GlobalTransform.Basis, -_player.CurrentBasis.Z, isWalking);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -135,8 +135,8 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
_enemyModelView.PlayHitAnimation();
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Alerted());
|
||||
|
||||
if (Player.EquippedWeapon.Value.WeaponTags.Contains(WeaponTag.SelfDamage))
|
||||
Player.Stats.SetCurrentHP(Player.Stats.CurrentHP.Value - 5);
|
||||
if (_player.EquippedWeapon.Value.WeaponTags.Contains(WeaponTag.SelfDamage))
|
||||
_player.Stats.SetCurrentHP(_player.Stats.CurrentHP.Value - 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,17 +170,17 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
|
||||
private void OnAttackTimeout()
|
||||
{
|
||||
if (GlobalPosition.DistanceTo(Player.CurrentPosition) > 5f)
|
||||
{
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Alerted());
|
||||
return;
|
||||
}
|
||||
//if (GlobalPosition.DistanceTo(_player.CurrentPosition) > 5f)
|
||||
//{
|
||||
// _enemyLogic.Input(new EnemyLogic.Input.Alerted());
|
||||
// return;
|
||||
//}
|
||||
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
_enemyLogic.Input(new EnemyLogic.Input.AttackTimer());
|
||||
_attackTimer.Stop();
|
||||
_attackTimer.WaitTime = rng.RandfRange(2f, 5.0f);
|
||||
//_attackTimer.WaitTime = rng.RandfRange(2f, 5.0f);
|
||||
_attackTimer.Start();
|
||||
}
|
||||
|
||||
@@ -189,8 +189,8 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
var overlappingBodies = _lineOfSight.GetOverlappingBodies();
|
||||
foreach (var _ in overlappingBodies)
|
||||
{
|
||||
if (_raycast.GlobalPosition != Player.CurrentPosition)
|
||||
_raycast.LookAt(Player.CurrentPosition, Vector3.Up);
|
||||
if (_raycast.GlobalPosition != _player.CurrentPosition)
|
||||
_raycast.LookAt(_player.CurrentPosition, Vector3.Up);
|
||||
_raycast.ForceRaycastUpdate();
|
||||
if (_raycast.IsColliding())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user