|
|
@@ -191,48 +191,43 @@ class DoCollectionManager:
|
|
|
else:
|
|
|
self.notify.warning('handleSetLocation: object %s not present' % self.getMsgChannel())
|
|
|
|
|
|
- def storeObjectLocation(self, doId, parentId, zoneId, object=None):
|
|
|
- if (object == None):
|
|
|
- object = self.doId2do.get(doId)
|
|
|
- if object is None:
|
|
|
- self.notify.warning('storeObjectLocation: object %s not present' % doId)
|
|
|
- else:
|
|
|
- oldParentId = object.parentId
|
|
|
- oldZoneId = object.zoneId
|
|
|
- if ((None not in (oldParentId, oldZoneId)) and
|
|
|
- ((oldParentId != parentId) or (oldZoneId != zoneId))):
|
|
|
- # Remove old location
|
|
|
- self.deleteObjectLocation(doId, oldParentId, oldZoneId)
|
|
|
- elif oldParentId == parentId and oldZoneId == zoneId:
|
|
|
- # object is already at that parent and zone
|
|
|
- return
|
|
|
- if (parentId is None) or (zoneId is None):
|
|
|
- # Do not store null values
|
|
|
- return
|
|
|
- # Add to new location
|
|
|
- self._doHierarchy.storeObjectLocation(doId, parentId, zoneId)
|
|
|
- # this check doesn't work because of global UD objects;
|
|
|
- # should they have a location?
|
|
|
- #assert len(self._doHierarchy) == len(self.doId2do)
|
|
|
-
|
|
|
- # Set the new parent and zone on the object
|
|
|
- object.parentId = parentId
|
|
|
- object.zoneId = zoneId
|
|
|
-
|
|
|
- if 1:
|
|
|
- # Do we still need this
|
|
|
- if oldParentId != parentId:
|
|
|
- # 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.doId2do.get(parentId)
|
|
|
- if parentObj is not None:
|
|
|
- parentObj.handleChildArrive(object, zoneId)
|
|
|
- elif parentId not in (0, self.getGameDoId()):
|
|
|
- self.notify.warning('storeObjectLocation(%s): parent %s not present' %
|
|
|
- (doId, parentId))
|
|
|
+ def storeObjectLocation(self, object, parentId, zoneId):
|
|
|
+ oldParentId = object.parentId
|
|
|
+ oldZoneId = object.zoneId
|
|
|
+ if ((None not in (oldParentId, oldZoneId)) and
|
|
|
+ ((oldParentId != parentId) or (oldZoneId != zoneId))):
|
|
|
+ # Remove old location
|
|
|
+ self.deleteObjectLocation(object, oldParentId, oldZoneId)
|
|
|
+ elif oldParentId == parentId and oldZoneId == zoneId:
|
|
|
+ # object is already at that parent and zone
|
|
|
+ return
|
|
|
+ if (parentId is None) or (zoneId is None):
|
|
|
+ # Do not store null values
|
|
|
+ return
|
|
|
+ # Add to new location
|
|
|
+ self._doHierarchy.storeObjectLocation(object, parentId, zoneId)
|
|
|
+ # this check doesn't work because of global UD objects;
|
|
|
+ # should they have a location?
|
|
|
+ #assert len(self._doHierarchy) == len(self.doId2do)
|
|
|
+
|
|
|
+ # Set the new parent and zone on the object
|
|
|
+ object.parentId = parentId
|
|
|
+ object.zoneId = zoneId
|
|
|
+
|
|
|
+ if 1:
|
|
|
+ # Do we still need this
|
|
|
+ if oldParentId != parentId:
|
|
|
+ # 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.doId2do.get(parentId)
|
|
|
+ if parentObj is not None:
|
|
|
+ parentObj.handleChildArrive(object, zoneId)
|
|
|
+ elif parentId not in (0, self.getGameDoId()):
|
|
|
+ self.notify.warning('storeObjectLocation(%s): parent %s not present' %
|
|
|
+ (doId, parentId))
|
|
|
|
|
|
- def deleteObjectLocation(self, doId, parentId, zoneId):
|
|
|
+ def deleteObjectLocation(self, object, parentId, zoneId):
|
|
|
# Do not worry about null values
|
|
|
if (parentId is None) or (zoneId is None):
|
|
|
return
|
|
|
@@ -241,11 +236,10 @@ class DoCollectionManager:
|
|
|
|
|
|
# notify any existing parent that we're moving away
|
|
|
oldParentObj = self.doId2do.get(parentId)
|
|
|
- obj = self.doId2do.get(doId)
|
|
|
- if oldParentObj is not None and obj is not None:
|
|
|
- oldParentObj.handleChildLeave(obj, zoneId)
|
|
|
+ if oldParentObj is not None:
|
|
|
+ oldParentObj.handleChildLeave(object, zoneId)
|
|
|
|
|
|
- self._doHierarchy.deleteObjectLocation(doId, parentId, zoneId)
|
|
|
+ self._doHierarchy.deleteObjectLocation(object, parentId, zoneId)
|
|
|
|
|
|
def addDOToTables(self, do, location=None, ownerView=False):
|
|
|
assert self.notify.debugStateCall(self)
|
|
|
@@ -270,7 +264,7 @@ class DoCollectionManager:
|
|
|
|
|
|
if not ownerView:
|
|
|
if self.isValidLocationTuple(location):
|
|
|
- self.storeObjectLocation(do.doId, location[0], location[1])
|
|
|
+ self.storeObjectLocation(do, location[0], location[1])
|
|
|
##assert do.doId not in self.zoneId2doIds.get(location, {})
|
|
|
##self.zoneId2doIds.setdefault(location, {})
|
|
|
##self.zoneId2doIds[location][do.doId]=do
|
|
|
@@ -289,7 +283,7 @@ class DoCollectionManager:
|
|
|
assert self.notify.debugStateCall(self)
|
|
|
#assert not hasattr(do, "isQueryAllResponse") or not do.isQueryAllResponse
|
|
|
#assert do.doId in self.doId2do
|
|
|
- self.deleteObjectLocation(do.doId, do.parentId, do.zoneId)
|
|
|
+ self.deleteObjectLocation(do, do.parentId, do.zoneId)
|
|
|
## location = do.getLocation()
|
|
|
## if location is not None:
|
|
|
## if location not in self.zoneId2doIds:
|