Complete the DamageEvent migration: one deal() entry point for every attacker

The bull's Hitbox already routed through DamageEvent, but the spear, the bear's
maul, and the matador's reach-gore still did raw Object.call(&"take_sword_hit", ...)
— the exact scattered string paths DamageEvent was meant to retire. Add a single
static DamageEvent.deal(target, cause, at, source, knock_up) that builds the typed
event and hands it to receive_damage(), falling back to the legacy string call for
any not-yet-migrated victim, and route all four attackers (Hitbox included) through
it. The damage_pipeline characterization test proves the bull's outcomes are
unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq1VX2o1ZfiNRdCjD294wf
This commit is contained in:
2026-09-05 10:52:10 +03:00
parent ffe3052468
commit 9c4563a973
5 changed files with 23 additions and 14 deletions
+18
View File
@@ -37,6 +37,24 @@ static func make(kind: Cause, at: Vector3, src: Node = null) -> DamageEvent:
return e
## The single entry point every attacker uses to wound a target: build the typed event and hand it
## to receive_damage(). Falls back to the legacy string call for any target not yet migrated, so a
## caller never has to branch on which contract the victim speaks. `knock_up_v` is the already-shaped
## pop (0 = grounded); callers that scale it by distance compute it before calling.
static func deal(target: Node, kind: Cause, at: Vector3, src: Node = null, knock_up_v: float = 0.0) -> void:
if target == null:
return
if target.has_method(&"receive_damage"):
var event := make(kind, at, src)
event.knock_up = knock_up_v
target.call(&"receive_damage", event)
return
if target.has_method(&"take_sword_hit"):
target.call(&"take_sword_hit", make(kind, at, src).cause_name(), at)
if knock_up_v > 0.0 and target.has_method(&"apply_knock_up"):
target.call(&"apply_knock_up", knock_up_v)
## Lower-case name of the cause, for logs and for the bull's existing cause-keyed reactions
## ("gored" / "mauled" / "thrown") during the migration off string causes.
func cause_name() -> String: