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

;; name: projectile-h.gc
;; name in dgo: projectile-h
;; dgos: GAME

;; +++projectile-options
(defenum projectile-options
  :bitfield #t
  :type uint64
  (po0 0)
  (po1 1)
  (po2 2)
  (po3 3)
  (po4 4)
  (po5 5)
  (po6 6)
  (po7 7)
  (po8 8)
  (po9 9)
  (po10 10)
  (po11 11)
  (po12 12)
  (po13 13)
  (po14 14)
  (po15 15)
  (po16 16)
  (po17 17)
  (po18 18)
  (po19 19)
  (po20 20)
  (po21 21)
  (po22 22)
  (po23 23)
  (po24 24)
  (po25 25)
  (po26 26)
  (po27 27)
  (po28 28)
  (po29 29)
  (po30 30)
  (po31 31)
  )
;; ---projectile-options


(declare-type projectile process)
(declare-type projectile-init-by-other-params structure)
(define-extern projectile-init-by-other (function projectile-init-by-other-params object :behavior projectile))

;; DECOMP BEGINS

(deftype projectile (process-drawable)
  ((parent                  (pointer process-drawable) :override)
   (root                    collide-shape-moving       :override)
   (starting-pos            vector                      :inline)
   (starting-dir            vector                      :inline)
   (target-pos              vector                      :inline)
   (base-target-pos         vector                      :inline)
   (pre-move-transv         vector                      :inline)
   (timeout                 time-frame)
   (spawn-time              time-frame)
   (options                 projectile-options)
   (last-target             handle)
   (notify-handle           handle)
   (owner-handle            handle)
   (ignore-handle           handle)
   (update-velocity         (function projectile none))
   (move                    (function projectile none))
   (pick-target             (function projectile none))
   (max-speed               float)
   (old-dist                float                       16)
   (old-dist-count          int32)
   (hits                    int32)
   (max-hits                int32)
   (tween                   float)
   (attack-mode             symbol)
   (attack-id               uint32)
   (damage                  float)
   (vehicle-damage-factor   float)
   (vehicle-impulse-factor  float)
   (charge-level            float)
   (sound-id                sound-id)
   (stop-speed              meters)
   (invinc-time             time-frame)
   (desired-target          handle)
   (desired-target-pos      vector                      :inline)
   )
  (:state-methods
    die
    dissipate
    impact
    moving
    )
  (:methods
    (projectile-method-24 (_type_) none)
    (projectile-method-25 (_type_) none)
    (projectile-method-26 (_type_) none)
    (projectile-method-27 (_type_) none)
    (play-impact-sound (_type_ projectile-options) none)
    (projectile-method-29 (_type_) none)
    (setup-collision! (_type_) none)
    (init-proj-settings! (_type_) none)
    (projectile-method-32 (_type_) none)
    (go-impact! (_type_) none)
    (projectile-method-34 (_type_) none)
    (proj-event-handler (_type_ process int symbol event-message-block) object)
    (handle-proj-hit! (_type_ process event-message-block) object)
    (deal-damage! (_type_ process event-message-block) symbol)
    (made-impact? (_type_) symbol)
    (projectile-method-39 (_type_) none)
    (projectile-method-40 (_type_) int)
    )
  )


(deftype projectile-init-by-other-params (structure)
  ((pos                     vector  :inline)
   (vel                     vector  :inline)
   (target-pos              vector  :inline)
   (target-handle           handle)
   (ent                     entity)
   (charge                  float)
   (attack-id               uint32)
   (options                 projectile-options)
   (notify-handle           handle)
   (owner-handle            handle)
   (ignore-handle           handle)
   (timeout                 time-frame)
   (damage                  float)
   (vehicle-damage-factor   float)
   (vehicle-impulse-factor  float)
   )
  )


(defun spawn-projectile ((proj-type type) (params projectile-init-by-other-params) (parent-proc-tree process-tree) (pool dead-pool))
  "Create a new process for a projectile of the given type."
  (process-spawn proj-type :runtime #t :name "projectile" :from pool :to parent-proc-tree :init projectile-init-by-other params)
  )

(deftype projectile-bounce (projectile)
  ((played-bounce-time  time-frame)
   (tumble-quat         quaternion  :inline)
   (gravity             float)
   )
  (:state-methods
    sitting
    )
  (:methods
    (projectile-bounce-method-42 (_type_) none)
    (projectile-bounce-method-43 (_type_) none)
    )
  )
