jak-project/goal_src/jak1/levels/sunken/sunken-pipegame.gc
Tyler Wilding c162c66118
g/j1: Cleanup all main issues in the formatter and format all of goal_src/jak1 (#3535)
This PR does two main things:
1. Work through the main low-hanging fruit issues in the formatter
keeping it from feeling mature and usable
2. Iterate and prove that point by formatting all of the Jak 1 code
base. **This has removed around 100K lines in total.**
- The decompiler will now format it's results for jak 1 to keep things
from drifting back to where they were. This is controlled by a new
config flag `format_code`.

How am I confident this hasn't broken anything?:
- I compiled the entire project and stored it's `out/jak1/obj` files
separately
- I then recompiled the project after formatting and wrote a script that
md5's each file and compares it (`compare-compilation-outputs.py`
- The results (eventually) were the same:

![Screenshot 2024-05-25
132900](https://github.com/open-goal/jak-project/assets/13153231/015e6f20-8d19-49b7-9951-97fa88ddc6c2)
> This proves that the only difference before and after is non-critical
whitespace for all code/macros that is actually in use.

I'm still aware of improvements that could be made to the formatter, as
well as general optimization of it's performance. But in general these
are for rare or non-critical situations in my opinion and I'll work
through them before doing Jak 2. The vast majority looks great and is
working properly at this point. Those known issues are the following if
you are curious:

![image](https://github.com/open-goal/jak-project/assets/13153231/0edfaba1-6d36-40f5-ab23-0642209867c4)
2024-06-05 22:17:31 -04:00

811 lines
31 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
(bundles "SUN.DGO")
(require "engine/common-obs/ticky.gc")
(require "engine/geometry/path.gc")
(require "engine/common-obs/collectables.gc")
(require "engine/camera/pov-camera-h.gc")
(require "engine/common-obs/basebutton.gc")
;; DECOMP BEGINS
(deftype sunken-pipegame-button (basebutton) ())
(deftype sunken-pipegame-prize (structure)
((puzzle-delay time-frame)
(pipe-travel-time-to-far time-frame)
(pipe-travel-time-to-jar time-frame)
(actor-handle handle)
(jar-pos vector :inline)
(far-pos vector :inline)
(sucked-up-jar-part-pos vector :inline)
(sucked-up-far-part-pos vector :inline)
(blown-out-jar-part-pos vector :inline)
(blown-out-far-part-pos vector :inline)
(sucked-up-part sparticle-launch-control)
(blown-out-part sparticle-launch-control)))
(deftype sunken-pipegame (process-drawable)
((abort-audio-if-beaten? symbol)
(challenges-mask uint32)
(challenge int32)
(ticker ticky :inline)
(button (pointer sunken-pipegame-button) 3)
(prize sunken-pipegame-prize 3 :inline))
(:methods
(sunken-pipegame-method-20 (_type_) uint)
(sunken-pipegame-method-21 (_type_ symbol) symbol)
(sunken-pipegame-method-22 (_type_ symbol) none))
(:states
sunken-pipegame-beat-challenge
sunken-pipegame-begin-play
sunken-pipegame-end-play
sunken-pipegame-idle
sunken-pipegame-start-up))
(defpartgroup group-pipegame-jar-suck0
:id 448
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 1741) (sp-item 1742) (sp-item 1743) (sp-item 1744 :flags (is-3d))))
(defpart 1741
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 10.0)
(:y (meters 6))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y (meters 1) (meters 0.5))
(:r 64.0 128.0)
(:g 0.0 32.0)
(:b 0.0)
(:a 0.0)
(:scalevel-y (meters 0.006666667))
(:fade-a 1.4222223)
(:accel-y (meters 0.0033333334))
(:timer (seconds 0.4))
(:flags (bit2))
(:next-time (seconds 0.15) (seconds 0.147))
(:next-launcher 1745)
(:conerot-x (degrees 0) (degrees 15))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0) (meters -10))))
(defpart 1745
:init-specs ((:fade-a 0.0)))
(defpart 1742
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 5.0)
(:y (meters 0) (meters 8))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y :copy scale-x)
(:r 128.0 64.0)
(:g 128.0 64.0)
(:b 128.0 64.0)
(:a 64.0 64.0)
(:fade-a -3.657143)
(:timer (seconds 0.1))
(:flags (bit2 bit3))
(:conerot-x (degrees 90))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0) (meters 2.5))))
(defpart 1743
:init-specs
((:texture (new 'static 'texture-id :index #x29 :page #x2))
(:num 1.0)
(:y (meters 4))
(:scale-x (meters 7) (meters 1))
(:scale-y (meters 7) (meters 3))
(:r 128.0 128.0)
(:g 0.0 64.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpart 1744
:init-specs
((:texture (new 'static 'texture-id :index #x12 :page #x2))
(:num 1.0)
(:y (meters 0.3))
(:scale-x (meters 5.5) (meters 2))
(:scale-y (meters 5.5) (meters 2))
(:r 128.0 128.0)
(:g 0.0 64.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpartgroup group-pipegame-jar-suck1
:id 449
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 1746) (sp-item 1742) (sp-item 1747) (sp-item 1748 :flags (is-3d))))
(defpart 1746
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 10.0)
(:y (meters 6))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y (meters 1) (meters 0.5))
(:r 0.0 64.0)
(:g 64.0 128.0)
(:b 0.0)
(:a 0.0)
(:scalevel-y (meters 0.006666667))
(:fade-a 1.4222223)
(:accel-y (meters 0.0033333334))
(:timer (seconds 0.4))
(:flags (bit2))
(:next-time (seconds 0.15) (seconds 0.147))
(:next-launcher 1745)
(:conerot-x (degrees 0) (degrees 15))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0) (meters -10))))
(defpart 1747
:init-specs
((:texture (new 'static 'texture-id :index #x29 :page #x2))
(:num 1.0)
(:y (meters 4))
(:scale-x (meters 7) (meters 1))
(:scale-y (meters 7) (meters 3))
(:r 0.0 64.0)
(:g 128.0 128.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpart 1748
:init-specs
((:texture (new 'static 'texture-id :index #x12 :page #x2))
(:num 1.0)
(:y (meters 0.3))
(:scale-x (meters 5.5) (meters 2))
(:scale-y (meters 5.5) (meters 2))
(:r 0.0 64.0)
(:g 128.0 128.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpartgroup group-pipegame-jar-suck2
:id 450
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 1749) (sp-item 1742) (sp-item 1750) (sp-item 1751 :flags (is-3d))))
(defpart 1749
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 10.0)
(:y (meters 6))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y (meters 1) (meters 0.5))
(:r 0.0)
(:g 0.0 64.0)
(:b 64.0 128.0)
(:a 0.0)
(:scalevel-y (meters 0.006666667))
(:fade-a 1.4222223)
(:accel-y (meters 0.0033333334))
(:timer (seconds 0.4))
(:flags (bit2))
(:next-time (seconds 0.15) (seconds 0.147))
(:next-launcher 1745)
(:conerot-x (degrees 0) (degrees 15))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0) (meters -10))))
(defpart 1750
:init-specs
((:texture (new 'static 'texture-id :index #x29 :page #x2))
(:num 1.0)
(:y (meters 4))
(:scale-x (meters 7) (meters 1))
(:scale-y (meters 7) (meters 3))
(:r 0.0)
(:g 0.0 64.0)
(:b 128.0 128.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpart 1751
:init-specs
((:texture (new 'static 'texture-id :index #x12 :page #x2))
(:num 1.0)
(:y (meters 0.3))
(:scale-x (meters 5.5) (meters 2))
(:scale-y (meters 5.5) (meters 2))
(:r 0.0)
(:g 0.0 64.0)
(:b 128.0 128.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpartgroup group-pipegame-blow0
:id 451
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 1752) (sp-item 1753) (sp-item 1754) (sp-item 1755 :flags (is-3d))))
(defpart 1752
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 4.0)
(:y (meters 0))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y (meters 1) (meters 0.5))
(:r 64.0 128.0)
(:g 0.0 32.0)
(:b 0.0)
(:a 64.0 64.0)
(:vel-y (meters -0.033333335))
(:scalevel-y (meters 0.006666667))
(:accel-y (meters -0.006666667))
(:timer (seconds 0.4))
(:flags (bit2))
(:next-time (seconds 0.15) (seconds 0.147))
(:next-launcher 1756)
(:conerot-x (degrees 150) (degrees 30))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0))))
(defpart 1756
:init-specs ((:fade-a -1.4222223)))
(defpart 1753
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 5.0)
(:y (meters 0) (meters -8))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y :copy scale-x)
(:r 128.0 64.0)
(:g 128.0 64.0)
(:b 128.0 64.0)
(:a 64.0 64.0)
(:fade-a -3.657143)
(:timer (seconds 0.1))
(:flags (bit2 bit3))
(:conerot-x (degrees 90))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0) (meters 2.5))))
(defpart 1754
:init-specs
((:texture (new 'static 'texture-id :index #x29 :page #x2))
(:num 1.0)
(:y (meters -3.5))
(:scale-x (meters 3) (meters 0.5))
(:rot-z (degrees 180))
(:scale-y (meters 13) (meters 3))
(:r 128.0 128.0)
(:g 0.0 64.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpart 1755
:init-specs
((:texture (new 'static 'texture-id :index #x12 :page #x2))
(:num 1.0)
(:y (meters 0.3))
(:scale-x (meters 5.5) (meters 2))
(:scale-y (meters 5.5) (meters 2))
(:r 128.0 128.0)
(:g 0.0 64.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpartgroup group-pipegame-blow1
:id 452
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 1757) (sp-item 1753) (sp-item 1758) (sp-item 1759 :flags (is-3d))))
(defpart 1757
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 4.0)
(:y (meters 0))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y (meters 1) (meters 0.5))
(:r 0.0 32.0)
(:g 64.0 128.0)
(:b 0.0)
(:a 64.0 64.0)
(:vel-y (meters -0.033333335))
(:scalevel-y (meters 0.006666667))
(:accel-y (meters -0.006666667))
(:timer (seconds 0.4))
(:flags (bit2))
(:next-time (seconds 0.15) (seconds 0.147))
(:next-launcher 1756)
(:conerot-x (degrees 150) (degrees 30))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0))))
(defpart 1758
:init-specs
((:texture (new 'static 'texture-id :index #x29 :page #x2))
(:num 1.0)
(:y (meters -3.5))
(:scale-x (meters 3) (meters 0.5))
(:rot-z (degrees 180))
(:scale-y (meters 13) (meters 3))
(:r 0.0 64.0)
(:g 128.0 128.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpart 1759
:init-specs
((:texture (new 'static 'texture-id :index #x12 :page #x2))
(:num 1.0)
(:y (meters 0.3))
(:scale-x (meters 5.5) (meters 2))
(:scale-y (meters 5.5) (meters 2))
(:r 0.0 64.0)
(:g 128.0 128.0)
(:b 0.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpartgroup group-pipegame-blow2
:id 453
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 1760) (sp-item 1753) (sp-item 1761) (sp-item 1762 :flags (is-3d))))
(defpart 1760
:init-specs
((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 4.0)
(:y (meters 0))
(:scale-x (meters 0.1) (meters 0.1))
(:scale-y (meters 1) (meters 0.5))
(:r 0.0)
(:g 0.0 32.0)
(:b 64.0 128.0)
(:a 64.0 64.0)
(:vel-y (meters -0.033333335))
(:scalevel-y (meters 0.006666667))
(:accel-y (meters -0.006666667))
(:timer (seconds 0.4))
(:flags (bit2))
(:next-time (seconds 0.15) (seconds 0.147))
(:next-launcher 1756)
(:conerot-x (degrees 150) (degrees 30))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0))))
(defpart 1761
:init-specs
((:texture (new 'static 'texture-id :index #x29 :page #x2))
(:num 1.0)
(:y (meters -3.5))
(:scale-x (meters 3) (meters 0.5))
(:rot-z (degrees 180))
(:scale-y (meters 13) (meters 3))
(:r 0.0)
(:g 0.0 64.0)
(:b 128.0 128.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defpart 1762
:init-specs
((:texture (new 'static 'texture-id :index #x12 :page #x2))
(:num 1.0)
(:y (meters 0.3))
(:scale-x (meters 5.5) (meters 2))
(:scale-y (meters 5.5) (meters 2))
(:r 0.0)
(:g 0.0 64.0)
(:b 128.0 128.0)
(:a 64.0 64.0)
(:fade-a -8.533334)
(:timer (seconds 0.035))
(:flags (bit2 bit3))))
(defbehavior sunken-pipegame-button-init-by-other sunken-pipegame-button ((arg0 vector) (arg1 quaternion) (arg2 entity-actor) (arg3 symbol))
(basebutton-init-by-other (the-as entity-actor #f) arg0 arg1 arg2 arg3 0.0)
(none))
(defmethod sunken-pipegame-method-20 ((this sunken-pipegame))
(let ((gp-0 0))
(if (task-complete? *game-info* (game-task sunken-pipe)) (+! gp-0 1))
(if (got-buzzer? *game-info* (game-task sunken-buzzer) 0) (+! gp-0 2))
(if (got-buzzer? *game-info* (game-task sunken-buzzer) 1) (+! gp-0 4))
(the-as uint gp-0)))
(defstate sunken-pipegame-start-up (sunken-pipegame)
:code
(behavior ()
(suspend)
(send-event (handle->process (-> self prize 0 actor-handle)) 'anim #f)
(go sunken-pipegame-idle)))
(defstate sunken-pipegame-idle (sunken-pipegame)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('trigger)
(when (= (-> proc type) sunken-pipegame-button)
(set! (-> self challenge) (-> (the-as sunken-pipegame-button proc) button-id))
(go sunken-pipegame-begin-play)))))
:code
(behavior ()
(loop
(suspend))))
(defstate sunken-pipegame-begin-play (sunken-pipegame)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('notify)
(case (-> proc type)
((fuel-cell buzzer) (go sunken-pipegame-beat-challenge))))))
:enter
(behavior ()
(sunken-pipegame-method-21 self #f)
(set! (-> self abort-audio-if-beaten?) #f)
(dotimes (gp-0 3)
(let ((v1-4 (-> self button gp-0)))
(if (and (!= gp-0 (-> self challenge)) (not (logtest? (ash 1 gp-0) (-> self challenges-mask))))
(send-event (ppointer->process v1-4) 'trigger)))))
:code
(behavior ()
(local-vars (v1-112 symbol))
(let ((gp-0 (current-time)))
(if (not (handle->process (-> self prize (-> self challenge) actor-handle))) (go sunken-pipegame-end-play))
(kill-current-level-hint '(camera) '() 'exit)
(let ((v1-10 (-> self challenge)))
(cond
((zero? v1-10)
(ambient-hint-spawn "gamcam27" (the-as vector #f) *entity-pool* 'camera)
(process-spawn pov-camera (-> self root trans) *sunkencam-sg* "pipegame-left" 0 #f '() :to self))
((= v1-10 1)
(ambient-hint-spawn "gamcam25" (the-as vector #f) *entity-pool* 'camera)
(process-spawn pov-camera (-> self root trans) *sunkencam-sg* "pipegame-middle" 0 #f '() :to self))
((= v1-10 2)
(ambient-hint-spawn "gamcam26" (the-as vector #f) *entity-pool* 'camera)
(process-spawn pov-camera (-> self root trans) *sunkencam-sg* "pipegame-right" 0 #f '() :to self))))
(set-time! (-> self state-time))
(let ((f30-0 0.0))
(until (time-elapsed? (-> self state-time) (seconds 2))
(let ((s5-3 (-> self prize (-> self challenge))))
(spawn (-> s5-3 sucked-up-part) (-> s5-3 sucked-up-jar-part-pos))
(spawn (-> s5-3 blown-out-part) (-> s5-3 blown-out-far-part-pos)))
(+! f30-0 (* 1024.0 (seconds-per-frame)))
(let ((s5-4 (new 'stack-no-clear 'vector)))
(set! (-> s5-4 quad) (-> (the-as (pointer uint128) (&+ (&-> self stack 160) (* 144 (-> self challenge))))))
(let* ((f28-0 (-> s5-4 y))
(v1-39 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-40 (the-as number (logior #x3f800000 v1-39))))
(set! (-> s5-4 y) (+ f28-0 (* (+ -1.0 (the-as float v1-40)) f30-0))))
(let ((a1-18 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-18 from) self)
(set! (-> a1-18 num-params) 1)
(set! (-> a1-18 message) 'trans)
(set! (-> a1-18 param 0) (the-as uint s5-4))
(let ((t9-17 send-event-function)
(a0-32 (handle->process (-> self prize (-> self challenge) actor-handle))))
(t9-17 a0-32 a1-18))))
(suspend))
(let ((f28-1 0.0))
(until (= f28-1 20480.0)
(let ((s5-5 (-> self prize (-> self challenge))))
(spawn (-> s5-5 sucked-up-part) (-> s5-5 sucked-up-jar-part-pos))
(spawn (-> s5-5 blown-out-part) (-> s5-5 blown-out-far-part-pos))
(set! f28-1 (seek f28-1 20480.0 (* 81920.0 (seconds-per-frame))))
(let ((s4-0 (new 'stack-no-clear 'vector)))
(set! (-> s4-0 quad) (-> s5-5 jar-pos quad))
(let* ((f26-0 (-> s4-0 y))
(v1-65 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-66 (the-as number (logior #x3f800000 v1-65))))
(set! (-> s4-0 y) (+ f26-0 (+ (* (+ -1.0 (the-as float v1-66)) f30-0) f28-1))))
(let ((a1-22 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-22 from) self)
(set! (-> a1-22 num-params) 1)
(set! (-> a1-22 message) 'trans)
(set! (-> a1-22 param 0) (the-as uint s4-0))
(let ((t9-22 send-event-function)
(a0-45 (handle->process (-> s5-5 actor-handle))))
(t9-22 a0-45 a1-22)))))
(suspend))))
(until (time-elapsed? gp-0 (-> self prize (-> self challenge) pipe-travel-time-to-far))
(let ((s5-6 (-> self prize (-> self challenge))))
(spawn (-> s5-6 sucked-up-part) (-> s5-6 sucked-up-jar-part-pos))
(spawn (-> s5-6 blown-out-part) (-> s5-6 blown-out-far-part-pos)))
(suspend)))
(sunken-pipegame-method-22 self #t)
(let ((f30-1 20480.0))
(until (= f30-1 0.0)
(set! f30-1 (seek f30-1 0.0 (* 81920.0 (seconds-per-frame))))
(let ((gp-1 (-> self prize (-> self challenge))))
(spawn (-> gp-1 sucked-up-part) (-> gp-1 sucked-up-jar-part-pos))
(spawn (-> gp-1 blown-out-part) (-> gp-1 blown-out-far-part-pos))
(let ((v1-96 (new 'stack-no-clear 'vector)))
(set! (-> v1-96 quad) (-> gp-1 far-pos quad))
(+! (-> v1-96 y) f30-1)
(let ((a1-32 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-32 from) self)
(set! (-> a1-32 num-params) 1)
(set! (-> a1-32 message) 'trans)
(set! (-> a1-32 param 0) (the-as uint v1-96))
(let ((t9-29 send-event-function)
(a0-64 (handle->process (-> gp-1 actor-handle))))
(t9-29 a0-64 a1-32)))))
(suspend)))
(if (not (handle->process (-> self prize (-> self challenge) actor-handle))) (go sunken-pipegame-end-play))
(until v1-112
(suspend)
(set! v1-112 (or (not *target*) (not (logtest? (-> *target* state-flags) (state-flags grabbed))))))
(set-time! (-> self state-time))
(sleep (-> self ticker) (-> self prize (-> self challenge) puzzle-delay))
(until (time-elapsed? (-> self state-time) (seconds 0.5))
(completed? (-> self ticker))
(suspend))
(level-hint-spawn (text-id sunken-pipegame-hint) "sksp0123" (the-as entity #f) *entity-pool* (game-task none))
(close-specific-task! (-> self entity extra perm task) (task-status need-hint))
(until (completed? (-> self ticker))
(suspend))
(kill-current-level-hint '(camera) '() 'exit)
(ambient-hint-spawn "gamcam26" (the-as vector #f) *entity-pool* 'camera)
(set! (-> self abort-audio-if-beaten?) #t)
(set-time! (-> self state-time))
(let ((f30-2 0.0))
(until (time-elapsed? (-> self state-time) (seconds 2))
(let ((gp-2 (-> self prize (-> self challenge))))
(spawn (-> gp-2 sucked-up-part) (-> gp-2 sucked-up-far-part-pos))
(spawn (-> gp-2 blown-out-part) (-> gp-2 blown-out-jar-part-pos))
(+! f30-2 (* 1024.0 (seconds-per-frame)))
(let ((s5-7 (new 'stack-no-clear 'vector)))
(set! (-> s5-7 quad) (-> gp-2 far-pos quad))
(let* ((f28-2 (-> s5-7 y))
(v1-146 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-147 (the-as number (logior #x3f800000 v1-146))))
(set! (-> s5-7 y) (+ f28-2 (* (+ -1.0 (the-as float v1-147)) f30-2))))
(let ((a1-42 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-42 from) self)
(set! (-> a1-42 num-params) 1)
(set! (-> a1-42 message) 'trans)
(set! (-> a1-42 param 0) (the-as uint s5-7))
(let ((t9-41 send-event-function)
(a0-91 (handle->process (-> gp-2 actor-handle))))
(t9-41 a0-91 a1-42)))))
(suspend))
(let ((f28-3 0.0))
(until (= f28-3 20480.0)
(let ((gp-3 (-> self prize (-> self challenge))))
(spawn (-> gp-3 sucked-up-part) (-> gp-3 sucked-up-far-part-pos))
(spawn (-> gp-3 blown-out-part) (-> gp-3 blown-out-jar-part-pos))
(set! f28-3 (seek f28-3 20480.0 (* 81920.0 (seconds-per-frame))))
(let ((s5-8 (new 'stack-no-clear 'vector)))
(set! (-> s5-8 quad) (-> gp-3 far-pos quad))
(let* ((f26-1 (-> s5-8 y))
(v1-169 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-170 (the-as number (logior #x3f800000 v1-169))))
(set! (-> s5-8 y) (+ f26-1 (+ (* (+ -1.0 (the-as float v1-170)) f30-2) f28-3))))
(let ((a1-46 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-46 from) self)
(set! (-> a1-46 num-params) 1)
(set! (-> a1-46 message) 'trans)
(set! (-> a1-46 param 0) (the-as uint s5-8))
(let ((t9-46 send-event-function)
(a0-104 (handle->process (-> gp-3 actor-handle))))
(t9-46 a0-104 a1-46)))))
(suspend))))
(sunken-pipegame-method-22 self #f)
(set! (-> self abort-audio-if-beaten?) #f)
(let ((v1-184 (-> self prize (-> self challenge)))
(a0-109 (new 'stack-no-clear 'vector)))
(set! (-> a0-109 quad) (-> v1-184 jar-pos quad))
(+! (-> a0-109 y) 40960.0)
(send-event (handle->process (-> v1-184 actor-handle)) 'trans a0-109))
(set-time! (-> self state-time))
(until (time-elapsed? (-> self state-time) (-> self prize (-> self challenge) pipe-travel-time-to-jar))
(let ((gp-4 (-> self prize (-> self challenge))))
(spawn (-> gp-4 sucked-up-part) (-> gp-4 sucked-up-far-part-pos))
(spawn (-> gp-4 blown-out-part) (-> gp-4 blown-out-jar-part-pos)))
(suspend))
(let ((f30-3 20480.0))
(until (= f30-3 0.0)
(set! f30-3 (seek f30-3 0.0 (* 40960.0 (seconds-per-frame))))
(let ((v1-203 (new 'stack-no-clear 'vector)))
(set! (-> v1-203 quad) (-> (the-as (pointer uint128) (&+ (&-> self stack 160) (* 144 (-> self challenge))))))
(+! (-> v1-203 y) f30-3)
(let ((a1-57 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-57 from) self)
(set! (-> a1-57 num-params) 1)
(set! (-> a1-57 message) 'trans)
(set! (-> a1-57 param 0) (the-as uint v1-203))
(let ((t9-52 send-event-function)
(a0-128 (handle->process (-> self prize (-> self challenge) actor-handle))))
(t9-52 a0-128 a1-57))))
(suspend)))
(set-time! (-> self state-time))
(until (time-elapsed? (-> self state-time) (seconds 1.5))
(suspend))
(ambient-hint-spawn "st-lose" (the-as vector #f) *entity-pool* 'stinger)
(go sunken-pipegame-end-play)))
(defstate sunken-pipegame-beat-challenge (sunken-pipegame)
:code
(behavior ()
(logior! (-> self challenges-mask) (ash 1 (-> self challenge)))
(if (-> self abort-audio-if-beaten?) (kill-current-level-hint '(camera) '() 'exit))
(go sunken-pipegame-end-play)))
(defstate sunken-pipegame-end-play (sunken-pipegame)
:code
(behavior ()
(local-vars (v1-3 symbol))
(sunken-pipegame-method-21 self #t)
(set! (-> self abort-audio-if-beaten?) #f)
(until v1-3
(suspend)
(set! v1-3 (or (not *target*) (not (logtest? (-> *target* state-flags) (state-flags grabbed))))))
(if (not (handle->process (-> self prize (-> self challenge) actor-handle)))
(logior! (-> self challenges-mask) (ash 1 (-> self challenge))))
(set! (-> self challenge) -1)
(dotimes (gp-0 3)
(let ((v1-18 (-> self button gp-0)))
(if (not (logtest? (ash 1 gp-0) (-> self challenges-mask))) (send-event (ppointer->process v1-18) 'untrigger))))
(go sunken-pipegame-idle)))
(defmethod sunken-pipegame-method-22 ((this sunken-pipegame) (arg0 symbol))
(let* ((v1-0 (-> this challenge))
(a2-0 v1-0))
(cond
((zero? a2-0)
(let ((v1-5 (handle->process (-> this prize v1-0 actor-handle))))
(when v1-5
(if arg0
(restore-collide-with-as (-> (the-as collectable v1-5) root))
(clear-collide-with-as (-> (the-as collectable v1-5) root))))))
((or (= a2-0 1) (= a2-0 2))
(let ((v1-13 (handle->process (-> this prize v1-0 actor-handle))))
(when v1-13
(if arg0
(restore-collide-with-as (-> (the-as collectable v1-13) root))
(clear-collide-with-as (-> (the-as collectable v1-13) root))))))))
(none))
(defmethod sunken-pipegame-method-21 ((this sunken-pipegame) (arg0 symbol))
(if arg0 (logior! (-> this mask) (process-mask actor-pause)) (logclear! (-> this mask) (process-mask actor-pause)))
(let ((v1-4 (-> this child)))
(while v1-4
(if arg0 (logior! (-> v1-4 0 mask) (process-mask actor-pause)) (logclear! (-> v1-4 0 mask) (process-mask actor-pause)))
(set! v1-4 (-> v1-4 0 brother))))
#f)
(defmethod deactivate ((this sunken-pipegame))
(dotimes (s5-0 3)
(let ((s4-0 (-> this prize s5-0)))
(if (nonzero? (-> s4-0 sucked-up-part)) (kill-and-free-particles (-> s4-0 sucked-up-part)))
(if (nonzero? (-> s4-0 blown-out-part)) (kill-and-free-particles (-> s4-0 blown-out-part)))))
((method-of-type process-drawable deactivate) this)
(none))
(defmethod relocate ((this sunken-pipegame) (arg0 int))
(dotimes (v1-0 3)
(let ((a0-4 (-> this prize v1-0)))
(when (nonzero? (-> a0-4 sucked-up-part))
(if (nonzero? (-> a0-4 sucked-up-part)) (&+! (-> a0-4 sucked-up-part) arg0)))
(when (nonzero? (-> a0-4 blown-out-part))
(if (nonzero? (-> a0-4 blown-out-part)) (&+! (-> a0-4 blown-out-part) arg0)))))
(call-parent-method this arg0))
(defmethod init-from-entity! ((this sunken-pipegame) (arg0 entity-actor))
(set! (-> this abort-audio-if-beaten?) #f)
(stack-size-set! (-> this main-thread) 512)
(set! (-> this challenge) -1)
(dotimes (v1-3 3)
(set! (-> this prize v1-3 actor-handle) (the-as handle #f)))
(set! (-> this root) (new 'process 'trsqv))
(process-drawable-from-entity! this arg0)
(set! (-> this path) (new 'process 'path-control this 'path 0.0))
(logior! (-> this path flags) (path-control-flag display draw-line draw-point draw-text))
(set! (-> this challenges-mask) (sunken-pipegame-method-20 this))
(let ((s4-0 (new 'stack-no-clear 'vector))
(s3-0 (new 'stack-no-clear 'quaternion)))
(quaternion-identity! s3-0)
(dotimes (s2-0 3)
(let* ((s0-0 (-> this prize s2-0))
(v1-17 (ash 1 s2-0))
(s1-1 (logtest? v1-17 (-> this challenges-mask))))
(eval-path-curve-div! (-> this path) (-> s0-0 jar-pos) (the float (* s2-0 2)) 'interp)
(eval-path-curve-div! (-> this path) (-> s0-0 far-pos) (the float (+ (* s2-0 2) 1)) 'interp)
(set! (-> s0-0 sucked-up-jar-part-pos quad) (-> s0-0 jar-pos quad))
(set! (-> s0-0 sucked-up-far-part-pos quad) (-> s0-0 far-pos quad))
(set! (-> s0-0 blown-out-jar-part-pos quad) (-> s0-0 jar-pos quad))
(+! (-> s0-0 blown-out-jar-part-pos y) 24576.0)
(set! (-> s0-0 blown-out-far-part-pos quad) (-> s0-0 far-pos quad))
(+! (-> s0-0 blown-out-far-part-pos y) 28672.0)
(let ((v1-30 s2-0))
(cond
((zero? v1-30)
(set! (-> s0-0 puzzle-delay) (seconds 25))
(set! (-> s0-0 pipe-travel-time-to-far) (seconds 8.5))
(set! (-> s0-0 pipe-travel-time-to-jar) (seconds 2.5))
(set-vector! s4-0 -30720.0 1146.88 5120.0 1.0)
(set! (-> s0-0 sucked-up-part) (create-launch-control (-> *part-group-id-table* 448) this))
(set! (-> s0-0 blown-out-part) (create-launch-control (-> *part-group-id-table* 451) this))
(+! (-> s0-0 jar-pos y) 11673.6)
(+! (-> s0-0 far-pos y) 11673.6)
(when (not s1-1)
(set! (-> s0-0 actor-handle)
(ppointer->handle (birth-pickup-at-point (-> s0-0 jar-pos) (pickup-type fuel-cell) 45.0 #f this (the-as fact-info #f))))
(let ((a1-10 (handle->process (-> s0-0 actor-handle))))
(if a1-10 (clear-collide-with-as (-> (the-as collectable a1-10) root))))))
((= v1-30 1)
(set! (-> s0-0 puzzle-delay) (seconds 15))
(set! (-> s0-0 pipe-travel-time-to-far) (seconds 5.5))
(set! (-> s0-0 pipe-travel-time-to-jar) (seconds 2.5))
(set-vector! s4-0 0.0 1146.88 5120.0 1.0)
(set! (-> s0-0 sucked-up-part) (create-launch-control (-> *part-group-id-table* 449) this))
(set! (-> s0-0 blown-out-part) (create-launch-control (-> *part-group-id-table* 452) this))
(+! (-> s0-0 jar-pos y) 7168.0)
(+! (-> s0-0 far-pos y) 7168.0)
(+! (-> s0-0 blown-out-far-part-pos y) 4096.0)
(when (not s1-1)
(set! (-> s0-0 actor-handle)
(ppointer->handle (birth-pickup-at-point (-> s0-0 jar-pos) (pickup-type buzzer) 49.0 #f this (the-as fact-info #f))))
(let ((s0-1 (handle->process (-> s0-0 actor-handle))))
(when s0-1
(send-event s0-1 'movie-pos 1)
(clear-collide-with-as (-> (the-as collectable s0-1) root))))))
((= v1-30 2)
(set! (-> s0-0 puzzle-delay) (seconds 15))
(set! (-> s0-0 pipe-travel-time-to-far) (seconds 4.5))
(set! (-> s0-0 pipe-travel-time-to-jar) (seconds 2.5))
(set-vector! s4-0 30720.0 1146.88 5120.0 1.0)
(set! (-> s0-0 sucked-up-part) (create-launch-control (-> *part-group-id-table* 450) this))
(set! (-> s0-0 blown-out-part) (create-launch-control (-> *part-group-id-table* 453) this))
(+! (-> s0-0 jar-pos y) 7168.0)
(+! (-> s0-0 far-pos y) 7168.0)
(+! (-> s0-0 blown-out-far-part-pos y) 4096.0)
(when (not s1-1)
(set! (-> s0-0 actor-handle)
(ppointer->handle (birth-pickup-at-point (-> s0-0 jar-pos) (pickup-type buzzer) 65585.0 #f this (the-as fact-info #f))))
(let ((s0-2 (handle->process (-> s0-0 actor-handle))))
(when s0-2
(send-event s0-2 'movie-pos 2)
(clear-collide-with-as (-> (the-as collectable s0-2) root))))))))
(vector+! s4-0 s4-0 (-> this root trans))
(let ((v1-102 (process-spawn sunken-pipegame-button s4-0 s3-0 arg0 s1-1 :to this)))
(set! (-> this button s2-0) (the-as (pointer sunken-pipegame-button) v1-102))
(set! (-> (the-as (pointer sunken-pipegame-button) v1-102) 0 button-id) s2-0)))))
(go sunken-pipegame-start-up)
(none))