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

;; name: waspala-obs.gc
;; name in dgo: waspala-obs
;; dgos: WASPALA

;; DECOMP BEGINS

(deftype water-anim-waspala (water-anim)
  ()
  )


(define ripple-for-water-anim-waspala (new 'static 'ripple-wave-set
                                        :count 3
                                        :converted #f
                                        :normal-scale 1.0
                                        :wave (new 'static 'inline-array ripple-wave 4
                                          (new 'static 'ripple-wave :scale 10.0 :xdiv 1 :speed 1.5)
                                          (new 'static 'ripple-wave :scale 10.0 :xdiv -1 :zdiv 1 :speed 1.5)
                                          (new 'static 'ripple-wave :scale 5.0 :xdiv 5 :zdiv 3 :speed 0.75)
                                          (new 'static 'ripple-wave)
                                          )
                                        )
        )

;; WARN: Return type mismatch ripple-wave-set vs object.
(defmethod init-water! ((this water-anim-waspala))
  (let ((t9-0 (method-of-type water-anim init-water!)))
    (t9-0 this)
    )
  (let ((v1-2 (new 'process 'ripple-control)))
    (set! (-> this draw ripple) v1-2)
    (set! (-> v1-2 global-scale) 3072.0)
    (set! (-> v1-2 close-fade-dist) 163840.0)
    (set! (-> v1-2 far-fade-dist) 245760.0)
    (let ((v0-2 ripple-for-water-anim-waspala))
      (set! (-> v1-2 waveform) v0-2)
      v0-2
      )
    )
  )

(deftype waspala-paddle-wheel (process-drawable)
  ()
  (:state-methods
    idle
    )
  (:methods
    (get-skel (_type_) art-group)
    )
  )


(defstate idle (waspala-paddle-wheel)
  :virtual #t
  :code (behavior ()
    (until #f
      (ja-no-eval :group! (ja-group) :num! (seek! max 0.05) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek! max 0.05))
        )
      )
    #f
    )
  :post (behavior ()
    (if (nonzero? (-> self sound))
        (update! (-> self sound))
        )
    (ja-post)
    )
  )

(defmethod init-from-entity! ((this waspala-paddle-wheel) (arg0 entity-actor))
  "Set up a newly created process from the entity that created it."
  (set! (-> this root) (new 'process 'trsqv))
  (process-drawable-from-entity! this arg0)
  (initialize-skeleton this (the-as skeleton-group (get-skel this)) (the-as pair 0))
  (set! (-> this sound) (new 'process 'ambient-sound (-> this entity) (-> this root trans) 0.0))
  (go (method-of-object this idle))
  )

(deftype waspala-paddle-wheel-a (waspala-paddle-wheel)
  ()
  )


(defskelgroup skel-waspala-paddle-wheel-a waspala-paddle-wheel-a waspala-paddle-wheel-a-lod0-jg waspala-paddle-wheel-a-idle-ja
              ((waspala-paddle-wheel-a-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 20)
              )

(defmethod get-skel ((this waspala-paddle-wheel-a))
  (art-group-get-by-name *level* "skel-waspala-paddle-wheel-a" (the-as (pointer level) #f))
  )

(deftype waspala-paddle-wheel-b (waspala-paddle-wheel)
  ()
  )


(defskelgroup skel-waspala-paddle-wheel-b waspala-paddle-wheel-b waspala-paddle-wheel-b-lod0-jg waspala-paddle-wheel-b-idle-ja
              ((waspala-paddle-wheel-b-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 15)
              )

(defmethod get-skel ((this waspala-paddle-wheel-b))
  (art-group-get-by-name *level* "skel-waspala-paddle-wheel-b" (the-as (pointer level) #f))
  )

(deftype waspala-windmill (process-drawable)
  ()
  (:state-methods
    idle
    )
  )


(defskelgroup skel-waspala-windmill waspala-windmill 0 2
              ((1 (meters 999999)))
              :bounds (static-spherem 0 -13 0 15)
              )

(defstate idle (waspala-windmill)
  :virtual #t
  :code (behavior ()
    (until #f
      (ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post ja-post
  )

(defmethod init-from-entity! ((this waspala-windmill) (arg0 entity-actor))
  "Set up a newly created process from the entity that created it."
  (set! (-> this root) (new 'process 'trsqv))
  (process-drawable-from-entity! this arg0)
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-waspala-windmill" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (go (method-of-object this idle))
  )

(deftype task-manager-throne-gun-training (task-manager)
  ((gui-id  sound-id)
   )
  (:methods
    (draw-text (_type_ text-id) none)
    )
  )


;; WARN: Return type mismatch float vs none.
(defmethod draw-text ((this task-manager-throne-gun-training) (arg0 text-id))
  (when (= (get-status *gui-control* (-> this gui-id)) (gui-status active))
    (let ((s5-1
            (new 'stack 'font-context *font-default-matrix* 32 290 0.0 (font-color default) (font-flags shadow kerning))
            )
          )
      (set! (-> s5-1 flags) (font-flags shadow kerning middle-vert large))
      (set-width! s5-1 440)
      (set-height! s5-1 80)
      (set-scale! s5-1 0.7)
      (let ((s4-0 print-game-text))
        (format (clear *temp-string*) (lookup-text! *common-text* arg0 #f))
        (s4-0 *temp-string* s5-1 #f 44 (bucket-id hud-draw-hud-alpha))
        )
      )
    )
  (none)
  )

(defstate active (task-manager-throne-gun-training)
  :virtual #t
  :parent (task-manager-throne-gun-training active)
  :exit (behavior ()
    (let ((t9-0 (-> (method-of-type task-manager active) exit)))
      (if t9-0
          (t9-0)
          )
      )
    (remove-setting! 'minimap)
    (remove-setting! 'change-gun)
    )
  :code (behavior ()
    (local-vars (v1-29 symbol))
    (adjust-player-ammo 500.0 (pickup-type ammo-red))
    (set-setting! 'minimap 'clear 0.0 (minimap-flag minimap))
    (set! (-> *game-info* gun-type) (pickup-type none))
    (until (process-grab? *target* #f)
      (suspend)
      )
    (let ((gp-0 27))
      (set-setting! 'change-gun #t 0.0 0)
      (suspend-for (seconds 5)
        )
      (set! (-> self gui-id)
            (add-process *gui-control* self (gui-channel message) (gui-action play) (-> self name) 81920.0 0)
            )
      (until (= gp-0 (-> *game-info* gun-type))
        (draw-text self (text-id text-056f))
        (suspend)
        )
      )
    (send-event *target* 'end-mode 'grab)
    (until v1-29
      (draw-text self (text-id hold-to-charge-and-then-release-to-fire-bigger-blast))
      (if (< (get-remaining-player-ammo (pickup-type ammo-red)) 60.0)
          (adjust-player-ammo 500.0 (pickup-type ammo-red))
          )
      (suspend)
      (set! v1-29
            (or (not *target*)
                (let ((f30-0 0.5))
                  (< f30-0 (the-as float (send-event (handle->process (-> *target* gun charge-active?)) 'charge)))
                  )
                )
            )
      )
    (send-event *target* 'end-mode 'grab)
    (task-node-close! (game-task-node arena-fight-2-gun-training) 'event)
    (until #f
      (suspend)
      )
    #f
    )
  )

(deftype waspala-blocker (process-drawable)
  ((root  collide-shape :override)
   )
  (:state-methods
    idle
    )
  )


(defskelgroup skel-waspala-blocker waspala-blocker waspala-blocker-lod0-jg waspala-blocker-idle-ja
              ((waspala-blocker-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 2 0 10)
              )

(defstate idle (waspala-blocker)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('on)
       (set! (-> self root root-prim prim-core collide-as) (collide-spec obstacle))
       (set! (-> self root root-prim prim-core collide-with) (collide-spec jak player-list))
       (transform-post)
       )
      (('off)
       (set! (-> self root root-prim prim-core collide-as) (collide-spec))
       (set! (-> self root root-prim prim-core collide-with) (collide-spec))
       (transform-post)
       )
      )
    )
  :code sleep-code
  )

(defmethod init-from-entity! ((this waspala-blocker) (arg0 entity-actor))
  "Set up a newly created process from the entity that created it."
  (let ((s4-0 (new 'process 'collide-shape this (collide-list-enum hit-by-others))))
    (let ((v1-2 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> v1-2 prim-core collide-as) (collide-spec obstacle))
      (set! (-> v1-2 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> v1-2 prim-core action) (collide-action solid))
      (set! (-> v1-2 transform-index) 3)
      (set-vector! (-> v1-2 local-sphere) 0.0 0.0 0.0 106496.0)
      (set! (-> s4-0 total-prims) (the-as uint 1))
      (set! (-> s4-0 root-prim) v1-2)
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (let ((v1-5 (-> s4-0 root-prim)))
      (set! (-> s4-0 backup-collide-as) (-> v1-5 prim-core collide-as))
      (set! (-> s4-0 backup-collide-with) (-> v1-5 prim-core collide-with))
      )
    (set! (-> this root) s4-0)
    )
  (set! (-> this root root-prim prim-core collide-as) (collide-spec))
  (set! (-> this root root-prim prim-core collide-with) (collide-spec))
  (process-drawable-from-entity! this arg0)
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-waspala-blocker" (the-as (pointer level) #f)))
    (the-as pair 0)
    )
  (transform-post)
  (go (method-of-object this idle))
  )
