Fix all 7 Cut 5d Soul findings: GL3 Sion perf >=57fps, PVS death gating, crater dedupe, hit-marker filter, loadout baseline, remote dust yaw/speed, distance-gated death trauma
This commit is contained in:
parent
323c02cf8d
commit
fcb91edb0d
16 changed files with 574 additions and 143 deletions
|
|
@ -105,6 +105,7 @@ public partial class ArenaAudioSystem : Node3D
|
|||
private readonly Dictionary<int, string> _lastContenderChassis = new();
|
||||
private readonly Dictionary<int, int> _lastContenderLoadoutVer = new();
|
||||
private readonly List<(float X, float Z, float Expiry)> _recentExplosionPoints = new(16);
|
||||
private readonly List<TerrainStampEvent> _pendingCraterStamps = new(8);
|
||||
private readonly List<LoopCandidate> _loopCandidates = new(32);
|
||||
|
||||
private bool _initialized;
|
||||
|
|
@ -294,9 +295,41 @@ public partial class ArenaAudioSystem : Node3D
|
|||
_lastContenderChassis.Clear();
|
||||
_lastContenderLoadoutVer.Clear();
|
||||
_recentExplosionPoints.Clear();
|
||||
_pendingCraterStamps.Clear();
|
||||
_overheatAlarmCooldown = 0f;
|
||||
}
|
||||
|
||||
public void ResetForSession(IClientArenaSession? session)
|
||||
{
|
||||
ClearAll();
|
||||
SeedLoadoutBaselines(session);
|
||||
}
|
||||
|
||||
private void SeedLoadoutBaselines(IClientArenaSession? session)
|
||||
{
|
||||
if (session is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var contenders = session.ViewState.Contenders;
|
||||
for (int i = 0; i < contenders.Count; i++)
|
||||
{
|
||||
var c = contenders[i];
|
||||
if (string.IsNullOrEmpty(c.Grid.Spec.Id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!_lastContenderChassis.ContainsKey(c.Id))
|
||||
{
|
||||
_lastContenderChassis[c.Id] = c.Grid.Spec.Id;
|
||||
}
|
||||
if (!_lastContenderLoadoutVer.ContainsKey(c.Id))
|
||||
{
|
||||
_lastContenderLoadoutVer[c.Id] = c.LoadoutVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetStatsForTest()
|
||||
{
|
||||
Total3DPlaysRequested = 0;
|
||||
|
|
@ -320,6 +353,32 @@ public partial class ArenaAudioSystem : Node3D
|
|||
return false;
|
||||
}
|
||||
|
||||
public int CountActiveVoicesForClip(string clipKey)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < _oneShotSlots.Length; i++)
|
||||
{
|
||||
if (_oneShotSlots[i].Active && string.Equals(_oneShotSlots[i].ClipKey, clipKey, StringComparison.Ordinal))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int CountActiveUiVoicesForClip(string clipKey)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < _uiSlots.Length; i++)
|
||||
{
|
||||
if (_uiSlots[i].Active && string.Equals(_uiSlots[i].ClipKey, clipKey, StringComparison.Ordinal))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public float? GetLastPitchForClipPrefix(string prefix)
|
||||
{
|
||||
for (int i = _oneShotSlots.Length - 1; i >= 0; i--)
|
||||
|
|
@ -353,6 +412,7 @@ public partial class ArenaAudioSystem : Node3D
|
|||
|
||||
var local = session.LocalContender;
|
||||
int localId = session.LocalContenderId;
|
||||
SeedLoadoutBaselines(session);
|
||||
UpdateLoopSlots(session, listenerPos, alpha);
|
||||
ConsumeSimEvents(session, events, listenerPos);
|
||||
ConsumeFootsteps(footsteps, localId, listenerPos);
|
||||
|
|
@ -372,6 +432,7 @@ public partial class ArenaAudioSystem : Node3D
|
|||
EnsureInitialized();
|
||||
int localId = session.LocalContenderId;
|
||||
var state = session.ViewState;
|
||||
_pendingCraterStamps.Clear();
|
||||
|
||||
for (int i = 0; i < events.Count; i++)
|
||||
{
|
||||
|
|
@ -379,6 +440,7 @@ public partial class ArenaAudioSystem : Node3D
|
|||
{
|
||||
case MatchResetEvent:
|
||||
ClearAll();
|
||||
SeedLoadoutBaselines(session);
|
||||
break;
|
||||
|
||||
case ShotFiredEvent shot:
|
||||
|
|
@ -390,29 +452,17 @@ public partial class ArenaAudioSystem : Node3D
|
|||
break;
|
||||
|
||||
case ContenderEliminatedEvent elim:
|
||||
HandleContenderEliminated(state, elim, listenerPos);
|
||||
HandleContenderEliminated(session, state, elim, listenerPos);
|
||||
break;
|
||||
|
||||
case SpectatorDestroyedEvent sdet:
|
||||
HandleSpectatorDestroyed(state, sdet, listenerPos);
|
||||
HandleSpectatorDestroyed(session, state, sdet, listenerPos);
|
||||
break;
|
||||
|
||||
case TerrainStampEvent stamp:
|
||||
if (stamp.Kind == (byte)TerrainStampKind.Crater && stamp.Radius >= 3.0f)
|
||||
{
|
||||
if (!HasRecentExplosionNear(stamp.X, stamp.Z, 12f))
|
||||
{
|
||||
float y = state.Terrain.SampleHeight(stamp.X, stamp.Z);
|
||||
PlayOneShot3D(
|
||||
"impact_explosion",
|
||||
new Vector3(stamp.X, y, stamp.Z),
|
||||
listenerPos,
|
||||
PriorityNearCombat,
|
||||
volumeDb: -4.0f,
|
||||
pitchScale: NextPitchJitter(0.94f, 1.06f),
|
||||
isLocalSource: false,
|
||||
sourceEntityId: -1);
|
||||
}
|
||||
_pendingCraterStamps.Add(stamp);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -433,10 +483,29 @@ public partial class ArenaAudioSystem : Node3D
|
|||
break;
|
||||
|
||||
case ContenderLoadoutEvent loadout:
|
||||
HandleLoadoutChanged(state, loadout, localId, listenerPos);
|
||||
HandleLoadoutChanged(session, state, loadout, localId, listenerPos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _pendingCraterStamps.Count; i++)
|
||||
{
|
||||
var stamp = _pendingCraterStamps[i];
|
||||
if (!HasRecentExplosionNear(stamp.X, stamp.Z, 12f))
|
||||
{
|
||||
float y = state.Terrain.SampleHeight(stamp.X, stamp.Z);
|
||||
PlayOneShot3D(
|
||||
"impact_explosion",
|
||||
new Vector3(stamp.X, y, stamp.Z),
|
||||
listenerPos,
|
||||
PriorityNearCombat,
|
||||
volumeDb: -4.0f,
|
||||
pitchScale: NextPitchJitter(0.94f, 1.06f),
|
||||
isLocalSource: false,
|
||||
sourceEntityId: -1);
|
||||
}
|
||||
}
|
||||
_pendingCraterStamps.Clear();
|
||||
}
|
||||
|
||||
public void ConsumeFootsteps(IReadOnlyList<FootstepPulse> footsteps, int localId, Vector3 listenerPos)
|
||||
|
|
@ -562,8 +631,9 @@ public partial class ArenaAudioSystem : Node3D
|
|||
PlayOneShot3D(clipKey, pos, listenerPos, priority, volDb, NextPitchJitter(0.92f, 1.08f), isLocalTarget, hit.TargetId);
|
||||
}
|
||||
|
||||
private void HandleContenderEliminated(MatchState state, ContenderEliminatedEvent elim, Vector3 listenerPos)
|
||||
private void HandleContenderEliminated(IClientArenaSession session, MatchState state, ContenderEliminatedEvent elim, Vector3 listenerPos)
|
||||
{
|
||||
if (elim.VictimId != session.LocalContenderId && !session.IsContenderVisible(elim.VictimId)) return;
|
||||
if (elim.VictimId < 0 || elim.VictimId >= state.Contenders.Count) return;
|
||||
var v = state.Contenders[elim.VictimId];
|
||||
Vector3 pos = new(v.X, v.Y, v.Z);
|
||||
|
|
@ -580,11 +650,29 @@ public partial class ArenaAudioSystem : Node3D
|
|||
|
||||
private static int _localKillerFallback(MatchState state, int killerId) => killerId;
|
||||
|
||||
private void HandleSpectatorDestroyed(MatchState state, SpectatorDestroyedEvent sdet, Vector3 listenerPos)
|
||||
private void HandleSpectatorDestroyed(IClientArenaSession session, MatchState state, SpectatorDestroyedEvent sdet, Vector3 listenerPos)
|
||||
{
|
||||
int sIdx = sdet.SpectatorId >= 1000 ? sdet.SpectatorId - 1000 : sdet.SpectatorId;
|
||||
if (sIdx < 0 || sIdx >= state.Spectators.Spectators.Count) return;
|
||||
var s = state.Spectators.Spectators[sIdx];
|
||||
if (!session.IsSpectatorVisible(sdet.SpectatorId)) return;
|
||||
SpectatorState? s = null;
|
||||
var specs = state.Spectators.Spectators;
|
||||
for (int i = 0; i < specs.Count; i++)
|
||||
{
|
||||
if (specs[i].Id == sdet.SpectatorId)
|
||||
{
|
||||
s = specs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s is null)
|
||||
{
|
||||
int sIdx = sdet.SpectatorId >= 1000 ? sdet.SpectatorId - 1000 : sdet.SpectatorId;
|
||||
if (sIdx >= 0 && sIdx < specs.Count)
|
||||
{
|
||||
s = specs[sIdx];
|
||||
}
|
||||
}
|
||||
if (s is null) return;
|
||||
|
||||
Vector3 pos = new(s.X, s.Y, s.Z);
|
||||
RecordExplosionPoint(s.X, s.Z);
|
||||
|
||||
|
|
@ -592,7 +680,7 @@ public partial class ArenaAudioSystem : Node3D
|
|||
PlayOneShot3D("mech_eject", pos, listenerPos, PriorityNearCombat, volumeDb: -4.5f, pitchScale: 1f, isLocalSource: false, sourceEntityId: sdet.SpectatorId);
|
||||
}
|
||||
|
||||
private void HandleLoadoutChanged(MatchState state, ContenderLoadoutEvent loadout, int localId, Vector3 listenerPos)
|
||||
private void HandleLoadoutChanged(IClientArenaSession session, MatchState state, ContenderLoadoutEvent loadout, int localId, Vector3 listenerPos)
|
||||
{
|
||||
int id = loadout.ContenderId;
|
||||
bool hadPrevChassis = _lastContenderChassis.TryGetValue(id, out string? prevChassis);
|
||||
|
|
@ -613,7 +701,7 @@ public partial class ArenaAudioSystem : Node3D
|
|||
{
|
||||
PlayUi(clipKey, volumeDb: -3.5f, pitchScale: 1f);
|
||||
}
|
||||
else if (id >= 0 && id < state.Contenders.Count)
|
||||
else if (session.IsContenderVisible(id) && id >= 0 && id < state.Contenders.Count)
|
||||
{
|
||||
var c = state.Contenders[id];
|
||||
PlayOneShot3D(clipKey, new Vector3(c.X, c.Y, c.Z), listenerPos, PriorityNearCombat, volumeDb: -5.0f, pitchScale: 1f, isLocalSource: false, sourceEntityId: id);
|
||||
|
|
|
|||
Loading…
Reference in a new issue