factory battles lock down the visibility

This commit is contained in:
Darren Ranalli 2003-12-06 01:13:35 +00:00
parent 3001f98c0b
commit a45a3e6980
3 changed files with 32 additions and 0 deletions

View File

@ -497,6 +497,26 @@ class DistributedLevel(DistributedObject.DistributedObject,
self.smallTitleText.hide()
self.spawnTitleText()
def lockVisibility(self, zoneNum=None, zoneId=None):
"""call this to lock the visibility to a particular zone
pass in either network zoneId or model zoneNum
"""
assert (zoneNum is None) or (zoneId is None)
assert not ((zoneNum is None) and (zoneId is None))
if zoneId is not None:
zoneNum = self.getZoneNumFromId(zoneId)
self.notify.info('lockVisibility to zoneNum %s' % zoneNum)
self.lockVizZone = zoneNum
self.enterZone(self.lockVizZone)
def unlockVisibility(self):
"""release the visibility lock"""
self.notify.info('unlockVisibility')
if hasattr(self, 'lockVizZone'):
del self.lockVizZone
self.updateVisibility()
def enterZone(self, zoneNum):
DistributedLevel.notify.info("entering zone %s" % zoneNum)
@ -518,6 +538,8 @@ class DistributedLevel(DistributedObject.DistributedObject,
#print 'updateVisibility %s' % globalClock.getFrameCount()
if zoneNum is None:
zoneNum = self.curZoneNum
if hasattr(self, 'lockVizZone'):
zoneNum = self.lockVizZone
zoneEntId = self.zoneNum2entId[zoneNum]
zoneEnt = self.getEntity(zoneEntId)

View File

@ -253,6 +253,10 @@ class Level:
assert entId in self.zoneEntId2zoneId
return self.zoneEntId2zoneId[entId]
def getZoneNumFromId(self, zoneId):
"""returns the model zoneNum that corresponds to a network zoneId"""
return self.zoneId2zoneNum[zoneId]
# these events are thrown as the level initializes itself
# LEVEL
def getLevelPreCreateEvent(self):

View File

@ -16,6 +16,8 @@ class LevelMgr(LevelMgrBase.LevelMgrBase):
self.level.zoneNum2entId = {}
# modelZoneNum -> network zoneId
self.level.zoneNum2zoneId = {}
# network zoneId -> modelZoneNum
self.level.zoneId2zoneNum = {}
# zone entId -> network zoneId
self.level.zoneEntId2zoneId = {}
@ -26,6 +28,7 @@ class LevelMgr(LevelMgrBase.LevelMgrBase):
def destroy(self):
del self.level.zoneIds
del self.level.zoneEntId2zoneId
del self.level.zoneId2zoneNum
del self.level.zoneNum2zoneId
del self.level.zoneNum2entId
self.geom.removeNode()
@ -55,6 +58,8 @@ class LevelMgr(LevelMgrBase.LevelMgrBase):
zoneEnt = self.level.getEntity(entId)
# unregister the zone from the maps
del self.level.zoneNum2entId[zoneEnt.modelZoneNum]
del self.level.zoneId2zoneNum[
self.level.zoneNum2zoneId[zoneEnt.modelZoneNum]]
del self.level.zoneNum2zoneId[zoneEnt.modelZoneNum]
del self.level.zoneEntId2zoneId[entId]
# reassign the zoneIds (we may not need to do this, if all of the
@ -80,4 +85,5 @@ class LevelMgr(LevelMgrBase.LevelMgrBase):
zoneEnt = self.level.getEntity(entId)
zoneId = zoneEnt.getZoneId()
self.level.zoneNum2zoneId[zoneEnt.modelZoneNum] = zoneId
self.level.zoneId2zoneNum[zoneId] = zoneEnt.modelZoneNum
self.level.zoneEntId2zoneId[entId] = zoneId