jak-project/goal_src/jak1/levels/lavatube/assistant-lavatube.gc
ManDude cd68cb671e
deftype and defmethod syntax major changes (#3094)
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>
2023-10-30 03:20:02 +00:00

149 lines
4.7 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: assistant-lavatube.gc
;; name in dgo: assistant-lavatube
;; dgos: L1, LAV
;; DECOMP BEGINS
(deftype assistant-lavatube-start (process-taskable)
()
)
(defskelgroup *assistant-lavatube-start-sg* assistant-lavatube-start assistant-lavatube-start-lod0-jg assistant-lavatube-start-idle-ja
((assistant-lavatube-start-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 4)
:shadow assistant-lavatube-start-shadow-mg
)
(defmethod play-anim! ((this assistant-lavatube-start) (arg0 symbol))
(case (current-status (-> this tasks))
(((task-status need-reward-speech))
(if arg0
(close-current! (-> this tasks))
)
(new 'static 'spool-anim
:name "assistant-lavatube-start-resolution"
:index 5
:parts 11
:command-list '((232 joint "cameraB") (491 joint "camera") (866 joint "cameraB") (1061 joint "camera"))
)
)
(else
(if arg0
(format
0
"ERROR: <GMJ>: ~S playing anim for task status ~S~%"
(-> this name)
(task-status->string (current-status (-> this tasks)))
)
)
(get-art-elem this)
)
)
)
(defmethod get-art-elem ((this assistant-lavatube-start))
(-> this draw art-group data 3)
)
(defstate hidden (assistant-lavatube-start)
:virtual #t
:trans (behavior ()
((-> (method-of-type process-taskable hidden) trans))
(when (and (cond
((and *target* (>= 61440.0 (vector-vector-distance (-> self root trans) (-> *target* control trans))))
#t
)
(else
(set-time! (-> self state-time))
#f
)
)
(and (not (closed? (-> self tasks) (game-task lavatube-start) (task-status need-reward-speech)))
(not (movie?))
(not (level-hint-displayed?))
(not (and *cheat-mode* (cpad-hold? 0 l3)))
(not (time-elapsed? (-> self state-time) (seconds 10)))
)
)
(hide-hud)
(kill-current-level-hint '() '(sidekick voicebox) 'exit)
(when (and (seen-text? *game-info* (text-id assistant-lavatube-need-cells))
(hud-hidden?)
(can-grab-display? self)
(not (-> *setting-control* current hint))
)
(let ((gp-0
(new 'stack 'font-context *font-default-matrix* 32 160 0.0 (font-color default) (font-flags shadow kerning))
)
)
(let ((v1-26 gp-0))
(set! (-> v1-26 width) (the float 448))
)
(let ((v1-27 gp-0))
(set! (-> v1-27 height) (the float 80))
)
(let ((v1-28 gp-0))
(set! (-> v1-28 scale) 0.8)
)
(set! (-> gp-0 flags) (font-flags shadow kerning middle large))
(print-game-text (lookup-text! *common-text* (text-id assistant-lavatube-need-cells-text) #f) gp-0 #f 128 22)
)
)
(level-hint-spawn
(text-id assistant-lavatube-need-cells)
"asstva74"
(the-as entity #f)
*entity-pool*
(game-task none)
)
)
)
)
(defstate idle (assistant-lavatube-start)
:virtual #t
:code (behavior ()
(loop
(when (!= (ja-group) (get-art-elem self))
(ja-channel-push! 1 (seconds 0.05))
(ja :group! assistant-lavatube-start-idle-ja)
)
(let* ((f30-0 2.0)
(v1-7 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-8 (the-as number (logior #x3f800000 v1-7)))
)
(countdown (gp-0 (+ (the int (* f30-0 (+ -1.0 (the-as float v1-8)))) 2))
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
(ja-channel-push! 1 (seconds 0.05))
(ja-no-eval :group! assistant-lavatube-start-idle-b-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
)
(defmethod should-display? ((this assistant-lavatube-start))
(first-any (-> this tasks) #t)
(= (current-status (-> this tasks)) (task-status need-reward-speech))
)
(defmethod init-from-entity! ((this assistant-lavatube-start) (arg0 entity-actor))
(process-taskable-method-40 this arg0 *assistant-lavatube-start-sg* 3 29 (new 'static 'vector :w 4096.0) 5)
(set! (-> this tasks) (get-task-control (game-task lavatube-start)))
(first-any (-> this tasks) #t)
(process-taskable-method-42 this)
(none)
)