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


Python RemoveStatusIcon.broadcast方法代码示例

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


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

示例1: _on_production_change

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def _on_production_change(self):
		"""Makes the instance act according to the producers
		current state"""
		state = self._get_current_state()
		if (state is PRODUCTION.STATES.waiting_for_res or\
			state is PRODUCTION.STATES.paused or\
			state is PRODUCTION.STATES.none):
			self.instance.act("idle", repeating=True)
		elif state is PRODUCTION.STATES.producing:
			self.instance.act("work", repeating=True)
		elif state is PRODUCTION.STATES.inventory_full:
			self.instance.act("idle_full", repeating=True)

		if self.instance.has_status_icon:
			full = state is PRODUCTION.STATES.inventory_full
			if full and not hasattr(self, "_producer_status_icon"):
				affected_res = set() # find them:
				for prod in self.get_productions():
					affected_res = affected_res.union( prod.get_unstorable_produced_res() )
				self._producer_status_icon = InventoryFullStatus(self.instance, affected_res)
				AddStatusIcon.broadcast(self, self._producer_status_icon)

			if not full and hasattr(self, "_producer_status_icon"):
				RemoveStatusIcon.broadcast(self, self.instance, InventoryFullStatus)
				del self._producer_status_icon
开发者ID:savionok,项目名称:unknown-horizons,代码行数:27,代码来源:producer.py

示例2: _on_production_change

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def _on_production_change(self):
		"""Makes the instance act according to the producers
		current state"""
		state = self._get_current_state()
		new_action = 'idle'
		if state is PRODUCTION.STATES.producing:
			new_action = "work"
		elif state is PRODUCTION.STATES.inventory_full:
			new_action = "idle_full"

		# don't force restarts as not to disturb sequences such as tree growth
		self.instance.act(new_action, repeating=True, force_restart=False)

		if self.instance.has_status_icon:
			full = state is PRODUCTION.STATES.inventory_full
			if full and not hasattr(self, "_producer_status_icon"):
				affected_res = set() # find them:
				for prod in self.get_productions():
					affected_res = affected_res.union( prod.get_unstorable_produced_res() )
				self._producer_status_icon = InventoryFullStatus(self.instance, affected_res)
				AddStatusIcon.broadcast(self, self._producer_status_icon)

			if not full and hasattr(self, "_producer_status_icon"):
				RemoveStatusIcon.broadcast(self, self.instance, InventoryFullStatus)
				del self._producer_status_icon
开发者ID:aedificium,项目名称:aedificium,代码行数:27,代码来源:producer.py

示例3: set_active

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def set_active(self, production=None, active=True):
		"""Pause or unpause a production (aka set it active/inactive).
		see also: is_active, toggle_active
		@param production: instance of Production. if None, we do it to all productions.
		@param active: whether to set it active or inactive"""
		if production is None:
			# set all
			for production in self.get_productions():
				self.set_active(production, active)
		else:
			line_id = production.get_production_line_id()
			if active:
				if not self.is_active(production):
					self.log.debug("ResHandler %s: reactivating production %s", self.instance.worldid, line_id)
					self._productions[line_id] = production
					del self._inactive_productions[line_id]
					production.pause(pause=False)
			else:
				if self.is_active(production):
					self.log.debug("ResHandler %s: deactivating production %s", self.instance.worldid, line_id)
					self._inactive_productions[line_id] = production
					del self._productions[line_id]
					production.pause()

			if self.is_active() is not self.__active:
				self.__active = not self.__active
				if self.__active:
					RemoveStatusIcon.broadcast(self, self.instance, DecommissionedStatus)
				else:
					icon = DecommissionedStatus(self.instance)
					AddStatusIcon.broadcast(self, icon)

		self.instance._changed()
		self.on_activity_changed(self.is_active())
开发者ID:savionok,项目名称:unknown-horizons,代码行数:36,代码来源:producer.py

示例4: update_capacity_utilization

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def update_capacity_utilization(self):
		"""Called by the scheduler to update the utilization regularly"""
		if not self.capacity_utilization_below(ProductivityLowStatus.threshold) is not self.__utilization_ok:
			self.__utilization_ok = not self.__utilization_ok
			if self.__utilization_ok:
				RemoveStatusIcon.broadcast(self, self.instance, ProductivityLowStatus)
			else:
				self._add_status_icon(ProductivityLowStatus(self.instance))
开发者ID:PlutoniumHeart,项目名称:unknown-horizons,代码行数:10,代码来源:producer.py

示例5: _update_status_icon

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def _update_status_icon(self):
		if self.has_status_icon:
			unhappy = self.happiness < self.__get_data("happiness_inhabitants_decrease_limit")
			# check for changes
			if unhappy and not hasattr(self, "_settler_status_icon"):
				self._settler_status_icon = SettlerUnhappyStatus(self) # save ref for removal later
				AddStatusIcon.broadcast(self, self._settler_status_icon)
			if not unhappy and hasattr(self, "_settler_status_icon"):
				RemoveStatusIcon.broadcast(self, self, SettlerUnhappyStatus)
				del self._settler_status_icon
开发者ID:STEVEOO6,项目名称:unknown-horizons,代码行数:12,代码来源:settler.py

示例6: _update_decommissioned_icon

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def _update_decommissioned_icon(self):
		"""Add or remove decommissioned icon."""
		if not self.instance.has_status_icon:
			return

		if self.is_active() is not self.__active:
			self.__active = not self.__active
			if self.__active:
				RemoveStatusIcon.broadcast(self, self.instance, DecommissionedStatus)
			else:
				self._add_status_icon(DecommissionedStatus(self.instance))
开发者ID:PlutoniumHeart,项目名称:unknown-horizons,代码行数:13,代码来源:producer.py

示例7: _check_main_square_in_range

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def _check_main_square_in_range(self):
		"""Notifies the user via a message in case there is no main square in range"""
		if not self.owner.is_local_player:
			return # only check this for local player
		for building in self.get_buildings_in_range():
			if building.id == BUILDINGS.MAIN_SQUARE:
				if StaticPather.get_path_on_roads(self.island, self, building) is not None:
					# a main square is in range
					if hasattr(self, "_main_square_status_icon"):
						RemoveStatusIcon.broadcast(self, self, SettlerNotConnectedStatus)
						del self._main_square_status_icon
					return
		if not hasattr(self, "_main_square_status_icon"):
			self._main_square_status_icon = SettlerNotConnectedStatus(self) # save ref for removal later
			AddStatusIcon.broadcast(self, self._main_square_status_icon)
		# no main square found
		# check_duplicate: only trigger once for different settlers of a neighborhood
		self.session.ingame_gui.message_widget.add(point=self.position.origin,
		                                           string_id='NO_MAIN_SQUARE_IN_RANGE', check_duplicate=True)
开发者ID:ErwinJunge,项目名称:unknown-horizons,代码行数:21,代码来源:settler.py

示例8: recover

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def recover(self, building):
		super(BuildingInfluencingDisaster, self).recover(building)
		RemoveStatusIcon.broadcast(self, building, self.STATUS_ICON)
		callback = Callback(self.wreak_havoc, building)
		Scheduler().rem_call(self, callback)
		self._affected_buildings.remove(building)
开发者ID:BenjaminHarper,项目名称:unknown-horizons,代码行数:8,代码来源:buildinginfluencingdisaster.py

示例9: recover

# 需要导入模块: from horizons.messaging import RemoveStatusIcon [as 别名]
# 或者: from horizons.messaging.RemoveStatusIcon import broadcast [as 别名]
	def recover(self, building):
		super(FireDisaster, self).recover(building)
		RemoveStatusIcon.broadcast(self, building, FireStatusIcon)
		Scheduler().rem_call(self, Callback(self.wreak_havoc, building))
		self._affected_buildings.remove(building)
开发者ID:ChrisOelmueller,项目名称:unknown-horizons,代码行数:7,代码来源:firedisaster.py


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