def AssumeStructureControl(self, slimItem, silent=False, force=False):
        item = sm.GetService('michelle').GetItem(slimItem.itemID) or slimItem
        if item and getattr(item, 'itemID',
                            None) and (item.itemID in self.currentlyAssuming
                                       or item.itemID in self.currentcontrol):
            raise UserError('StructureControlled',
                            {'item': (const.UE_TYPEID, item.typeID)})
        if slimItem.posState < pos.STRUCTURE_ONLINING:
            raise UserError('StructureNotControllableUntilOnline',
                            {'item': (const.UE_TYPEID, item.typeID)})
        self.currentlyAssuming[item.itemID] = True
        if item and not item.controllerID or force:
            for row in cfg.dgmtypeattribs.get(item.typeID, []):
                if row.attributeID == const.attributePosPlayerControlStructure:
                    self.currentcontrol[item.itemID] = True
                    if not silent:
                        try:
                            posMgr = moniker.GetPOSMgr()
                            posMgr.AssumeStructureControl(item.itemID)
                        except UserError as e:
                            del self.currentcontrol[item.itemID]
                            self.currentlyAssuming.pop(item.itemID, None)
                            eve.Message(e.msg, e.dict)
                            sys.exc_clear()

                    sm.ScatterEvent('OnAssumeStructureControl', item.itemID)
                    break

        self.currentlyAssuming.pop(item.itemID, None)
示例#2
0
 def Anchor(self, itemID, position):
     item = sm.GetService('michelle').GetItem(itemID)
     for row in cfg.dgmtypeeffects.get(item.typeID, []):
         if row.effectID == const.effectAnchorDropForStructures:
             posMgr = moniker.GetPOSMgr()
             posMgr.AnchorStructure(itemID, position)
             break
 def EnterTowerPassword(self, towerID):
     password = uiutil.NamePopup(
         caption=localization.GetByLabel(
             'UI/Inflight/POS/TowerShieldHarmonic'),
         label=localization.GetByLabel(
             'UI/Inflight/POS/EnterTheSharedSecret'),
         setvalue='',
         maxLength=50,
         passwordChar='*')
     if password is None:
         return
     posMgr = moniker.GetPOSMgr()
     posMgr.SetTowerPassword(towerID, password)
    def RelinquishStructureControl(self, slimItem, silent=False, force=False):
        item = sm.GetService('michelle').GetItem(slimItem.itemID) or slimItem
        if item and item.controllerID or force:
            for row in cfg.dgmtypeattribs.get(item.typeID, []):
                if row.attributeID == const.attributePosPlayerControlStructure:
                    if self.currentcontrol.has_key(item.itemID):
                        del self.currentcontrol[item.itemID]
                    if self.currenttargets.has_key(item.itemID):
                        del self.currenttargets[item.itemID]
                    if not silent:
                        try:
                            posMgr = moniker.GetPOSMgr()
                            posMgr.RelinquishStructureControl(item.itemID)
                        except UserError as e:
                            eve.Message(e.msg, e.dict)
                            sys.exc_clear()

                    sm.ScatterEvent('OnRelinquishStructureControl',
                                    item.itemID)
                    break