mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
new specs have maximum zone visibility
This commit is contained in:
parent
6aaa15f2f2
commit
b8d6318584
@ -8,12 +8,21 @@ from PythonUtil import list2dict
|
|||||||
import EntityTypes
|
import EntityTypes
|
||||||
import types
|
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):
|
def makeNewSpec(filename, modelPath, entTypeModule=EntityTypes):
|
||||||
"""call this to create a new level spec for the level model at 'modelPath'.
|
"""call this to create a new level spec for the level model at 'modelPath'.
|
||||||
Spec will be saved as 'filename'"""
|
Spec will be saved as 'filename'"""
|
||||||
spec = LevelSpec.LevelSpec()
|
spec = LevelSpec.LevelSpec()
|
||||||
privUpdateSpec(spec, modelPath, entTypeModule)
|
# make every zone visible from every other zone
|
||||||
spec.saveToDisk(filename, makeBackup=0)
|
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.'
|
print 'Done.'
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -39,8 +48,11 @@ def updateSpec(specModule, entTypeModule=EntityTypes, modelPath=None):
|
|||||||
spec.saveToDisk()
|
spec.saveToDisk()
|
||||||
print 'Done.'
|
print 'Done.'
|
||||||
|
|
||||||
def privUpdateSpec(spec, modelPath, entTypeModule):
|
def privUpdateSpec(spec, modelPath, entTypeModule, newZonesGloballyVisible=0):
|
||||||
"""internal: take a spec and update it to match its level model"""
|
"""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 __dev__
|
||||||
assert type(entTypeModule) is types.ModuleType
|
assert type(entTypeModule) is types.ModuleType
|
||||||
import EntityTypeRegistry
|
import EntityTypeRegistry
|
||||||
@ -119,6 +131,16 @@ def privUpdateSpec(spec, modelPath, entTypeModule):
|
|||||||
# by default, new zone can't see any other zones
|
# by default, new zone can't see any other zones
|
||||||
spec.doSetAttrib(entId, 'visibility', [])
|
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
|
# make sure none of the zones reference removed zones
|
||||||
# TODO: prune from other zoneList attribs
|
# TODO: prune from other zoneList attribs
|
||||||
for entId in zoneEntIds:
|
for entId in zoneEntIds:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user