Files
jak-project/test/decompiler/reference/jak1/levels/sunken/shover_REF.gc
T
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

135 lines
4.7 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type shover
(deftype shover (process-drawable)
((root collide-shape :override)
(shove-up float)
)
(:states
shover-idle
)
)
;; definition for method 3 of type shover
(defmethod inspect ((this shover))
(let ((t9-0 (method-of-type process-drawable inspect)))
(t9-0 this)
)
(format #t "~T~Tshove-up: ~f~%" (-> this shove-up))
this
)
;; failed to figure out what this is:
(defskelgroup *shover-sg* shover shover-lod0-jg shover-idle-ja
((shover-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 2)
)
;; failed to figure out what this is:
(defstate shover-idle (shover)
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touch 'attack)
(when (= (-> proc type) target)
(when ((method-of-type touching-shapes-entry prims-touching-action?)
(the-as touching-shapes-entry (-> block param 0))
(-> *target* control)
(collide-action solid)
(collide-action)
)
(let ((s4-0 (new 'stack 'attack-info)))
(calc-shove-up (-> self root) s4-0 (-> self shove-up))
(level-hint-spawn (text-id sunken-hotpipes) "sksp0134" (the-as entity #f) *entity-pool* (game-task none))
(if (or (= (-> *target* control unknown-surface00 mode) 'air)
(>= (+ (current-time) (seconds -0.2)) (-> *target* control unknown-dword11))
(< 0.75 (-> *target* control poly-normal y))
)
(send-event
proc
'attack-or-shove
(-> block param 0)
(static-attack-info ((mode 'burn) (vector (-> s4-0 vector)) (shove-up (-> s4-0 shove-up))))
)
(send-event
proc
'attack-or-shove
(-> block param 0)
(static-attack-info ((mode 'burn)
(shove-up (meters 0))
(shove-back (meters 2))
(vector (-> *target* control poly-normal))
(angle 'shove)
)
)
)
)
)
)
)
)
)
)
:code anim-loop
)
;; definition for method 11 of type shover
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! ((this shover) (arg0 entity-actor))
(local-vars (sv-16 res-tag))
(set! (-> this shove-up) (res-lump-float arg0 'shove :default 12288.0))
(let ((s3-0 (res-lump-value arg0 'collision-mesh-id uint128))
(s4-0 (new 'process 'collide-shape this (collide-list-enum hit-by-player)))
)
(let ((s3-1 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint s3-0) (the-as uint 0))))
(set! (-> s3-1 prim-core collide-as) (collide-kind wall-object))
(set! (-> s3-1 collide-with) (collide-kind target))
(set! (-> s3-1 prim-core action) (collide-action solid))
(set! (-> s3-1 prim-core offense) (collide-offense indestructible))
(set! (-> s3-1 transform-index) 0)
(set-vector! (-> s3-1 local-sphere) 0.0 0.0 0.0 53248.0)
(set-root-prim! s4-0 s3-1)
)
(set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
(backup-collide-with-as s4-0)
(set! (-> this root) s4-0)
)
(process-drawable-from-entity! this arg0)
(initialize-skeleton this *shover-sg* '())
(let ((v1-17 (new 'process 'path-control this 'path 0.0)))
(set! (-> this path) v1-17)
(logior! (-> v1-17 flags) (path-control-flag display draw-line draw-point draw-text))
(if (<= (-> v1-17 curve num-cverts) 0)
(go process-drawable-art-error "no path")
)
)
(set! sv-16 (new 'static 'res-tag))
(let ((v1-23 (res-lump-data arg0 'trans-offset (pointer float) :tag-ptr (& sv-16))))
(when v1-23
(+! (-> this root trans x) (-> v1-23 0))
(+! (-> this root trans y) (-> v1-23 1))
(+! (-> this root trans z) (-> v1-23 2))
)
)
(let ((f0-13 (res-lump-float arg0 'rotoffset)))
(if (!= f0-13 0.0)
(quaternion-rotate-y! (-> this root quat) (-> this root quat) f0-13)
)
)
(ja-channel-set! 1)
(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) 0.0)
)
(ja-post)
(update-transforms! (-> this root))
(set! *shover* this)
(go shover-idle)
(none)
)