diff --git a/modules/game/actors.scm b/modules/game/actors.scm index 6bc7502..5403c12 100644 --- a/modules/game/actors.scm +++ b/modules/game/actors.scm @@ -436,6 +436,7 @@ (define (^gate bcom x y) (define position (vector x y 1)) (define open? (spawn ^cell)) + (define activations (spawn ^cell 0)) (match-lambda* (('type) 'gate) (('position) position) @@ -444,11 +445,17 @@ (('enter obj grid-info) #f) (('exit obj grid-info) #f) (('activate grid-info) - ($ open? #t) - ($ grid-info 'append-event `(gate-open ,x ,y))) + (let ((k (1+ ($ activations)))) + ($ activations k) + (unless (> k 1) + ($ open? #t) + ($ grid-info 'append-event `(gate-open ,x ,y))))) (('deactivate grid-info) - ($ open? #f) - ($ grid-info 'append-event `(gate-close ,x ,y))) + (let ((k (1- ($ activations)))) + ($ activations k) + (when (= k 0) + ($ open? #f) + ($ grid-info 'append-event `(gate-close ,x ,y))))) (('wire-state grid-info from from-x from-y) #f) (('update-wire-state grid-info neighbor-grid) #f) (('alive?) #t)