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
def _readState(xmlCtx, section): state = DestructibleEntityState() for _, (stateCompXmlCtx, stateCompSection) in _xml.getChildrenWithContext(xmlCtx, section, 'components'): state.addComponent(*_readStateComponent(stateCompXmlCtx, stateCompSection)) if IS_CLIENT: effect = section.readString('effect', '') if effect == '': effect = None state.setClientProperties(effect) return (_xml.readString(xmlCtx, section, 'name'), state)
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