1 ;;; Copyright 2009 Christoph Senjak
3 (in-package :uxul-world)
5 (defun i-wanna-listen-to (object room &rest args)
6 "Brings all the Objects of the given classes in <args> into the
7 listen-to-array of object. Any previous value will be deleted."
9 (setf (listen-to object)
12 (get-objects room arg)))))
14 (defun must-be-listened-by (object room &rest args)
15 "Adds itself to the listen-to-array of all the objects of the given
18 (dolist (obj (get-objects room arg))
19 (push object (listen-to obj)))))
21 (defgeneric add-object (obj place)
22 (:documentation "Add an object to a place, i.e. a room or sth."))
24 (defmethod add-object ((obj t) (place t))
25 "Just Warn - this shouldnt happen!"
27 "add-object was called with arguments it wasnt defined
29 (class-name (class-of obj))
30 (class-name (class-of obj))))
32 (defmethod add-object ((object t) (room room))
33 (add-object-of-class object (object-array room)))
35 (defmethod add-object ((obj stone) (place room))
36 "Add a stone to a room and all the objects it can collide with"
37 (must-be-listened-by obj place 'player 'moving-enemy 'moving-item)
40 (defmethod add-object ((obj moving-enemy) (place room))
41 (i-wanna-listen-to obj place 'player 'stone)
42 (must-be-listened-by obj place 'player)
45 (defmethod add-object ((obj standing-enemy) (place room))
46 (must-be-listened-by obj place 'player)
49 (defmethod add-object ((obj moving-item) (place room))
50 (must-be-listened-by obj place 'player)
51 (i-wanna-listen-to obj place 'player 'stone)
54 (defmethod add-object ((obj standing-item) (place room))
55 (must-be-listened-by obj place 'player)
58 (defmethod add-object ((obj player) (place room))
59 (setf (key-listener place) obj)
60 (setf (graphic-centralizer place) obj)
61 (must-be-listened-by obj place 'moving-enemy 'moving-item)
62 (i-wanna-listen-to obj place 'moving-enemy 'moving-item 'standing-enemy
63 'standing-item 'stone 'bottom)