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