def _readPointList(xmlCtx, section): result = [] for _, ((stateCompXmlCtx, _), point) in _xml.getItemsWithContext(xmlCtx, section, 'point'): result.append(point.asVector3) return result
def _readVisualSettings(): ctx = (None, CONFIG_FILE + '/' + BORDER_VISUAL_TAG) settings = ResMgr.openSection(CONFIG_FILE)[BORDER_VISUAL_TAG] return VisualSetting( modelPath=_xml.readString(ctx, settings, 'modelPath'), overTerrainHeight=_xml.readFloat(ctx, settings, 'overTerrainHeight'), modelSettings={ getattr(SECTOR_EDGE_STATE, item[1][1]['edgeState'].asString.upper()): _readModelSetting(*item[1]) for item in _xml.getItemsWithContext(ctx, settings, 'modelSetting') if SECTOR_EDGE_STATE.hasKey(item[1][1] ['edgeState'].asString.upper()) })
def init(): global g_destructibleEntitiesCache g_destructibleEntitiesCache = DestructibleEntitiesCache() xmlPath = 'scripts/item_defs/destructible_entities.xml' section = ResMgr.openSection(xmlPath) if section is None: _xml.raiseWrongXml(None, xmlPath, 'can not open or read') xmlCtx = (None, xmlPath) for _, (typeXmlCtx, typeSection) in _xml.getItemsWithContext(xmlCtx, section, 'type'): destructibleEntityType = _readType(typeXmlCtx, typeSection) if g_destructibleEntitiesCache.getDestructibleEntityType(destructibleEntityType.id) is not None: _xml.raiseWrongXml(typeXmlCtx, 'id', 'duplicate id' % destructibleEntityType.id) g_destructibleEntitiesCache.addDestructibleEntityType(destructibleEntityType) if IS_CLIENT: _readDestructibleEntitiesEffects('scripts/destructible_entity_effects.xml') return
def _readMaterials(parentXmlCtx, section): materials = {} if IS_BASEAPP or IS_BOT: return materials else: for matName, (xmlCtx, matSection) in _xml.getItemsWithContext(parentXmlCtx, section): matKind = material_kinds.IDS_BY_NAMES.get(matName) if matKind is None: _xml.raiseWrongXml(xmlCtx, matName, 'material kind name is unknown') if matKind in materials: _xml.raiseWrongXml(xmlCtx, matName, 'duplicate material kind') effectMaterialName = _xml.readString(xmlCtx, matSection, 'effectMaterial') effectMaterialIdx = EFFECT_MATERIAL_INDEXES_BY_NAMES.get(effectMaterialName) if effectMaterialIdx is None: _xml.raiseWrongXml(xmlCtx, matName, 'Unknown effect material %s' % effectMaterialName) materials[matKind] = DestructibleMaterialInfo(kind=matKind, armor=_xml.readInt(xmlCtx, matSection, 'armor'), extra=None, vehicleDamageFactor=_xml.readFraction(xmlCtx, matSection, 'vehicleDamageFactor'), useHitAngle=_xml.readBool(xmlCtx, matSection, 'useHitAngle'), mayRicochet=_xml.readBool(xmlCtx, matSection, 'mayRicochet'), collideOnceOnly=True, checkCaliberForRichet=_xml.readBool(xmlCtx, matSection, 'checkCaliberForRichet'), checkCaliberForHitAngleNorm=_xml.readBool(xmlCtx, matSection, 'checkCaliberForHitAngleNorm'), effectMaterialIdx=effectMaterialIdx) return materials
def __readDebrisParams(xmlCtx, section, cache): result = [None, None] for name, (ctx, subSection) in _xml.getItemsWithContext(xmlCtx, section, 'trackDebris'): isLeft = _xml.readBool(ctx, subSection, 'isLeft') idx = 0 if isLeft else 1 if result[idx] is not None: _xml.raiseWrongXml(ctx, name, 'isLeft is the same') destructionEffect = _xml.readStringOrEmpty(ctx, subSection, 'destructionEffect') physicalParams = None if subSection['physicalParams'] is not None: hingeJointStiffness = _xml.readFloat(ctx, subSection, 'physicalParams/hingeJointStiffness') physicalParams = chassis_components.PhysicalTrackDebrisParams(hingeJointStiffness) nodesRemap = {} for key, value in subSection.items(): if key == 'remapNode': nodeName = _xml.readString(ctx, value, 'from') remapNode = _xml.readString(ctx, value, 'to') nodesRemap[nodeName] = remapNode result[idx] = chassis_components.TrackDebrisParams(destructionEffect, physicalParams, cache.getVehicleEffect(destructionEffect), nodesRemap) return chassis_components.TrackPairDebris(result[0], result[1]) if result[0] and result[1] else None