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


Python SettlerInhabitantsChanged.broadcast方法代码示例

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


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

示例1: initialize

# 需要导入模块: from horizons.messaging import SettlerInhabitantsChanged [as 别名]
# 或者: from horizons.messaging.SettlerInhabitantsChanged import broadcast [as 别名]
	def initialize(self):
		super(Settler, self).initialize()
		SettlerInhabitantsChanged.broadcast(self, self.inhabitants)
		happiness = self.__get_data("happiness_init_value")
		if happiness is not None:
			self.get_component(StorageComponent).inventory.alter(RES.HAPPINESS, happiness)
		if self.has_status_icon:
			self.get_component(StorageComponent).inventory.add_change_listener( self._update_status_icon )
		# give the user a month (about 30 seconds) to build a main square in range
		if self.owner.is_local_player:
			Scheduler().add_new_object(self._check_main_square_in_range, self, Scheduler().get_ticks_of_month())
		self.__init()
		self.run()
开发者ID:STEVEOO6,项目名称:unknown-horizons,代码行数:15,代码来源:settler.py

示例2: inhabitant_check

# 需要导入模块: from horizons.messaging import SettlerInhabitantsChanged [as 别名]
# 或者: from horizons.messaging.SettlerInhabitantsChanged import broadcast [as 别名]
	def inhabitant_check(self):
		"""Checks whether or not the population of this settler should increase or decrease"""
		change = 0
		if self.happiness > self.session.db.get_settler_happiness_increase_requirement() and \
			 self.inhabitants < self.inhabitants_max:
			change = 1
			self.log.debug("%s: inhabitants increase to %s", self, self.inhabitants)
		elif self.happiness < self.session.db.get_settler_happiness_decrease_limit() and \
		     self.inhabitants > 1:
			change = -1
			self.log.debug("%s: inhabitants decrease to %s", self, self.inhabitants)

		if change != 0:
			# see http://wiki.unknown-horizons.org/w/Supply_citizens_with_resources
			self.get_component(Producer).alter_production_time( 6.0/7.0 * math.log( 1.5 * (self.inhabitants + 1.2) ) )
			self.inhabitants += change
			SettlerInhabitantsChanged.broadcast(self, change)
			self._changed()
开发者ID:STEVEOO6,项目名称:unknown-horizons,代码行数:20,代码来源:settler.py

示例3: remove

# 需要导入模块: from horizons.messaging import SettlerInhabitantsChanged [as 别名]
# 或者: from horizons.messaging.SettlerInhabitantsChanged import broadcast [as 别名]
	def remove(self):
		SettlerInhabitantsChanged.broadcast(self, -self.inhabitants)

		UpgradePermissionsChanged.unsubscribe(self._on_change_upgrade_permissions, sender=self.settlement)
		super(Settler, self).remove()
开发者ID:STEVEOO6,项目名称:unknown-horizons,代码行数:7,代码来源:settler.py


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