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

(import "goal_src/jak1/import/snow-button-ag.gc")
(import "goal_src/jak1/import/flutflut-plat-med-ag.gc")
(import "goal_src/jak1/import/flutflut-plat-small-ag.gc")
(import "goal_src/jak1/import/flutflut-plat-large-ag.gc")

;; definition of type flutflut-plat
(deftype flutflut-plat (plat)
  ((has-path?           symbol               :offset-assert 264)
   (plat-type           int32                :offset-assert 268)
   (rise-time           int32                :offset-assert 272)
   (fall-time           int32                :offset-assert 276)
   (part-ry             float                :offset-assert 280)
   (sync-starting-val   float                :offset-assert 284)
   (flutflut-button     entity-actor         :offset-assert 288)
   (appear-trans-top    vector       :inline :offset-assert 304)
   (appear-trans-bottom vector       :inline :offset-assert 320)
   (appear-quat-top     quaternion   :inline :offset-assert 336)
   (appear-quat-bottom  quaternion   :inline :offset-assert 352)
   (start-trans         vector       :inline :offset-assert 368)
   )
  :heap-base #x110
  :method-count-assert 33
  :size-assert         #x180
  :flag-assert         #x2101100180
  (:states
    elevator-idle-at-cave
    elevator-idle-at-fort
    elevator-travel-to-cave
    elevator-travel-to-fort
    flutflut-plat-appear
    flutflut-plat-hidden-idle
    flutflut-plat-hide
    )
  )

;; definition for method 3 of type flutflut-plat
(defmethod inspect flutflut-plat ((obj flutflut-plat))
  (let ((t9-0 (method-of-type plat inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Thas-path?: ~A~%" (-> obj has-path?))
  (format #t "~T~Tplat-type: ~D~%" (-> obj plat-type))
  (format #t "~T~Trise-time: ~D~%" (-> obj rise-time))
  (format #t "~T~Tfall-time: ~D~%" (-> obj fall-time))
  (format #t "~T~Tpart-ry: ~f~%" (-> obj part-ry))
  (format #t "~T~Tsync-starting-val: ~f~%" (-> obj sync-starting-val))
  (format #t "~T~Tflutflut-button: ~A~%" (-> obj flutflut-button))
  (format #t "~T~Tappear-trans-top: #<vector @ #x~X>~%" (-> obj appear-trans-top))
  (format #t "~T~Tappear-trans-bottom: #<vector @ #x~X>~%" (-> obj appear-trans-bottom))
  (format #t "~T~Tappear-quat-top: #<quaternion @ #x~X>~%" (-> obj appear-quat-top))
  (format #t "~T~Tappear-quat-bottom: #<quaternion @ #x~X>~%" (-> obj appear-quat-bottom))
  (format #t "~T~Tstart-trans: #<vector @ #x~X>~%" (-> obj start-trans))
  obj
  )

;; definition of type snow-button
(deftype snow-button (process-drawable)
  ((root-override         collide-shape-moving         :offset        112)
   (wiggled?              symbol                       :offset-assert 176)
   (trying-for-fuel-cell? symbol                       :offset-assert 180)
   (timeout               time-frame                   :offset-assert 184)
   (delay-til-wiggle      time-frame                   :offset-assert 192)
   (prev-button           entity-actor                 :offset-assert 200)
   (ticker                ticky                :inline :offset-assert 208)
   )
  :heap-base #x80
  :method-count-assert 20
  :size-assert         #xf0
  :flag-assert         #x14008000f0
  (:states
    snow-button-activate
    snow-button-deactivate
    snow-button-up-idle
    )
  )

;; definition for method 3 of type snow-button
(defmethod inspect snow-button ((obj snow-button))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Twiggled?: ~A~%" (-> obj wiggled?))
  (format #t "~T~Ttimeout: ~D~%" (-> obj timeout))
  (format #t "~T~Tdelay-til-wiggle: ~D~%" (-> obj delay-til-wiggle))
  (format #t "~T~Tprev-button: ~A~%" (-> obj prev-button))
  (format #t "~T~Tticker: #<ticky @ #x~X>~%" (-> obj ticker))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *flutflut-plat-small-sg* flutflut-plat-small flutflut-plat-small-lod0-jg flutflut-plat-small-idle-ja
              ((flutflut-plat-small-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 -0.5 0 4)
              )

;; failed to figure out what this is:
(defskelgroup *flutflut-plat-med-sg* flutflut-plat-med flutflut-plat-med-lod0-jg flutflut-plat-med-idle-ja
              ((flutflut-plat-med-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 -1 0 6.75)
              )

;; failed to figure out what this is:
(defskelgroup *flutflut-plat-large-sg* flutflut-plat-large flutflut-plat-large-lod0-jg flutflut-plat-large-idle-ja
              ((flutflut-plat-large-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 9)
              )

;; failed to figure out what this is:
(defskelgroup *snow-button-sg* snow-button snow-button-lod0-jg -1
              ((snow-button-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 4.3)
              )

;; failed to figure out what this is:
(defpartgroup group-flutflut-plat-small
  :id 516
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 2087 :fade-after (meters 50) :falloff-to (meters 50))
    (sp-item 2088 :fade-after (meters 120) :falloff-to (meters 120))
    )
  )

;; failed to figure out what this is:
(defpart 2087
  :init-specs ((sp-flt spt-num 1.5)
    (sp-rnd-flt spt-x (meters -2) (meters 4) 1.0)
    (sp-flt spt-y (meters -1))
    (sp-rnd-flt spt-z (meters -2) (meters 4) 1.0)
    (sp-int spt-rot-x 5)
    (sp-flt spt-r 5324.8)
    (sp-flt spt-g 4096.0)
    (sp-flt spt-b 3686.4)
    (sp-flt spt-vel-y (meters -0.0033333334))
    (sp-flt spt-fade-b -16.383999)
    (sp-int spt-timer 25)
    (sp-cpuinfo-flags aux-list)
    (sp-flt spt-rotate-y (degrees 45.0))
    )
  )

;; failed to figure out what this is:
(defpart 2088
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 3.0)
    (sp-rnd-flt spt-x (meters -3) (meters 6) 1.0)
    (sp-flt spt-y (meters -1.25))
    (sp-rnd-flt spt-z (meters -3) (meters 6) 1.0)
    (sp-rnd-flt spt-scale-x (meters 2.5) (meters 1.5) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-g 0.0 64.0 1.0)
    (sp-rnd-flt spt-b 128.0 128.0 1.0)
    (sp-rnd-flt spt-a 16.0 32.0 1.0)
    (sp-flt spt-vel-y (meters -0.01))
    (sp-flt spt-fade-g -0.42666668)
    (sp-flt spt-fade-a -0.32)
    (sp-flt spt-accel-y -0.13653333)
    (sp-flt spt-friction 0.96)
    (sp-int spt-timer 150)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-flt spt-rotate-y (degrees 45.0))
    )
  )

;; failed to figure out what this is:
(defpartgroup group-flutflut-plat-med
  :id 517
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 2089 :fade-after (meters 50) :falloff-to (meters 50))
    (sp-item 2090 :fade-after (meters 120) :falloff-to (meters 120))
    )
  )

;; failed to figure out what this is:
(defpart 2089
  :init-specs ((sp-flt spt-num 3.0)
    (sp-flt spt-y (meters -2.5))
    (sp-int spt-rot-x 5)
    (sp-flt spt-r 5324.8)
    (sp-flt spt-g 4096.0)
    (sp-flt spt-b 3686.4)
    (sp-flt spt-vel-y (meters 0.0033333334))
    (sp-flt spt-fade-b -16.383999)
    (sp-int spt-timer 25)
    (sp-cpuinfo-flags aux-list)
    (sp-flt spt-conerot-x (degrees 90.0))
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 1) (meters 3) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2090
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 6.0)
    (sp-flt spt-y (meters -2.25))
    (sp-rnd-flt spt-scale-x (meters 3) (meters 2) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-g 0.0 64.0 1.0)
    (sp-rnd-flt spt-b 128.0 128.0 1.0)
    (sp-rnd-flt spt-a 16.0 32.0 1.0)
    (sp-flt spt-vel-y (meters 0.01))
    (sp-flt spt-fade-g -0.42666668)
    (sp-flt spt-fade-a -0.32)
    (sp-flt spt-accel-y -0.13653333)
    (sp-flt spt-friction 0.96)
    (sp-int spt-timer 150)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-flt spt-conerot-x (degrees 90.0))
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-radius (meters 1) (meters 3) 1.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-flutflut-plat-large
  :id 518
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 8)
  :parts ((sp-item 2091 :fade-after (meters 50) :falloff-to (meters 50))
    (sp-item 2092 :fade-after (meters 120) :falloff-to (meters 120))
    )
  )

;; failed to figure out what this is:
(defpart 2091
  :init-specs ((sp-flt spt-num 4.0)
    (sp-rnd-flt spt-x (meters -2) (meters 4) 1.0)
    (sp-flt spt-y (meters -1.5))
    (sp-rnd-flt spt-z (meters -6) (meters 12) 1.0)
    (sp-int spt-rot-x 5)
    (sp-flt spt-r 5324.8)
    (sp-flt spt-g 4096.0)
    (sp-flt spt-b 3686.4)
    (sp-flt spt-vel-y (meters -0.0033333334))
    (sp-flt spt-fade-b -16.383999)
    (sp-int spt-timer 25)
    (sp-cpuinfo-flags aux-list)
    (sp-flt spt-rotate-y (degrees 30.0))
    )
  )

;; failed to figure out what this is:
(defpart 2092
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-flt spt-num 8.0)
    (sp-rnd-flt spt-x (meters -2) (meters 4) 1.0)
    (sp-flt spt-y (meters -1.25))
    (sp-rnd-flt spt-z (meters -6) (meters 12) 1.0)
    (sp-rnd-flt spt-scale-x (meters 3) (meters 2) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-g 0.0 64.0 1.0)
    (sp-rnd-flt spt-b 128.0 128.0 1.0)
    (sp-rnd-flt spt-a 16.0 32.0 1.0)
    (sp-flt spt-vel-y (meters -0.01))
    (sp-flt spt-fade-g -0.42666668)
    (sp-flt spt-fade-a -0.32)
    (sp-flt spt-accel-y -0.13653333)
    (sp-flt spt-friction 0.96)
    (sp-int spt-timer 150)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-flt spt-rotate-y (degrees 30.0))
    )
  )

;; failed to figure out what this is:
(defstate snow-button-up-idle (snow-button)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (local-vars (v0-2 object))
    (case arg2
      (('touch 'attack 'bonk)
       (when (and (= (-> arg0 type) target)
                  (logtest? (-> *target* control root-prim prim-core action) (collide-action ca-14))
                  (>= 10649.6 (vector-vector-xz-distance (-> self root-override trans) (target-pos 0)))
                  )
         (close-specific-task! (game-task snow-ball) (task-status need-hint))
         (logclear! (-> self mask) (process-mask actor-pause))
         (process-entity-status! self (entity-perm-status bit-3) #t)
         (go snow-button-activate)
         )
       )
      (('query)
       (return #f)
       v0-2
       )
      )
    )
  :code (behavior ()
    (ja :group! (-> self draw art-group data 2) :num! min)
    (transform-post)
    (logior! (-> self mask) (process-mask sleep-code))
    (suspend)
    0
    (none)
    )
  )

;; failed to figure out what this is:
(defstate snow-button-activate (snow-button)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (local-vars (v0-0 object))
    (case arg2
      (('untrigger)
       (go snow-button-deactivate)
       )
      (('query)
       (return #t)
       v0-0
       )
      )
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (set! (-> self wiggled?) #f)
    (sleep (-> self ticker) (-> self timeout))
    (when (-> self prev-button)
      (let* ((v1-6 (-> self prev-button))
             (a0-1 (if v1-6
                       (-> v1-6 extra process)
                       )
                   )
             )
        (if a0-1
            (send-event a0-1 'untrigger)
            )
        )
      )
    (send-to-all-after (-> self link) 'trigger)
    (none)
    )
  :trans (behavior ()
    (if (completed? (-> self ticker))
        (go snow-button-deactivate)
        )
    (when (reached-delay? (-> self ticker) (-> self delay-til-wiggle))
      (when (not (-> self wiggled?))
        (set! (-> self wiggled?) #t)
        (send-to-all-after (-> self link) 'bounce)
        )
      )
    (rider-trans)
    (none)
    )
  :code (behavior ()
    (sound-play "prec-button1" :pitch -1)
    (ja-no-eval :group! (-> self draw art-group data 2) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (logior! (-> self mask) (process-mask sleep-code))
    (suspend)
    0
    (none)
    )
  :post (the-as (function none :behavior snow-button) rider-post)
  )

;; failed to figure out what this is:
(defstate snow-button-deactivate (snow-button)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (local-vars (v0-0 symbol))
    (case arg2
      (('query)
       (return (the-as object #f))
       v0-0
       )
      )
    )
  :exit (behavior ()
    (logior! (-> self mask) (process-mask actor-pause))
    (process-entity-status! self (entity-perm-status bit-3) #f)
    (none)
    )
  :trans (the-as (function none :behavior snow-button) rider-trans)
  :code (behavior ()
    (send-to-all-after (-> self link) 'untrigger)
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.6))
      (suspend)
      )
    (ja-no-eval :group! (-> self draw art-group data 3) :num! (seek!) :frame-num 0.0)
    (until (ja-done? 0)
      (suspend)
      (ja :num! (seek!))
      )
    (go snow-button-up-idle)
    (none)
    )
  :post (the-as (function none :behavior snow-button) rider-post)
  )

;; definition for method 11 of type snow-button
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! snow-button ((obj snow-button) (arg0 entity-actor))
  (let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
    (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-group s4-0 (the-as uint 3) 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-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 17612.8)
      (set-root-prim! s4-0 s3-0)
      (let ((s2-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
        (set! (-> s2-0 prim-core collide-as) (collide-kind ground-object))
        (set! (-> s2-0 collide-with) (collide-kind target))
        (set! (-> s2-0 prim-core offense) (collide-offense no-offense))
        (set! (-> s2-0 transform-index) 4)
        (set-vector! (-> s2-0 local-sphere) 0.0 0.0 0.0 10649.6)
        (append-prim s3-0 s2-0)
        )
      (let ((s2-1 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 1))))
        (set! (-> s2-1 prim-core collide-as) (collide-kind ground-object))
        (set! (-> s2-1 collide-with) (collide-kind target))
        (set! (-> s2-1 prim-core action) (collide-action solid ca-1))
        (set! (-> s2-1 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-1 transform-index) 4)
        (set-vector! (-> s2-1 local-sphere) 0.0 2048.0 0.0 11468.8)
        (append-prim s3-0 s2-1)
        )
      (let ((s2-2 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 1) (the-as uint 2))))
        (set! (-> s2-2 prim-core collide-as) (collide-kind ground-object))
        (set! (-> s2-2 collide-with) (collide-kind target))
        (set! (-> s2-2 prim-core action) (collide-action solid ca-1))
        (set! (-> s2-2 prim-core offense) (collide-offense indestructible))
        (set! (-> s2-2 transform-index) 3)
        (set-vector! (-> s2-2 local-sphere) 0.0 0.0 0.0 17612.8)
        (append-prim s3-0 s2-2)
        )
      )
    (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)
  (set! (-> obj link) (new 'process 'actor-link-info obj))
  (initialize-skeleton obj *snow-button-sg* '())
  (logior! (-> obj skel status) (janim-status inited))
  (set! (-> obj timeout) (the-as time-frame (the int (* 300.0 (res-lump-float arg0 'timeout :default 10.0)))))
  (set! (-> obj delay-til-wiggle) (+ (-> obj timeout) (seconds -0.4)))
  (if (> (entity-actor-count arg0 'alt-actor) 0)
      (set! (-> obj prev-button) (entity-actor-lookup arg0 'alt-actor 0))
      (set! (-> obj prev-button) #f)
      )
  (ja-channel-set! 1)
  (let ((s5-1 (-> obj skel root-channel 0)))
    (joint-control-channel-group-eval!
      s5-1
      (the-as art-joint-anim (-> obj draw art-group data 2))
      num-func-identity
      )
    (set! (-> s5-1 frame-num) 0.0)
    )
  (transform-post)
  (go snow-button-up-idle)
  (none)
  )

;; definition for method 26 of type flutflut-plat
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defmethod dummy-26 flutflut-plat ((obj flutflut-plat))
  (let ((t9-0 (method-of-type plat dummy-26)))
    (t9-0 obj)
    )
  (if (zero? (-> obj link))
      (set! (-> obj link) (new 'process 'actor-link-info obj))
      )
  (set! (-> obj sound-id) (new-sound-id))
  (set! (-> obj plat-type) (res-lump-value (-> obj entity) 'mode int))
  (set! (-> obj flutflut-button) (entity-actor-lookup (-> obj entity) 'alt-actor 0))
  (let ((f0-0 (res-lump-float (-> obj entity) 'rotoffset)))
    (if (!= f0-0 0.0)
        (quaternion-rotate-y! (-> obj root-override quat) (-> obj root-override quat) f0-0)
        )
    )
  (set! (-> obj has-path?)
        (and (zero? (logand (-> obj path flags) (path-control-flag not-found))) (> (-> obj sync period) 0))
        )
  (when (nonzero? (-> obj plat-type))
    (cond
      ((-> obj has-path?)
       (set! (-> obj sync-starting-val) (get-phase-offset (-> obj sync)))
       (sync-now! (-> obj sync) (-> obj sync-starting-val))
       (eval-path-curve!
         (-> obj path)
         (-> obj appear-trans-top)
         (if (logtest? (-> obj fact options) (fact-options wrap-phase))
             (get-current-phase (-> obj sync))
             (get-current-phase-with-mirror (-> obj sync))
             )
         'interp
         )
       )
      (else
        (set! (-> obj appear-trans-top quad) (-> obj root-override trans quad))
        )
      )
    (set! (-> obj appear-trans-bottom quad) (-> obj appear-trans-top quad))
    (set! (-> obj appear-trans-bottom y) (+ -286720.0 (-> obj appear-trans-bottom y)))
    (quaternion-copy! (-> obj appear-quat-top) (-> obj root-override quat))
    (let ((v1-33 (res-lump-value (-> obj entity) 'extra-id uint128)))
      (set! (-> obj rise-time) (the int (* 300.0 (+ 0.6 (* 0.15 (the float v1-33))))))
      )
    (set! (-> obj fall-time) 180)
    )
  (none)
  )

;; definition for method 27 of type flutflut-plat
;; INFO: Return type mismatch symbol vs skeleton-group.
(defmethod get-lit-skel flutflut-plat ((obj flutflut-plat))
  (if (and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status complete)))
      (return (the-as skeleton-group #t))
      )
  (when (task-complete? *game-info* (-> obj entity extra perm task))
    (process-entity-status! obj (entity-perm-status complete) #t)
    (return (the-as skeleton-group #t))
    )
  (the-as skeleton-group #f)
  )

;; failed to figure out what this is:
(defstate plat-startup (flutflut-plat)
  :virtual #t
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('trigger)
       (when (or (!= (-> self plat-type) 1)
                 (not (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete))))
                 )
         (logclear! (-> self mask) (process-mask actor-pause))
         (go flutflut-plat-appear)
         )
       )
      )
    )
  :code (behavior ((arg0 plat))
    (cond
      ((and (= (-> self plat-type) 1)
            (-> self entity)
            (logtest? (-> self entity extra perm status) (entity-perm-status complete))
            )
       (set! (-> self basetrans quad) (-> self appear-trans-top quad))
       (go elevator-idle-at-cave)
       )
      ((or (= (-> self plat-type) 1) (= (-> self plat-type) 2))
       (let* ((v1-11 (-> self flutflut-button))
              (a0-10 (if v1-11
                         (-> v1-11 extra process)
                         )
                     )
              )
         (if (and a0-10 (send-event a0-10 'query))
             (go flutflut-plat-appear)
             (go flutflut-plat-hidden-idle)
             )
         )
       )
      (else
        (let ((t9-4 (-> (method-of-type plat plat-startup) code)))
          (if t9-4
              ((the-as (function none :behavior plat) t9-4))
              )
          )
        )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate flutflut-plat-hidden-idle (flutflut-plat)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('trigger)
       (logclear! (-> self mask) (process-mask actor-pause))
       (go flutflut-plat-appear)
       )
      )
    )
  :trans (behavior ()
    (if (and (= (-> self plat-type) 1) (get-lit-skel self))
        (go flutflut-plat-appear)
        )
    (none)
    )
  :code (behavior ()
    (logior! (-> self draw status) (draw-status hidden))
    (clear-collide-with-as (-> self root-override))
    (set! (-> self root-override trans quad) (-> self appear-trans-top quad))
    (transform-post)
    (logior! (-> self mask) (process-mask sleep-code))
    (suspend)
    0
    (none)
    )
  )

;; failed to figure out what this is:
(defstate flutflut-plat-appear (flutflut-plat)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (if (or (= v1-0 'bonk) (= v1-0 'bounce))
                         (dummy-22 self)
                         )
              )
      )
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (logclear! (-> self mask) (process-mask actor-pause))
    (logclear! (-> self draw status) (draw-status hidden))
    (restore-collide-with-as (-> self root-override))
    (set! (-> self basetrans quad) (-> self appear-trans-bottom quad))
    (let ((s5-0 (new 'stack-no-clear 'vector))
          (gp-0 (new 'stack-no-clear 'quaternion))
          )
      (let ((f30-0 (rand-vu-float-range 0.0 65536.0)))
        (set-vector! s5-0 (cos f30-0) 0.0 (sin f30-0) 1.0)
        )
      (quaternion-vector-angle! (-> self appear-quat-bottom) s5-0 (rand-vu-float-range -21845.334 21845.334))
      (quaternion-axis-angle! gp-0 0.0 1.0 0.0 (rand-vu-float-range -32768.0 32768.0))
      (quaternion*! (-> self appear-quat-bottom) (-> self appear-quat-bottom) gp-0)
      )
    (none)
    )
  :exit (behavior ()
    (logior! (-> self mask) (process-mask actor-pause))
    (none)
    )
  :trans (behavior ()
    (plat-trans)
    (let* ((f0-1
             (fmin
               1.0
               (/ (the float (- (-> *display* base-frame-counter) (-> self state-time))) (the float (-> self rise-time)))
               )
             )
           (f0-2 (- 1.0 f0-1))
           (f0-3 (* f0-2 f0-2))
           (f30-0 (- 1.0 f0-3))
           )
      (vector-lerp! (-> self basetrans) (-> self appear-trans-bottom) (-> self appear-trans-top) f30-0)
      (quaternion-slerp! (-> self root-override quat) (-> self appear-quat-bottom) (-> self appear-quat-top) f30-0)
      (set-vector! (-> self draw color-mult) f30-0 f30-0 f30-0 1.0)
      (when (>= f30-0 1.0)
        (dummy-22 self)
        (rider-post)
        (cond
          ((= (-> self plat-type) 1)
           (if (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete)))
               (go elevator-idle-at-cave)
               (go-virtual plat-idle)
               )
           )
          ((-> self has-path?)
           (let ((a0-9 (-> self sync)))
             (sync-now! a0-9 (-> self sync-starting-val))
             (go-virtual plat-path-active (the-as plat a0-9))
             )
           )
          (else
            (go-virtual plat-idle)
            )
          )
        )
      )
    (dummy-20 self)
    (none)
    )
  :code (the-as (function none :behavior flutflut-plat) anim-loop)
  :post (the-as (function none :behavior flutflut-plat) rider-post)
  )

;; failed to figure out what this is:
(defstate plat-idle (flutflut-plat)
  :virtual #t
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (cond
                       ((or (= v1-0 'bonk) (= v1-0 'bounce))
                        (dummy-22 self)
                        )
                       ((= v1-0 'untrigger)
                        (go flutflut-plat-hide)
                        )
                       )
              )
      )
    )
  :enter (behavior ()
    (let ((t9-0 (-> (method-of-type plat plat-idle) enter)))
      (if t9-0
          (t9-0)
          )
      )
    (logclear! (-> self mask) (process-mask actor-pause))
    (none)
    )
  :exit (behavior ()
    (logior! (-> self mask) (process-mask actor-pause))
    (let ((t9-0 (-> (method-of-type plat plat-idle) exit)))
      (if t9-0
          (t9-0)
          )
      )
    (none)
    )
  :trans (behavior ()
    (let ((t9-0 (-> (method-of-type plat plat-idle) trans)))
      (if t9-0
          (t9-0)
          )
      )
    (if (and (= (-> self plat-type) 1) (get-lit-skel self))
        (go elevator-idle-at-cave)
        )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate plat-path-active (flutflut-plat)
  :virtual #t
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (cond
                       ((or (= v1-0 'bonk) (= v1-0 'bounce))
                        (dummy-22 self)
                        )
                       ((= v1-0 'untrigger)
                        (go flutflut-plat-hide)
                        )
                       )
              )
      )
    )
  :enter (behavior ((arg0 plat))
    (let ((t9-0 (-> (method-of-type plat plat-path-active) enter)))
      (if t9-0
          (t9-0 arg0)
          )
      )
    (if (or (!= (-> self plat-type) 1)
            (not (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete))))
            )
        (logclear! (-> self mask) (process-mask actor-pause))
        )
    (none)
    )
  :exit (behavior ()
    (logior! (-> self mask) (process-mask actor-pause))
    (let ((t9-0 (-> (method-of-type plat plat-path-active) exit)))
      (if t9-0
          (t9-0)
          )
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate flutflut-plat-hide (flutflut-plat)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (if (= v1-0 'bonk)
                         (dummy-22 self)
                         )
              )
      )
    )
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (logclear! (-> self mask) (process-mask actor-pause))
    (logclear! (-> self root-override root-prim prim-core action) (collide-action ca-1))
    (set! (-> self start-trans quad) (-> self root-override trans quad))
    (let ((s5-0 (new 'stack-no-clear 'vector))
          (gp-0 (new 'stack-no-clear 'quaternion))
          )
      (let ((f30-0 (rand-vu-float-range 0.0 65536.0)))
        (set-vector! s5-0 (cos f30-0) 0.0 (sin f30-0) 1.0)
        )
      (quaternion-vector-angle! (-> self appear-quat-bottom) s5-0 (rand-vu-float-range -21845.334 21845.334))
      (quaternion-axis-angle! gp-0 0.0 1.0 0.0 (rand-vu-float-range -32768.0 32768.0))
      (quaternion*! (-> self appear-quat-bottom) (-> self appear-quat-bottom) gp-0)
      )
    (none)
    )
  :exit (behavior ()
    (logior! (-> self mask) (process-mask actor-pause))
    (logior! (-> self root-override root-prim prim-core action) (collide-action ca-1))
    (none)
    )
  :trans (behavior ()
    (plat-trans)
    (let* ((f0-1
             (fmin
               1.0
               (/ (the float (- (-> *display* base-frame-counter) (-> self state-time))) (the float (-> self fall-time)))
               )
             )
           (f30-0 (* f0-1 f0-1))
           )
      (vector-lerp! (-> self basetrans) (-> self start-trans) (-> self appear-trans-bottom) f30-0)
      (quaternion-slerp! (-> self root-override quat) (-> self appear-quat-top) (-> self appear-quat-bottom) f30-0)
      (let ((f0-3 (- 1.0 f30-0)))
        (set-vector! (-> self draw color-mult) f0-3 f0-3 f0-3 1.0)
        )
      (when (>= f30-0 1.0)
        (rider-post)
        (go flutflut-plat-hidden-idle)
        )
      )
    (dummy-20 self)
    (none)
    )
  :code (the-as (function none :behavior flutflut-plat) anim-loop)
  :post (the-as (function none :behavior flutflut-plat) rider-post)
  )

;; failed to figure out what this is:
(defstate elevator-idle-at-cave (flutflut-plat)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as
        object
        (cond
          ((= v1-0 'bonk)
           (dummy-22 self)
           )
          ((= v1-0 'bounce)
           (if (not (and (-> self entity) (logtest? (-> self entity extra perm status) (entity-perm-status complete))))
               (dummy-22 self)
               )
           )
          ((= v1-0 'ridden)
           (if (or (not *target*) (zero? (logand (-> *target* control root-prim prim-core action) (collide-action ca-14))))
               (go elevator-travel-to-fort)
               )
           )
          )
        )
      )
    )
  :enter (behavior ()
    (set! (-> self path-pos) 0.0)
    (eval-path-curve! (-> self path) (-> self basetrans) 0.0 'interp)
    (none)
    )
  :trans (behavior ()
    (plat-trans)
    (dummy-20 self)
    (none)
    )
  :code (the-as (function none :behavior flutflut-plat) anim-loop)
  :post (the-as (function none :behavior flutflut-plat) plat-post)
  )

;; failed to figure out what this is:
(defstate elevator-travel-to-fort (flutflut-plat)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (if (or (= v1-0 'bonk) (= v1-0 'bounce))
                         (dummy-22 self)
                         )
              )
      )
    )
  :trans (behavior ()
    (when (= (-> self path-pos) 1.0)
      (dummy-22 self)
      (go elevator-idle-at-fort)
      )
    (seek! (-> self path-pos) 1.0 (* 0.06666667 (-> *display* seconds-per-frame)))
    (eval-path-curve! (-> self path) (-> self basetrans) (-> self path-pos) 'interp)
    (plat-trans)
    (dummy-20 self)
    (none)
    )
  :code (the-as (function none :behavior flutflut-plat) anim-loop)
  :post (the-as (function none :behavior flutflut-plat) plat-post)
  )

;; failed to figure out what this is:
(defstate elevator-idle-at-fort (flutflut-plat)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (if (or (= v1-0 'bonk) (= v1-0 'bounce))
                         (dummy-22 self)
                         )
              )
      )
    )
  :enter (behavior ()
    (set! (-> self path-pos) 1.0)
    (eval-path-curve! (-> self path) (-> self basetrans) 1.0 'interp)
    (none)
    )
  :trans (behavior ()
    (when *target*
      (if (and (>= 798720.0 (-> (target-pos 0) y))
               (not (and (logtest? (-> *target* control unknown-surface00 flags) (surface-flags jump))
                         (zero? (logand (-> *target* control status) (cshape-moving-flags onsurf)))
                         )
                    )
               )
          (go elevator-travel-to-cave)
          )
      )
    (plat-trans)
    (dummy-20 self)
    (none)
    )
  :code (the-as (function none :behavior flutflut-plat) anim-loop)
  :post (the-as (function none :behavior flutflut-plat) plat-post)
  )

;; failed to figure out what this is:
(defstate elevator-travel-to-cave (flutflut-plat)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (let ((v1-0 arg2))
      (the-as object (if (or (= v1-0 'bonk) (= v1-0 'bounce))
                         (dummy-22 self)
                         )
              )
      )
    )
  :trans (behavior ()
    (when (= (-> self path-pos) 0.0)
      (dummy-22 self)
      (go elevator-idle-at-cave)
      )
    (seek! (-> self path-pos) 0.0 (* 0.06666667 (-> *display* seconds-per-frame)))
    (eval-path-curve! (-> self path) (-> self basetrans) (-> self path-pos) 'interp)
    (plat-trans)
    (dummy-20 self)
    (none)
    )
  :code (the-as (function none :behavior flutflut-plat) anim-loop)
  :post (the-as (function none :behavior flutflut-plat) plat-post)
  )

;; definition of type flutflut-plat-small
(deftype flutflut-plat-small (flutflut-plat)
  ()
  :heap-base #x110
  :method-count-assert 33
  :size-assert         #x180
  :flag-assert         #x2101100180
  )

;; definition for method 3 of type flutflut-plat-small
(defmethod inspect flutflut-plat-small ((obj flutflut-plat-small))
  (let ((t9-0 (method-of-type flutflut-plat inspect)))
    (t9-0 obj)
    )
  obj
  )

;; definition of type flutflut-plat-med
(deftype flutflut-plat-med (flutflut-plat)
  ()
  :heap-base #x110
  :method-count-assert 33
  :size-assert         #x180
  :flag-assert         #x2101100180
  )

;; definition for method 3 of type flutflut-plat-med
(defmethod inspect flutflut-plat-med ((obj flutflut-plat-med))
  (let ((t9-0 (method-of-type flutflut-plat inspect)))
    (t9-0 obj)
    )
  obj
  )

;; definition of type flutflut-plat-large
(deftype flutflut-plat-large (flutflut-plat)
  ()
  :heap-base #x110
  :method-count-assert 33
  :size-assert         #x180
  :flag-assert         #x2101100180
  )

;; definition for method 3 of type flutflut-plat-large
(defmethod inspect flutflut-plat-large ((obj flutflut-plat-large))
  (let ((t9-0 (method-of-type flutflut-plat inspect)))
    (t9-0 obj)
    )
  obj
  )

;; definition for method 23 of type flutflut-plat-small
(defmethod get-unlit-skel flutflut-plat-small ((obj flutflut-plat-small))
  *flutflut-plat-small-sg*
  )

;; definition for method 25 of type flutflut-plat-small
;; INFO: Return type mismatch sparticle-launch-control vs sparticle-launch-group.
(defmethod TODO-RENAME-25 flutflut-plat-small ((obj flutflut-plat-small))
  (let ((v0-0 (create-launch-control (-> *part-group-id-table* 516) obj)))
    (set! (-> obj part) v0-0)
    (the-as sparticle-launch-group v0-0)
    )
  )

;; definition for method 20 of type flutflut-plat-small
;; INFO: Return type mismatch object vs none.
(defmethod dummy-20 flutflut-plat-small ((obj flutflut-plat-small))
  (when (nonzero? (-> obj part))
    (set! (-> *part-id-table* 2087 init-specs 12 initial-valuef) (-> obj part-ry))
    (set! (-> *part-id-table* 2088 init-specs 17 initial-valuef) (-> obj part-ry))
    (spawn (-> obj part) (-> obj root-override trans))
    )
  (none)
  )

;; definition for method 26 of type flutflut-plat-small
;; INFO: Return type mismatch float vs none.
(defmethod dummy-26 flutflut-plat-small ((obj flutflut-plat-small))
  (let ((t9-0 (method-of-type flutflut-plat dummy-26)))
    (t9-0 obj)
    )
  (set! (-> obj part-ry) (+ 16384.0 (quaternion-y-angle (-> obj root-override quat))))
  (none)
  )

;; definition for method 24 of type flutflut-plat-small
;; INFO: Return type mismatch int vs none.
(defmethod dummy-24 flutflut-plat-small ((obj flutflut-plat-small))
  (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) default-collision-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (alloc-riders s5-0 1)
    (let ((s4-0 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> s4-0 prim-core collide-as) (collide-kind ground-object))
      (set! (-> s4-0 collide-with) (collide-kind target))
      (set! (-> s4-0 prim-core action) (collide-action solid ca-1))
      (set! (-> s4-0 prim-core offense) (collide-offense indestructible))
      (set! (-> s4-0 transform-index) 0)
      (set-vector! (-> s4-0 local-sphere) 0.0 -2048.0 0.0 16384.0)
      (set-root-prim! s5-0 s4-0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> obj root-override) s5-0)
    )
  0
  (none)
  )

;; definition for method 23 of type flutflut-plat-med
(defmethod get-unlit-skel flutflut-plat-med ((obj flutflut-plat-med))
  *flutflut-plat-med-sg*
  )

;; definition for method 25 of type flutflut-plat-med
;; INFO: Return type mismatch sparticle-launch-control vs sparticle-launch-group.
(defmethod TODO-RENAME-25 flutflut-plat-med ((obj flutflut-plat-med))
  (let ((v0-0 (create-launch-control (-> *part-group-id-table* 517) obj)))
    (set! (-> obj part) v0-0)
    (the-as sparticle-launch-group v0-0)
    )
  )

;; definition for method 24 of type flutflut-plat-med
;; INFO: Return type mismatch int vs none.
(defmethod dummy-24 flutflut-plat-med ((obj flutflut-plat-med))
  (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) default-collision-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (alloc-riders s5-0 1)
    (let ((s4-0 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> s4-0 prim-core collide-as) (collide-kind ground-object))
      (set! (-> s4-0 collide-with) (collide-kind target))
      (set! (-> s4-0 prim-core action) (collide-action solid ca-1))
      (set! (-> s4-0 prim-core offense) (collide-offense indestructible))
      (set! (-> s4-0 transform-index) 0)
      (set-vector! (-> s4-0 local-sphere) 0.0 -4096.0 0.0 27648.0)
      (set-root-prim! s5-0 s4-0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> obj root-override) s5-0)
    )
  0
  (none)
  )

;; definition for method 23 of type flutflut-plat-large
(defmethod get-unlit-skel flutflut-plat-large ((obj flutflut-plat-large))
  *flutflut-plat-large-sg*
  )

;; definition for method 25 of type flutflut-plat-large
;; INFO: Return type mismatch sparticle-launch-control vs sparticle-launch-group.
(defmethod TODO-RENAME-25 flutflut-plat-large ((obj flutflut-plat-large))
  (let ((v0-0 (create-launch-control (-> *part-group-id-table* 518) obj)))
    (set! (-> obj part) v0-0)
    (the-as sparticle-launch-group v0-0)
    )
  )

;; definition for method 20 of type flutflut-plat-large
;; INFO: Return type mismatch object vs none.
(defmethod dummy-20 flutflut-plat-large ((obj flutflut-plat-large))
  (when (nonzero? (-> obj part))
    (set! (-> *part-id-table* 2091 init-specs 12 initial-valuef) (-> obj part-ry))
    (set! (-> *part-id-table* 2092 init-specs 17 initial-valuef) (-> obj part-ry))
    (spawn (-> obj part) (-> obj root-override trans))
    )
  (none)
  )

;; definition for method 26 of type flutflut-plat-large
;; INFO: Return type mismatch float vs none.
(defmethod dummy-26 flutflut-plat-large ((obj flutflut-plat-large))
  (let ((t9-0 (method-of-type flutflut-plat dummy-26)))
    (t9-0 obj)
    )
  (set! (-> obj part-ry) (+ 16384.0 (quaternion-y-angle (-> obj root-override quat))))
  (none)
  )

;; definition for method 24 of type flutflut-plat-large
;; INFO: Return type mismatch int vs none.
(defmethod dummy-24 flutflut-plat-large ((obj flutflut-plat-large))
  (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) default-collision-reaction)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
          )
    (alloc-riders s5-0 1)
    (let ((s4-0 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> s4-0 prim-core collide-as) (collide-kind ground-object))
      (set! (-> s4-0 collide-with) (collide-kind target))
      (set! (-> s4-0 prim-core action) (collide-action solid ca-1))
      (set! (-> s4-0 prim-core offense) (collide-offense indestructible))
      (set! (-> s4-0 transform-index) 0)
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 36864.0)
      (set-root-prim! s5-0 s4-0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> obj root-override) s5-0)
    )
  0
  (none)
  )
