Go to the documentation of this file.00001 import BigWorld
00002
00003
00004 class SpaceLoader( BigWorld.Base ):
00005 def __init__( self ):
00006 self.spaceDir = self.cellData[ "geometry" ]
00007 print "SpaceLoader", self.id, "geometry =", self.spaceDir, "spaceId=", self.cellData['spaceID']
00008
00009
00010
00011
00012 if self.isDefault:
00013 self.createInDefaultSpace()
00014 else:
00015 self.createInNewSpace()
00016
00017 def onGetCell( self ):
00018 print "SpaceLoader.onGetCell loading space", self.spaceDir
00019 BigWorld.fetchEntitiesFromChunks(self.spaceDir, EntityLoader(self))
00020
00021 def onLoseCell(self):
00022 print "SpaceLoader", self.spaceDir, " destroyed"
00023 self.destroy()
00024
00025
00026 class EntityLoader:
00027 def __init__( self, spaceLoader ):
00028 self.spaceLoader = spaceLoader
00029
00030 def onSection( self, entity, matrix ):
00031 entityType = entity.readString( "type" )
00032 properties = entity[ "properties" ]
00033 pos = matrix.applyToOrigin()
00034
00035 print "SpaceLoader.EntityLoader() creating entity, type=%s" % (entityType)
00036
00037
00038 base = BigWorld.createBaseAnywhere( entityType,
00039 properties,
00040 spawnerCellMb = self.spaceLoader.cell,
00041 position = pos,
00042 direction = (matrix.roll, matrix.pitch, matrix.yaw) )
00043
00044 if entityType == 'Spawn':
00045 base.position = pos
00046 base.direction = (matrix.roll, matrix.pitch, matrix.yaw)
00047
00048
00049 def onFinish( self ):
00050 print "Finished loading entities for space, destroying SpaceLoader for ", self.spaceLoader.spaceDir
00051 self.spaceLoader.destroyCellEntity()
00052