mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Bad tank movement
This commit is contained in:
parent
12f0062fe8
commit
90d2a95fa8
10 changed files with 514 additions and 8 deletions
|
|
@ -1,10 +1,35 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Godot;
|
||||
|
||||
public abstract partial class MovementHandler : Node2D
|
||||
{
|
||||
public Vector2 MovementDirection { get; set; }
|
||||
protected Actor _parent;
|
||||
|
||||
public abstract Vector2 MovementDirection { get; set; }
|
||||
|
||||
public abstract Vector2 FacingDirection { get; set; }
|
||||
|
||||
public abstract void Init(Actor parent);
|
||||
protected readonly List<InputProvider> _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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue