Mercurial > parpg-source
comparison gamestate.py @ 74:c9818290bbe7
Objects that are not on an actual map are now stored under the value None in the gamestates object dictionary.
author | KarstenBock@gmx.net |
---|---|
date | Thu, 22 Sep 2011 14:39:00 +0200 |
parents | 5c751b9a3d8b |
children | 9e03f7816061 |
comparison
equal
deleted
inserted
replaced
73:5c751b9a3d8b | 74:c9818290bbe7 |
---|---|
38 @type map_id: str or None | 38 @type map_id: str or None |
39 @param object: object to be added | 39 @param object: object to be added |
40 @type object: GameObject | 40 @type object: GameObject |
41 """ | 41 """ |
42 if not self.object_ids.has_key(object_id): | 42 if not self.object_ids.has_key(object_id): |
43 if map_id: | 43 self.objects[map_id][object_id] = game_object |
44 self.objects[map_id][object_id] = game_object | |
45 self.object_ids[object_id] = map_id | 44 self.object_ids[object_id] = map_id |
46 | 45 |
47 def deleteObject(self, object_id): | 46 def deleteObject(self, object_id): |
48 """Removes an object from the dictionaries | 47 """Removes an object from the dictionaries |
49 @param object_id: ID of the object | 48 @param object_id: ID of the object |
52 if self.hasObject(object_id): | 51 if self.hasObject(object_id): |
53 map_id = self.getMapOfObject(object_id) | 52 map_id = self.getMapOfObject(object_id) |
54 if map_id: | 53 if map_id: |
55 inst = self.maps[map_id].agent_layer.getInstance(object_id) | 54 inst = self.maps[map_id].agent_layer.getInstance(object_id) |
56 self.maps[map_id].agent_layer.deleteInstance(inst) | 55 self.maps[map_id].agent_layer.deleteInstance(inst) |
57 del self.objects[map_id][object_id] | 56 del self.objects[map_id][object_id] |
58 del self.object_ids[object_id] | 57 del self.object_ids[object_id] |
59 | 58 |
60 | 59 |
61 def getObjectsFromMap(self, map_id): | 60 def getObjectsFromMap(self, map_id): |
62 """Gets all objects that are currently on the given map. | 61 """Gets all objects that are currently on the given map. |