Skip to content

Commit

Permalink
feat: add auto-populate cemeteries and factories
Browse files Browse the repository at this point in the history
  • Loading branch information
qthequartermasterman committed Dec 29, 2023
1 parent 2f88e11 commit ef654c1
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 7 deletions.
14 changes: 13 additions & 1 deletion docs/Background/geography/loot_locations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@ Barons, and will often have a small convenience store attached to them.

As the game master, you can decide whether a given gas station is maintained or not.

<populate_geotag gas_station />
<populate_geotag gas_station />

## Factories

Factories are a great place to find scrap, raw materials, and other useful items. Factories are generally unmaintained.

<populate_geotag factory />

## Cemeteries

Cemeteries are a great place to find scrap, raw materials, and other useful items. Cemeteries are generally unmaintained, except those close to current settlements.

<populate_geotag cemetery />
11 changes: 6 additions & 5 deletions render_map/auto_populate/auto_populate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import pydantic

from render_map import mapping
from render_map.auto_populate.map_features import auto_populate_gas_stations
from render_map.auto_populate.map_features import auto_populate_super_markets
from render_map.auto_populate import map_features
from render_map.auto_populate.map_features import map_features_utils

LOGGER = mkdocs.plugins.get_plugin_logger(__name__)
Expand Down Expand Up @@ -80,7 +79,7 @@ def populate_features(
node_ids_to_ignore.extend([node.id for node in way.nodes])
name, zoom, icon = choose_name_function(way)
# Skip over unnamed features (they're likely not important enough to show up on the game map).
if name is None:
if name is None or len(way.nodes) == 0:
continue
latitude = way.center_lat or way.nodes[0].lat
longitude = way.center_lon or way.nodes[0].lon
Expand All @@ -101,8 +100,10 @@ def populate_features(
class AutoPopulateConfig(pydantic.BaseModel):
"""The configuration for the auto-populate plugin."""

supermarket: Annotated[bool, auto_populate_super_markets.SuperMarketFeatureMetadata] = False
gas_station: Annotated[bool, auto_populate_gas_stations.GasStationFeatureMetadata] = False
supermarket: Annotated[bool, map_features.SuperMarketFeatureMetadata] = False
gas_station: Annotated[bool, map_features.GasStationFeatureMetadata] = False
factory: Annotated[bool, map_features.FactoryFeatureMetadata] = False
cemetery: Annotated[bool, map_features.CemeteryFeatureMetadata] = False

@staticmethod
def tag_name() -> str:
Expand Down
4 changes: 4 additions & 0 deletions render_map/auto_populate/map_features/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from render_map.auto_populate.map_features.auto_populate_gas_stations import GasStationFeatureMetadata
from render_map.auto_populate.map_features.auto_populate_super_markets import SuperMarketFeatureMetadata
from render_map.auto_populate.map_features.factories import FactoryFeatureMetadata
from render_map.auto_populate.map_features.cemeteries import CemeteryFeatureMetadata
38 changes: 38 additions & 0 deletions render_map/auto_populate/map_features/cemeteries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import overpy

from render_map import mapping
from render_map.auto_populate.map_features import map_features_utils

CEMETERY_QUERY = """[out:json];
(node[amenity=grave_yard](around:130000,29.7063997,-95.553997);
//way[landuse=cemetery](around:130000,29.7063997,-95.553997);
);
(._;>;);
out meta;
"""


def choose_cemetery_name(node: overpy.Node | overpy.Way) -> map_features_utils.NameZoomIcon:
"""Choose the game name and map zoom level for a cemetery, based on the properties of the supermarket in the
real world.
Args:
node: The node in OpenStreetMap representing the cemetery.
Returns:
Game name and map zoom level for the cemetery.
"""
name_from_node = node.tags.get("name", "")
if name_from_node is None:
return None, mapping.ZoomLevel.WASTELAND, mapping.map_icons.MapIcon.CEMETERY

# TODO: Make name of marker similar to its real world name
# TODO: Create really big cemeteries visible from the wasteland map

zoom_level = mapping.ZoomLevel.TOWN
return "Cemetery", zoom_level, mapping.map_icons.MapIcon.CEMETERY


CemeteryFeatureMetadata = map_features_utils.FeaturePopulateMetadata(
feature_type_name="cemeteries", query=CEMETERY_QUERY, choose_name_function=choose_cemetery_name
)
28 changes: 28 additions & 0 deletions render_map/auto_populate/map_features/factories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import overpy

from render_map import mapping
from render_map.auto_populate import auto_populate_utils
from render_map.auto_populate.map_features import map_features_utils

FACTORY_QUERY = """[out:json];
(node[man_made=works](around:{radius},{lat},{lon});
);
(._;>;);
out meta;
"""

def choose_factory_name(node: overpy.Node | overpy.Way) -> map_features_utils.NameZoomIcon:
"""Choose the game name and map zoom level for a factory, based on the properties of the factory in the real world.
Args:
node: The node in OpenStreetMap representing the factory.
Returns:
Game name and map zoom level for the factory.
"""
# TODO: Add more custom names
return "Factory", mapping.ZoomLevel.WASTELAND, mapping.map_icons.MapIcon.FACTORY

FactoryFeatureMetadata = map_features_utils.FeaturePopulateMetadata(
feature_type_name="factories", query=FACTORY_QUERY, choose_name_function=choose_factory_name
)
2 changes: 1 addition & 1 deletion render_map/map_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MapIcon(enum.Enum):
INN = DOOR_TARGET

SUPER_DUPER_MART = "https://static.wikia.nocookie.net/fallout_gamepedia/images/e/e9/14.svg"
CEMETARY = "https://static.wikia.nocookie.net/fallout_gamepedia/images/d/df/144.svg"
CEMETERY = "https://static.wikia.nocookie.net/fallout_gamepedia/images/d/df/144.svg"
RICE_VILLAGE = "https://static.wikia.nocookie.net/fallout_gamepedia/images/c/c8/147.svg"

DRIVE_IN = "https://static.wikia.nocookie.net/fallout_gamepedia/images/5/51/169.svg"
Expand Down

0 comments on commit ef654c1

Please sign in to comment.