def __createOutfit(self, season, vehicleCD='', diff=None):
     component = deepcopy(self.descriptor.outfits[season])
     vehDescr = None
     if vehicleCD:
         vehDescr = VehicleDescr(vehicleCD)
     if vehDescr and ItemTags.ADD_NATIONAL_EMBLEM in self.tags:
         emblems = createNationalEmblemComponents(vehDescr)
         component.decals.extend(emblems)
     if vehDescr and self.isProgressive:
         vehicle = self._itemsCache.items.getItemByCD(
             vehDescr.type.compactDescr)
         component.styleProgressionLevel = self.getLatestOpenedProgressionLevel(
             vehicle)
         if self.isProgressionRewindEnabled:
             component.styleProgressionLevel = self.maxProgressionLevel
             styleOutfitData = self._itemsCache.items.inventory.getOutfitData(
                 vehDescr.type.compactDescr, SeasonType.ALL)
             if styleOutfitData:
                 styledOutfitComponent = parseCompDescr(styleOutfitData)
                 outfitLvl = styledOutfitComponent.styleProgressionLevel
                 component.styleProgressionLevel = outfitLvl if outfitLvl else 1
     if self.isWithSerialNumber and self.serialNumber is not None:
         component.serial_number = self.serialNumber
     if diff is not None:
         diffComponent = parseCompDescr(diff)
         if component.styleId != diffComponent.styleId:
             _logger.error(
                 'Merging outfits of different styles is not allowed. ID1: %s ID2: %s',
                 component.styleId, diffComponent.styleId)
         else:
             component = component.applyDiff(diffComponent)
     return self.itemsFactory.createOutfit(component=component,
                                           vehicleCD=vehicleCD)
 def __createOutfit(self, season, vehicleCD='', diff=None):
     component = deepcopy(self.descriptor.outfits[season])
     if vehicleCD and ItemTags.ADD_NATIONAL_EMBLEM in self.tags:
         vehDescr = VehicleDescr(vehicleCD)
         emblems = createNationalEmblemComponents(vehDescr)
         component.decals.extend(emblems)
     if diff is not None:
         diffComponent = parseCompDescr(diff)
         if component.styleId != diffComponent.styleId:
             _logger.error(
                 'Merging outfits of different styles is not allowed. ID1: %s ID2: %s',
                 component.styleId, diffComponent.styleId)
         else:
             component = component.applyDiff(diffComponent)
     return self.itemsFactory.createOutfit(component=component,
                                           vehicleCD=vehicleCD)
def getOutfitComponent(outfitCD, vehicleDescriptor=None):
    if outfitCD:
        outfitComponent = parseOutfitDescr(outfitCD)
        season = _currentMapSeason()
        if outfitComponent.styleId != 0 and season is not None:
            intCD = makeIntCompactDescrByID('customizationItem', CustomizationType.STYLE, outfitComponent.styleId)
            styleDescr = getItemByCompactDescr(intCD)
            if IS_EDITOR:
                if hasattr(outfitComponent, 'edSeasonsMask'):
                    enyOutfit = styleDescr.outfits[season]
                    season = enyOutfit.edSeasonsMask
            baseOutfitComponent = deepcopy(styleDescr.outfits[season])
            if vehicleDescriptor and ItemTags.ADD_NATIONAL_EMBLEM in styleDescr.tags:
                emblems = createNationalEmblemComponents(vehicleDescriptor)
                baseOutfitComponent.decals.extend(emblems)
            if isEditedStyle(outfitComponent):
                outfitComponent = baseOutfitComponent.applyDiff(outfitComponent)
            else:
                outfitComponent = baseOutfitComponent
        return outfitComponent
    else:
        return CustomizationOutfit()
Пример #4
0
 def __createOutfit(self, season, vehicleCD='', diff=None):
     component = deepcopy(self.descriptor.outfits[season])
     vehDescr = None
     if vehicleCD:
         vehDescr = VehicleDescr(vehicleCD)
     if vehDescr and ItemTags.ADD_NATIONAL_EMBLEM in self.tags:
         emblems = createNationalEmblemComponents(vehDescr)
         component.decals.extend(emblems)
     if vehDescr and self.isProgressive:
         vehicle = self._itemsCache.items.getItemByCD(
             vehDescr.type.compactDescr)
         component.styleProgressionLevel = self.getLatestOpenedProgressionLevel(
             vehicle)
     if diff is not None:
         diffComponent = parseCompDescr(diff)
         if component.styleId != diffComponent.styleId:
             _logger.error(
                 'Merging outfits of different styles is not allowed. ID1: %s ID2: %s',
                 component.styleId, diffComponent.styleId)
         else:
             component = component.applyDiff(diffComponent)
     return self.itemsFactory.createOutfit(component=component,
                                           vehicleCD=vehicleCD)
def getOutfitComponent(outfitCD, vehicleDescriptor=None, seasonType=None):
    if outfitCD:
        outfitComponent = parseOutfitDescr(outfitCD)
        if seasonType is None:
            seasonType = _currentMapSeason()
        if outfitComponent.styleId != 0 and outfitComponent.styleId != EMPTY_ITEM_ID and seasonType is not None:
            intCD = makeIntCompactDescrByID('customizationItem',
                                            CustomizationType.STYLE,
                                            outfitComponent.styleId)
            styleDescr = getItemByCompactDescr(intCD)
            if IS_EDITOR:
                if hasattr(outfitComponent, 'edSeasonsMask'):
                    if styleDescr.outfits is not None and bool(
                            styleDescr.outfits):
                        anyOutfit = styleDescr.outfits[
                            styleDescr.outfits.keys()[0]]
                        seasonType = anyOutfit.edSeasonsMask
                    else:
                        return outfitComponent
            baseOutfitComponent = deepcopy(styleDescr.outfits[seasonType])
            if styleDescr.isProgression or IS_EDITOR:
                if IS_EDITOR:
                    baseOutfitComponent.styleId = styleDescr.id
                outfit = Outfit(component=baseOutfitComponent,
                                vehicleCD=vehicleDescriptor.makeCompactDescr())
                if outfit and outfit.style and outfit.style.styleProgressions:
                    outfit = getStyleProgressionOutfit(
                        outfit, outfitComponent.styleProgressionLevel,
                        seasonType)
                    baseOutfitComponent = outfit.pack()
                baseOutfitComponent.styleProgressionLevel = outfitComponent.styleProgressionLevel
            if styleDescr.isWithSerialNumber:
                baseOutfitComponent.serial_number = outfitComponent.serial_number
            if vehicleDescriptor and ItemTags.ADD_NATIONAL_EMBLEM in styleDescr.tags:
                emblems = createNationalEmblemComponents(vehicleDescriptor)
                baseOutfitComponent.decals.extend(emblems)
            if isEditedStyle(outfitComponent):
                outfitComponent = baseOutfitComponent.applyDiff(
                    outfitComponent)
            else:
                outfitComponent = baseOutfitComponent
            if IS_EDITOR:

                def setupAlternateItem(itemType, outfit, sourceOutfit,
                                       collectionName):
                    alternateItem = outfit.editorData.alternateItems[itemType]
                    if alternateItem != 0:
                        sourceComponents = getattr(sourceOutfit,
                                                   collectionName)
                        if sourceComponents is not None:
                            if itemType != CustomizationType.MODIFICATION:
                                for componentItem in sourceComponents:
                                    componentItem.id = alternateItem

                            else:
                                for index, _ in enumerate(sourceComponents):
                                    sourceComponents[index] = alternateItem

                                setattr(sourceOutfit, collectionName,
                                        sourceComponents)
                    return

                anyOutfit = styleDescr.outfits[seasonType]
                setupAlternateItem(CustomizationType.DECAL, anyOutfit,
                                   outfitComponent, 'decals')
                setupAlternateItem(CustomizationType.PROJECTION_DECAL,
                                   anyOutfit, outfitComponent,
                                   'projection_decals')
                setupAlternateItem(CustomizationType.PAINT, anyOutfit,
                                   outfitComponent, 'paints')
                setupAlternateItem(CustomizationType.CAMOUFLAGE, anyOutfit,
                                   outfitComponent, 'camouflages')
                setupAlternateItem(CustomizationType.MODIFICATION, anyOutfit,
                                   outfitComponent, 'modifications')
                setupAlternateItem(CustomizationType.PERSONAL_NUMBER,
                                   anyOutfit, outfitComponent,
                                   'personal_numbers')
        return outfitComponent
    else:
        return CustomizationOutfit()
 def getEmptyOutfitWithNationalEmblems(self, vehicleCD):
     vehDesc = VehicleDescr(vehicleCD)
     decals = createNationalEmblemComponents(vehDesc)
     component = CustomizationOutfit(decals=decals)
     return self.itemsFactory.createOutfit(component=component,
                                           vehicleCD=vehicleCD)