added new sellbot leg factory

This commit is contained in:
Darren Ranalli 2003-10-29 21:44:26 +00:00
parent 4864b6a142
commit 23a63b2e73
6 changed files with 55 additions and 47 deletions

View File

@ -17,12 +17,6 @@ class NodePathAttribs:
if doReparent:
self.callSetters('parentEntId')
def setParentEntId(self, parentEntId):
self.parentEntId = parentEntId
self.level.requestReparent(self.getNodePath(), self.parentEntId)
def reparentTo(self, *args): self.getNodePath().reparentTo(*args)
def setPos(self, *args): self.getNodePath().setPos(*args)
def setX(self, *args): self.getNodePath().setX(*args)
def setY(self, *args): self.getNodePath().setY(*args)
@ -38,6 +32,12 @@ class NodePathAttribs:
def setSy(self, *args): self.getNodePath().setSy(*args)
def setSz(self, *args): self.getNodePath().setSz(*args)
def reparentTo(self, *args): self.getNodePath().reparentTo(*args)
def setParentEntId(self, parentEntId):
self.parentEntId = parentEntId
self.level.requestReparent(self, self.parentEntId)
class privNodePathImpl(NodePath.NodePath):
def __init__(self, name):
node = hidden.attachNewNode(name)

View File

@ -198,6 +198,9 @@ class DistributedLevel(DistributedObject.DistributedObject,
# fix up the floor collisions for walkable zones *before*
# any entities get put under the model
for zoneNum,zoneNode in self.zoneNum2node.items():
# don't do this to the uberzone
if zoneNum == LevelConstants.UberZoneNum:
continue
# if this is a walkable zone, fix up the model
allColls = zoneNode.findAllMatches('**/+CollisionNode').asList()
# which of them, if any, are floors?
@ -225,35 +228,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
self.toonEnterZone(zoneNum)
self.accept('enter%s' % floorCollName, handleZoneEnter)
# hack in another doorway
dw = self.geom.attachNewNode('Doorway27')
dw.setPos(-49.4,86.7,19.26)
dw.setH(0)
# find the doorway nodes
# this is going to go away soon.
def findNumberedNodes(baseString, model=self.geom, self=self):
# finds nodes whose name follows the pattern 'baseString#'
# where there are no characters after #
# returns dictionary that maps # to node
potentialNodes = model.findAllMatches(
'**/%s*' % baseString).asList()
num2node = {}
for potentialNode in potentialNodes:
name = potentialNode.getName()
DistributedLevel.notify.debug('potential match for %s: %s' %
(baseString, name))
try:
num = int(name[len(baseString):])
except:
continue
num2node[num] = potentialNode
return num2node
self.doorwayNum2Node = findNumberedNodes('Doorway')
def announceGenerate(self):
DistributedLevel.notify.debug('announceGenerate')
DistributedObject.DistributedObject.announceGenerate(self)
@ -287,10 +261,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
# remove factory menu to SpeedChat
toonbase.localToon.chatMgr.chatInputSpeedChat.removeFactoryMenu()
def getDoorwayNode(self, doorwayNum):
# returns node that doors should parent themselves to
return self.doorwayNum2Node[doorwayNum]
def getZoneNode(self, zoneNum):
return self.zoneNum2node[zoneNum]
@ -400,13 +370,23 @@ class DistributedLevel(DistributedObject.DistributedObject,
if zoneNum not in self.zoneNum2entId:
DistributedLevel.notify.error(
'no ZoneEntity for this zone (%s)!!' % zoneNum)
return
self.updateVisibility(zoneNum)
def updateVisibility(self, zoneNum=None):
"""update the visibility assuming that we're in the specified
zone; don't check to see if it's the zone we're already in"""
if zoneNum is None:
zoneNum = self.curZoneNum
zoneEntId = self.zoneNum2entId[zoneNum]
zoneSpec = self.levelSpec.getEntitySpec(zoneEntId)
# use dicts to efficiently ensure that there are no duplicates
visibleZoneNums = list2dict([zoneNum])
visibleZoneNums.update(list2dict(zoneSpec['visibility']))
# we should not have the uberZone in the list at this point
assert not 0 in visibleZoneNums
if DistributedLevel.HideZones:
# figure out which zones are new and which are going invisible
@ -416,7 +396,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
removedZoneNums = []
allVZ = dict(visibleZoneNums)
allVZ.update(self.curVisibleZoneNums)
for vz,None in allVZ.items():
for vz,dummy in allVZ.items():
new = vz in visibleZoneNums
old = vz in self.curVisibleZoneNums
if new and old:
@ -460,6 +440,11 @@ class DistributedLevel(DistributedObject.DistributedObject,
value = eval(valueStr)
self.levelSpec.setAttribChange(entId, attribName, value, username)
def handleVisChange(self):
"""the zone visibility lists have changed"""
Level.Level.handleVisChange(self)
self.updateVisibility()
def spawnTitleText(self):
def getDescription(zoneId, self=self):
entId = self.zoneNum2entId.get(zoneId)

View File

@ -322,3 +322,7 @@ class Level:
entity.destroy()
# update our local type->entId table
self.entType2ids[self.getEntityType(entId)].remove(entId)
def handleVisChange(self):
"""the zone visibility lists have changed"""
pass

View File

@ -1,10 +1,11 @@
"""LevelUtil module: contains Level utility funcs"""
import string
def getZoneNum2Node(levelModel):
""" given model, returns dict of ZoneNumber -> ZoneNode """
def findNumberedNodes(baseString, model):
# finds nodes whose name follows the pattern 'baseString#'
# where there are no characters after #
# finds nodes whose name follows the pattern 'baseString#blah'
# returns dictionary that maps # to node
potentialNodes = model.findAllMatches(
'**/%s*' % baseString).asList()
@ -12,16 +13,24 @@ def getZoneNum2Node(levelModel):
for potentialNode in potentialNodes:
name = potentialNode.getName()
print 'potential match for %s: %s' % (baseString, name)
try:
num = int(name[len(baseString):])
except:
name = name[len(baseString):]
numDigits = 0
while numDigits < len(name):
if name[numDigits] not in string.digits:
break
numDigits += 1
if numDigits == 0:
continue
num = int(name[:numDigits])
# do we already have a ZoneNode for this zone num?
assert not num in num2node
num2node[num] = potentialNode
return num2node
zoneNum2node = findNumberedNodes('Zone', levelModel)
# temp
zoneNum2node.update(findNumberedNodes('ZONE', levelModel))
# add the UberZone to the table
zoneNum2node[0] = levelModel
return zoneNum2node

View File

@ -82,3 +82,9 @@ def privUpdateSpec(spec, modelPath=None):
spec.insertEntity(entId, 'zone', LevelConstants.UberZoneEntId)
spec.doSetAttrib(entId, 'name', 'zone%s' % zoneNum)
spec.doSetAttrib(entId, 'modelZoneNum', zoneNum)
# by default, new zone can see every other zone
visList = list(modelZoneNums)
# cur zone and uberzone are implicit
visList.remove(zoneNum)
visList.remove(0)
spec.doSetAttrib(entId, 'visibility', visList)

View File

@ -12,3 +12,7 @@ class ZoneEntity(ZoneEntityBase.ZoneEntityBase, BasicEntities.NodePathAttribs):
def getNodePath(self):
return self.nodePath
def setVisibility(self, visibility):
self.visibility = visibility
self.level.handleVisChange()