mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
added VisibilityBlocker
This commit is contained in:
parent
7001df5c85
commit
e25ab93820
@ -63,9 +63,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
)
|
)
|
||||||
self.zonesEnteredList = []
|
self.zonesEnteredList = []
|
||||||
self.fColorZones = 0
|
self.fColorZones = 0
|
||||||
# we use these to track setZone requests
|
|
||||||
self.setZonesRequested = 0
|
|
||||||
self.setZonesReceived = 0
|
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
DistributedLevel.notify.debug('generate')
|
DistributedLevel.notify.debug('generate')
|
||||||
@ -446,10 +443,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
self.camEnterZone(zoneNum)
|
self.camEnterZone(zoneNum)
|
||||||
self.accept('on-floor', handleCameraRayFloorCollision)
|
self.accept('on-floor', handleCameraRayFloorCollision)
|
||||||
|
|
||||||
# register our datagram handler to listen for setZone msgs
|
|
||||||
self.oldTcrHandler = toonbase.tcr.handler
|
|
||||||
toonbase.tcr.handler = self.handleDatagram
|
|
||||||
|
|
||||||
# if no viz, listen to all the zones
|
# if no viz, listen to all the zones
|
||||||
if not DistributedLevel.WantVisibility:
|
if not DistributedLevel.WantVisibility:
|
||||||
zoneNums = list(self.zoneNums)
|
zoneNums = list(self.zoneNums)
|
||||||
@ -465,35 +458,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
def shutdownVisibility(self):
|
def shutdownVisibility(self):
|
||||||
taskMgr.remove(self.uniqueName(DistributedLevel.VisChangeTaskName))
|
taskMgr.remove(self.uniqueName(DistributedLevel.VisChangeTaskName))
|
||||||
|
|
||||||
if toonbase.tcr.handler == self.handleDatagram:
|
|
||||||
toonbase.tcr.handler = self.oldTcrHandler
|
|
||||||
del self.oldTcrHandler
|
|
||||||
|
|
||||||
def getSetZoneCompleteEvent(self, num):
|
|
||||||
return self.uniqueName('setZoneComplete-%s' % num)
|
|
||||||
|
|
||||||
def getNextSetZoneCompleteEvent(self):
|
|
||||||
return self.uniqueName('setZoneComplete-%s' % self.setZonesRequested)
|
|
||||||
|
|
||||||
def handleDatagram(self, msgType, di):
|
|
||||||
if msgType == CLIENT_DONE_SET_ZONE_RESP:
|
|
||||||
# snoop to see what zone we're talking about
|
|
||||||
di2 = DatagramIterator(di)
|
|
||||||
zone = di2.getUint32()
|
|
||||||
if zone != self.levelZone:
|
|
||||||
self.notify.warning('got setZoneComplete for unknown zone %s' %
|
|
||||||
zone)
|
|
||||||
else:
|
|
||||||
self.notify.info('setZone #%s complete' % self.setZonesReceived)
|
|
||||||
messenger.send(self.getSetZoneCompleteEvent(
|
|
||||||
self.setZonesReceived))
|
|
||||||
self.setZonesReceived += 1
|
|
||||||
|
|
||||||
if self.oldTcrHandler is None:
|
|
||||||
toonbase.tcr.handleUnexpectedMsgType(msgType, di)
|
|
||||||
else:
|
|
||||||
self.oldTcrHandler(msgType, di)
|
|
||||||
|
|
||||||
def toonEnterZone(self, zoneNum, ouchLevel=None):
|
def toonEnterZone(self, zoneNum, ouchLevel=None):
|
||||||
"""
|
"""
|
||||||
zoneNum is an int.
|
zoneNum is an int.
|
||||||
@ -628,7 +592,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
|||||||
self.hideZone(rz)
|
self.hideZone(rz)
|
||||||
|
|
||||||
self.setVisibility(visibleZoneNums.keys())
|
self.setVisibility(visibleZoneNums.keys())
|
||||||
self.setZonesRequested += 1
|
|
||||||
|
|
||||||
self.curZoneNum = zoneNum
|
self.curZoneNum = zoneNum
|
||||||
self.curVisibleZoneNums = visibleZoneNums
|
self.curVisibleZoneNums = visibleZoneNums
|
||||||
|
31
direct/src/level/VisibilityBlocker.py
Executable file
31
direct/src/level/VisibilityBlocker.py
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
"""VisibilityBlocker module: contains the VisibilityBlocker class"""
|
||||||
|
|
||||||
|
import Entity
|
||||||
|
|
||||||
|
class VisibilityBlocker:
|
||||||
|
"""This is a mixin class for level entities (see Entity.py) that in some
|
||||||
|
way 'block' visibility (such as doors) -- entities that can completely
|
||||||
|
obscure what's behind them. It provides the blocker with a mechanism
|
||||||
|
whereby they are informed of when it is safe for them to 'unblock' the
|
||||||
|
visibility and show what's behind them. Without this mechanism, the
|
||||||
|
blocker might show what's behind it before all of the distributed objects
|
||||||
|
behind it have been generated."""
|
||||||
|
def __init__(self):
|
||||||
|
# this may do something in the future; please call down to it
|
||||||
|
pass
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
self.ignoreAll()
|
||||||
|
|
||||||
|
def requestUnblockVis(self):
|
||||||
|
"""derived class should call this before the end of the frame in which
|
||||||
|
they cause the visibility to be extended. okToUnblockVis (see below)
|
||||||
|
will be called when it's safe to show the new zones."""
|
||||||
|
self.accept(self.level.tcr.getNextSetZoneDoneEvent(),
|
||||||
|
self.okToUnblockVis)
|
||||||
|
|
||||||
|
def okToUnblockVis(self):
|
||||||
|
"""derived class should override this func and do the vis unblock
|
||||||
|
(i.e. open the door, etc.)"""
|
||||||
|
# this may do something in the future; please call down to it
|
||||||
|
pass
|
Loading…
x
Reference in New Issue
Block a user