mirror of
https://github.com/osukey/osukey.git
synced 2025-06-29 07:07:55 +09:00
Further code tidying
This commit is contained in:
parent
00daaef27a
commit
ef31698f56
@ -7,6 +7,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
public override string Description => "They just won't stay still...";
|
public override string Description => "They just won't stay still...";
|
||||||
public override double ScoreMultiplier => 1;
|
public override double ScoreMultiplier => 1;
|
||||||
|
|
||||||
private const int wiggle_delay = 90; // (ms) Higher = fewer wiggles
|
private const int wiggle_duration = 90; // (ms) Higher = fewer wiggles
|
||||||
private const int wiggle_strength = 10; // Higher = stronger wiggles
|
private const int wiggle_strength = 10; // Higher = stronger wiggles
|
||||||
|
|
||||||
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
||||||
@ -32,51 +33,35 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state)
|
private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state)
|
||||||
{
|
{
|
||||||
var hitObject = (OsuHitObject)drawable.HitObject;
|
var osuObject = (OsuHitObject)drawable.HitObject;
|
||||||
Vector2 origPos = drawable.Position;
|
Vector2 origin = drawable.Position;
|
||||||
|
|
||||||
Random distRand = new Random(hitObject.ComboOffset);
|
Random distRand = new Random(osuObject.ComboOffset);
|
||||||
Random angleRand = new Random(hitObject.IndexInCurrentCombo);
|
Random angleRand = new Random(osuObject.IndexInCurrentCombo);
|
||||||
|
|
||||||
// Wiggle all objects during TimePreempt
|
// Wiggle all objects during TimePreempt
|
||||||
int amountWiggles = (int)hitObject.TimePreempt / wiggle_delay;
|
int amountWiggles = (int)osuObject.TimePreempt / wiggle_duration;
|
||||||
|
|
||||||
|
void wiggle()
|
||||||
|
{
|
||||||
|
float nextAngle = (float)(angleRand.NextDouble() * 2 * Math.PI);
|
||||||
|
float nextDist = (float)(distRand.NextDouble() * wiggle_strength);
|
||||||
|
drawable.MoveTo(new Vector2((float)(nextDist * Math.Cos(nextAngle) + origin.X), (float)(nextDist * Math.Sin(nextAngle) + origin.Y)), wiggle_duration);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < amountWiggles; i++)
|
for (int i = 0; i < amountWiggles; i++)
|
||||||
{
|
using (drawable.BeginAbsoluteSequence(osuObject.StartTime - osuObject.TimePreempt + i * wiggle_duration, true))
|
||||||
using (drawable.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt + i * wiggle_delay, true))
|
wiggle();
|
||||||
{
|
|
||||||
float nextAngle = (float)(angleRand.NextDouble() * 2 * Math.PI);
|
|
||||||
float nextDist = (float)(distRand.NextDouble() * wiggle_strength);
|
|
||||||
Vector2 wiggledPos = new Vector2((float)(nextDist * Math.Cos(nextAngle) + origPos.X), (float)(nextDist * Math.Sin(nextAngle) + origPos.Y));
|
|
||||||
drawable.MoveTo(wiggledPos, wiggle_delay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keep wiggling sliders and spinners for their duration
|
// Keep wiggling sliders and spinners for their duration
|
||||||
double objDuration;
|
if (!(osuObject is IHasEndTime endTime))
|
||||||
if (hitObject is Slider slider)
|
|
||||||
{
|
|
||||||
objDuration = slider.Duration;
|
|
||||||
}
|
|
||||||
else if (hitObject is Spinner spinner)
|
|
||||||
{
|
|
||||||
objDuration = spinner.Duration;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
amountWiggles = (int)(objDuration / wiggle_delay);
|
amountWiggles = (int)(endTime.Duration / wiggle_duration);
|
||||||
|
|
||||||
for (int i = 0; i < amountWiggles; i++)
|
for (int i = 0; i < amountWiggles; i++)
|
||||||
{
|
using (drawable.BeginAbsoluteSequence(osuObject.StartTime + i * wiggle_duration, true))
|
||||||
using (drawable.BeginAbsoluteSequence(hitObject.StartTime + i * wiggle_delay, true))
|
wiggle();
|
||||||
{
|
|
||||||
float nextAngle = (float)(angleRand.NextDouble() * 2 * Math.PI);
|
|
||||||
float nextDist = (float)(distRand.NextDouble() * wiggle_strength);
|
|
||||||
Vector2 wiggledPos = new Vector2((float)(nextDist * Math.Cos(nextAngle) + origPos.X), (float)(nextDist * Math.Sin(nextAngle) + origPos.Y));
|
|
||||||
drawable.MoveTo(wiggledPos, wiggle_delay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user