$('div').click(function() {
alert('click');
});
#Load some handlers for all current goblins
goblins = select("//mobile/baseModel[name='Goblin']")
goblins.onMove = goblinMoves
goblins.beforeDeath = goblinScreamOfAgony
# Load an event handler for all future goblins to equip them.
futureGoblins = futureSelect("//mobile/baseModel[name='Goblin']")
futureGoblins.onLoad = equipGoblin
To expose an API for finding game objects, I have a "database index document" that copies the XML of all currently loaded game objects along with a UUID -> Object map that stores the actual game object pointers. An XPath query is sent to the database, and a list of UUIDs returned. These are then sent to the Map, which finally returns the objects in a List.
This works, and is the basis of the (currently non-existent) event handling system in RingMUD. However, is it efficient? I do not think it is. So, I am looking for ways to improve it. My initial ideas are:
1. Trim the XML going into the Index Document. Right now it copies EVERYTHING, when all it needs is a skeletal structure.
2. Remove the Index Document entirely and actually just require document as part of the XPath parameter.
I think I'll be going with #2, but I want to see if anyone else has any ideas.