From 46190e6e709ea1c411a8867e166f44081f4e4273 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 29 Jul 2022 07:38:00 -0500 Subject: [add] drop-unit-if --- src/wheelwork.lisp | 11 +++++++---- 1 file 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) -- cgit v1.2.3