mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Revert af4c3727d77a16e2534df9bbf452336b5c544342
This commit is contained in:
@ -13,7 +13,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics
|
||||
{
|
||||
public class ParticleSpewer : Sprite
|
||||
public abstract class ParticleSpewer : Sprite
|
||||
{
|
||||
private readonly FallingParticle[] particles;
|
||||
private int currentIndex;
|
||||
@ -29,16 +29,12 @@ namespace osu.Game.Graphics
|
||||
|
||||
public override bool IsPresent => base.IsPresent && hasActiveParticles;
|
||||
|
||||
/// <summary>
|
||||
/// Called each time a new particle should be spawned.
|
||||
/// </summary>
|
||||
public Func<FallingParticle?> CreateParticle = () => new FallingParticle();
|
||||
|
||||
public float ParticleGravity;
|
||||
protected virtual bool CanSpawnParticles => true;
|
||||
protected virtual float ParticleGravity => 0;
|
||||
|
||||
private bool hasActiveParticles => Active.Value || (lastParticleAdded + maxDuration) > Time.Current;
|
||||
|
||||
public ParticleSpewer(Texture texture, int perSecond, double maxDuration)
|
||||
protected ParticleSpewer(Texture texture, int perSecond, double maxDuration)
|
||||
{
|
||||
Texture = texture;
|
||||
Blending = BlendingParameters.Additive;
|
||||
@ -57,25 +53,25 @@ namespace osu.Game.Graphics
|
||||
// this can happen when seeking in replays.
|
||||
if (lastParticleAdded > Time.Current) lastParticleAdded = 0;
|
||||
|
||||
if (Active.Value && Time.Current > lastParticleAdded + cooldown)
|
||||
if (Active.Value && CanSpawnParticles && Time.Current > lastParticleAdded + cooldown)
|
||||
{
|
||||
var newParticle = CreateParticle();
|
||||
newParticle.StartTime = (float)Time.Current;
|
||||
|
||||
if (newParticle.HasValue)
|
||||
{
|
||||
var particle = newParticle.Value;
|
||||
particle.StartTime = (float)Time.Current;
|
||||
particles[currentIndex] = newParticle;
|
||||
|
||||
particles[currentIndex] = particle;
|
||||
|
||||
currentIndex = (currentIndex + 1) % particles.Length;
|
||||
lastParticleAdded = Time.Current;
|
||||
}
|
||||
currentIndex = (currentIndex + 1) % particles.Length;
|
||||
lastParticleAdded = Time.Current;
|
||||
}
|
||||
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called each time a new particle should be spawned.
|
||||
/// </summary>
|
||||
protected virtual FallingParticle CreateParticle() => new FallingParticle();
|
||||
|
||||
protected override DrawNode CreateDrawNode() => new ParticleSpewerDrawNode(this);
|
||||
|
||||
# region DrawNode
|
||||
@ -178,7 +174,7 @@ namespace osu.Game.Graphics
|
||||
|
||||
#endregion
|
||||
|
||||
public struct FallingParticle
|
||||
protected struct FallingParticle
|
||||
{
|
||||
public float StartTime;
|
||||
public Vector2 StartPosition;
|
||||
|
Reference in New Issue
Block a user