Cut 5d-2: ParticlePool + OmniLight3D[4], CameraJuiceState, Hud hit-markers & vignette, unified SimEvent drain

This commit is contained in:
Meta Vens 2026-12-05 10:14:54 +01:00
commit 323c02cf8d
12 changed files with 2294 additions and 320 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using Godot;
using RustToDust.Core;
@ -41,7 +42,6 @@ public partial class PomDecalPool : Node3D
private readonly DecalSlot[] _slots = new DecalSlot[MaxDecals];
private int _writeCursor;
private long _lastProcessedHitId;
private MatchState? _boundState;
private MultiMesh _multiMesh = null!;
@ -110,7 +110,6 @@ public partial class PomDecalPool : Node3D
{
Array.Clear(_slots, 0, _slots.Length);
_writeCursor = 0;
_lastProcessedHitId = 0;
ActiveCount = 0;
if (_multiMesh is not null)
{
@ -119,8 +118,9 @@ public partial class PomDecalPool : Node3D
}
}
public void Sync(
public void ConsumeEvents(
IClientArenaSession session,
IReadOnlyList<ISimEvent> events,
float dt,
Func<bool, int, VehicleVisualInstance?> getVisual)
{
@ -132,16 +132,17 @@ public partial class PomDecalPool : Node3D
ClearAll();
}
var hits = state.HitEvents;
for (int i = 0; i < hits.Count; i++)
for (int i = 0; i < events.Count; i++)
{
var ev = hits[i];
if (ev.EventId <= _lastProcessedHitId)
switch (events[i])
{
continue;
case MatchResetEvent:
ClearAll();
break;
case HitImpactEvent hit:
StampHit(in hit, state, getVisual);
break;
}
_lastProcessedHitId = ev.EventId;
StampHit(ev, state, getVisual);
}
UpdateAndCommit(dt);
@ -172,23 +173,25 @@ public partial class PomDecalPool : Node3D
}
private void StampHit(
in HitFeedbackEvent ev,
in HitImpactEvent ev,
MatchState state,
Func<bool, int, VehicleVisualInstance?> getVisual)
{
if (ev.IsAirburst && ev.TargetKind == HitTargetKind.StaticCover && ev.TargetId < 0)
var targetKind = (HitTargetKind)ev.TargetKind;
var weaponClass = (WeaponVisualClass)ev.WeaponClass;
if (ev.IsAirburst && targetKind == HitTargetKind.StaticCover && ev.TargetId < 0)
{
return;
}
bool isVehicle = ev.TargetKind == HitTargetKind.Contender || ev.TargetKind == HitTargetKind.Spectator;
bool isVehicle = targetKind == HitTargetKind.Contender || targetKind == HitTargetKind.Spectator;
int tile;
float size;
float heat;
float depth;
float lifetime;
switch (ev.WeaponClass)
switch (weaponClass)
{
case WeaponVisualClass.ThermalBeam:
tile = string.Equals(ev.WeaponId, "gilded_lance", StringComparison.Ordinal) || !isVehicle
@ -235,7 +238,7 @@ public partial class PomDecalPool : Node3D
if (isVehicle)
{
bool isContender = ev.TargetKind == HitTargetKind.Contender;
bool isContender = targetKind == HitTargetKind.Contender;
VehicleVisualInstance? vis = getVisual(isContender, ev.TargetId);
if (vis is null || !vis.Root.IsInsideTree() || !vis.Root.Visible)
{