aboutsummaryrefslogtreecommitdiff
path: root/prefabs.scm
diff options
context:
space:
mode:
Diffstat (limited to 'prefabs.scm')
-rw-r--r--prefabs.scm10
1 files changed, 4 insertions, 6 deletions
diff --git a/prefabs.scm b/prefabs.scm
index 5ae1255..819a382 100644
--- a/prefabs.scm
+++ b/prefabs.scm
@@ -14,7 +14,7 @@
(define (engine-mixins)
'((physics-body #:vx 0 #:vy 0 #:ay 0 #:gravity? #t #:solid? #t #:on-ground? #f)
(has-facing #:facing 1)
- (animated #:anim-name idle #:anim-frame 0 #:anim-tick 0 #:tile-id 0)))
+ (animated #:anim-name idle #:anim-frame 0 #:anim-tick 0 #:tile-id 0 #:animations #t)))
;; Compose a prefab entry with mixin table
;; Returns (name . merged-plist)
@@ -79,11 +79,11 @@
(define (load-prefabs file engine-mixin-table user-hooks)
(let* ((data (with-input-from-file file read))
- (mixin-section (cdr (assq 'mixins data)))
+ (mixin-section (if (assq 'mixins data) (cdr (assq 'mixins data)) '()))
(prefab-section (cdr (assq 'prefabs data)))
(group-section (cond ((assq 'group-prefabs data) => cdr) (else '())))
;; user mixins first → user wins on assq lookup (overrides engine mixin by name)
- (user-mixin-table (map (lambda (m) (cons (car m) (cdr m))) mixin-section))
+ (user-mixin-table (if (null? mixin-section) '() (map (lambda (m) (cons (car m) (cdr m))) mixin-section)))
(merged-mixin-table (append user-mixin-table engine-mixin-table))
;; user-hooks first → user wins on assq lookup (overrides engine hooks by name)
(hook-table (append user-hooks *engine-hooks*))
@@ -109,9 +109,7 @@
(let ((entry (assq type (prefab-registry-prefabs registry))))
(if (not entry)
#f
- ;; instance fields prepended → highest priority
- (let* ((base (append (make-entity x y w h)
- (cdr entry)))
+ (let* ((base (append (cdr entry) (make-entity x y w h)))
(hook-val (entity-ref base #:on-instantiate #f))
(handler
(cond