コード例 #1
0
	def get_buildings_in_range(self, reslist=None):
		"""Returns all buildings in range .
		Overwrite in subclasses that need ranges around the pickup.
		@param res: optional, only search for buildings that provide res"""
		reach = RadiusRect(self.home_building.position, self.home_building.radius)
		return self.home_building.island.get_providers_in_range(reach, reslist=reslist,
		                                                        player=self.owner)
コード例 #2
0
 def get_providers(self):
     reach = RadiusRect(self.position, self.radius)
     resources = self.get_consumed_resources(include_inactive=True)
     providers = self.island.get_providers_in_range(reach,
                                                    reslist=resources)
     return [
         provider for provider in providers if isinstance(provider, Field)
     ]
コード例 #3
0
	def get_animals_in_range(self, reslist=None):
		"""Returns animals from buildings in range"""
		reach = RadiusRect(self.home_building.position, self.home_building.radius)
		# don't consider res when searching for buildings, since only their animals are
		# the actual providers
		buildings = self.home_building.island.get_providers_in_range(reach)
		animal_lists = (building.animals for building in buildings if hasattr(building, 'animals'))
		# use overloaded + for lists here in sum
		return sum(animal_lists, [])
コード例 #4
0
	def _do_select(cls, renderer, position, world, settlement, radius,
	               range_applies_only_on_island):
		# No super, we don't want to color the ground
		cls._init_fake_tile()
		layer = world.session.view.layers[LAYERS.FIELDS]
		for fish_deposit in world.get_providers_in_range(RadiusRect(position, radius), res=RES.FISH):
			#renderer.addColored(fish_deposit._instance, *cls.selection_color)
			#cls._selected_tiles.l.append(fish_deposit)
			for pos in fish_deposit.position:
				cls._add_fake_tile(pos.x, pos.y, layer, renderer)