2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-11-20 20:19:49 +08:00
|
|
|
|
using System;
|
2023-11-06 17:43:47 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-08-18 15:16:00 +08:00
|
|
|
|
using System.Linq;
|
2020-11-06 22:09:23 +08:00
|
|
|
|
using JetBrains.Annotations;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-08-06 13:43:39 +08:00
|
|
|
|
using osu.Framework.Audio;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2020-07-29 19:01:01 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-11-19 19:40:30 +08:00
|
|
|
|
using osu.Game.Audio;
|
2020-11-15 04:10:12 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2019-12-12 20:15:16 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2020-07-29 19:01:01 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2020-11-15 04:10:12 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2023-12-20 19:23:43 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Scoring;
|
2020-08-16 01:12:06 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Skinning;
|
2020-12-04 19:21:53 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
2017-12-31 04:23:18 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-09-06 14:24:00 +08:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2020-07-29 15:37:23 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
public partial class DrawableSpinner : DrawableOsuHitObject
|
|
|
|
|
{
|
2020-11-05 12:51:46 +08:00
|
|
|
|
public new Spinner HitObject => (Spinner)base.HitObject;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-15 04:10:12 +08:00
|
|
|
|
public new OsuSpinnerJudgementResult Result => (OsuSpinnerJudgementResult)base.Result;
|
|
|
|
|
|
2021-06-20 01:06:28 +08:00
|
|
|
|
public SkinnableDrawable Body { get; private set; }
|
2021-06-19 01:33:50 +08:00
|
|
|
|
|
2020-11-05 12:51:46 +08:00
|
|
|
|
public SpinnerRotationTracker RotationTracker { get; private set; }
|
2021-03-26 18:09:44 +08:00
|
|
|
|
|
|
|
|
|
private SpinnerSpmCalculator spmCalculator;
|
2019-08-21 02:50:49 +08:00
|
|
|
|
|
2020-11-05 12:51:46 +08:00
|
|
|
|
private Container<DrawableSpinnerTick> ticks;
|
2020-11-19 19:40:30 +08:00
|
|
|
|
private PausableSkinnableSound spinningSample;
|
2018-11-09 12:58:46 +08:00
|
|
|
|
|
2020-11-05 12:51:46 +08:00
|
|
|
|
private Bindable<bool> isSpinning;
|
2020-08-16 01:12:06 +08:00
|
|
|
|
private bool spinnerFrequencyModulate;
|
|
|
|
|
|
2021-05-24 14:10:33 +08:00
|
|
|
|
private const float spinning_sample_initial_frequency = 1.0f;
|
|
|
|
|
private const float spinning_sample_modulated_base_frequency = 0.5f;
|
|
|
|
|
|
2023-11-06 17:29:51 +08:00
|
|
|
|
private SkinnableSound maxBonusSample;
|
|
|
|
|
|
2021-03-03 02:43:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The amount of bonus score gained from spinning after the required number of spins, for display purposes.
|
|
|
|
|
/// </summary>
|
2023-10-20 14:57:13 +08:00
|
|
|
|
public double CurrentBonusScore => score_per_tick * Math.Clamp(completedFullSpins.Value - HitObject.SpinsRequiredForBonus, 0, HitObject.MaximumBonusSpins);
|
2021-03-03 02:43:32 +08:00
|
|
|
|
|
2023-10-20 14:37:51 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The maximum amount of bonus score which can be achieved from extra spins.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double MaximumBonusScore => score_per_tick * HitObject.MaximumBonusSpins;
|
|
|
|
|
|
|
|
|
|
public IBindable<int> CompletedFullSpins => completedFullSpins;
|
|
|
|
|
|
|
|
|
|
private readonly Bindable<int> completedFullSpins = new Bindable<int>();
|
2021-03-26 18:09:44 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of spins per minute this spinner is spinning at, for display purposes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly IBindable<double> SpinsPerMinute = new BindableDouble();
|
2021-03-03 02:43:32 +08:00
|
|
|
|
|
2022-10-19 04:48:51 +08:00
|
|
|
|
private const double fade_out_duration = 240;
|
2021-03-22 15:04:51 +08:00
|
|
|
|
|
2020-11-10 23:22:06 +08:00
|
|
|
|
public DrawableSpinner()
|
|
|
|
|
: this(null)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-06 22:09:23 +08:00
|
|
|
|
public DrawableSpinner([CanBeNull] Spinner s = null)
|
2019-02-28 12:31:40 +08:00
|
|
|
|
: base(s)
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
2020-11-05 12:51:46 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-05 12:51:46 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 08:06:39 +08:00
|
|
|
|
private void load()
|
2020-11-05 12:51:46 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
2017-05-18 18:40:20 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-03-26 18:09:44 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
2021-03-30 12:43:05 +08:00
|
|
|
|
spmCalculator = new SpinnerSpmCalculator
|
|
|
|
|
{
|
|
|
|
|
Result = { BindTarget = SpinsPerMinute },
|
|
|
|
|
},
|
2022-06-07 05:29:14 +08:00
|
|
|
|
ticks = new Container<DrawableSpinnerTick>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2020-07-29 19:01:01 +08:00
|
|
|
|
new AspectContainer
|
2017-05-18 18:40:20 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2020-07-29 19:01:01 +08:00
|
|
|
|
Children = new Drawable[]
|
2017-05-18 18:40:20 +08:00
|
|
|
|
{
|
2022-11-09 15:04:56 +08:00
|
|
|
|
Body = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SpinnerBody), _ => new DefaultSpinner()),
|
2020-11-05 13:40:48 +08:00
|
|
|
|
RotationTracker = new SpinnerRotationTracker(this)
|
2017-05-18 18:40:20 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-11-19 19:40:30 +08:00
|
|
|
|
spinningSample = new PausableSkinnableSound
|
|
|
|
|
{
|
|
|
|
|
Volume = { Value = 0 },
|
2023-10-20 20:18:32 +08:00
|
|
|
|
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
2020-11-19 19:40:30 +08:00
|
|
|
|
Looping = true,
|
|
|
|
|
Frequency = { Value = spinning_sample_initial_frequency }
|
2023-11-06 17:29:51 +08:00
|
|
|
|
},
|
|
|
|
|
maxBonusSample = new SkinnableSound
|
|
|
|
|
{
|
|
|
|
|
MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME,
|
2020-11-19 19:40:30 +08:00
|
|
|
|
}
|
2021-03-26 18:09:44 +08:00
|
|
|
|
});
|
2019-12-12 20:15:16 +08:00
|
|
|
|
|
2020-11-06 22:35:47 +08:00
|
|
|
|
PositionBindable.BindValueChanged(pos => Position = pos.NewValue);
|
2020-11-05 12:51:46 +08:00
|
|
|
|
}
|
2020-07-30 18:34:59 +08:00
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
isSpinning = RotationTracker.IsSpinning.GetBoundCopy();
|
|
|
|
|
isSpinning.BindValueChanged(updateSpinningSample);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-30 18:24:38 +08:00
|
|
|
|
protected override void OnFree()
|
2020-11-19 19:40:30 +08:00
|
|
|
|
{
|
2020-11-30 18:24:38 +08:00
|
|
|
|
base.OnFree();
|
2020-11-19 19:40:30 +08:00
|
|
|
|
|
2023-01-27 18:32:30 +08:00
|
|
|
|
spinningSample.ClearSamples();
|
2023-11-06 17:29:51 +08:00
|
|
|
|
maxBonusSample.ClearSamples();
|
2020-11-19 19:40:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 18:34:59 +08:00
|
|
|
|
protected override void LoadSamples()
|
|
|
|
|
{
|
|
|
|
|
base.LoadSamples();
|
|
|
|
|
|
2023-04-26 19:55:39 +08:00
|
|
|
|
spinningSample.Samples = HitObject.CreateSpinningSamples().Cast<ISampleInfo>().ToArray();
|
2022-03-14 16:08:04 +08:00
|
|
|
|
spinningSample.Frequency.Value = spinning_sample_initial_frequency;
|
2023-11-06 17:29:51 +08:00
|
|
|
|
|
2023-11-06 17:43:47 +08:00
|
|
|
|
maxBonusSample.Samples = new ISampleInfo[] { new SpinnerBonusMaxSampleInfo(HitObject.CreateHitSampleInfo()) };
|
2020-07-30 18:34:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateSpinningSample(ValueChangedEvent<bool> tracking)
|
|
|
|
|
{
|
2020-09-29 11:45:20 +08:00
|
|
|
|
if (tracking.NewValue)
|
2020-07-30 18:34:59 +08:00
|
|
|
|
{
|
2021-01-19 16:11:40 +08:00
|
|
|
|
if (!spinningSample.IsPlaying)
|
2021-03-23 09:38:37 +08:00
|
|
|
|
spinningSample.Play();
|
|
|
|
|
|
|
|
|
|
spinningSample.VolumeTo(1, 300);
|
2020-07-30 18:34:59 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-03-23 09:38:37 +08:00
|
|
|
|
spinningSample.VolumeTo(0, fade_out_duration);
|
2020-07-30 18:34:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-29 14:07:55 +08:00
|
|
|
|
public override void StopAllSamples()
|
|
|
|
|
{
|
|
|
|
|
base.StopAllSamples();
|
|
|
|
|
spinningSample?.Stop();
|
2023-11-06 17:29:51 +08:00
|
|
|
|
maxBonusSample?.Stop();
|
2020-09-29 14:07:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-12 20:15:16 +08:00
|
|
|
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
|
|
|
|
{
|
|
|
|
|
base.AddNestedHitObject(hitObject);
|
2019-08-21 02:50:49 +08:00
|
|
|
|
|
2019-12-12 20:15:16 +08:00
|
|
|
|
switch (hitObject)
|
2019-08-21 02:50:49 +08:00
|
|
|
|
{
|
2019-12-12 20:15:16 +08:00
|
|
|
|
case DrawableSpinnerTick tick:
|
|
|
|
|
ticks.Add(tick);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-21 02:50:49 +08:00
|
|
|
|
|
2020-11-04 15:19:07 +08:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2020-07-29 19:01:01 +08:00
|
|
|
|
{
|
2020-11-04 15:19:07 +08:00
|
|
|
|
base.UpdateHitStateTransforms(state);
|
2020-07-29 19:01:01 +08:00
|
|
|
|
|
2021-03-22 15:04:51 +08:00
|
|
|
|
this.FadeOut(fade_out_duration).OnComplete(_ =>
|
|
|
|
|
{
|
|
|
|
|
// looping sample should be stopped here as it is safer than running in the OnComplete
|
|
|
|
|
// of the volume transition above.
|
|
|
|
|
spinningSample.Stop();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Expire();
|
2020-07-30 18:34:59 +08:00
|
|
|
|
|
|
|
|
|
// skin change does a rewind of transforms, which will stop the spinning sound from playing if it's currently in playback.
|
|
|
|
|
isSpinning?.TriggerChange();
|
2020-07-29 19:01:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-12 20:15:16 +08:00
|
|
|
|
protected override void ClearNestedHitObjects()
|
|
|
|
|
{
|
|
|
|
|
base.ClearNestedHitObjects();
|
2020-11-12 14:59:48 +08:00
|
|
|
|
ticks.Clear(false);
|
2019-12-12 20:15:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DrawableHitObject CreateNestedHitObject(HitObject hitObject)
|
|
|
|
|
{
|
|
|
|
|
switch (hitObject)
|
|
|
|
|
{
|
2020-07-21 17:22:37 +08:00
|
|
|
|
case SpinnerBonusTick bonusTick:
|
|
|
|
|
return new DrawableSpinnerBonusTick(bonusTick);
|
|
|
|
|
|
2019-12-12 20:15:16 +08:00
|
|
|
|
case SpinnerTick tick:
|
|
|
|
|
return new DrawableSpinnerTick(tick);
|
2019-08-21 02:50:49 +08:00
|
|
|
|
}
|
2019-12-12 20:15:16 +08:00
|
|
|
|
|
|
|
|
|
return base.CreateNestedHitObject(hitObject);
|
2018-11-09 12:58:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-16 01:51:33 +08:00
|
|
|
|
protected override void ApplySkin(ISkinSource skin, bool allowFallback)
|
|
|
|
|
{
|
2020-08-16 02:34:17 +08:00
|
|
|
|
base.ApplySkin(skin, allowFallback);
|
2020-08-16 01:12:06 +08:00
|
|
|
|
spinnerFrequencyModulate = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.SpinnerFrequencyModulate)?.Value ?? true;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-07-30 11:55:34 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The completion progress of this spinner from 0..1 (clamped).
|
|
|
|
|
/// </summary>
|
2020-08-05 17:44:34 +08:00
|
|
|
|
public float Progress
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-11-05 12:51:46 +08:00
|
|
|
|
if (HitObject.SpinsRequired == 0)
|
2020-08-05 17:44:34 +08:00
|
|
|
|
// some spinners are so short they can't require an integer spin count.
|
|
|
|
|
// these become implicitly hit.
|
|
|
|
|
return 1;
|
|
|
|
|
|
2023-10-16 17:25:03 +08:00
|
|
|
|
return Math.Clamp(Result.TotalRotation / 360 / HitObject.SpinsRequired, 0, 1);
|
2020-08-05 17:44:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-15 04:10:12 +08:00
|
|
|
|
protected override JudgementResult CreateResult(Judgement judgement) => new OsuSpinnerJudgementResult(HitObject, judgement);
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
if (Time.Current < HitObject.StartTime) return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-15 05:42:19 +08:00
|
|
|
|
if (Progress >= 1)
|
|
|
|
|
Result.TimeCompleted ??= Time.Current;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-11-05 12:51:46 +08:00
|
|
|
|
if (userTriggered || Time.Current < HitObject.EndTime)
|
2018-08-01 20:46:22 +08:00
|
|
|
|
return;
|
|
|
|
|
|
2020-07-21 18:03:17 +08:00
|
|
|
|
// Trigger a miss result for remaining ticks to avoid infinite gameplay.
|
2020-10-04 03:11:34 +08:00
|
|
|
|
foreach (var tick in ticks.Where(t => !t.Result.HasResult))
|
2020-07-21 18:48:44 +08:00
|
|
|
|
tick.TriggerResult(false);
|
2020-07-21 18:03:17 +08:00
|
|
|
|
|
2018-08-03 14:38:48 +08:00
|
|
|
|
ApplyResult(r =>
|
2017-02-14 17:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
if (Progress >= 1)
|
2018-08-02 19:36:38 +08:00
|
|
|
|
r.Type = HitResult.Great;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
else if (Progress > .9)
|
2020-09-29 16:16:55 +08:00
|
|
|
|
r.Type = HitResult.Ok;
|
2017-02-14 17:55:54 +08:00
|
|
|
|
else if (Progress > .75)
|
2018-08-02 19:36:38 +08:00
|
|
|
|
r.Type = HitResult.Meh;
|
2020-11-05 12:51:46 +08:00
|
|
|
|
else if (Time.Current >= HitObject.EndTime)
|
2020-10-03 04:58:10 +08:00
|
|
|
|
r.Type = r.Judgement.MinResult;
|
2018-08-01 20:46:22 +08:00
|
|
|
|
});
|
2017-02-14 17:55:54 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-18 15:16:00 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2020-07-30 18:34:59 +08:00
|
|
|
|
|
2020-03-29 13:31:03 +08:00
|
|
|
|
if (HandleUserInput)
|
2021-01-30 01:35:11 +08:00
|
|
|
|
{
|
|
|
|
|
bool isValidSpinningTime = Time.Current >= HitObject.StartTime && Time.Current <= HitObject.EndTime;
|
|
|
|
|
bool correctButtonPressed = (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
|
|
|
|
|
|
|
|
|
|
RotationTracker.Tracking = !Result.HasResult
|
|
|
|
|
&& correctButtonPressed
|
|
|
|
|
&& isValidSpinningTime;
|
|
|
|
|
}
|
2020-07-30 18:34:59 +08:00
|
|
|
|
|
2020-08-16 02:07:44 +08:00
|
|
|
|
if (spinningSample != null && spinnerFrequencyModulate)
|
2020-08-16 02:44:02 +08:00
|
|
|
|
spinningSample.Frequency.Value = spinning_sample_modulated_base_frequency + Progress;
|
2023-11-01 17:28:05 +08:00
|
|
|
|
|
|
|
|
|
// Ticks can theoretically be judged at any point in the spinner's duration.
|
2023-11-02 15:18:37 +08:00
|
|
|
|
// A tick must be alive to correctly play back samples,
|
|
|
|
|
// but for performance reasons, we only want to keep the next tick alive.
|
2023-11-01 17:28:05 +08:00
|
|
|
|
var next = NestedHitObjects.FirstOrDefault(h => !h.Judged);
|
|
|
|
|
|
|
|
|
|
// See default `LifetimeStart` as set in `DrawableSpinnerTick`.
|
|
|
|
|
if (next?.LifetimeStart == double.MaxValue)
|
|
|
|
|
next.LifetimeStart = HitObject.StartTime;
|
2017-08-18 15:16:00 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-18 18:40:20 +08:00
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-03-26 18:09:44 +08:00
|
|
|
|
if (Result.TimeStarted == null && RotationTracker.Tracking)
|
|
|
|
|
Result.TimeStarted = Time.Current;
|
2021-01-29 18:55:51 +08:00
|
|
|
|
|
2021-03-09 15:15:44 +08:00
|
|
|
|
// don't update after end time to avoid the rate display dropping during fade out.
|
|
|
|
|
// this shouldn't be limited to StartTime as it causes weirdness with the underlying calculation, which is expecting updates during that period.
|
|
|
|
|
if (Time.Current <= HitObject.EndTime)
|
2023-10-16 17:25:03 +08:00
|
|
|
|
spmCalculator.SetRotation(Result.TotalRotation);
|
2020-07-21 18:03:17 +08:00
|
|
|
|
|
|
|
|
|
updateBonusScore();
|
2017-05-18 18:40:20 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2023-12-21 13:58:23 +08:00
|
|
|
|
private static readonly int score_per_tick = new OsuScoreProcessor().GetBaseScoreForResult(new SpinnerBonusTick.OsuSpinnerBonusTickJudgement().MaxResult);
|
2021-03-13 10:22:20 +08:00
|
|
|
|
|
2020-07-21 18:03:17 +08:00
|
|
|
|
private void updateBonusScore()
|
|
|
|
|
{
|
|
|
|
|
if (ticks.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-10-16 17:25:03 +08:00
|
|
|
|
int spins = (int)(Result.TotalRotation / 360);
|
2020-07-21 18:03:17 +08:00
|
|
|
|
|
2023-10-20 14:37:51 +08:00
|
|
|
|
if (spins < completedFullSpins.Value)
|
2020-07-21 18:03:17 +08:00
|
|
|
|
{
|
2020-07-21 18:21:30 +08:00
|
|
|
|
// rewinding, silently handle
|
2023-10-20 14:37:51 +08:00
|
|
|
|
completedFullSpins.Value = spins;
|
2020-07-21 18:21:30 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2020-07-21 18:03:17 +08:00
|
|
|
|
|
2023-10-20 14:37:51 +08:00
|
|
|
|
while (completedFullSpins.Value != spins)
|
2020-07-21 18:21:30 +08:00
|
|
|
|
{
|
2020-10-04 00:08:24 +08:00
|
|
|
|
var tick = ticks.FirstOrDefault(t => !t.Result.HasResult);
|
2020-07-21 18:03:17 +08:00
|
|
|
|
|
2020-07-21 18:21:30 +08:00
|
|
|
|
// tick may be null if we've hit the spin limit.
|
2023-11-02 18:52:49 +08:00
|
|
|
|
if (tick == null)
|
|
|
|
|
{
|
|
|
|
|
// we still want to play a sound. this will probably be a new sound in the future, but for now let's continue playing the bonus sound.
|
2023-11-06 17:29:51 +08:00
|
|
|
|
// TODO: this doesn't concurrency. i can't figure out how to make it concurrency. samples are bad and need a refactor.
|
|
|
|
|
maxBonusSample.Play();
|
2023-11-02 18:52:49 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
tick.TriggerResult(true);
|
2020-07-21 18:21:30 +08:00
|
|
|
|
|
2023-10-20 14:37:51 +08:00
|
|
|
|
completedFullSpins.Value++;
|
2020-07-21 18:03:17 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-06 17:43:47 +08:00
|
|
|
|
|
|
|
|
|
public class SpinnerBonusMaxSampleInfo : HitSampleInfo
|
|
|
|
|
{
|
|
|
|
|
public override IEnumerable<string> LookupNames
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
foreach (string name in base.LookupNames)
|
|
|
|
|
yield return name;
|
|
|
|
|
|
|
|
|
|
foreach (string name in base.LookupNames)
|
|
|
|
|
yield return name.Replace("-max", string.Empty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SpinnerBonusMaxSampleInfo(HitSampleInfo sampleInfo)
|
|
|
|
|
: base("spinnerbonus-max", sampleInfo.Bank, sampleInfo.Suffix, sampleInfo.Volume)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-14 17:55:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|