2025-06-20 15:39:19 +02:00
|
|
|
|
using Cirno.Scripts.AttackPatterns;
|
|
|
|
|
|
using Godot;
|
|
|
|
|
|
using Godot.Collections;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Resources.BulletScripts;
|
|
|
|
|
|
|
|
|
|
|
|
[GlobalClass]
|
|
|
|
|
|
[Tool]
|
|
|
|
|
|
public partial class BulletScript3D : Resource
|
|
|
|
|
|
{
|
|
|
|
|
|
[Export]
|
2026-03-01 23:14:33 +01:00
|
|
|
|
public string Title { get; set; } = string.Empty;
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public Array<AttackPattern> Patterns { get; set; } = new Array<AttackPattern>();
|
|
|
|
|
|
|
2025-06-20 15:39:19 +02:00
|
|
|
|
public BulletScriptMachine Make(Node parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new BulletScriptMachine(parent, Patterns);
|
|
|
|
|
|
}
|
2026-03-01 23:14:33 +01:00
|
|
|
|
|
2025-06-20 15:39:19 +02:00
|
|
|
|
public class BulletScriptMachine(Node parent, Array<AttackPattern> patterns)
|
|
|
|
|
|
{
|
|
|
|
|
|
private int _currentPatternIndex = 0;
|
|
|
|
|
|
//private double _patternTimer;
|
2026-03-01 23:14:33 +01:00
|
|
|
|
|
2025-06-20 15:39:19 +02:00
|
|
|
|
private AttackPattern CurrentPattern => patterns[_currentPatternIndex];
|
|
|
|
|
|
|
|
|
|
|
|
private IPatternMachine _currentPatternMachine;
|
2026-03-01 23:14:33 +01:00
|
|
|
|
|
2025-06-20 15:39:19 +02:00
|
|
|
|
public void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (patterns.Count == 0) return;
|
|
|
|
|
|
_currentPatternIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
_currentPatternMachine = CurrentPattern.MakeMachine(parent);
|
|
|
|
|
|
_currentPatternMachine.Start();
|
|
|
|
|
|
}
|
2026-03-01 23:14:33 +01:00
|
|
|
|
|
2025-06-20 15:39:19 +02:00
|
|
|
|
public void UpdatePhase(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
//_patternTimer += delta;
|
2026-03-01 23:14:33 +01:00
|
|
|
|
|
2025-06-20 15:39:19 +02:00
|
|
|
|
_currentPatternMachine.UpdatePattern(delta);
|
|
|
|
|
|
//CurrentPattern.UpdatePattern(delta);
|
|
|
|
|
|
|
|
|
|
|
|
if (!CurrentPattern.WaitForCompletion || _currentPatternMachine.IsComplete())
|
|
|
|
|
|
{
|
|
|
|
|
|
_currentPatternIndex = (_currentPatternIndex + 1) % patterns.Count;
|
|
|
|
|
|
_currentPatternMachine = CurrentPattern.MakeMachine(parent);
|
|
|
|
|
|
_currentPatternMachine.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|