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

;; name: mincan-obs.gc
;; name in dgo: mincan-obs
;; dgos: MCN

(declare-type mincan-lighthouse process-drawable)

;; DECOMP BEGINS

(deftype water-anim-mincan (water-anim)
  ()
  )


(define ripple-for-water-anim-mincan (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 5.0 :xdiv -1 :speed 2.75)
                                         (new 'static 'ripple-wave :scale 5.0 :xdiv -2 :zdiv 1 :speed 1.53)
                                         (new 'static 'ripple-wave :scale 5.0 :xdiv 1 :zdiv 1 :speed 2.61)
                                         (new 'static 'ripple-wave)
                                         )
                                       )
        )

(defmethod init-water! ((this water-anim-mincan))
  "Initialize a [[water-anim]]'s default settings, this may include applying a [[riple-control]]"
  (let ((func (method-of-type water-anim init-water!)))
    (func this)
    )
  (let ((ripple-control (new 'process 'ripple-control)))
    (set! (-> this draw ripple) ripple-control)
    (set-vector! (-> this draw color-mult) 0.01 0.45 0.5 0.75)
    (set! (-> ripple-control global-scale) 3072.0)
    (set! (-> ripple-control close-fade-dist) 163840.0)
    (set! (-> ripple-control far-fade-dist) 245760.0)
    (set! (-> ripple-control waveform) ripple-for-water-anim-mincan)
    )
  0
  (none)
  )

(deftype mincan-lighthouse-lens (process-drawable)
  ()
  (:state-methods
    idle
    erect
    )
  )


(defskelgroup skel-mincan-lighthouse-lens mincan-lighthouse mincan-lighthouse-lens-lod0-jg mincan-lighthouse-lens-idle-ja
              ((mincan-lighthouse-lens-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 5)
              :origin-joint-index 9
              )

(defstate idle (mincan-lighthouse-lens)
  :virtual #t
  :trans (behavior ()
    (if (task-node-closed? (game-task-node canyon-insert-items-resolution))
        (go-virtual erect)
        )
    )
  :code (behavior ()
    (until #f
      (ja-no-eval :group! mincan-lighthouse-lens-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post ja-post
  )

(defstate erect (mincan-lighthouse-lens)
  :virtual #t
  :code (behavior ()
    (ja-channel-push! 1 0)
    (until #f
      (ja-no-eval :group! mincan-lighthouse-lens-idle-erect-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post ja-post
  )

;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! ((this mincan-lighthouse-lens) (arg0 entity-actor))
  "Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
This commonly includes things such as:
- stack size
- collision information
- loading the skeleton group / bones
- sounds"
  (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-mincan-lighthouse-lens" (the-as (pointer uint32) #f))
      )
    (the-as pair 0)
    )
  (go (method-of-object this idle))
  (none)
  )

;; WARN: Return type mismatch object vs none.
(defbehavior mincan-lighthouse-lens-init-by-other mincan-lighthouse-lens ((arg0 mincan-lighthouse) (entity entity-actor))
  "Given an [[entity-actor]], create the [[mincan-lighthouse-lens]]"
  (set! (-> self root) (new 'process 'trsqv))
  (process-drawable-from-entity! self entity)
  (initialize-skeleton
    self
    (the-as
      skeleton-group
      (art-group-get-by-name *level* "skel-mincan-lighthouse-lens" (the-as (pointer uint32) #f))
      )
    (the-as pair 0)
    )
  (go-virtual idle)
  (none)
  )

(deftype mincan-lighthouse (process-drawable)
  ()
  (:state-methods
    idle
    erect
    )
  )


(defskelgroup skel-mincan-lighthouse mincan-lighthouse mincan-lighthouse-lod0-jg mincan-lighthouse-idle-ja
              ((mincan-lighthouse-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 -20 0 62.5)
              :origin-joint-index 6
              )

(defstate idle (mincan-lighthouse)
  :virtual #t
  :trans (behavior ()
    (if (task-node-closed? (game-task-node canyon-insert-items-resolution))
        (go-virtual erect)
        )
    )
  :code (behavior ()
    (ja-channel-push! 1 0)
    (until #f
      (ja-no-eval :group! mincan-lighthouse-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post ja-post
  )

(defstate erect (mincan-lighthouse)
  :virtual #t
  :code (behavior ()
    (ja-channel-push! 1 0)
    (until #f
      (ja-no-eval :group! mincan-lighthouse-idle-erect-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post ja-post
  )

;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! ((this mincan-lighthouse) (arg0 entity-actor))
  "Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
This commonly includes things such as:
- stack size
- collision information
- loading the skeleton group / bones
- sounds"
  (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-mincan-lighthouse" (the-as (pointer uint32) #f)))
    (the-as pair 0)
    )
  (process-spawn mincan-lighthouse-lens this arg0 :to this)
  (go (method-of-object this idle))
  (none)
  )

(deftype mincan-lens (process-drawable)
  ()
  (:state-methods
    closed
    open
    )
  )


(defskelgroup skel-mincan-lens mincan-lens mincan-lens-lod0-jg mincan-lens-idle-ja
              ((mincan-lens-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 5 0 15)
              :origin-joint-index 3
              )

(defstate closed (mincan-lens)
  :virtual #t
  :trans (behavior ()
    (if (task-node-closed? (game-task-node canyon-insert-items-resolution))
        (go-virtual open)
        )
    )
  :code (behavior ()
    (ja-channel-push! 1 0)
    (until #f
      (ja-no-eval :group! mincan-lens-idle-closed-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post transform-post
  )

(defstate open (mincan-lens)
  :virtual #t
  :code (behavior ()
    (ja-channel-push! 1 0)
    (until #f
      (ja-no-eval :group! mincan-lens-idle-ja :num! (seek!) :frame-num 0.0)
      (until (ja-done? 0)
        (suspend)
        (ja :num! (seek!))
        )
      )
    #f
    )
  :post transform-post
  )

;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! ((this mincan-lens) (arg0 entity-actor))
  "Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
This commonly includes things such as:
- stack size
- collision information
- loading the skeleton group / bones
- sounds"
  (let ((cshape (new 'process 'collide-shape this (collide-list-enum hit-by-player))))
    (let ((prim-group (new 'process 'collide-shape-prim-group cshape (the-as uint 7) 0)))
      (set! (-> cshape total-prims) (the-as uint 8))
      (set! (-> prim-group prim-core collide-as) (collide-spec obstacle))
      (set! (-> prim-group prim-core collide-with) (collide-spec jak player-list))
      (set! (-> prim-group prim-core action) (collide-action solid))
      (set-vector! (-> prim-group local-sphere) 0.0 0.0 0.0 81920.0)
      (set! (-> cshape root-prim) prim-group)
      )
    (let ((mesh-1 (new 'process 'collide-shape-prim-mesh cshape (the-as uint 6) (the-as uint 0))))
      (set! (-> mesh-1 prim-core collide-as) (collide-spec obstacle))
      (set! (-> mesh-1 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> mesh-1 prim-core action) (collide-action solid))
      (set! (-> mesh-1 transform-index) 3)
      (set-vector! (-> mesh-1 local-sphere) 0.0 0.0 0.0 20480.0)
      )
    (let ((mesh-2 (new 'process 'collide-shape-prim-mesh cshape (the-as uint 4) (the-as uint 0))))
      (set! (-> mesh-2 prim-core collide-as) (collide-spec obstacle))
      (set! (-> mesh-2 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> mesh-2 prim-core action) (collide-action solid))
      (set! (-> mesh-2 transform-index) 3)
      (set-vector! (-> mesh-2 local-sphere) 0.0 0.0 32768.0 8192.0)
      )
    (let ((mesh-3 (new 'process 'collide-shape-prim-mesh cshape (the-as uint 5) (the-as uint 0))))
      (set! (-> mesh-3 prim-core collide-as) (collide-spec obstacle))
      (set! (-> mesh-3 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> mesh-3 prim-core action) (collide-action solid))
      (set! (-> mesh-3 transform-index) 3)
      (set-vector! (-> mesh-3 local-sphere) 0.0 32768.0 0.0 28672.0)
      )
    (let ((mesh-4 (new 'process 'collide-shape-prim-mesh cshape (the-as uint 0) (the-as uint 0))))
      (set! (-> mesh-4 prim-core collide-as) (collide-spec obstacle))
      (set! (-> mesh-4 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> mesh-4 prim-core action) (collide-action solid))
      (set! (-> mesh-4 transform-index) 4)
      (set-vector! (-> mesh-4 local-sphere) 0.0 12288.0 -36864.0 28672.0)
      )
    (let ((mesh-5 (new 'process 'collide-shape-prim-mesh cshape (the-as uint 1) (the-as uint 0))))
      (set! (-> mesh-5 prim-core collide-as) (collide-spec obstacle))
      (set! (-> mesh-5 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> mesh-5 prim-core action) (collide-action solid))
      (set! (-> mesh-5 transform-index) 7)
      (set-vector! (-> mesh-5 local-sphere) 0.0 12288.0 -36864.0 28672.0)
      )
    (let ((mesh-6 (new 'process 'collide-shape-prim-mesh cshape (the-as uint 2) (the-as uint 0))))
      (set! (-> mesh-6 prim-core collide-as) (collide-spec obstacle))
      (set! (-> mesh-6 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> mesh-6 prim-core action) (collide-action solid))
      (set! (-> mesh-6 transform-index) 10)
      (set-vector! (-> mesh-6 local-sphere) 0.0 12288.0 -36864.0 28672.0)
      )
    (let ((mesh-7 (new 'process 'collide-shape-prim-mesh cshape (the-as uint 3) (the-as uint 0))))
      (set! (-> mesh-7 prim-core collide-as) (collide-spec obstacle))
      (set! (-> mesh-7 prim-core collide-with) (collide-spec jak player-list))
      (set! (-> mesh-7 prim-core action) (collide-action solid))
      (set! (-> mesh-7 transform-index) 13)
      (set-vector! (-> mesh-7 local-sphere) 0.0 12288.0 -36864.0 28672.0)
      )
    (set! (-> cshape nav-radius) (* 0.75 (-> cshape root-prim local-sphere w)))
    (let ((root-prim (-> cshape root-prim)))
      (set! (-> cshape backup-collide-as) (-> root-prim prim-core collide-as))
      (set! (-> cshape backup-collide-with) (-> root-prim prim-core collide-with))
      )
    (set! (-> this root) cshape)
    )
  (process-drawable-from-entity! this arg0)
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-mincan-lens" (the-as (pointer uint32) #f)))
    (the-as pair 0)
    )
  (go (method-of-object this closed))
  (none)
  )

(deftype mincan-cogs (process-drawable)
  ()
  (:state-methods
    idle
    )
  )


(defskelgroup skel-mincan-cogs mincan-cogs mincan-cogs-lod0-jg mincan-cogs-idle-ja
              ((mincan-cogs-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 70)
              :origin-joint-index 3
              )

(defstate idle (mincan-cogs)
  :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
  )

;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! ((this mincan-cogs) (arg0 entity-actor))
  "Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
This commonly includes things such as:
- stack size
- collision information
- loading the skeleton group / bones
- sounds"
  (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-mincan-cogs" (the-as (pointer uint32) #f)))
    (the-as pair 0)
    )
  (go (method-of-object this idle))
  (none)
  )
