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

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

(define-extern find-water-with-spheres (function (inline-array water-sphere) int water-info object))

;; DECOMP BEGINS

(deftype water-control (basic)
  ((flags              water-flag)
   (process            target)
   (joint-index        int32)
   (top-y-offset       float)
   (attack-id          uint32)
   (enter-water-time   time-frame)
   (wade-time          time-frame)
   (on-water-time      time-frame)
   (enter-swim-time    time-frame)
   (swim-time          time-frame)
   (base-height        meters)
   (wade-height        meters)
   (swim-height        meters)
   (surface-height     meters)
   (bottom-height      meters)
   (collide-height     meters)
   (height             meters)
   (height-offset      float          4)
   (base-ocean-offset  meters         :overlay-at (-> height-offset 0))
   (real-ocean-offset  meters         :overlay-at (-> height-offset 0))
   (ocean-offset       meters         :overlay-at (-> height-offset 1))
   (bob-offset         meters         :overlay-at (-> height-offset 2))
   (align-offset       meters         :overlay-at (-> height-offset 3))
   (swim-depth         meters         :offset 108)
   (bob                smush-control  :inline)
   (ripple             handle)
   (ripple-size        meters)
   (wake-size          meters)
   (bottom             vector         2 :inline)
   (top                vector         2 :inline)
   (enter-water-pos    vector         :inline)
   (drip-old-pos       vector         :inline)
   (drip-joint-index   int32)
   (drip-wetness       float)
   (drip-time          time-frame)
   (drip-speed         float)
   (drip-height        meters)
   (drip-mult          float)
   (distort-time       time-frame)
   (enter-water-sound  sound-name)
   (normal             vector         :inline)
   )
  (:methods
    (new (symbol type process int float float float) _type_)
    (water-control-method-9 (_type_) none)
    (water-control-method-10 (_type_) none)
    (start-bobbing! (_type_ float int int) none)
    (distance-from-surface (_type_) float)
    (spawn-ripples (_type_ float vector int vector symbol) none)
    (display-water-marks? (_type_) symbol)
    (enter-water (_type_) none)
    (water-control-method-16 (_type_) none)
    (water-control-method-17 (_type_) none)
    )
  )


(defmethod display-water-marks? ((this water-control))
  *display-water-marks*
  )

(defmethod new water-control ((allocation symbol) (type-to-make type) (arg0 process) (arg1 int) (arg2 float) (arg3 float) (arg4 float))
  (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
    (set! (-> v0-0 process) (the-as target arg0))
    (set! (-> v0-0 joint-index) arg1)
    (set! (-> v0-0 wade-height) arg4)
    (set! (-> v0-0 swim-height) arg3)
    (set! (-> v0-0 bottom-height) 32768.0)
    (set! (-> v0-0 ripple-size) 1638.4)
    (set! (-> v0-0 wake-size) 3072.0)
    (set! (-> v0-0 ripple) (the-as handle #f))
    (set! (-> v0-0 drip-mult) 1.0)
    (set! (-> v0-0 top-y-offset) arg2)
    (let* ((v1-6 *game-info*)
           (a0-2 (+ (-> v1-6 attack-id) 1))
           )
      (set! (-> v1-6 attack-id) a0-2)
      (set! (-> v0-0 attack-id) a0-2)
      )
    (set! (-> v0-0 enter-water-sound) (static-sound-name "swim-enter"))
    v0-0
    )
  )

(defmethod distance-from-surface ((this water-control))
  (- (-> this top 0 y) (-> this height))
  )

(deftype water-vol (process-hidden)
  ()
  )
