Reduce random allocations

This commit is contained in:
Dean Herbert 2018-09-14 18:20:19 +09:00
parent ef31698f56
commit ec6185cd31
1 changed files with 3 additions and 4 deletions

View File

@ -36,16 +36,15 @@ private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedS
var osuObject = (OsuHitObject)drawable.HitObject;
Vector2 origin = drawable.Position;
Random distRand = new Random(osuObject.ComboOffset);
Random angleRand = new Random(osuObject.IndexInCurrentCombo);
Random objRand = new Random((int)osuObject.StartTime);
// Wiggle all objects during TimePreempt
int amountWiggles = (int)osuObject.TimePreempt / wiggle_duration;
void wiggle()
{
float nextAngle = (float)(angleRand.NextDouble() * 2 * Math.PI);
float nextDist = (float)(distRand.NextDouble() * wiggle_strength);
float nextAngle = (float)(objRand.NextDouble() * 2 * Math.PI);
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);
}