mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Better hit object defaults setting.
This commit is contained in:
@ -8,11 +8,6 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
||||
{
|
||||
internal class OsuBeatmapProcessor : IBeatmapProcessor<OsuHitObject>
|
||||
{
|
||||
public void SetDefaults(OsuHitObject hitObject, Beatmap<OsuHitObject> beatmap)
|
||||
{
|
||||
hitObject.SetDefaultsFromBeatmap(beatmap);
|
||||
}
|
||||
|
||||
public void PostProcess(Beatmap<OsuHitObject> beatmap)
|
||||
{
|
||||
if (beatmap.ComboColors.Count == 0)
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using osu.Game.Modes.Objects;
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
using OpenTK.Graphics;
|
||||
@ -67,9 +66,11 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
return OsuScoreResult.Miss;
|
||||
}
|
||||
|
||||
public virtual void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
||||
public override void ApplyDefaults(HitObjectDefaults defaults)
|
||||
{
|
||||
Scale = (1.0f - 0.7f * (beatmap.BeatmapInfo.Difficulty.CircleSize - 5) / 5) / 2;
|
||||
base.ApplyDefaults(defaults);
|
||||
|
||||
Scale = (1.0f - 0.7f * (defaults.Difficulty.CircleSize - 5) / 5) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
@ -47,19 +46,17 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
public double Velocity;
|
||||
public double TickDistance;
|
||||
|
||||
public override void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
||||
public override void ApplyDefaults(HitObjectDefaults defaults)
|
||||
{
|
||||
base.SetDefaultsFromBeatmap(beatmap);
|
||||
|
||||
var baseDifficulty = beatmap.BeatmapInfo.Difficulty;
|
||||
base.ApplyDefaults(defaults);
|
||||
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = beatmap.TimingInfo.TimingPointAt(StartTime, out overridePoint);
|
||||
ControlPoint timingPoint = defaults.Timing.TimingPointAt(StartTime, out overridePoint);
|
||||
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
|
||||
var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment;
|
||||
var baseVelocity = 100 * defaults.Difficulty.SliderMultiplier / velocityAdjustment;
|
||||
|
||||
Velocity = baseVelocity / timingPoint.BeatLength;
|
||||
TickDistance = baseVelocity / baseDifficulty.SliderTickRate;
|
||||
TickDistance = baseVelocity / defaults.Difficulty.SliderTickRate;
|
||||
}
|
||||
|
||||
public IEnumerable<SliderTick> Ticks
|
||||
|
@ -8,17 +8,10 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// Processes a post-converted Beatmap.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public interface IBeatmapProcessor<T>
|
||||
where T : HitObject
|
||||
/// <typeparam name="TObject">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public interface IBeatmapProcessor<TObject>
|
||||
where TObject : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets default values for a HitObject.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The HitObject to set default values for.</param>
|
||||
/// <param name="beatmap">The Beatmap to extract the default values from.</param>
|
||||
void SetDefaults(T hitObject, Beatmap<T> beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
|
||||
/// <para>
|
||||
@ -26,6 +19,6 @@ namespace osu.Game.Beatmaps
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The Beatmap to process.</param>
|
||||
void PostProcess(Beatmap<T> beatmap);
|
||||
void PostProcess(Beatmap<TObject> beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,11 @@ namespace osu.Game.Modes.Objects
|
||||
/// The sample to be played when this HitObject is hit.
|
||||
/// </summary>
|
||||
public HitSampleInfo Sample { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Applies default values to this HitObject.
|
||||
/// </summary>
|
||||
/// <param name="defaults">The default values to apply.</param>
|
||||
public virtual void ApplyDefaults(HitObjectDefaults defaults) { }
|
||||
}
|
||||
}
|
||||
|
25
osu.Game/Modes/Objects/HitObjectDefaults.cs
Normal file
25
osu.Game/Modes/Objects/HitObjectDefaults.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ using osu.Game.Modes.Judgements;
|
||||
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;
|
||||
@ -86,16 +87,32 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap.");
|
||||
|
||||
// Convert + process the beatmap
|
||||
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
|
||||
Beatmap.HitObjects.ForEach(h => CreateBeatmapProcessor().SetDefaults(h, Beatmap));
|
||||
CreateBeatmapProcessor().PostProcess(Beatmap);
|
||||
|
||||
applyMods(beatmap.Mods.Value);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
IBeatmapConverter<TObject> converter = CreateBeatmapConverter();
|
||||
IBeatmapProcessor<TObject> processor = CreateBeatmapProcessor();
|
||||
|
||||
// Convert the 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);
|
||||
|
||||
// Post-process the beatmap
|
||||
processor.PostProcess(Beatmap);
|
||||
|
||||
// Add mods, should always be the last thing applied to give full control to mods
|
||||
applyMods(beatmap.Mods.Value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Applies the active mods to this HitRenderer.
|
||||
/// </summary>
|
||||
|
@ -100,6 +100,7 @@
|
||||
<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" />
|
||||
|
Reference in New Issue
Block a user