Files
jak-project/goal_src/jak2/engine/common_objs/blocking-plane.gc
T
Tyler Wilding dd0a8a17b2 docs - first chunk of work documenting the files I glossed over (#2130)
- started documenting the files I glossed over, some are totally done,
others are just partially done
- I changed the decompiler to automatically initialize the
art-group-info from the json file. This makes updating gsrc, even a
single file at a time, have consistent naming
- Though I disabled this functionality for jak 1, as I have no idea if
using the ntsc art groups will cause a regression for different versions
- fix indentation for docstrings -- it still doesn't look great, but
this is now a formatting concern, rather than the docstring having a
bunch of happen-stance leading whitespace.
2023-01-15 11:33:39 -05:00

236 lines
8.8 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: blocking-plane.gc
;; name in dgo: blocking-plane
;; dgos: GAME, COMMON
;; DECOMP BEGINS
(deftype blocking-plane (process-drawable)
((root-override collide-shape :offset 128)
)
:heap-base #x50
:method-count-assert 22
:size-assert #xc8
:flag-assert #x16005000c8
(:methods
(idle () _type_ :state 20)
(init! (_type_ (inline-array vector) float) none 21)
)
)
(defskelgroup skel-blocking-plane blocking-plane blocking-plane-lod0-jg blocking-plane-idle-ja
((blocking-plane-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 100.1)
:texture-level 6
)
(defstate idle (blocking-plane)
:virtual #t
:event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
(the-as object (case event-type
(('on)
(cond
((nonzero? (-> self root-override))
(let ((prim (-> self root-override root-prim)))
(set! (-> prim prim-core collide-as) (-> self root-override backup-collide-as))
(let ((v0-0 (the-as int (-> self root-override backup-collide-with))))
(set! (-> prim prim-core collide-with) (the-as collide-spec v0-0))
v0-0
)
)
)
(else
(let ((proc-child-ptr-0 (-> self child)))
(while proc-child-ptr-0
(let ((proc-child-0 (ppointer->process proc-child-ptr-0)))
(set! proc-child-ptr-0 (-> proc-child-ptr-0 0 brother))
(if (type? proc-child-0 blocking-plane)
(send-event proc-child-0 'on)
)
)
)
)
(the-as int #f)
)
)
)
(('off)
(cond
((nonzero? (-> self root-override))
(let ((v1-13 (-> self root-override root-prim)))
(set! (-> v1-13 prim-core collide-as) (collide-spec))
(set! (-> v1-13 prim-core collide-with) (collide-spec))
)
0
)
(else
(let ((proc-child-ptr-1 (-> self child)))
(while proc-child-ptr-1
(let ((proc-child-1 (ppointer->process proc-child-ptr-1)))
(set! proc-child-ptr-1 (-> proc-child-ptr-1 0 brother))
(if (type? proc-child-1 blocking-plane)
(send-event proc-child-1 'off)
)
)
)
)
(the-as int #f)
)
)
)
)
)
)
:code (the-as (function none :behavior blocking-plane) sleep-code)
)
(defmethod init! blocking-plane ((obj blocking-plane) (vec-pair (inline-array vector)) (height float))
"TODO - but sets up the plane given 2 vectors and a height"
(let ((s3-0 (-> vec-pair 0))
(s4-0 (-> vec-pair 1))
)
0.0
(* 0.5 (vector-vector-distance s3-0 s4-0))
(let ((s2-0 (new 'process 'collide-shape obj (collide-list-enum usually-hit-by-player))))
(let ((v1-3 (new 'process 'collide-shape-prim-mesh s2-0 (the-as uint 0) (the-as uint 0))))
(set! (-> v1-3 prim-core collide-as) (collide-spec blocking-plane))
(set! (-> v1-3 prim-core collide-with) (collide-spec jak player-list))
(set! (-> v1-3 prim-core action) (collide-action solid))
(set! (-> v1-3 transform-index) 3)
(set! (-> s2-0 total-prims) (the-as uint 1))
(set! (-> s2-0 root-prim) v1-3)
)
(set! (-> s2-0 nav-radius) (* 0.75 (-> s2-0 root-prim local-sphere w)))
(let ((v1-6 (-> s2-0 root-prim)))
(set! (-> s2-0 backup-collide-as) (-> v1-6 prim-core collide-as))
(set! (-> s2-0 backup-collide-with) (-> v1-6 prim-core collide-with))
)
(set! (-> obj root-override) s2-0)
)
(let ((s1-0 (new 'stack-no-clear 'matrix))
(s2-1 (-> obj root-override))
)
(vector+! (-> s2-1 trans) s3-0 s4-0)
(vector-float*! (-> s2-1 trans) (-> s2-1 trans) 0.5)
(+! (-> s2-1 trans y) (* 0.5 height))
(vector-! (the-as vector (-> s1-0 vector)) s4-0 s3-0)
(let ((f30-1 (vector-normalize-ret-len! (the-as vector (-> s1-0 vector)) 1.0)))
(set! (-> s2-1 scale x) (* 0.00024414062 f30-1))
(set! (-> s2-1 scale y) (* 0.00024414062 height))
(set! (-> s2-1 scale z) 0.0)
(set! (-> s1-0 vector 1 quad) (-> (new 'static 'vector :y 1.0 :w 1.0) quad))
(vector-cross! (-> s1-0 vector 2) (the-as vector (-> s1-0 vector)) (-> s1-0 vector 1))
(vector-normalize! (-> s1-0 vector 2) 1.0)
(matrix->quaternion (-> s2-1 quat) s1-0)
(let ((v1-20 (-> obj root-override root-prim local-sphere)))
(set! (-> v1-20 x) 0.0)
(set! (-> v1-20 y) (* 0.00024414062 (* 0.5 height)))
(set! (-> v1-20 z) 0.0)
(let ((f0-17 0.5)
(f1-7 (* f30-1 f30-1))
(f2-2 height)
)
(set! (-> v1-20 w) (* f0-17 (sqrtf (+ f1-7 (* f2-2 f2-2)))))
)
)
)
)
)
(initialize-skeleton
obj
(the-as skeleton-group (art-group-get-by-name *level* "skel-blocking-plane" (the-as (pointer uint32) #f)))
(the-as pair 0)
)
(logior! (-> obj draw status) (draw-control-status no-draw-bounds))
(transform-post)
(none)
)
;; WARN: Return type mismatch object vs none.
(defbehavior blocking-plane-init-by-other blocking-plane ((vec-pair (inline-array vector)) (height float))
"Calls [[blocking-plane::21]] with the given args"
(if (not vec-pair)
(deactivate self)
)
(init! self vec-pair height)
(go-virtual idle)
(none)
)
;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! blocking-plane ((obj blocking-plane) (arg0 entity-actor))
"Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
This commonly includes things such as:
- stack size
- collision information
- loading the skeleton group / bones
- sounds"
(let ((s5-0 (new 'process 'path-control obj 'path 0.0 (the-as entity #f) #f))
(f30-0 (res-lump-float (-> obj entity) 'height :default 122880.0))
)
(set! (-> obj path) s5-0)
(if (or (not s5-0) (< (-> s5-0 curve num-cverts) 2))
(go process-drawable-art-error "bad path")
)
(logior! (-> s5-0 flags) (path-control-flag display draw-line draw-point draw-text))
(let ((s4-0 (+ (-> s5-0 curve num-cverts) -1))
(s3-0 (new 'stack-no-clear 'inline-array 'vector 2))
)
(dotimes (v1-12 2)
(set! (-> s3-0 v1-12 quad) (the-as uint128 0))
)
(dotimes (s2-0 s4-0)
(get-point-in-path! s5-0 (-> s3-0 0) (the float s2-0) 'interp)
(get-point-in-path! s5-0 (-> s3-0 1) (the float (+ s2-0 1)) 'interp)
(process-spawn blocking-plane s3-0 f30-0 :to obj)
)
)
)
(go (method-of-object obj idle))
(none)
)
(defbehavior blocking-plane-spawn process ((arg0 curve-control) (arg1 (inline-array vector)) (arg2 float))
(cond
((and arg1 (or (not arg0) (logtest? (-> arg0 flags) (path-control-flag not-found))))
(process-spawn blocking-plane arg1 arg2 :to self)
)
(else
(let ((s4-1 (the int (get-num-segments arg0)))
(s3-0 0)
(s2-0 (new 'stack-no-clear 'inline-array 'vector 2))
)
(dotimes (v1-10 2)
(set! (-> s2-0 v1-10 quad) (the-as uint128 0))
)
(while (< s3-0 s4-1)
(get-point-in-path! arg0 (-> s2-0 0) (the float s3-0) 'interp)
(get-point-in-path! arg0 (-> s2-0 1) (the float (+ s3-0 1)) 'interp)
(process-spawn blocking-plane s2-0 arg2 :to self)
(+! s3-0 2)
)
)
)
)
0
(none)
)
(defbehavior blocking-plane-destroy blocking-plane ()
(let ((child-proc-ptr (-> self child)))
(while child-proc-ptr
(let ((child-proc (ppointer->process child-proc-ptr)))
(set! child-proc-ptr (-> child-proc-ptr 0 brother))
(if (type? child-proc blocking-plane)
(deactivate child-proc)
)
)
)
)
0
(none)
)