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

(import "goal_src/jak1/import/orbit-plat-ag.gc")
(import "goal_src/jak1/import/orbit-plat-bottom-ag.gc")

;; definition of type orbit-plat-bottom
(deftype orbit-plat-bottom (process-drawable)
  ((parent-override (pointer orbit-plat)      :offset         12)
   (part2           sparticle-launch-control  :offset-assert 176)
   )
  :heap-base #x50
  :method-count-assert 21
  :size-assert         #xb4
  :flag-assert         #x15005000b4
  (:methods
    (dummy-20 (_type_ vector vector) none 20)
    )
  (:states
    orbit-plat-bottom-idle
    )
  )

;; definition for method 3 of type orbit-plat-bottom
(defmethod inspect orbit-plat-bottom ((obj orbit-plat-bottom))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tpart2: ~A~%" (-> obj part2))
  obj
  )

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

;; definition of type orbit-plat
(deftype orbit-plat (baseplat)
  ((other        entity-actor         :offset-assert 228)
   (rot-dir      float                :offset-assert 232)
   (reset-trans  vector       :inline :offset-assert 240)
   (is-reset?    symbol               :offset-assert 256)
   (reset-length float                :offset-assert 260)
   (timeout      float                :offset-assert 264)
   (plat-status  uint64               :offset-assert 272)
   )
  :heap-base #xb0
  :method-count-assert 29
  :size-assert         #x118
  :flag-assert         #x1d00b00118
  (:methods
    (dummy-27 (_type_) symbol 27)
    (dummy-28 (_type_) symbol 28)
    )
  (:states
    orbit-plat-idle
    orbit-plat-reset
    orbit-plat-riding
    orbit-plat-rotating
    orbit-plat-still
    orbit-plat-wait-for-other
    )
  )

;; definition for method 3 of type orbit-plat
(defmethod inspect orbit-plat ((obj orbit-plat))
  (let ((t9-0 (method-of-type baseplat inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tother: ~A~%" (-> obj other))
  (format #t "~T~Trot-dir: ~f~%" (-> obj rot-dir))
  (format #t "~T~Treset-trans: #<vector @ #x~X>~%" (-> obj reset-trans))
  (format #t "~T~Tis-reset?: ~A~%" (-> obj is-reset?))
  (format #t "~T~Treset-length: ~f~%" (-> obj reset-length))
  (format #t "~T~Ttimeout: ~f~%" (-> obj timeout))
  (format #t "~T~Tplat-status: ~D~%" (-> obj plat-status))
  obj
  )

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

;; failed to figure out what this is:
(defpartgroup group-orbit-plat-jet
  :id 440
  :bounds (static-bspherem 0 0 0 6)
  :parts ((sp-item 1715 :fade-after (meters 100) :falloff-to (meters 120) :period 150 :length 75)
    (sp-item 1715 :fade-after (meters 100) :falloff-to (meters 120) :period 75 :length 96)
    (sp-item 1715 :fade-after (meters 140) :falloff-to (meters 160) :period 90 :length 60)
    (sp-item 1716 :fade-after (meters 100) :falloff-to (meters 100))
    )
  )

;; failed to figure out what this is:
(defpart 1716
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-rnd-flt spt-num 0.0 1.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 1) (meters 0.5) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 0.0)
    (sp-flt spt-g 64.0)
    (sp-flt spt-b 48.0)
    (sp-rnd-flt spt-a 32.0 96.0 1.0)
    (sp-rnd-flt spt-vel-z (meters 0.02) (meters 0.0033333334) 1.0)
    (sp-rnd-flt spt-scalevel-x (meters -0.013333334) (meters 0.006666667) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -1.7066667)
    (sp-int spt-timer 75)
    (sp-cpuinfo-flags bit2)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 15.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 1715
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-rnd-flt spt-num 1.0 2.0 1.0)
    (sp-sound (static-sound-spec "steam-medium" :num 0.05 :volume 80.0))
    (sp-rnd-flt spt-scale-x (meters 0.75) (meters 0.75) 1.0)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 0.0)
    (sp-flt spt-g 96.0)
    (sp-flt spt-b 128.0)
    (sp-rnd-flt spt-a 16.0 32.0 1.0)
    (sp-rnd-flt spt-vel-z (meters 0.053333335) (meters 0.0033333334) 1.0)
    (sp-rnd-flt spt-scalevel-x (meters -0.013333334) (meters 0.006666667) 1.0)
    (sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 2.4) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a -0.8)
    (sp-flt spt-friction 0.96)
    (sp-int spt-timer 75)
    (sp-cpuinfo-flags bit2)
    (sp-rnd-flt spt-rotate-y (degrees 0.0) (degrees 15.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 1717
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 1.0 3.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 1.7) (meters 0.3) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-flt spt-r 32.0)
    (sp-rnd-flt spt-g 16.0 96.0 1.0)
    (sp-flt spt-b 255.0)
    (sp-flt spt-a 64.0)
    (sp-rnd-flt spt-vel-z (meters 0.45) (meters 0.05) 1.0)
    (sp-flt spt-fade-r -0.08888889)
    (sp-int spt-timer 360)
    (sp-cpuinfo-flags bit2 launch-along-z)
    (sp-flt spt-conerot-x (degrees 0.0))
    (sp-flt spt-conerot-y (degrees 0.0))
    (sp-rnd-flt spt-conerot-radius (meters -3) (meters 4) 1.0)
    )
  )

;; definition for method 20 of type orbit-plat-bottom
;; INFO: Return type mismatch int vs none.
(defmethod dummy-20 orbit-plat-bottom ((obj orbit-plat-bottom) (arg0 vector) (arg1 vector))
  (let* ((s5-1 (vector-! (new 'stack-no-clear 'vector) arg1 arg0))
         (f30-0 (vector-length s5-1))
         )
    (let ((f28-0 (* 0.0005022321 f30-0)))
      (set! (-> *part-id-table* 1717 init-specs 13 initial-valuef) (vector-y-angle s5-1))
      (set! (-> *part-id-table* 1717 init-specs 12 initial-valuef) (- (vector-x-angle s5-1)))
      (set! (-> *part-id-table* 1717 init-specs 9 initial-valuef) (/ -32.0 f28-0))
      (set! (-> *part-id-table* 1717 init-specs 10 initial-valuef) (the-as float (the int f28-0)))
      )
    (set! (-> *part-id-table* 1717 init-specs 1 random-rangef) (* 0.000009494358 f30-0))
    )
  (sp-launch-particles-var
    *sp-particle-system-2d*
    (-> *part-id-table* 1717)
    arg0
    (the-as sparticle-launch-state #f)
    (the-as sparticle-launch-control #f)
    1.0
    )
  0
  (none)
  )

;; failed to figure out what this is:
(defstate orbit-plat-bottom-idle (orbit-plat-bottom)
  :code (behavior ()
    (loop
      (set! (-> self root trans quad) (-> self parent-override 0 root-override trans quad))
      (set! (-> self root trans y) (+ -5324.8 (-> self root trans y)))
      (spawn (-> self part2) (-> self root trans))
      (let* ((a0-6 (-> self parent-override 0 other))
             (v1-9 (if a0-6
                       (-> a0-6 extra process)
                       )
                   )
             )
        (when v1-9
          (let ((f30-0 (atan
                         (- (-> (the-as orbit-plat v1-9) root-override trans x) (-> self root trans x))
                         (- (-> (the-as orbit-plat v1-9) root-override trans z) (-> self root trans z))
                         )
                       )
                )
            (quaternion-axis-angle! (-> self root quat) 0.0 1.0 0.0 f30-0)
            (let ((v1-16 (-> self parent-override 0 plat-status))
                  (f30-1 (+ 16384.0 f30-0))
                  )
              (cond
                ((= v1-16 2)
                 (let ((gp-0 (new 'stack-no-clear 'vector)))
                   (set-vector! gp-0 0.0 -2048.0 8192.0 1.0)
                   (if (< (-> self parent-override 0 rot-dir) 0.0)
                       (set! f30-1 (+ 32768.0 f30-1))
                       )
                   (vector-rotate-around-y! gp-0 gp-0 f30-1)
                   (set! (-> *part-id-table* 1716 init-specs 16 initial-valuef) f30-1)
                   (set! (-> *part-id-table* 1715 init-specs 18 initial-valuef) f30-1)
                   (vector+! gp-0 gp-0 (-> self root trans))
                   (spawn (-> self part) gp-0)
                   )
                 )
                (else
                  (let* ((a0-18 (-> self parent-override 0 other))
                         (v1-32 (if a0-18
                                    (-> a0-18 extra process)
                                    )
                                )
                         )
                    (when (and v1-32 (= (-> (the-as orbit-plat v1-32) plat-status) 2))
                      (let ((gp-1 (new 'stack-no-clear 'vector))
                            (s5-0 (new 'stack-no-clear 'vector))
                            )
                        (let ((s4-0 (new 'stack-no-clear 'vector)))
                          (set! (-> gp-1 quad) (-> self root trans quad))
                          (set! (-> gp-1 y) (+ -2048.0 (-> gp-1 y)))
                          (set! (-> s5-0 quad) (-> (the-as orbit-plat v1-32) root-override trans quad))
                          (set! (-> s5-0 y) (+ -7372.8 (-> s5-0 y)))
                          (vector-! s4-0 s5-0 gp-1)
                          (vector-normalize! s4-0 1.0)
                          (vector+*! s5-0 gp-1 s4-0 26624.0)
                          (vector+*! gp-1 gp-1 s4-0 8192.0)
                          )
                        (dummy-20 self gp-1 s5-0)
                        )
                      )
                    )
                  )
                )
              )
            )
          )
        )
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior orbit-plat-bottom) ja-post)
  )

;; definition for method 7 of type orbit-plat-bottom
;; INFO: Return type mismatch process-drawable vs orbit-plat-bottom.
(defmethod relocate orbit-plat-bottom ((obj orbit-plat-bottom) (arg0 int))
  (if (nonzero? (-> obj part2))
      (&+! (-> obj part2) arg0)
      )
  (the-as orbit-plat-bottom ((method-of-type process-drawable relocate) obj arg0))
  )

;; definition for method 10 of type orbit-plat-bottom
(defmethod deactivate orbit-plat-bottom ((obj orbit-plat-bottom))
  (if (nonzero? (-> obj part2))
      (kill-and-free-particles (-> obj part2))
      )
  ((method-of-type process-drawable deactivate) obj)
  (none)
  )

;; definition for function orbit-plat-bottom-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior orbit-plat-bottom-init-by-other orbit-plat-bottom ((arg0 entity-actor) (arg1 orbit-plat))
  (set! (-> self entity) arg0)
  (set! (-> self mask) (logior (process-mask platform) (-> self mask)))
  (set! (-> self root) (new 'process 'trsqv))
  (set! (-> self root trans quad) (-> arg1 root-override trans quad))
  (quaternion-copy! (-> self root quat) (-> arg1 root-override quat))
  (set! (-> self root scale quad) (-> arg1 root-override scale quad))
  (set! (-> self root trans y) (+ -5324.8 (-> self root trans y)))
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 440) self))
  (set! (-> self part2) (create-launch-control (-> *part-group-id-table* 107) self))
  (initialize-skeleton self *orbit-plat-bottom-sg* '())
  (ja-channel-set! 1)
  (ja :group! orbit-plat-idle-ja :num! min)
  (go orbit-plat-bottom-idle)
  (none)
  )

;; failed to figure out what this is:
(defstate orbit-plat-idle (orbit-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 'go)
                        (go orbit-plat-rotating)
                        )
                       ((= v1-0 'query-reset)
                        (if (not (-> self is-reset?))
                            (go orbit-plat-reset)
                            )
                        (let ((a1-1 (new 'stack-no-clear 'event-message-block)))
                          (set! (-> a1-1 from) self)
                          (set! (-> a1-1 num-params) 0)
                          (set! (-> a1-1 message) 'reset)
                          (let ((t9-3 send-event-function)
                                (v1-8 (-> self other))
                                )
                            (t9-3
                              (if v1-8
                                  (-> v1-8 extra process)
                                  )
                              a1-1
                              )
                            )
                          )
                        )
                       ((= v1-0 'reset)
                        (go orbit-plat-reset)
                        )
                       )
              )
      )
    )
  :trans (the-as (function none :behavior orbit-plat) plat-trans)
  :code (behavior ()
    (set! (-> self plat-status) (the-as uint 0))
    (ja-no-eval :num! (seek! 0.0))
    (dotimes (gp-0 2)
      (transform-post)
      (suspend)
      (if (not (ja-done? 0))
          (ja :num! (seek! 0.0))
          )
      )
    (loop
      (when (nonzero? (-> self root-override riders num-riders))
        (let ((a1-2 (new 'stack-no-clear 'event-message-block)))
          (set! (-> a1-2 from) self)
          (set! (-> a1-2 num-params) 0)
          (set! (-> a1-2 message) 'go)
          (let ((t9-4 send-event-function)
                (v1-14 (-> self other))
                )
            (t9-4
              (if v1-14
                  (-> v1-14 extra process)
                  )
              a1-2
              )
            )
          )
        (go orbit-plat-riding)
        )
      (suspend)
      (if (not (ja-done? 0))
          (ja :num! (seek! 0.0))
          )
      (when (not (-> self is-reset?))
        (let ((a1-4 (new 'stack-no-clear 'event-message-block)))
          (set! (-> a1-4 from) self)
          (set! (-> a1-4 num-params) 0)
          (set! (-> a1-4 message) 'query-reset)
          (let ((t9-8 send-event-function)
                (v1-26 (-> self other))
                )
            (t9-8
              (if v1-26
                  (-> v1-26 extra process)
                  )
              a1-4
              )
            )
          )
        )
      )
    (none)
    )
  :post (the-as (function none :behavior orbit-plat) plat-post)
  )

;; definition for method 28 of type orbit-plat
(defmethod dummy-28 orbit-plat ((obj orbit-plat))
  (when (>= (- (-> *display* base-frame-counter) (-> obj state-time)) (the int (* 300.0 (-> obj timeout))))
    (cond
      (*target*
        (let ((s5-0 (target-pos 0)))
          (if (or (>= (vector-vector-xz-distance s5-0 (-> obj root-override trans)) 102400.0)
                  (>= (- (-> obj root-override trans y) (-> s5-0 y)) 16384.0)
                  )
              (return #t)
              )
          )
        )
      (else
        (return #t)
        )
      )
    )
  #f
  )

;; failed to figure out what this is:
(defstate orbit-plat-still (orbit-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 'go)
                        (go orbit-plat-rotating)
                        )
                       )
              )
      )
    )
  :trans (the-as (function none :behavior orbit-plat) plat-trans)
  :code (behavior ()
    (set! (-> self plat-status) (the-as uint 0))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (ja-no-eval :num! (seek! 0.0))
    (until (dummy-28 self)
      (when (nonzero? (-> self root-override riders num-riders))
        (let ((a1-1 (new 'stack-no-clear 'event-message-block)))
          (set! (-> a1-1 from) self)
          (set! (-> a1-1 num-params) 0)
          (set! (-> a1-1 message) 'go)
          (let ((t9-1 send-event-function)
                (v1-10 (-> self other))
                )
            (t9-1
              (if v1-10
                  (-> v1-10 extra process)
                  )
              a1-1
              )
            )
          )
        (go orbit-plat-riding)
        )
      (suspend)
      (if (not (ja-done? 0))
          (ja :num! (seek! 0.0))
          )
      )
    (go orbit-plat-idle)
    (none)
    )
  :post (the-as (function none :behavior orbit-plat) plat-post)
  )

;; failed to figure out what this is:
(defstate orbit-plat-riding (orbit-plat)
  :event (the-as (function process int symbol event-message-block object :behavior orbit-plat) plat-event)
  :trans (the-as (function none :behavior orbit-plat) plat-trans)
  :code (behavior ()
    (set! (-> self plat-status) (the-as uint 1))
    (ja-no-eval :num! (seek!))
    (loop
      (when (zero? (-> self root-override riders num-riders))
        (let ((a1-1 (new 'stack-no-clear 'event-message-block)))
          (set! (-> a1-1 from) self)
          (set! (-> a1-1 num-params) 0)
          (set! (-> a1-1 message) 'stop)
          (let ((t9-1 send-event-function)
                (v1-13 (-> self other))
                )
            (t9-1
              (if v1-13
                  (-> v1-13 extra process)
                  )
              a1-1
              )
            )
          )
        (go orbit-plat-still)
        )
      (suspend)
      (if (not (ja-done? 0))
          (ja :num! (seek!))
          )
      )
    (none)
    )
  :post (the-as (function none :behavior orbit-plat) plat-post)
  )

;; definition for function get-rotate-point!
(defun get-rotate-point! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector) (arg4 float) (arg5 float))
  (let ((s5-0 (new 'stack-no-clear 'vector)))
    (let ((s2-0 (new 'stack-no-clear 'vector)))
      (vector-! s5-0 arg2 arg1)
      (when (!= arg4 0.0)
        (set! (-> s2-0 x) (* arg4 (-> s5-0 z)))
        (set! (-> s2-0 y) 0.0)
        (set! (-> s2-0 z) (- (* arg4 (-> s5-0 x))))
        (vector-normalize! s2-0 (* arg5 (-> *display* seconds-per-frame)))
        (+! (-> s5-0 x) (-> s2-0 x))
        (+! (-> s5-0 z) (-> s2-0 z))
        )
      )
    (vector-normalize! s5-0 (the-as float arg3))
    (vector+! arg0 arg1 s5-0)
    )
  arg0
  )

;; definition for function get-nav-point!
;; INFO: Used lq/sq
(defun get-nav-point! ((arg0 vector) (arg1 orbit-plat) (arg2 vector) (arg3 float))
  (set! (-> arg1 nav target-pos quad) (-> arg2 quad))
  (logclear! (-> arg1 nav flags) (nav-control-flags navcf19))
  (dummy-11 (-> arg1 nav) (-> arg1 nav target-pos))
  (let ((f0-0 (vector-length (-> arg1 nav travel))))
    (if (< arg3 f0-0)
        (set! f0-0 arg3)
        )
    (vector-normalize! (-> arg1 nav travel) (* f0-0 (-> *display* seconds-per-frame)))
    )
  (set! (-> arg0 x) (+ (-> arg1 root-override trans x) (-> arg1 nav travel x)))
  (set! (-> arg0 y) (-> arg1 root-override trans x))
  (set! (-> arg0 z) (+ (-> arg1 root-override trans z) (-> arg1 nav travel z)))
  arg0
  )

;; failed to figure out what this is:
(defstate orbit-plat-rotating (orbit-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 'stop)
                        (go orbit-plat-still)
                        )
                       )
              )
      )
    )
  :trans (the-as (function none :behavior orbit-plat) plat-trans)
  :code (behavior ()
    (set! (-> self plat-status) (the-as uint 2))
    (set! (-> self is-reset?) #f)
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      0.0
      (let ((a0-0 (new 'stack-no-clear 'vector))
            (s5-0 (new 'stack-no-clear 'vector))
            )
        (let ((v1-1 gp-0)
              (a1-0 (-> self other))
              )
          (set! (-> v1-1 quad) (-> (the-as orbit-plat (if a1-0
                                                          (-> a1-0 extra process)
                                                          )
                                           )
                                   root-override
                                   trans
                                   quad
                                   )
                )
          )
        (vector-! a0-0 (-> self basetrans) gp-0)
        (let ((f30-0 (vector-length a0-0)))
          (set! (-> self reset-length) f30-0)
          (ja-no-eval :num! (seek! 0.0))
          (label cfg-3)
          (dotimes (s4-0 2)
            (get-rotate-point! s5-0 gp-0 (-> self basetrans) (the-as vector f30-0) (-> self rot-dir) 40960.0)
            (b! (not (dummy-16 (-> self nav) s5-0)) cfg-6 :delay (empty-form))
            (set! (-> self basetrans quad) (-> s5-0 quad))
            (b! #t cfg-9 :delay (nop!))
            (label cfg-6)
            (set! (-> self rot-dir) (- (-> self rot-dir)))
            )
          )
        )
      )
    (label cfg-9)
    (suspend)
    (if (not (ja-done? 0))
        (ja :num! (seek! 0.0))
        )
    (b! #t cfg-3 :delay (nop!))
    (none)
    )
  :post (the-as (function none :behavior orbit-plat) plat-post)
  )

;; definition for method 27 of type orbit-plat
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs symbol.
;; WARN: disable def twice: 132. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
(defmethod dummy-27 orbit-plat ((obj orbit-plat))
  (local-vars (v0-11 object))
  (let* ((v1-0 (-> obj other))
         (s5-0 (if v1-0
                   (-> v1-0 extra process)
                   )
               )
         )
    (the-as
      symbol
      (cond
        ((and s5-0
              (< (vector-vector-xz-distance (the-as vector (&-> s5-0 stack 96)) (the-as vector (&-> s5-0 stack 128)))
                 (vector-vector-xz-distance (-> obj basetrans) (-> obj reset-trans))
                 )
              )
         (cond
           ((-> (the-as orbit-plat s5-0) is-reset?)
            (when (!= (-> obj plat-status) 2)
              (set! (-> obj plat-status) (the-as uint 2))
              (let ((f30-1 (atan
                             (- (-> obj basetrans x) (-> (the-as orbit-plat s5-0) basetrans x))
                             (- (-> obj basetrans z) (-> (the-as orbit-plat s5-0) basetrans z))
                             )
                           )
                    (f0-9 (atan
                            (- (-> obj reset-trans x) (-> (the-as orbit-plat s5-0) basetrans x))
                            (- (-> obj reset-trans z) (-> (the-as orbit-plat s5-0) basetrans z))
                            )
                          )
                    )
                (if (>= (deg- f0-9 f30-1) 0.0)
                    (set! (-> obj rot-dir) 1.0)
                    (set! (-> obj rot-dir) -1.0)
                    )
                )
              )
            (let ((s4-0 (new 'stack-no-clear 'vector)))
              0.0
              (let ((a0-7 (new 'stack-no-clear 'vector))
                    (s5-1 (new 'stack-no-clear 'vector))
                    )
                (let ((v1-9 s4-0)
                      (a1-5 (-> obj other))
                      )
                  (set! (-> v1-9 quad) (-> (the-as orbit-plat (if a1-5
                                                                  (-> a1-5 extra process)
                                                                  )
                                                   )
                                           root-override
                                           trans
                                           quad
                                           )
                        )
                  )
                (vector-! a0-7 (-> obj basetrans) s4-0)
                (let ((f30-2 (vector-length a0-7)))
                  (get-rotate-point! s5-1 s4-0 (-> obj basetrans) (the-as vector f30-2) (-> obj rot-dir) 40960.0)
                  (cond
                    ((dummy-16 (-> obj nav) s5-1)
                     (set! (-> obj basetrans quad) (-> s5-1 quad))
                     )
                    (else
                      (set! (-> obj rot-dir) (- (-> obj rot-dir)))
                      (get-rotate-point! s5-1 s4-0 (-> obj basetrans) (the-as vector f30-2) (-> obj rot-dir) 40960.0)
                      (if (dummy-16 (-> obj nav) s5-1)
                          (set! (-> obj basetrans quad) (-> s5-1 quad))
                          )
                      )
                    )
                  )
                )
              )
            (when (>= 614.4 (vector-vector-xz-distance (-> obj basetrans) (-> obj reset-trans)))
              (set! v0-11 (logior (nav-control-flags navcf19) (-> obj nav flags)))
              (set! (-> obj nav flags) (the-as nav-control-flags v0-11))
              v0-11
              )
            )
           (else
             (let ((s5-2 (new 'stack-no-clear 'vector)))
               (let ((s4-1 (new 'stack-no-clear 'vector)))
                 (get-nav-point! s5-2 obj (-> obj reset-trans) 40960.0)
                 (let ((v1-20 s4-1)
                       (a0-19 (-> obj other))
                       )
                   (set! (-> v1-20 quad) (-> (the-as orbit-plat (if a0-19
                                                                    (-> a0-19 extra process)
                                                                    )
                                                     )
                                             root-override
                                             trans
                                             quad
                                             )
                         )
                   )
                 (set! (-> s5-2 y) (-> s4-1 y))
                 (vector-! s5-2 s5-2 s4-1)
                 (vector-normalize! s5-2 (-> obj reset-length))
                 (vector+! s5-2 s5-2 s4-1)
                 (when (not (dummy-16 (-> obj nav) s5-2))
                   (logclear! (-> obj nav flags) (nav-control-flags navcf19))
                   (get-rotate-point! s5-2 s4-1 (-> obj basetrans) (the-as vector (-> obj reset-length)) 0.0 40960.0)
                   (when (not (dummy-16 (-> obj nav) s5-2))
                     (get-rotate-point!
                       s5-2
                       s4-1
                       (-> obj basetrans)
                       (the-as vector (-> obj reset-length))
                       (-> obj rot-dir)
                       40960.0
                       )
                     (when (not (dummy-16 (-> obj nav) s5-2))
                       (set! (-> obj rot-dir) (- (-> obj rot-dir)))
                       (get-rotate-point!
                         s5-2
                         s4-1
                         (-> obj basetrans)
                         (the-as vector (-> obj reset-length))
                         (-> obj rot-dir)
                         40960.0
                         )
                       )
                     )
                   )
                 )
               (set! (-> s5-2 y) (-> obj basetrans y))
               (set! v0-11 (-> obj basetrans))
               (set! (-> (the-as vector v0-11) quad) (-> s5-2 quad))
               )
             v0-11
             )
           )
         )
        (else
          (let ((s5-3 (new 'stack-no-clear 'vector)))
            (set! (-> s5-3 quad) (-> obj basetrans quad))
            (get-nav-point! (-> obj basetrans) obj (-> obj reset-trans) 40960.0)
            (let ((f0-29 (-> s5-3 y)))
              (set! (-> obj basetrans y) f0-29)
              f0-29
              )
            )
          )
        )
      )
    )
  )

;; failed to figure out what this is:
(defstate orbit-plat-reset (orbit-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 'go)
                        (go orbit-plat-rotating)
                        )
                       )
              )
      )
    )
  :trans (the-as (function none :behavior orbit-plat) plat-trans)
  :code (behavior ()
    (set! (-> self plat-status) (the-as uint 3))
    (logclear! (-> self nav flags) (nav-control-flags navcf19))
    (ja-no-eval :num! (seek! 0.0))
    (while (zero? (logand (nav-control-flags navcf19) (-> self nav flags)))
      (dummy-27 self)
      (when (nonzero? (-> self root-override riders num-riders))
        (let ((a1-1 (new 'stack-no-clear 'event-message-block)))
          (set! (-> a1-1 from) self)
          (set! (-> a1-1 num-params) 0)
          (set! (-> a1-1 message) 'go)
          (let ((t9-2 send-event-function)
                (v1-13 (-> self other))
                )
            (t9-2
              (if v1-13
                  (-> v1-13 extra process)
                  )
              a1-1
              )
            )
          )
        (go orbit-plat-riding)
        )
      (suspend)
      (if (not (ja-done? 0))
          (ja :num! (seek! 0.0))
          )
      )
    (set! (-> self is-reset?) #t)
    (go orbit-plat-idle)
    (none)
    )
  :post (the-as (function none :behavior orbit-plat) plat-post)
  )

;; failed to figure out what this is:
(defstate orbit-plat-wait-for-other (orbit-plat)
  :code (behavior ()
    (set! (-> self plat-status) (the-as uint 0))
    (ja-no-eval :num! (seek! 0.0))
    (loop
      (let ((v1-3 (-> self other)))
        (when (if v1-3
                  (-> v1-3 extra process)
                  )
          (suspend)
          (go orbit-plat-idle)
          )
        )
      (suspend)
      (if (not (ja-done? 0))
          (ja :num! (seek! 0.0))
          )
      )
    (none)
    )
  :post (the-as (function none :behavior orbit-plat) ja-post)
  )

;; definition for method 11 of type orbit-plat
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! orbit-plat ((obj orbit-plat) (arg0 entity-actor))
  (set! (-> obj plat-status) (the-as uint 0))
  (set! (-> obj mask) (logior (process-mask platform) (-> obj mask)))
  (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 0.0 0.0 13926.4)
      (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 *orbit-plat-sg* '())
  (logior! (-> obj skel status) (janim-status inited))
  (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))
  (dummy-21 obj)
  (set! (-> obj nav) (new 'process 'nav-control (-> obj root-override) 16 40960.0))
  (logior! (-> obj nav flags) (nav-control-flags display-marks navcf3 navcf5 navcf6 navcf7))
  (set! (-> obj nav gap-event) 'blocked)
  (set! (-> obj other) (entity-actor-lookup arg0 'alt-actor 0))
  (let ((f0-7 (res-lump-float arg0 'scale :default 1.0)))
    (set-vector! (-> obj root-override scale) f0-7 f0-7 f0-7 1.0)
    )
  (set! (-> obj timeout) (res-lump-float arg0 'timeout :default 10.0))
  (set! (-> obj rot-dir) 1.0)
  (set! (-> obj reset-trans quad) (-> obj basetrans quad))
  (set! (-> obj is-reset?) #t)
  (process-spawn orbit-plat-bottom (-> obj entity) obj :to obj)
  (go orbit-plat-wait-for-other)
  (none)
  )
