(in-package goal) (define *los-time-offset* (the-as time-frame 0)) (defmethod los-control-method-9 los-control ((obj los-control) (process process-focusable) (trans-vec vector) (radius float)) (when (and (>= (- (-> self clock frame-counter) (-> obj last-check-time)) (-> obj check-interval)) (-> obj src-proc) (or process (-> obj dst-proc)) ) (let* ((process-source (handle->process (-> obj src-proc))) (process-focus (if (type? process-source process-focusable) (the-as process-focusable process-source) ) ) ) (when process-focus (when (not process) (let ((process-dest (handle->process (-> obj dst-proc)))) (set! process (if (type? process-dest process-focusable) (the-as process-focusable process-dest) ) ) ) ) (when process (let ((start-pos (new 'stack-no-clear 'vector))) (set! (-> start-pos quad) (-> (get-trans process-focus 3) quad)) (if (not trans-vec) (set! trans-vec (get-trans process 3)) ) (let ((distance (vector-! (new 'stack-no-clear 'vector) trans-vec start-pos)) (cquery (new 'stack-no-clear 'collide-query)) ) (set! (-> cquery start-pos quad) (-> start-pos quad)) (set! (-> cquery move-dist quad) (-> distance quad)) (let ((query cquery)) (set! (-> query radius) radius) (set! (-> query collide-with) (-> obj collide-with)) (set! (-> query ignore-process0) process-focus) (set! (-> query ignore-process1) process) (set! (-> query ignore-pat) (-> process-focus root-override pat-ignore-mask)) (set! (-> query action-mask) (collide-action solid)) ) (fill-using-line-sphere *collide-cache* cquery) (let ((f30-0 (probe-using-line-sphere *collide-cache* cquery))) (quad-copy! (the-as pointer (-> obj last-collide-result)) (the-as pointer (-> cquery best-other-tri)) 6) (if (>= 0.0 f30-0) (set! (-> obj have-no-los) (-> self clock frame-counter)) (set! (-> obj have-los) (-> self clock frame-counter)) ) ) ) ) (set! (-> obj last-check-time) (-> self clock frame-counter)) ) ) ) ) (none) ) (defmethod check-los? los-control ((obj los-control) (arg0 time-frame)) (and (>= (- (-> self clock frame-counter) (-> obj have-los)) (+ (-> obj check-interval) arg0)) (< (- (-> self clock frame-counter) (-> obj have-no-los)) (-> obj check-interval)) ) ) (defmethod skip-check-los? los-control ((obj los-control) (arg0 int)) (and (>= (- (-> self clock frame-counter) (-> obj have-no-los)) (+ (-> obj check-interval) arg0)) (< (- (-> self clock frame-counter) (-> obj have-los)) (-> obj check-interval)) ) ) (defmethod set-dst-proc! los-control ((obj los-control) (dst handle)) (set! (-> obj dst-proc) dst) 0 (none) ) (defmethod new-source! los-control ((obj los-control) (proc process) (check-interval time-frame) (c-spec collide-spec)) (set! (-> obj src-proc) (process->handle proc)) (set! (-> obj dst-proc) (the-as handle #f)) (set! (-> obj have-los) 0) (set! (-> obj have-no-los) 0) (set! (-> obj last-check-time) *los-time-offset*) (set! (-> obj check-interval) check-interval) (set! (-> obj collide-with) c-spec) (set! *los-time-offset* (+ *los-time-offset* 1)) 0 (none) )