new handler for child setLocation calls

This commit is contained in:
Joe Shochet 2005-04-26 19:57:27 +00:00
parent 2f4327c5a0
commit 09962a0e54
2 changed files with 19 additions and 5 deletions

View File

@ -55,11 +55,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
else:
if self.gridParent:
self.gridParent.delete()
self.gridParent = None
# NOTE: at this point the avatar has been detached from the scene
# graph. Someone else needs to reparent him to something in the scene graph
# TODO: handle DistributedNode parenting
self.gridParent = None
def __cmp__(self, other):
# DistributedNode inherits from NodePath, which inherits a

View File

@ -353,10 +353,28 @@ class DistributedObject(PandaObject):
# The store must run first so we know the old location
#self.cr.storeObjectLocation(self.doId, parentId, zoneId)
self.__location = (parentId, zoneId)
# Give the parent a chance to run code when a new child
# sets location to it. For example, the parent may want to
# scene graph reparent the child to some subnode it owns.
parentObj = self.cr.doId2do.get(parentId)
if parentObj:
parentObj.handleChildSetLocation(self, zoneId)
def getLocation(self):
return self.__location
def handleChildSetLocation(self, childObj, zoneId):
self.notify.info("handleChildSetLocation: %s childId: %s zoneId: %s" %
(self.doId, childObj.doId, zoneId))
# A new child has just setLocation beneath us. Give us a
# chance to run code when a new child sets location to us. For
# example, we may want to scene graph reparent the child to
# some subnode we own.
# Inheritors should override
pass
def isLocal(self):
# This returns true if the distributed object is "local,"
# which means the client created it instead of the AI, and it