added SpecUtil funcs for creating and adapting specs to new level models

This commit is contained in:
Darren Ranalli 2003-10-25 01:18:04 +00:00
parent be086b33d7
commit e1f49b2569

27
direct/src/level/LevelUtil.py Executable file
View File

@ -0,0 +1,27 @@
"""LevelUtil module: contains Level utility funcs"""
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 #
# returns dictionary that maps # to node
potentialNodes = model.findAllMatches(
'**/%s*' % baseString).asList()
num2node = {}
for potentialNode in potentialNodes:
name = potentialNode.getName()
print 'potential match for %s: %s' % (baseString, name)
try:
num = int(name[len(baseString):])
except:
continue
num2node[num] = potentialNode
return num2node
zoneNum2node = findNumberedNodes('Zone', levelModel)
# add the UberZone to the table
zoneNum2node[0] = levelModel
return zoneNum2node