Pass through method instead of instantiating object.

This commit is contained in:
smoogipooo 2017-03-16 17:24:41 +09:00
parent 0c47638820
commit 9f6f581b64
6 changed files with 17 additions and 44 deletions

View File

@ -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;
}
}
}

View File

@ -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<SliderTick> Ticks

View File

@ -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
/// <summary>
/// Applies default values to this HitObject.
/// </summary>
/// <param name="defaults">The default values to apply.</param>
public virtual void ApplyDefaults(HitObjectDefaults defaults) { }
/// <param name="difficulty">The difficulty settings to use.</param>
/// <param name="timing">The timing settings to use.</param>
public virtual void ApplyDefaults(TimingInfo timing, BaseDifficulty difficulty) { }
}
}

View File

@ -1,25 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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
{
/// <summary>
/// A set of default Beatmap values for HitObjects to consume.
/// </summary>
public class HitObjectDefaults
{
/// <summary>
/// The Beatmap timing.
/// </summary>
public TimingInfo Timing;
/// <summary>
/// The Beatmap difficulty.
/// </summary>
public BaseDifficulty Difficulty;
}
}

View File

@ -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);

View File

@ -100,7 +100,6 @@
<Compile Include="Modes\Objects\BezierApproximator.cs" />
<Compile Include="Modes\Objects\CircularArcApproximator.cs" />
<Compile Include="Modes\Objects\CurvedHitObject.cs" />
<Compile Include="Modes\Objects\HitObjectDefaults.cs" />
<Compile Include="Modes\Objects\Legacy\LegacyHit.cs" />
<Compile Include="Modes\Objects\LegacyHitObjectParser.cs" />
<Compile Include="Modes\Objects\Legacy\LegacyHold.cs" />