mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Added ability to specifiy a zone to use when calling addObjectToGrid.
This commit is contained in:
parent
7573bcfebd
commit
0ffadd6cb3
@ -39,7 +39,7 @@ class DistributedCartesianGridAI(DistributedNodeAI.DistributedNodeAI,
|
|||||||
return [self.style, rule]
|
return [self.style, rule]
|
||||||
|
|
||||||
# Reparent and setLocation on av to DistributedOceanGrid
|
# Reparent and setLocation on av to DistributedOceanGrid
|
||||||
def addObjectToGrid(self, av):
|
def addObjectToGrid(self, av, useZoneId=-1):
|
||||||
print "setting parent to grid %s" % self
|
print "setting parent to grid %s" % self
|
||||||
avId = av.doId
|
avId = av.doId
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ class DistributedCartesianGridAI(DistributedNodeAI.DistributedNodeAI,
|
|||||||
self.gridObjects[avId] = av
|
self.gridObjects[avId] = av
|
||||||
|
|
||||||
# Put the avatar on the grid
|
# Put the avatar on the grid
|
||||||
self.handleAvatarZoneChange(av)
|
self.handleAvatarZoneChange(av, useZoneId)
|
||||||
|
|
||||||
if not self.updateTaskStarted:
|
if not self.updateTaskStarted:
|
||||||
self.startUpdateGridTask()
|
self.startUpdateGridTask()
|
||||||
@ -100,11 +100,17 @@ class DistributedCartesianGridAI(DistributedNodeAI.DistributedNodeAI,
|
|||||||
task.delayTime = 1.0
|
task.delayTime = 1.0
|
||||||
return Task.again
|
return Task.again
|
||||||
|
|
||||||
def handleAvatarZoneChange(self, av):
|
def handleAvatarZoneChange(self, av, useZoneId=-1):
|
||||||
# Calculate zone id
|
# Calculate zone id
|
||||||
# Get position of av relative to this grid
|
# Get position of av relative to this grid
|
||||||
|
if (useZoneId == -1):
|
||||||
pos = av.getPos(self)
|
pos = av.getPos(self)
|
||||||
zoneId = self.getZoneFromXYZ(pos)
|
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):
|
if not self.isValidZone(zoneId):
|
||||||
self.notify.warning("%s handleAvatarZoneChange %s: not a valid zone (%s) for pos %s" %
|
self.notify.warning("%s handleAvatarZoneChange %s: not a valid zone (%s) for pos %s" %
|
||||||
|
Loading…
x
Reference in New Issue
Block a user