Big refactor in place: Organize nodes in line with dependency injection expectations, use state machine flow more

This commit is contained in:
2024-09-11 15:33:36 -07:00
parent 6a4eb81529
commit 4d47a7586e
63 changed files with 1123 additions and 469 deletions

View File

@@ -7,7 +7,7 @@ using Godot;
namespace GameJamDungeon
{
public interface IPlayer : ICharacterBody3D
public interface IPlayer : ICharacterBody3D, IKillable
{
PlayerStatInfo PlayerStatInfo { get; }
@@ -84,7 +84,7 @@ namespace GameJamDungeon
public void Setup()
{
Settings = new PlayerLogic.Settings() { RotationSpeed = RotationSpeed, MoveSpeed = MoveSpeed };
Settings = new PlayerLogic.Settings() { RotationSpeed = RotationSpeed, MoveSpeed = MoveSpeed, Acceleration = Acceleration };
PlayerLogic = new PlayerLogic();
PlayerLogic.Set(this as IPlayer);
@@ -92,14 +92,6 @@ namespace GameJamDungeon
PlayerLogic.Set(AppRepo);
PlayerLogic.Set(GameRepo);
PlayerLogic.Set(PlayerData);
GameRepo.SetPlayerGlobalPosition(GlobalPosition);
GameRepo.PlayerGlobalPosition.Sync += OnPlayerPositionUpdated;
GameRepo.SetPlayerStatInfo(PlayerStatInfo);
HealthTimer.Timeout += OnHealthTimerTimeout;
CollisionDetector.AreaEntered += OnEnemyHitBoxEntered;
}
public void OnResolved()
@@ -127,6 +119,11 @@ namespace GameJamDungeon
PlayerLogic.Start();
SwordSlashAnimation.Position = GetViewport().GetVisibleRect().Size / 2;
GlobalPosition = GameRepo.PlayerGlobalPosition.Value;
GameRepo.SetPlayerStatInfo(PlayerStatInfo);
HealthTimer.Timeout += OnHealthTimerTimeout;
CollisionDetector.AreaEntered += OnEnemyHitBoxEntered;
}
public void OnReady()
@@ -227,6 +224,8 @@ namespace GameJamDungeon
AnimationPlayer.AnimationFinished -= OnAnimationFinished;
}
public void Kill() => PlayerLogic.Input(new PlayerLogic.Input.Killed());
private void OnHPChanged(double newHP)
{
HPNumber.Text = $"{Mathf.RoundToInt(newHP)}/{PlayerStatInfo.MaximumHP}";