#:use-module (oop goops)
#:export (<gameobj>
+ create-gameobj
gameobj-loc
gameobj-gm
;;; gameobj message handlers
;;; ========================
+;; TODO: This init stuff is a mess, and should be redone now that
+;; we have the *init* action stuff. We've really spread out the
+;; logic for creating a gameobj in several places, eg gm-inject-special!
+(define (create-gameobj class gm loc . args)
+ "Create a gameobj of CLASS with GM and set to location LOC, applying rest of ARGS.
+Note that this doesn't do any special dyn-ref of the location."
+ (let ((new-gameobj (apply create-actor (%current-actor) class
+ #:gm gm args)))
+ ;; Set the location
+ (<-wait new-gameobj 'set-loc! #:loc loc)
+ ;; Initialize the object
+ (<-wait new-gameobj 'init)))
+
+;; ;; @@: Should we also dyn-ref the loc here? We can do that, unlike with
+;; ;; create-gameobj.
+;; ;; Another route could be to have set-loc! itself know how to use the
+;; ;; dyn-ref.
+;; (define (gameobj-create-gameobj gameobj class loc . args)
+;; "Like create-gameobj but saves the step of passing in the gm."
+;; (apply create-gameobj class (gameobj-gm gameobj) loc args))
+
;; Kind of a useful utility, maybe?
(define (simple-slot-getter slot)
(lambda (actor message)
(match special-symbol
;; if it's a symbol, look it up dynamically
((? symbol? _)
+ ;; TODO: If we get back an #f at this point, should we throw
+ ;; an error? Obviously #f is okay, but maybe not if
(mbody-val (<-wait (slot-ref gameobj 'gm) 'lookup-special
#:symbol special-symbol)))
;; if it's false, return nothing