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

(import "goal_src/jak1/import/light-eco-ag.gc")

;; definition of type light-eco-child
(deftype light-eco-child (process-drawable)
  ((root-override      collide-shape         :offset        112)
   (angle-bit          int32                 :offset-assert 176)
   (ground-y           float                 :offset-assert 180)
   (falling-start-time time-frame            :offset-assert 184)
   (last-update-time   time-frame            :offset-assert 192)
   (rot                vector        :inline :offset-assert 208)
   (rotv               vector        :inline :offset-assert 224)
   (traj               trajectory    :inline :offset-assert 240)
   )
  :heap-base #xb0
  :method-count-assert 21
  :size-assert         #x118
  :flag-assert         #x1500b00118
  (:methods
    (common-trans (_type_) none 20)
    )
  (:states
    light-eco-child-appear
    light-eco-child-die
    light-eco-child-grabbed
    light-eco-child-hit-ground
    light-eco-child-idle
    )
  )

;; definition for method 3 of type light-eco-child
(defmethod inspect light-eco-child ((obj light-eco-child))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tangle-bit: ~D~%" (-> obj angle-bit))
  (format #t "~T~Tground-y: ~f~%" (-> obj ground-y))
  (format #t "~T~Tfalling-start-time: ~D~%" (-> obj falling-start-time))
  (format #t "~T~Tlast-update-time: ~D~%" (-> obj last-update-time))
  (format #t "~T~Trot: #<vector @ #x~X>~%" (-> obj rot))
  (format #t "~T~Trotv: #<vector @ #x~X>~%" (-> obj rotv))
  (format #t "~T~Ttraj: #<trajectory @ #x~X>~%" (-> obj traj))
  obj
  )

;; definition of type light-eco-mother
(deftype light-eco-mother (process-drawable)
  ((player-got-eco?   symbol                    :offset-assert 176)
   (angle-mask        int64                     :offset-assert 184)
   (delay-til-spawn   int32                     :offset-assert 192)
   (part2             sparticle-launch-control  :offset-assert 196)
   (last-update-time  time-frame                :offset-assert 200)
   (last-spawned-time time-frame                :offset-assert 208)
   )
  :heap-base #x70
  :method-count-assert 22
  :size-assert         #xd8
  :flag-assert         #x16007000d8
  (:methods
    (spawn-child-eco (_type_) symbol 20)
    (common-trans (_type_) none 21)
    )
  (:states
    light-eco-mother-active
    light-eco-mother-appear
    light-eco-mother-discipate
    )
  )

;; definition for method 3 of type light-eco-mother
(defmethod inspect light-eco-mother ((obj light-eco-mother))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tplayer-got-eco?: ~A~%" (-> obj player-got-eco?))
  (format #t "~T~Tangle-mask: ~D~%" (-> obj angle-mask))
  (format #t "~T~Tdelay-til-spawn: ~D~%" (-> obj delay-til-spawn))
  (format #t "~T~Tpart2: ~A~%" (-> obj part2))
  (format #t "~T~Tlast-update-time: ~D~%" (-> obj last-update-time))
  (format #t "~T~Tlast-spawned-time: ~D~%" (-> obj last-spawned-time))
  obj
  )

;; failed to figure out what this is:
(defskelgroup *light-eco-big-sg* light-eco light-eco-big-lod0-jg -1
              ((light-eco-big-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 9)
              )

;; failed to figure out what this is:
(defskelgroup *light-eco-small-sg* light-eco light-eco-small-lod0-jg -1
              ((light-eco-small-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 1.5)
              )

;; failed to figure out what this is:
(defpartgroup group-light-eco-mother-growing
  :id 690
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 32)
  :parts ((sp-item 2902) (sp-item 2900) (sp-item 2897) (sp-item 2898))
  )

;; failed to figure out what this is:
(defpart 2897
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x2 :page #x2))
    (sp-flt spt-num 0.5)
    (sp-rnd-flt spt-scale-x (meters 10.5) (meters 4.5) 1.0)
    (sp-int spt-rot-x 4)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-scale-y (meters 2.1) (meters 1.8) 1.0)
    (sp-rnd-int spt-r 0 1 255.0)
    (sp-rnd-int spt-g 0 1 255.0)
    (sp-rnd-int spt-b 0 1 255.0)
    (sp-flt spt-a 0.0)
    (sp-flt spt-scalevel-x (meters 0.009765625))
    (sp-rnd-flt spt-rotvel-z (degrees -0.15) (degrees 0.3) 1.0)
    (sp-flt spt-scalevel-y (meters 0.009765625))
    (sp-flt spt-fade-a 0.35555556)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int spt-next-time 90)
    (sp-launcher-by-id spt-next-launcher 2899)
    )
  )

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

;; failed to figure out what this is:
(defpart 2898
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x2 :page #x2))
    (sp-flt spt-num 0.06)
    (sp-rnd-flt spt-scale-x (meters 20) (meters 4.5) 1.0)
    (sp-int spt-rot-x 4)
    (sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
    (sp-flt spt-scale-y (meters 1.2))
    (sp-rnd-int spt-r 0 1 255.0)
    (sp-rnd-int spt-g 0 1 255.0)
    (sp-rnd-int spt-b 0 1 255.0)
    (sp-flt spt-a 0.0)
    (sp-flt spt-scalevel-x (meters 0.009765625))
    (sp-rnd-flt spt-rotvel-z (degrees -0.15) (degrees 0.3) 1.0)
    (sp-flt spt-fade-a 0.32)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit3 bit14)
    (sp-int spt-next-time 75)
    (sp-launcher-by-id spt-next-launcher 232)
    )
  )

;; failed to figure out what this is:
(defpart 2900
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-rnd-flt spt-num 0.05 0.05 1.0)
    (sp-rnd-flt spt-x (meters -0.001) (meters 0.002) 1.0)
    (sp-rnd-flt spt-y (meters -0.001) (meters 0.002) 1.0)
    (sp-rnd-flt spt-z (meters -0.001) (meters 0.002) 1.0)
    (sp-rnd-flt spt-scale-x (meters 10) (meters 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-rnd-flt spt-r 192.0 64.0 1.0)
    (sp-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-flt spt-vel-y (meters 0))
    (sp-flt spt-scalevel-x (meters 0.016666668))
    (sp-rnd-flt spt-rotvel-z (degrees -0.3) (degrees 0.6) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a 0.21333334)
    (sp-int spt-timer 600)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int-plain-rnd spt-next-time 240 59 1)
    (sp-launcher-by-id spt-next-launcher 2901)
    )
  )

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

;; failed to figure out what this is:
(defpart 2902
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 1.0 8.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.2) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 192.0 64.0 1.0)
    (sp-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 64.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.10666667) (meters 0.21333334) 1.0)
    (sp-flt spt-scalevel-x (meters -0.00083333335))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-rnd-flt spt-accel-y -6.826667 -2.7306666 1.0)
    (sp-flt spt-friction 0.9)
    (sp-int-plain-rnd spt-timer 30 149 1)
    (sp-cpuinfo-flags bit0 bit2 bit3)
    (sp-flt spt-userdata 1638400.0)
    (sp-func spt-func 'check-drop-level-lighteco-big-pops)
    (sp-int-plain-rnd spt-next-time 45 299 1)
    (sp-launcher-by-id spt-next-launcher 2903)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 180.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees -1440.0) (degrees 2880.0) 1.0)
    (sp-flt spt-conerot-radius (meters 4))
    )
  )

;; failed to figure out what this is:
(defpart 2903
  :init-specs ((sp-flt spt-userdata 2252800.0))
  )

;; definition for function check-drop-level-lighteco-big-pops
(defun check-drop-level-lighteco-big-pops ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (when (< (-> arg2 y) (-> arg1 user-float))
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (sp-kill-particle arg0 arg1)
      (set-vector! gp-0 (-> arg2 x) (-> arg2 y) (-> arg2 z) 1.0)
      (sp-launch-particles-var
        *sp-particle-system-2d*
        (-> *part-id-table* 2904)
        gp-0
        (the-as sparticle-launch-state #f)
        (the-as sparticle-launch-control #f)
        1.0
        )
      (sp-launch-particles-var
        *sp-particle-system-2d*
        (-> *part-id-table* 2905)
        gp-0
        (the-as sparticle-launch-state #f)
        (the-as sparticle-launch-control #f)
        1.0
        )
      )
    )
  (none)
  )

;; failed to figure out what this is:
(defpart 2905
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 1) (meters 0.4) 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 255.0)
    (sp-flt spt-g 255.0)
    (sp-flt spt-b 255.0)
    (sp-rnd-flt spt-a 16.0 32.0 1.0)
    (sp-flt spt-fade-a -1.92)
    (sp-int spt-timer 20)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpart 2904
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 4.0 4.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.3) (meters 0.2) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 192.0 64.0 1.0)
    (sp-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 64.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.053333335) (meters 0.053333335) 1.0)
    (sp-rnd-flt spt-accel-y -6.826667 -2.7306666 1.0)
    (sp-flt spt-friction 0.85)
    (sp-int-plain-rnd spt-timer 15 119 1)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpartgroup group-light-eco-mother
  :id 691
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 32)
  :parts ((sp-item 2902) (sp-item 2900) (sp-item 2897) (sp-item 2898))
  )

;; failed to figure out what this is:
(defpartgroup group-light-eco-child
  :id 692
  :flags (use-local-clock)
  :bounds (static-bspherem 0 0 0 4)
  :parts ((sp-item 2906) (sp-item 2907))
  )

;; failed to figure out what this is:
(defpart 2907
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #x2))
    (sp-rnd-flt spt-num 0.025 0.025 1.0)
    (sp-rnd-flt spt-x (meters -0.001) (meters 0.002) 1.0)
    (sp-rnd-flt spt-y (meters -0.001) (meters 0.002) 1.0)
    (sp-rnd-flt spt-z (meters -0.001) (meters 0.002) 1.0)
    (sp-rnd-flt spt-scale-x (meters 2) (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-rnd-flt spt-r 192.0 64.0 1.0)
    (sp-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-flt spt-a 0.0)
    (sp-flt spt-vel-y (meters 0))
    (sp-flt spt-scalevel-x (meters 0.006666667))
    (sp-rnd-flt spt-rotvel-z (degrees -0.3) (degrees 0.6) 1.0)
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-flt spt-fade-a 0.85333335)
    (sp-int spt-timer 300)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-int-plain-rnd spt-next-time 120 29 1)
    (sp-launcher-by-id spt-next-launcher 2908)
    )
  )

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

;; failed to figure out what this is:
(defpart 2906
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 1.0 2.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.15) (meters 0.3) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 192.0 64.0 1.0)
    (sp-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 64.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.10666667) (meters 0.21333334) 1.0)
    (sp-flt spt-scalevel-x (meters -0.00083333335))
    (sp-copy-from-other spt-scalevel-y -4)
    (sp-rnd-flt spt-accel-y -6.826667 -2.7306666 1.0)
    (sp-flt spt-friction 0.5)
    (sp-int-plain-rnd spt-timer 30 149 1)
    (sp-cpuinfo-flags bit0 bit2 bit3)
    (sp-flt spt-userdata 1638400.0)
    (sp-func spt-func 'check-drop-level-lighteco-pops)
    (sp-int-plain-rnd spt-next-time 45 299 1)
    (sp-launcher-by-id spt-next-launcher 2909)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 180.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees -1440.0) (degrees 2880.0) 1.0)
    )
  )

;; failed to figure out what this is:
(defpart 2909
  :init-specs ((sp-flt spt-userdata 2048000.0))
  )

;; definition for function check-drop-level-lighteco-pops
(defun check-drop-level-lighteco-pops ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
  (when (< (-> arg2 y) (-> arg1 user-float))
    (let ((gp-0 (new 'stack-no-clear 'vector)))
      (sp-kill-particle arg0 arg1)
      (set-vector! gp-0 (-> arg2 x) (-> arg2 y) (-> arg2 z) 1.0)
      (sp-launch-particles-var
        *sp-particle-system-2d*
        (-> *part-id-table* 2910)
        gp-0
        (the-as sparticle-launch-state #f)
        (the-as sparticle-launch-control #f)
        1.0
        )
      (sp-launch-particles-var
        *sp-particle-system-2d*
        (-> *part-id-table* 2911)
        gp-0
        (the-as sparticle-launch-state #f)
        (the-as sparticle-launch-control #f)
        1.0
        )
      )
    )
  (none)
  )

;; failed to figure out what this is:
(defpart 2911
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
    (sp-flt spt-num 1.0)
    (sp-rnd-flt spt-scale-x (meters 1) (meters 0.4) 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 255.0)
    (sp-flt spt-g 255.0)
    (sp-flt spt-b 255.0)
    (sp-rnd-flt spt-a 16.0 32.0 1.0)
    (sp-flt spt-fade-a -1.92)
    (sp-int spt-timer 20)
    (sp-cpuinfo-flags bit2 bit3)
    )
  )

;; failed to figure out what this is:
(defpart 2910
  :init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
    (sp-rnd-flt spt-num 4.0 4.0 1.0)
    (sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.2) 1.0)
    (sp-copy-from-other spt-scale-y -4)
    (sp-rnd-flt spt-r 192.0 64.0 1.0)
    (sp-rnd-flt spt-g 192.0 64.0 1.0)
    (sp-rnd-flt spt-b 192.0 64.0 1.0)
    (sp-rnd-flt spt-a 32.0 64.0 1.0)
    (sp-rnd-flt spt-vel-y (meters 0.053333335) (meters 0.053333335) 1.0)
    (sp-rnd-flt spt-accel-y -6.826667 -2.7306666 1.0)
    (sp-flt spt-friction 0.85)
    (sp-int-plain-rnd spt-timer 15 119 1)
    (sp-cpuinfo-flags bit2 bit3)
    (sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
    (sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
    )
  )

;; definition for function light-eco-child-default-event-handler
(defbehavior light-eco-child-default-event-handler light-eco-child ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (case arg2
    (('touch 'attack)
     (when (= (-> arg0 type) target)
       (send-event (ppointer->process (-> self parent)) 'trigger (-> self angle-bit))
       (go light-eco-child-grabbed)
       )
     )
    )
  )

;; definition for method 20 of type light-eco-child
;; INFO: Return type mismatch object vs none.
(defmethod common-trans light-eco-child ((obj light-eco-child))
  (let ((v1-1 (-> *display* base-frame-counter)))
    (when (!= v1-1 (-> obj last-update-time))
      (set! (-> obj last-update-time) v1-1)
      (let* ((s5-0 (new 'stack-no-clear 'vector))
             (s4-0 (-> obj rot))
             (f30-0 (-> s4-0 w))
             )
        (vector-v++! s4-0 (-> obj rotv))
        (set! (-> s4-0 w) (+ f30-0 (* (-> obj rotv w) (-> *display* seconds-per-frame))))
        (set-vector! s5-0 (cos (-> s4-0 x)) (cos (-> s4-0 y)) (cos (-> s4-0 z)) 1.0)
        (vector-normalize! s5-0 1.0)
        (quaternion-vector-angle! (-> obj root-override quat) s5-0 f30-0)
        )
      (spawn (-> obj part) (-> obj root-override trans))
      )
    )
  (none)
  )

;; failed to figure out what this is:
(defstate light-eco-child-appear (light-eco-child)
  :event light-eco-child-default-event-handler
  :enter (behavior ()
    (set! (-> self falling-start-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (let ((f30-0
            (fmin (the float (- (-> *display* base-frame-counter) (-> self falling-start-time))) (-> self traj time))
            )
          )
      (eval-position! (-> self traj) f30-0 (-> self root-override trans))
      (if (= f30-0 (-> self traj time))
          (go light-eco-child-hit-ground)
          )
      )
    (common-trans self)
    (none)
    )
  :code (behavior ()
    (loop
      (suspend)
      (ja :num! (loop!))
      )
    (none)
    )
  :post (the-as (function none :behavior light-eco-child) transform-post)
  )

;; failed to figure out what this is:
(defstate light-eco-child-hit-ground (light-eco-child)
  :event light-eco-child-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (let ((f30-0 (+ (-> self root-override transv y) (* -544768.0 (-> *display* seconds-per-frame)))))
      (when (and (< f30-0 0.0) (>= (-> self ground-y) (-> self root-override trans y)))
        (if (>= 4096.0 (fabs f30-0))
            (go light-eco-child-idle)
            )
        (set! (-> self root-override transv y) 0.0)
        (vector-normalize! (-> self root-override transv) (* 0.25 (vector-xz-length (-> self root-override transv))))
        (set! f30-0 (* 0.35 (- f30-0)))
        )
      (set! (-> self root-override transv y) f30-0)
      )
    (vector-v+! (-> self root-override trans) (-> self root-override trans) (-> self root-override transv))
    (let ((f0-8 (vector-vector-xz-distance
                  (-> self root-override trans)
                  (-> (the-as light-eco-mother (-> self parent 0)) root trans)
                  )
                )
          )
      (when (< 92610.56 f0-8)
        (let ((gp-1 (new 'stack-no-clear 'vector)))
          (vector-! gp-1 (-> self root-override trans) (-> (the-as light-eco-mother (-> self parent 0)) root trans))
          (set! (-> gp-1 y) 0.0)
          (vector-normalize! gp-1 92610.56)
          (vector+! gp-1 gp-1 (-> (the-as light-eco-mother (-> self parent 0)) root trans))
          (set! (-> gp-1 y) (-> self root-override trans y))
          (set! (-> self root-override trans quad) (-> gp-1 quad))
          )
        )
      )
    (common-trans self)
    (none)
    )
  :code (behavior ()
    (loop
      (suspend)
      (ja :num! (loop!))
      )
    (none)
    )
  :post (the-as (function none :behavior light-eco-child) transform-post)
  )

;; failed to figure out what this is:
(defstate light-eco-child-idle (light-eco-child)
  :event light-eco-child-default-event-handler
  :enter (behavior ()
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (none)
    )
  :trans (behavior ()
    (if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 4))
        (go light-eco-child-die)
        )
    (common-trans self)
    (none)
    )
  :code (behavior ()
    (loop
      (suspend)
      (ja :num! (loop!))
      )
    (none)
    )
  :post (the-as (function none :behavior light-eco-child) transform-post)
  )

;; failed to figure out what this is:
(defstate light-eco-child-die (light-eco-child)
  :code (behavior ()
    (send-event (ppointer->process (-> self parent)) 'untrigger (-> self angle-bit))
    (clear-collide-with-as (-> self root-override))
    (logior! (-> self draw status) (draw-status hidden))
    (set! (-> self state-time) (-> *display* base-frame-counter))
    (until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.1))
      (suspend)
      )
    (none)
    )
  )

;; failed to figure out what this is:
(defstate light-eco-child-grabbed (light-eco-child)
  :code (behavior ()
    (suspend)
    0
    (none)
    )
  )

;; definition for function light-eco-child-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior light-eco-child-init-by-other light-eco-child ((arg0 entity-actor) (arg1 vector) (arg2 vector) (arg3 int))
  (set! (-> self entity) arg0)
  (set! (-> self angle-bit) arg3)
  (set! (-> self ground-y) (-> arg2 y))
  (set! (-> self last-update-time) 0)
  (set-vector!
    (-> self rotv)
    (rand-vu-float-range 5898.24 9539.129)
    (rand-vu-float-range 5552.3555 9193.244)
    (rand-vu-float-range 6007.467 9648.355)
    (rand-vu-float-range 11013.688 18295.467)
    )
  (set-vector!
    (-> self rot)
    (rand-vu-float-range 0.0 65536.0)
    (rand-vu-float-range 0.0 65536.0)
    (rand-vu-float-range 0.0 65536.0)
    (rand-vu-float-range 0.0 65536.0)
    )
  (let ((s4-2 (new 'process 'collide-shape self (collide-list-enum hit-by-player))))
    (let ((s3-0 (new 'process 'collide-shape-prim-sphere s4-2 (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 offense) (collide-offense no-offense))
      (set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 4096.0)
      (set-root-prim! s4-2 s3-0)
      )
    (set! (-> s4-2 nav-radius) (* 0.75 (-> s4-2 root-prim local-sphere w)))
    (backup-collide-with-as s4-2)
    (set! (-> self root-override) s4-2)
    )
  (set! (-> self root-override trans quad) (-> arg1 quad))
  (set-vector! (-> self root-override scale) 2.0 2.0 2.0 1.0)
  (quaternion-identity! (-> self root-override quat))
  (setup-from-to-height! (-> self traj) (-> self root-override trans) arg2 4096.0 -4.551111)
  (let ((s4-3 (-> self root-override transv)))
    (vector-! s4-3 arg2 arg1)
    (set! (-> s4-3 y) 0.0)
    (vector-normalize! s4-3 163840.0)
    (set! (-> s4-3 y) -122880.0)
    )
  (logclear! (-> self mask) (process-mask actor-pause))
  (initialize-skeleton self *light-eco-small-sg* '())
  (ja-channel-set! 1)
  (ja-no-eval :num! (seek!))
  (ja :group! light-eco-small-idle-ja :num! min)
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 692) self))
  (transform-post)
  (go light-eco-child-appear)
  (none)
  )

;; definition for method 21 of type light-eco-mother
;; INFO: Return type mismatch int vs none.
(defmethod common-trans light-eco-mother ((obj light-eco-mother))
  (let ((v1-1 (-> *display* base-frame-counter)))
    (when (!= v1-1 (-> obj last-update-time))
      (set! (-> obj last-update-time) v1-1)
      (let ((s5-0 (new 'stack-no-clear 'vector)))
        (set-vector!
          s5-0
          (cos (* 25.700392 (the float (mod (-> *display* base-frame-counter) 2550))))
          (cos (* 24.59229 (the float (mod (-> *display* base-frame-counter) 2664))))
          (cos (* 26.121408 (the float (mod (-> *display* base-frame-counter) 2508))))
          1.0
          )
        (vector-normalize! s5-0 1.0)
        (quaternion-vector-angle!
          (-> obj root quat)
          s5-0
          (* 48.860058 (the float (mod (-> *display* base-frame-counter) 1341)))
          )
        )
      (cond
        ((and *target* (logtest? (-> *target* state-flags) (state-flags grabbed)))
         (set! (-> obj last-spawned-time) (-> *display* base-frame-counter))
         (set! (-> obj delay-til-spawn) 2400)
         )
        (else
          (when (>= (- (-> *display* base-frame-counter) (-> obj last-spawned-time)) (-> obj delay-til-spawn))
            (when (spawn-child-eco obj)
              (set! (-> obj last-spawned-time) (-> *display* base-frame-counter))
              (set! (-> obj delay-til-spawn) (rand-vu-int-range 300 600))
              )
            )
          )
        )
      (update! (-> obj sound))
      0
      )
    )
  (none)
  )

;; definition for method 20 of type light-eco-mother
(defmethod spawn-child-eco light-eco-mother ((obj light-eco-mother))
  (countdown (s3-0 4)
    (let ((gp-0 (rand-vu-int-count 32)))
      (when (zero? (logand (-> obj angle-mask) (ash 1 gp-0)))
        (let ((f28-0 (* 2048.0 (the float gp-0)))
              (f30-0 (rand-vu-float-range 61440.0 88514.56))
              (s4-0 (new 'stack-no-clear 'vector))
              )
          (set-vector! s4-0 (* (sin f28-0) f30-0) 0.0 (* (cos f28-0) f30-0) 1.0)
          (vector+! s4-0 s4-0 (-> obj root trans))
          (set! (-> s4-0 y) 1974272.0)
          (when (or (not *target*) (>= (vector-vector-xz-distance s4-0 (target-pos 0)) 49152.0))
            (logior! (-> obj angle-mask) (ash 1 gp-0))
            (process-spawn light-eco-child (-> obj entity) (-> obj root trans) s4-0 gp-0 :to obj)
            (return #t)
            )
          )
        )
      )
    )
  #f
  )

;; definition for function light-eco-mother-default-event-handler
;; INFO: Return type mismatch object vs int.
(defbehavior light-eco-mother-default-event-handler light-eco-mother ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
  (let ((v1-0 arg2))
    (the-as
      int
      (cond
        ((= v1-0 'untrigger)
         (the-as int (when (= (-> arg0 type) light-eco-child)
                       (let* ((a1-3 (-> arg3 param 0))
                              (v0-0 (logxor (-> self angle-mask) (ash 1 a1-3)))
                              )
                         (set! (-> self angle-mask) v0-0)
                         v0-0
                         )
                       )
                 )
         )
        ((= v1-0 'trigger)
         (the-as int (when (not (-> self player-got-eco?))
                       (set! (-> self player-got-eco?) #t)
                       (the-as int (send-event (ppointer->process (-> self parent)) 'white-eco-picked-up))
                       )
                 )
         )
        ((= v1-0 'beam-off)
         (the-as int (go light-eco-mother-discipate))
         )
        )
      )
    )
  )

;; failed to figure out what this is:
(defstate light-eco-mother-appear (light-eco-mother)
  :event light-eco-mother-default-event-handler
  :trans (behavior ()
    (common-trans self)
    (spawn (-> self part2) (-> self root trans))
    (none)
    )
  :code (behavior ()
    (while (!= (-> self root scale x) 12.0)
      (let ((f0-3 (seek-with-smooth (-> self root scale x) 12.0 (* 6.0 (-> *display* seconds-per-frame)) 0.25 0.001)))
        (set-vector! (-> self root scale) f0-3 f0-3 f0-3 1.0)
        )
      (suspend)
      (ja :num! (loop!))
      )
    (go light-eco-mother-active)
    (none)
    )
  :post (the-as (function none :behavior light-eco-mother) ja-post)
  )

;; failed to figure out what this is:
(defstate light-eco-mother-active (light-eco-mother)
  :event light-eco-mother-default-event-handler
  :trans (behavior ()
    (common-trans self)
    (spawn (-> self part) (-> self root trans))
    0
    (none)
    )
  :code (behavior ()
    (loop
      (suspend)
      (ja :num! (loop!))
      )
    (none)
    )
  :post (the-as (function none :behavior light-eco-mother) ja-post)
  )

;; failed to figure out what this is:
(defstate light-eco-mother-discipate (light-eco-mother)
  :event light-eco-mother-default-event-handler
  :trans (behavior ()
    (common-trans self)
    (none)
    )
  :code (behavior ()
    (while (!= (-> self root scale x) 0.0)
      (let ((f0-3 (seek-with-smooth (-> self root scale x) 0.0 (* 12.0 (-> *display* seconds-per-frame)) 0.5 0.001)))
        (set-vector! (-> self root scale) f0-3 f0-3 f0-3 1.0)
        )
      (suspend)
      (ja :num! (loop!))
      )
    (logior! (-> self draw status) (draw-status hidden))
    (until (not (-> self child))
      (suspend)
      )
    (none)
    )
  :post (the-as (function none :behavior light-eco-mother) ja-post)
  )

;; definition for method 10 of type light-eco-mother
(defmethod deactivate light-eco-mother ((obj light-eco-mother))
  (if (nonzero? (-> obj part2))
      (kill-and-free-particles (-> obj part2))
      )
  ((method-of-type projectile deactivate) (the-as projectile obj))
  (none)
  )

;; definition for method 7 of type light-eco-mother
;; INFO: Return type mismatch projectile vs light-eco-mother.
(defmethod relocate light-eco-mother ((obj light-eco-mother) (arg0 int))
  (if (nonzero? (-> obj part2))
      (&+! (-> obj part2) arg0)
      )
  (the-as light-eco-mother ((method-of-type projectile relocate) (the-as projectile obj) arg0))
  )

;; definition for function light-eco-mother-init-by-other
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defbehavior light-eco-mother-init-by-other light-eco-mother ((arg0 entity-actor) (arg1 vector))
  (set! (-> self entity) arg0)
  (set! (-> self last-update-time) 0)
  (set! (-> self last-spawned-time) (-> *display* base-frame-counter))
  (set! (-> self delay-til-spawn) 2400)
  (set! (-> self angle-mask) 0)
  (set! (-> self player-got-eco?) #f)
  (set! (-> self root) (new 'process 'trsqv))
  (set! (-> self root trans quad) (-> arg1 quad))
  (vector-reset! (-> self root scale))
  (quaternion-identity! (-> self root quat))
  (logclear! (-> self mask) (process-mask actor-pause))
  (initialize-skeleton self *light-eco-big-sg* '())
  (ja-channel-set! 1)
  (ja-no-eval :num! (seek!))
  (ja :group! light-eco-big-idle-ja :num! min)
  (set! (-> self part) (create-launch-control (-> *part-group-id-table* 691) self))
  (set! (-> self part2) (create-launch-control (-> *part-group-id-table* 690) self))
  (set! (-> self sound)
        (new 'process 'ambient-sound (static-sound-spec "white-eco-lp" :fo-min 300 :fo-max 400) (-> self root trans))
        )
  (ja-post)
  (let ((f0-4 0.0))
    (countdown (v1-33 4)
      (let ((a2-4 (the int (* 0.00048828125 f0-4))))
        (logior! (-> self angle-mask) (ash 1 a2-4))
        )
      (set! f0-4 (+ 16384.0 f0-4))
      )
    )
  (go light-eco-mother-appear)
  (none)
  )
