Exemplo n.º 1
0
 def GetOutputVolumePerHour(self):
     cycleTime = self.GetCycleTime()
     if not self.IsProducer() or not cycleTime:
         return 0.0
     volumePerCycle = planetCommon.GetCommodityTotalVolume(self.GetProducts())
     volumePerHour = planetCommon.GetBandwidth(volumePerCycle, cycleTime)
     return volumePerHour
Exemplo n.º 2
0
    def _ApplyMaxAmountFilter(self, toMove):
        availableVolume = self.destPin.GetCapacity(
        ) - self.destPin.capacityUsed
        availableVolume -= planetCommon.GetCommodityTotalVolume(
            self.transferContents)
        transferVolume = planetCommon.GetCommodityTotalVolume(toMove)
        if transferVolume >= availableVolume:
            newToMove = {}
            if len(toMove) == 1:
                for typeID, quantity in toMove.iteritems():
                    commodityVolume = cfg.invtypes.Get(typeID).volume
                    maxAmount = int(
                        math.floor(availableVolume / commodityVolume))
                    newToMove[typeID] = maxAmount

            eve.Message('ExpeditedTransferNotEnoughSpace')
            return newToMove
        else:
            return toMove
Exemplo n.º 3
0
    def OnRouteAmountEditChanged(self, newVal):
        try:
            routeAmount = int(newVal)
        except ValueError:
            return

        if not self.currRouteCycleTime:
            return
        routeAmount = min(routeAmount, self.routeMaxAmount)
        routeAmount = max(routeAmount, 0.0)
        volume = planetCommon.GetCommodityTotalVolume(
            {self.commodityToRoute: routeAmount})
        volumePerHour = planetCommon.GetBandwidth(volume,
                                                  self.currRouteCycleTime)
        sm.GetService('planetUI').myPinManager.OnRouteVolumeChanged(
            volumePerHour)
Exemplo n.º 4
0
    def RefreshLists(self, *args):
        pinListItems = []
        for typeID, qty in self.pinContents.iteritems():
            lbl = '<t>%s<t>%d' % (cfg.invtypes.Get(typeID).name, qty)
            data = util.KeyVal(itemID=None,
                               typeID=typeID,
                               label=lbl,
                               getIcon=1,
                               quantity=qty,
                               OnDropData=self.OnSourceScrollDropData)
            pinListItems.append(listentry.Get('DraggableItem', data=data))

        transferListItems = []
        for typeID, qty in self.transferContents.iteritems():
            lbl = '<t>%s<t>%d' % (cfg.invtypes.Get(typeID).name, qty)
            data = util.KeyVal(itemID=None,
                               typeID=typeID,
                               label=lbl,
                               getIcon=1,
                               quantity=qty,
                               OnDropData=self.OnTransferScrollDropData)
            transferListItems.append(listentry.Get('DraggableItem', data=data))

        self.sr.sourcePinListScroll.Load(
            contentList=pinListItems,
            noContentHint=localization.GetByLabel(
                'UI/PI/Common/StorehouseIsEmpty'),
            headers=[
                localization.GetByLabel('UI/Common/Type'),
                localization.GetByLabel('UI/Common/Name'),
                localization.GetByLabel('UI/Common/Quantity')
            ])
        self.sr.transferListScroll.Load(
            contentList=transferListItems,
            noContentHint=localization.GetByLabel('UI/PI/Common/NoItemsFound'),
            headers=[
                localization.GetByLabel('UI/Common/Type'),
                localization.GetByLabel('UI/Common/Name'),
                localization.GetByLabel('UI/Common/Quantity')
            ])
        transferVolume = planetCommon.GetCommodityTotalVolume(
            self.transferContents)
        self.sr.volumeText.text = localization.GetByLabel(
            'UI/PI/Common/VolumeAmount', amount=transferVolume)
        self.SetNextTransferText()
        self.SetCooldownTimeText()
Exemplo n.º 5
0
def GetSchematicData(processorTypeID):
    schematicsData = cfg.schematicsByPin[processorTypeID]
    if len(schematicsData) == 0:
        log.LogTraceback('Authoring error: No schematics found for processor pin with typeID %s' % processorTypeID)
    schematics = []
    for s in schematicsData:
        try:
            schematic = cfg.schematics.Get(s.schematicID)
        except:
            log.LogTraceback('Authoring error: No schematic found with id=%s' % s.schematicID)
            raise 

        inputs, outputs = _GetSchematicInputsAndOutputs(schematic.schematicID)
        outputsDict = {}
        for o in outputs:
            outputsDict[o.typeID] = o.quantity

        volumePerCycle = planetCommon.GetCommodityTotalVolume(outputsDict)
        volumePerHour = planetCommon.GetBandwidth(volumePerCycle, schematic.cycleTime * SEC)
        sData = util.KeyVal(name=schematic.schematicName, schematicID=schematic.schematicID, cycleTime=schematic.cycleTime, outputs=outputs, inputs=inputs, outputVolume=volumePerHour)
        schematics.append((sData.name, sData))

    return uiutil.SortListOfTuples(schematics)
Exemplo n.º 6
0
 def CanImportCommodities(self, commodities):
     volume = planetCommon.GetCommodityTotalVolume(commodities)
     if self.capacityUsed + volume > self.GetCapacity():
         return False
     return True