本文整理匯總了Python中horizons.messaging.HoverSettlementChanged.broadcast方法的典型用法代碼示例。如果您正苦於以下問題:Python HoverSettlementChanged.broadcast方法的具體用法?Python HoverSettlementChanged.broadcast怎麽用?Python HoverSettlementChanged.broadcast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類horizons.messaging.HoverSettlementChanged
的用法示例。
在下文中一共展示了HoverSettlementChanged.broadcast方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update
# 需要導入模塊: from horizons.messaging import HoverSettlementChanged [as 別名]
# 或者: from horizons.messaging.HoverSettlementChanged import broadcast [as 別名]
def update(self, current):
"""Update to new world position. Sets internal state to new settlement or no settlement
@param current: some kind of position coords with x- and y-values"""
settlement = self.session.world.get_settlement(Point(int(round(current.x)), int(round(current.y))))
# check if it's a new settlement independent of player
if resolve_weakref(self._cur_settlement) is not settlement:
self._cur_settlement = create_weakref(settlement)
HoverSettlementChanged.broadcast(self, settlement)
# player-sensitive code
new_player_settlement = weakref.ref(settlement) if \
settlement and settlement.owner.is_local_player else None
need_msg = False
# check if actual last player settlement is a new one
if new_player_settlement is not None and \
resolve_weakref(self._last_player_settlement) is not resolve_weakref( new_player_settlement):
self._last_player_settlement = new_player_settlement
need_msg = True
# check if we changed to or from None
# this doesn't change the last settlement, but we need a message
if (new_player_settlement is None and not self._last_player_settlement_hovered_was_none) or \
(new_player_settlement is not None and self._last_player_settlement_hovered_was_none):
need_msg = True
if need_msg:
NewPlayerSettlementHovered.broadcast(self, resolve_weakref(new_player_settlement))
self._last_player_settlement_hovered_was_none = (new_player_settlement is None)