Bad tank movement

This commit is contained in:
Marco 2025-02-18 17:40:33 +01:00
commit 90d2a95fa8
10 changed files with 514 additions and 8 deletions

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using Cirno.Scripts;
using Cirno.Scripts.Components.Actors;
using Godot;
public partial class Actor : CharacterBody2D
@ -7,12 +8,15 @@ public partial class Actor : CharacterBody2D
[Export]
public float MovementSpeed { get; private set; }
public Vector2 MovementDirection { get; set; }
public Vector2 FacingDirection { get; set; }
private GameManager _gameManager;
private List<MovementHandler> _movementHandlers = new();
private List<AnimationHandler> _animationHandlers = new();
public override void _Ready()
{
@ -23,6 +27,12 @@ public partial class Actor : CharacterBody2D
if (child is MovementHandler movementHandler)
{
_movementHandlers.Add(movementHandler);
movementHandler.Init(this);
}
else if (child is AnimationHandler animationHandler)
{
_animationHandlers.Add(animationHandler);
animationHandler.Init(this);
}
}
}
@ -33,6 +43,11 @@ public partial class Actor : CharacterBody2D
{
handler.Move(delta);
}
foreach (var handler in _animationHandlers)
{
handler.Update(delta);
}
}
}