From 61b8cecc0b7e22e85f70d19c8e218efb2a472499 Mon Sep 17 00:00:00 2001 From: stevenhowes <38082088+stevenhowes@users.noreply.github.com> Date: Sun, 27 Mar 2022 17:13:18 +0100 Subject: [PATCH] Allow easy killing (with animation) of anything that has a DR. Useful for plausibly disposing of projectiles. --- component_damage_receiver.go | 3 +++ element.go | 1 + 2 files changed, 4 insertions(+) diff --git a/component_damage_receiver.go b/component_damage_receiver.go index e141515..bdb8912 100644 --- a/component_damage_receiver.go +++ b/component_damage_receiver.go @@ -25,6 +25,9 @@ func (dr *damageReceiver) onDraw() error { } func (dr *damageReceiver) onUpdate() error { + if dr.container.Kill { + dr.health = -1 + } // If we're out of health if dr.health <= 0 { // If we have an animator, run the destroy sequence diff --git a/element.go b/element.go index 88f4370..3806181 100644 --- a/element.go +++ b/element.go @@ -21,6 +21,7 @@ type Element struct { Rotation float64 Active bool Delete bool + Kill bool Collisions []Circle components []component parentElement *Element