jak-project/goal_src/jak2/engine/common_objs/generic-obs-h.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

232 lines
6 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: generic-obs-h.gc
;; name in dgo: generic-obs-h
;; dgos: ENGINE, GAME
(defenum manipy-options
:bitfield #t
:type uint32
(mo-0 0)
)
(declare-type part-tracker process)
(declare-type manipy process-drawable)
(declare-type sparticle-launch-group basic)
(define-extern part-tracker-init (function sparticle-launch-group time-frame (function part-tracker none) (pointer process-drawable) process matrix none :behavior part-tracker))
(define-extern manipy-init (function vector entity-actor skeleton-group vector object none :behavior manipy))
(define-extern lightning-tracker-init (function lightning-spec time-frame symbol process-drawable vector vector none :behavior lightning-tracker))
(define-extern birth-pickup-at-point (function vector pickup-type float symbol process-tree fact-info (pointer process) :behavior process))
(define-extern process-grab? (function process symbol symbol :behavior process))
(define-extern process-release? (function process symbol :behavior process))
;; DECOMP BEGINS
(deftype manipy (process-drawable)
((root collide-shape :override)
(new-trans-hook (function none))
(cur-trans-hook (function none))
(cur-event-hook (function none))
(new-joint-anim art-joint-anim)
(new-joint-anim-blend uint64)
(anim-mode symbol)
(cur-grab-handle handle)
(cur-target-handle handle)
(old-grab-pos vector :inline)
(joint joint-mod 4)
(new-post-hook (function none))
(cur-post-hook (function none))
(clone-copy-trans symbol)
(shadow-backup basic)
(draw? symbol)
(userdata uint64)
(prefix basic)
(shadow-volume-joint int32)
(speed float)
(user-uint64 uint64 4)
(options manipy-options)
)
(:state-methods
idle
)
)
(deftype part-spawner (process)
((root trsqv)
(part sparticle-launch-control)
(sound ambient-sound)
(mode (pointer sparticle-launch-group))
(enable symbol)
(radius meters)
(world-sphere sphere :inline)
)
(:state-methods
active
)
(:methods
(is-in-view? (_type_) symbol)
)
)
(deftype part-tracker (process)
((root trsqv)
(mat matrix :inline)
(part sparticle-launch-control)
(callback (function part-tracker vector))
(linger-callback (function part-tracker vector))
(duration uint64)
(linger-duration uint64)
(start-time time-frame)
(target handle)
(target-joint int32)
(offset vector :inline)
(userdata uint64)
(user-time time-frame 2)
(user-vector vector :inline)
(user-handle uint32 2 :offset 352)
)
(:state-methods
active
)
(:methods
(notify-parent-of-death (_type_) none)
)
)
(deftype lightning-tracker (process)
((ppointer (pointer lightning-tracker) :override)
(root trsqv)
(lightning lightning-control)
(callback (function lightning-tracker none))
(duration uint64)
(start-time time-frame)
(offset0 vector :inline)
(offset1 vector :inline)
(target0 handle)
(target1 handle)
(target-joint0 int32)
(target-joint1 int32)
(sound sound-id)
(userdata uint64)
(user-time time-frame 2)
(user-vector vector :inline)
(user-handle handle 2 :offset 288)
)
(:state-methods
active
)
(:methods
(notify-parent-of-death (_type_) none)
(update (_type_) none)
)
)
(deftype touch-tracker (process-drawable)
((root collide-shape :override)
(duration time-frame)
(target handle)
(event symbol)
(run-function (function object))
(callback (function touch-tracker none))
(event-mode basic)
)
(:state-methods
active
)
)
(deftype swingpole (process-drawable)
((root collide-shape :override)
(edge-length meters)
(path-pos float)
(joint-track int32)
(speed meters)
(dir vector :inline)
(sync sync-eased :inline)
)
(:state-methods
idle
(active handle)
)
(:methods
(move-along-path (_type_) none)
)
)
(deftype gui-query (structure)
((x-position int32)
(y-position int32)
(message string)
(decision symbol)
(only-allow-cancel symbol)
(no-msg string)
(message-space int32)
)
(:methods
(gui-query-method-9 () none)
(gui-query-method-10 () none)
)
)
(deftype othercam (process)
((hand handle)
(old-global-mask process-mask)
(mask-to-clear process-mask)
(cam-joint-index int32)
(old-pos vector :inline)
(old-mat-z vector :inline)
(had-valid-frame basic)
(border-value basic)
(die? symbol)
(survive-anim-end? symbol)
(spooling? symbol)
(fov float)
)
(:states
othercam-running
)
)
(deftype explosion (process-drawable)
((root collide-shape :override)
(start-time time-frame)
(duration uint32)
(linger-duration uint32)
(attack-id uint32)
)
(:state-methods
explode
)
(:methods
(setup-explosion-collision (_type_) none)
(explosion-method-22 (_type_) none)
)
)
(deftype explosion-init-params (structure)
((spawn-point vector :inline)
(spawn-quat quaternion :inline)
(radius float)
(group sparticle-launch-group)
(collide-with collide-spec)
(penetrate-using penetrate)
)
)
(deftype process-hidden (process)
()
(:state-methods
die
)
)