cirnogodot/Scripts/Resources/DecreasingSpeedModifier.cs
2025-05-09 11:46:58 +02:00

22 lines
No EOL
650 B
C#

using Cirno.Scripts.Components;
using Godot;
namespace Cirno.Scripts.Resources;
[GlobalClass]
[Tool]
public partial class DecreasingSpeedModifier : BulletCreationModifier, IBulletModifier
{
[Export] private float decreaseRate = 0.1f;
public override BulletInfo ModifyBullet(BulletInfo bullet, int bulletIndex, int totalBullets)
{
bullet.Speed = ModifySpeed(bullet.OriginalBulletResource.BulletSpeed, bulletIndex, totalBullets);
return bullet;
}
public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
{
return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex));
}
}