slot-ref-maybe-runcheck
val-or-run
+ build-props
dyn-ref
;; Some of the more common commands
;;; Gameobj
;;; =======
+(define build-props build-rmeta-slot)
;;; *all* game components that talk to players should somehow
;;; derive from this class.
;; props by default only have a 'get-prop read-only action handler;
;; any coordination of setting a prop between actors must be
;; added to that actor, to keep things from getting out of control.
- (props #:init-thunk make-hash-table)
+ (props #:init-thunk make-hash-table
+ #:init-keyword #:props)
;; gameobjs may inherit an initial list of these via the
;; initial-props slot, which must always have its
- ;; #:allocation #:each-subclass and use (build-rmeta-slot).
+ ;; #:allocation #:each-subclass and use (build-props) for the
+ ;; #:init-thunk.
;; The vanilla gameobj has no props, on purpose.
(initial-props #:allocation #:each-subclass
- #:init-thunk (build-rmeta-slot '()))
+ #:init-thunk (build-props '()))
;; Most objects are generally visible by default
(invisible? #:init-value #f
(define props (slot-ref gameobj 'props))
(maybe-build-rmeta-slot-cache! class 'initial-props
eq? hashq-set! hashq-ref)
+ ;; Kind of a kludge... we read through the rmeta-slot-cache
+ ;; and use that to build up the table
(hash-for-each
(lambda (key value)
- (hashq-set! props key value))
- (rmeta-slot-table (class-slot-ref class 'initial-props))))
+ (when (not (hashq-ref props key value)) ; don't override init'ed instance values
+ (hashq-set! props key value)))
+ (rmeta-slot-cache (class-slot-ref class 'initial-props))))
;; TODO: Use the *init* action?
;; We could also use a generic method if they didn't have