1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:42:56 +08:00

Remove IUpdatableByHitObject completely

This commit is contained in:
tgi74000 2018-08-05 09:52:19 +02:00
parent 07d6a75e23
commit b1d1a2400b
3 changed files with 29 additions and 55 deletions

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Input.States; using osu.Framework.Input.States;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -14,29 +13,31 @@ using static osu.Game.Input.Handlers.ReplayInputHandler;
namespace osu.Game.Rulesets.Osu.Mods namespace osu.Game.Rulesets.Osu.Mods
{ {
public class OsuModRelax : ModRelax, IApplicableFailOverride, IUpdatableByHitObject, IUpdatableByPlayfield public class OsuModRelax : ModRelax, IApplicableFailOverride, IUpdatableByPlayfield
{ {
public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things."; public override string Description => @"You don't need to click. Give your clicking/tapping fingers a break from the heat of things.";
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray(); public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
public bool AllowFail => false; public bool AllowFail => false;
private bool hitStill; public void Update(Playfield playfield)
private bool hitOnce;
public void Update(DrawableHitObject drawable)
{ {
bool hitStill = false;
bool hitOnce = false;
const float relax_leniency = 3; const float relax_leniency = 3;
foreach (var drawable in playfield.HitObjects.Objects)
{
if (!(drawable is DrawableOsuHitObject osuHit)) if (!(drawable is DrawableOsuHitObject osuHit))
return; continue;
double time = osuHit.Clock.CurrentTime; double time = osuHit.Clock.CurrentTime;
if (time >= osuHit.HitObject.StartTime - relax_leniency) if (osuHit.IsAlive && time >= osuHit.HitObject.StartTime - relax_leniency)
{ {
if (osuHit.HitObject is IHasEndTime hasEnd && time > hasEnd.EndTime || osuHit.IsHit) if (osuHit.HitObject is IHasEndTime hasEnd && time > hasEnd.EndTime || osuHit.IsHit)
return; continue;
hitStill |= osuHit is DrawableSlider slider && (slider.Ball.IsHovered || osuHit.IsHovered) || osuHit is DrawableSpinner; hitStill |= osuHit is DrawableSlider slider && (slider.Ball.IsHovered || osuHit.IsHovered) || osuHit is DrawableSpinner;
@ -44,18 +45,13 @@ namespace osu.Game.Rulesets.Osu.Mods
} }
} }
public void Update(Playfield playfield) var osuHitSample = playfield.HitObjects.Objects.First(d => d is DrawableOsuHitObject) as DrawableOsuHitObject;
{
var osuHit = playfield.HitObjects.Objects.First(d => d is DrawableOsuHitObject) as DrawableOsuHitObject;
if (hitOnce) if (hitOnce)
{ {
hit(osuHit, false); hit(osuHitSample, false);
hit(osuHit, true); hit(osuHitSample, true);
} }
hit(osuHit, hitStill); hit(osuHitSample, hitStill);
hitOnce = false;
hitStill = false;
} }
private bool wasHit; private bool wasHit;

View File

@ -1,12 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Mods
{
public interface IUpdatableByHitObject : IApplicableMod
{
void Update(DrawableHitObject drawable);
}
}

View File

@ -13,8 +13,6 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Objects.Drawables namespace osu.Game.Rulesets.Objects.Drawables
{ {
@ -43,8 +41,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
public IReadOnlyList<Judgement> Judgements => judgements; public IReadOnlyList<Judgement> Judgements => judgements;
private readonly List<Judgement> judgements = new List<Judgement>(); private readonly List<Judgement> judgements = new List<Judgement>();
private WorkingBeatmap beatmap;
/// <summary> /// <summary>
/// Whether a visible judgement should be displayed when this representation is hit. /// Whether a visible judgement should be displayed when this representation is hit.
/// </summary> /// </summary>
@ -84,9 +80,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindableBeatmap bBeatmap) private void load()
{ {
beatmap = bBeatmap.Value;
var samples = GetSamples().ToArray(); var samples = GetSamples().ToArray();
if (samples.Any()) if (samples.Any())
@ -137,11 +132,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
{ {
base.Update(); base.Update();
if(beatmap != null)
foreach (var mod in beatmap.Mods.Value)
if (mod is IUpdatableByHitObject updatable)
updatable.Update(this);
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
while (judgements.Count > 0) while (judgements.Count > 0)