* src/system.scm: get-key
get-component
* src/examples/making-systems.scm: access functions testing
(define-component a x y)
+(define-system (s1)
+ (lambda (e)
+ (list (new-entity (make-a 1 2))
+ (new-entity (make-a 10 20)))))
+
+(define-system (s2 a)
+ (lambda (e)
+ (for-each
+ (lambda (e1)
+ (format #t "Key: ~a Component: ~a~%" (get-key e1) (get-component 'a e1)))
+ e)
+ '()))
+
(define (making-systems)
(let ((entities '())
(components '()))
- (receive (e c) (((make-system () (lambda (e) (list (new-entity (make-a 1 2)) (new-entity (make-a 10 20))))) entities components))
+ (receive (e c) ((s1 entities components))
(set! entities e)
(set! components c))
(format #t "Two new entities with a:~%~a~%~a~%~%" entities components)
- (((make-system (a) (lambda (e) (display e) (newline) '())) entities components))))
+ ((s2 entities components))))
(export making-systems)
make-system
join-systems
threaded-systems)
+
+
+;;; Entities and components access inside systems
+
+(define (get-key entity)
+ (car entity))
+
+(define (get-component component-name entity)
+ (assoc-ref (cdr entity) component-name))
+
+
+(export get-key
+ get-component)