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

(import "goal_src/jak1/import/shover-ag.gc")

;; definition of type shover
(deftype shover (process-drawable)
  ((root-override collide-shape  :offset        112)
   (shove-up      float          :offset-assert 176)
   )
  :heap-base #x50
  :method-count-assert 20
  :size-assert         #xb4
  :flag-assert         #x14005000b4
  (:states
    shover-idle
    )
  )

;; definition for method 3 of type shover
(defmethod inspect shover ((obj shover))
  (let ((t9-0 (method-of-type process-drawable inspect)))
    (t9-0 obj)
    )
  (format #t "~T~Tshove-up: ~f~%" (-> obj shove-up))
  obj
  )

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

;; failed to figure out what this is:
(defstate shover-idle (shover)
  :event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
    (case arg2
      (('touch 'attack)
       (when (= (-> arg0 type) target)
         (when ((method-of-type touching-shapes-entry prims-touching-action?)
                (the-as touching-shapes-entry (-> arg3 param 0))
                (-> *target* control)
                (collide-action solid)
                (collide-action)
                )
           (let ((s4-0 (new 'stack 'attack-info)))
             (dummy-41 (-> self root-override) s4-0 (-> self shove-up))
             (level-hint-spawn (game-text-id sunken-hotpipes) "sksp0134" (the-as entity #f) *entity-pool* (game-task none))
             (if (or (= (-> *target* control unknown-surface00 mode) 'air)
                     (>= (+ (-> *display* base-frame-counter) (seconds -0.2)) (-> *target* control unknown-dword11))
                     (< 0.75 (-> *target* control poly-normal y))
                     )
                 (send-event
                   arg0
                   'attack-or-shove
                   (-> arg3 param 0)
                   (static-attack-info ((mode 'burn) (vector (-> s4-0 vector)) (shove-up (-> s4-0 shove-up))))
                   )
                 (send-event
                   arg0
                   'attack-or-shove
                   (-> arg3 param 0)
                   (static-attack-info ((mode 'burn)
                                        (shove-up (meters 0))
                                        (shove-back (meters 2))
                                        (vector (-> *target* control poly-normal))
                                        (angle 'shove)
                                        )
                                       )
                   )
                 )
             )
           )
         )
       )
      )
    )
  :code (the-as (function none :behavior shover) anim-loop)
  )

;; definition for method 11 of type shover
;; INFO: Used lq/sq
;; INFO: Return type mismatch object vs none.
(defmethod init-from-entity! shover ((obj shover) (arg0 entity-actor))
  (local-vars (sv-16 res-tag))
  (set! (-> obj shove-up) (res-lump-float arg0 'shove :default 12288.0))
  (let ((s3-0 (res-lump-value arg0 'collision-mesh-id uint128))
        (s4-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-player)))
        )
    (let ((s3-1 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint s3-0) (the-as uint 0))))
      (set! (-> s3-1 prim-core collide-as) (collide-kind wall-object))
      (set! (-> s3-1 collide-with) (collide-kind target))
      (set! (-> s3-1 prim-core action) (collide-action solid))
      (set! (-> s3-1 prim-core offense) (collide-offense indestructible))
      (set! (-> s3-1 transform-index) 0)
      (set-vector! (-> s3-1 local-sphere) 0.0 0.0 0.0 53248.0)
      (set-root-prim! s4-0 s3-1)
      )
    (set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
    (backup-collide-with-as s4-0)
    (set! (-> obj root-override) s4-0)
    )
  (process-drawable-from-entity! obj arg0)
  (initialize-skeleton obj *shover-sg* '())
  (let ((v1-17 (new 'process 'path-control obj 'path 0.0)))
    (set! (-> obj path) v1-17)
    (logior! (-> v1-17 flags) (path-control-flag display draw-line draw-point draw-text))
    (if (<= (-> v1-17 curve num-cverts) 0)
        (go process-drawable-art-error "no path")
        )
    )
  (set! sv-16 (new 'static 'res-tag))
  (let ((v1-23 (res-lump-data arg0 'trans-offset (pointer float) :tag-ptr (& sv-16))))
    (when v1-23
      (+! (-> obj root-override trans x) (-> v1-23 0))
      (+! (-> obj root-override trans y) (-> v1-23 1))
      (+! (-> obj root-override trans z) (-> v1-23 2))
      )
    )
  (let ((f0-13 (res-lump-float arg0 'rotoffset)))
    (if (!= f0-13 0.0)
        (quaternion-rotate-y! (-> obj root-override quat) (-> obj root-override quat) f0-13)
        )
    )
  (ja-channel-set! 1)
  (let ((s5-1 (-> obj skel root-channel 0)))
    (joint-control-channel-group-eval!
      s5-1
      (the-as art-joint-anim (-> obj draw art-group data 2))
      num-func-identity
      )
    (set! (-> s5-1 frame-num) 0.0)
    )
  (ja-post)
  (update-transforms! (-> obj root-override))
  (set! *shover* obj)
  (go shover-idle)
  (none)
  )
