From efd4d12c217fc43c1a679892aa847d41e150229c Mon Sep 17 00:00:00 2001 From: maarvin Date: Mon, 9 Feb 2026 04:39:27 +0100 Subject: [PATCH] Add info about damage dealt to ranked play user state (#36627) Adds a `DamageInfo` property to `RankedPlayDamageInfo` to be used by the result screen. The issue this is trying to solve is that once the result screen initializes, the HP value of each player has already been updated in the room state so the previous values are no longer accessible. Doing this without the state exposing it would require some kinda setup to keep the previous MatchState's HP values around on the client which would introduce a lot of unnecessary weirdness. --- .../RankedPlay/RankedPlayDamageInfo.cs | 56 +++++++++++++++++++ .../RankedPlay/RankedPlayUserInfo.cs | 9 +++ 2 files changed, 65 insertions(+) create mode 100644 osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayDamageInfo.cs diff --git a/osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayDamageInfo.cs b/osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayDamageInfo.cs new file mode 100644 index 0000000000..66ae9fc9a6 --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayDamageInfo.cs @@ -0,0 +1,56 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay +{ + [Serializable] + [MessagePackObject] + public class RankedPlayDamageInfo : IEquatable + { + /// + /// Total amount of damage dealt. + /// + [Key(0)] + public required int Damage { get; init; } + + /// + /// Damage dealt before multipliers are applied. + /// + [Key(1)] + public required int RawDamage { get; init; } + + /// + /// Life before damage was applied. + /// + [Key(2)] + public required int OldLife { get; init; } + + /// + /// Life after damage was applied. + /// + [Key(3)] + public required int NewLife { get; init; } + + public bool Equals(RankedPlayDamageInfo? other) + { + if (other is null) return false; + if (ReferenceEquals(this, other)) return true; + + return Damage == other.Damage && RawDamage == other.RawDamage && OldLife == other.OldLife && NewLife == other.NewLife; + } + + public override bool Equals(object? obj) + { + if (obj is null) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + + return Equals((RankedPlayDamageInfo)obj); + } + + public override int GetHashCode() => HashCode.Combine(Damage, RawDamage, OldLife, NewLife); + } +} diff --git a/osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayUserInfo.cs b/osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayUserInfo.cs index a5064676c6..a370ef194c 100644 --- a/osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayUserInfo.cs +++ b/osu.Game/Online/Multiplayer/MatchTypes/RankedPlay/RankedPlayUserInfo.cs @@ -34,5 +34,14 @@ namespace osu.Game.Online.Multiplayer.MatchTypes.RankedPlay /// [Key(3)] public int RatingAfter { get; set; } + + /// + /// Information about damage being applied in the current stage. + /// + /// + /// This value is only expected to be populated during the stage. + /// + [Key(4)] + public RankedPlayDamageInfo? DamageInfo; } }