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, string> _lastContenderChassis = new();
|
||||||
private readonly Dictionary<int, int> _lastContenderLoadoutVer = new();
|
private readonly Dictionary<int, int> _lastContenderLoadoutVer = new();
|
||||||
private readonly List<(float X, float Z, float Expiry)> _recentExplosionPoints = new(16);
|
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 readonly List<LoopCandidate> _loopCandidates = new(32);
|
||||||
|
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
|
|
@ -294,9 +295,41 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
_lastContenderChassis.Clear();
|
_lastContenderChassis.Clear();
|
||||||
_lastContenderLoadoutVer.Clear();
|
_lastContenderLoadoutVer.Clear();
|
||||||
_recentExplosionPoints.Clear();
|
_recentExplosionPoints.Clear();
|
||||||
|
_pendingCraterStamps.Clear();
|
||||||
_overheatAlarmCooldown = 0f;
|
_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()
|
public void ResetStatsForTest()
|
||||||
{
|
{
|
||||||
Total3DPlaysRequested = 0;
|
Total3DPlaysRequested = 0;
|
||||||
|
|
@ -320,6 +353,32 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
return false;
|
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)
|
public float? GetLastPitchForClipPrefix(string prefix)
|
||||||
{
|
{
|
||||||
for (int i = _oneShotSlots.Length - 1; i >= 0; i--)
|
for (int i = _oneShotSlots.Length - 1; i >= 0; i--)
|
||||||
|
|
@ -353,6 +412,7 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
|
|
||||||
var local = session.LocalContender;
|
var local = session.LocalContender;
|
||||||
int localId = session.LocalContenderId;
|
int localId = session.LocalContenderId;
|
||||||
|
SeedLoadoutBaselines(session);
|
||||||
UpdateLoopSlots(session, listenerPos, alpha);
|
UpdateLoopSlots(session, listenerPos, alpha);
|
||||||
ConsumeSimEvents(session, events, listenerPos);
|
ConsumeSimEvents(session, events, listenerPos);
|
||||||
ConsumeFootsteps(footsteps, localId, listenerPos);
|
ConsumeFootsteps(footsteps, localId, listenerPos);
|
||||||
|
|
@ -372,6 +432,7 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
EnsureInitialized();
|
EnsureInitialized();
|
||||||
int localId = session.LocalContenderId;
|
int localId = session.LocalContenderId;
|
||||||
var state = session.ViewState;
|
var state = session.ViewState;
|
||||||
|
_pendingCraterStamps.Clear();
|
||||||
|
|
||||||
for (int i = 0; i < events.Count; i++)
|
for (int i = 0; i < events.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -379,6 +440,7 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
{
|
{
|
||||||
case MatchResetEvent:
|
case MatchResetEvent:
|
||||||
ClearAll();
|
ClearAll();
|
||||||
|
SeedLoadoutBaselines(session);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShotFiredEvent shot:
|
case ShotFiredEvent shot:
|
||||||
|
|
@ -390,29 +452,17 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContenderEliminatedEvent elim:
|
case ContenderEliminatedEvent elim:
|
||||||
HandleContenderEliminated(state, elim, listenerPos);
|
HandleContenderEliminated(session, state, elim, listenerPos);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpectatorDestroyedEvent sdet:
|
case SpectatorDestroyedEvent sdet:
|
||||||
HandleSpectatorDestroyed(state, sdet, listenerPos);
|
HandleSpectatorDestroyed(session, state, sdet, listenerPos);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TerrainStampEvent stamp:
|
case TerrainStampEvent stamp:
|
||||||
if (stamp.Kind == (byte)TerrainStampKind.Crater && stamp.Radius >= 3.0f)
|
if (stamp.Kind == (byte)TerrainStampKind.Crater && stamp.Radius >= 3.0f)
|
||||||
{
|
{
|
||||||
if (!HasRecentExplosionNear(stamp.X, stamp.Z, 12f))
|
_pendingCraterStamps.Add(stamp);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -433,10 +483,29 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContenderLoadoutEvent loadout:
|
case ContenderLoadoutEvent loadout:
|
||||||
HandleLoadoutChanged(state, loadout, localId, listenerPos);
|
HandleLoadoutChanged(session, state, loadout, localId, listenerPos);
|
||||||
break;
|
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)
|
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);
|
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;
|
if (elim.VictimId < 0 || elim.VictimId >= state.Contenders.Count) return;
|
||||||
var v = state.Contenders[elim.VictimId];
|
var v = state.Contenders[elim.VictimId];
|
||||||
Vector3 pos = new(v.X, v.Y, v.Z);
|
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 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 (!session.IsSpectatorVisible(sdet.SpectatorId)) return;
|
||||||
if (sIdx < 0 || sIdx >= state.Spectators.Spectators.Count) return;
|
SpectatorState? s = null;
|
||||||
var s = state.Spectators.Spectators[sIdx];
|
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);
|
Vector3 pos = new(s.X, s.Y, s.Z);
|
||||||
RecordExplosionPoint(s.X, 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);
|
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;
|
int id = loadout.ContenderId;
|
||||||
bool hadPrevChassis = _lastContenderChassis.TryGetValue(id, out string? prevChassis);
|
bool hadPrevChassis = _lastContenderChassis.TryGetValue(id, out string? prevChassis);
|
||||||
|
|
@ -613,7 +701,7 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
{
|
{
|
||||||
PlayUi(clipKey, volumeDb: -3.5f, pitchScale: 1f);
|
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];
|
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);
|
PlayOneShot3D(clipKey, new Vector3(c.X, c.Y, c.Z), listenerPos, PriorityNearCombat, volumeDb: -5.0f, pitchScale: 1f, isLocalSource: false, sourceEntityId: id);
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ public partial class ArenaRenderer : Node3D
|
||||||
|
|
||||||
var state = session.ViewState;
|
var state = session.ViewState;
|
||||||
_pomDecals.ConsumeEvents(session, events, stepDt, ResolveEntityVisual);
|
_pomDecals.ConsumeEvents(session, events, stepDt, ResolveEntityVisual);
|
||||||
_particles.ConsumeEvents(events, state, camPos, hasCam, sampleGroundTint);
|
_particles.ConsumeEvents(session, events, camPos, hasCam, sampleGroundTint);
|
||||||
|
|
||||||
for (int i = 0; i < footsteps.Count; i++)
|
for (int i = 0; i < footsteps.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -595,7 +595,7 @@ public partial class ArenaRenderer : Node3D
|
||||||
vis.Visual.Root.Transform = new Transform3D(new Basis(q), pos);
|
vis.Visual.Root.Transform = new Transform3D(new Basis(q), pos);
|
||||||
|
|
||||||
float distSq = hasCam ? pos.DistanceSquaredTo(camPos) : 0f;
|
float distSq = hasCam ? pos.DistanceSquaredTo(camPos) : 0f;
|
||||||
bool castShadows = !hasCam || c.Id == localId || distSq <= 75f * 75f;
|
bool castShadows = !hasCam || c.Id == localId || distSq <= 55f * 55f;
|
||||||
bool useStaticLod = hasCam && c.Id != localId && !vis.Visual.HasAnyStrippedCell &&
|
bool useStaticLod = hasCam && c.Id != localId && !vis.Visual.HasAnyStrippedCell &&
|
||||||
(vis.Visual.IsStaticLod ? distSq > 64f * 64f : distSq > 68f * 68f);
|
(vis.Visual.IsStaticLod ? distSq > 64f * 64f : distSq > 68f * 68f);
|
||||||
vis.Visual.SetLodState(useStaticLod, castShadows);
|
vis.Visual.SetLodState(useStaticLod, castShadows);
|
||||||
|
|
@ -698,7 +698,7 @@ public partial class ArenaRenderer : Node3D
|
||||||
if (hasCam)
|
if (hasCam)
|
||||||
{
|
{
|
||||||
float distSq = specPos.DistanceSquaredTo(camPos);
|
float distSq = specPos.DistanceSquaredTo(camPos);
|
||||||
castShadows = distSq <= 70f * 70f;
|
castShadows = distSq <= 55f * 55f;
|
||||||
if (!vis.Visual.HasAnyStrippedCell)
|
if (!vis.Visual.HasAnyStrippedCell)
|
||||||
{
|
{
|
||||||
useStaticLod = vis.Visual.IsStaticLod ? distSq > 50f * 50f : distSq > 55f * 55f;
|
useStaticLod = vis.Visual.IsStaticLod ? distSq > 50f * 50f : distSq > 55f * 55f;
|
||||||
|
|
@ -1207,7 +1207,7 @@ public partial class ArenaRenderer : Node3D
|
||||||
float nextDust = _tireDustNextTime.GetValueOrDefault(key);
|
float nextDust = _tireDustNextTime.GetValueOrDefault(key);
|
||||||
if (_vfxClock >= nextDust)
|
if (_vfxClock >= nextDust)
|
||||||
{
|
{
|
||||||
_tireDustNextTime[key] = _vfxClock + 0.07f; // ~14 Hz
|
_tireDustNextTime[key] = _vfxClock + 0.09f; // ~11 Hz
|
||||||
float sinY = MathF.Sin(c.Yaw);
|
float sinY = MathF.Sin(c.Yaw);
|
||||||
float cosY = MathF.Cos(c.Yaw);
|
float cosY = MathF.Cos(c.Yaw);
|
||||||
Vector3 rearPos = pos - new Vector3(sinY, 0f, cosY) * (c.Grid.Spec.HalfLength * 0.72f);
|
Vector3 rearPos = pos - new Vector3(sinY, 0f, cosY) * (c.Grid.Spec.HalfLength * 0.72f);
|
||||||
|
|
@ -1228,7 +1228,7 @@ public partial class ArenaRenderer : Node3D
|
||||||
float nextVent = _thermalVentNextTime.GetValueOrDefault(key);
|
float nextVent = _thermalVentNextTime.GetValueOrDefault(key);
|
||||||
if (_vfxClock >= nextVent)
|
if (_vfxClock >= nextVent)
|
||||||
{
|
{
|
||||||
_thermalVentNextTime[key] = _vfxClock + 0.10f; // 10 Hz
|
_thermalVentNextTime[key] = _vfxClock + 0.13f; // ~7.7 Hz
|
||||||
Vector3 ventPos = ResolveHotAnchorWorld(av?.Visual, c.Grid, pos, c.Grid.Spec.HalfHeight);
|
Vector3 ventPos = ResolveHotAnchorWorld(av?.Visual, c.Grid, pos, c.Grid.Spec.HalfHeight);
|
||||||
_particles.EmitThermalVent(ventPos, thermalRatio, camPos, hasCam);
|
_particles.EmitThermalVent(ventPos, thermalRatio, camPos, hasCam);
|
||||||
}
|
}
|
||||||
|
|
@ -1239,7 +1239,7 @@ public partial class ArenaRenderer : Node3D
|
||||||
float nextSmoke = _damageSmokeNextTime.GetValueOrDefault(key);
|
float nextSmoke = _damageSmokeNextTime.GetValueOrDefault(key);
|
||||||
if (_vfxClock >= nextSmoke)
|
if (_vfxClock >= nextSmoke)
|
||||||
{
|
{
|
||||||
_damageSmokeNextTime[key] = _vfxClock + 0.10f; // 10 Hz
|
_damageSmokeNextTime[key] = _vfxClock + 0.13f; // ~7.7 Hz
|
||||||
Vector3 dmgPos = pos + new Vector3(0f, c.Grid.Spec.HalfHeight * 0.6f, 0f);
|
Vector3 dmgPos = pos + new Vector3(0f, c.Grid.Spec.HalfHeight * 0.6f, 0f);
|
||||||
_particles.EmitDamageSmokeAndFire(dmgPos, coreHpRatio, camPos, hasCam);
|
_particles.EmitDamageSmokeAndFire(dmgPos, coreHpRatio, camPos, hasCam);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,54 @@ public sealed class CameraJuiceState
|
||||||
_time = 0f;
|
_time = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConsumeEvents(IReadOnlyList<ISimEvent> events, int localContenderId, Vector3 localPos)
|
public void ConsumeEvents(
|
||||||
|
IReadOnlyList<ISimEvent> events,
|
||||||
|
int localContenderId,
|
||||||
|
Vector3 localPos,
|
||||||
|
IClientArenaSession? session = null)
|
||||||
|
{
|
||||||
|
ConsumeEvents(events, localContenderId, localPos, session is null ? null : (isContender, id) =>
|
||||||
|
{
|
||||||
|
if (isContender)
|
||||||
|
{
|
||||||
|
var contenders = session.ViewState.Contenders;
|
||||||
|
if (id >= 0 && id < contenders.Count && (id == session.LocalContenderId || session.IsContenderVisible(id)))
|
||||||
|
{
|
||||||
|
var c = contenders[id];
|
||||||
|
return (true, new Vector3(c.X, c.Y, c.Z));
|
||||||
|
}
|
||||||
|
return (false, Vector3.Zero);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (session.IsSpectatorVisible(id))
|
||||||
|
{
|
||||||
|
var specs = session.ViewState.Spectators.Spectators;
|
||||||
|
for (int s = 0; s < specs.Count; s++)
|
||||||
|
{
|
||||||
|
if (specs[s].Id == id)
|
||||||
|
{
|
||||||
|
var sp = specs[s];
|
||||||
|
return (true, new Vector3(sp.X, sp.Y, sp.Z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int sIdx = id >= 1000 ? id - 1000 : id;
|
||||||
|
if (sIdx >= 0 && sIdx < specs.Count)
|
||||||
|
{
|
||||||
|
var sp = specs[sIdx];
|
||||||
|
return (true, new Vector3(sp.X, sp.Y, sp.Z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (false, Vector3.Zero);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConsumeEvents(
|
||||||
|
IReadOnlyList<ISimEvent> events,
|
||||||
|
int localContenderId,
|
||||||
|
Vector3 localPos,
|
||||||
|
Func<bool, int, (bool Visible, Vector3 Pos)>? resolveActor)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < events.Count; i++)
|
for (int i = 0; i < events.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -92,15 +139,39 @@ public sealed class CameraJuiceState
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ContenderEliminatedEvent:
|
case ContenderEliminatedEvent elim:
|
||||||
case SpectatorDestroyedEvent:
|
ApplyDeathTrauma(isContender: true, elim.VictimId, localPos, resolveActor);
|
||||||
// Large chassis detonation thump when nearby (camera-local subtle shake)
|
break;
|
||||||
AddTrauma(0.14f);
|
|
||||||
|
case SpectatorDestroyedEvent sdet:
|
||||||
|
ApplyDeathTrauma(isContender: false, sdet.SpectatorId, localPos, resolveActor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ApplyDeathTrauma(
|
||||||
|
bool isContender,
|
||||||
|
int entityId,
|
||||||
|
Vector3 localPos,
|
||||||
|
Func<bool, int, (bool Visible, Vector3 Pos)>? resolveActor)
|
||||||
|
{
|
||||||
|
if (resolveActor is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var (visible, pos) = resolveActor(isContender, entityId);
|
||||||
|
if (!visible)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float dist = Vector3.Distance(pos, localPos);
|
||||||
|
if (dist < 90f)
|
||||||
|
{
|
||||||
|
AddTrauma(0.14f * (1f - dist / 90f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ConsumeFootsteps(IReadOnlyList<FootstepPulse> footsteps, int localContenderId)
|
public void ConsumeFootsteps(IReadOnlyList<FootstepPulse> footsteps, int localContenderId)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < footsteps.Count; i++)
|
for (int i = 0; i < footsteps.Count; i++)
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ namespace RustToDust.Client;
|
||||||
public partial class DebrisSystem : Node3D
|
public partial class DebrisSystem : Node3D
|
||||||
{
|
{
|
||||||
private const float Gravity = -20f;
|
private const float Gravity = -20f;
|
||||||
private const float DefaultLifetime = 8.0f;
|
private const float DefaultLifetime = 4.5f;
|
||||||
private const float FadeDuration = 2.0f;
|
private const float FadeDuration = 1.2f;
|
||||||
private const int MaxActiveDebris = 256;
|
private const int MaxActiveDebris = 96;
|
||||||
|
|
||||||
private sealed class DebrisPiece
|
private sealed class DebrisPiece
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,9 @@ public partial class Hud : CanvasLayer
|
||||||
float pulse = (WeaponVisualClass)hit.WeaponClass == WeaponVisualClass.Explosive ? 0.95f : 0.62f;
|
float pulse = (WeaponVisualClass)hit.WeaponClass == WeaponVisualClass.Explosive ? 0.95f : 0.62f;
|
||||||
_damagePulse = MathF.Max(_damagePulse, pulse);
|
_damagePulse = MathF.Max(_damagePulse, pulse);
|
||||||
}
|
}
|
||||||
if (hit.IsContenderShooter && hit.ShooterId == localContenderId)
|
bool targetIsVehicle = hit.TargetKind == (byte)HitTargetKind.Contender
|
||||||
|
|| hit.TargetKind == (byte)HitTargetKind.Spectator;
|
||||||
|
if (targetIsVehicle && hit.IsContenderShooter && hit.ShooterId == localContenderId)
|
||||||
{
|
{
|
||||||
_crosshair?.TriggerHitMarker(hit.CoreDamage > 0.001f, hit.Killed);
|
_crosshair?.TriggerHitMarker(hit.CoreDamage > 0.001f, hit.Killed);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -415,9 +415,13 @@ public partial class Main : Node3D
|
||||||
_footsteps.Clear();
|
_footsteps.Clear();
|
||||||
_frameEvents.Clear();
|
_frameEvents.Clear();
|
||||||
_frameFootsteps.Clear();
|
_frameFootsteps.Clear();
|
||||||
_audio.ClearAll();
|
_audio.ResetForSession(_session);
|
||||||
_hud.ResetFeedback();
|
_hud.ResetFeedback();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_audio.ResetForSession(_session);
|
||||||
|
}
|
||||||
|
|
||||||
_camera.Far = _mapKind == ArenaMapKind.Sion ? 4200f : 1800f;
|
_camera.Far = _mapKind == ArenaMapKind.Sion ? 4200f : 1800f;
|
||||||
ApplyEnvironmentForMap(_mapKind);
|
ApplyEnvironmentForMap(_mapKind);
|
||||||
|
|
@ -442,6 +446,12 @@ public partial class Main : Node3D
|
||||||
_terrain.UpdateTileLod(_camera.GlobalPosition);
|
_terrain.UpdateTileLod(_camera.GlobalPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var localStart = _session.LocalContender;
|
||||||
|
Vector3 startVec = new(localStart.X, localStart.Y, localStart.Z);
|
||||||
|
Vector3 startFwd = new(MathF.Sin(localStart.Yaw), 0f, MathF.Cos(localStart.Yaw));
|
||||||
|
_arena.Particles.PrewarmFlashLights(startVec, startFwd);
|
||||||
|
_arena.PomDecals.PrewarmShader(startVec);
|
||||||
|
|
||||||
_hud.Sync(_session);
|
_hud.Sync(_session);
|
||||||
SyncMouseMode();
|
SyncMouseMode();
|
||||||
}
|
}
|
||||||
|
|
@ -826,7 +836,7 @@ public partial class Main : Node3D
|
||||||
|
|
||||||
var local = _session.LocalContender;
|
var local = _session.LocalContender;
|
||||||
var localPos = new System.Numerics.Vector3(local.X, local.Y, local.Z);
|
var localPos = new System.Numerics.Vector3(local.X, local.Y, local.Z);
|
||||||
_camJuice.ConsumeEvents(_frameEvents, _session.LocalContenderId, localPos);
|
_camJuice.ConsumeEvents(_frameEvents, _session.LocalContenderId, localPos, _session);
|
||||||
_camJuice.ConsumeFootsteps(_frameFootsteps, _session.LocalContenderId);
|
_camJuice.ConsumeFootsteps(_frameFootsteps, _session.LocalContenderId);
|
||||||
_camJuice.Update(dt, local.Speed, local.Grid.Spec.IsVtol);
|
_camJuice.Update(dt, local.Speed, local.Grid.Spec.IsVtol);
|
||||||
}
|
}
|
||||||
|
|
@ -1374,7 +1384,7 @@ public partial class Main : Node3D
|
||||||
{
|
{
|
||||||
_sun.LightColor = new Color(1.0f, 0.95f, 0.87f);
|
_sun.LightColor = new Color(1.0f, 0.95f, 0.87f);
|
||||||
_sun.LightEnergy = 1.25f;
|
_sun.LightEnergy = 1.25f;
|
||||||
_sun.DirectionalShadowMaxDistance = 160f;
|
_sun.DirectionalShadowMaxDistance = 120f;
|
||||||
_sun.RotationDegrees = new Vector3(-42f, 28f, 0f);
|
_sun.RotationDegrees = new Vector3(-42f, 28f, 0f);
|
||||||
|
|
||||||
_skyMat.SkyTopColor = new Color(0.18f, 0.36f, 0.62f);
|
_skyMat.SkyTopColor = new Color(0.18f, 0.36f, 0.62f);
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,10 @@ public partial class MultiMeshPartPool : Node3D
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool castShadow = wantsShadow && bucket.LocalRadius >= 0.55f;
|
bool castShadow = wantsShadow && bucket.LocalRadius >= 1.15f;
|
||||||
if (castShadow && _hasFrustum)
|
if (castShadow && _hasFrustum)
|
||||||
{
|
{
|
||||||
float maxShadowDist = 85f + scaledRadius;
|
float maxShadowDist = 45f + scaledRadius;
|
||||||
if (worldCenter.DistanceSquaredTo(_camPos) > maxShadowDist * maxShadowDist)
|
if (worldCenter.DistanceSquaredTo(_camPos) > maxShadowDist * maxShadowDist)
|
||||||
{
|
{
|
||||||
castShadow = false;
|
castShadow = false;
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ namespace RustToDust.Client;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Single-draw-call GPU billboard particle pool (<see cref="MultiMeshInstance3D"/> backed by
|
/// Single-draw-call GPU billboard particle pool (<see cref="MultiMeshInstance3D"/> backed by
|
||||||
/// <c>particle_billboard.gdshader</c>) plus the strictly capped <see cref="OmniLight3D"/>[4]
|
/// <c>particle_billboard.gdshader</c>) plus the strictly capped <see cref="OmniLight3D"/>[2]
|
||||||
/// dynamic combat flash pool for OpenGL 3.3 (<c>gl_compatibility</c>).
|
/// dynamic combat flash pool for OpenGL 3.3 (<c>gl_compatibility</c>).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class ParticlePool : Node3D
|
public partial class ParticlePool : Node3D
|
||||||
{
|
{
|
||||||
public const int MaxParticles = 768;
|
public const int MaxParticles = 512;
|
||||||
public const int MaxFlashLights = 4;
|
public const int MaxFlashLights = 2;
|
||||||
|
|
||||||
public const float ModeDustSmoke = 0f;
|
public const float ModeDustSmoke = 0f;
|
||||||
public const float ModeMuzzleStarburst = 1f;
|
public const float ModeMuzzleStarburst = 1f;
|
||||||
|
|
@ -65,6 +65,7 @@ public partial class ParticlePool : Node3D
|
||||||
private MultiMeshInstance3D _instanceNode = null!;
|
private MultiMeshInstance3D _instanceNode = null!;
|
||||||
private ShaderMaterial _material = null!;
|
private ShaderMaterial _material = null!;
|
||||||
private int _writeCursor;
|
private int _writeCursor;
|
||||||
|
private int _warmupFramesRemaining;
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
private uint _rng = 0x7A3B91E5u;
|
private uint _rng = 0x7A3B91E5u;
|
||||||
|
|
||||||
|
|
@ -132,7 +133,7 @@ public partial class ParticlePool : Node3D
|
||||||
Name = $"CombatFlashLight_{i}",
|
Name = $"CombatFlashLight_{i}",
|
||||||
ShadowEnabled = false,
|
ShadowEnabled = false,
|
||||||
OmniAttenuation = 1.6f,
|
OmniAttenuation = 1.6f,
|
||||||
OmniRange = 10f,
|
OmniRange = 14f,
|
||||||
LightEnergy = 0f,
|
LightEnergy = 0f,
|
||||||
Visible = false
|
Visible = false
|
||||||
};
|
};
|
||||||
|
|
@ -141,6 +142,40 @@ public partial class ParticlePool : Node3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pre-warms the pooled <see cref="OmniLight3D"/> nodes on startup for 1 rendered frame
|
||||||
|
/// with near-zero energy so OpenGL 3.3 compiles lit shader variants before combat begins.
|
||||||
|
/// </summary>
|
||||||
|
public void PrewarmFlashLights(Vector3 nearPos, Vector3 forwardHoriz)
|
||||||
|
{
|
||||||
|
EnsureInitialized();
|
||||||
|
_warmupFramesRemaining = 2;
|
||||||
|
Vector3 fwd = forwardHoriz.LengthSquared() > 1e-4f ? forwardHoriz.Normalized() : Vector3.Forward;
|
||||||
|
for (int i = 0; i < _flashLights.Length; i++)
|
||||||
|
{
|
||||||
|
ref FlashLightSlot slot = ref _flashLights[i];
|
||||||
|
slot.Active = false;
|
||||||
|
slot.Priority = 0;
|
||||||
|
slot.Age = 0f;
|
||||||
|
slot.Duration = 0f;
|
||||||
|
slot.StartEnergy = 0f;
|
||||||
|
slot.Range = 22f;
|
||||||
|
slot.Light.Position = i == 0 ? nearPos + new Vector3(0f, 2f, 0f) : nearPos + fwd * 72f + new Vector3(0f, 3f, 0f);
|
||||||
|
slot.Light.LightColor = Colors.White;
|
||||||
|
slot.Light.OmniRange = 22f;
|
||||||
|
slot.Light.OmniAttenuation = 1.6f;
|
||||||
|
slot.Light.LightEnergy = 0.001f;
|
||||||
|
slot.Light.Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also pre-warm the particle billboard shader on frame 0 with 1 micro-quad
|
||||||
|
_multiMesh.SetInstanceTransform(0, new Transform3D(Basis.FromScale(new Vector3(0.01f, 0.01f, 1f)), nearPos));
|
||||||
|
_multiMesh.SetInstanceColor(0, new Color(1f, 1f, 1f, 0.01f));
|
||||||
|
_multiMesh.SetInstanceCustomData(0, new Color(ModeDustSmoke, 0f, 0f, 0f));
|
||||||
|
_multiMesh.VisibleInstanceCount = 1;
|
||||||
|
_instanceNode.Visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void ClearAll()
|
public void ClearAll()
|
||||||
{
|
{
|
||||||
EnsureInitialized();
|
EnsureInitialized();
|
||||||
|
|
@ -150,6 +185,7 @@ public partial class ParticlePool : Node3D
|
||||||
_recentShotCursor = 0;
|
_recentShotCursor = 0;
|
||||||
_recentHitCursor = 0;
|
_recentHitCursor = 0;
|
||||||
_writeCursor = 0;
|
_writeCursor = 0;
|
||||||
|
_warmupFramesRemaining = 0;
|
||||||
ActiveParticleCount = 0;
|
ActiveParticleCount = 0;
|
||||||
PeakFlashLightCount = 0;
|
PeakFlashLightCount = 0;
|
||||||
|
|
||||||
|
|
@ -167,13 +203,14 @@ public partial class ParticlePool : Node3D
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConsumeEvents(
|
public void ConsumeEvents(
|
||||||
|
IClientArenaSession session,
|
||||||
IReadOnlyList<ISimEvent> events,
|
IReadOnlyList<ISimEvent> events,
|
||||||
MatchState state,
|
|
||||||
Vector3 camPos,
|
Vector3 camPos,
|
||||||
bool hasCam,
|
bool hasCam,
|
||||||
Func<float, float, Color> sampleGroundTint)
|
Func<float, float, Color> sampleGroundTint)
|
||||||
{
|
{
|
||||||
EnsureInitialized();
|
EnsureInitialized();
|
||||||
|
var state = session.ViewState;
|
||||||
|
|
||||||
for (int i = 0; i < events.Count; i++)
|
for (int i = 0; i < events.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -192,7 +229,8 @@ public partial class ParticlePool : Node3D
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContenderEliminatedEvent elim:
|
case ContenderEliminatedEvent elim:
|
||||||
if (elim.VictimId >= 0 && elim.VictimId < state.Contenders.Count)
|
if ((elim.VictimId == session.LocalContenderId || session.IsContenderVisible(elim.VictimId)) &&
|
||||||
|
elim.VictimId >= 0 && elim.VictimId < state.Contenders.Count)
|
||||||
{
|
{
|
||||||
var v = state.Contenders[elim.VictimId];
|
var v = state.Contenders[elim.VictimId];
|
||||||
EmitChassisExplosion(new Vector3(v.X, v.Y + 0.6f, v.Z), v.Grid.Spec.MassKg, camPos, hasCam, sampleGroundTint);
|
EmitChassisExplosion(new Vector3(v.X, v.Y + 0.6f, v.Z), v.Grid.Spec.MassKg, camPos, hasCam, sampleGroundTint);
|
||||||
|
|
@ -201,6 +239,10 @@ public partial class ParticlePool : Node3D
|
||||||
|
|
||||||
case SpectatorDestroyedEvent sdet:
|
case SpectatorDestroyedEvent sdet:
|
||||||
{
|
{
|
||||||
|
if (!session.IsSpectatorVisible(sdet.SpectatorId))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
var specs = state.Spectators.Spectators;
|
var specs = state.Spectators.Spectators;
|
||||||
for (int s = 0; s < specs.Count; s++)
|
for (int s = 0; s < specs.Count; s++)
|
||||||
{
|
{
|
||||||
|
|
@ -228,9 +270,9 @@ public partial class ParticlePool : Node3D
|
||||||
|
|
||||||
float massScale = Math.Clamp(pulse.MassKg / 2600f, 0.72f, 1.55f);
|
float massScale = Math.Clamp(pulse.MassKg / 2600f, 0.72f, 1.55f);
|
||||||
float loadScale = Math.Clamp(pulse.LoadG, 0.5f, 1.8f);
|
float loadScale = Math.Clamp(pulse.LoadG, 0.5f, 1.8f);
|
||||||
int count = pulse.MassKg >= 3600f ? 5 : 3;
|
int count = pulse.MassKg >= 3600f ? 3 : 2;
|
||||||
|
|
||||||
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.52f);
|
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.50f);
|
||||||
Color dustEnd = new(groundTint.R * 0.92f, groundTint.G * 0.92f, groundTint.B * 0.92f, 0.0f);
|
Color dustEnd = new(groundTint.R * 0.92f, groundTint.G * 0.92f, groundTint.B * 0.92f, 0.0f);
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
|
|
@ -246,15 +288,15 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = vel,
|
Velocity = vel,
|
||||||
Gravity = 0.25f,
|
Gravity = 0.25f,
|
||||||
Drag = 2.8f,
|
Drag = 2.8f,
|
||||||
StartSize = 0.65f * massScale,
|
StartSize = 0.55f * massScale,
|
||||||
EndSize = 2.35f * massScale,
|
EndSize = MathF.Min(2.2f, 1.55f * massScale),
|
||||||
AspectY = 1.0f,
|
AspectY = 1.0f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.4f,
|
AngularVel = NextSigned() * 1.4f,
|
||||||
Emissive = 0f,
|
Emissive = 0f,
|
||||||
ColorStart = dustStart,
|
ColorStart = dustStart,
|
||||||
ColorEnd = dustEnd,
|
ColorEnd = dustEnd,
|
||||||
Lifetime = 0.42f + NextFloat() * 0.24f
|
Lifetime = 0.35f + NextFloat() * 0.18f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -268,7 +310,7 @@ public partial class ParticlePool : Node3D
|
||||||
}
|
}
|
||||||
|
|
||||||
float scale = Math.Clamp(intensity, 0.5f, 1.5f);
|
float scale = Math.Clamp(intensity, 0.5f, 1.5f);
|
||||||
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.44f);
|
Color dustStart = new(groundTint.R, groundTint.G, groundTint.B, 0.42f);
|
||||||
Color dustEnd = new(groundTint.R * 0.95f, groundTint.G * 0.95f, groundTint.B * 0.95f, 0.0f);
|
Color dustEnd = new(groundTint.R * 0.95f, groundTint.G * 0.95f, groundTint.B * 0.95f, 0.0f);
|
||||||
|
|
||||||
SpawnParticle(new ParticleSlot
|
SpawnParticle(new ParticleSlot
|
||||||
|
|
@ -279,15 +321,15 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = -vehicleVel * 0.15f + new Vector3(NextSigned() * 1.1f, 0.9f + NextFloat() * 0.8f, NextSigned() * 1.1f),
|
Velocity = -vehicleVel * 0.15f + new Vector3(NextSigned() * 1.1f, 0.9f + NextFloat() * 0.8f, NextSigned() * 1.1f),
|
||||||
Gravity = 0.15f,
|
Gravity = 0.15f,
|
||||||
Drag = 2.4f,
|
Drag = 2.4f,
|
||||||
StartSize = 0.55f * scale,
|
StartSize = 0.50f * scale,
|
||||||
EndSize = 2.15f * scale,
|
EndSize = MathF.Min(2.1f, 1.65f * scale),
|
||||||
AspectY = 1.0f,
|
AspectY = 1.0f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.2f,
|
AngularVel = NextSigned() * 1.2f,
|
||||||
Emissive = 0f,
|
Emissive = 0f,
|
||||||
ColorStart = dustStart,
|
ColorStart = dustStart,
|
||||||
ColorEnd = dustEnd,
|
ColorEnd = dustEnd,
|
||||||
Lifetime = 0.45f + NextFloat() * 0.20f
|
Lifetime = 0.36f + NextFloat() * 0.16f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,15 +350,15 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = new Vector3(NextSigned() * 0.9f, 2.2f + NextFloat() * 1.5f, NextSigned() * 0.9f),
|
Velocity = new Vector3(NextSigned() * 0.9f, 2.2f + NextFloat() * 1.5f, NextSigned() * 0.9f),
|
||||||
Gravity = -0.35f,
|
Gravity = -0.35f,
|
||||||
Drag = 1.6f,
|
Drag = 1.6f,
|
||||||
StartSize = 0.42f,
|
StartSize = 0.40f,
|
||||||
EndSize = 1.45f + heatT * 0.45f,
|
EndSize = 1.25f + heatT * 0.35f,
|
||||||
AspectY = 1.0f,
|
AspectY = 1.0f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.8f,
|
AngularVel = NextSigned() * 1.8f,
|
||||||
Emissive = 0.35f + heatT * 0.85f,
|
Emissive = 0.35f + heatT * 0.85f,
|
||||||
ColorStart = new Color(0.95f, 0.88f - heatT * 0.32f, 0.78f - heatT * 0.50f, 0.65f),
|
ColorStart = new Color(0.95f, 0.88f - heatT * 0.32f, 0.78f - heatT * 0.50f, 0.62f),
|
||||||
ColorEnd = new Color(0.65f, 0.58f, 0.54f, 0.0f),
|
ColorEnd = new Color(0.65f, 0.58f, 0.54f, 0.0f),
|
||||||
Lifetime = 0.42f + NextFloat() * 0.18f
|
Lifetime = 0.36f + NextFloat() * 0.16f
|
||||||
});
|
});
|
||||||
|
|
||||||
if (heatT > 0.35f)
|
if (heatT > 0.35f)
|
||||||
|
|
@ -359,15 +401,15 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = new Vector3(NextSigned() * 0.8f, 2.4f + NextFloat() * 1.4f, NextSigned() * 0.8f),
|
Velocity = new Vector3(NextSigned() * 0.8f, 2.4f + NextFloat() * 1.4f, NextSigned() * 0.8f),
|
||||||
Gravity = -0.35f,
|
Gravity = -0.35f,
|
||||||
Drag = 1.2f,
|
Drag = 1.2f,
|
||||||
StartSize = 0.65f,
|
StartSize = 0.58f,
|
||||||
EndSize = 2.25f + dmgT * 0.8f,
|
EndSize = MathF.Min(2.2f, 1.65f + dmgT * 0.55f),
|
||||||
AspectY = 1.0f,
|
AspectY = 1.0f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.1f,
|
AngularVel = NextSigned() * 1.1f,
|
||||||
Emissive = 0f,
|
Emissive = 0f,
|
||||||
ColorStart = new Color(0.18f, 0.16f, 0.15f, 0.72f),
|
ColorStart = new Color(0.18f, 0.16f, 0.15f, 0.70f),
|
||||||
ColorEnd = new Color(0.10f, 0.10f, 0.10f, 0.0f),
|
ColorEnd = new Color(0.10f, 0.10f, 0.10f, 0.0f),
|
||||||
Lifetime = 0.70f + NextFloat() * 0.30f
|
Lifetime = 0.55f + NextFloat() * 0.25f
|
||||||
});
|
});
|
||||||
|
|
||||||
if (dmgT > 0.3f && NextFloat() < 0.65f)
|
if (dmgT > 0.3f && NextFloat() < 0.65f)
|
||||||
|
|
@ -446,7 +488,7 @@ public partial class ParticlePool : Node3D
|
||||||
_multiMesh.VisibleInstanceCount = visibleCount;
|
_multiMesh.VisibleInstanceCount = visibleCount;
|
||||||
_instanceNode.Visible = visibleCount > 0;
|
_instanceNode.Visible = visibleCount > 0;
|
||||||
|
|
||||||
// 2. Advance pooled OmniLight3D[4] dynamic flashes
|
// 2. Advance pooled OmniLight3D[2] dynamic flashes
|
||||||
int activeLights = 0;
|
int activeLights = 0;
|
||||||
for (int i = 0; i < _flashLights.Length; i++)
|
for (int i = 0; i < _flashLights.Length; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -479,6 +521,21 @@ public partial class ParticlePool : Node3D
|
||||||
activeLights++;
|
activeLights++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_warmupFramesRemaining > 0)
|
||||||
|
{
|
||||||
|
_warmupFramesRemaining--;
|
||||||
|
if (_warmupFramesRemaining == 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _flashLights.Length; i++)
|
||||||
|
{
|
||||||
|
if (!_flashLights[i].Active)
|
||||||
|
{
|
||||||
|
_flashLights[i].Light.Visible = false;
|
||||||
|
_flashLights[i].Light.LightEnergy = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (activeLights > PeakFlashLightCount)
|
if (activeLights > PeakFlashLightCount)
|
||||||
{
|
{
|
||||||
PeakFlashLightCount = activeLights;
|
PeakFlashLightCount = activeLights;
|
||||||
|
|
@ -506,7 +563,7 @@ public partial class ParticlePool : Node3D
|
||||||
|
|
||||||
Vector3 start = new(shot.StartX, shot.StartY, shot.StartZ);
|
Vector3 start = new(shot.StartX, shot.StartY, shot.StartZ);
|
||||||
Vector3 end = new(shot.EndX, shot.EndY, shot.EndZ);
|
Vector3 end = new(shot.EndX, shot.EndY, shot.EndZ);
|
||||||
if (hasCam && start.DistanceSquaredTo(camPos) > 160f * 160f)
|
if (hasCam && start.DistanceSquaredTo(camPos) > 120f * 120f)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -536,10 +593,6 @@ public partial class ParticlePool : Node3D
|
||||||
ColorEnd = new Color(0.95f, 0.55f, 0.16f, 0.0f),
|
ColorEnd = new Color(0.95f, 0.55f, 0.16f, 0.0f),
|
||||||
Lifetime = 0.065f
|
Lifetime = 0.065f
|
||||||
});
|
});
|
||||||
if (!hasCam || start.DistanceSquaredTo(camPos) <= 95f * 95f)
|
|
||||||
{
|
|
||||||
SpawnFlashLight(start, new Color(1.0f, 0.82f, 0.45f), 1.45f, 6.5f, 0.08f, priority: 1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -581,7 +634,7 @@ public partial class ParticlePool : Node3D
|
||||||
Lifetime = 0.32f
|
Lifetime = 0.32f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!hasCam || start.DistanceSquaredTo(camPos) <= 120f * 120f)
|
if (!hasCam || start.DistanceSquaredTo(camPos) <= 45f * 45f)
|
||||||
{
|
{
|
||||||
SpawnFlashLight(start, new Color(1.0f, 0.68f, 0.24f), 2.8f, 10.5f, 0.10f, priority: 3);
|
SpawnFlashLight(start, new Color(1.0f, 0.68f, 0.24f), 2.8f, 10.5f, 0.10f, priority: 3);
|
||||||
}
|
}
|
||||||
|
|
@ -638,7 +691,7 @@ public partial class ParticlePool : Node3D
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasCam || start.DistanceSquaredTo(camPos) <= 140f * 140f)
|
if (!hasCam || start.DistanceSquaredTo(camPos) <= 65f * 65f)
|
||||||
{
|
{
|
||||||
SpawnFlashLight(start, new Color(1.0f, 0.58f, 0.18f), isRecoilless ? 4.2f : 2.6f, isRecoilless ? 14f : 10f, 0.13f, priority: 5);
|
SpawnFlashLight(start, new Color(1.0f, 0.58f, 0.18f), isRecoilless ? 4.2f : 2.6f, isRecoilless ? 14f : 10f, 0.13f, priority: 5);
|
||||||
}
|
}
|
||||||
|
|
@ -665,9 +718,9 @@ public partial class ParticlePool : Node3D
|
||||||
ColorEnd = beamCol with { A = 0f },
|
ColorEnd = beamCol with { A = 0f },
|
||||||
Lifetime = 0.09f
|
Lifetime = 0.09f
|
||||||
});
|
});
|
||||||
if (!hasCam || start.DistanceSquaredTo(camPos) <= 130f * 130f)
|
if (!hasCam || start.DistanceSquaredTo(camPos) <= 45f * 45f)
|
||||||
{
|
{
|
||||||
SpawnFlashLight(start, beamCol with { A = 1f }, isLance ? 3.5f : 2.6f, 11.5f, 0.12f, priority: 4);
|
SpawnFlashLight(start, beamCol with { A = 1f }, isLance ? 3.5f : 2.6f, 11f, 0.12f, priority: 4);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -694,7 +747,7 @@ public partial class ParticlePool : Node3D
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 pos = new(hit.HitX, hit.HitY, hit.HitZ);
|
Vector3 pos = new(hit.HitX, hit.HitY, hit.HitZ);
|
||||||
if (hasCam && pos.DistanceSquaredTo(camPos) > 165f * 165f)
|
if (hasCam && pos.DistanceSquaredTo(camPos) > 125f * 125f)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -715,17 +768,17 @@ public partial class ParticlePool : Node3D
|
||||||
Mode = ModeSteamFire,
|
Mode = ModeSteamFire,
|
||||||
Position = pos,
|
Position = pos,
|
||||||
Velocity = Vector3.Zero,
|
Velocity = Vector3.Zero,
|
||||||
StartSize = 0.55f,
|
StartSize = 0.50f,
|
||||||
EndSize = 2.45f,
|
EndSize = 2.15f,
|
||||||
AspectY = 1f,
|
AspectY = 1f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.5f,
|
AngularVel = NextSigned() * 1.5f,
|
||||||
Emissive = 1.6f,
|
Emissive = 1.6f,
|
||||||
ColorStart = new Color(1.0f, 0.55f, 0.16f, 0.90f),
|
ColorStart = new Color(1.0f, 0.55f, 0.16f, 0.90f),
|
||||||
ColorEnd = new Color(0.24f, 0.16f, 0.12f, 0.0f),
|
ColorEnd = new Color(0.24f, 0.16f, 0.12f, 0.0f),
|
||||||
Lifetime = 0.28f
|
Lifetime = 0.35f
|
||||||
});
|
});
|
||||||
SpawnSparkBurst(pos, normal, 4, new Color(1.0f, 0.68f, 0.24f, 0.98f), 10f);
|
SpawnSparkBurst(pos, normal, 3, new Color(1.0f, 0.68f, 0.24f, 0.98f), 10f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -743,18 +796,14 @@ public partial class ParticlePool : Node3D
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WeaponVisualClass.Autocannon:
|
case WeaponVisualClass.Autocannon:
|
||||||
EmitImpactDustPlume(pos, normal, groundTint, count: 2, size: 1.55f);
|
EmitImpactDustPlume(pos, normal, groundTint, count: 2, size: 1.45f);
|
||||||
SpawnSparkBurst(pos, normal, 4, new Color(1.0f, 0.72f, 0.26f, 0.98f), 11.5f);
|
SpawnSparkBurst(pos, normal, 3, new Color(1.0f, 0.72f, 0.26f, 0.98f), 11.5f);
|
||||||
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 130f * 130f)
|
|
||||||
{
|
|
||||||
SpawnFlashLight(pos + normal * 0.3f, new Color(1.0f, 0.68f, 0.24f), 2.8f, 9.5f, 0.10f, priority: 4);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WeaponVisualClass.Explosive:
|
case WeaponVisualClass.Explosive:
|
||||||
{
|
{
|
||||||
bool isRecoilless = string.Equals(hit.WeaponId, "recoilless", StringComparison.Ordinal);
|
bool isRecoilless = string.Equals(hit.WeaponId, "recoilless", StringComparison.Ordinal);
|
||||||
EmitImpactDustPlume(pos, normal, groundTint, count: isRecoilless ? 5 : 3, size: isRecoilless ? 2.6f : 1.7f);
|
EmitImpactDustPlume(pos, normal, groundTint, count: isRecoilless ? 4 : 2, size: isRecoilless ? 1.85f : 1.35f);
|
||||||
for (int f = 0; f < (isRecoilless ? 3 : 2); f++)
|
for (int f = 0; f < (isRecoilless ? 3 : 2); f++)
|
||||||
{
|
{
|
||||||
SpawnParticle(new ParticleSlot
|
SpawnParticle(new ParticleSlot
|
||||||
|
|
@ -765,21 +814,21 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = normal * (1.8f + NextFloat() * 1.8f) + new Vector3(NextSigned(), 1.2f, NextSigned()),
|
Velocity = normal * (1.8f + NextFloat() * 1.8f) + new Vector3(NextSigned(), 1.2f, NextSigned()),
|
||||||
Gravity = -0.3f,
|
Gravity = -0.3f,
|
||||||
Drag = 1.6f,
|
Drag = 1.6f,
|
||||||
StartSize = isRecoilless ? 1.1f : 0.7f,
|
StartSize = isRecoilless ? 0.95f : 0.65f,
|
||||||
EndSize = isRecoilless ? 3.5f : 2.1f,
|
EndSize = isRecoilless ? 3.1f : 2.0f,
|
||||||
AspectY = 1f,
|
AspectY = 1f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.4f,
|
AngularVel = NextSigned() * 1.4f,
|
||||||
Emissive = 2.6f,
|
Emissive = 2.6f,
|
||||||
ColorStart = new Color(1.0f, 0.64f, 0.18f, 0.95f),
|
ColorStart = new Color(1.0f, 0.64f, 0.18f, 0.95f),
|
||||||
ColorEnd = new Color(0.28f, 0.16f, 0.12f, 0.0f),
|
ColorEnd = new Color(0.28f, 0.16f, 0.12f, 0.0f),
|
||||||
Lifetime = isRecoilless ? 0.36f : 0.26f
|
Lifetime = isRecoilless ? 0.38f : 0.35f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
SpawnSparkBurst(pos, normal, isRecoilless ? 6 : 4, new Color(1.0f, 0.64f, 0.20f, 0.98f), 14f);
|
SpawnSparkBurst(pos, normal, isRecoilless ? 5 : 3, new Color(1.0f, 0.64f, 0.20f, 0.98f), 14f);
|
||||||
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 155f * 155f)
|
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 75f * 75f)
|
||||||
{
|
{
|
||||||
SpawnFlashLight(pos + normal * 0.45f, new Color(1.0f, 0.55f, 0.16f), isRecoilless ? 4.8f : 3.2f, isRecoilless ? 16f : 11f, 0.16f, priority: 7);
|
SpawnFlashLight(pos + normal * 0.45f, new Color(1.0f, 0.55f, 0.16f), isRecoilless ? 4.8f : 3.2f, isRecoilless ? 14.5f : 11f, 0.14f, priority: 7);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -791,20 +840,16 @@ public partial class ParticlePool : Node3D
|
||||||
Mode = ModeSteamFire,
|
Mode = ModeSteamFire,
|
||||||
Position = pos,
|
Position = pos,
|
||||||
Velocity = normal * 1.4f,
|
Velocity = normal * 1.4f,
|
||||||
StartSize = 0.65f,
|
StartSize = 0.60f,
|
||||||
EndSize = 1.85f,
|
EndSize = 1.75f,
|
||||||
AspectY = 1f,
|
AspectY = 1f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
Emissive = 2.8f,
|
Emissive = 2.8f,
|
||||||
ColorStart = new Color(0.45f, 0.94f, 1.0f, 0.94f),
|
ColorStart = new Color(0.45f, 0.94f, 1.0f, 0.94f),
|
||||||
ColorEnd = new Color(0.95f, 0.52f, 0.16f, 0.0f),
|
ColorEnd = new Color(0.95f, 0.52f, 0.16f, 0.0f),
|
||||||
Lifetime = 0.24f
|
Lifetime = 0.35f
|
||||||
});
|
});
|
||||||
SpawnSparkBurst(pos, normal, 5, new Color(0.55f, 0.92f, 1.0f, 0.98f), 12f);
|
SpawnSparkBurst(pos, normal, 4, new Color(0.55f, 0.92f, 1.0f, 0.98f), 12f);
|
||||||
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 135f * 135f)
|
|
||||||
{
|
|
||||||
SpawnFlashLight(pos + normal * 0.3f, new Color(0.45f, 0.90f, 1.0f), 3.2f, 10.5f, 0.12f, priority: 5);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -816,7 +861,7 @@ public partial class ParticlePool : Node3D
|
||||||
bool hasCam,
|
bool hasCam,
|
||||||
Func<float, float, Color> sampleGroundTint)
|
Func<float, float, Color> sampleGroundTint)
|
||||||
{
|
{
|
||||||
if (hasCam && pos.DistanceSquaredTo(camPos) > 220f * 220f)
|
if (hasCam && pos.DistanceSquaredTo(camPos) > 160f * 160f)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -824,7 +869,7 @@ public partial class ParticlePool : Node3D
|
||||||
float sizeScale = Math.Clamp(massKg / 2800f, 0.85f, 1.55f);
|
float sizeScale = Math.Clamp(massKg / 2800f, 0.85f, 1.55f);
|
||||||
Color gTint = sampleGroundTint(pos.X, pos.Z);
|
Color gTint = sampleGroundTint(pos.X, pos.Z);
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
SpawnParticle(new ParticleSlot
|
SpawnParticle(new ParticleSlot
|
||||||
{
|
{
|
||||||
|
|
@ -834,19 +879,19 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = new Vector3(NextSigned() * 2.4f, 2.2f + NextFloat() * 2.8f, NextSigned() * 2.4f),
|
Velocity = new Vector3(NextSigned() * 2.4f, 2.2f + NextFloat() * 2.8f, NextSigned() * 2.4f),
|
||||||
Gravity = -0.35f,
|
Gravity = -0.35f,
|
||||||
Drag = 1.4f,
|
Drag = 1.4f,
|
||||||
StartSize = 1.3f * sizeScale,
|
StartSize = 1.1f * sizeScale,
|
||||||
EndSize = 4.2f * sizeScale,
|
EndSize = MathF.Min(3.8f, 2.7f * sizeScale),
|
||||||
AspectY = 1f,
|
AspectY = 1f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.5f,
|
AngularVel = NextSigned() * 1.5f,
|
||||||
Emissive = 3.0f,
|
Emissive = 3.0f,
|
||||||
ColorStart = new Color(1.0f, 0.62f, 0.16f, 0.98f),
|
ColorStart = new Color(1.0f, 0.62f, 0.16f, 0.98f),
|
||||||
ColorEnd = new Color(0.22f, 0.12f, 0.08f, 0.0f),
|
ColorEnd = new Color(0.22f, 0.12f, 0.08f, 0.0f),
|
||||||
Lifetime = 0.46f + NextFloat() * 0.22f
|
Lifetime = 0.42f + NextFloat() * 0.18f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
SpawnParticle(new ParticleSlot
|
SpawnParticle(new ParticleSlot
|
||||||
{
|
{
|
||||||
|
|
@ -856,26 +901,30 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = new Vector3(NextSigned() * 2.8f, 3.0f + NextFloat() * 2.8f, NextSigned() * 2.8f),
|
Velocity = new Vector3(NextSigned() * 2.8f, 3.0f + NextFloat() * 2.8f, NextSigned() * 2.8f),
|
||||||
Gravity = -0.35f,
|
Gravity = -0.35f,
|
||||||
Drag = 1.1f,
|
Drag = 1.1f,
|
||||||
StartSize = 1.4f * sizeScale,
|
StartSize = 1.0f * sizeScale,
|
||||||
EndSize = 4.8f * sizeScale,
|
EndSize = MathF.Min(2.2f, 1.55f * sizeScale),
|
||||||
AspectY = 1f,
|
AspectY = 1f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.1f,
|
AngularVel = NextSigned() * 1.1f,
|
||||||
Emissive = 0f,
|
Emissive = 0f,
|
||||||
ColorStart = new Color(0.20f * 0.6f + gTint.R * 0.2f, 0.18f * 0.6f + gTint.G * 0.2f, 0.16f * 0.6f + gTint.B * 0.2f, 0.82f),
|
ColorStart = new Color(0.20f * 0.6f + gTint.R * 0.2f, 0.18f * 0.6f + gTint.G * 0.2f, 0.16f * 0.6f + gTint.B * 0.2f, 0.80f),
|
||||||
ColorEnd = new Color(0.10f, 0.10f, 0.10f, 0.0f),
|
ColorEnd = new Color(0.10f, 0.10f, 0.10f, 0.0f),
|
||||||
Lifetime = 0.95f + NextFloat() * 0.45f
|
Lifetime = 0.72f + NextFloat() * 0.30f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SpawnSparkBurst(pos, Vector3.Up, 8, new Color(1.0f, 0.68f, 0.22f, 0.98f), 17f);
|
SpawnSparkBurst(pos, Vector3.Up, 6, new Color(1.0f, 0.68f, 0.22f, 0.98f), 17f);
|
||||||
SpawnFlashLight(pos + new Vector3(0f, 1.2f, 0f), new Color(1.0f, 0.56f, 0.14f), 6.2f, 22f, 0.22f, priority: 10);
|
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 95f * 95f)
|
||||||
|
{
|
||||||
|
SpawnFlashLight(pos + new Vector3(0f, 1.2f, 0f), new Color(1.0f, 0.56f, 0.14f), 6.2f, 16f, 0.18f, priority: 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EmitImpactDustPlume(Vector3 pos, Vector3 normal, Color groundTint, int count, float size)
|
private void EmitImpactDustPlume(Vector3 pos, Vector3 normal, Color groundTint, int count, float size)
|
||||||
{
|
{
|
||||||
Color c0 = new(groundTint.R, groundTint.G, groundTint.B, 0.62f);
|
Color c0 = new(groundTint.R, groundTint.G, groundTint.B, 0.60f);
|
||||||
Color c1 = new(groundTint.R * 0.88f, groundTint.G * 0.88f, groundTint.B * 0.88f, 0.0f);
|
Color c1 = new(groundTint.R * 0.88f, groundTint.G * 0.88f, groundTint.B * 0.88f, 0.0f);
|
||||||
|
float endSize = MathF.Min(2.2f, size * 1.15f);
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
Vector3 vel = normal * (1.8f + NextFloat() * 2.4f) + new Vector3(NextSigned() * 1.6f, 0.8f + NextFloat() * 1.2f, NextSigned() * 1.6f);
|
Vector3 vel = normal * (1.8f + NextFloat() * 2.4f) + new Vector3(NextSigned() * 1.6f, 0.8f + NextFloat() * 1.2f, NextSigned() * 1.6f);
|
||||||
|
|
@ -887,15 +936,15 @@ public partial class ParticlePool : Node3D
|
||||||
Velocity = vel,
|
Velocity = vel,
|
||||||
Gravity = 0.45f,
|
Gravity = 0.45f,
|
||||||
Drag = 2.0f,
|
Drag = 2.0f,
|
||||||
StartSize = size * 0.42f,
|
StartSize = size * 0.40f,
|
||||||
EndSize = size * 1.35f,
|
EndSize = endSize,
|
||||||
AspectY = 1f,
|
AspectY = 1f,
|
||||||
Rotation = NextFloat() * MathF.Tau,
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
AngularVel = NextSigned() * 1.4f,
|
AngularVel = NextSigned() * 1.4f,
|
||||||
Emissive = 0f,
|
Emissive = 0f,
|
||||||
ColorStart = c0,
|
ColorStart = c0,
|
||||||
ColorEnd = c1,
|
ColorEnd = c1,
|
||||||
Lifetime = 0.38f + NextFloat() * 0.20f
|
Lifetime = 0.35f + NextFloat() * 0.16f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -965,17 +1014,18 @@ public partial class ParticlePool : Node3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float clampedRange = Math.Clamp(range, 6.5f, 22f);
|
||||||
ref FlashLightSlot slot = ref _flashLights[targetIdx];
|
ref FlashLightSlot slot = ref _flashLights[targetIdx];
|
||||||
slot.Active = true;
|
slot.Active = true;
|
||||||
slot.Priority = priority;
|
slot.Priority = priority;
|
||||||
slot.Age = 0f;
|
slot.Age = 0f;
|
||||||
slot.Duration = MathF.Max(0.04f, duration);
|
slot.Duration = MathF.Max(0.04f, duration);
|
||||||
slot.StartEnergy = energy;
|
slot.StartEnergy = energy;
|
||||||
slot.Range = range;
|
slot.Range = clampedRange;
|
||||||
slot.Color = color;
|
slot.Color = color;
|
||||||
slot.Light.Position = pos;
|
slot.Light.Position = pos;
|
||||||
slot.Light.LightColor = color;
|
slot.Light.LightColor = color;
|
||||||
slot.Light.OmniRange = range;
|
slot.Light.OmniRange = clampedRange;
|
||||||
slot.Light.LightEnergy = energy;
|
slot.Light.LightEnergy = energy;
|
||||||
slot.Light.Visible = true;
|
slot.Light.Visible = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace RustToDust.Client;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class PomDecalPool : Node3D
|
public partial class PomDecalPool : Node3D
|
||||||
{
|
{
|
||||||
public const int MaxDecals = 512;
|
public const int MaxDecals = 256;
|
||||||
private const float HeatCoolDuration = 3.5f;
|
private const float HeatCoolDuration = 3.5f;
|
||||||
private const float DetachFadeDuration = 0.35f;
|
private const float DetachFadeDuration = 0.35f;
|
||||||
private const float EndFadeDuration = 2.0f;
|
private const float EndFadeDuration = 2.0f;
|
||||||
|
|
@ -148,6 +148,28 @@ public partial class PomDecalPool : Node3D
|
||||||
UpdateAndCommit(dt);
|
UpdateAndCommit(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PrewarmShader(Vector3 nearPos)
|
||||||
|
{
|
||||||
|
EnsureInitialized();
|
||||||
|
if (ActiveCount > 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AllocateSlot(new DecalSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Age = 0f,
|
||||||
|
Lifetime = 0.04f,
|
||||||
|
TileIndex = 12f,
|
||||||
|
InitialHeat = 0f,
|
||||||
|
BaseOpacity = 0.03f,
|
||||||
|
DepthScale = 0.02f,
|
||||||
|
WorldXform = BuildSurfaceTransform(nearPos, Vector3.Up, 0.05f, 0f),
|
||||||
|
DetachedFadeRemaining = -1f
|
||||||
|
});
|
||||||
|
UpdateAndCommit(0f);
|
||||||
|
}
|
||||||
|
|
||||||
public void StampTestDecal(
|
public void StampTestDecal(
|
||||||
Vector3 worldPos,
|
Vector3 worldPos,
|
||||||
Vector3 worldNormal,
|
Vector3 worldNormal,
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ namespace RustToDust.Client;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SionMapRenderer : Node3D
|
public partial class SionMapRenderer : Node3D
|
||||||
{
|
{
|
||||||
public const float Lod1DistanceM = 650f;
|
public const float Lod1DistanceM = 520f;
|
||||||
public const float CullDistanceM = 2200f;
|
public const float CullDistanceM = 2200f;
|
||||||
public const float ShadowDistanceM = 450f;
|
public const float ShadowDistanceM = 220f;
|
||||||
private const int ChunkGridVerts = 129; // 128 quads per 512m chunk (4m spacing)
|
private const int ChunkGridVerts = 129; // 128 quads per 512m chunk (4m spacing)
|
||||||
|
|
||||||
private sealed class BuildingTileEntry
|
private sealed class BuildingTileEntry
|
||||||
|
|
@ -196,17 +196,14 @@ public partial class SionMapRenderer : Node3D
|
||||||
void fragment() {
|
void fragment() {
|
||||||
vec3 base_col = texture(surface_tex, UV).rgb;
|
vec3 base_col = texture(surface_tex, UV).rgb;
|
||||||
|
|
||||||
// Multi-scale crisp world-space micro-grain for up-close ground readability
|
// Crisp world-space micro-grain for up-close ground readability
|
||||||
float dist = length((INV_VIEW_MATRIX * vec4(0.0, 0.0, 0.0, 1.0)).xyz - v_world_pos);
|
float dist = length((INV_VIEW_MATRIX * vec4(0.0, 0.0, 0.0, 1.0)).xyz - v_world_pos);
|
||||||
float near_fade = clamp(1.0 - smoothstep(140.0, 520.0, dist), 0.12, 1.0);
|
float near_fade = clamp(1.0 - smoothstep(140.0, 480.0, dist), 0.12, 1.0);
|
||||||
float macro = (value_noise(v_world_pos.xz * 0.28) - 0.5) * 0.07;
|
float macro = (value_noise(v_world_pos.xz * 0.28) - 0.5) * 0.07;
|
||||||
float micro = (value_noise(v_world_pos.xz * 2.4) - 0.5) * 0.06;
|
float grit = (hash21(floor(v_world_pos.xz * 8.0)) - 0.5) * 0.045;
|
||||||
float grit = (hash21(floor(v_world_pos.xz * 12.0)) - 0.5) * 0.035;
|
|
||||||
|
|
||||||
float slope = 1.0 - clamp(v_world_normal.y, 0.0, 1.0);
|
float slope = 1.0 - clamp(v_world_normal.y, 0.0, 1.0);
|
||||||
float strata = (value_noise(vec2(v_world_pos.x * 0.15 + v_world_pos.z * 0.15, v_world_pos.y * 0.9)) - 0.5) * 0.10 * smoothstep(0.10, 0.35, slope);
|
vec3 col = clamp(base_col + vec3(macro + grit * near_fade), vec3(0.0), vec3(1.0));
|
||||||
|
|
||||||
vec3 col = clamp(base_col + vec3(macro + (micro + grit) * near_fade + strata), vec3(0.0), vec3(1.0));
|
|
||||||
ALBEDO = col;
|
ALBEDO = col;
|
||||||
ROUGHNESS = mix(0.88, 0.96, slope);
|
ROUGHNESS = mix(0.88, 0.96, slope);
|
||||||
METALLIC = 0.03;
|
METALLIC = 0.03;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ void vertex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
const int POM_STEPS = 10;
|
const int POM_STEPS = 6;
|
||||||
const float CELL_SIZE = 0.25;
|
const float CELL_SIZE = 0.25;
|
||||||
|
|
||||||
float tile_idx = floor(clamp(v_custom.x + 0.5, 0.0, 15.0));
|
float tile_idx = floor(clamp(v_custom.x + 0.5, 0.0, 15.0));
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,7 @@ float hash21(vec2 p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float soft_noise(vec2 p) {
|
float soft_noise(vec2 p) {
|
||||||
vec2 i = floor(p);
|
return 0.5 + 0.25 * sin(p.x * 2.7 + p.y * 1.9) + 0.25 * cos(p.y * 2.3 - p.x * 1.7);
|
||||||
vec2 f = fract(p);
|
|
||||||
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
||||||
float a = hash21(i);
|
|
||||||
float b = hash21(i + vec2(1.0, 0.0));
|
|
||||||
float c = hash21(i + vec2(0.0, 1.0));
|
|
||||||
float d = hash21(i + vec2(1.0, 1.0));
|
|
||||||
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vertex() {
|
void vertex() {
|
||||||
|
|
|
||||||
|
|
@ -1266,7 +1266,7 @@ public partial class Smoke : Node
|
||||||
Check(particles.ActiveParticleCount == afterFirst,
|
Check(particles.ActiveParticleCount == afterFirst,
|
||||||
$"Expected duplicate ShotFiredEvent #{tracerId} across dt=0 frames to spawn once, got {afterFirst} -> {particles.ActiveParticleCount}");
|
$"Expected duplicate ShotFiredEvent #{tracerId} across dt=0 frames to spawn once, got {afterFirst} -> {particles.ActiveParticleCount}");
|
||||||
|
|
||||||
// OmniLight3D[4] pool strictly capped at <= 4 active lights even under 12 simultaneous flashes
|
// OmniLight3D[2] pool strictly capped at <= 2 active lights even under 12 simultaneous flashes
|
||||||
particles.ClearAll();
|
particles.ClearAll();
|
||||||
for (int f = 0; f < 12; f++)
|
for (int f = 0; f < 12; f++)
|
||||||
{
|
{
|
||||||
|
|
@ -1279,8 +1279,8 @@ public partial class Smoke : Node
|
||||||
priority: f);
|
priority: f);
|
||||||
}
|
}
|
||||||
particles.AdvanceAndCommit(0f);
|
particles.AdvanceAndCommit(0f);
|
||||||
Check(particles.FlashLightPoolSize == 4 && particles.ActiveFlashLightCount <= 4 && particles.PeakFlashLightCount <= 4,
|
Check(particles.FlashLightPoolSize == 2 && particles.ActiveFlashLightCount <= 2 && particles.PeakFlashLightCount <= 2,
|
||||||
$"Expected OmniLight3D pool capped at <= 4, got active={particles.ActiveFlashLightCount} peak={particles.PeakFlashLightCount}");
|
$"Expected OmniLight3D pool capped at <= 2, got active={particles.ActiveFlashLightCount} peak={particles.PeakFlashLightCount}");
|
||||||
|
|
||||||
// Far walker footstep pulse (>70m static LOD, <=110m) still emits terrain-tinted dust in ParticlePool
|
// Far walker footstep pulse (>70m static LOD, <=110m) still emits terrain-tinted dust in ParticlePool
|
||||||
particles.ClearAll();
|
particles.ClearAll();
|
||||||
|
|
@ -1302,7 +1302,7 @@ public partial class Smoke : Node
|
||||||
juice.Reset();
|
juice.Reset();
|
||||||
Check(juice.IsIdle, "Expected CameraJuiceState idle after Reset");
|
Check(juice.IsIdle, "Expected CameraJuiceState idle after Reset");
|
||||||
var (aimIdleX, aimIdleY, aimIdleZ) = _main.ProbeCenterScreenAim();
|
var (aimIdleX, aimIdleY, aimIdleZ) = _main.ProbeCenterScreenAim();
|
||||||
juice.ConsumeEvents(simBatch, _main.Session.LocalContenderId, new System.Numerics.Vector3(pPos.X, pPos.Y, pPos.Z));
|
juice.ConsumeEvents(simBatch, _main.Session.LocalContenderId, new System.Numerics.Vector3(pPos.X, pPos.Y, pPos.Z), _main.Session);
|
||||||
juice.Update(0.016f, 0f, false);
|
juice.Update(0.016f, 0f, false);
|
||||||
Check(!juice.IsIdle && juice.RecoilPitchRad > 0f, "Expected CameraJuiceState recoil after local recoilless shot");
|
Check(!juice.IsIdle && juice.RecoilPitchRad > 0f, "Expected CameraJuiceState recoil after local recoilless shot");
|
||||||
var (aimJuiceX, aimJuiceY, aimJuiceZ) = _main.ProbeCenterScreenAim();
|
var (aimJuiceX, aimJuiceY, aimJuiceZ) = _main.ProbeCenterScreenAim();
|
||||||
|
|
@ -1330,6 +1330,44 @@ public partial class Smoke : Node
|
||||||
_main.Hud.ConsumeEvents(new ISimEvent[] { aiHit }, _main.Session.LocalContenderId, 1.0f, 0.2f);
|
_main.Hud.ConsumeEvents(new ISimEvent[] { aiHit }, _main.Session.LocalContenderId, 1.0f, 0.2f);
|
||||||
Check(!_main.Hud.HasActiveHitMarker, "Expected AI/other shooter hit NOT to trigger local reticle hit-marker");
|
Check(!_main.Hud.HasActiveHitMarker, "Expected AI/other shooter hit NOT to trigger local reticle hit-marker");
|
||||||
|
|
||||||
|
// Local shooter hitting Terrain / StaticCover / Airburst must produce ZERO reticle hit-marker flash
|
||||||
|
var missTerrainHit = new HitImpactEvent
|
||||||
|
{
|
||||||
|
EventId = 8810,
|
||||||
|
ShooterId = _main.Session.LocalContenderId,
|
||||||
|
IsContenderShooter = true,
|
||||||
|
TargetKind = (byte)HitTargetKind.Terrain,
|
||||||
|
TargetId = -1,
|
||||||
|
ArmorDamage = 0f,
|
||||||
|
CoreDamage = 0f,
|
||||||
|
Killed = false
|
||||||
|
};
|
||||||
|
var missCoverHit = new HitImpactEvent
|
||||||
|
{
|
||||||
|
EventId = 8811,
|
||||||
|
ShooterId = _main.Session.LocalContenderId,
|
||||||
|
IsContenderShooter = true,
|
||||||
|
TargetKind = (byte)HitTargetKind.StaticCover,
|
||||||
|
TargetId = 0,
|
||||||
|
ArmorDamage = 0f,
|
||||||
|
CoreDamage = 0f,
|
||||||
|
Killed = false
|
||||||
|
};
|
||||||
|
var missAirburstHit = new HitImpactEvent
|
||||||
|
{
|
||||||
|
EventId = 8812,
|
||||||
|
ShooterId = _main.Session.LocalContenderId,
|
||||||
|
IsContenderShooter = true,
|
||||||
|
TargetKind = (byte)HitTargetKind.StaticCover,
|
||||||
|
TargetId = -1,
|
||||||
|
IsAirburst = true,
|
||||||
|
ArmorDamage = 0f,
|
||||||
|
CoreDamage = 0f,
|
||||||
|
Killed = false
|
||||||
|
};
|
||||||
|
_main.Hud.ConsumeEvents(new ISimEvent[] { missTerrainHit, missCoverHit, missAirburstHit }, _main.Session.LocalContenderId, 1.0f, 0.2f);
|
||||||
|
Check(!_main.Hud.HasActiveHitMarker, "Expected Terrain/StaticCover/Airburst miss NOT to trigger local reticle hit-marker");
|
||||||
|
|
||||||
// Local armor hit -> Armor X-flash
|
// Local armor hit -> Armor X-flash
|
||||||
var localArmorHit = new HitImpactEvent
|
var localArmorHit = new HitImpactEvent
|
||||||
{
|
{
|
||||||
|
|
@ -1511,6 +1549,63 @@ public partial class Smoke : Node
|
||||||
|
|
||||||
Check(kestrelPitch.HasValue && bastionPitch.HasValue && bastionPitch.Value < kestrelPitch.Value,
|
Check(kestrelPitch.HasValue && bastionPitch.HasValue && bastionPitch.Value < kestrelPitch.Value,
|
||||||
$"Expected Bastion pitch ({bastionPitch}) < Kestrel pitch ({kestrelPitch})");
|
$"Expected Bastion pitch ({bastionPitch}) < Kestrel pitch ({kestrelPitch})");
|
||||||
|
|
||||||
|
// Finding 4: TerrainStampEvent(Crater) + ContenderEliminatedEvent in same batch plays impact_explosion EXACTLY ONCE
|
||||||
|
audio.ClearAll();
|
||||||
|
var victim = _main.Session.ViewState.Contenders[1];
|
||||||
|
var killEvents = new ISimEvent[]
|
||||||
|
{
|
||||||
|
new TerrainStampEvent
|
||||||
|
{
|
||||||
|
Kind = (byte)TerrainStampKind.Crater,
|
||||||
|
X = victim.X,
|
||||||
|
Z = victim.Z,
|
||||||
|
Radius = 4.2f,
|
||||||
|
Depth = 0.3f
|
||||||
|
},
|
||||||
|
new ContenderEliminatedEvent
|
||||||
|
{
|
||||||
|
VictimId = victim.Id,
|
||||||
|
KillerId = _main.Session.LocalContenderId,
|
||||||
|
IsSpectatorKiller = false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
audio.ConsumeSimEvents(_main.Session, killEvents, listener);
|
||||||
|
int expCount = audio.CountActiveVoicesForClip("impact_explosion");
|
||||||
|
int ejectCount = audio.CountActiveVoicesForClip("mech_eject");
|
||||||
|
Check(expCount == 1 && ejectCount == 1,
|
||||||
|
$"Expected kill crater+eliminated batch to play impact_explosion=1 & mech_eject=1, got exp={expCount} eject={ejectCount}");
|
||||||
|
|
||||||
|
// Finding 5: ResetForSession seeds loadout baselines so first equip (1 -> 2) plays mech_quick_bolt
|
||||||
|
audio.ResetForSession(_main.Session);
|
||||||
|
var equipEv = new ContenderLoadoutEvent
|
||||||
|
{
|
||||||
|
ContenderId = localC.Id,
|
||||||
|
ChassisId = localC.Grid.Spec.Id,
|
||||||
|
LoadoutVersion = localC.LoadoutVersion + 1
|
||||||
|
};
|
||||||
|
audio.ConsumeSimEvents(_main.Session, new ISimEvent[] { equipEv }, listener);
|
||||||
|
Check(audio.CountActiveUiVoicesForClip("mech_quick_bolt") == 1,
|
||||||
|
$"Expected first ContenderLoadoutEvent (1 -> 2) after ResetForSession to play mech_quick_bolt, got {audio.CountActiveUiVoicesForClip("mech_quick_bolt")}");
|
||||||
|
|
||||||
|
// Finding 3: Out-of-PVS deaths spawn zero phantom particles, lights, or audio
|
||||||
|
audio.ResetForSession(_main.Session);
|
||||||
|
var particles3 = _main.Arena.Particles;
|
||||||
|
particles3.ClearAll();
|
||||||
|
var hiddenSession = new HiddenRemoteDeathsSession(_main.Session);
|
||||||
|
var spec0 = _main.Session.ViewState.Spectators.Spectators[0];
|
||||||
|
var hiddenDeaths = new ISimEvent[]
|
||||||
|
{
|
||||||
|
new ContenderEliminatedEvent { VictimId = victim.Id, KillerId = localC.Id, IsSpectatorKiller = false },
|
||||||
|
new SpectatorDestroyedEvent { SpectatorId = spec0.Id, KillerContenderId = localC.Id }
|
||||||
|
};
|
||||||
|
particles3.ConsumeEvents(hiddenSession, hiddenDeaths, listener, hasCam: true, _main.SampleCurrentMapGroundTint);
|
||||||
|
particles3.AdvanceAndCommit(0f);
|
||||||
|
audio.ConsumeSimEvents(hiddenSession, hiddenDeaths, listener);
|
||||||
|
Check(particles3.ActiveParticleCount == 0 && particles3.ActiveFlashLightCount == 0 && audio.ActiveOneShotVoiceCount == 0,
|
||||||
|
$"Expected out-of-PVS deaths to spawn 0 VFX/SFX, got particles={particles3.ActiveParticleCount} lights={particles3.ActiveFlashLightCount} voices={audio.ActiveOneShotVoiceCount}");
|
||||||
|
particles3.ClearAll();
|
||||||
|
|
||||||
GD.Print($"SMOKE INFO: Audio verified (haven={audio.Bank.HavenClipCount}, proc={audio.Bank.ProceduralClipCount}, dummy={audio.IsDummyAudio}, kestrelPitch={kestrelPitch:F3}, bastionPitch={bastionPitch:F3})");
|
GD.Print($"SMOKE INFO: Audio verified (haven={audio.Bank.HavenClipCount}, proc={audio.Bank.ProceduralClipCount}, dummy={audio.IsDummyAudio}, kestrelPitch={kestrelPitch:F3}, bastionPitch={bastionPitch:F3})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1859,4 +1954,30 @@ public partial class Smoke : Node
|
||||||
GD.Print(_failures.Count == 0 ? "SMOKE PASS" : $"SMOKE FAILED ({_failures.Count})");
|
GD.Print(_failures.Count == 0 ? "SMOKE PASS" : $"SMOKE FAILED ({_failures.Count})");
|
||||||
GetTree().Quit(_failures.Count == 0 ? 0 : 1);
|
GetTree().Quit(_failures.Count == 0 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sealed class HiddenRemoteDeathsSession : IClientArenaSession
|
||||||
|
{
|
||||||
|
private readonly IClientArenaSession _inner;
|
||||||
|
public HiddenRemoteDeathsSession(IClientArenaSession inner) => _inner = inner;
|
||||||
|
public MatchState ViewState => _inner.ViewState;
|
||||||
|
public int LocalContenderId => _inner.LocalContenderId;
|
||||||
|
public ContenderState LocalContender => _inner.LocalContender;
|
||||||
|
public ClientMatchOutcome LocalOutcome => _inner.LocalOutcome;
|
||||||
|
public int LocalDetectedByCount => _inner.LocalDetectedByCount;
|
||||||
|
public IReadOnlyDictionary<int, PlayerContactMemory> LocalContenderContacts => _inner.LocalContenderContacts;
|
||||||
|
public IReadOnlyDictionary<int, PlayerContactMemory> LocalSpectatorContacts => _inner.LocalSpectatorContacts;
|
||||||
|
public NetworkStatusSnapshot ConnectionStatus => _inner.ConnectionStatus;
|
||||||
|
public bool IsContenderVisible(int contenderId) => contenderId == _inner.LocalContenderId;
|
||||||
|
public bool IsSpectatorVisible(int spectatorId) => false;
|
||||||
|
public void BeginRenderFrame(double dt, float physicsAlpha) => _inner.BeginRenderFrame(dt, physicsAlpha);
|
||||||
|
public void SubmitLocalInput(in PlayerInput input, bool isPhysicsTick) => _inner.SubmitLocalInput(in input, isPhysicsTick);
|
||||||
|
public void DrainSimEvents(List<ISimEvent> dest) => _inner.DrainSimEvents(dest);
|
||||||
|
public bool RequestEquipCargo(int cargoIndex, string hardpointId) => _inner.RequestEquipCargo(cargoIndex, hardpointId);
|
||||||
|
public void RequestNewMatch(int seed, ArenaMapKind mapKind) => _inner.RequestNewMatch(seed, mapKind);
|
||||||
|
public (System.Numerics.Vector3 Pos, System.Numerics.Quaternion Rot, System.Numerics.Vector3 Vel) GetInterpolatedContenderPose(int contenderId, float alpha) => _inner.GetInterpolatedContenderPose(contenderId, alpha);
|
||||||
|
public (System.Numerics.Vector3 Pos, System.Numerics.Quaternion Rot, System.Numerics.Vector3 Vel) GetInterpolatedSpectatorPose(int spectatorId, float alpha) => _inner.GetInterpolatedSpectatorPose(spectatorId, alpha);
|
||||||
|
public bool TrySampleInterpolatedWalkerPose(bool isContender, int id, float alpha, out WalkerVisualSnapshot snap) => _inner.TrySampleInterpolatedWalkerPose(isContender, id, alpha, out snap);
|
||||||
|
public ClientRayHit CastWorldRayClosest(System.Numerics.Vector3 origin, System.Numerics.Vector3 translation) => _inner.CastWorldRayClosest(origin, translation);
|
||||||
|
public void Dispose() { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1069,6 +1069,9 @@ namespace RustToDust.Net
|
||||||
c.X = nc.Pos.X; c.Y = nc.Pos.Y; c.Z = nc.Pos.Z;
|
c.X = nc.Pos.X; c.Y = nc.Pos.Y; c.Z = nc.Pos.Z;
|
||||||
c.CurrRotX = nc.Rot.X; c.CurrRotY = nc.Rot.Y; c.CurrRotZ = nc.Rot.Z; c.CurrRotW = nc.Rot.W;
|
c.CurrRotX = nc.Rot.X; c.CurrRotY = nc.Rot.Y; c.CurrRotZ = nc.Rot.Z; c.CurrRotW = nc.Rot.W;
|
||||||
c.VelX = nc.Vel.X; c.VelY = nc.Vel.Y; c.VelZ = nc.Vel.Z;
|
c.VelX = nc.Vel.X; c.VelY = nc.Vel.Y; c.VelZ = nc.Vel.Z;
|
||||||
|
c.Speed = MathF.Sqrt(c.VelX * c.VelX + c.VelZ * c.VelZ);
|
||||||
|
var forward = Vector3.Transform(Vector3.UnitZ, NormalizeQuat(nc.Rot));
|
||||||
|
c.Yaw = MathF.Atan2(forward.X, forward.Z);
|
||||||
c.AimX = nc.Pos.X + MathF.Sin(nc.AimYaw) * 25f;
|
c.AimX = nc.Pos.X + MathF.Sin(nc.AimYaw) * 25f;
|
||||||
c.AimZ = nc.Pos.Z + MathF.Cos(nc.AimYaw) * 25f;
|
c.AimZ = nc.Pos.Z + MathF.Cos(nc.AimYaw) * 25f;
|
||||||
c.AimY = nc.Pos.Y + MathF.Tan(nc.AimPitchDeg * (MathF.PI / 180f)) * 25f;
|
c.AimY = nc.Pos.Y + MathF.Tan(nc.AimPitchDeg * (MathF.PI / 180f)) * 25f;
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,52 @@ public sealed class AudioSynthTests
|
||||||
Assert.Contains(events, e => e is ShotFiredEvent);
|
Assert.Contains(events, e => e is ShotFiredEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void RemoteArenaSession_UpdatesRemoteContenderSpeedAndYawFromSnapshot()
|
||||||
|
{
|
||||||
|
using var host = new ServerMatchHost(IPAddress.Loopback, port: 0, seed: 42, mapKind: ArenaMapKind.Desert);
|
||||||
|
using var remoteA = new RemoteArenaSession(new IPEndPoint(IPAddress.Loopback, host.BoundPort), "Observer");
|
||||||
|
using var remoteB = new RemoteArenaSession(new IPEndPoint(IPAddress.Loopback, host.BoundPort), "Driver");
|
||||||
|
IClientArenaSession ifaceA = remoteA;
|
||||||
|
IClientArenaSession ifaceB = remoteB;
|
||||||
|
|
||||||
|
long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||||
|
for (int t = 0; t < 20 && (!remoteA.IsJoined || !remoteB.IsJoined); t++)
|
||||||
|
{
|
||||||
|
host.StepOnce(nowMs + t * 16);
|
||||||
|
ifaceA.BeginRenderFrame(1.0 / 60.0, 1.0f);
|
||||||
|
ifaceB.BeginRenderFrame(1.0 / 60.0, 1.0f);
|
||||||
|
}
|
||||||
|
Assert.True(remoteA.IsJoined && remoteB.IsJoined);
|
||||||
|
|
||||||
|
int idA = ifaceA.LocalContenderId;
|
||||||
|
int idB = ifaceB.LocalContenderId;
|
||||||
|
var hostA = host.Session.State.Contenders[idA];
|
||||||
|
var hostB = host.Session.State.Contenders[idB];
|
||||||
|
hostB.Grid.SwapChassis(Catalog.Jackal);
|
||||||
|
host.Session.SetContenderPose(idB, hostA.X + 20f, hostA.Z + 20f, 0.75f);
|
||||||
|
|
||||||
|
for (int t = 0; t < 25; t++)
|
||||||
|
{
|
||||||
|
ifaceA.SubmitLocalInput(new PlayerInput(0f, 0f, hostA.X, hostA.Z + 20f, false, false, false), isPhysicsTick: true);
|
||||||
|
ifaceB.SubmitLocalInput(new PlayerInput(1.0f, 0.25f, hostB.X + 30f, hostB.Z + 30f, false, false, false), isPhysicsTick: true);
|
||||||
|
host.StepOnce(nowMs + 350 + t * 16);
|
||||||
|
ifaceA.BeginRenderFrame(1.0 / 60.0, 1.0f);
|
||||||
|
ifaceB.BeginRenderFrame(1.0 / 60.0, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.True(ifaceA.IsContenderVisible(idB));
|
||||||
|
var rivalOnA = ifaceA.ViewState.Contenders[idB];
|
||||||
|
float expectedSpeed = MathF.Sqrt(rivalOnA.VelX * rivalOnA.VelX + rivalOnA.VelZ * rivalOnA.VelZ);
|
||||||
|
Assert.True(rivalOnA.Speed > 2.0f, $"Expected remote moving Jackal Speed > 2.0, got {rivalOnA.Speed}");
|
||||||
|
Assert.InRange(MathF.Abs(rivalOnA.Speed - expectedSpeed), 0f, 0.01f);
|
||||||
|
|
||||||
|
var q = Quaternion.Normalize(new Quaternion(rivalOnA.CurrRotX, rivalOnA.CurrRotY, rivalOnA.CurrRotZ, rivalOnA.CurrRotW));
|
||||||
|
var fwd = Vector3.Transform(Vector3.UnitZ, q);
|
||||||
|
float expectedYaw = MathF.Atan2(fwd.X, fwd.Z);
|
||||||
|
Assert.InRange(MathF.Abs(MatchRules.NormalizeAngle(rivalOnA.Yaw - expectedYaw)), 0f, 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
private static void AssertValidPcmBounds(PcmClipData clip, string label)
|
private static void AssertValidPcmBounds(PcmClipData clip, string label)
|
||||||
{
|
{
|
||||||
Assert.True(clip.Samples.Length > 0, $"{label} empty");
|
Assert.True(clip.Samples.Length > 0, $"{label} empty");
|
||||||
|
|
|
||||||
|
|
@ -114,4 +114,32 @@ public sealed class CameraJuiceTests
|
||||||
Assert.Equal(0f, juice.FootstepBumpY);
|
Assert.Equal(0f, juice.FootstepBumpY);
|
||||||
Assert.Equal(0f, juice.FovOffsetDeg);
|
Assert.Equal(0f, juice.FovOffsetDeg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CameraJuiceState_DeathTrauma_RequiresVisibleAndWithin90m()
|
||||||
|
{
|
||||||
|
var juice = new CameraJuiceState();
|
||||||
|
var localPos = Vector3.Zero;
|
||||||
|
|
||||||
|
// 1. Out-of-PVS (not visible) contender death even nearby -> 0.0f trauma
|
||||||
|
var hiddenDeath = new ISimEvent[]
|
||||||
|
{
|
||||||
|
new ContenderEliminatedEvent { VictimId = 3, KillerId = 1, IsSpectatorKiller = false }
|
||||||
|
};
|
||||||
|
juice.ConsumeEvents(hiddenDeath, localContenderId: 0, localPos, (_, _) => (false, new Vector3(15f, 0f, 0f)));
|
||||||
|
Assert.Equal(0.0f, juice.Trauma);
|
||||||
|
|
||||||
|
// 2. Visible but distant (>= 90m) contender death -> 0.0f trauma
|
||||||
|
juice.ConsumeEvents(hiddenDeath, localContenderId: 0, localPos, (_, _) => (true, new Vector3(120f, 0f, 0f)));
|
||||||
|
Assert.Equal(0.0f, juice.Trauma);
|
||||||
|
|
||||||
|
// 3. No resolver/session -> 0.0f trauma (never global)
|
||||||
|
juice.ConsumeEvents(hiddenDeath, localContenderId: 0, localPos);
|
||||||
|
Assert.Equal(0.0f, juice.Trauma);
|
||||||
|
|
||||||
|
// 4. Nearby visible death (20m) -> positive scaled trauma: 0.14 * (1 - 20 / 90)
|
||||||
|
juice.ConsumeEvents(hiddenDeath, localContenderId: 0, localPos, (_, _) => (true, new Vector3(20f, 0f, 0f)));
|
||||||
|
float expected = 0.14f * (1f - 20f / 90f);
|
||||||
|
Assert.InRange(juice.Trauma, expected - 1e-4f, expected + 1e-4f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue