adding teleport support

This commit is contained in:
Samir Naik 2005-03-28 22:31:19 +00:00
parent 19ef896a9b
commit 60a0c18273
3 changed files with 13 additions and 12 deletions

View File

@ -41,7 +41,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
DistributedObject.DistributedObject.generate(self)
self.gotStringParentToken = 0
def setLocation(self, parentId, zoneId):
def setLocation(self, parentId, zoneId, teleport=0):
# Redefine DistributedObject setLocation, so that when
# location is set to the ocean grid, we can update our parenting
# under gridParent
@ -51,7 +51,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
if parentObj.isGridParent():
if not self.gridParent:
self.gridParent = GridParent.GridParent(self)
self.gridParent.setGridParent(parentObj, zoneId)
self.gridParent.setGridParent(parentObj, zoneId, teleport)
else:
if self.gridParent:
self.gridParent.delete()

View File

@ -23,7 +23,7 @@ class DistributedNodeAI(DistributedObjectAI.DistributedObjectAI, NodePath):
self.removeNode()
DistributedObjectAI.DistributedObjectAI.delete(self)
def setLocation(self, parentId, zoneId):
def setLocation(self, parentId, zoneId, teleport=0):
# Redefine DistributedObject setLocation, so that when
# location is set to the ocean grid, we can update our parenting
# under gridParent

View File

@ -35,15 +35,16 @@ class GridParent:
# Remove the gridNodes
self.cellOrigin.removeNode()
def setGridParent(self, grid, zoneId):
# If the avatar has a parent, preserve his absolute position. Otherwise
# if he has no parent, assume this is the first time he's been parented
# to anything, and don't wrtReparent, just do a regular reparent.
firstParent = 0
if self.av.getParent().isEmpty():
firstParent = 1
def setGridParent(self, grid, zoneId, teleport=0):
# If teleport=0, preserve the avatar's absolute position. If teleport=1
# the avatars previous world position is invalid, so don't wrtReparent,
# just do a regular reparent, and let the cellOrigin give us our new position
if not firstParent:
# Also, if the avatar has no parent, then force teleport=1
if self.av.getParent().isEmpty():
teleport = 1
if not teleport:
# Stick the avatar under hidden while we move the cellOrigin into
# position so we do not lose the avatars absolute position.
self.av.wrtReparentTo(hidden)
@ -63,7 +64,7 @@ class GridParent:
self.cellOrigin.setPos(*cellPos)
# Reparent our avatar to this node
if not firstParent:
if not teleport:
self.av.wrtReparentTo(self.cellOrigin)
else:
self.av.reparentTo(self.cellOrigin)