slot.py (3470B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\cosmetics\common\ships\skins\static_data\slot.py 2 from cosmetics.common.ships.skins.static_data import slot_name 3 from cosmetics.common.ships.skins.static_data.component import ComponentsDataLoader 4 from cosmetics.common.ships.skins.static_data.component_category import get_category_from_fsd, ComponentCategory 5 from cosmetics.common.ships.skins.static_data.slot_category import get_slot_category_from_fsd, SlotCategory 6 from cosmetics.common.ships.skins.static_data.slot_name import SlotID 7 from localization import GetByMessageID 8 from fsdBuiltData.common.base import BuiltDataLoader 9 try: 10 import ship_cosmetic_slotsLoader 11 except ImportError: 12 ship_cosmetic_slotsLoader = None 13 14 class SlotsDataLoader(BuiltDataLoader): 15 __resBuiltFile__ = 'res:/staticdata/ship_cosmetic_slots.fsdbinary' 16 __clientAutobuildBuiltFile__ = 'eve/autobuild/staticData/client/ship_cosmetic_slots.fsdbinary' 17 __serverAutobuildBuiltFile__ = 'eve/autobuild/staticData/server/ship_cosmetic_slots.fsdbinary' 18 __loader__ = ship_cosmetic_slotsLoader 19 _slot_data_by_id = None 20 21 @classmethod 22 def get_slots_by_id(cls): 23 return cls.GetData() 24 25 @classmethod 26 def get_slot_data(cls, slot_id): 27 cls._check_init_slot_definitions() 28 return cls._slot_data_by_id[slot_id] 29 30 @classmethod 31 def _check_init_slot_definitions(cls): 32 if cls._slot_data_by_id: 33 return 34 cls._slot_data_by_id = {} 35 for slot_id, slot_data in SlotsDataLoader.GetData().items(): 36 cls._slot_data_by_id[slot_id] = Slot.build_from_fsd(slot_id, slot_data) 37 38 @classmethod 39 def ReloadDataFromDisk(cls): 40 super(SlotsDataLoader, cls).ReloadDataFromDisk() 41 cls._slot_data_by_id = None 42 43 @classmethod 44 def get_allowed_component(cls, slot_id): 45 slot_data = cls.get_slot_data(slot_id) 46 allowed_components = ComponentsDataLoader.get_components_data(category_filter=slot_data.allowed_component_categories, slot_internal_name_filter=slot_data.unique_id) 47 return allowed_components 48 49 50 class Slot(object): 51 52 def __init__(self, unique_id, category, name_id, description_id, allowed_component_categories): 53 self._unique_id = unique_id 54 self._internal_name = slot_name.INTERNAL_NAME_BY_SLOT_ID[unique_id] 55 self._category = category 56 self._name_id = name_id 57 self._description_id = description_id 58 self._allowed_component_categories = allowed_component_categories 59 60 @property 61 def unique_id(self): 62 return self._unique_id 63 64 @property 65 def internal_name(self): 66 return self._internal_name 67 68 @property 69 def category(self): 70 return self._category 71 72 @property 73 def name(self): 74 return GetByMessageID(self._name_id) 75 76 @property 77 def description(self): 78 return GetByMessageID(self._description_id) 79 80 @property 81 def allowed_component_categories(self): 82 return self._allowed_component_categories 83 84 @staticmethod 85 def build_from_fsd(slot_id, fsd_data): 86 name_id = fsd_data.name 87 description_id = fsd_data.description 88 category = get_slot_category_from_fsd(fsd_data.category) 89 allowed_component_categories = [ get_category_from_fsd(x) for x in fsd_data.allowed_design_component_categories ] 90 return Slot(slot_id, category, name_id, description_id, allowed_component_categories)