3D 리플레이 자동 시점 · Tab 점수판: 카메라 "자동"(교전 직전에 이긴 선수 1인칭, 직전 우리 팀 콜이 있으면 그 말부터 · 설치/해체 · 혼자 남은 선수 · 교전이 없으면 살아 있는 선수가 다 보이게 위에서) · Tab 을 누르고 있으면 게임처럼 팀 점수 · 궁극기 · K/D/A · 주무기 · 크레딧 · 변환기 scoreboard (크레딧 · 궁 점수 · 킬/데스/어시 · 전투 점수, BasicCombatStats · PlayerScore 하위 객체 읽기) · self-test · 테스트
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ using Replay.Models.Unreal;
|
||||
using Replay.Valorant.Combat;
|
||||
using Replay.Valorant.Descriptors;
|
||||
using Replay.Valorant.Descriptors.Agents;
|
||||
using Replay.Valorant.Economy;
|
||||
using Replay.Valorant.Events.Combat;
|
||||
using Replay.Valorant.Events.Movement;
|
||||
using Replay.Valorant.Flashes.Descriptors;
|
||||
@@ -50,6 +51,55 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
||||
private readonly Dictionary<uint, string> _equipName = [];
|
||||
private readonly List<(int T, uint Character, uint Equip)> _equips = [];
|
||||
private readonly List<(int T, uint State, string Name)> _shotEquips = [];
|
||||
// 점수판 (게임 Tab): PlayerState 액터별 크레딧 · 궁극기 점수 · 킬/데스/어시 · 전투 점수가 바뀐 시각
|
||||
private readonly List<(int T, uint State, int Field, int Value)> _board = [];
|
||||
|
||||
/// 점수판 열 (scoreboard 행의 2번째부터): 크레딧 · 궁극기 점수 · 킬 · 데스 · 어시스트 · 전투 점수
|
||||
public const int BoardMoney = 0, BoardUlt = 1, BoardKills = 2, BoardDeaths = 3, BoardAssists = 4, BoardScore = 5, BoardFields = 6;
|
||||
public const string CombatStatsPath = "/Script/ShooterGame.BasicCombatStatsComponent";
|
||||
public const string ScorePath = "/Script/ShooterGame.PlayerScoreComponent";
|
||||
private static readonly Dictionary<string, int> CombatFields = new()
|
||||
{
|
||||
["AggregateKills"] = BoardKills, ["AggregateDeaths"] = BoardDeaths, ["AggregateAssists"] = BoardAssists, ["Score"] = BoardScore,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 점수판 행: 선수 값이 바뀔 때마다 그 선수 전체 값 [t, 선수, 크레딧, 궁 점수, 킬, 데스, 어시, 전투 점수] (아직 안 온 값 -1).
|
||||
/// 같은 시각에 나눠 온 것은 한 줄로, 값이 그대로면 줄을 넣지 않는다. 선수를 모르는 기록(-1)은 건너뛴다
|
||||
/// </summary>
|
||||
public static List<int[]> BuildScoreboard(IEnumerable<(int T, int Player, int Field, int Value)> rows)
|
||||
{
|
||||
var board = new List<int[]>();
|
||||
var now = new Dictionary<int, int[]>();
|
||||
foreach (var (t, pi, field, value) in rows.OrderBy(b => b.T))
|
||||
{
|
||||
if (pi < 0) continue;
|
||||
if (!now.TryGetValue(pi, out var cur)) now[pi] = cur = Enumerable.Repeat(-1, BoardFields).ToArray();
|
||||
if (cur[field] == value) continue;
|
||||
cur[field] = value;
|
||||
var row = new int[2 + BoardFields];
|
||||
row[0] = t;
|
||||
row[1] = pi;
|
||||
Array.Copy(cur, 0, row, 2, BoardFields);
|
||||
if (board.Count > 0 && board[^1][0] == t && board[^1][1] == pi) board[^1] = row;
|
||||
else board.Add(row);
|
||||
}
|
||||
return board;
|
||||
}
|
||||
|
||||
/// <summary>파서 기본 목록에 없는 점수판 필드 (킬 · 데스 · 어시 · 전투 점수). 이름으로 찾으므로 패치로 번호가 밀려도 된다</summary>
|
||||
public static DescriptorCatalog Catalog()
|
||||
{
|
||||
var c = ValorantDescriptors.CreateCatalog();
|
||||
// PlayerState 의 하위 객체 이름 → 클래스 (파서 목록에 없다)
|
||||
c.AddSubobjectClassPath("BasicCombatStatsComponent", CombatStatsPath);
|
||||
c.AddSubobjectClassPath("PlayerScoreComponent", ScorePath);
|
||||
FieldDescriptor F(string name) => new() { ExportName = name, PropertyName = name, Categories = ExportCategory.GameState, Decoder = Replay.Unreal.Parsing.PrimitiveDecoders.Int32 };
|
||||
c.Add(new ExportGroupDescriptor(CombatStatsPath, ExportCategory.GameState, ExportGroupKind.Component,
|
||||
fields: [F("AggregateKills"), F("AggregateDeaths"), F("AggregateAssists")]));
|
||||
c.Add(new ExportGroupDescriptor(ScorePath, ExportCategory.GameState, ExportGroupKind.Component, fields: [F("Score")]));
|
||||
return c;
|
||||
}
|
||||
|
||||
private static int Ms(float seconds) => (int)Math.Round(seconds * 1000.0);
|
||||
private static int R(double v) => (int)Math.Round(v);
|
||||
@@ -123,7 +173,12 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
||||
if (eq != 0) _equips.Add((Ms(x.TimeSeconds), ch, eq));
|
||||
break;
|
||||
}
|
||||
case MoneyManagementComponentDescriptor mm when mm.HasDecoded(nameof(MoneyManagementComponentDescriptor.Money)) && mm.Money is { } money:
|
||||
_board.Add((Ms(x.TimeSeconds), x.ActorNetGuid, BoardMoney, money));
|
||||
break;
|
||||
case BombPlayerStateDescriptor ps:
|
||||
if (ps.HasDecoded(nameof(BombPlayerStateDescriptor.NumUltimatePoints)))
|
||||
_board.Add((Ms(x.TimeSeconds), x.ActorNetGuid, BoardUlt, ps.NumUltimatePoints));
|
||||
if (ps.HasDecoded(nameof(BombPlayerStateDescriptor.Subject)) && !string.IsNullOrEmpty(ps.Subject))
|
||||
_subjectByState[x.ActorNetGuid] = ps.Subject!;
|
||||
if (ps.HasDecoded(nameof(BombPlayerStateDescriptor.SpawnedCharacter)) && ps.SpawnedCharacter.NetGuid != 0)
|
||||
@@ -142,9 +197,15 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
||||
private void OnFields(ExportGroupReceived x)
|
||||
{
|
||||
var a = x.ActorNetGuid;
|
||||
var board = x.ExportGroupPath is CombatStatsPath or ScorePath;
|
||||
foreach (var f in x.DiagnosticFields)
|
||||
{
|
||||
var v = f.Value;
|
||||
if (board && v.Kind == DecodedFieldValueKind.Int32 && f.Name is { } fn && CombatFields.TryGetValue(fn, out var bf))
|
||||
{
|
||||
_board.Add((Ms(x.TimeSeconds), a, bf, v.Int32Value));
|
||||
continue;
|
||||
}
|
||||
switch (v.Kind)
|
||||
{
|
||||
case DecodedFieldValueKind.ObjectReference when v.ObjectReferenceValue.NetGuid != 0:
|
||||
@@ -490,8 +551,11 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
||||
}
|
||||
|
||||
|
||||
var scoreboard = BuildScoreboard(_board.Select(b => (b.T, PlayerOfState(b.State), b.Field, b.Value)));
|
||||
|
||||
return new ReplayFile
|
||||
{
|
||||
Scoreboard = scoreboard,
|
||||
Equips = equips,
|
||||
EquipKinds = equipKinds,
|
||||
MatchId = _matchId,
|
||||
|
||||
@@ -44,6 +44,8 @@ public sealed class ReplayFile
|
||||
/// 들고 있는 것이 바뀐 시각 [t, player, kind 번호]. 총은 영어 이름(Vandal 등), 칼은 Melee, 스파이크는 Spike, 스킬은 클래스 이름
|
||||
public List<int[]> Equips { get; set; } = [];
|
||||
public List<string> EquipKinds { get; set; } = [];
|
||||
/// 점수판 (게임 Tab 화면): 선수 값이 바뀔 때마다 [t, player, 크레딧, 궁극기 점수, 킬, 데스, 어시스트, 전투 점수] (아직 모르는 값 -1, 변환기 1.10.0~)
|
||||
public List<int[]> Scoreboard { get; set; } = [];
|
||||
}
|
||||
|
||||
public sealed class ReplayPlayer
|
||||
|
||||
@@ -52,6 +52,21 @@ public static class Program
|
||||
var cs = Crosshair.Snapshot(0, new Dictionary<string, object> { ["p.cb"] = 0, ["p.cg"] = 0, ["a.useCustom"] = true, ["a.ur"] = 0 });
|
||||
if (cs.Primary.Color != "#ff0000") fails.Add($"주 조준점 색: {cs.Primary.Color} (기대 #ff0000)");
|
||||
if (cs.Ads.Color != "#00ffff") fails.Add($"정조준 사용자 지정 색: {cs.Ads.Color} (기대 #00ffff)");
|
||||
// 점수판: 같은 시각 값은 한 줄 · 값이 그대로면 줄 없음 · 모르는 선수 건너뜀 · 시간 순
|
||||
var sb = Collector.BuildScoreboard([
|
||||
(2000, 0, Collector.BoardUlt, 3), (1000, 0, Collector.BoardMoney, 800), (1000, 0, Collector.BoardKills, 0),
|
||||
(1500, 0, Collector.BoardMoney, 800), (1500, -1, Collector.BoardMoney, 100), (2000, 1, Collector.BoardMoney, 4000),
|
||||
]);
|
||||
Eq("점수판 줄 수", sb.Count, 3);
|
||||
if (sb.Count == 3)
|
||||
{
|
||||
Eq("첫 줄 크레딧", sb[0][2 + Collector.BoardMoney], 800);
|
||||
Eq("첫 줄 킬", sb[0][2 + Collector.BoardKills], 0);
|
||||
Eq("첫 줄 궁(아직 모름)", sb[0][2 + Collector.BoardUlt], -1);
|
||||
Eq("둘째 줄 궁", sb[1][2 + Collector.BoardUlt], 3);
|
||||
Eq("둘째 줄 크레딧 유지", sb[1][2 + Collector.BoardMoney], 800);
|
||||
Eq("셋째 줄 선수", sb[2][1], 1);
|
||||
}
|
||||
foreach (var f in fails) Console.Error.WriteLine("FAIL " + f);
|
||||
Console.WriteLine(JsonSerializer.Serialize(new { ok = fails.Count == 0, selfTest = true, failed = fails.Count }));
|
||||
return fails.Count == 0 ? 0 : 1;
|
||||
@@ -79,7 +94,7 @@ public static class Program
|
||||
var enricher = new ValorantEventEnricher(collector);
|
||||
// 진단 필드: 스킬 주인(Instigator) · 투사체 비행(ReplicatedMovement) · 무기 상태(CurrentState)를 페이로드 종류와 상관없이 읽는다
|
||||
var profile = new ParseProfile { EnabledCategories = ExportCategory.All, CaptureDiagnosticFields = true };
|
||||
var result = ValorantReplayReader.CreateDefault(null, enricher, profile).Read(archive);
|
||||
var result = new ValorantReplayReader(null, enricher, profile, Collector.Catalog()).Read(archive);
|
||||
enricher.Complete();
|
||||
var info = result.Metadata.ReplayInfo;
|
||||
if (args[1] == "--fields")
|
||||
@@ -127,6 +142,7 @@ public static class Program
|
||||
players = replay.Players.Count,
|
||||
rounds = replay.Rounds.Count,
|
||||
kills = replay.Kills.Count,
|
||||
scoreboard = replay.Scoreboard.Count,
|
||||
crosshairs,
|
||||
elapsedMs = sw.ElapsedMilliseconds,
|
||||
status = result.Status.ToString(),
|
||||
|
||||
Reference in New Issue
Block a user