Example #1
0
    def pack(self):
        component = CustomizationOutfit()
        for container in self._containers.itervalues():
            container.pack(component)

        component.styleId = self._id
        component.styleProgressionLevel = self.__styleProgressionLevel
        return component
    def _applyItems(self, purchaseItems, isModeChanged, callback):
        results = []
        vehicleCD = g_currentVehicle.item.descriptor.makeCompactDescr()
        modifiedOutfits = {
            season: outfit.copy()
            for season, outfit in self._modifiedOutfits.iteritems()
        }
        originalOutfits = self._ctx.startMode.getOriginalOutfits()
        removeUnselectedItemsFromEditableStyle(modifiedOutfits,
                                               self.__baseOutfits,
                                               purchaseItems)
        requestData = []
        for season in SeasonType.COMMON_SEASONS:
            outfit = modifiedOutfits[season]
            baseOutfit = self.__baseOutfits[season]
            if outfit.vehicleCD != baseOutfit.vehicleCD or not outfit.isEqual(
                    baseOutfit):
                diff = getEditableStyleOutfitDiff(outfit, baseOutfit)
                outfit = self.__style.getOutfit(season,
                                                vehicleCD=vehicleCD,
                                                diff=diff)
                requestData.append((outfit, season))

        if not requestData:
            emptyComponent = CustomizationOutfit()
            outfit = self._modifiedOutfits[self.season]
            emptyComponent.styleId = outfit.id
            if outfit.style is not None and outfit.style.isProgressionRewindEnabled:
                emptyComponent.styleProgressionLevel = outfit.progressionLevel
            outfit = Outfit(component=emptyComponent)
            requestData.append((outfit, SeasonType.ALL))
        result = yield OutfitApplier(g_currentVehicle.item,
                                     requestData).request()
        results.append(result)
        if self.isInited:
            self._events.onItemsBought(originalOutfits, purchaseItems, results)
        callback(self)
        return