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

;; name: stadium-race-obs.gc
;; name in dgo: stadium-race-obs
;; dgos: STD, STC, STB

;; DECOMP BEGINS

(deftype stdmb-race-hatch (process-drawable)
  ((tt         float)
   (tt-target  float)
   )
  (:state-methods
    idle
    )
  (:methods
    (stdmb-race-hatch-method-21 (_type_) none)
    (stdmb-race-hatch-method-22 (_type_) none)
    )
  )


(defskelgroup skel-stdmb-race-hatch stdmb-race-hatch stdmb-race-hatch-lod0-jg -1
              ((stdmb-race-hatch-lod0-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 12.5)
              )

(defstate idle (stdmb-race-hatch)
  :virtual #t
  :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
    (case message
      (('open)
       (set! (-> self tt-target) 1.0)
       )
      (('close)
       (set! (-> self tt-target) 0.0)
       )
      )
    )
  :code sleep-code
  :post (behavior ()
    (cond
      ((!= (-> self tt) (-> self tt-target))
       (seek! (-> self tt) (-> self tt-target) (seconds-per-frame))
       (ja :num-func num-func-identity :frame-num (ja-aframe (-> self tt) 0))
       (transform-post)
       )
      (else
        (ja-post)
        )
      )
    )
  )

(defmethod stdmb-race-hatch-method-21 ((this stdmb-race-hatch))
  (let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum usually-hit-by-player))))
    (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
    (set! (-> s5-0 reaction) cshape-reaction-default)
    (set! (-> s5-0 no-reaction)
          (the-as (function collide-shape-moving collide-query vector vector object) nothing)
          )
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
      (set! (-> s5-0 total-prims) (the-as uint 3))
      (set! (-> s4-0 prim-core collide-as) (collide-spec camera-blocker pusher))
      (set! (-> s4-0 prim-core collide-with) (collide-spec jak bot player-list))
      (set! (-> s4-0 prim-core action) (collide-action solid rideable))
      (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 51200.0)
      (set! (-> s5-0 root-prim) s4-0)
      )
    (pusher-init s5-0)
    (let ((v1-14 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0))))
      (set! (-> v1-14 prim-core collide-as) (collide-spec camera-blocker pusher))
      (set! (-> v1-14 prim-core collide-with) (collide-spec jak bot player-list))
      (set! (-> v1-14 prim-core action) (collide-action solid rideable))
      (set! (-> v1-14 transform-index) 4)
      (set-vector! (-> v1-14 local-sphere) 0.0 0.0 0.0 51200.0)
      )
    (let ((v1-16 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 1) (the-as uint 0))))
      (set! (-> v1-16 prim-core collide-as) (collide-spec camera-blocker pusher))
      (set! (-> v1-16 prim-core collide-with) (collide-spec jak bot player-list))
      (set! (-> v1-16 prim-core action) (collide-action solid rideable))
      (set! (-> v1-16 transform-index) 5)
      (set-vector! (-> v1-16 local-sphere) 0.0 0.0 0.0 51200.0)
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (let ((v1-19 (-> s5-0 root-prim)))
      (set! (-> s5-0 backup-collide-as) (-> v1-19 prim-core collide-as))
      (set! (-> s5-0 backup-collide-with) (-> v1-19 prim-core collide-with))
      )
    (set! (-> this root) s5-0)
    )
  0
  (none)
  )

(defmethod stdmb-race-hatch-method-22 ((this stdmb-race-hatch))
  (initialize-skeleton
    this
    (the-as skeleton-group (art-group-get-by-name *level* "skel-stdmb-race-hatch" (the-as (pointer uint32) #f)))
    (the-as pair 0)
    )
  (set! (-> this draw shadow-mask) (the-as uint 30))
  (set! (-> this draw shadow-values) (the-as uint #x22220))
  (set! (-> this tt) 0.0)
  (set! (-> this tt-target) 0.0)
  (ja-channel-push! 1 0)
  (let ((v1-7 (-> this skel root-channel 0)))
    (set! (-> v1-7 frame-group) (the-as art-joint-anim (-> this draw art-group data 3)))
    )
  (transform-post)
  (go (method-of-object this idle))
  0
  (none)
  )

(defmethod init-from-entity! ((this stdmb-race-hatch) (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"
  (stdmb-race-hatch-method-21 this)
  (process-drawable-from-entity! this arg0)
  (stdmb-race-hatch-method-22 this)
  (none)
  )

(defbehavior stdmb-race-hatch-init-by-other stdmb-race-hatch ((arg0 vector) (arg1 quaternion))
  (stdmb-race-hatch-method-21 self)
  (set! (-> self root trans quad) (-> arg0 quad))
  (quaternion-copy! (-> self root quat) arg1)
  (stdmb-race-hatch-method-22 self)
  (none)
  )

(deftype stdmb-platform (stdmb-race-hatch)
  ()
  )
