osu/osu.Game/Rulesets/Scoring/HitEvent.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.9 KiB
C#
Raw Normal View History

2020-06-19 10:58:35 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 07:37:17 +00:00
#nullable disable
2020-06-19 10:58:35 +00:00
using JetBrains.Annotations;
using osu.Game.Rulesets.Objects;
using osuTK;
namespace osu.Game.Rulesets.Scoring
{
2020-06-19 12:41:48 +00:00
/// <summary>
/// A <see cref="HitEvent"/> generated by the <see cref="ScoreProcessor"/> containing extra statistics around a <see cref="HitResult"/>.
/// </summary>
2020-06-19 10:58:35 +00:00
public readonly struct HitEvent
{
/// <summary>
/// The time offset from the end of <see cref="HitObject"/> at which the event occurred.
/// </summary>
public readonly double TimeOffset;
/// <summary>
/// The true gameplay rate at the time of the event.
/// </summary>
public readonly double? GameplayRate;
2020-06-19 10:58:35 +00:00
/// <summary>
/// The hit result.
/// </summary>
public readonly HitResult Result;
/// <summary>
/// The <see cref="HitObject"/> on which the result occurred.
/// </summary>
public readonly HitObject HitObject;
/// <summary>
/// The <see cref="HitObject"/> occurring prior to <see cref="HitObject"/>.
/// </summary>
[CanBeNull]
public readonly HitObject LastHitObject;
/// <summary>
2020-06-22 10:04:51 +00:00
/// A position, if available, at the time of the event.
2020-06-19 10:58:35 +00:00
/// </summary>
[CanBeNull]
2020-06-22 10:04:51 +00:00
public readonly Vector2? Position;
2020-06-19 10:58:35 +00:00
2020-06-19 12:41:48 +00:00
/// <summary>
/// Creates a new <see cref="HitEvent"/>.
/// </summary>
/// <param name="timeOffset">The time offset from the end of <paramref name="hitObject"/> at which the event occurs.</param>
/// <param name="result">The <see cref="HitResult"/>.</param>
/// <param name="gameplayRate">The true gameplay rate at the time of the event.</param>
2020-06-19 12:41:48 +00:00
/// <param name="hitObject">The <see cref="HitObject"/> that triggered the event.</param>
/// <param name="lastHitObject">The previous <see cref="HitObject"/>.</param>
2020-06-22 10:04:51 +00:00
/// <param name="position">A position corresponding to the event.</param>
public HitEvent(double timeOffset, double? gameplayRate, HitResult result, HitObject hitObject, [CanBeNull] HitObject lastHitObject, [CanBeNull] Vector2? position)
2020-06-19 10:58:35 +00:00
{
TimeOffset = timeOffset;
GameplayRate = gameplayRate;
2020-06-19 10:58:35 +00:00
Result = result;
HitObject = hitObject;
LastHitObject = lastHitObject;
2020-06-22 10:04:51 +00:00
Position = position;
2020-06-19 10:58:35 +00:00
}
2020-06-19 12:41:48 +00:00
/// <summary>
/// Creates a new <see cref="HitEvent"/> with an optional positional offset.
/// </summary>
/// <param name="positionOffset">The positional offset.</param>
/// <returns>The new <see cref="HitEvent"/>.</returns>
public HitEvent With(Vector2? positionOffset) => new HitEvent(TimeOffset, GameplayRate, Result, HitObject, LastHitObject, positionOffset);
2020-06-19 10:58:35 +00:00
}
}