Add scene-authored FX effect library and Fx autoload
Replace code-buried CPUParticles with inspector-editable effect scenes fired through one Fx autoload: code names the effect (Fx.spawn(&"blood_burst", xform)), the .tscn owns the look. Ships four placeholder effects (blood_burst, slam_dust, spark, hit_flash) seeded from the old code params, a self-freeing one_shot_effect root helper, a live preview gallery, and an FX style guide for Siim. CPUParticles only (mobile GLES3 constraint). Existing call sites untouched -- migrated later. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
extends CPUParticles3D
|
||||
## Root helper for a one-shot effect scene: fires this emitter (and any CPUParticles3D children)
|
||||
## once when spawned, then frees the whole scene after the longest-lived particle has died. This
|
||||
## is what lets an effect be nothing but a tunable CPUParticles3D scene — no per-effect code, so
|
||||
## Siim owns the look entirely in the inspector. Fired by the Fx autoload; see fx/README.md.
|
||||
|
||||
const _FREE_MARGIN := 0.5
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var ttl := _arm(self)
|
||||
for emitter: CPUParticles3D in _child_emitters():
|
||||
ttl = maxf(ttl, _arm(emitter))
|
||||
get_tree().create_timer(ttl + _FREE_MARGIN).timeout.connect(queue_free)
|
||||
|
||||
|
||||
func _arm(p: CPUParticles3D) -> float:
|
||||
p.one_shot = true
|
||||
p.emitting = true
|
||||
return p.lifetime
|
||||
|
||||
|
||||
func _child_emitters() -> Array[CPUParticles3D]:
|
||||
var out: Array[CPUParticles3D] = []
|
||||
_gather(self, out)
|
||||
return out
|
||||
|
||||
|
||||
func _gather(node: Node, out: Array[CPUParticles3D]) -> void:
|
||||
for child: Node in node.get_children():
|
||||
if child is CPUParticles3D:
|
||||
out.append(child)
|
||||
_gather(child, out)
|
||||
Reference in New Issue
Block a user