mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
79 lines
No EOL
2.1 KiB
C#
79 lines
No EOL
2.1 KiB
C#
using System;
|
|
using Cirno.Scripts.Enums;
|
|
using Cirno.Scripts.Resources;
|
|
using Cirno.Scripts.Resources.Loot;
|
|
using Godot;
|
|
using Godot.Collections;
|
|
|
|
namespace Cirno.Scripts.Components.FSM.Enemy;
|
|
|
|
public partial class EnemyFSMProxy : CharacterBody2D, IActivable
|
|
{
|
|
[Export] public EnemyStateMachine EnemyFSM { get; private set; }
|
|
|
|
[Export] public EnemyResource EnemyResource { get; private set; }
|
|
|
|
[Export] public Array<LootDrop> ExtraLoot { get; private set; } = [];
|
|
|
|
[Export] public bool OverrideLoot { get; set; } = false;
|
|
|
|
[Export]
|
|
public AiState StartingAiState { get; private set; }
|
|
|
|
[ExportCategory("Defeat Script")]
|
|
[Export] public Node2D DefeatScript { get; set; }
|
|
|
|
[Export] public ActivationType ActivationType { get; private set; } = ActivationType.Toggle;
|
|
|
|
[Signal] public delegate void DeathEventHandler(EnemyFSMProxy enemy);
|
|
|
|
public void Init(EnemyResource enemyResource)
|
|
{
|
|
this.EnemyResource = enemyResource;
|
|
|
|
}
|
|
|
|
public void TriggerDeath()
|
|
{
|
|
EmitSignalDeath(this);
|
|
}
|
|
|
|
public void RequestAlert(Vector2 destination)
|
|
{
|
|
//EnemyFSM.SetState(EnemyState.Alert);
|
|
}
|
|
|
|
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
|
{
|
|
switch (activationType)
|
|
{
|
|
case ActivationType.Toggle:
|
|
EnemyFSM.SetState(EnemyState.Controlled);
|
|
break;
|
|
case ActivationType.Enable:
|
|
// Enable or disable AI
|
|
EnemyFSM.SetState(EnemyState.Shooting);
|
|
break;
|
|
case ActivationType.Disable:
|
|
EnemyFSM.SetState(EnemyState.Idle);
|
|
// Enable or disable AI
|
|
break;
|
|
case ActivationType.Use:
|
|
break;
|
|
case ActivationType.Destroy:
|
|
EnemyFSM.SetState(EnemyState.Dead);
|
|
break;
|
|
case ActivationType.Open:
|
|
break;
|
|
case ActivationType.Close:
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public void Toggle()
|
|
{
|
|
this.Activate();
|
|
}
|
|
} |