Exemplo n.º 1
0
def OpenDroneBay(itemIDs):
    usePrimary = len(itemIDs) == 1
    openFromWnd = uicore.registry.GetActive() if usePrimary else None
    for itemID in itemIDs:
        invID = ('ShipDroneBay', itemID)
        invCtrl.ShipDroneBay(itemID).GetItems()
        form.Inventory.OpenOrShow(invID=invID, usePrimary=usePrimary, openFromWnd=openFromWnd)
Exemplo n.º 2
0
 def OnDropData(self, dragObj, nodes):
     invCtrl.ShipDroneBay(util.GetActiveShip()).OnDropData(nodes)
     CargoSlots.OnDropData(self, dragObj, nodes)
Exemplo n.º 3
0
 def GetInvController(self):
     return invCtrl.ShipDroneBay(self.controller.GetItemID())
Exemplo n.º 4
0
 def OnDropData(self, dragObj, nodes):
     if self.controller.IsSimulated():
         self.AddSimulatedDrones(nodes)
     else:
         invCtrl.ShipDroneBay(util.GetActiveShip()).OnDropData(nodes)
     CargoSlots.OnDropData(self, dragObj, nodes)
Exemplo n.º 5
0
 def GetInvController(self):
     if self.controller.IsSimulated():
         itemID = None
     else:
         itemID = self.controller.GetItemID()
     return invCtrl.ShipDroneBay(itemID)
Exemplo n.º 6
0
def TryFit(invItems, shipID=None):
    if not shipID:
        shipID = GetActiveShip()
        if not shipID:
            return
    godma = sm.services['godma']
    invCache = sm.GetService('invCache')
    shipInv = invCache.GetInventoryFromId(shipID,
                                          locationID=session.stationid2)
    godmaSM = godma.GetStateManager()
    useRigs = None
    charges = set()
    drones = []
    subSystemGroupIDs = set()
    for invItem in invItems[:]:
        if IsFittingModule(invItem.categoryID):
            moduleEffects = cfg.dgmtypeeffects.get(invItem.typeID, [])
            for mEff in moduleEffects:
                if mEff.effectID == const.effectRigSlot:
                    if useRigs is None:
                        useRigs = True if RigFittingCheck(invItem) else False
                    if not useRigs:
                        invItems.remove(invItem)
                        invCache.UnlockItem(invItem.itemID)
                        break

        if invItem.categoryID == const.categorySubSystem:
            if invItem.groupID in subSystemGroupIDs:
                invItems.remove(invItem)
            else:
                subSystemGroupIDs.add(invItem.groupID)
        elif invItem.categoryID == const.categoryCharge:
            charges.add(invItem)
            invItems.remove(invItem)
        elif invItem.categoryID == const.categoryDrone:
            drones.append(invItem)
            invItems.remove(invItem)

    if len(invItems) > 0:
        shipInv.moniker.MultiAdd([invItem.itemID for invItem in invItems],
                                 invItems[0].locationID,
                                 flag=const.flagAutoFit)
    if charges:
        shipStuff = shipInv.List()
        shipStuff.sort(key=lambda r: (r.flagID, isinstance(r.itemID, tuple)))
        loadedSlots = set()
    if drones:
        invCtrl.ShipDroneBay(shipID or GetActiveShip()).AddItems(drones)
    dogmaLocation = sm.GetService('clientDogmaIM').GetDogmaLocation()
    shipDogmaItem = dogmaLocation.dogmaItems.get(shipID, None)
    loadedSomething = False
    for DBRowInvItem in charges:
        invItem = KeyVal(DBRowInvItem)
        chargeDgmType = godmaSM.GetType(invItem.typeID)
        isCrystalOrScript = invItem.groupID in cfg.GetCrystalGroups()
        for row in shipStuff:
            if row in loadedSlots:
                continue
            if not IsShipFittingFlag(row.flagID):
                continue
            if dogmaLocation.IsInWeaponBank(
                    row.locationID,
                    row.itemID) and dogmaLocation.IsModuleSlave(
                        row.itemID, row.locationID):
                continue
            if row.categoryID == const.categoryCharge:
                continue
            moduleDgmType = godmaSM.GetType(row.typeID)
            desiredSize = getattr(moduleDgmType, 'chargeSize', None)
            for x in xrange(1, 5):
                chargeGroup = getattr(moduleDgmType, 'chargeGroup%d' % x,
                                      False)
                if not chargeGroup:
                    continue
                if chargeDgmType.groupID != chargeGroup:
                    continue
                if desiredSize and getattr(chargeDgmType, 'chargeSize',
                                           -1) != desiredSize:
                    continue
                for i, squatter in enumerate(
                    [i for i in shipStuff if i.flagID == row.flagID]):
                    if isCrystalOrScript and i > 0:
                        break
                    if shipDogmaItem is None:
                        continue
                    subLocation = dogmaLocation.GetSubLocation(
                        shipID, squatter.flagID)
                    if subLocation is None:
                        continue
                    chargeVolume = chargeDgmType.volume * dogmaLocation.GetAttributeValue(
                        subLocation, const.attributeQuantity)
                    if godmaSM.GetType(row.typeID).capacity <= chargeVolume:
                        break
                else:
                    moduleCapacity = godmaSM.GetType(row.typeID).capacity
                    numCharges = moduleCapacity / chargeDgmType.volume
                    subLocation = dogmaLocation.GetSubLocation(
                        shipID, row.flagID)
                    if subLocation:
                        numCharges -= dogmaLocation.GetAttributeValue(
                            subLocation, const.attributeQuantity)
                    dogmaLocation.LoadAmmoToModules(shipID, [row.itemID],
                                                    invItem.typeID,
                                                    invItem.itemID,
                                                    invItem.locationID)
                    loadedSomething = True
                    invItem.stacksize -= numCharges
                    loadedSlots.add(row)
                    blue.pyos.synchro.SleepWallclock(100)
                    break

            else:
                continue

            if invItem.stacksize <= 0:
                break
        else:
            if not loadedSomething:
                uicore.Message('NoSuitableModules')