本文整理汇总了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)