mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
76 lines
No EOL
1.7 KiB
C#
76 lines
No EOL
1.7 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; } = 20f;
|
|
|
|
[Export]
|
|
public float Health { get; private set; } = 4f;
|
|
|
|
[ExportCategory("Defeat Script")]
|
|
[Export] public Node2D DefeatScript { get; set; }
|
|
|
|
[Export] public ActivationType ActivationType { get; private set; } = ActivationType.Toggle;
|
|
|
|
[Export]
|
|
public AiState StartingAiState { get; private set; }
|
|
|
|
public Vector2 MovementDirection { get; set; }
|
|
public Vector2 FacingDirection { get; set; }
|
|
|
|
private GameManager _gameManager;
|
|
|
|
private List<ActorModule> _modules = new();
|
|
|
|
[Signal]
|
|
public delegate void OnDeathEventHandler();
|
|
|
|
[Signal]
|
|
public delegate void OnControlAssumedEventHandler();
|
|
|
|
public bool IsDestroyed { get; set; }
|
|
|
|
public override void _Ready()
|
|
{
|
|
_gameManager = this.GetGameManager();
|
|
|
|
var children = GetChildren();
|
|
foreach (var child in children)
|
|
{
|
|
if (child is not ActorModule actorModule) continue;
|
|
_modules.Add(actorModule);
|
|
actorModule.Init(this);
|
|
}
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
foreach (var handler in _modules)
|
|
{
|
|
handler.Update(delta);
|
|
}
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
foreach (var handler in _modules)
|
|
{
|
|
handler.PhysicsUpdate(delta);
|
|
}
|
|
}
|
|
|
|
public void TriggerDeath()
|
|
{
|
|
EmitSignal(SignalName.OnDeath);
|
|
}
|
|
|
|
public void AssumeControl()
|
|
{
|
|
EmitSignal(SignalName.OnControlAssumed);
|
|
}
|
|
|
|
} |