mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 02:15:54 +00:00
Made bullet creation modifier generics
This commit is contained in:
parent
9ae07e5b38
commit
797e24d766
7 changed files with 46 additions and 10 deletions
9
Scripts/Resources/BulletCreationModifier.cs
Normal file
9
Scripts/Resources/BulletCreationModifier.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public abstract partial class BulletCreationModifier : Resource, IBulletModifier
|
||||
{
|
||||
public abstract float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets);
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ public partial class BulletResource : Resource
|
|||
[Export] public DamageType DamageType = DamageType.Neutral;
|
||||
|
||||
[Export]
|
||||
public Resource Modifier;
|
||||
public BulletCreationModifier Modifier;
|
||||
[Export] public Array<Resource> TimeModifiers;
|
||||
|
||||
public BulletInfo MakeBullet(Vector2 position, int count = 1, float spread = 0f, float rotationOffset = 0f)
|
||||
|
|
@ -36,7 +36,7 @@ public partial class BulletResource : Resource
|
|||
Spread = spread,
|
||||
BulletScene = BulletScene,
|
||||
RotationOffset = rotationOffset,
|
||||
Modifier = Modifier as IBulletModifier,
|
||||
Modifier = Modifier,
|
||||
LifeTime = LifeTime,
|
||||
DestructionParticlesScene = DestructionParticlesScene,
|
||||
TimeModifiers = TimeModifiers?.Where(mod => mod is TimeModifier).Cast<TimeModifier>().ToList() ??
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class DecreasingSpeedModifier : Resource, IBulletModifier
|
||||
public partial class DecreasingSpeedModifier : BulletCreationModifier, IBulletModifier
|
||||
{
|
||||
[Export] private float decreaseRate = 0.1f;
|
||||
|
||||
public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
public override float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
{
|
||||
return Mathf.Max(0, baseSpeed - (decreaseRate * bulletIndex));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace Cirno.Scripts.Resources;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SpeedModifier : Resource, IBulletModifier
|
||||
public partial class SpeedModifier : BulletCreationModifier, IBulletModifier
|
||||
{
|
||||
[Export] public SpeedModifierType ModifierType;
|
||||
[Export] public EasingType Easing;
|
||||
|
|
@ -11,7 +11,7 @@ public partial class SpeedModifier : Resource, IBulletModifier
|
|||
[Export] public float MinimumSpeed = 10f;
|
||||
[Export] public float ScalingFactor = 10.0f;
|
||||
|
||||
public float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
public override float ModifySpeed(float baseSpeed, int bulletIndex, int totalBullets)
|
||||
{
|
||||
if (totalBullets <= 1)
|
||||
return baseSpeed;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue