From b1d1a2400bfc49c47649ea497cb0437a0467abcd Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Sun, 5 Aug 2018 09:52:19 +0200 Subject: [PATCH] Remove IUpdatableByHitObject completely --- osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs | 60 +++++++++---------- .../Rulesets/Mods/IUpdatableByHitObject.cs | 12 ---- .../Objects/Drawables/DrawableHitObject.cs | 12 +--- 3 files changed, 29 insertions(+), 55 deletions(-) delete mode 100644 osu.Game/Rulesets/Mods/IUpdatableByHitObject.cs diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs index 296a9f9631..e10ddfaec1 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Input.States; using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.UI; @@ -14,48 +13,45 @@ using static osu.Game.Input.Handlers.ReplayInputHandler; 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 Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray(); public bool AllowFail => false; - private bool hitStill; - private bool hitOnce; - - public void Update(DrawableHitObject drawable) - { - const float relax_leniency = 3; - - if (!(drawable is DrawableOsuHitObject osuHit)) - return; - - double time = osuHit.Clock.CurrentTime; - - if (time >= osuHit.HitObject.StartTime - relax_leniency) - { - if (osuHit.HitObject is IHasEndTime hasEnd && time > hasEnd.EndTime || osuHit.IsHit) - return; - - hitStill |= osuHit is DrawableSlider slider && (slider.Ball.IsHovered || osuHit.IsHovered) || osuHit is DrawableSpinner; - - hitOnce |= osuHit is DrawableHitCircle && osuHit.IsHovered; - } - } - public void Update(Playfield playfield) { - var osuHit = playfield.HitObjects.Objects.First(d => d is DrawableOsuHitObject) as DrawableOsuHitObject; + bool hitStill = false; + bool hitOnce = false; + + const float relax_leniency = 3; + + foreach (var drawable in playfield.HitObjects.Objects) + { + if (!(drawable is DrawableOsuHitObject osuHit)) + continue; + + double time = osuHit.Clock.CurrentTime; + + if (osuHit.IsAlive && time >= osuHit.HitObject.StartTime - relax_leniency) + { + if (osuHit.HitObject is IHasEndTime hasEnd && time > hasEnd.EndTime || osuHit.IsHit) + continue; + + hitStill |= osuHit is DrawableSlider slider && (slider.Ball.IsHovered || osuHit.IsHovered) || osuHit is DrawableSpinner; + + hitOnce |= osuHit is DrawableHitCircle && osuHit.IsHovered; + } + } + + var osuHitSample = playfield.HitObjects.Objects.First(d => d is DrawableOsuHitObject) as DrawableOsuHitObject; if (hitOnce) { - hit(osuHit, false); - hit(osuHit, true); + hit(osuHitSample, false); + hit(osuHitSample, true); } - hit(osuHit, hitStill); - - hitOnce = false; - hitStill = false; + hit(osuHitSample, hitStill); } private bool wasHit; diff --git a/osu.Game/Rulesets/Mods/IUpdatableByHitObject.cs b/osu.Game/Rulesets/Mods/IUpdatableByHitObject.cs deleted file mode 100644 index 6dd900e9c5..0000000000 --- a/osu.Game/Rulesets/Mods/IUpdatableByHitObject.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// 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); - } -} diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index f060f7382c..a22aaa784f 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -13,8 +13,6 @@ using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; using OpenTK.Graphics; -using osu.Game.Beatmaps; -using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Objects.Drawables { @@ -43,8 +41,6 @@ namespace osu.Game.Rulesets.Objects.Drawables public IReadOnlyList Judgements => judgements; private readonly List judgements = new List(); - private WorkingBeatmap beatmap; - /// /// Whether a visible judgement should be displayed when this representation is hit. /// @@ -84,9 +80,8 @@ namespace osu.Game.Rulesets.Objects.Drawables } [BackgroundDependencyLoader] - private void load(IBindableBeatmap bBeatmap) + private void load() { - beatmap = bBeatmap.Value; var samples = GetSamples().ToArray(); if (samples.Any()) @@ -137,11 +132,6 @@ namespace osu.Game.Rulesets.Objects.Drawables { 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; while (judgements.Count > 0)