Esempio n. 1
0
 def _readClientOnlyFromXml(self, target, xmlCtx, section, cache=None):
     super(SequenceXmlReader,
           self)._readClientOnlyFromXml(target, xmlCtx, section)
     target.sequenceName = ix.readStringOrNone(xmlCtx, section,
                                               'sequenceName')
     if IS_EDITOR:
         target.name = ix.readStringOrNone(xmlCtx, section, 'name')
Esempio n. 2
0
def _parseDialog(xmlCtx, section, flags):
    dialogID = parseID(xmlCtx, section, 'Specify a dialog ID')
    dialogType = _xml.readString(xmlCtx, section, 'type')
    bSec = _xml.getSubsection(xmlCtx, section, 'buttons')
    submitID = bSec.readString('submit', '')
    cancelID = bSec.readString('cancel', '')
    customID = bSec.readString('custom', '')
    content = {
        'type':
        dialogType,
        'dialogID':
        dialogID,
        'submitID':
        submitID,
        'cancelID':
        cancelID,
        'customID':
        customID,
        'title':
        translation(_xml.readStringOrNone(xmlCtx, section, 'title') or ''),
        'message':
        translation(_xml.readStringOrNone(xmlCtx, section, 'text') or ''),
        'imageUrl':
        _xml.readStringOrNone(xmlCtx, section, 'image') or ''
    }
    parser = _DIALOG_SUB_PARERS.get(dialogType)
    if parser is not None:
        dialog = parser(xmlCtx, section, flags, dialogID, dialogType, content)
    else:
        dialog = tutorial_chapter.PopUp(dialogID, dialogType, content)
    dialog.setActions(
        parseActions(xmlCtx, _xml.getSubsection(xmlCtx, section, 'actions'),
                     flags))
    return dialog
Esempio n. 3
0
 def _readConfig(self, xmlCtx, section):
     self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay')
     self.modelName = _xml.readString(xmlCtx, section, 'modelName')
     self.soundEvent = _xml.readString(xmlCtx, section, 'soundEvent')
     self.speed = _xml.readInt(xmlCtx, section, 'speed')
     self.heights = _xml.readTupleOfPositiveInts(xmlCtx, section, 'heights', 2)
     self.areaLength = _xml.readPositiveFloat(xmlCtx, section, 'areaLength')
     self.areaWidth = _xml.readPositiveFloat(xmlCtx, section, 'areaWidth')
     self.antepositions = _xml.readTupleOfFloats(xmlCtx, section, 'antepositions')
     self.lateropositions = _xml.readTupleOfFloats(xmlCtx, section, 'lateropositions')
     self.bombingMask = tuple((bool(v) for v in _xml.readTupleOfInts(xmlCtx, section, 'bombingMask')))
     if not len(self.antepositions) == len(self.lateropositions) == len(self.bombingMask):
         _xml.raiseWrongSection(xmlCtx, 'bombers number mismatch')
     self.waveFraction = _xml.readPositiveFloat(xmlCtx, section, 'waveFraction')
     self.bombsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'bombsNumber')
     self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr')
     self.tracerKind = _xml.readInt(xmlCtx, section, 'tracerKind')
     self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2)
     self.gravity = _xml.readPositiveFloat(xmlCtx, section, 'gravity')
     self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual')
     self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor')
     self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker')
     self.reusable = _xml.readBool(xmlCtx, section, 'reusable')
     self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0
     self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
Esempio n. 4
0
 def _readConfig(self, xmlCtx, section):
     self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay')
     self.modelName = _xml.readString(xmlCtx, section, 'modelName')
     if IS_CLIENT:
         self.soundEvent = _xml.readString(xmlCtx, section, 'wwsoundEvent')
     self.speed = _xml.readInt(xmlCtx, section, 'speed')
     self.heights = _xml.readTupleOfPositiveInts(xmlCtx, section, 'heights', 2)
     self.areaLength = _xml.readPositiveFloat(xmlCtx, section, 'areaLength')
     self.areaWidth = _xml.readPositiveFloat(xmlCtx, section, 'areaWidth')
     self.antepositions = _xml.readTupleOfFloats(xmlCtx, section, 'antepositions')
     self.lateropositions = _xml.readTupleOfFloats(xmlCtx, section, 'lateropositions')
     self.bombingMask = tuple((bool(v) for v in _xml.readTupleOfInts(xmlCtx, section, 'bombingMask')))
     if not len(self.antepositions) == len(self.lateropositions) == len(self.bombingMask):
         _xml.raiseWrongSection(xmlCtx, 'bombers number mismatch')
     self.waveFraction = _xml.readPositiveFloat(xmlCtx, section, 'waveFraction')
     self.bombsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'bombsNumber')
     self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr')
     self.tracerKind = _xml.readInt(xmlCtx, section, 'tracerKind')
     self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2)
     self.gravity = _xml.readPositiveFloat(xmlCtx, section, 'gravity')
     self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual')
     self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor')
     self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker')
     self.reusable = _xml.readBool(xmlCtx, section, 'reusable')
     self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0
     self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
Esempio n. 5
0
def readSplineConfig(xmlCtx, section, cache):
    """Reads levered suspension section.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param cache: instance of vehicles.Cache.
    :return: instance of SplineConfig or None.
    """
    if section['splineDesc'] is None:
        return
    else:
        return chassis_components.SplineConfig(
            segmentModelLeft=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelLeft'),
            segmentModelRight=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelRight'),
            segmentLength=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentLength'),
            leftDesc=_xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'),
            rightDesc=_xml.readStringOrNone(xmlCtx, section,
                                            'splineDesc/right'),
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            segmentOffset=section.readFloat('splineDesc/segmentOffset', 0),
            segment2ModelLeft=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelLeft'),
            segment2ModelRight=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelRight'),
            segment2Offset=section.readFloat('splineDesc/segment2Offset', 0),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))
def readTrackNodes(xmlCtx, section):
    if section['trackNodes'] is None:
        return component_constants.EMPTY_TUPLE
    else:
        defElasticity = _xml.readFloat(xmlCtx, section, 'trackNodes/elasticity', 1500.0)
        defDamping = _xml.readFloat(xmlCtx, section, 'trackNodes/damping', 1.0)
        defForwardElastK = _xml.readFloat(xmlCtx, section, 'trackNodes/forwardElastK', 1.0)
        defBackwardElastK = _xml.readFloat(xmlCtx, section, 'trackNodes/backwardElastK', 1.0)
        defOffset = _xml.readFloat(xmlCtx, section, 'trackNodes/offset', 0.0)
        trackNodes = []
        xmlCtx = (xmlCtx, 'trackNodes')
        for sname, subsection in _xml.getChildren(xmlCtx, section, 'trackNodes'):
            if sname == 'node':
                ctx = (xmlCtx, 'trackNodes/node')
                name = _xml.readStringOrNone(ctx, subsection, 'leftSibling')
                if name is not None:
                    leftNodeName = intern(name)
                else:
                    leftNodeName = None
                name = _xml.readStringOrNone(ctx, subsection, 'rightSibling')
                if name is not None:
                    rightNodeName = intern(name)
                else:
                    rightNodeName = None
                trackNode = chassis_components.TrackNode(name=intern(_xml.readNonEmptyString(ctx, subsection, 'name')), isLeft=_xml.readBool(ctx, subsection, 'isLeft'), initialOffset=_xml.readFloat(ctx, subsection, 'offset', defOffset), leftNodeName=leftNodeName, rightNodeName=rightNodeName, damping=_xml.readFloat(ctx, subsection, 'damping', defDamping), elasticity=_xml.readFloat(ctx, subsection, 'elasticity', defElasticity), forwardElasticityCoeff=_xml.readFloat(ctx, subsection, 'forwardElastK', defForwardElastK), backwardElasticityCoeff=_xml.readFloat(ctx, subsection, 'backwardElastK', defBackwardElastK))
                trackNodes.append(trackNode)

        return tuple(trackNodes)
Esempio n. 7
0
def readSoundSiegeModeStateChange(xmlCtx, section):
    """Reads soundStateChange section for siege mode.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :return: instance of LeveredSuspensionConfig for levered suspension or None.
    """
    return sound_components.SoundSiegeModeStateChange(
        on=_xml.readStringOrNone(xmlCtx, section, 'soundStateChange/on'),
        off=_xml.readStringOrNone(xmlCtx, section, 'soundStateChange/off'))
 def _readClientOnlyFromXml(self, target, xmlCtx, section, cache=None):
     super(AttachmentXmlReader,
           self)._readClientOnlyFromXml(target, xmlCtx, section)
     target.modelName = ix.readStringOrNone(xmlCtx, section, 'modelName')
     target.sequenceId = ix.readIntOrNone(xmlCtx, section, 'sequenceId')
     target.attachmentLogic = ix.readStringOrNone(xmlCtx, section,
                                                  'attachmentLogic')
     target.initialVisibility = ix.readBool(xmlCtx, section,
                                            'initialVisibility', True)
Esempio n. 9
0
 def _readConfig(self, xmlCtx, section):
     self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay')
     self.duration = _xml.readPositiveFloat(xmlCtx, section, 'duration')
     self.shotsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'shotsNumber')
     self.areaRadius = _xml.readPositiveFloat(xmlCtx, section, 'areaRadius')
     self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr')
     self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2)
     self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual')
     self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor')
     self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker')
     self.areaLength = self.areaWidth = self.areaRadius * 2
     self.reusable = _xml.readBool(xmlCtx, section, 'reusable')
     self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0
     self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
Esempio n. 10
0
 def _readConfig(self, xmlCtx, section):
     self.delay = _xml.readPositiveFloat(xmlCtx, section, 'delay')
     self.duration = _xml.readPositiveFloat(xmlCtx, section, 'duration')
     self.shotsNumber = _xml.readNonNegativeInt(xmlCtx, section, 'shotsNumber')
     self.areaRadius = _xml.readPositiveFloat(xmlCtx, section, 'areaRadius')
     self.shellCompactDescr = _xml.readInt(xmlCtx, section, 'shellCompactDescr')
     self.piercingPower = _xml.readTupleOfPositiveInts(xmlCtx, section, 'piercingPower', 2)
     self.areaVisual = _xml.readStringOrNone(xmlCtx, section, 'areaVisual')
     self.areaColor = _xml.readIntOrNone(xmlCtx, section, 'areaColor')
     self.areaMarker = _xml.readStringOrNone(xmlCtx, section, 'areaMarker')
     self.areaLength = self.areaWidth = self.areaRadius * 2
     self.reusable = _xml.readBool(xmlCtx, section, 'reusable')
     self.cooldownTime = _xml.readNonNegativeFloat(xmlCtx, section, 'cooldownTime') if self.reusable else 0.0
     self.deployTime = _xml.readNonNegativeFloat(xmlCtx, section, 'deployTime')
Esempio n. 11
0
def readRecoilEffect(xmlCtx, section, cache):
    """Reads configuration of gun recoil effect.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :param cache: instance of vehicles.Cache to get desired LoD distance by name.
    :return: instance of RecoilEffect.
    """
    effName = _xml.readStringOrNone(xmlCtx, section, 'recoil/recoilEffect')
    if effName is not None:
        recoilEff = cache.getGunRecoilEffects(effName)
        if recoilEff is not None:
            backoffTime = recoilEff[0]
            returnTime = recoilEff[1]
        else:
            backoffTime = component_constants.ZERO_FLOAT
            returnTime = component_constants.ZERO_FLOAT
    else:
        backoffTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                                'recoil/backoffTime')
        returnTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                               'recoil/returnTime')
    return gun_components.RecoilEffect(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'recoil/lodDist',
                                           cache),
        amplitude=_xml.readNonNegativeFloat(xmlCtx, section,
                                            'recoil/amplitude'),
        backoffTime=backoffTime,
        returnTime=returnTime)
Esempio n. 12
0
def readSplineTrackPairDesc(xmlCtx, section, cache):
    splineSegmentModelSets = {'default': chassis_components.SplineSegmentModelSet(left=_xml.readNonEmptyString(xmlCtx, section, 'segmentModelLeft'), right=_xml.readNonEmptyString(xmlCtx, section, 'segmentModelRight'), secondLeft=_xml.readStringOrNone(xmlCtx, section, 'segment2ModelLeft') or '', secondRight=_xml.readStringOrNone(xmlCtx, section, 'segment2ModelRight') or '')}
    modelSetsSection = section['modelSets']
    if modelSetsSection:
        for sname, subSection in modelSetsSection.items():
            splineSegmentModelSets[sname] = chassis_components.SplineSegmentModelSet(left=_xml.readNonEmptyString(xmlCtx, subSection, 'segmentModelLeft'), right=_xml.readNonEmptyString(xmlCtx, subSection, 'segmentModelRight'), secondLeft=_xml.readStringOrNone(xmlCtx, subSection, 'segment2ModelLeft') or '', secondRight=_xml.readStringOrNone(xmlCtx, subSection, 'segment2ModelRight') or '')

    length = _xml.readFloat(xmlCtx, section, 'segmentLength')
    offset = _xml.readFloat(xmlCtx, section, 'segmentOffset', 0)
    offset2 = _xml.readFloat(xmlCtx, section, 'segment2Offset', 0)
    trackPairIdx = section.readInt('trackPairIdx', 0)
    atlasUTiles = section.readInt('atlas/UTiles', 1)
    atlasVTiles = section.readInt('atlas/VTiles', 1)
    leftDesc = _xml.readStringOrNone(xmlCtx, section, 'left')
    rightDesc = _xml.readStringOrNone(xmlCtx, section, 'right')
    return SplineTrackPairDesc(trackPairIdx, splineSegmentModelSets, leftDesc, rightDesc, length, offset, offset2, atlasUTiles, atlasVTiles)
Esempio n. 13
0
def readRecoilEffect(xmlCtx, section, cache):
    effName = _xml.readStringOrNone(xmlCtx, section, 'recoil/recoilEffect')
    if effName is not None:
        recoilEff = cache.getGunRecoilEffects(effName)
        if recoilEff is not None:
            backoffTime = recoilEff[0]
            returnTime = recoilEff[1]
        else:
            backoffTime = component_constants.ZERO_FLOAT
            returnTime = component_constants.ZERO_FLOAT
    else:
        backoffTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                                'recoil/backoffTime')
        returnTime = _xml.readNonNegativeFloat(xmlCtx, section,
                                               'recoil/returnTime')
    recoil = gun_components.RecoilEffect(
        lodDist=shared_readers.readLodDist(xmlCtx, section, 'recoil/lodDist',
                                           cache),
        amplitude=_xml.readNonNegativeFloat(xmlCtx, section,
                                            'recoil/amplitude'),
        backoffTime=backoffTime,
        returnTime=returnTime)
    if IS_EDITOR:
        recoil.effectName = effName
    return recoil
Esempio n. 14
0
def _readMiscSlot(ctx, subsection, slotType):
    descr = shared_components.MiscSlot(
        type=slotType,
        slotId=_xml.readInt(ctx, subsection, 'slotId'),
        position=_xml.readVector3OrNone(ctx, subsection, 'position'),
        rotation=_xml.readVector3OrNone(ctx, subsection, 'rotation'),
        attachNode=_xml.readStringOrNone(ctx, subsection, 'attachNode'))
    _verifySlotId(ctx, slotType, descr.slotId)
    return descr
Esempio n. 15
0
def _readRequestExclusiveHintEffectSection(xmlCtx, section, _, conditions):
    componentID = sub_parsers.parseID(xmlCtx, section,
                                      'missing hint target component ID')
    soundID = _xml.readStringOrNone(xmlCtx, section, 'sound')
    if soundID is None:
        soundID = 'bc_new_ui_element_button'
    if conditions is None:
        conditions = Conditions()
    conditions.insert(0, ComponentOnSceneCondition(componentID))
    return bc_effects.RequestExclusiveHintEffect(componentID,
                                                 soundID,
                                                 conditions=conditions)
Esempio n. 16
0
 def __init__(self):
     self.reset()
     xmlPath = ''
     self.shells = {}
     self.shells_stunning = {}
     for nation in nations.NAMES:
         xmlPath = '%s%s%s%s' % (ITEM_DEFS_PATH, 'vehicles/', nation, '/components/shells.xml')
         xmlCtx_s = (((None, '{}/{}'.format(xmlPath, n)), s) for n, s in ResMgr.openSection(xmlPath).items() if (n != 'icons') and (n != 'xmlns:xmlref'))
         id_xmlCtx_s = ((_xml.readInt(xmlCtx, s, 'id', 0, 65535), xmlCtx, s) for xmlCtx, s in xmlCtx_s)
         self.shells[nation] = [i for i, xmlCtx, s in id_xmlCtx_s if s.readBool('improved', False)]
         self.shells_stunning[nation] = [i for i, xmlCtx, s in id_xmlCtx_s if _xml.readStringOrNone(xmlCtx, s, 'stunDuration')]
     ResMgr.purge(xmlPath, True)
Esempio n. 17
0
 def __init__(self):
     self.reset()
     xmlPath = ''
     self.shells = {}
     self.shells_stunning = {}
     for nation in nations.NAMES:
         xmlPath = '%s%s%s%s' % (ITEM_DEFS_PATH, 'vehicles/', nation, '/components/shells.xml')
         xmlCtx_s = (((None, '{}/{}'.format(xmlPath, n)), s) for n, s in ResMgr.openSection(xmlPath).items() if (n != 'icons') and (n != 'xmlns:xmlref'))
         id_xmlCtx_s = ((_xml.readInt(xmlCtx, s, 'id', 0, 65535), xmlCtx, s) for xmlCtx, s in xmlCtx_s)
         self.shells[nation] = [i for i, xmlCtx, s in id_xmlCtx_s if s.readBool('improved', False)]
         self.shells_stunning[nation] = [i for i, xmlCtx, s in id_xmlCtx_s if _xml.readStringOrNone(xmlCtx, s, 'stunDuration')]
     ResMgr.purge(xmlPath, True)
Esempio n. 18
0
def readModelsSets(xmlCtx, section, subsectionName):
    undamaged = _xml.readNonEmptyString(xmlCtx, section,
                                        subsectionName + '/undamaged')
    destroyed = _xml.readNonEmptyString(xmlCtx, section,
                                        subsectionName + '/destroyed')
    exploded = _xml.readNonEmptyString(xmlCtx, section,
                                       subsectionName + '/exploded')
    modelsSets = {
        'default':
        shared_components.ModelStatesPaths(undamaged, destroyed, exploded)
    }
    subsection = section[subsectionName]
    if subsection:
        setSection = subsection['sets'] or {}
        for k, v in setSection.items():
            modelsSets[k] = shared_components.ModelStatesPaths(
                _xml.readStringOrNone(xmlCtx, v, 'undamaged') or undamaged,
                _xml.readStringOrNone(xmlCtx, v, 'destroyed') or destroyed,
                _xml.readStringOrNone(xmlCtx, v, 'exploded') or exploded)

    return modelsSets
Esempio n. 19
0
def readTagsOrEmpty(xmlCtx, section, allowedTagNames, subsectionName='tags'):
    tags = _xml.readStringOrNone(xmlCtx, section, subsectionName)
    res = set()
    if tags is not None:
        tagNames = tags.split()
        for tagName in tagNames:
            if tagName not in allowedTagNames:
                _xml.raiseWrongXml(xmlCtx, subsectionName,
                                   "unknown tag '%s'" % tagName)
            res.add(intern(tagName))

    return frozenset(res)
def readGroundNodesAndGroups(xmlCtx, section, cache):
    if section['groundNodes'] is None:
        return (component_constants.EMPTY_TUPLE,
                component_constants.EMPTY_TUPLE, False, None)
    else:
        groundGroups = []
        groundNodes = []
        for sname, subsection in _xml.getChildren(xmlCtx, section,
                                                  'groundNodes'):
            if sname == 'group':
                ctx = (xmlCtx, 'groundNodes/group')
                group = chassis_components.GroundNodeGroup(
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'),
                    nodesTemplate=intern(
                        _xml.readNonEmptyString(ctx, subsection, 'template')),
                    affectedWheelsTemplate=_xml.readStringOrNone(
                        ctx, subsection, 'affectedWheelsTemplate'),
                    nodesCount=_xml.readInt(ctx, subsection, 'count', 1),
                    startIndex=subsection.readInt('startIndex', 0),
                    collisionSamplesCount=subsection.readInt(
                        'collisionSamplesCount', 1),
                    hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode',
                                              False))
                groundGroups.append(group)
            if sname == 'node':
                ctx = (xmlCtx, 'groundNodes/node')
                groundNode = chassis_components.GroundNode(
                    nodeName=intern(
                        _xml.readNonEmptyString(ctx, subsection, 'name')),
                    affectedWheelName=_xml.readStringOrEmpty(
                        ctx, subsection, 'affectedWheelName'),
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    minOffset=_xml.readFloat(ctx, subsection, 'minOffset'),
                    maxOffset=_xml.readFloat(ctx, subsection, 'maxOffset'),
                    collisionSamplesCount=_xml.readInt(
                        ctx, subsection, 'collisionSamplesCount', 1),
                    hasLiftMode=_xml.readBool(ctx, subsection, 'hasLiftMode',
                                              False))
                groundNodes.append(groundNode)

        activePostmortem = _xml.readBool(xmlCtx, section,
                                         'groundNodes/activePostmortem', False)
        lodSettingsSection = section['groundNodes/lodSettings']
        if lodSettingsSection is not None:
            lodSettings = shared_readers.readLodSettings(
                xmlCtx, section['groundNodes'], cache)
        else:
            lodSettings = None
        return (tuple(groundGroups), tuple(groundNodes), activePostmortem,
                lodSettings)
def _readGroupRoles(xmlCtx, section, subsectionName):
    source = _xml.readStringOrNone(xmlCtx, section, subsectionName)
    if source is not None:
        tags = source.split()
        roles = []
        for tag in tags:
            if tag not in skills_constants.ROLES:
                _xml.raiseWrongXml(xmlCtx, subsectionName, 'unknown tag "{}"'.format(tag))
            roles.append(intern(tag))

    else:
        tags = skills_constants.ROLES
    return frozenset(tags)
Esempio n. 22
0
def readTrackNodes(xmlCtx, section):
    """Reads section 'trackNodes' for each chassis if it has.
    :param xmlCtx: tuple(root ctx or None, path to section).
    :param section: instance of DataSection.
    :return: tuple containing TrackNode items.
    """
    if section['trackNodes'] is None:
        return component_constants.EMPTY_TUPLE
    else:
        xmlCtx = (xmlCtx, 'trackNodes')
        trackNodes = []
        defElasticity = section.readFloat('trackNodes/elasticity', 1500.0)
        defDamping = section.readFloat('trackNodes/damping', 1.0)
        defForwardElastK = section.readFloat('trackNodes/forwardElastK', 1.0)
        defBackwardElastK = section.readFloat('trackNodes/backwardElastK', 1.0)
        defOffset = section.readFloat('trackNodes/offset')
        for sname, subsection in _xml.getChildren(xmlCtx, section,
                                                  'trackNodes'):
            if sname == 'node':
                ctx = (xmlCtx, 'trackNodes/node')
                trackNode = chassis_components.TrackNode(
                    name=_xml.readNonEmptyString(ctx, subsection, 'name'),
                    isLeft=_xml.readBool(ctx, subsection, 'isLeft'),
                    initialOffset=subsection.readFloat('offset', defOffset),
                    leftNodeName=_xml.readStringOrNone(ctx, subsection,
                                                       'leftSibling'),
                    rightNodeName=_xml.readStringOrNone(
                        ctx, subsection, 'rightSibling'),
                    damping=subsection.readFloat('damping', defDamping),
                    elasticity=subsection.readFloat('elasticity',
                                                    defElasticity),
                    forwardElasticityCoeff=subsection.readFloat(
                        'forwardElastK', defForwardElastK),
                    backwardElasticityCoeff=subsection.readFloat(
                        'backwardElastK', defBackwardElastK))
                trackNodes.append(trackNode)

        return tuple(trackNodes)
Esempio n. 23
0
def readSplineConfig(xmlCtx, section, cache):
    return None if section[
        'splineDesc'] is None else chassis_components.SplineConfig(
            segmentModelLeft=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelLeft'),
            segmentModelRight=_xml.readNonEmptyString(
                xmlCtx, section, 'splineDesc/segmentModelRight'),
            segmentLength=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentLength'),
            leftDesc=_xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'),
            rightDesc=_xml.readStringOrNone(xmlCtx, section,
                                            'splineDesc/right'),
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            segmentOffset=_xml.readFloat(xmlCtx, section,
                                         'splineDesc/segmentOffset', 0),
            segment2ModelLeft=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelLeft'),
            segment2ModelRight=_xml.readStringOrNone(
                xmlCtx, section, 'splineDesc/segment2ModelRight'),
            segment2Offset=_xml.readFloat(xmlCtx, section,
                                          'splineDesc/segment2Offset', 0),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))
Esempio n. 24
0
def readOrderedTagsOrEmpty(xmlCtx,
                           section,
                           allowedTagValidator,
                           subsectionName='tags'):
    tags = _xml.readStringOrNone(xmlCtx, section, subsectionName)
    res = []
    if tags is not None:
        tagNames = tags.split()
        for tagName in tagNames:
            if not allowedTagValidator(tagName):
                _xml.raiseWrongXml(xmlCtx, subsectionName,
                                   "unknown tag '%s'" % tagName)
            res.append(intern(tagName))

    return tuple(res)
def _readGroupTags(xmlCtx, section, subsectionName):
    source = _xml.readStringOrNone(xmlCtx, section, subsectionName)
    if source is not None:
        tags = source.split()
        restrictions = []
        for tag in tags:
            if not (tag in tankmen_components.GROUP_TAG.RANGE or vehicles.g_list.isVehicleExisting(tag)):
                _xml.raiseWrongXml(xmlCtx, subsectionName, 'unknown tag "{}"'.format(tag))
            if tag in tankmen_components.GROUP_TAG.RESTRICTIONS:
                restrictions.append(tag)

        if restrictions and tankmen_components.GROUP_TAG.PASSPORT_REPLACEMENT_FORBIDDEN not in restrictions:
            _xml.raiseWrongXml(xmlCtx, subsectionName, 'Group contains tags of restrictions {}, so tag "{}" is mandatory'.format(restrictions, tankmen_components.GROUP_TAG.PASSPORT_REPLACEMENT_FORBIDDEN))
    else:
        tags = []
    return frozenset(tags)
Esempio n. 26
0
def _readGroupRoles(xmlCtx, section, subsectionName):
    """
    Returns contents of roles tag group as an immutable subset of ROLES
    :param xmlCtx: xml context for reporting and error handling purposes.
    :param section: group section to read roles section.
    :param subsectionName: name of roles section inside group section.
    :return: subset of ROLES.
    """
    source = _xml.readStringOrNone(xmlCtx, section, subsectionName)
    if source is not None:
        tags = source.split()
        roles = []
        for tag in tags:
            if tag not in skills_constants.ROLES:
                _xml.raiseWrongXml(xmlCtx, subsectionName, 'unknown tag "{}"'.format(tag))
            roles.append(tag)

    else:
        tags = skills_constants.ROLES
    return frozenset(tags)
Esempio n. 27
0
    def __readFilterNodeFromXml(xmlCtx, section):
        fn = cc.VehicleFilter.FilterNode()
        strNations = ix.readStringOrNone(xmlCtx, section, 'nations')
        if strNations:
            r = []
            for nation in strNations.split():
                nationId = nations.INDICES.get(nation)
                if nationId is None:
                    ix.raiseWrongXml(xmlCtx, 'nations',
                                     "unknown nation '%s'" % nation)
                r.append(nationId)

            fn.nations = r
        if section.has_key('levels'):
            fn.levels = ix.readTupleOfPositiveInts(xmlCtx, section, 'levels')
        if section.has_key('vehicles'):
            fn.vehicles = iv._readNationVehiclesByNames(
                xmlCtx, section, 'vehicles', None)
        if section.has_key('tags'):
            fn.tags = iv._readTags(xmlCtx, section, 'tags', 'vehicle')
        return fn
 def _readFromXml(self, target, xmlCtx, section, cache=None):
     super(SequenceXmlReader, self)._readFromXml(target, xmlCtx, section)
     target.sequenceName = ix.readStringOrNone(xmlCtx, section,
                                               'sequenceName')
def readSoundSiegeModeStateChange(xmlCtx, section):
    return sound_components.SoundSiegeModeStateChange(
        on=_xml.readStringOrNone(xmlCtx, section, 'soundStateChange/on'),
        off=_xml.readStringOrNone(xmlCtx, section, 'soundStateChange/off'))
Esempio n. 30
0
 def isStunningShell(n, s):
     if n != 'icons':
         xmlCtx = (None, xmlPath + '/' + n)
         stunDuration = _xml.readStringOrNone(xmlCtx, s, 'stunDuration')
         return _xml.readInt(xmlCtx, s, 'id', 0, 65535) if stunDuration else None
 def _readFromXml(self, target, xmlCtx, section, cache=None):
     super(AttachmentXmlReader, self)._readFromXml(target, xmlCtx, section)
     target.modelName = ix.readStringOrNone(xmlCtx, section, 'modelName')
def readSplineConfig(xmlCtx, section, cache):
    if not section.has_key('splineDesc'):
        return
    else:
        splineSegmentModelSets = {
            'default':
            chassis_components.SplineSegmentModelSet(
                left=_xml.readNonEmptyString(xmlCtx, section,
                                             'splineDesc/segmentModelLeft'),
                right=_xml.readNonEmptyString(xmlCtx, section,
                                              'splineDesc/segmentModelRight'),
                secondLeft=_xml.readStringOrNone(
                    xmlCtx, section, 'splineDesc/segment2ModelLeft') or '',
                secondRight=_xml.readStringOrNone(
                    xmlCtx, section, 'splineDesc/segment2ModelRight') or '')
        }
        modelSetsSection = section['splineDesc/modelSets']
        if modelSetsSection:
            for sname, subSection in modelSetsSection.items():
                splineSegmentModelSets[
                    sname] = chassis_components.SplineSegmentModelSet(
                        left=_xml.readNonEmptyString(xmlCtx, subSection,
                                                     'segmentModelLeft'),
                        right=_xml.readNonEmptyString(xmlCtx, subSection,
                                                      'segmentModelRight'),
                        secondLeft=_xml.readStringOrNone(
                            xmlCtx, subSection, 'segment2ModelLeft') or '',
                        secondRight=_xml.readStringOrNone(
                            xmlCtx, subSection, 'segment2ModelRight') or '')

        leftDescs = []
        rightDescs = []
        multipleTracks = section['splineDesc/multipleTracks']
        if multipleTracks is not None:
            for node in multipleTracks.items():
                desc = _xml.readNonEmptyString(xmlCtx, node[1], 'desc')
                pairIdx = _xml.readNonNegativeInt(xmlCtx, node[1],
                                                  'trackPairIdx')
                length = _xml.readFloat(xmlCtx, node[1], 'segmentLength')
                offset = _xml.readFloat(xmlCtx, node[1], 'segmentOffset', 0)
                offset2 = _xml.readFloat(xmlCtx, node[1], 'segment2Offset', 0)
                descList = [desc, pairIdx, length, offset, offset2]
                if node[0] == 'left':
                    leftDescs.append(descList)
                if node[0] == 'right':
                    rightDescs.append(descList)

        else:
            length = _xml.readFloat(xmlCtx, section,
                                    'splineDesc/segmentLength')
            offset = _xml.readFloat(xmlCtx, section,
                                    'splineDesc/segmentOffset', 0)
            offset2 = _xml.readFloat(xmlCtx, section,
                                     'splineDesc/segment2Offset', 0)
            leftTuple = [
                _xml.readStringOrNone(xmlCtx, section, 'splineDesc/left'), 0,
                length, offset, offset2
            ]
            rightTuple = [
                _xml.readStringOrNone(xmlCtx, section, 'splineDesc/right'), 0,
                length, offset, offset2
            ]
            leftDescs.append(leftTuple)
            rightDescs.append(rightTuple)
        return chassis_components.SplineConfig(
            segmentModelSets=splineSegmentModelSets,
            leftDesc=leftDescs,
            rightDesc=rightDescs,
            lodDist=shared_readers.readLodDist(xmlCtx, section,
                                               'splineDesc/lodDist', cache),
            atlasUTiles=section.readInt('splineDesc/atlas/UTiles', 1),
            atlasVTiles=section.readInt('splineDesc/atlas/VTiles', 1))