diff options
Diffstat (limited to 'entity.scm')
| -rw-r--r-- | entity.scm | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -27,6 +27,36 @@ (define (entity-update entity key proc #!optional default) (entity-set entity key (proc (entity-ref entity key default)))) + ;; #:skip-pipelines — list of symbols naming frame pipeline steps to skip for this + ;; entity. Physics documents the built-in step names (see docs/physics.org). Other + ;; subsystems (e.g. animation, rendering) may reserve additional symbols later and + ;; use the same predicate and define-pipeline macro. + + (define (entity-skips-pipeline? entity step) + (let ((skips (entity-ref entity #:skip-pipelines '()))) + (and (pair? skips) (memq step skips)))) + + ;; er-macro-transformer so (rename 'entity-skips-pipeline?) captures the + ;; binding from THIS module — works across compiled unit boundaries. + (define-syntax define-pipeline + (er-macro-transformer + (lambda (form rename _compare) + (let* ((name-skip (cadr form)) + (name (car name-skip)) + (skip (cadr name-skip)) + (formals (caddr form)) + (f1 (car formals)) + (body (cdddr form)) + (%define (rename 'define)) + (%if (rename 'if)) + (%let (rename 'let)) + (%quote (rename 'quote)) + (%skip? (rename 'entity-skips-pipeline?))) + `(,%define (,name ,@formals) + (,%if (,%skip? ,f1 (,%quote ,skip)) + ,f1 + (,%let () ,@body))))))) + (define (make-player-entity x y width height) (list #:type 'player #:x x |
