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

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

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

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

;; failed to figure out what this is:
(defskelgroup *farmer-sg* farmer farmer-lod0-jg farmer-sitting-cycle-ja
              ((farmer-lod0-mg (meters 20)) (farmer-lod1-mg (meters 999999)))
              :bounds (static-spherem 0 0 0 4)
              :shadow farmer-shadow-mg
              )

;; definition for method 32 of type farmer
(defmethod play-anim! farmer ((obj farmer) (arg0 symbol))
  (case (current-status (-> obj tasks))
    (((task-status need-hint) (task-status need-introduction))
     (if arg0
         (close-status! (-> obj tasks) (task-status need-introduction))
         )
     (new 'static 'spool-anim :name "farmer-introduction" :index 6 :parts 5 :command-list '())
     )
    (((task-status need-reminder))
     (set! (-> obj skippable) #t)
     (cond
       ((zero? (get-reminder (-> obj tasks) 0))
        (if arg0
            (save-reminder (-> obj tasks) 1 0)
            )
        (new 'static 'spool-anim :name "farmer-reminder-1" :index 7 :parts 2 :command-list '())
        )
       (else
         (if arg0
             (save-reminder (-> obj tasks) 0 0)
             )
         (new 'static 'spool-anim :name "farmer-reminder-2" :index 8 :parts 2 :command-list '())
         )
       )
     )
    (((task-status need-reward-speech))
     (when arg0
       (set! (-> obj cell-for-task) (current-task (-> obj tasks)))
       (close-current! (-> obj tasks))
       )
     (new 'static 'spool-anim :name "farmer-resolution" :index 9 :parts 4 :command-list '())
     )
    (else
      (if arg0
          (format
            0
            "ERROR: <GMJ>: ~S playing anim for task status ~S~%"
            (-> obj name)
            (task-status->string (current-status (-> obj tasks)))
            )
          )
      (-> obj draw art-group data 4)
      )
    )
  )

;; definition for method 31 of type farmer
(defmethod get-art-elem farmer ((obj farmer))
  (case (current-status (-> obj tasks))
    (((task-status need-hint) (task-status need-introduction) (task-status need-resolution) (task-status invalid))
     (-> obj draw art-group data 4)
     )
    (else
      (-> obj draw art-group data 5)
      )
    )
  )

;; definition for method 43 of type farmer
(defmethod TODO-RENAME-43 farmer ((obj farmer))
  (when (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) (seconds 30) 122880.0 obj)
    (let ((f0-2 (rand-float-gen)))
      (cond
        ((< 0.8333333 f0-2)
         (play-ambient (-> obj ambient) "FAR-LO1A" #f (-> obj root-override trans))
         )
        ((< 0.6666667 f0-2)
         (play-ambient (-> obj ambient) "FAR-AM01" #f (-> obj root-override trans))
         )
        ((< 0.5 f0-2)
         #f
         )
        ((< 0.33333334 f0-2)
         (play-ambient (-> obj ambient) "FAR-AM2A" #f (-> obj root-override trans))
         )
        ((< 0.16666667 f0-2)
         (play-ambient (-> obj ambient) "FAR-AM02" #f (-> obj root-override trans))
         )
        (else
          #f
          )
        )
      )
    )
  )

;; definition for method 41 of type farmer
;; INFO: Return type mismatch int vs none.
(defmethod initialize-collision farmer ((obj farmer) (arg0 int) (arg1 vector))
  (let ((s5-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-player))))
    (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
      (set! (-> s4-0 prim-core collide-as) (collide-kind enemy))
      (set! (-> s4-0 collide-with) (collide-kind target))
      (set! (-> s4-0 prim-core action) (collide-action solid))
      (set! (-> s4-0 prim-core offense) (collide-offense indestructible))
      (set-vector! (-> s4-0 local-sphere) 4096.0 8192.0 -4096.0 12288.0)
      (set-root-prim! s5-0 s4-0)
      (let ((s3-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
        (set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
        (set! (-> s3-0 collide-with) (collide-kind target))
        (set! (-> s3-0 prim-core action) (collide-action solid))
        (set! (-> s3-0 prim-core offense) (collide-offense indestructible))
        (set-vector! (-> s3-0 local-sphere) 4096.0 6144.0 -4096.0 8192.0)
        (append-prim s4-0 s3-0)
        )
      (let ((s3-1 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
        (set! (-> s3-1 prim-core collide-as) (collide-kind enemy))
        (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-vector! (-> s3-1 local-sphere) 4096.0 10240.0 -4096.0 8192.0)
        (append-prim s4-0 s3-1)
        )
      )
    (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
    (backup-collide-with-as s5-0)
    (set! (-> obj root-override) s5-0)
    )
  0
  (none)
  )

;; definition for method 11 of type farmer
(defmethod init-from-entity! farmer ((obj farmer) (arg0 entity-actor))
  (dummy-40 obj arg0 *farmer-sg* 3 25 (new 'static 'vector :w 4096.0) 5)
  (set! (-> obj root-override nav-radius) 40960.0)
  (nav-mesh-connect obj (-> obj root-override) (the-as nav-control #f))
  (set! (-> obj tasks) (get-task-control (game-task village1-yakow)))
  (dummy-42 obj)
  (none)
  )
