From 9f6f581b6439ebee7c9d96785781b0a6c4745067 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 16 Mar 2017 17:24:41 +0900 Subject: [PATCH] Pass through method instead of instantiating object. --- osu.Game.Modes.Osu/Objects/OsuHitObject.cs | 8 ++++--- osu.Game.Modes.Osu/Objects/Slider.cs | 11 ++++----- osu.Game/Modes/Objects/HitObject.cs | 7 ++++-- osu.Game/Modes/Objects/HitObjectDefaults.cs | 25 --------------------- osu.Game/Modes/UI/HitRenderer.cs | 9 +------- osu.Game/osu.Game.csproj | 1 - 6 files changed, 17 insertions(+), 44 deletions(-) delete mode 100644 osu.Game/Modes/Objects/HitObjectDefaults.cs diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs index 42313a7e71..9648ba9c87 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs @@ -6,6 +6,8 @@ using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Objects.Types; using OpenTK.Graphics; +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; namespace osu.Game.Modes.Osu.Objects { @@ -66,11 +68,11 @@ public OsuScoreResult ScoreResultForOffset(double offset) return OsuScoreResult.Miss; } - public override void ApplyDefaults(HitObjectDefaults defaults) + public override void ApplyDefaults(TimingInfo timing, BaseDifficulty difficulty) { - base.ApplyDefaults(defaults); + base.ApplyDefaults(timing, difficulty); - Scale = (1.0f - 0.7f * (defaults.Difficulty.CircleSize - 5) / 5) / 2; + Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; } } } diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 35883ff131..baa6e9442d 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using osu.Game.Modes.Objects; +using osu.Game.Database; namespace osu.Game.Modes.Osu.Objects { @@ -46,17 +47,17 @@ public override int StackHeight public double Velocity; public double TickDistance; - public override void ApplyDefaults(HitObjectDefaults defaults) + public override void ApplyDefaults(TimingInfo timing, BaseDifficulty difficulty) { - base.ApplyDefaults(defaults); + base.ApplyDefaults(timing, difficulty); ControlPoint overridePoint; - ControlPoint timingPoint = defaults.Timing.TimingPointAt(StartTime, out overridePoint); + ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint); var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1; - var baseVelocity = 100 * defaults.Difficulty.SliderMultiplier / velocityAdjustment; + var baseVelocity = 100 * difficulty.SliderMultiplier / velocityAdjustment; Velocity = baseVelocity / timingPoint.BeatLength; - TickDistance = baseVelocity / defaults.Difficulty.SliderTickRate; + TickDistance = baseVelocity / difficulty.SliderTickRate; } public IEnumerable Ticks diff --git a/osu.Game/Modes/Objects/HitObject.cs b/osu.Game/Modes/Objects/HitObject.cs index 94e1f88b7f..7fe30ff1ac 100644 --- a/osu.Game/Modes/Objects/HitObject.cs +++ b/osu.Game/Modes/Objects/HitObject.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Beatmaps.Samples; +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; namespace osu.Game.Modes.Objects { @@ -26,7 +28,8 @@ public class HitObject /// /// Applies default values to this HitObject. /// - /// The default values to apply. - public virtual void ApplyDefaults(HitObjectDefaults defaults) { } + /// The difficulty settings to use. + /// The timing settings to use. + public virtual void ApplyDefaults(TimingInfo timing, BaseDifficulty difficulty) { } } } diff --git a/osu.Game/Modes/Objects/HitObjectDefaults.cs b/osu.Game/Modes/Objects/HitObjectDefaults.cs deleted file mode 100644 index 7a0d64391e..0000000000 --- a/osu.Game/Modes/Objects/HitObjectDefaults.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Beatmaps; -using osu.Game.Beatmaps.Timing; -using osu.Game.Database; - -namespace osu.Game.Modes.Objects -{ - /// - /// A set of default Beatmap values for HitObjects to consume. - /// - public class HitObjectDefaults - { - /// - /// The Beatmap timing. - /// - public TimingInfo Timing; - - /// - /// The Beatmap difficulty. - /// - public BaseDifficulty Difficulty; - } -} diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index da47bf2c67..6707f7aa15 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -9,7 +9,6 @@ using osu.Game.Modes.Mods; using osu.Game.Modes.Objects; using osu.Game.Modes.Objects.Drawables; -using osu.Game.Modes.Objects.Types; using osu.Game.Screens.Play; using System; using System.Collections.Generic; @@ -96,14 +95,8 @@ protected HitRenderer(WorkingBeatmap beatmap) Beatmap = converter.Convert(beatmap.Beatmap); // Apply defaults - HitObjectDefaults defaults = new HitObjectDefaults - { - Timing = Beatmap.TimingInfo, - Difficulty = Beatmap.BeatmapInfo.BaseDifficulty - }; - foreach (var h in Beatmap.HitObjects) - h.ApplyDefaults(defaults); + h.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.BaseDifficulty); // Post-process the beatmap processor.PostProcess(Beatmap); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d7370078ed..80d5c906e0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -100,7 +100,6 @@ -