From b8d6318584a4eed3d3a2462074d46e76fa75f7bf Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Thu, 8 Jan 2004 19:38:22 +0000 Subject: [PATCH] new specs have maximum zone visibility --- direct/src/level/SpecUtil.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/direct/src/level/SpecUtil.py b/direct/src/level/SpecUtil.py index 270e41b0d8..34dc337676 100755 --- a/direct/src/level/SpecUtil.py +++ b/direct/src/level/SpecUtil.py @@ -8,12 +8,21 @@ from PythonUtil import list2dict import EntityTypes import types +""" +TO CREATE A NEW SPEC: +import SpecUtil +import FactoryEntityTypes +SpecUtil.makeNewSpec('$TOONTOWN/src/coghq/FactoryMockupSpec.py', 'phase_9/models/cogHQ/SelbotLegFactory', FactoryEntityTypes) +""" def makeNewSpec(filename, modelPath, entTypeModule=EntityTypes): """call this to create a new level spec for the level model at 'modelPath'. Spec will be saved as 'filename'""" spec = LevelSpec.LevelSpec() - privUpdateSpec(spec, modelPath, entTypeModule) - spec.saveToDisk(filename, makeBackup=0) + # make every zone visible from every other zone + privUpdateSpec(spec, modelPath, entTypeModule, newZonesGloballyVisible=1) + # expand any env vars, then convert to an OS-correct path + fname = Filename.expandFrom(filename).toOsSpecific() + spec.saveToDisk(fname, makeBackup=0) print 'Done.' """ @@ -39,8 +48,11 @@ def updateSpec(specModule, entTypeModule=EntityTypes, modelPath=None): spec.saveToDisk() print 'Done.' -def privUpdateSpec(spec, modelPath, entTypeModule): - """internal: take a spec and update it to match its level model""" +def privUpdateSpec(spec, modelPath, entTypeModule, newZonesGloballyVisible=0): + """internal: take a spec and update it to match its level model + If newZonesGloballyVisible is true, any new zones will be added to the + visibility lists for every zone. + """ assert __dev__ assert type(entTypeModule) is types.ModuleType import EntityTypeRegistry @@ -119,6 +131,16 @@ def privUpdateSpec(spec, modelPath, entTypeModule): # by default, new zone can't see any other zones spec.doSetAttrib(entId, 'visibility', []) + if newZonesGloballyVisible: + for entId in zoneEntIds: + visList = list(spec.getEntitySpec(entId)['visibility']) + visDict = list2dict(visList) + for zoneNum in newZoneNums: + visDict[zoneNum] = None + visList = visDict.keys() + visList.sort() + spec.doSetAttrib(entId, 'visibility', visList) + # make sure none of the zones reference removed zones # TODO: prune from other zoneList attribs for entId in zoneEntIds: