Added ability to specifiy a zone to use when calling addObjectToGrid.

This commit is contained in:
Justin Butler 2005-06-07 01:47:13 +00:00
parent 7573bcfebd
commit 0ffadd6cb3

View File

@ -39,7 +39,7 @@ class DistributedCartesianGridAI(DistributedNodeAI.DistributedNodeAI,
return [self.style, rule]
# Reparent and setLocation on av to DistributedOceanGrid
def addObjectToGrid(self, av):
def addObjectToGrid(self, av, useZoneId=-1):
print "setting parent to grid %s" % self
avId = av.doId
@ -49,7 +49,7 @@ class DistributedCartesianGridAI(DistributedNodeAI.DistributedNodeAI,
self.gridObjects[avId] = av
# Put the avatar on the grid
self.handleAvatarZoneChange(av)
self.handleAvatarZoneChange(av, useZoneId)
if not self.updateTaskStarted:
self.startUpdateGridTask()
@ -100,11 +100,17 @@ class DistributedCartesianGridAI(DistributedNodeAI.DistributedNodeAI,
task.delayTime = 1.0
return Task.again
def handleAvatarZoneChange(self, av):
def handleAvatarZoneChange(self, av, useZoneId=-1):
# Calculate zone id
# Get position of av relative to this grid
if (useZoneId == -1):
pos = av.getPos(self)
zoneId = self.getZoneFromXYZ(pos)
else:
# zone already calcualte, position of object might not
# give the correct zone
pos = None
zoneId = useZoneId
if not self.isValidZone(zoneId):
self.notify.warning("%s handleAvatarZoneChange %s: not a valid zone (%s) for pos %s" %