diff options
author | Colin Okay <colin@cicadas.surf> | 2022-07-29 07:38:00 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-07-29 07:38:00 -0500 |
commit | 46190e6e709ea1c411a8867e166f44081f4e4273 (patch) | |
tree | 1ced5947a0c2151e7f2fe3c0ed60e2e4f6266e05 /src/wheelwork.lisp | |
parent | 54b626cd2934aa01d12f6a26a2d30dc026bb06e3 (diff) |
[add] drop-unit-if
Diffstat (limited to 'src/wheelwork.lisp')
-rw-r--r-- | src/wheelwork.lisp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/wheelwork.lisp b/src/wheelwork.lisp index da432ba..b4c5431 100644 --- a/src/wheelwork.lisp +++ b/src/wheelwork.lisp @@ -9,17 +9,20 @@ (defmethod add-unit ((unit unit)) "Adds a unit to the display." - (assert *application*) (vector-push-extend unit (application-scene *application*) (1+ (length (application-scene *application*)))) (setf (unit-in-scene-p unit) t)) (defgeneric drop-unit (unit)) (defmethod drop-unit ((unit unit)) "A removes a unit from the display." - (assert *application*) + (setf (unit-in-scene-p unit) nil) (setf (application-scene *application*) - (delete unit (application-scene *application*))) - (setf (unit-in-scene-p unit) nil)) + (delete unit (application-scene *application*)))) + +(defun drop-unit-if (predicate) + "Removes all units from scene that satisfy the predicate." + (setf (application-scene *application*) + (delete-if predicate (application-scene *application*)))) (defun start (app &key (x :centered) (y :centered)) (sdl2:with-init (:everything) |