X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fsystem.scm;h=2bf05208fefb215eec76c28e3075ce0a3f56e218;hb=c62dceb1471afb94efa57eef5506fbdf6f2ef679;hp=b70bfee062527580b7560bcc686d45eb32b13ab5;hpb=7daac782bf89c735e87131f8dc9c04a396415d5a;p=gacela.git diff --git a/src/system.scm b/src/system.scm index b70bfee..2bf0520 100644 --- a/src/system.scm +++ b/src/system.scm @@ -123,14 +123,16 @@ (register-components key (map (lambda (c) (car c)) nc) components) - key)))) + (cons key nc))))) (define (remove-entity key) (lambda (entities components) - (let ((clist (map (lambda (c) (car c)) (assoc-ref entities key)))) + (let ((clist (map (lambda (c) (car c)) (assoc-ref entities key))) + (entity (assoc key entities))) (values (assoc-remove! entities key) - (unregister-components key clist components))))) + (unregister-components key clist components) + entity)))) (define (set-entity key . new-components) (lambda (entities components) @@ -140,7 +142,8 @@ (values (assoc-set! entities key nc) (register-components key (lset-difference eq? nclist clist) - (unregister-components key (lset-difference eq? clist nclist) components)))))) + (unregister-components key (lset-difference eq? clist nclist) components)) + (cons key nc))))) (define (set-entity-components key . new-components) (lambda (entities components) @@ -152,7 +155,8 @@ nc) (values (assoc-set! entities key clist) - (register-components key (map (lambda (c) (car c)) nc) components))))) + (register-components key (map (lambda (c) (car c)) nc) components) + (cons key clist))))) (define (remove-entity-components key . old-components) (lambda (entities components) @@ -163,7 +167,8 @@ old-components) (values (assoc-set! entities key clist) - (unregister-components key old-components components))))) + (unregister-components key old-components components) + (cons key clist))))) (define (modify-entities changes entities components) (cond ((null? changes) @@ -242,11 +247,20 @@ (receive (e2 c2) ((join-thread (car thd)) e c) (run-wait (cdr thd) e2 c2))))))) +(define (group-systems . systems) + (cond ((null? systems) + (make-system ())) + ((= (length systems) 1) + (car systems)) + (else + (join-systems systems)))) + (export find-entities-by-components define-system make-system join-systems - threaded-systems) + threaded-systems + group-systems) ;;; Entities and components access inside systems