本文整理汇总了Python中horizons.messaging.SettlementRangeChanged类的典型用法代码示例。如果您正苦于以下问题:Python SettlementRangeChanged类的具体用法?Python SettlementRangeChanged怎么用?Python SettlementRangeChanged使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SettlementRangeChanged类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_settlement
def remove_settlement(self, building):
"""Removes the settlement property from tiles within the radius of the given building"""
settlement = building.settlement
buildings_to_abandon, settlement_coords_to_change = Tear.additional_removals_after_tear(building)
assert building not in buildings_to_abandon
self.abandon_buildings(buildings_to_abandon)
flat_land_set = self.terrain_cache.cache[TerrainRequirement.LAND][(1, 1)]
land_or_coast = self.terrain_cache.land_or_coast
settlement_tiles_changed = []
clean_coords = set()
for coords in settlement_coords_to_change:
tile = self.ground_map[coords]
tile.settlement = None
building = tile.object
if building is not None:
settlement.remove_building(building)
building.owner = None
building.settlement = None
if coords in land_or_coast:
clean_coords.add(coords)
settlement_tiles_changed.append(self.ground_map[coords])
del settlement.ground_map[coords]
Minimap.update(coords)
if coords in flat_land_set:
self.available_flat_land += 1
self.available_land_cache.add_area(clean_coords)
self._register_change()
if self.terrain_cache:
settlement.buildability_cache.modify_area(clean_coords)
SettlementRangeChanged.broadcast(settlement, settlement_tiles_changed)
示例2: highlight_buildable
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)
示例3: early_end
def early_end(self):
"""Called to speed up session destruction."""
assert self._enabled
self._enabled = False
SettlementRangeChanged.unsubscribe(self._on_settlement_range_changed)
NewDisaster.unsubscribe(self.notify_new_disaster)
MineEmpty.unsubscribe(self.notify_mine_empty)
示例4: assign_settlement
def assign_settlement(self, position, radius, settlement):
"""Assigns the settlement property to tiles within the circle defined by \
position and radius.
@param position: Rect
@param radius:
@param settlement:
"""
settlement_coords_changed = []
for coords in position.get_radius_coordinates(radius, include_self=True):
if coords not in self.ground_map:
continue
tile = self.ground_map[coords]
if tile.settlement is not None:
continue
tile.settlement = settlement
settlement.ground_map[coords] = tile
settlement_coords_changed.append(coords)
building = tile.object
# In theory fish deposits should never be on the island but this has been
# possible since they were turned into a 2x2 building. Since they are never
# entirely on the island then it is easiest to just make it impossible to own
# fish deposits.
if building is None or building.id == BUILDINGS.FISH_DEPOSIT:
continue
# Assign the entire building to the first settlement that covers some of it.
assert building.settlement is None or building.settlement is settlement
for building_coords in building.position.tuple_iter():
building_tile = self.ground_map[building_coords]
if building_tile.settlement is not settlement:
assert building_tile.settlement is None
building_tile.settlement = settlement
settlement.ground_map[building_coords] = building_tile
settlement_coords_changed.append(building_coords)
building.settlement = settlement
building.owner = settlement.owner
settlement.add_building(building)
if not settlement_coords_changed:
return
flat_land_set = self.terrain_cache.cache[TerrainRequirement.LAND][(1, 1)]
settlement_tiles_changed = []
for coords in settlement_coords_changed:
settlement_tiles_changed.append(self.ground_map[coords])
Minimap.update(coords)
if coords in flat_land_set:
self.available_flat_land -= 1
self.available_land_cache.remove_area(settlement_coords_changed)
self._register_change()
if self.terrain_cache:
settlement.buildability_cache.modify_area(settlement_coords_changed)
SettlementRangeChanged.broadcast(settlement, settlement_tiles_changed)
示例5: __init
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)
示例6: assign_settlement
def assign_settlement(self, position, radius, settlement):
"""Assigns the settlement property to tiles within the circle defined by \
position and radius.
@param position: Rect
@param radius:
@param settlement:
"""
settlement_tiles_changed = []
for coord in position.get_radius_coordinates(radius, include_self=True):
tile = self.get_tile_tuple(coord)
if tile is not None:
if tile.settlement == settlement:
continue
if tile.settlement is None:
tile.settlement = settlement
settlement.ground_map[coord] = tile
Minimap.update(coord)
self._register_change(coord[0], coord[1])
settlement_tiles_changed.append(tile)
# notify all AI players when land ownership changes
for player in self.session.world.players:
if hasattr(player, "on_settlement_expansion"):
player.on_settlement_expansion(settlement, coord)
building = tile.object
# found a new building, that is now in settlement radius
# assign buildings on tiles to settlement
if (
building is not None and building.settlement is None and building.island == self
): # don't steal from other islands
building.settlement = settlement
building.owner = settlement.owner
settlement.add_building(building)
if settlement_tiles_changed:
SettlementRangeChanged.broadcast(settlement, settlement_tiles_changed)
示例7: remove_settlement
def remove_settlement(self, position, radius, settlement):
"""Removes the settlement property from tiles within the circle defined by \
position and radius.
@param position: Rect
@param radius:
@param settlement:
"""
buildings_to_abandon, settlement_coords_to_change = Tear.destroyable_buildings(position, settlement)
self.abandon_buildings(buildings_to_abandon)
flat_land_set = self.terrain_cache.cache[TerrainRequirement.LAND][(1, 1)]
land_or_coast = self.terrain_cache.land_or_coast
settlement_tiles_changed = []
clean_coords = set()
for coords in settlement_coords_to_change:
tile = self.ground_map[coords]
tile.settlement = None
building = tile.object
if building is not None:
settlement.remove_building(building)
building.owner = None
building.settlement = None
if coords in land_or_coast:
clean_coords.add(coords)
settlement_tiles_changed.append(self.ground_map[coords])
del settlement.ground_map[coords]
Minimap.update(coords)
if coords in flat_land_set:
self.available_flat_land += 1
self.available_land_cache.add_area(clean_coords)
self._register_change()
if self.terrain_cache:
settlement.buildability_cache.modify_area(clean_coords)
SettlementRangeChanged.broadcast(settlement, settlement_tiles_changed)
示例8: remove
def remove(self, session):
if self.subscribed:
self.subscribed = False
SettlementRangeChanged.unsubscribe(self._on_update)
示例9: on_escape
def on_escape(self, session):
session.ingame_gui.show_build_menu() # will call remove()
if self.subscribed:
self.subscribed = False
SettlementRangeChanged.unsubscribe(self._on_update)
示例10: early_end
def early_end(self):
"""Called to speed up session destruction."""
assert self._enabled
self._enabled = False
SettlementRangeChanged.unsubscribe(self._on_settlement_range_changed)