def _extractRawParams(self): if self._vehicleDescr is not None: descriptors = getGunDescriptors(self._itemDescr, self._vehicleDescr) params = calcGunParams(self._itemDescr, descriptors) else: params = self._getPrecachedInfo().params return params
def getAvgParams(self): if self._vehicleDescr is not None: descriptors = getGunDescriptors(self._itemDescr, self._vehicleDescr) avgParams = calcGunParams(self._itemDescr, descriptors) else: avgParams = self.precachedParams.avgParams return avgParams
def __precacheGuns(self): for nationIdx in nations.INDICES.itervalues(): self.__cache.setdefault(nationIdx, {})[ITEM_TYPES.vehicleGun] = {} vcls = self.__getItems(ITEM_TYPES.vehicle, nationIdx) guns = self.__getItems(ITEM_TYPES.vehicleGun, nationIdx) for g in guns: descriptors = list() turretsList = list() turretsIntCDs = dict() clipVehiclesList = set() for vDescr in vcls: turretsIntCDs[ vDescr.type. compactDescr] = curVehicleTurretsCDs = list() for vTurrets in vDescr.type.turrets: for turret in vTurrets: for gun in turret['guns']: if gun['id'][1] == g['id'][1]: descriptors.append(gun) if len(vDescr.hull['fakeTurrets'] ['lobby']) != len(vDescr.turrets): curVehicleTurretsCDs.append( turret['compactDescr']) turretsList.append( turret['userString']) if gun['clip'][0] > 1: clipVehiclesList.add( vDescr.type.compactDescr) self.__cache[nationIdx][ITEM_TYPES.vehicleGun][ g['compactDescr']] = PrecachedGun( turrets=tuple(turretsList), clipVehicles=clipVehiclesList, avgParams=calcGunParams(g, descriptors), turretsByVehicles=turretsIntCDs)
def __precacheGuns(self): for nationIdx in nations.INDICES.itervalues(): self.__cache.setdefault(nationIdx, {})[ITEM_TYPES.vehicleGun] = {} vcls = self.__getItems(ITEM_TYPES.vehicle, nationIdx) guns = self.__getItems(ITEM_TYPES.vehicleGun, nationIdx) for g in guns: descriptors = [] turretsIntCDs = {} clipVehiclesList = set() for vDescr in vcls: curVehicleTurretsCDs = [] for vTurrets in vDescr.type.turrets: for turret in vTurrets: for gun in turret.guns: if gun.id[1] == g.id[1]: descriptors.append(gun) if len(vDescr.hull.fakeTurrets['lobby'] ) != len(vDescr.turrets): curVehicleTurretsCDs.append( turret.compactDescr) if gun.clip[0] > 1: clipVehiclesList.add( vDescr.type.compactDescr) turretsIntCDs[vDescr.type.compactDescr] = tuple( curVehicleTurretsCDs) self.__cache[nationIdx][ITEM_TYPES.vehicleGun][ g.compactDescr] = PrecachedGun( clipVehicles=clipVehiclesList, params=calcGunParams(g, descriptors), turretsByVehicles=turretsIntCDs)
def __precacheGuns(self, vehiclesCache): descriptors = [] curVehicleTurretsCDs = [] getter = vehicles.g_cache.guns for nationIdx in nations.INDICES.itervalues(): self.__cache.setdefault(nationIdx, {})[ITEM_TYPES.vehicleGun] = {} for g in getter(nationIdx).itervalues(): del descriptors[:] turretsIntCDs = {} clipVehiclesList = set() autoReloadVehsList = set() for vDescr in vehiclesCache.generator(nationIdx): del curVehicleTurretsCDs[:] vehCD = vDescr.type.compactDescr for vTurrets in vDescr.type.turrets: for turret in vTurrets: for gun in turret.guns: if gun.id[1] == g.id[1]: descriptors.append(gun) if len(vDescr.hull.fakeTurrets['lobby'] ) != len(vDescr.turrets): curVehicleTurretsCDs.append( turret.compactDescr) if gun.clip[0] > 1: clipVehiclesList.add(vehCD) if isAutoReloadGun(gun): autoReloadVehsList.add(vehCD) if curVehicleTurretsCDs: turretsIntCDs[vDescr.type.compactDescr] = tuple( curVehicleTurretsCDs) self.__cache[nationIdx][ITEM_TYPES.vehicleGun][ g.compactDescr] = PrecachedGun( clipVehicles=clipVehiclesList if clipVehiclesList else None, autoReloadVehicles=frozenset(autoReloadVehsList) if autoReloadVehsList else None, params=calcGunParams(g, descriptors), turretsByVehicles=turretsIntCDs) return
def __precachGuns(self): for nationIdx in nations.INDICES.itervalues(): self.__cache.setdefault(nationIdx, {})[ITEM_TYPES.vehicleGun] = {} vcls = self.__getItems(ITEM_TYPES.vehicle, nationIdx) guns = self.__getItems(ITEM_TYPES.vehicleGun, nationIdx) for g in guns: descriptors = list() turretsList = list() turretsIntCDs = dict() clipVehiclesList = set() for vDescr in vcls: turretsIntCDs[vDescr.type.compactDescr] = curVehicleTurretsCDs = list() for vTurrets in vDescr.type.turrets: for turret in vTurrets: for gun in turret['guns']: if gun['id'][1] == g['id'][1]: descriptors.append(gun) if len(vDescr.hull['fakeTurrets']['lobby']) != len(vDescr.turrets): curVehicleTurretsCDs.append(turret['compactDescr']) turretsList.append(turret['userString']) if gun['clip'][0] > 1: clipVehiclesList.add(vDescr.type.compactDescr) self.__cache[nationIdx][ITEM_TYPES.vehicleGun][g['compactDescr']] = PrecachedGun(turrets=tuple(turretsList), clipVehicles=clipVehiclesList, avgParams=calcGunParams(g, descriptors), turretsByVehicles=turretsIntCDs)