3D 리플레이: 1인칭 · 자유시점 카메라, 선수가 들고 있는 총 (변환기 equips · 이름표 · 킬 피드)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-17 19:48:48 +09:00
parent 6d71abaabd
commit d87f4ade27
5 changed files with 324 additions and 25 deletions

View File

@@ -30,6 +30,10 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
private readonly Dictionary<uint, int> _closedAt = [];
private readonly Dictionary<uint, uint> _objectOwner = [];
private readonly Dictionary<string, int> _stats = [];
// 들고 있는 것: 장비 액터 → 이름 (총은 파서 목록 이름, 나머지는 클래스 이름), 캐릭터별 바뀐 시각
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 = [];
private static int Ms(float seconds) => (int)Math.Round(seconds * 1000.0);
private static int R(double v) => (int)Math.Round(v);
@@ -53,6 +57,8 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
if (s.ArchetypePath is { } arch)
{
_archetypeByActor[s.ActorNetGuid] = arch;
if (ValorantEquippableResolver.TryResolve(s.ActorNetGuid, [s.ReplicationClassPath, s.ArchetypePath, s.ActorPath], out var eq) && eq.Name is { } en)
_equipName[s.ActorNetGuid] = en;
Count("spawn " + Simplify(arch));
if (s.Location is { } loc && ObjectClass().IsMatch(arch) && !arch.EndsWith("_PC_C"))
_objects.Add((Ms(s.TimeSeconds), s.ActorNetGuid, Simplify(arch), R(loc.X), R(loc.Y), R(loc.Z)));
@@ -83,6 +89,15 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
case BombGameStateDescriptor gs when gs.HasDecoded(nameof(BombGameStateDescriptor.MatchID)) && !string.IsNullOrEmpty(gs.MatchID):
_matchId ??= gs.MatchID;
break;
case AresInventoryDescriptor inv:
{
var ch = inv.HasDecoded(nameof(AresInventoryDescriptor.Character)) && inv.Character.NetGuid != 0 ? inv.Character.NetGuid : x.ActorNetGuid;
uint eq = 0;
if (inv.HasDecoded(nameof(AresInventoryDescriptor.CurrentEquippable))) eq = inv.CurrentEquippable.NetGuid;
else if (inv.HasDecoded(nameof(AresInventoryDescriptor.NewCurrentEquippable))) eq = inv.NewCurrentEquippable.NetGuid;
if (eq != 0) _equips.Add((Ms(x.TimeSeconds), ch, eq));
break;
}
case BombPlayerStateDescriptor ps:
if (ps.HasDecoded(nameof(BombPlayerStateDescriptor.Subject)) && !string.IsNullOrEmpty(ps.Subject))
_subjectByState[x.ActorNetGuid] = ps.Subject!;
@@ -105,6 +120,8 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
private void OnRpc(RpcReceived r)
{
var t = Ms(r.TimeSeconds);
if (ValorantEquippableResolver.TryResolveClassNetCachePath(r.ClassPath, r.ActorNetGuid, out var eq) && eq.Name is { } en)
_equipName.TryAdd(r.ActorNetGuid, en);
switch (r.Payload)
{
case ClientGamePhaseBeginParameters p:
@@ -152,6 +169,11 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
pitch = Math.Atan2(v.Z, Math.Sqrt(v.X * v.X + v.Y * v.Y)) * 180 / Math.PI;
}
_shots.Add((Ms(s.TimeSeconds), state, R(loc.X), R(loc.Y), R(loc.Z), R(yaw), R(pitch)));
if (shot.Equippable is { Name: { } en })
{
_shotEquips.Add((Ms(s.TimeSeconds), state, en));
if (shot.Equippable.NetGuid != 0) _equipName.TryAdd(shot.Equippable.NetGuid, en);
}
}
private static string Simplify(string archetype) => archetype.StartsWith("Default__") ? archetype[9..] : archetype;
@@ -245,8 +267,41 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
objects.Add([o.T0, _closedAt.TryGetValue(o.Actor, out var t1) && t1 >= o.T0 ? t1 : -1, k, o.X, o.Y, o.Z, owner]);
}
// 들고 있는 것: [t, 선수, 종류]. 같은 선수가 같은 것을 다시 들면 뺀다
var equipKinds = new List<string>();
var equipKindIndex = new Dictionary<string, int>();
int EquipKind(string name)
{
if (!equipKindIndex.TryGetValue(name, out var k)) { k = equipKinds.Count; equipKinds.Add(name); equipKindIndex[name] = k; }
return k;
}
var equipRows = new List<(int T, int P, string Name)>();
foreach (var (t, ch, eq) in _equips)
{
if (!indexByCharacter.TryGetValue(ch, out var pi)) continue;
var name = _equipName.TryGetValue(eq, out var n) ? n : _archetypeByActor.TryGetValue(eq, out var a) ? Simplify(a) : null;
if (name != null) equipRows.Add((t, pi, name));
}
// 인벤토리 기록이 없는 선수는 사격 무기로 채운다
var hasInv = equipRows.Select(e => e.P).ToHashSet();
foreach (var (t, st, name) in _shotEquips)
{
var pi = PlayerOfState(st);
if (pi >= 0 && !hasInv.Contains(pi)) equipRows.Add((t, pi, name));
}
var equips = new List<int[]>();
var lastByPlayer = new Dictionary<int, string>();
foreach (var e in equipRows.OrderBy(e => e.T))
{
if (lastByPlayer.TryGetValue(e.P, out var last) && last == e.Name) continue;
lastByPlayer[e.P] = e.Name;
equips.Add([e.T, e.P, EquipKind(e.Name)]);
}
return new ReplayFile
{
Equips = equips,
EquipKinds = equipKinds,
MatchId = _matchId,
Map = _map,
Build = branch?.Replace("++Ares-Core+", ""),

View File

@@ -26,6 +26,9 @@ public sealed class ReplayFile
/// 스킬 · 설치물 [t0, t1, kind 번호, x, y, z, player] (t1 = 사라진 시각, 모르면 -1)
public List<int[]> Objects { get; set; } = [];
public List<string> ObjectKinds { get; set; } = [];
/// 들고 있는 것이 바뀐 시각 [t, player, kind 번호]. 총은 영어 이름(Vandal 등), 칼은 Melee, 스파이크는 Spike, 스킬은 클래스 이름
public List<int[]> Equips { get; set; } = [];
public List<string> EquipKinds { get; set; } = [];
}
public sealed class ReplayPlayer