X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=blobdiff_plain;f=mudsync%2Fgameobj.scm;h=9046520bbb9ba7dc396dcfa4bec301117f85f716;hp=b686e3cbd74a4d2d41825f0f5f5777290b8357f4;hb=31d4d0fb22546efe897756ad00699d44907c7737;hpb=7e11c67b59dc07a46576b2acaa4657ee533df7d5 diff --git a/mudsync/gameobj.scm b/mudsync/gameobj.scm index b686e3c..9046520 100644 --- a/mudsync/gameobj.scm +++ b/mudsync/gameobj.scm @@ -24,6 +24,7 @@ #:use-module (8sync systems actors) #:use-module (8sync agenda) #:use-module (srfi srfi-1) + #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (oop goops) #:export ( @@ -31,6 +32,7 @@ gameobj-loc gameobj-gm + gameobj-act-init gameobj-set-loc! gameobj-occupants gameobj-actions @@ -48,7 +50,7 @@ ;;; Actions supported by all gameobj (define gameobj-actions (build-actions - (init (wrap-apply gameobj-init)) + (init (wrap-apply gameobj-act-init)) ;; Commands for co-occupants (get-commands (wrap-apply gameobj-get-commands)) ;; Commands for participants in a room @@ -112,7 +114,11 @@ ;; @@: Would be preferable to be using generic methods for this... ;; Hopefully we can port this to Guile 2.2 soon... (visible-to-player? - #:init-value (wrap-apply gameobj-visible-to-player?))) + #:init-value (wrap-apply gameobj-visible-to-player?)) + + ;; Set this on self-destruct + ;; (checked by some "long running" game routines) + (destructed #:init-value #f)) ;;; gameobj message handlers @@ -149,9 +155,9 @@ (replace-step actor replace-reply)) replace-steps)))) -;; @@: This could be kind of a messy way of doing gameobj-init +;; @@: This could be kind of a messy way of doing gameobj-act-init ;; stuff. If only we had generic methods :( -(define-mhandler (gameobj-init actor message) +(define-mhandler (gameobj-act-init actor message) "Your most basic game object init procedure. Assists in its replacement of occupants if necessary and nothing else." (run-replacement actor message gameobj-replace-steps*)) @@ -256,12 +262,13 @@ Assists in its replacement of occupants if necessary and nothing else." (format #t "DEBUG: Location set to ~s for ~s\n" loc (actor-id-actor gameobj)) - (slot-set! gameobj 'loc loc) - ;; Change registation of where we currently are - (if loc - (<-wait gameobj loc 'add-occupant! #:who (actor-id gameobj))) - (if old-loc - (<-wait gameobj old-loc 'remove-occupant! #:who (actor-id gameobj)))) + (when (not (equal? old-loc loc)) + (slot-set! gameobj 'loc loc) + ;; Change registation of where we currently are + (if old-loc + (<-wait gameobj old-loc 'remove-occupant! #:who (actor-id gameobj))) + (if loc + (<-wait gameobj loc 'add-occupant! #:who (actor-id gameobj))))) ;; @@: Should it really be #:id ? Maybe #:loc-id or #:loc? (define-mhandler (gameobj-act-set-loc! actor message loc) @@ -315,6 +322,7 @@ By default, this is whether or not the generally-visible flag is set." "General gameobj self destruction routine" ;; Unregister from being in any particular room (gameobj-set-loc! gameobj #f) + (slot-set! gameobj 'destructed #t) ;; Boom! (self-destruct gameobj))