Ejemplo n.º 1
0
 def writeGroundNode(curGroup, curSection):
     _xml.rewriteString(curSection, 'template', curGroup.nodesTemplate)
     _xml.rewriteInt(curSection, 'startIndex', curGroup.startIndex)
     _xml.rewriteInt(curSection, 'count', curGroup.nodesCount)
     _xml.rewriteBool(curSection, 'isLeft', curGroup.isLeft)
     _xml.rewriteFloat(curSection, 'minOffset', curGroup.minOffset)
     _xml.rewriteFloat(curSection, 'maxOffset', curGroup.maxOffset)
Ejemplo n.º 2
0
def writeSwingingSettings(item, section):

    def paramsToString(floatTuple):
        return ' '.join([ '{:.2f}'.format(x) for x in floatTuple ])

    _xml.rewriteFloat(section, 'sensitivityToImpulse', item.sensitivityToImpulse)
    _xml.rewriteString(section, 'pitchParams', paramsToString(item.pitchParams))
    _xml.rewriteString(section, 'rollParams', paramsToString(item.rollParams))
Ejemplo n.º 3
0
def writeTrackBasicParams(trackBasicParams, section, cache):
    if trackBasicParams is None:
        return
    else:
        shared_writers.writeLodDist(trackBasicParams.lodDist, section, 'tracks/lodDist', cache)
        _xml.rewriteString(section, 'tracks/leftMaterial', trackBasicParams.leftMaterial)
        _xml.rewriteString(section, 'tracks/rightMaterial', trackBasicParams.rightMaterial)
        _xml.rewriteFloat(section, 'tracks/textureScale', trackBasicParams.textureScale)
        return
Ejemplo n.º 4
0
def writeProjectionSlots(slotDS, slot):
    slotDS.write('compatibleModels', ' '.join(slot.compatibleModels))
    slotDS.write('position', slot.position)
    slotDS.write('rotation', slot.rotation)
    slotDS.write('scale', slot.scale)
    slotDS.write('showOn', slot.showOn)
    if slot.type != 'fixedProjectionDecal':
        slotDS.write('verticalMirror', slot.canBeMirroredVertically)
    _xml.rewriteBool(slotDS, 'doubleSided', slot.doubleSided, False)
    _xml.rewriteBool(slotDS, 'hiddenForUser', slot.hiddenForUser, False)
    _xml.rewriteFloat(slotDS, 'clipAngle', slot.clipAngle, 0.0)
    if slot.type == 'projectionDecal':
        writeProjectionSlotsNotFixed(slotDS, slot)
    elif slot.type == 'fixedProjectionDecal':
        writeProjectionSlotsFixed(slotDS, slot)
Ejemplo n.º 5
0
def __writeDebris(tracksDebris, section):
    if tracksDebris is None:
        return
    else:
        for sname, subsection in section.items():
            if sname != 'trackDebris':
                continue
            isLeft = _xml.readBool(None, subsection, 'isLeft', True)
            tracksDebrisParams = tracksDebris.left if isLeft else tracksDebris.right
            if tracksDebrisParams is not None:
                _xml.rewriteString(subsection, 'destructionEffect', tracksDebrisParams.destructionEffect)
                physicalParams = tracksDebrisParams.physicalParams
                if physicalParams is not None and physicalParams.hingeJointStiffness is not None:
                    _xml.rewriteFloat(subsection, 'physicalParams/hingeJointStiffness', physicalParams.hingeJointStiffness)

        return
Ejemplo n.º 6
0
def writeHullAimingSound(hullAimingSound, section, cache):
    if hullAimingSound is None:
        return _xml.deleteAndCleanup(section, 'hullAiming/audio')
    else:
        changed = False
        audioKey = 'hullAiming/audio/'
        changed |= shared_writers.writeLodDist(hullAimingSound.lodDist,
                                               section, audioKey + 'lodDist',
                                               cache)
        changed |= _xml.rewriteFloat(
            section, audioKey + 'angleLimitValue',
            math.degrees(hullAimingSound.angleLimitValue))
        soundsKey = audioKey + 'sounds/'
        soundsDS = _xml.ListRewriter(section, soundsKey + '*')
        for sound in hullAimingSound.sounds:
            soundDS = soundsDS.next(
                preferredPredicate=lambda ds, snd=sound: ds.name == snd.state,
                path=soundsKey + sound.state)
            changed |= _xml.rewriteString(soundDS,
                                          'underLimitSounds/wwsoundPC',
                                          sound.underLimitSounds.PC)
            changed |= _xml.rewriteString(soundDS,
                                          'underLimitSounds/wwsoundNPC',
                                          sound.underLimitSounds.NPC)
            changed |= _xml.rewriteString(soundDS, 'overLimitSounds/wwsoundPC',
                                          sound.overLimitSounds.PC)
            changed |= _xml.rewriteString(soundDS,
                                          'overLimitSounds/wwsoundNPC',
                                          sound.overLimitSounds.NPC)

        changed |= soundsDS.flush()
        return changed
def writeProjectionSlots(slotDS, slot):
    slotDS.write('compatibleModels', ' '.join(slot.compatibleModels))
    slotDS.write('position', slot.position)
    slotDS.write('rotation', slot.rotation)
    slotDS.write('scale', slot.scale)
    slotDS.write('showOn', slot.showOn)
    slotDS.write('verticalMirror', slot.canBeMirroredVertically)
    _xml.rewriteBool(slotDS, 'doubleSided', slot.doubleSided, False)
    _xml.rewriteFloat(slotDS, 'clipAngle', slot.clipAngle, 0.0)
    if slot.attachedParts is not None and len(slot.attachedParts) != 0:
        if not isinstance(slot.attachedParts, set):
            partTypeToNames = slot.attachedParts.items()
            partTypeToName = ((pType, pName) for pType, pNames in partTypeToNames for pName in pNames)
            attachedParts = ' '.join((':'.join((str(pType), pName)) for pType, pName in partTypeToName))
            if attachedParts:
                slotDS.write('attachedPart', attachedParts)
    if slot.type == 'projectionDecal':
        writeProjectionSlotsNotFixed(slotDS, slot)
    elif slot.type == 'fixedProjectionDecal':
        writeProjectionSlotsFixed(slotDS, slot)
    return
Ejemplo n.º 8
0
def writeProjectionSlots(slotDS, slot):
    if slot.type == 'projectionDecal':
        slotDS.write('tags', ' '.join(slot.tags))
    if len(slot.compatibleModels) == 1 and slot.compatibleModels[0] == 'default':
        slotDS.deleteSection('compatibleModels')
    else:
        slotDS.write('compatibleModels', ' '.join(slot.compatibleModels))
    slotDS.write('position', slot.position)
    slotDS.write('rotation', slot.rotation)
    slotDS.write('scale', slot.scale)
    _xml.rewriteBool(slotDS, 'doubleSided', slot.doubleSided, False)
    _xml.rewriteBool(slotDS, 'hiddenForUser', slot.hiddenForUser, False)
    slotDS.write('showOn', slot.showOn)
    _xml.rewriteFloat(slotDS, 'clipAngle', slot.clipAngle, None)
    _xml.rewriteBool(slotDS, 'verticalMirror', slot.canBeMirroredVertically, False)
    if slot.type == 'projectionDecal':
        slotDS.write('anchorShift', slot.anchorShift)
    elif slot.type == 'fixedProjectionDecal':
        slotDS.write('itemId', slot.itemId)
        slotDS.write('options', slot.options)
    return
Ejemplo n.º 9
0
def writeWheelsAndGroups(wheelsConfig, section):
    wheelId = 0
    groupId = 0
    defSyncAngle = section.readFloat('wheels/leadingWheelSyncAngle', 60)
    for sname, subsection in _xml.getChildren(None, section, 'wheels'):
        if sname == 'group':
            group = wheelsConfig.groups[groupId]
            _xml.rewriteString(subsection, 'template', group.template)
            _xml.rewriteInt(subsection, 'count', group.count, 1)
            _xml.rewriteInt(subsection, 'startIndex', group.startIndex, 0)
            _xml.rewriteFloat(subsection, 'radius', group.radius)
            groupId += 1
        if sname == 'wheel':
            from items.vehicles import _writeHitTester, _writeArmor
            index = _xml.readIntOrNone(None, subsection, 'index')
            if index is not None:
                wheelId = index
            wheel = wheelsConfig.wheels[wheelId]
            radiusKey = 'radius' if subsection.has_key('radius') else 'geometry/radius'
            _xml.rewriteInt(subsection, 'index', wheelId, createNew=False)
            _xml.rewriteFloat(subsection, radiusKey, wheel.radius)
            _xml.rewriteString(subsection, 'name', wheel.nodeName)
            _xml.rewriteBool(subsection, 'isLeading', wheel.isLeading)
            _xml.rewriteFloat(subsection, 'syncAngle', wheel.leadingSyncAngle, defSyncAngle)
            _xml.rewriteVector3(subsection, 'wheelPos', wheel.position, Vector3(0, 0, 0))
            _writeHitTester(wheel.hitTester, None, subsection, 'hitTester')
            _writeArmor(wheel.materials, None, subsection, 'armor', optional=True, index=wheelId)
            wheelId += 1

    return
Ejemplo n.º 10
0
 def writeTrackNode(curNode, curSection):
     _xml.rewriteBool(curSection, 'isLeft', curNode.isLeft)
     _xml.rewriteString(curSection, 'name', curNode.name)
     _xml.rewriteFloat(curSection, 'forwardElastK', curNode.forwardElasticityCoeff, defForwardElastK)
     _xml.rewriteFloat(curSection, 'backwardElastK', curNode.backwardElasticityCoeff, defBackwardElastK)
     _xml.rewriteFloat(curSection, 'offset', curNode.initialOffset, defOffset)
     if curNode.leftNodeName:
         _xml.rewriteString(curSection, 'leftSibling', curNode.leftNodeName)
     if curNode.rightNodeName:
         _xml.rewriteString(curSection, 'rightSibling', curNode.rightNodeName)
Ejemplo n.º 11
0
def writeRecoilEffect(item, section, cache):
    if item.effectName != 'none':
        _xml.rewriteString(section, 'recoilEffect', item.effectName)
        section.deleteSection('backoffTime')
        section.deleteSection('returnTime')
    else:
        _xml.rewriteFloat(section, 'backoffTime', item.backoffTime)
        _xml.rewriteFloat(section, 'returnTime', item.returnTime)
        section.deleteSection('recoilEffect')
    _xml.rewriteFloat(section, 'amplitude', item.amplitude)
    shared_writers.writeLodDist(item.lodDist, section, 'lodDist', cache)
Ejemplo n.º 12
0
 def __encodeValue(self, section, key, value, fieldType):
     if fieldType.type == FieldTypes.VARINT:
         return _xml.rewriteInt(section, key, value)
     if fieldType.type == FieldTypes.FLOAT:
         return _xml.rewriteFloat(section, key, value)
     if fieldType.type == FieldTypes.APPLY_AREA_ENUM:
         if fieldType.flags & FieldFlags.SAVE_AS_STRING:
             return _xml.rewriteString(section, key, encodeFlagEnum(ApplyArea, value).upper())
         return _xml.rewriteInt(section, key, value)
     if fieldType.type == FieldTypes.TAGS:
         return _xml.rewriteString(section, key, ' '.join(value))
     if fieldType.type == FieldTypes.STRING:
         return _xml.rewriteString(section, key, value)
     if fieldType.type == FieldTypes.OPTIONS_ENUM:
         return _xml.rewriteInt(section, key, value)
     if fieldType.type & FieldTypes.TYPED_ARRAY:
         ft = fieldType._asdict()
         ft['type'] ^= FieldTypes.TYPED_ARRAY
         return self.__encodeArray(section, key, value, FieldType(**ft))
     if fieldType.type >= FieldTypes.CUSTOM_TYPE_OFFSET:
         return self.__encodeCustomType(section, key, value)
     raise SerializationException('Unsupported field type %d' % (fieldType.type,))
Ejemplo n.º 13
0
 def writeOneSectionParams(item, sect):
     segment2ModelLeft = item.segment2ModelLeft()
     segment2ModelRight = item.segment2ModelRight()
     _xml.rewriteString(sect, 'segmentModelLeft', item.segmentModelLeft())
     _xml.rewriteString(sect, 'segmentModelRight', item.segmentModelRight())
     if segment2ModelLeft is not None:
         _xml.rewriteString(sect, 'segment2ModelLeft', segment2ModelLeft)
     if segment2ModelRight is not None:
         _xml.rewriteString(sect, 'segment2ModelRight', segment2ModelRight)
     _xml.rewriteString(sect, 'left', item.leftDesc[0][0])
     _xml.rewriteString(sect, 'right', item.rightDesc[0][0])
     _xml.rewriteFloat(sect, 'segmentLength', item.editorData.leftDesc[0][2])
     _xml.rewriteFloat(sect, 'segmentOffset', item.editorData.leftDesc[0][3])
     if item.editorData.leftDesc[0][4] != 0.0:
         _xml.rewriteFloat(sect, 'segment2Offset', item.editorData.leftDesc[0][4])
     shared_writers.writeLodDist(item.lodDist, sect, 'lodDist', cache)
     _xml.rewriteInt(sect, 'atlas/UTiles', item.atlasUTiles)
     _xml.rewriteInt(sect, 'atlas/VTiles', item.atlasVTiles)
     return
Ejemplo n.º 14
0
 def writeTrackPairParams(item, section):
     segment2ModelLeft = item.segment2ModelLeft()
     segment2ModelRight = item.segment2ModelRight()
     _xml.rewriteInt(section, 'trackPairIdx', item.trackPairIdx, 0)
     _xml.rewriteString(section, 'segmentModelLeft', item.segmentModelLeft())
     _xml.rewriteString(section, 'segmentModelRight', item.segmentModelRight())
     if segment2ModelLeft is not None:
         _xml.rewriteString(section, 'segment2ModelLeft', segment2ModelLeft)
     if segment2ModelRight is not None:
         _xml.rewriteString(section, 'segment2ModelRight', segment2ModelRight)
     _xml.rewriteString(section, 'left', item.leftDesc)
     _xml.rewriteString(section, 'right', item.rightDesc)
     _xml.rewriteFloat(section, 'segmentLength', item.segmentLength)
     _xml.rewriteFloat(section, 'segmentOffset', item.segmentOffset)
     if item.segment2Offset != 0.0:
         _xml.rewriteFloat(section, 'segment2Offset', item.segment2Offset)
     _xml.rewriteInt(section, 'atlas/UTiles', item.atlasUTiles)
     _xml.rewriteInt(section, 'atlas/VTiles', item.atlasVTiles)
     return
Ejemplo n.º 15
0
 def rewritePartRotation(section, partName, value):
     return _xml.rewriteFloat(section, partName, value)
Ejemplo n.º 16
0
 def writeEffectValue(effectSection, type, value):
     result = _xml.rewriteString(effectSection, 'type', type)
     result |= _xml.rewriteFloat(effectSection, 'value', value)
     return result
Ejemplo n.º 17
0
def __writeTrackPairParams(trackPairParams, section):
    _xml.rewriteString(section, 'leftMaterial', trackPairParams.leftMaterial)
    _xml.rewriteString(section, 'rightMaterial', trackPairParams.rightMaterial)
    _xml.rewriteFloat(section, 'textureScale', trackPairParams.textureScale)
    __writeDebris(trackPairParams.tracksDebris, section)
Ejemplo n.º 18
0
def writeTrackSplineParams(trackSplineParams, section):
    if trackSplineParams is None:
        return
    else:
        if not section.has_key('trackNodes'):
            section.createSection('trackNodes')
        _xml.rewriteFloat(section, 'trackThickness',
                          trackSplineParams.thickness)
        _xml.rewriteBool(section, 'trackNodes/enable',
                         trackSplineParams.editorData._enable)
        _xml.rewriteBool(section, 'trackNodes/linkBones',
                         trackSplineParams.editorData.linkBones)
        _xml.rewriteFloat(section, 'trackNodes/maxAmplitude',
                          trackSplineParams.maxAmplitude)
        _xml.rewriteFloat(section, 'trackNodes/maxOffset',
                          trackSplineParams.maxOffset)
        _xml.rewriteFloat(section, 'trackNodes/gravity',
                          trackSplineParams.gravity)
        _xml.rewriteFloat(section, 'trackNodes/elasticity',
                          trackSplineParams.editorData.elasticity)
        _xml.rewriteFloat(section, 'trackNodes/damping',
                          trackSplineParams.editorData.damping)
        return