mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
adding teleport support
This commit is contained in:
parent
19ef896a9b
commit
60a0c18273
@ -41,7 +41,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
|||||||
DistributedObject.DistributedObject.generate(self)
|
DistributedObject.DistributedObject.generate(self)
|
||||||
self.gotStringParentToken = 0
|
self.gotStringParentToken = 0
|
||||||
|
|
||||||
def setLocation(self, parentId, zoneId):
|
def setLocation(self, parentId, zoneId, teleport=0):
|
||||||
# Redefine DistributedObject setLocation, so that when
|
# Redefine DistributedObject setLocation, so that when
|
||||||
# location is set to the ocean grid, we can update our parenting
|
# location is set to the ocean grid, we can update our parenting
|
||||||
# under gridParent
|
# under gridParent
|
||||||
@ -51,7 +51,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
|||||||
if parentObj.isGridParent():
|
if parentObj.isGridParent():
|
||||||
if not self.gridParent:
|
if not self.gridParent:
|
||||||
self.gridParent = GridParent.GridParent(self)
|
self.gridParent = GridParent.GridParent(self)
|
||||||
self.gridParent.setGridParent(parentObj, zoneId)
|
self.gridParent.setGridParent(parentObj, zoneId, teleport)
|
||||||
else:
|
else:
|
||||||
if self.gridParent:
|
if self.gridParent:
|
||||||
self.gridParent.delete()
|
self.gridParent.delete()
|
||||||
|
@ -23,7 +23,7 @@ class DistributedNodeAI(DistributedObjectAI.DistributedObjectAI, NodePath):
|
|||||||
self.removeNode()
|
self.removeNode()
|
||||||
DistributedObjectAI.DistributedObjectAI.delete(self)
|
DistributedObjectAI.DistributedObjectAI.delete(self)
|
||||||
|
|
||||||
def setLocation(self, parentId, zoneId):
|
def setLocation(self, parentId, zoneId, teleport=0):
|
||||||
# Redefine DistributedObject setLocation, so that when
|
# Redefine DistributedObject setLocation, so that when
|
||||||
# location is set to the ocean grid, we can update our parenting
|
# location is set to the ocean grid, we can update our parenting
|
||||||
# under gridParent
|
# under gridParent
|
||||||
|
@ -35,15 +35,16 @@ class GridParent:
|
|||||||
# Remove the gridNodes
|
# Remove the gridNodes
|
||||||
self.cellOrigin.removeNode()
|
self.cellOrigin.removeNode()
|
||||||
|
|
||||||
def setGridParent(self, grid, zoneId):
|
def setGridParent(self, grid, zoneId, teleport=0):
|
||||||
# If the avatar has a parent, preserve his absolute position. Otherwise
|
# If teleport=0, preserve the avatar's absolute position. If teleport=1
|
||||||
# if he has no parent, assume this is the first time he's been parented
|
# the avatars previous world position is invalid, so don't wrtReparent,
|
||||||
# to anything, and don't wrtReparent, just do a regular reparent.
|
# just do a regular reparent, and let the cellOrigin give us our new position
|
||||||
firstParent = 0
|
|
||||||
if self.av.getParent().isEmpty():
|
|
||||||
firstParent = 1
|
|
||||||
|
|
||||||
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
|
# Stick the avatar under hidden while we move the cellOrigin into
|
||||||
# position so we do not lose the avatars absolute position.
|
# position so we do not lose the avatars absolute position.
|
||||||
self.av.wrtReparentTo(hidden)
|
self.av.wrtReparentTo(hidden)
|
||||||
@ -63,7 +64,7 @@ class GridParent:
|
|||||||
self.cellOrigin.setPos(*cellPos)
|
self.cellOrigin.setPos(*cellPos)
|
||||||
|
|
||||||
# Reparent our avatar to this node
|
# Reparent our avatar to this node
|
||||||
if not firstParent:
|
if not teleport:
|
||||||
self.av.wrtReparentTo(self.cellOrigin)
|
self.av.wrtReparentTo(self.cellOrigin)
|
||||||
else:
|
else:
|
||||||
self.av.reparentTo(self.cellOrigin)
|
self.av.reparentTo(self.cellOrigin)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user