mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -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>
208 lines
6.1 KiB
Common Lisp
208 lines
6.1 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: sunken-elevator.gc
|
|
;; name in dgo: sunken-elevator
|
|
;; dgos: L1, VI2
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype sunken-elevator (plat-button)
|
|
((play-at-top-going-up-camera? symbol)
|
|
(teleport-if-below-y float)
|
|
(teleport-if-above-y float)
|
|
)
|
|
)
|
|
|
|
|
|
(defskelgroup *sunken-elevator-sg* sunken-elevator sunken-elevator-lod0-jg sunken-elevator-pressed-ja
|
|
((sunken-elevator-lod0-mg (meters 999999)))
|
|
:bounds (static-spherem 0 -1 0 6.6)
|
|
)
|
|
|
|
(defmethod should-teleport? ((this sunken-elevator))
|
|
(let ((f0-0 (-> (camera-pos) y)))
|
|
(case (-> this path-pos)
|
|
((0.0)
|
|
(if (< f0-0 (-> this teleport-if-below-y))
|
|
(return #t)
|
|
)
|
|
)
|
|
((1.0)
|
|
(if (< (-> this teleport-if-above-y) f0-0)
|
|
(return #t)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
#f
|
|
)
|
|
|
|
(defstate plat-button-pressed (sunken-elevator)
|
|
:virtual #t
|
|
:enter (behavior ()
|
|
(let ((t9-0 (-> (method-of-type plat-button plat-button-pressed) enter)))
|
|
(if t9-0
|
|
(t9-0)
|
|
)
|
|
)
|
|
(case (-> self path-pos)
|
|
((0.0)
|
|
(load-state-want-display-level 'sunken 'display)
|
|
(let ((gp-0 (get-process *default-dead-pool* village2cam #x4000)))
|
|
(set! (-> (the-as village2cam (-> (when gp-0
|
|
(let ((t9-3 (method-of-type village2cam activate)))
|
|
(t9-3 (the-as village2cam gp-0) self 'village2cam (the-as pointer #x70004000))
|
|
)
|
|
(run-now-in-process
|
|
gp-0
|
|
pov-camera-init-by-other
|
|
(-> self spawn-pos)
|
|
*village2cam-sg*
|
|
"elevator-at-top-going-down"
|
|
0
|
|
#f
|
|
'()
|
|
)
|
|
(-> gp-0 ppointer)
|
|
)
|
|
0
|
|
)
|
|
)
|
|
seq
|
|
)
|
|
(the-as uint 0)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
((1.0)
|
|
(let ((v1-10 (process-spawn
|
|
village2cam
|
|
:init pov-camera-init-by-other
|
|
(-> self spawn-pos)
|
|
*village2cam-sg*
|
|
"elevator-at-top-going-down"
|
|
0
|
|
#f
|
|
'()
|
|
:to self
|
|
)
|
|
)
|
|
)
|
|
(set! (-> (the-as village2cam (-> v1-10 0)) seq) (the-as uint 1))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defstate plat-button-move-upward (sunken-elevator)
|
|
:virtual #t
|
|
:enter (behavior ()
|
|
(let ((t9-0 (-> (method-of-type plat-button plat-button-move-upward) enter)))
|
|
(if t9-0
|
|
(t9-0)
|
|
)
|
|
)
|
|
(set! (-> self play-at-top-going-up-camera?) #t)
|
|
)
|
|
:trans (behavior ()
|
|
(let ((t9-0 (-> (method-of-type plat-button plat-button-move-upward) trans)))
|
|
(if t9-0
|
|
(t9-0)
|
|
)
|
|
)
|
|
(when (and (-> self play-at-top-going-up-camera?) (>= 0.14 (-> self path-pos)))
|
|
(set! *teleport* #t)
|
|
(set! (-> self play-at-top-going-up-camera?) #f)
|
|
(load-state-want-display-level 'sunken 'special)
|
|
(let ((v1-8 (process-spawn
|
|
village2cam
|
|
:init pov-camera-init-by-other
|
|
(-> self spawn-pos)
|
|
*village2cam-sg*
|
|
"elevator-at-top-going-down"
|
|
0
|
|
#f
|
|
'()
|
|
:to self
|
|
)
|
|
)
|
|
)
|
|
(set! (-> (the-as village2cam (-> v1-8 0)) seq) (the-as uint 2))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defstate plat-button-move-downward (sunken-elevator)
|
|
:virtual #t
|
|
:trans (behavior ()
|
|
(let ((s5-0 (new 'stack-no-clear 'vector))
|
|
(gp-0 (new 'stack-no-clear 'vector))
|
|
)
|
|
(set! *teleport* #t)
|
|
(set! (-> s5-0 quad) (-> self root trans quad))
|
|
(let ((t9-1 (-> (find-parent-state) trans)))
|
|
(if t9-1
|
|
(t9-1)
|
|
)
|
|
)
|
|
(vector-! gp-0 (-> self root trans) s5-0)
|
|
(when (< (-> self path-pos) 0.9)
|
|
(move-by-vector! (-> *target* control) gp-0)
|
|
(send-event *target* 'reset-height)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defmethod can-target-move? ((this sunken-elevator))
|
|
(set! (-> this play-at-top-going-up-camera?) #f)
|
|
(let ((s5-0 (new 'stack-no-clear 'vector)))
|
|
(eval-path-curve! (-> this path) s5-0 0.4 'interp)
|
|
(set! (-> this teleport-if-above-y) (-> s5-0 y))
|
|
(eval-path-curve! (-> this path) s5-0 0.6 'interp)
|
|
(set! (-> this teleport-if-below-y) (-> s5-0 y))
|
|
)
|
|
(none)
|
|
)
|
|
|
|
(defmethod plat-button-method-27 ((this sunken-elevator))
|
|
(ja-channel-set! 1)
|
|
(cond
|
|
((can-activate? this)
|
|
(let ((s5-0 (-> this skel root-channel 0)))
|
|
(joint-control-channel-group-eval!
|
|
s5-0
|
|
(the-as art-joint-anim (-> this draw art-group data 2))
|
|
num-func-identity
|
|
)
|
|
(set! (-> s5-0 frame-num) 0.0)
|
|
)
|
|
)
|
|
(else
|
|
(let ((s5-1 (-> this skel root-channel 0)))
|
|
(joint-control-channel-group-eval!
|
|
s5-1
|
|
(the-as art-joint-anim (-> this draw art-group data 2))
|
|
num-func-identity
|
|
)
|
|
(set! (-> s5-1 frame-num)
|
|
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 2)) data 0 length) -1))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(ja-post)
|
|
(update-transforms! (-> this root))
|
|
(none)
|
|
)
|
|
|
|
(defmethod plat-button-method-31 ((this sunken-elevator))
|
|
(initialize-skeleton this *sunken-elevator-sg* '())
|
|
0
|
|
(none)
|
|
)
|