def __init__(self, data=None): self.states = {} if IS_AIRPLANE_EDITOR: self.__data = data if data != None: params = (('id', 0), ('componentType', ''), ('componentTypeQuota', 1.0), ('componentXml', ''), ('repairDestructedAfter', -1.0), ('health', '20.0'), ('fireMountPoint', ''), ('componentPosition', 'Front')) if IS_AIRPLANE_EDITOR: self.__params = params readValues(self, data, params) if data.has_key('gunPartName'): readValue(self, data, 'gunPartName', '') if self.health.find('%') == -1: self.healthValue = float(self.health) self.healthPrc = 0.0 else: self.healthPrc = float(self.health[:-1]) / 100.0 self.healthValue = 0.0 self.componentXml = self.componentXml.lower() self.bboxes = BBoxes(findSection(data, 'bBoxes')) statesSection = findSection(data, 'states') if statesSection: for stateData in statesSection.values(): state = PartTypeStateSettings(stateData) self.states[int(state.id)] = state fireSection = findSection(data, 'fire') if fireSection: self.fire = FireStateSettings(fireSection) if not hasattr(self, 'fire'): self.fire = None return
def __init__(self, data=None): if data: params = (('texture', ''), ('mountPoint', '')) readValues(self, data, params) self.scale = data.readVector3('scale') if IS_AIRPLANE_EDITOR: self.ed_data = data self.__params = params
def __init__(self, data): if IS_AIRPLANE_EDITOR: self.__data = data if data: params = (('baseChance', 0.1), ('vMin', 250.0), ('pMin', 1.0), ('vMax', 500.0), ('pMax', 3.0)) if IS_AIRPLANE_EDITOR: self.__params = params readValues(self, data, params)
def readSettings(data): for section in data.values(): settingsClass = CustomSettingsFactory.PART_SETTINGS_DICT.get( section.name, None) if settingsClass is not None: settings = settingsClass(section) readValues(settings, section, settings.params()) return settings return
def __init__(self, data): self.subItems = [] self.effectSettings = None self.affectedParts = [] self.customSettings = {} if IS_AIRPLANE_EDITOR: self.__data = data if data != None: params = (('id', 0), ('usage', ''), ('model', ''), ('animationController', ''), ('stateHelthCfc', 0.0), ('stateFireChance', 0.2), ('stateAction', STATE_ACTION_NONE), ('fallingOutModel', ''), ('stateAnimation', '')) if IS_AIRPLANE_EDITOR: self.__params = params readValues(self, data, params) if self.id == 0: DBLOG_ERROR('state id missed for part') if self.stateHelthCfc < 0 and self.stateHelthCfc != ANIMATION_STATE_HEALTH_K: DBLOG_ERROR('invalid stateHelthCfc') bBoxesData = findSection(data, 'bBoxes') self.bboxes = bBoxesData and BBoxes(bBoxesData) or None affectedPartsData = findSection(data, 'affectedParts') if affectedPartsData: for partData in affectedPartsData.values(): partID = partData.readInt('partID', -1) if partID != -1: minimalPartState = partData.readInt( 'minimalPartState', 1) self.affectedParts.append((partID, minimalPartState)) usagestr = self.usage.lower() self.stateFlag = 0 if usagestr.find(PART_STATE_HANGAR) != -1: self.stateFlag = self.stateFlag | PART_STATE_IDHANGAR if usagestr.find(PART_STATE_CRASH) != -1: self.stateFlag = self.stateFlag | PART_STATE_IDCRASH if usagestr.find(PART_STATE_FALL) != -1: self.stateFlag = self.stateFlag | PART_STATE_IDFALL subItemsSection = findSection(data, 'subItems') if subItemsSection != None: for subItemData in subItemsSection.values(): subItem = PartTypeStateSubItemSettings(subItemData) self.subItems.append(subItem) self.effectSettings = EffectsSettings(data) decalSection = findSection(data, 'groundDecal') if decalSection: self.groundDecal = GroundDecal(decalSection) settings = CustomSettingsFactory.readSettings(data) if settings: self.customSettings[settings.name()] = settings return
def __init__(self, data=None): self.customSettings = {} if IS_AIRPLANE_EDITOR: self.__data = data if data != None: params = (('model', ''), ('mountPoint', ''), ('animatorName', '')) if IS_AIRPLANE_EDITOR: self.__params = params readValue(self, data, 'name', '') readValues(self, data, params) settings = CustomSettingsFactory.readSettings(data) if settings: self.customSettings[settings.name()] = settings return
def __init__(self, data, triggered=False): if data != None: params = (('name', ''), ('mountPoint', ''), ('trigger', '')) readValues(self, data, params) if not triggered: self.trigger = None self.delay = data.readVector2('delay') if data.has_key( 'delay') else None if self.mountPoint.find(PartSettings.currentInitedPart + '/') == 0: mountData = self.mountPoint.split('/') if len(mountData) > 1: self.mountPoint = mountData[1] if IS_AIRPLANE_EDITOR: self.ed_data = data self.__params = params return
def __init__(self, data=None): self.upgrades = {} if IS_AIRPLANE_EDITOR: self.__data = data if data != None: params = (('name', ''), ('partId', 0), ('groupId', 0), ('mountPoint', '')) if IS_AIRPLANE_EDITOR: self.__params = params readValues(self, data, params) PartSettings.currentInitedPart = self.name for sName, sData in data.items(): if sName == 'upgrade': upgrade = PartUpgrade(sData) self.upgrades[upgrade.id] = upgrade return
def __init__(self, data): if IS_AIRPLANE_EDITOR: self.__data = data if data: params = (('extinguish_time', 5.0), ('fire_damage', '2.0'), ('tickLength', 2.0), ('effectFire', ''), ('fire_chance', 0.0)) if IS_AIRPLANE_EDITOR: self.__params = params readValues(self, data, params) if self.fire_damage.find('%') == -1: self.fire_damage = float(self.fire_damage) self.fire_damagePrc = 0.0 else: self.fire_damagePrc = float(self.fire_damage[:-1]) / 100.0 self.fire_damage = 0.0 self.extinguish_chance = FireExtinguishChance( findSection(data, 'extinguish_chance'))
def readData(self, data): params = (('airplaneClasses', ''), ('position', Math.Vector3()), ('rotation', Math.Vector3())) readValues(self, data, params) self.position *= WORLD_SCALING self.airplaneClasses = [ PLANE_TYPE_LETTER[c] for c in self.airplaneClasses.split(' ') if c != '' ]
def readData(self, data, newDatabase): r""" Loads tunes and some other data from XML. For newDatabase structure please refer to \depot runc\game\hammer es\scripts\common\_aircrafts_db.py _aircrafts_db.py is autogenerated from aircrafts.xml Please see Confluence docs for more info. Also please note that flight model params are overloaded from newDatabase, see below at the end of method. """ if data != None: airplaneData = findSection(data, 'Airplane') if airplaneData is None and newDatabase is not None: LOG_ERROR('No Airplane section for last .xml file. Set config_consts.DB_ENABLE_LOG to True for get more information') sys.exit() if IS_EDITOR: self.__data = airplaneData if airplaneData is not None: params = (('name', ''), ('longName', ''), ('model', ''), ('stealthFactor', 1.0), ('collisionDamageCfc', 0.001), ('autoPilotStartAlt', 60.0), ('autoPilotEndAlt', 100.0), ('hudIcoPath', NOT_AVAILABLE), ('iconPath', NOT_AVAILABLE), ('previewIconPath', NOT_AVAILABLE), ('treeIconPath', NOT_AVAILABLE), ('shakingProfile', '')) if IS_EDITOR: self.__params = params readValues(self, airplaneData, params) visualSettingsData = findSection(airplaneData, 'visualSettings') if self.visualSettings: self.visualSettings.readData(visualSettingsData) else: self.visualSettings = AirCraftVisualSettings(visualSettingsData) partsSettingsData = findSection(airplaneData, 'parts') if self.partsSettings: self.partsSettings.readData(partsSettingsData) else: self.partsSettings = PartsTunes(partsSettingsData) if IS_DEVELOPMENT and IS_CELLAPP: try: requiredCritableStatesSet = set([1, 2, 3, 4]) from EntityHelpers import getPartEnum from AvatarCritsSystem import AvatarCritsSystem def checkAffectedPartsMissedStates(upgrade): for state in upgrade.states.itervalues(): for aPartID, aPartMinState in state.affectedParts: aPart = self.partsSettings.getPartByID(aPartID) if aPart: for aUpgrade in aPart.upgrades.itervalues(): if aPartMinState not in set(aUpgrade.states): yield (upgrade.id, aPartID, aUpgrade.id, aPartMinState) else: yield (upgrade.id, aPartID) for part in self.partsSettings.getPartsOnlyList(): for upgrade in part.upgrades.itervalues(): if getPartEnum(upgrade) in AvatarCritsSystem.CRITABLE_PARTS: absentStates = requiredCritableStatesSet.difference(set(upgrade.states)) if absentStates: DBLOG_CRITICAL(part.partId, part.name, 'PARTS_VALIDATION_ERROR critable part has no all required states:', upgrade.id, absentStates) missedStates = list(checkAffectedPartsMissedStates(upgrade)) if missedStates: LOG_ERROR(part.partId, part.name, upgrade.id, 'PARTS_VALIDATION_ERROR part has no such affected states:', missedStates) except Exception as e: import sys LOG_DEBUG_DEV(sys.exc_info()) self.bboxes = BBoxes(findSection(airplaneData, 'bBoxes')) def magnetPoints(section): section = findSection(section, 'magnetPoints') if section: for id, data in section.items(): yield {'position': data.readVector3('position', Math.Vector3()) * WORLD_SCALING, 'weight': data.readFloat('staticMass', 1.0)} self.magnetPoints = tuple(magnetPoints(data)) descriptionData = findSection(airplaneData, 'description') if self.description: self.description.readData(descriptionData) else: self.description = AirCraftDescription(descriptionData) if newDatabase: for aircraft in newDatabase.aircraft: if aircraft.name == self.name.lower(): aircraftData = aircraft break else: aircraftData = None if aircraftData == None: DBLOG_ERROR("No new style database data found for aircraft '" + self.name + ' (' + self.longName + ')' + "', Please check aircrafts.xml and _aircrafts_db.py.") else: DBLOG_NOTE("New style database data available for aircraft '" + self.name + "', Ok.") self.patch(aircraftData) return
def readData(self, data): readValues(self, data, self.__params)