A7: Visual effects, hit marker and hurt flash
EffectsView (src/client/effects/) draws muzzle flashes at the held weapon's muzzle, tracer ribbons to each pellet's impact (and streaks behind projectiles in flight), hit bursts on players, chips and dust by material or ground, keg blasts with fireball, debris, smoke and a light, build dust, collapse clouds for broken pieces, splashes and surge spray. Particles are simulated on the CPU in packed arrays and drawn by two MultiMeshes (blended and added) through a small billboard shader that reads each particle's size from custom data (the stock billboard modes drop the instance scale) and converts Palette's sRGB colours. Pools are allocated once at the preset's budget (256/512/1024 particles, 64 tracers, 4 lights): three draw calls whatever happens. The HUD gains a reticle, four ticks round it when your shot strikes a player (HitFeedback), and a rust flash at the screen's edge when hurt. Tests: test_effects_view (12), including a 24-shooter stress scene that stays inside each budget and never adds nodes. Captures: make effects-captures (fight, blast, work, stress), checked by eye, and the blast in the Compatibility renderer. Closes #47 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,8 @@ var _viewed: Simulation = null
|
||||
var _status: Label = null
|
||||
## ClientGame.fx_received when the figures last heard the FX.
|
||||
var _fx_seen: int = 0
|
||||
## The hit marker and hurt flash (A7).
|
||||
var feedback: HitFeedback = HitFeedback.new()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
@@ -158,13 +160,20 @@ func _process(delta: float) -> void:
|
||||
if _status != null:
|
||||
_status.text = status_text()
|
||||
if hud != null:
|
||||
hud.show_state(hud_state())
|
||||
var state: HudState = hud_state()
|
||||
feedback.update(state.health if state.playing else -1, delta)
|
||||
state.hit = feedback.hit()
|
||||
state.hurt = feedback.hurt()
|
||||
hud.show_state(state)
|
||||
_show_charts(delta)
|
||||
|
||||
|
||||
## What the HUD should show now.
|
||||
func hud_state() -> HudState:
|
||||
return HudState.from_client(game, input, own_handle())
|
||||
var state: HudState = HudState.from_client(game, input, own_handle())
|
||||
state.hit = feedback.hit()
|
||||
state.hurt = feedback.hurt()
|
||||
return state
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
@@ -221,7 +230,10 @@ func _show(delta: float) -> void:
|
||||
var fresh: int = mini(game.fx_received - _fx_seen, game.fx.size())
|
||||
_fx_seen = game.fx_received
|
||||
if fresh > 0:
|
||||
view.entities.hear(game.fx.slice(game.fx.size() - fresh))
|
||||
var records: Array[Dictionary] = game.fx.slice(game.fx.size() - fresh)
|
||||
view.entities.hear(records)
|
||||
view.effects.hear(records)
|
||||
feedback.hear(records, mirror.own_id)
|
||||
_show_ghost()
|
||||
if mirror.own_id != 0:
|
||||
# The player's own look is newer than any command made from it.
|
||||
|
||||
Reference in New Issue
Block a user