jak-project/goal_src/jak1/levels/village2/flutflut-bluehut.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

116 lines
3.5 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: flutflut-bluehut.gc
;; name in dgo: flutflut-bluehut
;; dgos: L1, VI2
;; DECOMP BEGINS
(deftype flutflut-bluehut (process-taskable)
()
)
(defskelgroup *flutflut-bluehut-sg* flutflut-bluehut flutflut-bluehut-lod0-jg flutflut-bluehut-idle-breathe-ja
((flutflut-bluehut-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 3.25)
)
(defmethod play-anim! ((this flutflut-bluehut) (arg0 symbol))
(current-status (-> this tasks))
(if arg0
(format
0
"ERROR: <GMJ>: ~S playing anim for task status ~S~%"
(-> this name)
(task-status->string (current-status (-> this tasks)))
)
)
(the-as basic (get-art-elem this))
)
(defmethod get-art-elem ((this flutflut-bluehut))
(-> this draw art-group data 2)
)
(defmethod should-display? ((this flutflut-bluehut))
(and (closed? (-> this tasks) (game-task village2-levitator) (task-status need-introduction))
(task-closed? (game-task beach-flutflut) (task-status need-resolution))
)
)
(defstate idle (flutflut-bluehut)
:virtual #t
:trans (behavior ()
(set! (-> self will-talk) #f)
((-> (method-of-type process-taskable idle) trans))
)
:code (behavior ()
(if (!= (ja-group) (get-art-elem self))
(ja-channel-push! 1 (seconds 0.05))
)
(loop
(ja :group! flutflut-bluehut-idle-breathe-ja)
(let* ((f30-0 2.0)
(v1-8 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-9 (the-as number (logior #x3f800000 v1-8)))
)
(countdown (gp-0 (+ (the int (* f30-0 (+ -1.0 (the-as float v1-9)))) 1))
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
(let ((s5-0 (current-time)))
(while (< (+ (current-time) (seconds -0.5)) s5-0)
(suspend)
)
)
(ja-no-eval :group! (ja-group) :num! (seek! 0.0) :frame-num max)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! 0.0))
)
(let ((s5-1 (current-time)))
(while (< (+ (current-time) (seconds -0.5)) s5-1)
(suspend)
)
)
)
)
(ja-no-eval :group! flutflut-bluehut-idle-start-scratch-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
(ja :group! flutflut-bluehut-idle-scratch-ja)
(let* ((f30-1 2.0)
(v1-102 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-103 (the-as number (logior #x3f800000 v1-102)))
)
(countdown (gp-1 (+ (the int (* f30-1 (+ -1.0 (the-as float v1-103)))) 6))
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
(ja-no-eval :group! flutflut-bluehut-idle-start-scratch-ja :num! (seek! 0.0) :frame-num max)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! 0.0))
)
)
)
)
(defmethod init-from-entity! ((this flutflut-bluehut) (arg0 entity-actor))
(process-taskable-method-40 this arg0 *flutflut-bluehut-sg* 3 0 (new 'static 'vector :w 4096.0) 27)
(set! (-> this tasks) (get-task-control (game-task village2-levitator)))
(set! (-> this draw light-index) (the-as uint 1))
(process-taskable-method-42 this)
(none)
)