mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Delayed speed increase modifier
This commit is contained in:
parent
0e26056aa1
commit
97027ddc33
11 changed files with 145 additions and 9 deletions
26
Scripts/Resources/Modifiers/DelayedSpeedIncreaseModifier.cs
Normal file
26
Scripts/Resources/Modifiers/DelayedSpeedIncreaseModifier.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using Cirno.Scripts.Actors;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources.Modifiers;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DelayedSpeedIncreaseModifier : TimeModifier
|
||||
{
|
||||
|
||||
[Export] public Tween.TransitionType TransitionType { get; set; } = Tween.TransitionType.Linear;
|
||||
[Export] public Tween.EaseType EaseType { get; set; } = Tween.EaseType.InOut;
|
||||
|
||||
[Export] public float Duration { get; set; } = 1.0f;
|
||||
|
||||
public override void Update(Bullet bullet, double delta, double elapsed)
|
||||
{
|
||||
float easedValue = ApplyEasing(Value, elapsed);
|
||||
bullet.Speed += easedValue;
|
||||
}
|
||||
|
||||
private float ApplyEasing(float value, double time)
|
||||
{
|
||||
float t = Mathf.Clamp((float)time, 0f, 1f); // Ensure the value stays within range
|
||||
return (float)Tween.InterpolateValue(0f, value, t, Duration, TransitionType, EaseType);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue