Function name changes and state exports
This commit is contained in:
parent
700b7a9cda
commit
2a4945d9c7
1 changed files with 11 additions and 6 deletions
|
|
@ -10,6 +10,11 @@
|
|||
(srfi 113)
|
||||
(srfi 128))
|
||||
|
||||
;; We export the world, component sets, systems, and event buses so that the core can be extended to
|
||||
;; include serialization functions across all.
|
||||
;; NOTE: direct read/write to these is undefined, and will cause problems.
|
||||
(export world component-sets systems event-buses)
|
||||
|
||||
;; The world hash table
|
||||
(define world (make-hash-table))
|
||||
;; The component-sets hash table
|
||||
|
|
@ -33,7 +38,7 @@
|
|||
|
||||
;; Create an entity in the world immediately,
|
||||
;; and add it to the requisite component-sets
|
||||
(define (create-entity id components)
|
||||
(define (create-entity-now id components)
|
||||
(hash-table-set! world id components)
|
||||
(for-each
|
||||
(lambda (component)
|
||||
|
|
@ -41,7 +46,7 @@
|
|||
components))
|
||||
|
||||
;; Remove a single matching item from a set
|
||||
(define (set-remove! set element)
|
||||
(define (remove-from-set! set element)
|
||||
(set-search! set element
|
||||
(lambda (insert ignore)
|
||||
(ignore #f))
|
||||
|
|
@ -50,11 +55,11 @@
|
|||
|
||||
;; Remove an entity from the world immediately,
|
||||
;; as well as from all component sets.
|
||||
(define (remove-entity id)
|
||||
(define (remove-entity-now id)
|
||||
(hash-table-delete! world id)
|
||||
(for-each
|
||||
(lambda (set)
|
||||
(set-remove! set id))
|
||||
(remove-from-set! set id))
|
||||
(hash-table-values component-sets)))
|
||||
|
||||
;; Queues for entity creation and deletion
|
||||
|
|
@ -78,7 +83,7 @@
|
|||
(lambda (entity)
|
||||
(let ((id (car entity))
|
||||
(components (cdr entity)))
|
||||
(create-entity id components)))
|
||||
(create-entity-now id components)))
|
||||
add-entity-queue)
|
||||
(set! add-entity-queue '()))
|
||||
|
||||
|
|
@ -86,7 +91,7 @@
|
|||
(define (remove-queued-entities)
|
||||
(for-each
|
||||
(lambda (id)
|
||||
(remove-entity id))
|
||||
(remove-entity-now id))
|
||||
del-entity-queue)
|
||||
(set! del-entity-queue '()))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue