mirror of
https://github.com/osukey/osukey.git
synced 2025-06-08 04:48:04 +09:00
Merge pull request #495 from smoogipooo/better_hitobject_defaults
Better hitobject defaults
This commit is contained in:
commit
163a21a7bf
@ -8,11 +8,6 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
|||||||
{
|
{
|
||||||
internal class OsuBeatmapProcessor : IBeatmapProcessor<OsuHitObject>
|
internal class OsuBeatmapProcessor : IBeatmapProcessor<OsuHitObject>
|
||||||
{
|
{
|
||||||
public void SetDefaults(OsuHitObject hitObject, Beatmap<OsuHitObject> beatmap)
|
|
||||||
{
|
|
||||||
hitObject.SetDefaultsFromBeatmap(beatmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PostProcess(Beatmap<OsuHitObject> beatmap)
|
public void PostProcess(Beatmap<OsuHitObject> beatmap)
|
||||||
{
|
{
|
||||||
if (beatmap.ComboColors.Count == 0)
|
if (beatmap.ComboColors.Count == 0)
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects
|
namespace osu.Game.Modes.Osu.Objects
|
||||||
{
|
{
|
||||||
@ -67,9 +68,11 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
return OsuScoreResult.Miss;
|
return OsuScoreResult.Miss;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
Scale = (1.0f - 0.7f * (beatmap.BeatmapInfo.Difficulty.CircleSize - 5) / 5) / 2;
|
base.ApplyDefaults(timing, difficulty);
|
||||||
|
|
||||||
|
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Beatmaps.Samples;
|
using osu.Game.Beatmaps.Samples;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects
|
namespace osu.Game.Modes.Osu.Objects
|
||||||
{
|
{
|
||||||
@ -47,19 +47,17 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
public double Velocity;
|
public double Velocity;
|
||||||
public double TickDistance;
|
public double TickDistance;
|
||||||
|
|
||||||
public override void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
base.SetDefaultsFromBeatmap(beatmap);
|
base.ApplyDefaults(timing, difficulty);
|
||||||
|
|
||||||
var baseDifficulty = beatmap.BeatmapInfo.Difficulty;
|
|
||||||
|
|
||||||
ControlPoint overridePoint;
|
ControlPoint overridePoint;
|
||||||
ControlPoint timingPoint = beatmap.TimingInfo.TimingPointAt(StartTime, out overridePoint);
|
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
|
||||||
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
|
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
|
||||||
var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment;
|
var baseVelocity = 100 * difficulty.SliderMultiplier / velocityAdjustment;
|
||||||
|
|
||||||
Velocity = baseVelocity / timingPoint.BeatLength;
|
Velocity = baseVelocity / timingPoint.BeatLength;
|
||||||
TickDistance = baseVelocity / baseDifficulty.SliderTickRate;
|
TickDistance = baseVelocity / difficulty.SliderTickRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<SliderTick> Ticks
|
public IEnumerable<SliderTick> Ticks
|
||||||
|
@ -8,17 +8,10 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes a post-converted Beatmap.
|
/// Processes a post-converted Beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of HitObject contained in the Beatmap.</typeparam>
|
/// <typeparam name="TObject">The type of HitObject contained in the Beatmap.</typeparam>
|
||||||
public interface IBeatmapProcessor<T>
|
public interface IBeatmapProcessor<TObject>
|
||||||
where T : HitObject
|
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>
|
/// <summary>
|
||||||
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
|
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
|
||||||
/// <para>
|
/// <para>
|
||||||
@ -26,6 +19,6 @@ namespace osu.Game.Beatmaps
|
|||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The Beatmap to process.</param>
|
/// <param name="beatmap">The Beatmap to process.</param>
|
||||||
void PostProcess(Beatmap<T> beatmap);
|
void PostProcess(Beatmap<TObject> beatmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps.Samples;
|
using osu.Game.Beatmaps.Samples;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Objects
|
namespace osu.Game.Modes.Objects
|
||||||
{
|
{
|
||||||
@ -22,5 +24,12 @@ namespace osu.Game.Modes.Objects
|
|||||||
/// The sample to be played when this HitObject is hit.
|
/// The sample to be played when this HitObject is hit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HitSampleInfo Sample { get; set; }
|
public HitSampleInfo Sample { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies default values to this HitObject.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="difficulty">The difficulty settings to use.</param>
|
||||||
|
/// <param name="timing">The timing settings to use.</param>
|
||||||
|
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,16 +89,26 @@ namespace osu.Game.Modes.UI
|
|||||||
{
|
{
|
||||||
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap.");
|
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;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
IBeatmapConverter<TObject> converter = CreateBeatmapConverter();
|
||||||
|
IBeatmapProcessor<TObject> processor = CreateBeatmapProcessor();
|
||||||
|
|
||||||
|
// Convert the beatmap
|
||||||
|
Beatmap = converter.Convert(beatmap.Beatmap);
|
||||||
|
|
||||||
|
// Apply defaults
|
||||||
|
foreach (var h in Beatmap.HitObjects)
|
||||||
|
h.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty);
|
||||||
|
|
||||||
|
// 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>
|
/// <summary>
|
||||||
/// Applies the active mods to this HitRenderer.
|
/// Applies the active mods to this HitRenderer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user