当前位置: 首页>>代码示例>>Python>>正文


Python NewPlayerSettlementHovered.broadcast方法代码示例

本文整理汇总了Python中horizons.messaging.NewPlayerSettlementHovered.broadcast方法的典型用法代码示例。如果您正苦于以下问题:Python NewPlayerSettlementHovered.broadcast方法的具体用法?Python NewPlayerSettlementHovered.broadcast怎么用?Python NewPlayerSettlementHovered.broadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizons.messaging.NewPlayerSettlementHovered的用法示例。


在下文中一共展示了NewPlayerSettlementHovered.broadcast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from horizons.messaging import NewPlayerSettlementHovered [as 别名]
# 或者: from horizons.messaging.NewPlayerSettlementHovered 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)
开发者ID:alanshi,项目名称:unknown-horizons,代码行数:32,代码来源:lastactiveplayersettlementmanager.py


注:本文中的horizons.messaging.NewPlayerSettlementHovered.broadcast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。