mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Apply same logic changes to IsStrong
status
This commit is contained in:
parent
a5ca736e37
commit
7bc8a4bb5f
@ -78,15 +78,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
validActionPressed = pressHandledThisFrame = false;
|
||||
}
|
||||
|
||||
private HitSampleInfo[] getRimSamples() => HitObject.Samples.Where(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE).ToArray();
|
||||
|
||||
protected override void LoadSamples()
|
||||
{
|
||||
base.LoadSamples();
|
||||
|
||||
type.Value = getRimSamples().Any() ? HitType.Rim : HitType.Centre;
|
||||
}
|
||||
|
||||
private void updateActionsFromType()
|
||||
{
|
||||
HitActions =
|
||||
|
@ -1,11 +1,9 @@
|
||||
// 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 System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osuTK;
|
||||
@ -29,14 +27,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
protected override void OnApply()
|
||||
{
|
||||
isStrong.BindTo(HitObject.IsStrongBindable);
|
||||
isStrong.BindValueChanged(_ =>
|
||||
{
|
||||
// will overwrite samples, should only be called on subsequent changes
|
||||
// after the initial application.
|
||||
updateSamplesFromStrong();
|
||||
|
||||
RecreatePieces();
|
||||
});
|
||||
// this doesn't need to be run inline as RecreatePieces is called by the base call below.
|
||||
isStrong.BindValueChanged(_ => RecreatePieces());
|
||||
|
||||
base.OnApply();
|
||||
}
|
||||
@ -50,30 +42,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
isStrong.UnbindEvents();
|
||||
}
|
||||
|
||||
private HitSampleInfo[] getStrongSamples() => HitObject.Samples.Where(s => s.Name == HitSampleInfo.HIT_FINISH).ToArray();
|
||||
|
||||
protected override void LoadSamples()
|
||||
{
|
||||
base.LoadSamples();
|
||||
isStrong.Value = getStrongSamples().Any();
|
||||
}
|
||||
|
||||
private void updateSamplesFromStrong()
|
||||
{
|
||||
var strongSamples = getStrongSamples();
|
||||
|
||||
if (isStrong.Value != strongSamples.Any())
|
||||
{
|
||||
if (isStrong.Value)
|
||||
HitObject.Samples.Add(new HitSampleInfo(HitSampleInfo.HIT_FINISH));
|
||||
else
|
||||
{
|
||||
foreach (var sample in strongSamples)
|
||||
HitObject.Samples.Remove(sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RecreatePieces()
|
||||
{
|
||||
base.RecreatePieces();
|
||||
|
@ -1,8 +1,10 @@
|
||||
// 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 System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects
|
||||
@ -31,8 +33,30 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
public bool IsStrong
|
||||
{
|
||||
get => IsStrongBindable.Value;
|
||||
set => IsStrongBindable.Value = value;
|
||||
set
|
||||
{
|
||||
IsStrongBindable.Value = value;
|
||||
updateSamplesFromStrong();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSamplesFromStrong()
|
||||
{
|
||||
var strongSamples = getStrongSamples();
|
||||
|
||||
if (IsStrongBindable.Value != strongSamples.Any())
|
||||
{
|
||||
if (IsStrongBindable.Value)
|
||||
Samples.Add(new HitSampleInfo(HitSampleInfo.HIT_FINISH));
|
||||
else
|
||||
{
|
||||
foreach (var sample in strongSamples)
|
||||
Samples.Remove(sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private HitSampleInfo[] getStrongSamples() => Samples.Where(s => s.Name == HitSampleInfo.HIT_FINISH).ToArray();
|
||||
|
||||
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user