mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
using parentId, zoneId rather than __location
This commit is contained in:
parent
5351d31c64
commit
87920f25ac
@ -35,9 +35,10 @@ class DistributedObject(PandaObject):
|
|||||||
except:
|
except:
|
||||||
self.DistributedObject_initialized = 1
|
self.DistributedObject_initialized = 1
|
||||||
self.cr = cr
|
self.cr = cr
|
||||||
if wantOtpServer:
|
self.children = {}
|
||||||
# Location stores the parentId, zoneId of this object
|
## if wantOtpServer:
|
||||||
self.__location = (None, None)
|
## # Location stores the parentId, zoneId of this object
|
||||||
|
## self.__location = (None, None)
|
||||||
|
|
||||||
# Most DistributedObjects are simple and require no real
|
# Most DistributedObjects are simple and require no real
|
||||||
# effort to load. Some, particularly actors, may take
|
# effort to load. Some, particularly actors, may take
|
||||||
@ -396,7 +397,7 @@ class DistributedObject(PandaObject):
|
|||||||
oldParentObj.handleChildLeave(self, oldZoneId)
|
oldParentObj.handleChildLeave(self, oldZoneId)
|
||||||
|
|
||||||
# The store must run first so we know the old location
|
# The store must run first so we know the old location
|
||||||
self.__location = (parentId, zoneId)
|
## self.__location = (parentId, zoneId)
|
||||||
self.parentId = parentId
|
self.parentId = parentId
|
||||||
self.zoneId = zoneId
|
self.zoneId = zoneId
|
||||||
self.cr.storeObjectLocation(self.doId, parentId, zoneId)
|
self.cr.storeObjectLocation(self.doId, parentId, zoneId)
|
||||||
@ -410,24 +411,28 @@ class DistributedObject(PandaObject):
|
|||||||
parentObj.handleChildArrive(self, zoneId)
|
parentObj.handleChildArrive(self, zoneId)
|
||||||
|
|
||||||
def getLocation(self):
|
def getLocation(self):
|
||||||
return self.__location
|
return (self.parentId, self.zoneId)
|
||||||
|
|
||||||
def handleChildArrive(self, childObj, zoneId):
|
def handleChildArrive(self, childObj, zoneId):
|
||||||
self.notify.debug("handleChildArrive: %s childId: %s zoneId: %s" %
|
self.notify.debugCall()
|
||||||
(self.doId, childObj.doId, zoneId))
|
|
||||||
# A new child has just setLocation beneath us. Give us a
|
# A new child has just setLocation beneath us. Give us a
|
||||||
# chance to run code when a new child sets location to us. For
|
# chance to run code when a new child sets location to us. For
|
||||||
# example, we may want to scene graph reparent the child to
|
# example, we may want to scene graph reparent the child to
|
||||||
# some subnode we own.
|
# some subnode we own.
|
||||||
|
## zone=self.children.setdefault(zoneId, {})
|
||||||
|
## zone[childObj.doId]=childObj
|
||||||
|
|
||||||
# Inheritors should override
|
# Inheritors should override
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handleChildLeave(self, childObj, zoneId):
|
def handleChildLeave(self, childObj, zoneId):
|
||||||
self.notify.debug("handleChildLeave: %s childId: %s zoneId: %s" %
|
self.notify.debugCall()
|
||||||
(self.doId, childObj.doId, zoneId))
|
|
||||||
# A child is about to setLocation away from us. Give us a
|
# A child is about to setLocation away from us. Give us a
|
||||||
# chance to run code just before a child sets location away from us.
|
# chance to run code just before a child sets location away from us.
|
||||||
|
## zone=self.children[zoneId]
|
||||||
|
## del zone[childObj.doId]
|
||||||
|
## if not len(zone):
|
||||||
|
## del self.children[zoneId]
|
||||||
|
|
||||||
# Inheritors should override
|
# Inheritors should override
|
||||||
pass
|
pass
|
||||||
|
@ -21,7 +21,9 @@ class DistributedObjectAI(DirectObject):
|
|||||||
# Record the repository
|
# Record the repository
|
||||||
self.air = air
|
self.air = air
|
||||||
# Record our parentId and zoneId
|
# Record our parentId and zoneId
|
||||||
self.__location = None
|
## self.__location = None
|
||||||
|
self.parentId = None
|
||||||
|
self.zoneId = None
|
||||||
|
|
||||||
# Record our distributed class
|
# Record our distributed class
|
||||||
className = self.__class__.__name__
|
className = self.__class__.__name__
|
||||||
@ -195,14 +197,15 @@ class DistributedObjectAI(DirectObject):
|
|||||||
self.handleLogicalZoneChange(zoneId, lastLogicalZone)
|
self.handleLogicalZoneChange(zoneId, lastLogicalZone)
|
||||||
self.lastNonQuietZone = zoneId
|
self.lastNonQuietZone = zoneId
|
||||||
self.air.storeObjectLocation(self.doId, parentId, zoneId)
|
self.air.storeObjectLocation(self.doId, parentId, zoneId)
|
||||||
self.__location = (parentId, zoneId)
|
## self.__location = (parentId, zoneId)
|
||||||
|
|
||||||
# Set the initial values of parentId,zoneId
|
# Set the initial values of parentId,zoneId
|
||||||
def setInitLocation(self, parentId, zoneId):
|
def setInitLocation(self, parentId, zoneId):
|
||||||
self.__location = (parentId, zoneId)
|
self.parentId=parentId
|
||||||
|
self.zoneId=zoneId
|
||||||
|
|
||||||
def getLocation(self):
|
def getLocation(self):
|
||||||
return self.__location
|
return (self.parentId, self.zoneId)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# NON OTP
|
# NON OTP
|
||||||
@ -314,9 +317,9 @@ class DistributedObjectAI(DirectObject):
|
|||||||
|
|
||||||
# The repository is the one that really does the work
|
# The repository is the one that really does the work
|
||||||
parentId = self.air.districtId
|
parentId = self.air.districtId
|
||||||
self.air.generateWithRequired(self, parentId, zoneId, optionalFields)
|
|
||||||
self.parentId = parentId
|
self.parentId = parentId
|
||||||
self.zoneId = zoneId
|
self.zoneId = zoneId
|
||||||
|
self.air.generateWithRequired(self, parentId, zoneId, optionalFields)
|
||||||
self.generate()
|
self.generate()
|
||||||
else:
|
else:
|
||||||
def generateWithRequired(self, zoneId, optionalFields=[]):
|
def generateWithRequired(self, zoneId, optionalFields=[]):
|
||||||
@ -346,7 +349,7 @@ class DistributedObjectAI(DirectObject):
|
|||||||
self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields)
|
self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields)
|
||||||
self.parentId = parentId
|
self.parentId = parentId
|
||||||
self.zoneId = zoneId
|
self.zoneId = zoneId
|
||||||
self.__location = (parentId, zoneId)
|
## self.__location = (parentId, zoneId)
|
||||||
self.generate()
|
self.generate()
|
||||||
else:
|
else:
|
||||||
def generateWithRequiredAndId(self, doId, zoneId, optionalFields=[]):
|
def generateWithRequiredAndId(self, doId, zoneId, optionalFields=[]):
|
||||||
@ -371,7 +374,7 @@ class DistributedObjectAI(DirectObject):
|
|||||||
assert not hasattr(self, 'parentId')
|
assert not hasattr(self, 'parentId')
|
||||||
self.parentId = parentId
|
self.parentId = parentId
|
||||||
self.zoneId = zoneId
|
self.zoneId = zoneId
|
||||||
self.__location = (parentId, zoneId)
|
## self.__location = (parentId, zoneId)
|
||||||
self.generate()
|
self.generate()
|
||||||
|
|
||||||
def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None):
|
def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None):
|
||||||
@ -392,10 +395,10 @@ class DistributedObjectAI(DirectObject):
|
|||||||
# Send a generate message
|
# Send a generate message
|
||||||
self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields)
|
self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields)
|
||||||
|
|
||||||
assert not hasattr(self, 'parentId')
|
assert not hasattr(self, 'parentId') or self.parentId is None
|
||||||
self.parentId = parentId
|
self.parentId = parentId
|
||||||
self.zoneId = zoneId
|
self.zoneId = zoneId
|
||||||
self.__location = (parentId, zoneId)
|
## self.__location = (parentId, zoneId)
|
||||||
self.generate()
|
self.generate()
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user