jak-project/goal_src/levels/jungle/jungle-elevator.gc
Tyler Wilding 4ff2130d55
decomp: decompile almost all the platform related files (#812)
* deocmp: `plat` finished, `baseplat` started

* decomp: finish `baseplat`

* decomp: finish `plat-button`

* decomp: finish `plat-eco`

* decomp: finish `citb-drop-plat-CIT`

* decomp: finish `cit-drop-plat-L1`

* decomp: finish `plat-flip`

* decomp: added a bunch of label defs

* decomp: `plat-button` ref test added

* stash

* decomp: finish `baseplat`

* decomp: finish `plat`

* decomp: finish `plat-button`

* tests: fix offline-test to handle multi-DGO files better

* decomp: finish `citb-drop-plat-CIT`

* decomp: finish `plat-flip`

* decomp: finish `wedge-plats`

* tools: fix memory analyzer, skip invalid type

* decomp: finish `wall-plat`

* fix ordering

* fix some casting issues

* cleanup after conflict resolution

* address reviews
2021-09-06 21:10:19 -04:00

220 lines
5.5 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: jungle-elevator.gc
;; name in dgo: jungle-elevator
;; dgos: JUN, JUNGLE, L1
(define-extern *plat-button-sg* skeleton-group)
;; definition of type jungle-elevator
(deftype jungle-elevator (plat-button)
((bottom-height float :offset-assert 240)
(teleport-if-below-y float :offset-assert 244)
(teleport-if-above-y float :offset-assert 248)
)
:heap-base #x90
:method-count-assert 33
:size-assert #xfc
:flag-assert #x21009000fc
)
;; definition for method 26 of type jungle-elevator
(defmethod can-activate? jungle-elevator ((obj jungle-elevator))
(and
((method-of-type plat-button can-activate?) obj)
(task-complete? *game-info* (game-task jungle-tower))
)
)
;; failed to figure out what this is:
(defstate plat-button-move-downward (jungle-elevator)
:virtual #t
:enter
(behavior ()
(let
((t9-0 (-> (method-of-type plat-button plat-button-move-downward) enter)))
(if t9-0
(t9-0)
)
)
(set! (-> self draw light-index) (the-as uint 255))
(set! (-> self bottom-height) (-> jungle bottom-height))
(set! (-> jungle bottom-height) (-> jungleb bottom-height))
(let ((a1-0 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-0 from) self)
(set! (-> a1-0 num-params) 1)
(set! (-> a1-0 message) 'reset-pickup)
(set! (-> a1-0 param 0) (the-as uint 'eco))
(send-event-function *target* a1-0)
)
(none)
)
:exit
(behavior ()
(set! (-> jungle bottom-height) (-> self bottom-height))
(let
((t9-0 (-> (method-of-type plat-button plat-button-move-downward) exit)))
(if t9-0
(t9-0)
)
)
(none)
)
:trans
(behavior ()
(let ((s5-0 (new 'stack-no-clear 'vector))
(gp-0 (new 'stack-no-clear 'vector))
)
(set! (-> s5-0 quad) (-> self root-override trans quad))
(let
((t9-1
(->
(the-as (state plat-button) (find-parent-method jungle-elevator 23))
trans
)
)
)
(if t9-1
(t9-1)
)
)
(vector-! gp-0 (-> self root-override trans) s5-0)
)
(when (< (-> self path-pos) 0.9)
(TODO-RENAME-28 (-> *target* control))
(let ((a1-2 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-2 from) self)
(set! (-> a1-2 num-params) 0)
(set! (-> a1-2 message) 'reset-height)
(send-event-function *target* a1-2)
)
)
(if
(and
(>= (-> self path-pos) 0.2)
(<
(- (-> *display* base-frame-counter) (the-as int (-> self state-time)))
60
)
)
(load-commands-set! *level* (load-command-get-index *level* 'jungle 0))
)
(none)
)
)
;; failed to figure out what this is:
(defstate plat-button-move-upward (jungle-elevator)
:virtual #t
:enter
(behavior ()
(let ((t9-0 (-> (method-of-type plat-button plat-button-move-upward) enter)))
(if t9-0
(t9-0)
)
)
(set! (-> self draw light-index) (the-as uint 255))
(set! (-> self bottom-height) (-> jungle bottom-height))
(set! (-> jungle bottom-height) (-> jungleb bottom-height))
(set! (-> self grab-player?) (process-grab? *target*))
(none)
)
:exit
(behavior ()
(set! (-> jungle bottom-height) (-> self bottom-height))
(let ((t9-0 (-> (method-of-type plat-button plat-button-move-upward) exit)))
(if t9-0
(t9-0)
)
)
(none)
)
:trans
(behavior ()
(let ((t9-0 (-> (method-of-type plat-button plat-button-move-upward) trans)))
(if t9-0
(t9-0)
)
)
(if
(and
(< (-> self path-pos) 0.8)
(<
(- (-> *display* base-frame-counter) (the-as int (-> self state-time)))
60
)
)
(load-commands-set! *level* (load-command-get-index *level* 'jungle 1))
)
(none)
)
)
;; failed to figure out what this is:
(defstate plat-button-at-end (jungle-elevator)
:virtual #t
:code
(behavior ()
(cond
((!= (-> self path-pos) 0.0)
(set! (-> self draw light-index) (the-as uint 1))
(let ((a1-1 (res-lump-struct (-> self entity) 'continue-name structure)))
(when a1-1
(let ((v1-4 (set-continue! *game-info* (the-as basic a1-1))))
(load-commands-set! *level* (-> v1-4 load-commands))
)
)
)
)
(else
(set! (-> self draw light-index) (the-as uint 255))
(load-commands-set! *level* '())
)
)
(let ((t9-4 (-> (method-of-type plat-button plat-button-at-end) code)))
(if t9-4
((the-as (function none :behavior plat-button) t9-4))
)
)
(none)
)
)
;; definition for method 30 of type jungle-elevator
(defmethod should-teleport? jungle-elevator ((obj jungle-elevator))
(let ((f0-0 (-> (camera-pos) y)))
(case (-> obj path-pos)
((0.0)
(when (< f0-0 (-> obj teleport-if-below-y))
(set! (-> obj draw light-index) (the-as uint 1))
(return #t)
)
)
((1.0)
(when (< (-> obj teleport-if-above-y) f0-0)
(set! (-> obj draw light-index) (the-as uint 255))
(return #t)
)
)
)
)
#f
)
;; definition for method 29 of type jungle-elevator
(defmethod can-target-move? jungle-elevator ((obj jungle-elevator))
(let ((s5-0 (new 'stack-no-clear 'vector)))
(eval-path-curve! (-> obj path) s5-0 0.4 'interp)
(set! (-> obj teleport-if-above-y) (-> s5-0 y))
(eval-path-curve! (-> obj path) s5-0 0.6 'interp)
(set! (-> obj teleport-if-below-y) (-> s5-0 y))
)
(set! (-> obj draw light-index) (the-as uint 255))
(set! (-> obj bidirectional?) #f)
(let ((v0-2 #t))
(set! (-> obj should-grab-player?) v0-2)
v0-2
)
)