mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Remade resource script system
This commit is contained in:
parent
4261009c33
commit
029128c8b8
17 changed files with 576 additions and 386 deletions
|
|
@ -12,38 +12,47 @@ public partial class SimpleMovementPattern : AttackPattern
|
|||
[Export] private Tween.TransitionType transitionType = Tween.TransitionType.Linear;
|
||||
[Export] private Tween.EaseType easeType = Tween.EaseType.InOut;
|
||||
|
||||
private Tween tween;
|
||||
private bool isComplete = false;
|
||||
|
||||
protected IScriptHost Boss;
|
||||
|
||||
public override void Start(Node2D parent)
|
||||
public override IPatternMachine MakeMachine(Node2D parent)
|
||||
{
|
||||
Parent = parent;
|
||||
if (parent is not IScriptHost boss)
|
||||
return;
|
||||
|
||||
Boss = boss;
|
||||
tween = Parent.CreateTween();
|
||||
isComplete = false;
|
||||
|
||||
Vector2 targetPosition = (Boss?.HomePosition ?? Parent.GlobalPosition) + relativeTargetPosition;
|
||||
|
||||
boss.ChangeSpriteDirection(-(Parent.GlobalPosition - targetPosition));
|
||||
tween.TweenProperty(Parent, "global_position", targetPosition, moveDuration)
|
||||
.SetTrans(transitionType)
|
||||
.SetEase(easeType)
|
||||
.Finished += () =>
|
||||
{
|
||||
isComplete = true;
|
||||
boss.ChangeSpriteDirection(Vector2.Zero);
|
||||
};
|
||||
return new SimpleMovementPatternMachine(this, parent);
|
||||
}
|
||||
|
||||
public override void UpdatePattern(double delta) { }
|
||||
|
||||
public override bool IsComplete()
|
||||
public class SimpleMovementPatternMachine(SimpleMovementPattern pattern, Node2D parent) : IPatternMachine
|
||||
{
|
||||
return isComplete;
|
||||
public Node2D Parent => parent;
|
||||
|
||||
private Tween tween;
|
||||
private bool isComplete = false;
|
||||
|
||||
protected IScriptHost Boss;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (parent is not IScriptHost boss)
|
||||
return;
|
||||
|
||||
Boss = boss;
|
||||
tween = Parent.CreateTween();
|
||||
isComplete = false;
|
||||
|
||||
Vector2 targetPosition = (Boss?.HomePosition ?? Parent.GlobalPosition) + pattern.relativeTargetPosition;
|
||||
|
||||
boss.ChangeSpriteDirection(-(Parent.GlobalPosition - targetPosition));
|
||||
tween.TweenProperty(Parent, "global_position", targetPosition, pattern.moveDuration)
|
||||
.SetTrans(pattern.transitionType)
|
||||
.SetEase(pattern.easeType)
|
||||
.Finished += () =>
|
||||
{
|
||||
isComplete = true;
|
||||
boss.ChangeSpriteDirection(Vector2.Zero);
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdatePattern(double delta) { }
|
||||
|
||||
public bool IsComplete()
|
||||
{
|
||||
return isComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue