diff --git a/bapi.dll b/bapi.dll index 27d3d9104a2..172b0a9e7bc 100644 Binary files a/bapi.dll and b/bapi.dll differ diff --git a/code/modules/effects/map_effects/marker/mapmanip.dm b/code/modules/effects/map_effects/marker/mapmanip.dm index 3686ead8e54..b6c19c1ed48 100644 --- a/code/modules/effects/map_effects/marker/mapmanip.dm +++ b/code/modules/effects/map_effects/marker/mapmanip.dm @@ -28,6 +28,14 @@ icon_state = "mapmanip_insert" pixel_x = -32 pixel_y = -32 + /// Direction of submap insertion. + /// Default is NORTHEAST, meaning the marker is the bottom-left corner, + /// and the submap is inserted to the north-east starting from the marker. + /// Directions such as NORTH means the marker is bottom-center, + /// and the submap is inserted to the north starting from the marker. + /// + /// Must be set in map (if anything other than NORTHEAST), as mapmanip does not read code. + dir = NORTHEAST /obj/effect/map_effect/marker_helper/mapmanip/submap/edge name = "mapmanip helper marker, edge of submap" diff --git a/html/changelogs/DreamySkrell-directional-submap-insert-marker.yml b/html/changelogs/DreamySkrell-directional-submap-insert-marker.yml new file mode 100644 index 00000000000..61c91287e8d --- /dev/null +++ b/html/changelogs/DreamySkrell-directional-submap-insert-marker.yml @@ -0,0 +1,7 @@ + +author: DreamySkrell + +delete-after: True + +changes: + - rscadd: "Submap insert markers now support different directions." diff --git a/icons/effects/map_effects_96x96.dmi b/icons/effects/map_effects_96x96.dmi index fa0c418f374..42c6f0ba819 100644 Binary files a/icons/effects/map_effects_96x96.dmi and b/icons/effects/map_effects_96x96.dmi differ diff --git a/rust/bapi/src/mapmanip/mod.rs b/rust/bapi/src/mapmanip/mod.rs index b801b808523..0f543b3b1b1 100644 --- a/rust/bapi/src/mapmanip/mod.rs +++ b/rust/bapi/src/mapmanip/mod.rs @@ -169,8 +169,49 @@ fn mapmanip_submap_extract_insert( // find all the insert markers let mut marker_insert_coords = vec![]; - for (coord, tile) in map.grid.iter() { - if tile.prefabs.iter().any(|p| p.path == *marker_insert) { + for (mut coord, tile) in map.grid.iter() { + if let Some(p) = tile.prefabs.iter().find(|p| p.path == *marker_insert) { + let dir = p + .vars + .get("dir") + .and_then(Constant::to_float) + .and_then(|f| Dir::from_int(f as i32)) + .unwrap_or(Dir::Northeast); + + // Adjust for direction of submap insertion. + // Default is NORTHEAST, meaning the marker is the bottom-left corner, + // and the submap is inserted to the north-east starting from the marker. + // Directions such as NORTH means the marker is bottom-center, + // and the submap is inserted to the north starting from the marker. + match dir { + Dir::North => { + coord.x -= submap_size.x / 2; + } + Dir::South => { + coord.x -= submap_size.x / 2; + coord.y -= submap_size.y - 1; + } + Dir::East => { + coord.y -= submap_size.y / 2; + } + Dir::West => { + coord.x -= submap_size.x - 1; + coord.y -= submap_size.y / 2; + } + Dir::Northeast => { + // default, no offset needed + } + Dir::Northwest => { + coord.x -= submap_size.x - 1; + } + Dir::Southeast => { + coord.y -= submap_size.y - 1; + } + Dir::Southwest => { + coord.x -= submap_size.x - 1; + coord.y -= submap_size.y - 1; + } + } marker_insert_coords.push(coord); } } diff --git a/tools/ci/libbapi_ci.so b/tools/ci/libbapi_ci.so index 50d546f1983..2d3ef277e1c 100644 Binary files a/tools/ci/libbapi_ci.so and b/tools/ci/libbapi_ci.so differ