Add get-entity
This commit is contained in:
parent
4f8ca4d97b
commit
c7373bccf8
2 changed files with 8 additions and 1 deletions
|
|
@ -102,7 +102,12 @@
|
||||||
(add-queued-entities))
|
(add-queued-entities))
|
||||||
|
|
||||||
;; Entity creation/removal interface
|
;; Entity creation/removal interface
|
||||||
(export create-named-entity create-entity remove-entity clear-world)
|
(export create-named-entity create-entity remove-entity
|
||||||
|
get-entity clear-world)
|
||||||
|
|
||||||
|
(define (get-entity id)
|
||||||
|
(assert (symbol? id))
|
||||||
|
(hash-table-ref world id))
|
||||||
|
|
||||||
;; Create an entity in the world and return it's ID
|
;; Create an entity in the world and return it's ID
|
||||||
(define (create-named-entity id . components)
|
(define (create-named-entity id . components)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
(check (hash-table-exists? world 'ball) => #t)
|
(check (hash-table-exists? world 'ball) => #t)
|
||||||
(check (hash-table-exists? component-sets '<point>) => #t)
|
(check (hash-table-exists? component-sets '<point>) => #t)
|
||||||
|
|
||||||
|
(check (point? (car (get-entity 'ball))) => #t) ;; Get entity retrieves the entity components
|
||||||
|
|
||||||
(clear-world)
|
(clear-world)
|
||||||
(check (hash-table-size world) => 1) ;; World state does not immediately clear
|
(check (hash-table-size world) => 1) ;; World state does not immediately clear
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue