def _readType(xmlCtx, section):
    id = section.readInt('id', -1)
    displayName = section.readString('display_name')
    health = section.readFloat('health', 100)
    destroyedNotificationRadius = section.readFloat(
        'destroyedNotificationRadius', 0)
    materials = _readMaterials(
        *_xml.getSubSectionWithContext(xmlCtx, section, 'materials'))
    observationPoints = _readPointList(
        *_xml.getSubSectionWithContext(xmlCtx, section, 'observationPoints'))
    observedPoints = _readPointList(
        *_xml.getSubSectionWithContext(xmlCtx, section, 'observedPoints'))
    directVisionRadius = section.readFloat('directVisionRadius', 0)
    normalRadioDistance = section.readFloat('normalRadioDistance', 0)
    destructibleEntityType = DestructibleEntityType(
        id,
        displayName,
        health,
        destroyedNotificationRadius,
        materials,
        observationPoints=observationPoints,
        observedPoints=observedPoints,
        directVisionRadius=directVisionRadius,
        normalRadioDistance=normalRadioDistance)
    for _, (stateXmlCtx, stateSection) in _xml.getChildrenWithContext(
            xmlCtx, section, 'states'):
        destructibleEntityType.addState(*_readState(stateXmlCtx, stateSection))

    return destructibleEntityType
Ejemplo n.º 2
0
def _readType(xmlCtx, section):
    id = section.readInt('id', -1)
    displayName = section.readString('display_name')
    health = section.readFloat('health', 100)
    destroyedNotificationRadius = section.readFloat('destroyedNotificationRadius', 0)
    materials = _readMaterials(*_xml.getSubSectionWithContext(xmlCtx, section, 'materials'))
    destructibleEntityType = DestructibleEntityType(id, displayName, health, destroyedNotificationRadius, materials)
    for _, (stateXmlCtx, stateSection) in _xml.getChildrenWithContext(xmlCtx, section, 'states'):
        destructibleEntityType.addState(*_readState(stateXmlCtx, stateSection))

    return destructibleEntityType
Ejemplo n.º 3
0
def _readRepairSpeedLimiter(xmlCtx, section):
    if not section.has_key('repairSpeedLimiter'):
        return None
    else:
        ctx, subsection = _xml.getSubSectionWithContext(
            xmlCtx, section, 'repairSpeedLimiter')
        repairSpeedModifier = _xml.readNonNegativeFloat(
            ctx, subsection, 'repairSpeedModifier')
        return {
            'repairSpeedModifier':
            repairSpeedModifier,
            'speedToStartLimitedRepair':
            component_constants.KMH_TO_MS * _xml.readNonNegativeFloat(
                ctx, subsection, 'speedToStartLimitedRepair'),
            'speedToStopLimitedRepair':
            component_constants.KMH_TO_MS * _xml.readNonNegativeFloat(
                ctx, subsection, 'speedToStopLimitedRepair'),
            'repairMode':
            DeviceRepairMode.SLOWED
            if repairSpeedModifier > 0.0 else DeviceRepairMode.SUSPENDED
        }