;;-*-Lisp-*-
(in-package goal)

(import "goal_src/jak1/import/exit-chamber-ag.gc")
(import "goal_src/jak1/import/blue-eco-charger-ag.gc")
(import "goal_src/jak1/import/blue-eco-charger-orb-ag.gc")

;; definition of type blue-eco-charger-orb
(deftype blue-eco-charger-orb (process-drawable)
  ((parent-process  (pointer blue-eco-charger)         :offset         12)
   (orbit-rot       vector                     :inline :offset-assert 176)
   (orbit-rotv      vector                     :inline :offset-assert 192)
   (targ-orbit-rotv vector                     :inline :offset-assert 208)
   (rest-pos        vector                     :inline :offset-assert 224)
   )
  :heap-base #x80
  :method-count-assert 21
  :size-assert         #xf0
  :flag-assert         #x15008000f0
  (:methods
    (dummy-20 (_type_ float) vector 20)
    )
  (:states
    blue-eco-charger-orb-active
    blue-eco-charger-orb-idle
    )
  )

;; definition for method 3 of type blue-eco-charger-orb
(defmethod inspect blue-eco-charger-orb ((obj blue-eco-charger-orb))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Torbit-rot: #<vector @ #x~X>~%" (-> obj orbit-rot))
  (format #t "~T~Torbit-rotv: #<vector @ #x~X>~%" (-> obj orbit-rotv))
  (format #t "~T~Ttarg-orbit-rotv: #<vector @ #x~X>~%" (-> obj targ-orbit-rotv))
  (format #t "~T~Trest-pos: #<vector @ #x~X>~%" (-> obj rest-pos))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *blue-eco-charger-orb-sg* blue-eco-charger-orb blue-eco-charger-orb-lod0-jg blue-eco-charger-orb-idle-ja
              ((blue-eco-charger-orb-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 1.1)
              )

;; definition of type blue-eco-charger
(deftype blue-eco-charger (process-drawable)
  ((root-override collide-shape  :offset        112)
   (charger-id    int32          :offset-assert 176)
   (open-level    float          :offset-assert 180)
   (master        entity-actor   :offset-assert 184)
   )
  :heap-base #x50
  :method-count-assert 22
  :size-assert         #xbc
  :flag-assert         #x16005000bc
  (:methods
    (dummy-20 (_type_) object 20)
    (dummy-21 (_type_ symbol) object 21)
    )
  (:states
    blue-eco-charger-close
    blue-eco-charger-idle
    (blue-eco-charger-open symbol)
    blue-eco-charger-stuck-open
    )
  )

;; definition for method 3 of type blue-eco-charger
(defmethod inspect blue-eco-charger ((obj blue-eco-charger))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tcharger-id: ~D~%" (-> obj charger-id))
  (format #t "~T~Topen-level: ~f~%" (-> obj open-level))
  (format #t "~T~Tmaster: ~A~%" (-> obj master))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *blue-eco-charger-sg* blue-eco-charger blue-eco-charger-lod0-jg blue-eco-charger-open-ja
              ((blue-eco-charger-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 1.9 0 2.7)
              )

;; definition of type exit-chamber-items
(deftype exit-chamber-items (structure)
  ((door-pos    vector     :inline :offset-assert   0)
   (door-quat   quaternion :inline :offset-assert  16)
   (button-pos  vector     :inline :offset-assert  32)
   (button-quat quaternion :inline :offset-assert  48)
   (fcell-pos   vector     :inline :offset-assert  64)
   )
  :method-count-assert 9
  :size-assert         #x50
  :flag-assert         #x900000050
  )

;; definition for method 3 of type exit-chamber-items
(defmethod inspect exit-chamber-items ((obj exit-chamber-items))
  (format #t "[~8x] ~A~%" obj 'exit-chamber-items)
  (format #t "~Tdoor-pos: #<vector @ #x~X>~%" (-> obj door-pos))
  (format #t "~Tdoor-quat: #<quaternion @ #x~X>~%" (-> obj door-quat))
  (format #t "~Tbutton-pos: #<vector @ #x~X>~%" (-> obj button-pos))
  (format #t "~Tbutton-quat: #<quaternion @ #x~X>~%" (-> obj button-quat))
  (format #t "~Tfcell-pos: #<vector @ #x~X>~%" (-> obj fcell-pos))
  obj
  )

;; definition of type exit-chamber
(deftype exit-chamber (process-drawable)
  ((root-override           collide-shape-moving                  :offset        112)
   (chargers-active         uint32                                :offset-assert 176)
   (move-player?            symbol                                :offset-assert 180)
   (move-fcell?             symbol                                :offset-assert 184)
   (play-assistant-message? symbol                                :offset-assert 188)
   (wave-scale              float                                 :offset-assert 192)
   (button                  (pointer exit-chamber-button)         :offset-assert 196)
   (door                    (pointer sun-iris-door)               :offset-assert 200)
   (fcell-handle            handle                                :offset-assert 208)
   (orig-trans              vector                        :inline :offset-assert 224)
   (last-pos                vector                        :inline :offset-assert 240)
   )
  :heap-base #x90
  :method-count-assert 25
  :size-assert         #x100
  :flag-assert         #x1900900100
  (:methods
    (dummy-20 (_type_ float) float 20)
    (dummy-21 (_type_ exit-chamber-items) vector 21)
    (dummy-22 (_type_) none 22)
    (dummy-23 (_type_ symbol) object 23)
    (dummy-24 (_type_ float) none 24)
    )
  (:states
    exit-chamber-charger-puzzle
    exit-chamber-charger-puzzle-beaten
    exit-chamber-idle-in-sunken
    (exit-chamber-idle-in-village symbol)
    exit-chamber-lower
    exit-chamber-rise
    )
  )

;; definition for method 3 of type exit-chamber
(defmethod inspect exit-chamber ((obj exit-chamber))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tchargers-active: ~D~%" (-> obj chargers-active))
  (format #t "~T~Tmove-player?: ~A~%" (-> obj move-player?))
  (format #t "~T~Tmove-fcell?: ~A~%" (-> obj move-fcell?))
  (format #t "~T~Tplay-assistant-message?: ~A~%" (-> obj play-assistant-message?))
  (format #t "~T~Twave-scale: ~f~%" (-> obj wave-scale))
  (format #t "~T~Tbutton: #x~X~%" (-> obj button))
  (format #t "~T~Tdoor: #x~X~%" (-> obj door))
  (format #t "~T~Tfcell-handle: ~D~%" (-> obj fcell-handle))
  (format #t "~T~Torig-trans: #<vector @ #x~X>~%" (-> obj orig-trans))
  (format #t "~T~Tlast-pos: #<vector @ #x~X>~%" (-> obj last-pos))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *exit-chamber-sg* exit-chamber exit-chamber-lod0-jg exit-chamber-idle-ja
              ((exit-chamber-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 4 0 16.5)
              )

;; failed to figure out what this is:
(defpartgroup group-exit-chamber-ripples
  :id 620
  :duration 900
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 64)
  :parts ((sp-item 2512 :flags (is-3d)))
  )

;; failed to figure out what this is:
(defpart 2513
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1e :page #x2))
    (sp-func spt-birth-func 'birth-func-ocean-height)
    (sp-flt spt-num 0.25)
    (sp-rnd-flt spt-x (meters 5) (meters 3) 1.0)
    (sp-rnd-flt spt-scale-x (meters 12) (meters 6) 1.0)
    (sp-rnd-flt spt-rot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 128.0 64.0 1.0)
    (sp-rnd-flt spt-g 128.0 64.0 1.0)
    (sp-rnd-flt spt-b 128.0 64.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-scalevel-x (meters 0.02) (meters 0.02) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a 3.2)
    (sp-int spt-timer 1500)
    (sp-cpuinfo-flags bit2 bit14)
    (sp-flt spt-userdata 2048.0)
    (sp-int-plain-rnd spt-next-time 10 29 1)
    (sp-launcher-by-id spt-next-launcher 2514)
    (sp-rnd-flt spt-conerot-x (degrees 70.0) (degrees 20.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2514
  :init-specs ((sp-flt spt-fade-a -0.094814815))
  )

;; failed to figure out what this is:
(defpart 2512
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1e :page #x2))
    (sp-func spt-birth-func 'birth-func-ocean-height)
    (sp-flt spt-num 0.5)
    (sp-rnd-flt spt-x (meters 6) (meters 4) 1.0)
    (sp-rnd-flt spt-scale-x (meters 3.5) (meters 2.5) 1.0)
    (sp-rnd-flt spt-rot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 128.0 64.0 1.0)
    (sp-rnd-flt spt-g 128.0 64.0 1.0)
    (sp-rnd-flt spt-b 128.0 64.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-rnd-flt spt-scalevel-x (meters 0.013333334) (meters 0.01) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a 3.2)
    (sp-int spt-timer 1500)
    (sp-cpuinfo-flags bit2 bit14)
    (sp-flt spt-userdata 2048.0)
    (sp-int-plain-rnd spt-next-time 10 29 1)
    (sp-launcher-by-id spt-next-launcher 2514)
    (sp-rnd-flt spt-conerot-x (degrees 70.0) (degrees 20.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; definition for method 20 of type blue-eco-charger-orb
(defmethod dummy-20 blue-eco-charger-orb ((obj blue-eco-charger-orb) (arg0 float))
  (set-vector!
    (-> obj targ-orbit-rotv)
    (rand-vu-float-range 72817.78 258503.11)
    (rand-vu-float-range 72817.78 258503.11)
    (rand-vu-float-range 72817.78 258503.11)
    1.0
    )
  (vector-float*! (-> obj targ-orbit-rotv) (-> obj targ-orbit-rotv) arg0)
  )

;; failed to figure out what this is:
(defstate blue-eco-charger-orb-idle (blue-eco-charger-orb)
  :code (behavior ()
    (set! (-> self root trans quad) (-> self rest-pos quad))
    (loop
      (let ((f0-0 (-> self parent-process 0 open-level)))
        (if (< 0.0 f0-0)
            (go blue-eco-charger-orb-active)
            )
        )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior blue-eco-charger-orb) ja-post)
  )

;; failed to figure out what this is:
(defstate blue-eco-charger-orb-active (blue-eco-charger-orb)
  :code (behavior ()
    (local-vars (at-0 int))
    (rlet ((vf0 :class vf)
           (vf1 :class vf)
           (vf2 :class vf)
           )
      (init-vf0-vector)
      (dummy-20 self (-> self parent-process 0 open-level))
      (vector-reset! (-> self orbit-rotv))
      (loop
        (let ((f30-0 (-> self parent-process 0 open-level)))
          (if (>= 0.0 f30-0)
              (go blue-eco-charger-orb-idle)
              )
          (if (zero? (rand-vu-int-count 30))
              (dummy-20 self f30-0)
              )
          (set! (-> self orbit-rotv x)
                (seek-with-smooth (-> self orbit-rotv x) (-> self targ-orbit-rotv x) 873.81335 0.8 0.12136297)
                )
          (set! (-> self orbit-rotv y)
                (seek-with-smooth (-> self orbit-rotv y) (-> self targ-orbit-rotv y) 873.81335 0.8 0.12136297)
                )
          (set! (-> self orbit-rotv z)
                (seek-with-smooth (-> self orbit-rotv z) (-> self targ-orbit-rotv z) 873.81335 0.8 0.12136297)
                )
          (let ((a1-5 (-> self orbit-rot))
                (v1-13 (-> self orbit-rot))
                (a0-6 (new 'stack-no-clear 'vector))
                )
            (.lvf vf1 (&-> (-> self orbit-rotv) quad))
            (let ((f0-11 (-> *display* seconds-per-frame)))
              (.mov at-0 f0-11)
              )
            (.mov vf2 at-0)
            (.mov.vf vf1 vf0 :mask #b1000)
            (.mul.x.vf vf1 vf1 vf2 :mask #b111)
            (.svf (&-> a0-6 quad) vf1)
            (vector+! a1-5 v1-13 a0-6)
            )
          (let ((gp-0 (new 'stack-no-clear 'vector)))
            (set! (-> gp-0 x) (* 1228.8 f30-0 (cos (-> self orbit-rot x))))
            (set! (-> gp-0 y) (* 1228.8 f30-0 (cos (-> self orbit-rot y))))
            (set! (-> gp-0 z) (* 1228.8 f30-0 (cos (-> self orbit-rot z))))
            (vector+! (-> self root trans) gp-0 (-> self rest-pos))
            (set-vector!
              gp-0
              (cos (* 436.90668 (the float (mod (-> *display* base-frame-counter) 150))))
              (cos (* 247.39902 (the float (mod (-> *display* base-frame-counter) 264))))
              (cos (* 601.7998 (the float (mod (-> *display* base-frame-counter) 108))))
              1.0
              )
            (vector-normalize! gp-0 1.0)
            (quaternion-vector-angle!
              (-> self root quat)
              gp-0
              (* 463.8075 (the float (mod (-> *display* base-frame-counter) 141)))
              )
            )
          )
        (let ((gp-1 (new 'stack-no-clear 'vector)))
          (set! (-> gp-1 x) (rand-vu-float-range -4096.0 4096.0))
          (set! (-> gp-1 y) (rand-vu-float-range -4096.0 4096.0))
          (set! (-> gp-1 z) (rand-vu-float-range -4096.0 4096.0))
          (vector+! gp-1 gp-1 (-> self root trans))
          (eco-blue-glow gp-1)
          (set! (-> gp-1 x) (rand-vu-float-range -4096.0 4096.0))
          (set! (-> gp-1 y) (rand-vu-float-range -4096.0 4096.0))
          (set! (-> gp-1 z) (rand-vu-float-range -4096.0 4096.0))
          (vector+! gp-1 gp-1 (-> self root trans))
          (vector-lerp! gp-1 gp-1 (-> self parent-process 0 root-override trans) (rand-vu-float-range 0.2 0.8))
          (eco-blue-glow gp-1)
          )
        (suspend)
        )
      (none)
      )
    )
  :post (the-as (function none :behavior blue-eco-charger-orb) ja-post)
  )

;; definition for function blue-eco-charger-orb-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior blue-eco-charger-orb-init-by-other blue-eco-charger-orb ((arg0 entity-actor) (arg1 blue-eco-charger-orb))
  (set! (-> self entity) arg0)
  (set! (-> self root) (new 'process 'trsqv))
  (set! (-> self root trans quad) (-> arg1 root trans quad))
  (quaternion-copy! (-> self root quat) (-> arg1 root quat))
  (set! (-> self root scale quad) (-> arg1 root scale quad))
  (set! (-> self root trans y) (+ 14069.76 (-> self root trans y)))
  (set! (-> self rest-pos quad) (-> self root trans quad))
  (initialize-skeleton self *blue-eco-charger-orb-sg* '())
  (ja-channel-set! 1)
  (ja :group! (-> self draw art-group data 2) :num! min)
  (set-vector! (-> self orbit-rot) 0.0 0.0 0.0 1.0)
  (go blue-eco-charger-orb-idle)
  (none)
  )

;; definition for method 21 of type blue-eco-charger
(defmethod dummy-21 blue-eco-charger ((obj blue-eco-charger) (arg0 symbol))
  (let* ((v1-0 (-> obj master))
         (a0-1 (if v1-0
                   (-> v1-0 extra process)
                   )
               )
         )
    (when (not a0-1)
      (set! (-> obj master) (entity-actor-lookup (-> obj entity) 'alt-actor 0))
      (let ((v1-3 (-> obj master)))
        (set! a0-1 (if v1-3
                       (-> v1-3 extra process)
                       )
              )
        )
      )
    (if a0-1
        (send-event
          a0-1
          'notify
          (if arg0
              1
              2
              )
          (-> obj charger-id)
          )
        )
    )
  )

;; definition for method 20 of type blue-eco-charger
(defmethod dummy-20 blue-eco-charger ((obj blue-eco-charger))
  (and (and *target* (>= 16384.0 (vector-vector-distance (-> obj root-override trans) (-> *target* control trans))))
       (send-event *target* 'query 'powerup (pickup-type eco-blue))
       )
  )

;; failed to figure out what this is:
(defstate blue-eco-charger-idle (blue-eco-charger)
  :code (behavior ()
    (set! (-> self open-level) 0.0)
    (ja-channel-set! 1)
    (ja :group! (-> self draw art-group data 2) :num! min)
    (loop
      (when (logtest? (-> self draw status) (draw-status was-drawn))
        (if (and (and *target* (>= 16384.0 (vector-vector-distance (-> self root-override trans) (-> *target* control trans))))
                 (not (send-event *target* 'query 'powerup (pickup-type eco-blue)))
                 )
            (level-hint-spawn
              (game-text-id sunken-blue-eco-charger-hint)
              "sksp0125"
              (the-as entity #f)
              *entity-pool*
              (game-task none)
              )
            )
        )
      (when (dummy-20 self)
        (increment-success-for-hint (game-text-id sunken-blue-eco-charger-hint))
        (go blue-eco-charger-open #t)
        )
      (if (nonzero? (get-reminder (get-task-control (game-task sunken-room)) 0))
          (go blue-eco-charger-open #t)
          )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior blue-eco-charger) ja-post)
  )

;; failed to figure out what this is:
(defstate blue-eco-charger-open (blue-eco-charger)
  :enter (behavior ((arg0 symbol))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (if arg0
        (sound-play "blue-eco-start")
        )
    (dummy-21 self #t)
    (none)
    )
  :trans (behavior ()
    (if (dummy-20 self)
        (set! (-> self state-time) (-> *display* base-frame-counter))
        )
    (update! (-> self sound))
    (none)
    )
  :code (behavior ((arg0 symbol))
    (ja-no-eval :num! (seek!))
    (while (not (ja-done? 0))
      (suspend)
      (ja :num! (seek!))
      (set! (-> self open-level) (/ (ja-frame-num 0) (the float (+ (-> (ja-group) data 0 length) -1))))
      )
    (loop
      (cond
        ((zero? (get-reminder (get-task-control (game-task sunken-room)) 0))
         (when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 20))
           (level-hint-spawn
             (game-text-id sunken-blue-eco-charger-all-hint)
             "sksp0133"
             (the-as entity #f)
             *entity-pool*
             (game-task none)
             )
           (go blue-eco-charger-close)
           )
         )
        (else
          (go blue-eco-charger-stuck-open)
          )
        )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior blue-eco-charger) ja-post)
  )

;; failed to figure out what this is:
(defstate blue-eco-charger-stuck-open (blue-eco-charger)
  :trans (behavior ()
    (update! (-> self sound))
    (none)
    )
  :code (behavior ()
    (loop
      (logior! (-> self mask) (process-mask sleep-code))
      (suspend)
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate blue-eco-charger-close (blue-eco-charger)
  :exit (behavior ()
    (stop! (-> self sound))
    (none)
    )
  :code (behavior ()
    (ja-no-eval :num! (seek! 0.0))
    (while (not (ja-done? 0))
      (when (dummy-20 self)
        (increment-success-for-hint (game-text-id sunken-blue-eco-charger-hint))
        (go blue-eco-charger-open #t)
        )
      (if (nonzero? (get-reminder (get-task-control (game-task sunken-room)) 0))
          (go blue-eco-charger-open #t)
          )
      (update! (-> self sound))
      (suspend)
      (ja :num! (seek! 0.0))
      (set! (-> self open-level) (/ (ja-frame-num 0) (the float (+ (-> (ja-group) data 0 length) -1))))
      )
    (dummy-21 self #f)
    (go blue-eco-charger-idle)
    (none)
    )
  :post (the-as (function none :behavior blue-eco-charger) ja-post)
  )

;; definition for method 11 of type blue-eco-charger
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! blue-eco-charger ((obj blue-eco-charger) (arg0 entity-actor))
  (set! (-> obj open-level) 0.0)
  (let ((s4-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-player))))
    (let ((s3-0 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> s3-0 prim-core collide-as) (collide-kind wall-object))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core action) (collide-action solid))
      (set! (-> s3-0 prim-core offense) (collide-offense indestructible))
      (set! (-> s3-0 transform-index) 3)
      (set-vector! (-> s3-0 local-sphere) 8192.0 0.0 0.0 16384.0)
      (set-root-prim! s4-0 s3-0)
      )
    (set! (-> s4-0 nav-radius) 6553.6)
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (initialize-skeleton obj *blue-eco-charger-sg* '())
  (let ((f0-6 (res-lump-float (-> obj entity) 'rotoffset)))
    (if (!= f0-6 0.0)
        (quaternion-rotate-y! (-> obj root-override quat) (-> obj root-override quat) f0-6)
        )
    )
  (ja-channel-set! 1)
  (let ((s4-1 (-> obj skel root-channel 0)))
    (joint-control-channel-group-eval!
      s4-1
      (the-as art-joint-anim (-> obj draw art-group data 2))
      num-func-identity
      )
    (set! (-> s4-1 frame-num) 0.0)
    )
  (ja-post)
  (update-transforms! (-> obj root-override))
  (nav-mesh-connect obj (-> obj root-override) (the-as nav-control #f))
  (set! (-> obj master) (entity-actor-lookup arg0 'alt-actor 0))
  (set! (-> obj link) (new 'process 'actor-link-info obj))
  (set! (-> obj charger-id) (+ (actor-count-before (-> obj link)) 1))
  (process-spawn blue-eco-charger-orb (-> obj entity) obj :to obj)
  (set! (-> obj sound)
        (new 'process 'ambient-sound (static-sound-spec "blue-eco-charg" :fo-max 35) (-> obj root-override trans))
        )
  (if (zero? (get-reminder (get-task-control (game-task sunken-room)) 0))
      (go blue-eco-charger-idle)
      (go blue-eco-charger-open #f)
      )
  (none)
  )

;; definition of type exit-chamber-button
(deftype exit-chamber-button (basebutton)
  ()
  :heap-base #x90
  :method-count-assert 32
  :size-assert         #x100
  :flag-assert         #x2000900100
  )

;; definition for method 3 of type exit-chamber-button
(defmethod inspect exit-chamber-button ((obj exit-chamber-button))
  (let ((t9-0 (method-of-type basebutton inspect)))
    (t9-0 obj)
    )
  obj
  )

;; definition for function exit-chamber-button-init-by-other
(defbehavior exit-chamber-button-init-by-other exit-chamber-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)
  )

;; definition for method 20 of type exit-chamber
(defmethod dummy-20 exit-chamber ((obj exit-chamber) (arg0 float))
  (let ((f0-5 (+ (-> obj orig-trans y)
                 (* 2252.8 arg0 (cos (* 36.40889 (the float (mod (-> *display* base-frame-counter) 1800)))))
                 )
              )
        )
    (set! (-> obj root-override trans y) f0-5)
    f0-5
    )
  )

;; failed to figure out what this is:
(defpart 2515
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x9 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.6) (meters 0.2) 1.0)
    (sp-rnd-flt spt-scale-y (meters 0.3) (meters 0.1) 1.0)
    (sp-flt spt-r 128.0)
    (sp-flt spt-g 128.0)
    (sp-flt spt-b 128.0)
    (sp-rnd-flt spt-a 40.0 24.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.006666667) (meters 0.013333334) 1.0)
    (sp-flt spt-accel-y 2.7306666)
    (sp-flt spt-friction 0.96)
    (sp-int spt-timer 1500)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-flt spt-userdata 0.0)
    (sp-func spt-func 'check-water-level-above-and-die)
    )
  )

;; definition for method 24 of type exit-chamber
(defmethod dummy-24 exit-chamber ((obj exit-chamber) (arg0 float))
  (let ((s4-0 (-> obj node-list data 3 bone transform))
        (f30-0 (rand-vu-float-range 0.0 65536.0))
        (f28-0 (rand-vu-float-range 8192.0 40960.0))
        (gp-0 (new 'stack-no-clear 'vector))
        )
    (set-vector! gp-0 (* (sin f30-0) arg0) f28-0 (* (cos f30-0) arg0) 1.0)
    (vector-matrix*! gp-0 gp-0 s4-0)
    (vector-float*! gp-0 gp-0 (/ 1.0 (-> gp-0 w)))
    (set! (-> *part-id-table* 2515 init-specs 13 initial-valuef) (+ 24576.0 (-> gp-0 y)))
    (sp-launch-particles-var
      *sp-particle-system-2d*
      (-> *part-id-table* 2515)
      gp-0
      (the-as sparticle-launch-state #f)
      (the-as sparticle-launch-control #f)
      1.0
      )
    )
  (none)
  )

;; definition for method 21 of type exit-chamber
(defmethod dummy-21 exit-chamber ((obj exit-chamber) (arg0 exit-chamber-items))
  (let ((s5-0 (-> obj node-list data 3 bone transform)))
    (set-vector! (-> arg0 door-pos) 0.0 13107.2 -40960.0 1.0)
    (vector-matrix*! (-> arg0 door-pos) (-> arg0 door-pos) s5-0)
    (vector-float*! (-> arg0 door-pos) (-> arg0 door-pos) (/ 1.0 (-> arg0 door-pos w)))
    (matrix->quaternion (-> arg0 door-quat) s5-0)
    (set-vector! (-> arg0 button-pos) 0.0 -3072.0 0.0 1.0)
    (vector-matrix*! (-> arg0 button-pos) (-> arg0 button-pos) s5-0)
    (vector-float*! (-> arg0 button-pos) (-> arg0 button-pos) (/ 1.0 (-> arg0 button-pos w)))
    (quaternion-copy! (-> arg0 button-quat) (-> arg0 door-quat))
    (set-vector! (-> arg0 fcell-pos) 0.0 68300.8 0.0 1.0)
    (vector-matrix*! (-> arg0 fcell-pos) (-> arg0 fcell-pos) s5-0)
    )
  (vector-float*! (-> arg0 fcell-pos) (-> arg0 fcell-pos) (/ 1.0 (-> arg0 fcell-pos w)))
  )

;; definition for method 23 of type exit-chamber
;; INFO: Used lq/sq
(defmethod dummy-23 exit-chamber ((obj exit-chamber) (arg0 symbol))
  (new 'stack-no-clear 'vector)
  (let ((s5-0 (new 'stack-no-clear 'vector)))
    (vector<-cspace! (-> obj last-pos) (-> obj node-list data 3))
    (vector-! s5-0 (-> obj last-pos) (-> obj root-override trans))
    (set! (-> obj draw bounds quad) (-> s5-0 quad))
    )
  (set! (-> obj draw bounds y) (+ 16384.0 (-> obj draw bounds y)))
  (set! (-> obj draw bounds w) 67584.0)
  (let ((s5-1 (new 'stack-no-clear 'exit-chamber-items)))
    (dummy-21 obj s5-1)
    (if (-> obj button)
        (send-event (ppointer->process (-> obj button)) 'move-to (-> s5-1 button-pos) (-> s5-1 button-quat))
        )
    (when (and *target* (-> obj move-player?))
      (let ((a1-6 (new 'stack-no-clear 'vector)))
        (set! (-> a1-6 quad) (-> s5-1 button-pos quad))
        (set! (-> a1-6 y) (+ 2662.4 (-> a1-6 y)))
        (move-to-point! (-> *target* control) a1-6)
        )
      (vector-reset! (-> *target* control transv))
      )
    (if (-> obj door)
        (send-event (ppointer->process (-> obj door)) 'move-to (-> s5-1 door-pos) (-> s5-1 door-quat))
        )
    (when arg0
      (let ((a0-12 (handle->process (-> obj fcell-handle))))
        (when a0-12
          (when (or (-> obj move-fcell?) (< (-> (the-as fuel-cell a0-12) root-override trans y) (-> s5-1 fcell-pos y)))
            (when (not (-> obj move-fcell?))
              (set! (-> obj move-fcell?) #t)
              (let ((v1-50 (-> obj entity extra perm)))
                (logior! (-> v1-50 status) (entity-perm-status user-set-from-cstage))
                (set! (-> v1-50 user-int8 0) 1)
                )
              )
            (send-event a0-12 'trans (-> s5-1 fcell-pos))
            )
          )
        )
      )
    )
  )

;; failed to figure out what this is:
(defstate exit-chamber-charger-puzzle (exit-chamber)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (local-vars (v0-0 object))
    (case arg2
      (('notify)
       (case (-> arg3 param 0)
         ((1)
          (when (zero? (get-reminder (get-task-control (game-task sunken-room)) 0))
            (let* ((a1-2 (-> arg3 param 1))
                   (v1-5 (logior (-> self chargers-active) (ash 1 a1-2)))
                   )
              (set! (-> self chargers-active) v1-5)
              (when (= v1-5 62)
                (save-reminder (get-task-control (game-task sunken-room)) 1 0)
                (go exit-chamber-charger-puzzle-beaten)
                (return #t)
                v0-0
                )
              )
            )
          )
         ((2)
          (when (zero? (get-reminder (get-task-control (game-task sunken-room)) 0))
            (let ((a1-6 (-> arg3 param 1)))
              (set! v0-0 (logclear (-> self chargers-active) (ash 1 a1-6)))
              )
            (set! (-> self chargers-active) (the-as uint v0-0))
            v0-0
            )
          )
         )
       )
      )
    )
  :exit (behavior ()
    (logclear! (-> self draw status) (draw-status hidden))
    (none)
    )
  :code (behavior ()
    (loop
      (if (>= 214228270000.0 (vector-vector-distance-squared (camera-pos) (-> self root-override trans)))
          (logclear! (-> self draw status) (draw-status hidden))
          (logior! (-> self draw status) (draw-status hidden))
          )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior exit-chamber) ja-post)
  )

;; failed to figure out what this is:
(defstate exit-chamber-charger-puzzle-beaten (exit-chamber)
  :code (behavior ()
    (process-spawn
      pov-camera
      (-> self root-override trans)
      *sunkencam-sg*
      "exit-chamber-door-open"
      0
      #f
      '()
      :to self
      )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 2.5))
      (suspend)
      )
    (send-event (ppointer->process (-> self door)) 'trigger)
    (go exit-chamber-idle-in-sunken)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate exit-chamber-idle-in-sunken (exit-chamber)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (local-vars (v0-1 object))
    (case arg2
      (('trigger)
       (go exit-chamber-rise)
       (return #t)
       v0-1
       )
      (('notify)
       (when (and (= (-> arg0 type) fuel-cell) (= (-> arg3 param 0) 'pickup))
         (let ((a0-5 (handle->process (-> self fcell-handle))))
           (when a0-5
             (let ((v1-10 (new 'stack-no-clear 'vector)))
               (set-vector! v1-10 0.0 64102.4 0.0 1.0)
               (vector+! v1-10 v1-10 (-> self last-pos))
               (send-event a0-5 'set-movie-pos v1-10)
               )
             )
           )
         )
       )
      )
    )
  :exit (behavior ()
    (logclear! (-> self draw status) (draw-status hidden))
    (none)
    )
  :code (behavior ()
    (save-reminder (get-task-control (game-task sunken-room)) 1 0)
    (set! (-> self wave-scale) 0.0)
    (if (-> self door)
        (send-event (ppointer->process (-> self door)) 'trigger)
        )
    (if (-> self button)
        (send-event (ppointer->process (-> self button)) 'untrigger)
        )
    (loop
      (if (>= 214228270000.0 (vector-vector-distance-squared (camera-pos) (-> self root-override trans)))
          (logclear! (-> self draw status) (draw-status hidden))
          (logior! (-> self draw status) (draw-status hidden))
          )
      (suspend)
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate exit-chamber-rise (exit-chamber)
  :enter (behavior ()
    (set! (-> self move-player?) #f)
    (none)
    )
  :trans (behavior ()
    (if (not (-> self move-player?))
        (rider-trans)
        )
    (none)
    )
  :code (behavior ()
    (aybabtu 2)
    (let ((v1-1 (handle->process (-> self fcell-handle))))
      (if v1-1
          (clear-collide-with-as (-> (the-as fuel-cell v1-1) root-override))
          )
      )
    (close-specific-task! (game-task sunken-room) (task-status need-reminder))
    (send-event *target* 'reset-pickup 'eco)
    (let ((gp-0 (get-process *default-dead-pool* sunkencam #x4000)))
      (set! (-> (the-as sunkencam (-> (when gp-0
                                        (let ((t9-5 (method-of-type sunkencam activate)))
                                          (t9-5 (the-as sunkencam gp-0) self 'sunkencam (the-as pointer #x70004000))
                                          )
                                        (run-now-in-process
                                          gp-0
                                          pov-camera-init-by-other
                                          (-> self root-override trans)
                                          *sunkencam-sg*
                                          "qbert-show-door-open"
                                          0
                                          #f
                                          '()
                                          )
                                        (-> gp-0 ppointer)
                                        )
                                      0
                                      )
                        )
                seq
                )
            (the-as uint 0)
            )
      )
    0
    (suspend)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (let ((gp-1 #f))
      (ja-no-eval :group! (-> self draw art-group data 3) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (when (and (not gp-1) (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.75)) (-> self door))
          (set! gp-1 #t)
          (send-event (ppointer->process (-> self door)) 'untrigger)
          )
        (suspend)
        (ja :num! (seek!))
        )
      )
    (set! (-> self move-player?) #t)
    (ja-no-eval :group! (-> self draw art-group data 4) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (load-state-want-levels 'sunken 'village2)
    (ja-no-eval :group! (-> self draw art-group data 5) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (dummy-24 self 51200.0)
      (update-trans! (-> self sound) (-> self last-pos))
      (update! (-> self sound))
      (suspend)
      (ja :num! (seek!))
      )
    (stop! (-> self sound))
    (load-state-want-display-level 'village2 'display)
    (load-state-want-display-level 'sunken 'special)
    (let ((gp-2 #f))
      (ja-no-eval :group! (-> self draw art-group data 6) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (seek! (-> self wave-scale) 1.0 0.0016666667)
        (dummy-20 self (-> self wave-scale))
        (if (and (-> self move-player?) (>= (ja-aframe-num 0) 310.0))
            (set! (-> self move-player?) #f)
            )
        (let ((a0-36 (new 'stack-no-clear 'vector)))
          (set! (-> a0-36 quad) (-> self last-pos quad))
          (set! (-> a0-36 y) (+ 51814.4 (-> a0-36 y)))
          (when (>= (-> a0-36 y) (ocean-get-height a0-36))
            (if (not gp-2)
                (set! gp-2 #t)
                )
            (spawn (-> self part) (-> self last-pos))
            (spawn (-> self part) (-> self last-pos))
            (spawn (-> self part) (-> self last-pos))
            )
          )
        (suspend)
        (ja :num! (seek!))
        )
      )
    (kill-and-free-particles (-> self part))
    (load-state-want-vis 'vi2)
    (send-event *target* 'dry)
    (let ((v1-143 (handle->process (-> self fcell-handle))))
      (if v1-143
          (restore-collide-with-as (-> (the-as fuel-cell v1-143) root-override))
          )
      )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.5))
      (seek! (-> self wave-scale) 1.0 0.0016666667)
      (dummy-20 self (-> self wave-scale))
      (suspend)
      )
    (if (-> self door)
        (send-event (ppointer->process (-> self door)) 'trigger)
        )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 2.5))
      (seek! (-> self wave-scale) 1.0 0.0016666667)
      (dummy-20 self (-> self wave-scale))
      (suspend)
      )
    (go exit-chamber-idle-in-village #f)
    (none)
    )
  :post (behavior ()
    (if (-> self move-player?)
        (transform-post)
        (rider-post)
        )
    (dummy-23 self #t)
    (none)
    )
  )

;; failed to figure out what this is:
(defstate exit-chamber-idle-in-village (exit-chamber)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('trigger)
       (go exit-chamber-lower)
       )
      (('notify)
       (when (and (= (-> arg0 type) fuel-cell) (= (-> arg3 param 0) 'pickup))
         (let ((a0-5 (handle->process (-> self fcell-handle))))
           (when a0-5
             (let ((v1-8 (new 'stack-no-clear 'vector)))
               (set-vector! v1-8 0.0 64102.4 0.0 1.0)
               (vector+! v1-8 v1-8 (-> self last-pos))
               (send-event a0-5 'set-movie-pos v1-8)
               )
             )
           )
         )
       )
      )
    )
  :enter (behavior ((arg0 symbol))
    (set! (-> self mask) (logior (process-mask platform) (-> self mask)))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :exit (behavior ()
    (logclear! (-> self mask) (process-mask platform))
    (none)
    )
  :trans (behavior ()
    (rider-trans)
    (when *target*
      (let ((f30-0 (vector-vector-xz-distance (target-pos 0) (-> self last-pos))))
        (when (-> self door)
          (if (and *target* (>= 114688.0 f30-0))
              (send-event (ppointer->process (-> self door)) 'trigger)
              (send-event (ppointer->process (-> self door)) 'untrigger)
              )
          )
        (when (and (-> self play-assistant-message?) (>= f30-0 57344.0))
          (set! (-> self play-assistant-message?) #f)
          (level-hint-spawn
            (game-text-id sunken-room-resolution)
            "asstvb22"
            (the-as entity #f)
            *entity-pool*
            (game-task none)
            )
          )
        )
      )
    (none)
    )
  :code (behavior ((arg0 symbol))
    (set! (-> self move-player?) #f)
    (set! (-> self wave-scale) 1.0)
    (save-reminder (get-task-control (game-task sunken-room)) 2 0)
    (if (-> self button)
        (send-event (ppointer->process (-> self button)) 'untrigger)
        )
    (when arg0
      (logior! (-> self draw status) (draw-status skip-bones))
      (dummy-20 self 1.0)
      (suspend)
      (logclear! (-> self draw status) (draw-status skip-bones))
      )
    (loop
      (dummy-20 self 1.0)
      (suspend)
      )
    (none)
    )
  :post (behavior ()
    (rider-post)
    (dummy-23 self #t)
    (if (and *target* (>= (vector-vector-xz-distance (target-pos 0) (-> self last-pos)) 40960.0))
        (spawn (-> self part) (-> self last-pos))
        )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate exit-chamber-lower (exit-chamber)
  :enter (behavior ()
    (set! (-> self move-player?) #t)
    (let ((v1-2 (handle->process (-> self fcell-handle))))
      (if v1-2
          (clear-collide-with-as (-> (the-as fuel-cell v1-2) root-override))
          )
      )
    (none)
    )
  :trans (behavior ()
    (if (not (-> self move-player?))
        (rider-trans)
        )
    (seek! (-> self wave-scale) 0.0 0.0016666667)
    (dummy-20 self (-> self wave-scale))
    (none)
    )
  :code (behavior ()
    (let ((v1-1 (process-spawn
                  sunkencam
                  :init pov-camera-init-by-other
                  (-> self root-override trans)
                  *sunkencam-sg*
                  "qbert-show-door-open"
                  0
                  #f
                  '()
                  :to self
                  )
                )
          )
      (set! (-> (the-as sunkencam (-> v1-1 0)) seq) (the-as uint 1))
      )
    (load-state-want-display-level 'sunken 'display)
    (suspend)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (let ((gp-1 #f)
          (s5-0 #f)
          )
      (ja-no-eval :group! (-> self draw art-group data 7) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (when (and (not gp-1) (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.25)) (-> self door))
          (set! gp-1 #t)
          (send-event (ppointer->process (-> self door)) 'untrigger)
          )
        (when (+ (-> *display* base-frame-counter) (seconds -0.1))
          (let ((a0-9 (new 'stack-no-clear 'vector)))
            (set! (-> a0-9 quad) (-> self last-pos quad))
            (set! (-> a0-9 y) (+ 64102.4 (-> a0-9 y)))
            (when (< (-> a0-9 y) (+ 12288.0 (ocean-get-height a0-9)))
              (if (not s5-0)
                  (set! s5-0 #t)
                  )
              )
            )
          (spawn (-> self part) (-> self last-pos))
          )
        (suspend)
        (ja :num! (seek!))
        )
      )
    (load-state-want-levels 'sunken 'sunkenb)
    (kill-and-free-particles (-> self part))
    (ja-no-eval :group! (-> self draw art-group data 8) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (dummy-24 self 47104.0)
      (update-trans! (-> self sound) (-> self last-pos))
      (update! (-> self sound))
      (suspend)
      (ja :num! (seek!))
      )
    (stop! (-> self sound))
    (load-state-want-display-level 'sunkenb 'display)
    (load-state-want-vis 'sub)
    (ja-no-eval :group! (-> self draw art-group data 9) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (set! (-> self move-player?) #f)
    (if (-> self door)
        (send-event (ppointer->process (-> self door)) 'trigger)
        )
    (let ((v1-109 (handle->process (-> self fcell-handle))))
      (if v1-109
          (restore-collide-with-as (-> (the-as fuel-cell v1-109) root-override))
          )
      )
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
      (suspend)
      )
    (set-continue! *game-info* "sunkenb-start")
    (go exit-chamber-idle-in-sunken)
    (none)
    )
  :post (behavior ()
    (if (-> self move-player?)
        (transform-post)
        (rider-post)
        )
    (dummy-23 self #t)
    (none)
    )
  )

;; definition for method 11 of type exit-chamber
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! exit-chamber ((obj exit-chamber) (arg0 entity-actor))
  (process-entity-status! obj (entity-perm-status bit-3) #t)
  (process-entity-status! obj (entity-perm-status bit-7) #t)
  (set! (-> obj move-player?) #f)
  (set! (-> obj move-fcell?) #f)
  (set! (-> obj play-assistant-message?) #t)
  (set! (-> obj wave-scale) 0.0)
  (set! (-> obj fcell-handle) (the-as handle #f))
  (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-others))))
    (set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s4-0 reaction) default-collision-reaction)
    (set! (-> s4-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (alloc-riders s4-0 1)
    (let ((s3-0 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> s3-0 prim-core collide-as) (collide-kind ground-object))
      (set! (-> s3-0 collide-with) (collide-kind target))
      (set! (-> s3-0 prim-core action) (collide-action solid ca-1))
      (set! (-> s3-0 prim-core offense) (collide-offense indestructible))
      (set! (-> s3-0 transform-index) 3)
      (set-vector! (-> s3-0 local-sphere) 0.0 16384.0 0.0 67584.0)
      (set-root-prim! s4-0 s3-0)
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (initialize-skeleton obj *exit-chamber-sg* '())
  (logior! (-> obj skel status) (janim-status inited))
  (logclear! (-> obj mask) (process-mask actor-pause))
  (set! (-> obj part) (create-launch-control (-> *part-group-id-table* 620) obj))
  (ja-channel-set! 1)
  (let ((s4-1 (get-reminder (get-task-control (game-task sunken-room)) 0)))
    (let ((s2-0 #f)
          (s3-1 (new 'stack-no-clear 'matrix))
          )
      (let ((a0-17 (-> obj entity extra perm)))
        (set! (-> obj move-fcell?) (nonzero? (-> a0-17 user-int8 0)))
        )
      (let ((v1-35 s4-1))
        (cond
          ((zero? v1-35)
           (set! (-> obj chargers-active) (the-as uint 0))
           (let ((s1-0 (-> obj skel root-channel 0)))
             (joint-control-channel-group-eval!
               s1-0
               (the-as art-joint-anim (-> obj draw art-group data 2))
               num-func-identity
               )
             (set! (-> s1-0 frame-num) 0.0)
             )
           )
          ((= v1-35 1)
           (set! (-> obj chargers-active) (the-as uint 62))
           (let ((s1-1 (-> obj skel root-channel 0)))
             (joint-control-channel-group-eval!
               s1-1
               (the-as art-joint-anim (-> obj draw art-group data 2))
               num-func-identity
               )
             (set! (-> s1-1 frame-num) 0.0)
             )
           )
          ((= v1-35 2)
           (set! (-> obj chargers-active) (the-as uint 62))
           (let ((s1-2 (-> obj skel root-channel 0)))
             (joint-control-channel-group-eval!
               s1-2
               (the-as art-joint-anim (-> obj draw art-group data 6))
               num-func-identity
               )
             (set! (-> s1-2 frame-num)
                   (the float (+ (-> (the-as art-joint-anim (-> obj draw art-group data 6)) data 0 length) -1))
                   )
             )
           )
          )
        )
      (ja-post)
      (update-transforms! (-> obj root-override))
      (dummy-21 obj (the-as exit-chamber-items s3-1))
      (let ((s1-3 #t))
        (let ((v1-64 s4-1))
          (cond
            ((zero? v1-64)
             (set! s1-3 #f)
             )
            ((= v1-64 2)
             (if (or (not *target*) (< 114688.0 (vector-vector-xz-distance (target-pos 0) (-> obj last-pos))))
                 (set! s1-3 #f)
                 )
             )
            )
          )
        (set! (-> obj door) (process-spawn sun-iris-door (-> s3-1 vector) (-> s3-1 vector 1) s1-3 :to obj))
        )
      (set! (-> obj button)
            (process-spawn exit-chamber-button (-> s3-1 vector 2) (-> s3-1 vector 3) arg0 #f :to obj)
            )
      (set! (-> obj sound) (new
                             'process
                             'ambient-sound
                             (static-sound-spec "chamber-move" :fo-min 300 :fo-max 400)
                             (-> obj root-override trans)
                             )
            )
      (when (not (task-complete? *game-info* (game-task sunken-room)))
        (let ((a0-40 (new 'stack-no-clear 'vector)))
          (if s2-0
              (set! (-> a0-40 quad) (-> (&+ s3-1 64) vector 0 quad))
              (set-vector! a0-40 2357755.5 -882327.1 -6879603.0 1.0)
              )
          (set! (-> obj fcell-handle) (ppointer->handle (birth-pickup-at-point
                                                          a0-40
                                                          (pickup-type fuel-cell)
                                                          (the float (-> obj entity extra perm task))
                                                          #f
                                                          obj
                                                          (the-as fact-info #f)
                                                          )
                                                        )
                )
          )
        )
      )
    (set! (-> obj orig-trans quad) (-> obj root-override trans quad))
    (set! (-> obj last-pos quad) (-> obj root-override trans quad))
    (set! (-> obj move-player?) #f)
    (dummy-23 obj #t)
    (set! (-> obj move-player?) #f)
    (cond
      ((zero? s4-1)
       (go exit-chamber-charger-puzzle)
       )
      ((= s4-1 1)
       (go exit-chamber-idle-in-sunken)
       )
      ((= s4-1 2)
       (go exit-chamber-idle-in-village #t)
       )
      )
    )
  (none)
  )
