本文整理汇总了Python中UnitBase.UnitBase类的典型用法代码示例。如果您正苦于以下问题:Python UnitBase类的具体用法?Python UnitBase怎么用?Python UnitBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnitBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _giveLeadership
def _giveLeadership(self, memberDBID):
prevRoleFlags = self._players[memberDBID]["role"]
UnitBase._giveLeadership(self, memberDBID)
newRoleFlags = self._players[memberDBID]["role"]
self._creatorDBID = memberDBID
self.onUnitMembersListChanged()
self.onUnitPlayerRoleChanged(memberDBID, prevRoleFlags, newRoleFlags)
示例2: _addPlayer
def _addPlayer(self, accountDBID, **kwargs):
if (
"role" in kwargs
and kwargs["role"] & UNIT_ROLE.CREATOR == UNIT_ROLE.CREATOR
and self._playerSlots.get(accountDBID) == LEADER_SLOT
):
self._creatorDBID = accountDBID
UnitBase._addPlayer(self, accountDBID, **kwargs)
示例3: _changePlayerRole
def _changePlayerRole(self, accountDBID, roleFlags):
prevRoleFlags = UNIT_ROLE.DEFAULT
if accountDBID in self._players:
prevRoleFlags = self._players[accountDBID]["role"]
UnitBase._changePlayerRole(self, accountDBID, roleFlags)
if roleFlags & UNIT_ROLE.CREATOR == UNIT_ROLE.CREATOR and self._playerSlots.get(accountDBID) == LEADER_SLOT:
self._creatorDBID = accountDBID
self.onUnitPlayerRoleChanged(accountDBID, prevRoleFlags, roleFlags)
示例4: _changePlayerRole
def _changePlayerRole(self, playerID, roleFlags):
prevRoleFlags = UNIT_ROLE.DEFAULT
if playerID in self._players:
prevRoleFlags = self._players[playerID]['role']
UnitBase._changePlayerRole(self, playerID, roleFlags)
if roleFlags & UNIT_ROLE.COMMANDER_UPDATES > 0:
self._creatorDBID = playerID
self.onUnitPlayerRoleChanged(playerID, prevRoleFlags, roleFlags)
示例5: _unpackVehicleDict
def _unpackVehicleDict(self, packedOps):
nextOps = UnitBase._unpackVehicleDict(self, packedOps)
try:
(playerID,) = struct.unpack_from(PLAYER_ID_CHR, packedOps, offset=VEH_LEN_SIZE)
self.onUnitPlayerVehDictChanged(playerID)
except struct.error as e:
LOG_ERROR(e)
return nextOps
示例6: __init__
def __init__(self, slotDefs = {}, slotCount = 0, packedRoster = '', packedUnit = ''):
self.__eManager = Event.EventManager()
self.onUnitStateChanged = Event.Event(self.__eManager)
self.onUnitReadyMaskChanged = Event.Event(self.__eManager)
self.onUnitVehicleChanged = Event.Event(self.__eManager)
self.onUnitSettingChanged = Event.Event(self.__eManager)
self.onUnitPlayerRoleChanged = Event.Event(self.__eManager)
self.onUnitRosterChanged = Event.Event(self.__eManager)
self.onUnitMembersListChanged = Event.Event(self.__eManager)
self.onUnitPlayerAdded = Event.Event(self.__eManager)
self.onUnitPlayerRemoved = Event.Event(self.__eManager)
self.onUnitPlayersListChanged = Event.Event(self.__eManager)
self.onUnitPlayerVehDictChanged = Event.Event(self.__eManager)
self.onUnitPlayerInfoChanged = Event.Event(self.__eManager)
self.onUnitUpdated = Event.Event(self.__eManager)
self._creatorDBID = 0L
UnitBase.__init__(self, slotDefs, slotCount, packedRoster, packedUnit)
示例7: unpackOps
def unpackOps(self, packedOps = ''):
invokedOps = UnitBase.unpackOps(self, packedOps)
if {UNIT_OP.REMOVE_PLAYER, UNIT_OP.ADD_PLAYER} & invokedOps:
self.onUnitPlayersListChanged()
if {UNIT_OP.DEL_MEMBER, UNIT_OP.SET_MEMBER} & invokedOps:
self.onUnitMembersListChanged()
if UNIT_OP.SET_SLOT in invokedOps:
self.onUnitRosterChanged()
示例8: unpackOps
def unpackOps(self, packedOps=""):
invokedOps = UnitBase.unpackOps(self, packedOps)
if {UNIT_OP.REMOVE_PLAYER, UNIT_OP.ADD_PLAYER} & invokedOps:
self.onUnitPlayersListChanged()
if {UNIT_OP.DEL_MEMBER, UNIT_OP.SET_MEMBER} & invokedOps:
self.onUnitMembersListChanged()
if UNIT_OP.SET_SLOT in invokedOps:
self.onUnitRosterChanged()
if {UNIT_OP.EXTRAS_UPDATE, UNIT_OP.EXTRAS_RESET} & invokedOps:
self.onUnitExtraChanged(self._extras)
示例9: __init__
def __init__(self, limitsDefs = {}, slotDefs = {}, slotCount = 0, packedRoster = '', extrasInit = None, packedUnit = ''):
self.__eManager = Event.SuspendedEventManager()
self.onUnitFlagsChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitReadyMaskChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitVehicleChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitVehiclesChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitSettingChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitPlayerRoleChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitRosterChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitMembersListChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitPlayerAdded = Event.SuspendedEvent(self.__eManager)
self.onUnitPlayerRemoved = Event.SuspendedEvent(self.__eManager)
self.onUnitPlayersListChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitPlayerVehDictChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitPlayerInfoChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitExtraChanged = Event.SuspendedEvent(self.__eManager)
self.onUnitUpdated = Event.SuspendedEvent(self.__eManager)
self._creatorDBID = 0
UnitBase.__init__(self, limitsDefs, slotDefs, slotCount, packedRoster, extrasInit, packedUnit)
示例10: _unpackPlayer
def _unpackPlayer(self, packedOps):
(playerID, hasPlayer,) = (0, False)
try:
(playerID,) = struct.unpack_from(PLAYER_ID_CHR, packedOps)
filtered = dict(filter(lambda item: item[1].get('role', 0) & UNIT_ROLE.INVITED == 0, self._players.iteritems()))
hasPlayer = playerID in filtered
except struct.error as e:
LOG_ERROR(e)
nextOps = UnitBase._unpackPlayer(self, packedOps)
if not hasPlayer and playerID:
self.onUnitPlayerAdded(playerID, self.getPlayer(playerID))
if hasPlayer:
LOG_DEBUG_DEV('onUnitPlayerInfoChanged', playerID, self.getPlayer(playerID))
self.onUnitPlayerInfoChanged(playerID, self.getPlayer(playerID))
return nextOps
示例11: _unpackPlayer
def _unpackPlayer(self, packedOps):
accountDBID, hasPlayer = 0, False
try:
accountDBID, = struct.unpack_from(PLAYER_ID_CHR, packedOps)
filtered = dict(
filter(lambda item: item[1].get("role", 0) & UNIT_ROLE.INVITED == 0, self._players.iteritems())
)
hasPlayer = accountDBID in filtered
except struct.error as e:
LOG_ERROR(e)
nextOps = UnitBase._unpackPlayer(self, packedOps)
if not hasPlayer and accountDBID:
self.onUnitPlayerAdded(accountDBID, self.getPlayer(accountDBID))
if hasPlayer:
LOG_DEBUG_DEV("onUnitPlayerInfoChanged", accountDBID, self.getPlayer(accountDBID))
self.onUnitPlayerInfoChanged(accountDBID, self.getPlayer(accountDBID))
return nextOps
示例12: setComment
def setComment(self, strComment):
UnitBase.setComment(self, strComment)
self.onUnitSettingChanged(UNIT_OP.SET_COMMENT, self._strComment)
示例13: _setUnitState
def _setUnitState(self, state):
prevState = self._state
UnitBase._setUnitState(self, state)
self.onUnitStateChanged(prevState, self._state)
示例14: _removePlayer
def _removePlayer(self, accountDBID):
pInfo = self.getPlayer(accountDBID)
if pInfo:
self.onUnitPlayerRemoved(accountDBID, pInfo)
UnitBase._removePlayer(self, accountDBID)
示例15: _setVehicle
def _setVehicle(self, playerID, vehTypeCompDescr, vehInvID):
UnitBase._setVehicle(self, playerID, vehTypeCompDescr, vehInvID)
self.onUnitVehicleChanged(playerID, vehInvID, vehTypeCompDescr)