aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-07-29 07:38:00 -0500
committerColin Okay <colin@cicadas.surf>2022-07-29 07:38:00 -0500
commit46190e6e709ea1c411a8867e166f44081f4e4273 (patch)
tree1ced5947a0c2151e7f2fe3c0ed60e2e4f6266e05
parent54b626cd2934aa01d12f6a26a2d30dc026bb06e3 (diff)
[add] drop-unit-if
-rw-r--r--src/wheelwork.lisp11
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)