mirror of
https://github.com/open-goal/jak-project
synced 2026-08-08 10:34:30 -04:00
jak 2
This commit is contained in:
+25
@@ -464,6 +464,10 @@
|
||||
(set! *defstate-type-stack* '())
|
||||
`(none)
|
||||
)
|
||||
|
||||
(seval (define *defstate-current-type* #f))
|
||||
(seval (define *defstate-current-state-name* #f))
|
||||
|
||||
;; *no-state* is just used for the compiler to know whether a handler was actually set or not
|
||||
(defmacro defstate (state-name parents
|
||||
&key (virtual #f)
|
||||
@@ -483,6 +487,10 @@
|
||||
*defstate-type-stack*)
|
||||
)
|
||||
(set! *defstate-type-stack* '())
|
||||
(when virtual
|
||||
(set! *defstate-current-type* defstate-type)
|
||||
(set! *defstate-current-state-name* state-name)
|
||||
)
|
||||
;; check for default handlers
|
||||
(let ((default-handlers (assoc defstate-type *default-state-handlers*)))
|
||||
(when default-handlers
|
||||
@@ -545,6 +553,23 @@
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro find-parent-state ()
|
||||
(when (or (not *defstate-current-type*)
|
||||
(not *defstate-current-state-name*))
|
||||
(error "use of find-parent-state outside of a defstate.")
|
||||
)
|
||||
`(cast-to-method-type
|
||||
,*defstate-current-type*
|
||||
,*defstate-current-state-name*
|
||||
(find-parent-method ,*defstate-current-type* (method-id-of-type ,*defstate-current-type* ,*defstate-current-state-name*))
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro call-parent-method (&rest args)
|
||||
`((the (current-method-function-type) (find-parent-method (current-method-type) (current-method-id)))
|
||||
,@args)
|
||||
)
|
||||
|
||||
(defmacro behavior (bindings &rest body)
|
||||
"Define an anonymous behavior for a process state. This may only be used inside a defstate!"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user