mirror of
https://github.com/ppy/osu
synced 2025-02-17 19:07:07 +00:00
Add Triangles.Reset()
This commit is contained in:
parent
33c643e369
commit
3bcf9c255a
@ -87,12 +87,9 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float Velocity = 1;
|
public float Velocity = 1;
|
||||||
|
|
||||||
private readonly Random stableRandom;
|
|
||||||
|
|
||||||
private float nextRandom() => (float)(stableRandom?.NextDouble() ?? RNG.NextSingle());
|
|
||||||
|
|
||||||
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
|
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
|
||||||
|
|
||||||
|
private Random stableRandom;
|
||||||
private IShader shader;
|
private IShader shader;
|
||||||
private readonly Texture texture;
|
private readonly Texture texture;
|
||||||
|
|
||||||
@ -173,7 +170,20 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int AimCount;
|
/// <summary>
|
||||||
|
/// Clears and re-initialises triangles according to a given seed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seed">An optional seed to stabilise random positions / attributes. Note that this does not guarantee stable playback when seeking in time.</param>
|
||||||
|
public void Reset(int? seed = null)
|
||||||
|
{
|
||||||
|
if (seed != null)
|
||||||
|
stableRandom = new Random(seed.Value);
|
||||||
|
|
||||||
|
parts.Clear();
|
||||||
|
addTriangles(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int AimCount { get; private set; }
|
||||||
|
|
||||||
private void addTriangles(bool randomY)
|
private void addTriangles(bool randomY)
|
||||||
{
|
{
|
||||||
@ -227,6 +237,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float nextRandom() => (float)(stableRandom?.NextDouble() ?? RNG.NextSingle());
|
||||||
|
|
||||||
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(this);
|
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(this);
|
||||||
|
|
||||||
private class TrianglesDrawNode : DrawNode
|
private class TrianglesDrawNode : DrawNode
|
||||||
|
Loading…
Reference in New Issue
Block a user