1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 22:33:05 +08:00

Run all type and sample mutations through standardising methods

This commit is contained in:
Dean Herbert 2021-05-23 20:22:48 +09:00
parent d0d90d77c9
commit dc322d1c63
3 changed files with 49 additions and 20 deletions

View File

@ -2,30 +2,23 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Bindables;
using osu.Game.Audio;
namespace osu.Game.Rulesets.Taiko.Objects
{
public class Hit : TaikoStrongableHitObject
{
public readonly Bindable<HitType> TypeBindable = new Bindable<HitType>();
/// <summary>
/// The <see cref="HitType"/> that actuates this <see cref="Hit"/>.
/// </summary>
public HitType Type
protected override void UpdateTypeFromSamples()
{
get => TypeBindable.Value;
set
{
TypeBindable.Value = value;
updateSamplesFromType();
}
base.UpdateTypeFromSamples();
Type = getRimSamples().Any() ? HitType.Rim : HitType.Centre;
}
private void updateSamplesFromType()
protected override void UpdateSamplesFromType()
{
base.UpdateSamplesFromType();
var rimSamples = getRimSamples();
bool isRimType = Type == HitType.Rim;

View File

@ -1,6 +1,7 @@
// 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.
using osu.Framework.Bindables;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
@ -11,6 +12,17 @@ namespace osu.Game.Rulesets.Taiko.Objects
{
public abstract class TaikoHitObject : HitObject
{
public readonly Bindable<HitType> TypeBindable = new Bindable<HitType>();
/// <summary>
/// The <see cref="HitType"/> that actuates this <see cref="Hit"/>.
/// </summary>
public HitType Type
{
get => TypeBindable.Value;
set => TypeBindable.Value = value;
}
/// <summary>
/// Default size of a drawable taiko hit object.
/// </summary>
@ -19,5 +31,19 @@ namespace osu.Game.Rulesets.Taiko.Objects
public override Judgement CreateJudgement() => new TaikoJudgement();
protected override HitWindows CreateHitWindows() => new TaikoHitWindows();
protected TaikoHitObject()
{
SamplesBindable.BindCollectionChanged((_, __) => UpdateTypeFromSamples());
TypeBindable.BindValueChanged(_ => UpdateSamplesFromType());
}
protected virtual void UpdateSamplesFromType()
{
}
protected virtual void UpdateTypeFromSamples()
{
}
}
}

View File

@ -33,15 +33,25 @@ namespace osu.Game.Rulesets.Taiko.Objects
public bool IsStrong
{
get => IsStrongBindable.Value;
set
{
IsStrongBindable.Value = value;
updateSamplesFromStrong();
}
set => IsStrongBindable.Value = value;
}
private void updateSamplesFromStrong()
protected TaikoStrongableHitObject()
{
IsStrongBindable.BindValueChanged(_ => UpdateSamplesFromType());
}
protected override void UpdateTypeFromSamples()
{
base.UpdateTypeFromSamples();
IsStrong = getStrongSamples().Any();
}
protected override void UpdateSamplesFromType()
{
base.UpdateSamplesFromType();
var strongSamples = getStrongSamples();
if (IsStrongBindable.Value != strongSamples.Any())