mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
133 lines
3.6 KiB
Common Lisp
133 lines
3.6 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: simple-nav-sphere.gc
|
|
;; name in dgo: simple-nav-sphere
|
|
;; dgos: GAME, COMMON
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype simple-nav-sphere (process-drawable)
|
|
((root collide-shape :override)
|
|
(first-time? symbol)
|
|
(track-joint int32)
|
|
)
|
|
(:state-methods
|
|
idle
|
|
active
|
|
)
|
|
)
|
|
|
|
|
|
(defbehavior simple-nav-sphere-event-handler simple-nav-sphere ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
|
|
(case event-type
|
|
(('die-fast)
|
|
(go empty-state)
|
|
)
|
|
(('move-trans)
|
|
(move-to-point! (-> self root) (the-as vector (-> event param 0)))
|
|
#t
|
|
)
|
|
(('set-radius)
|
|
(let ((radius (the-as float (-> event param 0)))
|
|
(collide-shape (-> self root))
|
|
)
|
|
(set! (-> collide-shape nav-radius) radius)
|
|
(set! (-> collide-shape root-prim local-sphere w) radius)
|
|
(update-transforms collide-shape)
|
|
)
|
|
#t
|
|
)
|
|
)
|
|
)
|
|
|
|
(defmethod run-logic? ((this simple-nav-sphere))
|
|
(cond
|
|
(*display-nav-marks*
|
|
#t
|
|
)
|
|
((>= (-> this track-joint) 0)
|
|
#t
|
|
)
|
|
((-> this first-time?)
|
|
(set! (-> this first-time?) #f)
|
|
#t
|
|
)
|
|
)
|
|
)
|
|
|
|
(defstate idle (simple-nav-sphere)
|
|
:virtual #t
|
|
:event simple-nav-sphere-event-handler
|
|
:trans (behavior ()
|
|
(if *display-nav-marks*
|
|
(add-debug-sphere
|
|
#t
|
|
(bucket-id debug2)
|
|
(-> self root trans)
|
|
(-> self root nav-radius)
|
|
(new 'static 'rgba :r #x80 :g #x40 :a #x80)
|
|
)
|
|
)
|
|
)
|
|
:code sleep-code
|
|
)
|
|
|
|
(defstate active (simple-nav-sphere)
|
|
:virtual #t
|
|
:event simple-nav-sphere-event-handler
|
|
:trans (behavior ()
|
|
(let ((v1-0 (ppointer->process (-> self parent)))
|
|
(gp-0 (new 'stack-no-clear 'vector))
|
|
)
|
|
(vector<-cspace! gp-0 (-> (the-as process-drawable v1-0) node-list data (-> self track-joint)))
|
|
(move-to-point! (-> self root) gp-0)
|
|
)
|
|
)
|
|
:code sleep-code
|
|
)
|
|
|
|
;; WARN: Return type mismatch object vs none.
|
|
(defbehavior simple-nav-sphere-init-by-other simple-nav-sphere ((arg0 float) (arg1 vector) (arg2 nav-mesh) (arg3 int))
|
|
(set! (-> self track-joint) arg3)
|
|
(set! (-> self first-time?) #t)
|
|
(let ((s5-0 (new 'process 'collide-shape self (collide-list-enum usually-hit-by-player))))
|
|
(let ((v1-3 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
|
|
(set! (-> v1-3 prim-core collide-as) (collide-spec obstacle))
|
|
(set-vector! (-> v1-3 local-sphere) 0.0 0.0 0.0 4096.0)
|
|
(set! (-> s5-0 total-prims) (the-as uint 1))
|
|
(set! (-> s5-0 root-prim) v1-3)
|
|
)
|
|
(set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
|
|
(let ((v1-6 (-> s5-0 root-prim)))
|
|
(set! (-> s5-0 backup-collide-as) (-> v1-6 prim-core collide-as))
|
|
(set! (-> s5-0 backup-collide-with) (-> v1-6 prim-core collide-with))
|
|
)
|
|
(set! (-> s5-0 nav-radius) arg0)
|
|
(set! (-> s5-0 root-prim local-sphere w) arg0)
|
|
(if arg1
|
|
(set! (-> s5-0 trans quad) (-> arg1 quad))
|
|
)
|
|
(vector-identity! (-> s5-0 scale))
|
|
(quaternion-identity! (-> s5-0 quat))
|
|
(let ((v1-11 (-> s5-0 root-prim)))
|
|
(set! (-> v1-11 prim-core collide-as) (collide-spec))
|
|
(set! (-> v1-11 prim-core collide-with) (collide-spec))
|
|
)
|
|
0
|
|
(update-transforms s5-0)
|
|
(set! (-> self root) s5-0)
|
|
)
|
|
(logclear! (-> self mask) (process-mask actor-pause enemy))
|
|
(set! (-> self event-hook) simple-nav-sphere-event-handler)
|
|
(if arg2
|
|
(add-process-drawable-to-navmesh arg2 self #f)
|
|
(nav-mesh-connect-from-ent self)
|
|
)
|
|
(if (>= (-> self track-joint) 0)
|
|
(go-virtual active)
|
|
(go-virtual idle)
|
|
)
|
|
(none)
|
|
)
|