using System.Collections.Generic; using System.Linq; using Cirno.Scripts.Components.Actors; using Godot; public abstract partial class MovementHandler : Node2D { protected Actor _parent; public abstract Vector2 MovementDirection { get; set; } public abstract Vector2 FacingDirection { get; set; } protected readonly List _inputProviders = new(); public virtual void Init(Actor parent) { _parent = parent; var children = GetChildren(); foreach (var child in children) { if (child is InputProvider inputProvider) { _inputProviders.Add(inputProvider); } } } public virtual Vector2 AggregateInputProviders() { return _inputProviders.Aggregate(Vector2.Zero, (current, inputProvider) => current + inputProvider.GetMovementInput().Normalized()); } public abstract void Move(double delta); }