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

(import "goal_src/jak1/import/flutflut-bluehut-ag.gc")

;; definition of type flutflut-bluehut
(deftype flutflut-bluehut (process-taskable)
  ()
  :heap-base #x110
  :method-count-assert 53
  :size-assert         #x17c
  :flag-assert         #x350110017c
  )

;; definition for method 3 of type flutflut-bluehut
(defmethod inspect flutflut-bluehut ((obj flutflut-bluehut))
  (let ((t9-0 (method-of-type process-taskable inspect)))
    (t9-0 obj)
    )
  obj
  )

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

;; definition for method 32 of type flutflut-bluehut
;; INFO: Return type mismatch art-element vs basic.
(defmethod play-anim! flutflut-bluehut ((obj flutflut-bluehut) (arg0 symbol))
  (current-status (-> obj tasks))
  (if arg0
      (format
        0
        "ERROR: <GMJ>: ~S playing anim for task status ~S~%"
        (-> obj name)
        (task-status->string (current-status (-> obj tasks)))
        )
      )
  (the-as basic (get-art-elem obj))
  )

;; definition for method 31 of type flutflut-bluehut
(defmethod get-art-elem flutflut-bluehut ((obj flutflut-bluehut))
  (-> obj draw art-group data 2)
  )

;; definition for method 39 of type flutflut-bluehut
(defmethod should-display? flutflut-bluehut ((obj flutflut-bluehut))
  (and (closed? (-> obj tasks) (game-task village2-levitator) (task-status need-introduction))
       (task-closed? (game-task beach-flutflut) (task-status need-resolution))
       )
  )

;; failed to figure out what this is:
(defstate idle (flutflut-bluehut)
  :virtual #t
  :trans (behavior ()
    (set! (-> self will-talk) #f)
    ((-> (method-of-type process-taskable idle) trans))
    (none)
    )
  :code (behavior ()
    (if (!= (ja-group) (get-art-elem self))
        (ja-channel-push! 1 (seconds 0.05))
        )
    (loop
      (ja :group! flutflut-bluehut-idle-breathe-ja)
      (let* ((f30-0 2.0)
             (v1-8 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
             (v1-9 (the-as number (logior #x3f800000 v1-8)))
             )
        (countdown (gp-0 (+ (the int (* f30-0 (+ -1.0 (the-as float v1-9)))) 1))
          (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
          (until (ja-done? 0)
            (suspend)
            (ja :num! (seek!))
            )
          (let ((s5-0 (-> *display* base-frame-counter)))
            (while (< (+ (-> *display* base-frame-counter) (seconds -0.5)) s5-0)
              (suspend)
              )
            )
          (ja-no-eval :group! (ja-group) :num! (seek! 0.0) :frame-num max)
          (until (ja-done? 0)
            (suspend)
            (ja :num! (seek! 0.0))
            )
          (let ((s5-1 (-> *display* base-frame-counter)))
            (while (< (+ (-> *display* base-frame-counter) (seconds -0.5)) s5-1)
              (suspend)
              )
            )
          )
        )
      (ja-no-eval :group! flutflut-bluehut-idle-start-scratch-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      (ja :group! flutflut-bluehut-idle-scratch-ja)
      (let* ((f30-1 2.0)
             (v1-102 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
             (v1-103 (the-as number (logior #x3f800000 v1-102)))
             )
        (countdown (gp-1 (+ (the int (* f30-1 (+ -1.0 (the-as float v1-103)))) 6))
          (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
          (until (ja-done? 0)
            (suspend)
            (ja :num! (seek!))
            )
          )
        )
      (ja-no-eval :group! flutflut-bluehut-idle-start-scratch-ja :num! (seek! 0.0) :frame-num max)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! 0.0))
        )
      )
    (none)
    )
  )

;; definition for method 11 of type flutflut-bluehut
(defmethod init-from-entity! flutflut-bluehut ((obj flutflut-bluehut) (arg0 entity-actor))
  (dummy-40 obj arg0 *flutflut-bluehut-sg* 3 0 (new 'static 'vector :w 4096.0) 27)
  (set! (-> obj tasks) (get-task-control (game-task village2-levitator)))
  (set! (-> obj draw light-index) (the-as uint 1))
  (dummy-42 obj)
  (none)
  )
