本文整理汇总了Python中horizons.messaging.SettlementRangeChanged.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Python SettlementRangeChanged.subscribe方法的具体用法?Python SettlementRangeChanged.subscribe怎么用?Python SettlementRangeChanged.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.messaging.SettlementRangeChanged
的用法示例。
在下文中一共展示了SettlementRangeChanged.subscribe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: highlight_buildable
# 需要导入模块: from horizons.messaging import SettlementRangeChanged [as 别名]
# 或者: from horizons.messaging.SettlementRangeChanged import subscribe [as 别名]
def highlight_buildable(self, building_tool, tiles_to_check=None):
"""Highlights all buildable tiles.
@param tiles_to_check: list of tiles to check for coloring."""
# resolved variables from inner loops
is_tile_buildable = building_tool._class.is_tile_buildable
session = building_tool.session
player = session.world.player
if not self.subscribed:
self.subscribed = True
SettlementRangeChanged.subscribe(self._on_update)
if tiles_to_check is not None: # only check these tiles
for tile in tiles_to_check:
if is_tile_buildable(session, tile, None):
building_tool._color_buildable_tile(tile)
else: #default build on island
for settlement in session.world.settlements:
if settlement.owner == player:
island = session.world.get_island(Point(*settlement.ground_map.iterkeys().next()))
for tile in settlement.ground_map.itervalues():
if is_tile_buildable(session, tile, None, island, check_settlement=False):
building_tool._color_buildable_tile(tile)
示例2: __init
# 需要导入模块: from horizons.messaging import SettlementRangeChanged [as 别名]
# 或者: from horizons.messaging.SettlementRangeChanged import subscribe [as 别名]
def __init(self):
self._enabled = True # whether this player is enabled (currently disabled at the end of the game)
self.world = self.session.world
self.islands = {}
self.settlement_managers = []
self._settlement_manager_by_settlement_id = {}
self.missions = set()
self.fishers = []
self.settlement_founder = SettlementFounder(self)
self.unit_builder = UnitBuilder(self)
self.unit_manager = UnitManager(self)
self.combat_manager = CombatManager(self)
self.strategy_manager = StrategyManager(self)
self.behavior_manager = BehaviorManager(self)
self.settlement_expansions = [] # [(coords, settlement)]
self.goals = [DoNothingGoal(self)]
self.special_domestic_trade_manager = SpecialDomesticTradeManager(self)
self.international_trade_manager = InternationalTradeManager(self)
SettlementRangeChanged.subscribe(self._on_settlement_range_changed)