mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Reduce random allocations
This commit is contained in:
parent
ef31698f56
commit
ec6185cd31
@ -36,16 +36,15 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
var osuObject = (OsuHitObject)drawable.HitObject;
|
var osuObject = (OsuHitObject)drawable.HitObject;
|
||||||
Vector2 origin = drawable.Position;
|
Vector2 origin = drawable.Position;
|
||||||
|
|
||||||
Random distRand = new Random(osuObject.ComboOffset);
|
Random objRand = new Random((int)osuObject.StartTime);
|
||||||
Random angleRand = new Random(osuObject.IndexInCurrentCombo);
|
|
||||||
|
|
||||||
// Wiggle all objects during TimePreempt
|
// Wiggle all objects during TimePreempt
|
||||||
int amountWiggles = (int)osuObject.TimePreempt / wiggle_duration;
|
int amountWiggles = (int)osuObject.TimePreempt / wiggle_duration;
|
||||||
|
|
||||||
void wiggle()
|
void wiggle()
|
||||||
{
|
{
|
||||||
float nextAngle = (float)(angleRand.NextDouble() * 2 * Math.PI);
|
float nextAngle = (float)(objRand.NextDouble() * 2 * Math.PI);
|
||||||
float nextDist = (float)(distRand.NextDouble() * wiggle_strength);
|
float nextDist = (float)(objRand.NextDouble() * wiggle_strength);
|
||||||
drawable.MoveTo(new Vector2((float)(nextDist * Math.Cos(nextAngle) + origin.X), (float)(nextDist * Math.Sin(nextAngle) + origin.Y)), wiggle_duration);
|
drawable.MoveTo(new Vector2((float)(nextDist * Math.Cos(nextAngle) + origin.X), (float)(nextDist * Math.Sin(nextAngle) + origin.Y)), wiggle_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user