mirror of
https://github.com/osukey/osukey.git
synced 2025-05-31 10:27:26 +09:00
Move taiko Type
to Hit
and localise all bind handling
This commit is contained in:
parent
912748b428
commit
cbad7bb7f0
@ -1,10 +1,59 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// 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
|
namespace osu.Game.Rulesets.Taiko.Objects
|
||||||
{
|
{
|
||||||
public class Hit : TaikoStrongableHitObject
|
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
|
||||||
|
{
|
||||||
|
get => TypeBindable.Value;
|
||||||
|
set => TypeBindable.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Hit()
|
||||||
|
{
|
||||||
|
TypeBindable.BindValueChanged(_ => updateSamplesFromType());
|
||||||
|
SamplesBindable.BindCollectionChanged((_, __) => updateTypeFromSamples());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTypeFromSamples()
|
||||||
|
{
|
||||||
|
Type = getRimSamples().Any() ? HitType.Rim : HitType.Centre;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an array of any samples which would cause this object to be a "rim" type hit.
|
||||||
|
/// </summary>
|
||||||
|
private HitSampleInfo[] getRimSamples() => Samples.Where(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE).ToArray();
|
||||||
|
|
||||||
|
private void updateSamplesFromType()
|
||||||
|
{
|
||||||
|
var rimSamples = getRimSamples();
|
||||||
|
|
||||||
|
bool isRimType = Type == HitType.Rim;
|
||||||
|
|
||||||
|
if (isRimType != rimSamples.Any())
|
||||||
|
{
|
||||||
|
if (isRimType)
|
||||||
|
Samples.Add(new HitSampleInfo(HitSampleInfo.HIT_CLAP));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var sample in rimSamples)
|
||||||
|
Samples.Remove(sample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit { StartTime = startTime };
|
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit { StartTime = startTime };
|
||||||
|
|
||||||
public class StrongNestedHit : StrongNestedHitObject
|
public class StrongNestedHit : StrongNestedHitObject
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Game.Audio;
|
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -14,17 +11,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
{
|
{
|
||||||
public abstract class TaikoHitObject : HitObject
|
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>
|
/// <summary>
|
||||||
/// Default size of a drawable taiko hit object.
|
/// Default size of a drawable taiko hit object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,39 +19,5 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
public override Judgement CreateJudgement() => new TaikoJudgement();
|
public override Judgement CreateJudgement() => new TaikoJudgement();
|
||||||
|
|
||||||
protected override HitWindows CreateHitWindows() => new TaikoHitWindows();
|
protected override HitWindows CreateHitWindows() => new TaikoHitWindows();
|
||||||
|
|
||||||
protected TaikoHitObject()
|
|
||||||
{
|
|
||||||
SamplesBindable.BindCollectionChanged((_, __) => UpdateTypeFromSamples());
|
|
||||||
TypeBindable.BindValueChanged(_ => updateSamplesFromType());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSamplesFromType()
|
|
||||||
{
|
|
||||||
var rimSamples = getRimSamples();
|
|
||||||
|
|
||||||
bool isRimType = Type == HitType.Rim;
|
|
||||||
|
|
||||||
if (isRimType != rimSamples.Any())
|
|
||||||
{
|
|
||||||
if (isRimType)
|
|
||||||
Samples.Add(new HitSampleInfo(HitSampleInfo.HIT_CLAP));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var sample in rimSamples)
|
|
||||||
Samples.Remove(sample);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void UpdateTypeFromSamples()
|
|
||||||
{
|
|
||||||
Type = getRimSamples().Any() ? HitType.Rim : HitType.Centre;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns an array of any samples which would cause this object to be a "rim" type hit.
|
|
||||||
/// </summary>
|
|
||||||
private HitSampleInfo[] getRimSamples() => Samples.Where(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE).ToArray();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,11 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
|||||||
protected TaikoStrongableHitObject()
|
protected TaikoStrongableHitObject()
|
||||||
{
|
{
|
||||||
IsStrongBindable.BindValueChanged(_ => updateSamplesFromType());
|
IsStrongBindable.BindValueChanged(_ => updateSamplesFromType());
|
||||||
|
SamplesBindable.BindCollectionChanged((_, __) => updateTypeFromSamples());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateTypeFromSamples()
|
private void updateTypeFromSamples()
|
||||||
{
|
{
|
||||||
base.UpdateTypeFromSamples();
|
|
||||||
|
|
||||||
IsStrong = getStrongSamples().Any();
|
IsStrong = getStrongSamples().Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user