`(hide-mob-hash (,mob 'get-mob-id)))))
(define (run-mobs mobs)
+ (clear-mob-data)
(for-each
(lambda (m)
(glPushMatrix)
((get-type)
,type-symbol)
(else
- (display ,(cons 'list (map (lambda (x) `(acons ',(car x) ,(car x) '())) publish)))
- (newline)
(catch #t
(lambda () ,@body)
- (lambda (key . args) #f))))))))
+ (lambda (key . args) #f))
+ (cond ((not (null? ',publish))
+ (display ,(cons 'list (map (lambda (x) `(cons ',(car x) ,(car x))) publish)))
+ (publish-mob-data ,mob-id-symbol ,type-symbol ,(cons 'list (map (lambda (x) `(cons ',(car x) ,(car x))) publish)))))
+ (newline)))))))
(define-macro (lambda-mob attr . body)
`(the-mob 'undefined ,attr '() ,@body))
+
+
+;;; Events Engine
+
+(define publish-mob-data #f)
+(define clear-mob-data #f)
+(define def-mobs-event #f)
+
+(define published-data (make-hash-table))
+(define mobs-events (make-hash-table))
+
+(let ((nop #f))
+ (set! publish-mob-data
+ (lambda (mob-id mob-type data)
+ (let ((t (hash-ref published-data mob-type))
+ (i (cons mob-id data)))
+ (hash-set! published-data mob-type
+ (cond (t (cons i t))
+ (else (list i)))))))
+
+ (set! clear-mob-data
+ (lambda ()
+ (hash-clear! published-data)))
+
+ (set! def-mobs-event
+ (lambda (type1 type2 fun)
+ #f))
+)
+
+(define-macro (define-mobs-event type1 type2 . body)
+ `(def-mobs-event
+ ,type1
+ ,type2
+ ,(cond ((null? body) #f)
+ (else `(lambda () ,@body)))))