From 1cb85bd682a8e10f3eec9b91f58b419b714c48c5 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 24 May 2024 16:57:17 -0400 Subject: [PATCH] Allow blocks to be pushed through gates. --- modules/game/actors.scm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/game/actors.scm b/modules/game/actors.scm index ecfeb03..6bc7502 100644 --- a/modules/game/actors.scm +++ b/modules/game/actors.scm @@ -154,14 +154,17 @@ (#(w h) (let ((x (modulo (+ x dx) w)) (y (modulo (+ y dy) h))) - (let ((occupant-types - (map (lambda (obj) ($ obj 'type)) - ($ grid-info 'occupants x y)))) - (match occupant-types - ((or () ('switch)) - ($ pushed? #t) - ($ position (vector x y z))) - (_ #f)))))))))))) + (define (do-push) + ($ pushed? #t) + ($ position (vector x y z))) + (match ($ grid-info 'occupants x y) + (() (do-push)) + ((obj) + (match ($ obj 'type) + ('switch (do-push)) + ('gate (when ($ obj 'open?) (do-push))) + (_ (values)))) + (_ (values)))))))))))) (('pushed?) ($ pushed?)))) (define (^clock-emitter bcom x y interval)