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));
    }
}