mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-14 00:15:54 +00:00
Simplified actor modules
This commit is contained in:
parent
28671c098b
commit
a7f4f4eb28
8 changed files with 57 additions and 34 deletions
|
|
@ -14,40 +14,35 @@ public partial class Actor : CharacterBody2D
|
|||
|
||||
private GameManager _gameManager;
|
||||
|
||||
private List<MovementHandler> _movementHandlers = new();
|
||||
|
||||
private List<AnimationHandler> _animationHandlers = new();
|
||||
private List<ActorModule> _modules = 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);
|
||||
}
|
||||
foreach (var child in children)
|
||||
{
|
||||
if (child is not ActorModule actorModule) continue;
|
||||
_modules.Add(actorModule);
|
||||
actorModule.Init(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
foreach (var handler in _movementHandlers)
|
||||
{
|
||||
handler.Move(delta);
|
||||
}
|
||||
|
||||
foreach (var handler in _animationHandlers)
|
||||
foreach (var handler in _modules)
|
||||
{
|
||||
handler.Update(delta);
|
||||
}
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
foreach (var handler in _modules)
|
||||
{
|
||||
handler.PhysicsUpdate(delta);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue