2025-09-29 14:50:10 +02:00
|
|
|
|
using Cirno.Scripts.Components.FSM;
|
|
|
|
|
|
using Cirno.Scripts.Components.FSM.Enemy._3D;
|
|
|
|
|
|
using Cirno.Scripts.Enums;
|
|
|
|
|
|
using Cirno.Scripts.Resources;
|
2026-03-01 19:14:34 +01:00
|
|
|
|
using Cirno.Scripts.Resources.Loot;
|
2025-09-29 14:50:10 +02:00
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Components.Actors._3D;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class EnemyDropModule3D : ModuleBase<EnemyState, CharacterBody3D>
|
|
|
|
|
|
{
|
|
|
|
|
|
[Export] public EnemyStorage3D StorageModule { get; private set; }
|
2026-03-01 19:14:34 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>Radius of the circle in which dropped items are scattered uniformly.</summary>
|
|
|
|
|
|
[Export] public float LootScatterRadius { get; set; } = 1.0f;
|
|
|
|
|
|
/// <summary>Initial upward speed applied to each dropped item so it pops up before falling.</summary>
|
|
|
|
|
|
[Export] public float LootLaunchUpSpeed { get; set; } = 3.0f;
|
|
|
|
|
|
|
2025-09-29 14:50:10 +02:00
|
|
|
|
private bool _initialized = false;
|
|
|
|
|
|
private bool _enabled = false;
|
2026-03-01 19:14:34 +01:00
|
|
|
|
|
|
|
|
|
|
private RandomNumberGenerator _rng = new();
|
|
|
|
|
|
|
2025-09-29 14:50:10 +02:00
|
|
|
|
public override void EnterState(EnemyState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
_enabled = true;
|
|
|
|
|
|
|
2026-03-01 19:14:34 +01:00
|
|
|
|
LootDropHelper.SpawnDrops(
|
|
|
|
|
|
StorageModule.LootDrops,
|
|
|
|
|
|
_machine.MainObject,
|
|
|
|
|
|
_machine.MainObject.GlobalPosition,
|
|
|
|
|
|
LootScatterRadius,
|
|
|
|
|
|
LootLaunchUpSpeed,
|
|
|
|
|
|
_rng);
|
2025-09-29 14:50:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExitState(EnemyState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
_enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IStateMachine<EnemyState, CharacterBody3D> _machine;
|
2026-03-01 19:14:34 +01:00
|
|
|
|
|
2025-09-29 14:50:10 +02:00
|
|
|
|
public override void Init(IStateMachine<EnemyState, CharacterBody3D> machine)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_initialized) return;
|
2026-03-01 19:14:34 +01:00
|
|
|
|
|
2025-09-29 14:50:10 +02:00
|
|
|
|
_machine = machine;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Process(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void PhysicsProcess(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2026-03-01 19:14:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|