Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutable special chunk placement #52056

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions data/json/overmap/overmap_mutable/microlab_mutable.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"west": "microlab_to_microlab"
},
"microlab_sub_station": { "overmap": "microlab_sub_station_north", "north": "microlab_station_to_subway", "south": "microlab_entry_to_station" },
"microlab_subway": { "overmap": "microlab_sub_connector_south", "north": "microlab_station_to_subway" },
"microlab_subway": { "overmap": "microlab_sub_connector_north", "south": "microlab_station_to_subway" },
"firebreak": { "overmap": "microlab_generic_firebreak_north", "north": "hallway_to_hallway", "south": "hallway_to_hallway" },
"hallway_cross": {
"overmap": "microlab_generic_hallway_nesw",
Expand All @@ -81,22 +81,43 @@
"south": "hallway_to_hallway",
"west": "hallway_to_hallway"
},
"hallway_blind_tee": {
"overmap": "microlab_generic_hallway_nes",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": "hallway_to_hallway",
"west": { "id": "microlab_to_microlab", "type": "available" }
},
"hallway_straight": {
"overmap": "microlab_generic_hallway_ns",
"north": "hallway_to_hallway",
"east": "microlab_to_microlab",
"south": "hallway_to_hallway",
"west": "microlab_to_microlab"
},
"hallway_blind_straight": {
"overmap": "microlab_generic_hallway_ns",
"north": "hallway_to_hallway",
"east": { "id": "microlab_to_microlab", "type": "available" },
"south": "hallway_to_hallway",
"west": { "id": "microlab_to_microlab", "type": "available" }
},
"hallway_curve": {
"overmap": "microlab_generic_hallway_ne",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": "microlab_to_microlab",
"west": "microlab_to_microlab"
},
"hallway_blind_curve": {
"overmap": "microlab_generic_hallway_ne",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": { "id": "microlab_to_microlab", "type": "available" },
"west": { "id": "microlab_to_microlab", "type": "available" }
},
"hallway_end": {
"overmap": "microlab_generic_hallway_end_north",
"overmap": "microlab_generic_hallway_end_south",
"north": "hallway_to_hallway",
"east": "microlab_to_microlab",
"south": "microlab_to_microlab",
Expand All @@ -115,9 +136,15 @@
[ { "overmap": "below_entrance", "max": 1 } ],
[ { "overmap": "surface_access", "max": 1 } ],
[
{ "overmap": "microlab_sub_entry", "max": 1 },
{ "overmap": "microlab_sub_station", "max": 1 },
{ "overmap": "microlab_subway", "max": 1 }
{
"name": "subway_chunk_at_-2",
"chunk": [
{ "overmap": "microlab_sub_entry", "pos": [ 0, 0, 0 ] },
{ "overmap": "microlab_sub_station", "pos": [ 0, -1, 0 ] },
{ "overmap": "microlab_subway", "pos": [ 0, -2, 0 ] }
],
"max": 1
}
],
[ { "overmap": "hallway_end", "max": 1 } ],
[ { "overmap": "hallway_straight", "max": 5 } ],
Expand All @@ -126,10 +153,12 @@
[ { "overmap": "hallway_end", "max": 3 } ],
[ { "overmap": "microlab", "max": 20 } ],
[
{ "overmap": "microlab_edge", "weight": 1000 },
{ "overmap": "hallway_end", "weight": 10 },
{ "overmap": "hallway_curve", "weight": 1 },
{ "overmap": "hallway_blind_end", "weight": 1 }
{ "overmap": "microlab_edge", "weight": 1000000 },
{ "overmap": "hallway_end", "weight": 100 },
{ "overmap": "hallway_blind_end", "weight": 30 },
{ "overmap": "hallway_blind_straight", "weight": 10 },
{ "overmap": "hallway_blind_curve", "weight": 10 },
{ "overmap": "hallway_blind_tee", "weight": 1 }
]
]
}
Expand Down
208 changes: 208 additions & 0 deletions data/mods/TEST_DATA/overmap_specials.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,213 @@
},
"root": "crater_all",
"phases": [ [ { "overmap": "crater_all", "max": { "poisson": 5 } } ], [ { "overmap": "crater_edge", "weight": 1 } ] ]
},
{
"type": "overmap_special",
"id": "test_microlab",
"subtype": "mutable",
"locations": [ "subterranean_empty" ],
"city_distance": [ 25, -1 ],
"city_sizes": [ 0, 20 ],
"occurrences": [ 0, 1 ],
"flags": [ "CLASSIC", "WILDERNESS" ],
"check_for_locations": [
[ [ 0, 0, 0 ], [ "land" ] ],
[ [ 0, 0, -1 ], [ "subterranean_empty" ] ],
[ [ 0, 0, -2 ], [ "subterranean_empty" ] ],
[ [ 1, 0, -2 ], [ "subterranean_empty" ] ],
[ [ 0, 1, -2 ], [ "subterranean_empty" ] ],
[ [ -1, 0, -2 ], [ "subterranean_empty" ] ],
[ [ 0, -1, -2 ], [ "subterranean_empty" ] ]
],
"joins": [
"hallway_to_hallway",
"duct_to_surface",
"duct_to_entrance",
"microlab_to_microlab",
{ "id": "hallway_to_microlab", "opposite": "microlab_to_hallway" },
{ "id": "microlab_to_hallway", "opposite": "hallway_to_microlab" },
"microlab_entry_to_station",
"microlab_station_to_subway",
"stairs_down_to_middle",
"stairs_up_to_middle"
],
"overmaps": {
"surface": { "overmap": "lab_subway_vent_shaft_surface", "below": "duct_to_surface", "locations": [ "land" ] },
"below_entrance": { "overmap": "lab_subway_vent_shaft-1", "above": "duct_to_surface", "below": "duct_to_entrance" },
"surface_access": {
"overmap": "microlab_generic_vent_shaft_connector",
"above": "duct_to_entrance",
"north": "microlab_to_microlab",
"east": "microlab_to_microlab",
"south": "microlab_to_microlab",
"west": "microlab_to_microlab"
},
"stairs_down": { "overmap": "microlab_generic_stairs_down_north", "below": "stairs_down_to_middle", "north": "hallway_to_hallway" },
"stairs_middle": {
"overmap": "microlab_generic_isolated_stairs_odd_north",
"above": "stairs_down_to_middle",
"below": "stairs_up_to_middle"
},
"stairs_up": {
"overmap": "microlab_generic_isolated_stairs_up_north",
"above": "stairs_up_to_middle",
"north": "hallway_to_hallway"
},
"microlab": {
"overmap": "microlab_generic",
"north": "microlab_to_microlab",
"east": "microlab_to_microlab",
"south": "microlab_to_microlab",
"west": "microlab_to_microlab"
},
"microlab_edge": {
"overmap": "microlab_generic_edge",
"north": { "id": "microlab_to_microlab", "type": "available" },
"east": { "id": "microlab_to_microlab", "type": "available" },
"south": { "id": "microlab_to_microlab", "type": "available" },
"west": { "id": "microlab_to_microlab", "type": "available" }
},
"microlab_sub_entry": {
"overmap": "microlab_generic_sub_entry_north",
"north": "microlab_entry_to_station",
"east": "microlab_to_microlab",
"south": "microlab_to_microlab",
"west": "microlab_to_microlab"
},
"microlab_sub_station": { "overmap": "microlab_sub_station_north", "north": "microlab_station_to_subway", "south": "microlab_entry_to_station" },
"microlab_subway": { "overmap": "microlab_sub_connector_south", "south": "microlab_station_to_subway" },
"firebreak": { "overmap": "microlab_generic_firebreak_north", "north": "hallway_to_hallway", "south": "hallway_to_hallway" },
"hallway_cross": {
"overmap": "microlab_generic_hallway_nesw",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": "hallway_to_hallway",
"west": "hallway_to_hallway"
},
"hallway_straight": {
"overmap": "microlab_generic_hallway_ns",
"north": "hallway_to_hallway",
"east": "microlab_to_microlab",
"south": "hallway_to_hallway",
"west": "microlab_to_microlab"
},
"hallway_blind_straight": {
"overmap": "microlab_generic_hallway_ns",
"north": "hallway_to_hallway",
"east": { "id": "microlab_to_microlab", "type": "available" },
"south": "hallway_to_hallway",
"west": { "id": "microlab_to_microlab", "type": "available" }
},
"hallway_tee": {
"overmap": "microlab_generic_hallway_nes",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": "hallway_to_hallway",
"west": "microlab_to_microlab"
},
"hallway_blind_tee": {
"overmap": "microlab_generic_hallway_nes",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": "hallway_to_hallway",
"west": { "id": "microlab_to_microlab", "type": "available" }
},
"hallway_corner": {
"overmap": "microlab_generic_hallway_ne",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": "microlab_to_microlab",
"west": "microlab_to_microlab"
},
"hallway_blind_corner": {
"overmap": "microlab_generic_hallway_ne",
"north": "hallway_to_hallway",
"east": "hallway_to_hallway",
"south": { "id": "microlab_to_microlab", "type": "available" },
"west": { "id": "microlab_to_microlab", "type": "available" }
},
"hallway_end": {
"overmap": "microlab_generic_hallway_end_south",
"north": "hallway_to_hallway",
"east": "microlab_to_microlab",
"south": "microlab_to_microlab",
"west": "microlab_to_microlab"
},
"hallway_blind_end": {
"overmap": "microlab_generic_hallway_blind_end_south",
"north": { "id": "hallway_to_hallway" },
"east": { "id": "microlab_to_microlab", "type": "available" },
"south": { "id": "microlab_to_microlab", "type": "available" },
"west": { "id": "microlab_to_microlab", "type": "available" }
}
},
"root": "surface",
"phases": [
[ { "overmap": "below_entrance", "max": 1 } ],
[ { "overmap": "surface_access", "max": 1 } ],
[
{
"name": "subway_chunk_at_-2",
"chunk": [
{ "overmap": "microlab_sub_entry", "pos": [ 0, 0, 0 ], "rot": "north" },
{ "overmap": "microlab_sub_station", "pos": [ 0, -1, 0 ] },
{ "overmap": "microlab_subway", "pos": [ 0, -2, 0 ] }
],
"max": 1
}
],
[ { "overmap": "hallway_end", "max": 1 } ],
[ { "overmap": "hallway_straight", "max": 3 } ],
[ { "overmap": "hallway_cross", "max": 1 } ],
[
{ "overmap": "hallway_corner", "max": 1 },
{ "overmap": "hallway_straight", "max": 10 },
{ "overmap": "firebreak", "max": 1 }
],
[
{ "overmap": "hallway_end", "max": 2 },
{
"name": "stairs_to_-4",
"chunk": [
{ "overmap": "stairs_down", "pos": [ 0, 0, 0 ] },
{ "overmap": "stairs_middle", "pos": [ 0, 0, -1 ] },
{ "overmap": "stairs_up", "pos": [ 0, 0, -2 ] }
],
"max": 1
}
],
[ { "overmap": "microlab", "max": 20 } ],
[
{ "overmap": "microlab_edge", "weight": 1000 },
{ "overmap": "hallway_blind_end", "weight": 10 },
{ "overmap": "hallway_blind_corner", "weight": 1 },
{ "overmap": "hallway_blind_straight", "weight": 1 },
{ "overmap": "hallway_blind_tee", "weight": 1 },
{ "overmap": "hallway_cross", "weight": 1 }
],
[ { "overmap": "hallway_straight", "max": 3 } ],
[ { "overmap": "hallway_end", "max": 1 } ],
[
{
"name": "subway_chunk_at_-4",
"chunk": [
{ "overmap": "microlab_sub_entry", "pos": [ 0, 0, 0 ] },
{ "overmap": "microlab_sub_station", "pos": [ 0, -1, 0 ] },
{ "overmap": "microlab_subway", "pos": [ 0, -2, 0 ] }
],
"max": 1
}
],
[ { "overmap": "microlab", "max": 10 } ],
[
{ "overmap": "microlab_edge", "weight": 1000 },
{ "overmap": "hallway_blind_end", "weight": 10 },
{ "overmap": "hallway_corner", "weight": 1 },
{ "overmap": "hallway_straight", "weight": 1 },
{ "overmap": "hallway_tee", "weight": 1 },
{ "overmap": "hallway_cross", "weight": 1 }
]
]
}
]
30 changes: 30 additions & 0 deletions doc/OVERMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,36 @@ proceeds to the next phase.
If all phases complete and unsatisfied joins remain, this is considered an
error and a debugmsg will be displayed with more details.

#### Chunks

A placement rule in the phases can specify multiple overmaps to be placed in a
particular configuration. This is useful if you want to place some feature
that's larger than a single OMT. Here is an example from the microlab:

```json
{
"name": "subway_chunk_at_-2",
"chunk": [
{ "overmap": "microlab_sub_entry", "pos": [ 0, 0, 0 ], "rot": "north" },
{ "overmap": "microlab_sub_station", "pos": [ 0, -1, 0 ] },
{ "overmap": "microlab_subway", "pos": [ 0, -2, 0 ] }
],
"max": 1
}
```

The `"name"` of a chunk is only for debugging messages when something goes
wrong. `"max"` and `"weight"` are handled as above.

The new feature is `"chunks"` which specifies a list of overmaps and their
relative positions and rotations. The overmaps are taken from the ones defined
for this special. Rotation of `"north"` is the default, so specifying that has
no effect, but it's included here to demonstrate the syntax.

The postions and rotations are relative. The chunk can be placed at any offset
and rotation, so long as all the overmaps are shifted and rotated together like
a rigid body.

#### Techniques to avoid placement errors

To help avoid these errors, some additional features of the mutable special
Expand Down
7 changes: 4 additions & 3 deletions src/cube_direction.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ template <> struct hash<cube_direction> {
};
} // namespace std

cube_direction operator+( const cube_direction, const om_direction::type );
cube_direction operator+( const cube_direction, int i );
cube_direction operator-( const cube_direction, int i );
cube_direction operator+( cube_direction, om_direction::type );
cube_direction operator+( cube_direction, int i );
cube_direction operator-( cube_direction, om_direction::type );
cube_direction operator-( cube_direction, int i );

#endif // CATA_SRC_CUBE_DIRECTION_H
15 changes: 12 additions & 3 deletions src/omdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum class type : int {
east,
south,
west,
last
};

/** For the purposes of iteration. */
Expand All @@ -65,15 +66,18 @@ const size_t size = all.size();
/** Number of bits needed to store directions. */
const size_t bits = static_cast<size_t>( -1 ) >> ( CHAR_BIT *sizeof( size_t ) - size );

/** Identifier for serialization purposes. */
const std::string &id( type dir );

/** Get Human readable name of a direction */
std::string name( type dir );

/** Various rotations. */
point rotate( const point &p, type dir );
tripoint rotate( const tripoint &p, type dir );
template<typename Point, coords::scale Scale>
auto rotate( const coords::coord_point<Point, coords::origin::relative, Scale> &p, type dir )
-> coords::coord_point<Point, coords::origin::relative, Scale>
{
return coords::coord_point<Point, coords::origin::relative, Scale> { rotate( p.raw(), dir ) };
}
uint32_t rotate_symbol( uint32_t sym, type dir );

/** Returns point(0, 0) displaced in specified direction by a specified distance
Expand Down Expand Up @@ -103,6 +107,11 @@ bool are_parallel( type dir1, type dir2 );

} // namespace om_direction

template<>
struct enum_traits<om_direction::type> {
static constexpr om_direction::type last = om_direction::type::last;
};

class overmap_land_use_code
{
public:
Expand Down
Loading