1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 15:27:24 +08:00

Remove CentreHit/RimHit hitobject abstraction

This commit is contained in:
smoogipoo 2020-03-23 12:08:15 +09:00
parent 2e9fc80a72
commit 5106d275ca
12 changed files with 50 additions and 65 deletions

View File

@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Mods
[TestCase(false)]
[TestCase(true)]
public void TestHit(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new CentreHit { StartTime = 1000 }), shouldMiss);
public void TestHit(bool shouldMiss) => CreateHitObjectTest(new HitObjectTestData(new Hit { StartTime = 1000, Type = HitType.Centre }), shouldMiss);
[TestCase(false)]
[TestCase(true)]

View File

@ -27,8 +27,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
{
StartTime = hitObject.StartTime,
EndTime = hitObject.GetEndTime(),
IsRim = hitObject is RimHit,
IsCentre = hitObject is CentreHit,
IsRim = (hitObject as Hit)?.Type == HitType.Rim,
IsCentre = (hitObject as Hit)?.Type == HitType.Centre,
IsDrumRoll = hitObject is DrumRoll,
IsSwell = hitObject is Swell,
IsStrong = ((TaikoHitObject)hitObject).IsStrong

View File

@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
{
HitObjects = new List<HitObject> { new CentreHit() },
HitObjects = new List<HitObject> { new Hit { Type = HitType.Centre } },
BeatmapInfo = new BeatmapInfo
{
BaseDifficulty = new BeatmapDifficulty(),

View File

@ -124,24 +124,13 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
bool isRim = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
strong = currentSamples.Any(s => s.Name == HitSampleInfo.HIT_FINISH);
if (isRim)
{
yield return new RimHit
yield return new Hit
{
StartTime = j,
Type = isRim ? HitType.Rim : HitType.Centre,
Samples = currentSamples,
IsStrong = strong
};
}
else
{
yield return new CentreHit
{
StartTime = j,
Samples = currentSamples,
IsStrong = strong
};
}
i = (i + 1) % allSamples.Count;
}
@ -180,24 +169,13 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
{
bool isRim = samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE);
if (isRim)
{
yield return new RimHit
yield return new Hit
{
StartTime = obj.StartTime,
Type = isRim ? HitType.Rim : HitType.Centre,
Samples = obj.Samples,
IsStrong = strong
};
}
else
{
yield return new CentreHit
{
StartTime = obj.StartTime,
Samples = obj.Samples,
IsStrong = strong
};
}
break;
}

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate)
: base(hitObject, lastObject, clockRate)
{
HasTypeChange = lastObject is RimHit != hitObject is RimHit;
HasTypeChange = (lastObject as Hit)?.Type != (hitObject as Hit)?.Type;
}
}
}

View File

@ -1,9 +0,0 @@
// 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.
namespace osu.Game.Rulesets.Taiko.Objects
{
public class CentreHit : Hit
{
}
}

View File

@ -5,5 +5,9 @@ namespace osu.Game.Rulesets.Taiko.Objects
{
public class Hit : TaikoHitObject
{
/// <summary>
/// The <see cref="HitType"/> that actuates this <see cref="Hit"/>.
/// </summary>
public HitType Type { get; set; }
}
}

View File

@ -0,0 +1,21 @@
// 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.
namespace osu.Game.Rulesets.Taiko.Objects
{
/// <summary>
/// The type of a <see cref="Hit"/>.
/// </summary>
public enum HitType
{
/// <summary>
/// A <see cref="Hit"/> that can be hit by the centre portion of the drum.
/// </summary>
Centre,
/// <summary>
/// A <see cref="Hit"/> that can be hit by the rim portion of the drum.
/// </summary>
Rim
}
}

View File

@ -1,9 +0,0 @@
// 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.
namespace osu.Game.Rulesets.Taiko.Objects
{
public class RimHit : Hit
{
}
}

View File

@ -97,7 +97,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
{
TaikoAction[] actions;
if (hit is CentreHit)
if (hit.Type == HitType.Centre)
{
actions = h.IsStrong
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }

View File

@ -48,11 +48,11 @@ namespace osu.Game.Rulesets.Taiko.UI
{
switch (h)
{
case CentreHit centreHit:
return new DrawableCentreHit(centreHit);
case RimHit rimHit:
return new DrawableRimHit(rimHit);
case Hit hit:
if (hit.Type == HitType.Centre)
return new DrawableCentreHit(hit);
else
return new DrawableRimHit(hit);
case DrumRoll drumRoll:
return new DrawableDrumRoll(drumRoll);

View File

@ -14,9 +14,9 @@ using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects;
using osuTK;
using osuTK.Graphics;
@ -245,7 +245,7 @@ namespace osu.Game.Rulesets.Taiko.UI
if (!result.IsHit)
break;
bool isRim = judgedObject.HitObject is RimHit;
bool isRim = (judgedObject.HitObject as Hit)?.Type == HitType.Rim;
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));