mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
53 lines
No EOL
1.3 KiB
C#
53 lines
No EOL
1.3 KiB
C#
using System.Collections.Generic;
|
|
using Cirno.Scripts;
|
|
using Cirno.Scripts.Components.Actors;
|
|
using Godot;
|
|
|
|
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()
|
|
{
|
|
_gameManager = this.GetGameManager();
|
|
|
|
var children = GetChildren();
|
|
foreach (var child in children) {
|
|
if (child is MovementHandler movementHandler)
|
|
{
|
|
_movementHandlers.Add(movementHandler);
|
|
movementHandler.Init(this);
|
|
}
|
|
else if (child is AnimationHandler animationHandler)
|
|
{
|
|
_animationHandlers.Add(animationHandler);
|
|
animationHandler.Init(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
foreach (var handler in _movementHandlers)
|
|
{
|
|
handler.Move(delta);
|
|
}
|
|
|
|
foreach (var handler in _animationHandlers)
|
|
{
|
|
handler.Update(delta);
|
|
}
|
|
}
|
|
|
|
} |