NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

eveDollRandomizer.py (7697B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\login\charcreation\eveDollRandomizer.py
      2 from eve.common.script.util.paperDollBloodLineAssets import bloodlineAssets
      3 from eve.common.script.paperDoll.paperDollRandomizer import DollRandomizer, AbstractRandomizer
      4 import eve.common.script.paperDoll.paperDollDefinitions as pdDef
      5 import random
      6 import eve.client.script.ui.login.charcreation.ccUtil as ccUtil
      7 import charactercreator.const as ccConst
      8 import eve.common.lib.appConst as appConst
      9 MASTER_COLORS = [ccConst.hair, ccConst.eyes]
     10 
     11 class EveDollRandomizer(DollRandomizer):
     12     bloodline = property(fget=lambda self: self.GetBloodline(), fset=lambda self, x: self.setbloodline(x))
     13 
     14     def setbloodline(self, bloodline):
     15         self.__bloodline = bloodline
     16 
     17     race = property(fget=lambda self: self.GetRace(), fset=lambda self, x: self.setrace(x))
     18 
     19     def setrace(self, race):
     20         self.__race = race
     21 
     22     def __init__(self, modifierLoader):
     23         DollRandomizer.__init__(self, modifierLoader)
     24         self.__bloodline = None
     25         self.__race = None
     26         self.isNewCharacter = False
     27         self.fullRandomization = False
     28 
     29     def GetBloodline(self):
     30         if not self.__bloodline:
     31             self.__bloodline = random.sample(bloodlineAssets, 1)[0]
     32         return self.__bloodline
     33 
     34     def GetRace(self):
     35         if not self.__race:
     36             self.__race = random.sample([appConst.raceAmarr,
     37              appConst.raceCaldari,
     38              appConst.raceGallente,
     39              appConst.raceMinmatar], 1)
     40         return self.__race
     41 
     42     def GetColorVariations(self, modifier):
     43         retList = DollRandomizer.GetColorVariations(self, modifier)
     44         if modifier.categorie == pdDef.BODY_CATEGORIES.SKINTONE and modifier.name == 'basic':
     45             bloodlineName = bloodlineAssets[self.GetBloodline()].split('_')[1]
     46             retList = [ x for x in retList if x.startswith(bloodlineName) ]
     47         return retList
     48 
     49     def ListOptions(self, category):
     50         opts = DollRandomizer.ListOptions(self, category)
     51         if category == pdDef.DOLL_PARTS.HEAD:
     52             return [bloodlineAssets[self.GetBloodline()]]
     53         return opts
     54 
     55     def ListTypes(self, category):
     56         if self.isNewCharacter:
     57             if category == pdDef.DOLL_PARTS.HAIR:
     58                 if self.gender == pdDef.GENDER.MALE:
     59                     return ['res:/Graphics/Character/Modular/Male/hair/Hair_Stubble_02/Types/Hair_Stubble_02.type']
     60                 else:
     61                     return ['res:/Graphics/Character/Modular/Female/hair/Hair_Stubble_01/Types/Hair_Stubble_01.type']
     62         ret = []
     63         types = self.modifierLoader.ListTypes(self.gender, category)
     64         if self.fullRandomization:
     65             if category in (ccConst.skinaging, ccConst.freckles, ccConst.scarring):
     66                 types = types[:1]
     67         availableTypeIDs = sm.GetService('cc').GetMyApparel()
     68         for each in types:
     69             typeData = self.modifierLoader.GetItemType(each, gender=self.gender)
     70             if typeData is None:
     71                 continue
     72             if category in ccConst.randomizerBlacklist:
     73                 if typeData[0].split('/')[-1] in ccConst.randomizerBlacklist[category]:
     74                     continue
     75             assetID, assetTypeID = sm.GetService('character').GetAssetAndTypeIDsFromPath(self.gender, each)
     76             if assetTypeID is not None and assetTypeID not in availableTypeIDs:
     77                 continue
     78             fsdData = cfg.paperdollResources.Get(assetID)
     79             if fsdData:
     80                 empireRestrictions = fsdData.empireRestrictions
     81                 if self.race is None or empireRestrictions is None or empireRestrictions and self.race not in empireRestrictions:
     82                     ret.append(each)
     83             else:
     84                 ret.append(each)
     85 
     86         return ret
     87 
     88     def SetSculptingLimits(self):
     89         bloodlineID = self.GetBloodline()
     90         limitPath = 'res:/Graphics/Character/Global/FaceSetup/ScultpingLimits/%s_%s_blendshape_limits.yaml' % (bloodlineAssets[bloodlineID], self.GetGender())
     91         self.SetBlendshapeLimits(limitPath)
     92 
     93     def ApplyRandomizedResourcesToCharacter(self, charID, randomizedResources):
     94         charSvc = sm.GetService('character')
     95         for cat, categoryValue in randomizedResources.iteritems():
     96             for resType, res in categoryValue:
     97                 if not res:
     98                     continue
     99                 var = None
    100                 weight = self.weights.get(res, 1.0)
    101                 if resType == self.RESOURCE_TYPE:
    102                     resPath = charSvc.factory.GetItemType(res, gender=self.gender)[0]
    103                     color1Value, color1Name, color2Name, variation = (None, None, None, None)
    104                     glossiness = None
    105                     colorizeData = None
    106                     if cat in MASTER_COLORS or cat.startswith('makeup') and cat != 'makeup/eyebrows' or cat.startswith('tattoo'):
    107                         genderID = ccUtil.PaperDollGenderToGenderID(self.gender)
    108                         colorsA, colorsB = charSvc.GetAvailableColorsForCategory(cat, genderID, self.race)
    109                         colorA = []
    110                         colorB = []
    111                         if len(colorsA) > 0:
    112                             colorA = random.choice(colorsA)
    113                             colorB = None
    114                             if len(colorsB) > 0:
    115                                 colorB = random.choice(colorsB)
    116                             color1Value, color1Name, color2Name, variation = charSvc.GetColorsToUse(colorA, colorB)
    117                         if color1Value:
    118                             colorizeData = color1Value
    119                         elif colorB or variation:
    120                             var = variation
    121                         elif len(colorA) > 0:
    122                             var = colorA[1]
    123                         if self.gender == pdDef.GENDER.FEMALE and ccUtil.HasUserDefinedSpecularity(cat):
    124                             glossiness = round(0.3 + 0.3 * random.random(), 2)
    125                     modifier = charSvc.ApplyTypeToDoll(charID, res, weight, doUpdate=False, rawColorVariation=var)
    126                     if color1Name:
    127                         charSvc.characterMetadata[charID].typeColors[cat] = (color1Name, color2Name)
    128                     if glossiness:
    129                         charSvc.SetColorSpecularityByCategory(charID, cat, glossiness, doUpdate=False)
    130                     if colorizeData:
    131                         modifier.SetColorizeData(colorizeData)
    132                 else:
    133                     modifier = charSvc.ApplyItemToDoll(charID, cat, res, removeFirst=True, doUpdate=False)
    134                     colorVariations = self.GetColorVariations(modifier)
    135                     colorVariation = AbstractRandomizer.SelectOneFromCollection(colorVariations, oddsOfSelectingNone=0)
    136                     if colorVariation:
    137                         colorTuple = (colorVariation, modifier.colorVariations[colorVariation])
    138                         charSvc.SetColorValueByCategory(charID, cat, colorTuple, None, doUpdate=False)
    139                     modifier.weight = weight
    140 
    141     def RandomizeHairColor(self, charID, randomizeFacialDarkness = True):
    142         genderID = 0 if self.gender == pdDef.GENDER.FEMALE else 1
    143         charSvc = sm.GetService('character')
    144         p, s = charSvc.GetAvailableColorsForCategory(pdDef.DOLL_PARTS.HAIR, genderID, self.race)
    145         primary = random.choice(p)
    146         secondary = random.choice(s)
    147         charSvc.SetColorValueByCategory(charID, 'hair', primary, secondary, doUpdate=False)
    148         charSvc.SetHairDarkness(charID, random.random())
    149         charSvc.SynchronizeHairColors()