Submaps can now be rotated to any cardinal direction (South is default)

This commit is contained in:
atermonera
2018-08-31 01:31:54 -07:00
parent a20085ccff
commit 2f9cebd38d
4 changed files with 34 additions and 39 deletions

View File

@@ -102,9 +102,11 @@ var/list/global/map_templates = list()
return TRUE
/datum/map_template/proc/load(turf/T, centered = FALSE, orientation = SOUTH)
world << "/datum/map_template/proc/load()\tPlacing at ([T.x], [T.y], [T.z])"
var/old_T = T
if(centered)
T = locate(T.x - round(width/2) , T.y - round(height/2) , T.z)
T = locate(T.x - round(((orientation & NORTH|SOUTH) ? width : height)/2) , T.y - round(((orientation & NORTH|SOUTH) ? height : width)/2) , T.z)
world << "\t\t\t\t\tCentered placement to ([T.x], [T.y], [T.z])"
if(!T)
return
if(T.x+width > world.maxx)
@@ -113,7 +115,7 @@ var/list/global/map_templates = list()
return
if(annihilate)
annihilate_bounds(old_T, centered)
annihilate_bounds(old_T, centered, orientation)
var/list/bounds = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE, orientation = orientation)
if(!bounds)
@@ -137,10 +139,10 @@ var/list/global/map_templates = list()
placement = corner
return block(placement, locate(placement.x+((orientation & NORTH|SOUTH) ? width : height)-1, placement.y+((orientation & NORTH|SOUTH) ? height : width)-1, placement.z))
/datum/map_template/proc/annihilate_bounds(turf/origin, centered = FALSE)
/datum/map_template/proc/annihilate_bounds(turf/origin, centered = FALSE, orientation = SOUTH)
var/deleted_atoms = 0
admin_notice("<span class='danger'>Annihilating objects in submap loading locatation.</span>", R_DEBUG)
var/list/turfs_to_clean = get_affected_turfs(origin, centered)
var/list/turfs_to_clean = get_affected_turfs(origin, centered, orientation)
if(turfs_to_clean.len)
for(var/turf/T in turfs_to_clean)
for(var/atom/movable/AM in T)
@@ -225,17 +227,21 @@ var/list/global/map_templates = list()
var/specific_sanity = 100 // A hundred chances to place the chosen submap.
while(specific_sanity > 0)
specific_sanity--
var/width_border = TRANSITIONEDGE + SUBMAP_MAP_EDGE_PAD + round(chosen_template.width / 2)
var/height_border = TRANSITIONEDGE + SUBMAP_MAP_EDGE_PAD + round(chosen_template.height / 2)
var/orientation = pick(cardinal)
chosen_template.preload_size(chosen_template.mappath, orientation)
var/width_border = TRANSITIONEDGE + SUBMAP_MAP_EDGE_PAD + round(((orientation & NORTH|SOUTH) ? chosen_template.width : chosen_template.height) / 2)
var/height_border = TRANSITIONEDGE + SUBMAP_MAP_EDGE_PAD + round(((orientation & NORTH|SOUTH) ? chosen_template.height : chosen_template.width) / 2)
var/z_level = pick(z_levels)
var/turf/T = locate(rand(width_border, world.maxx - width_border), rand(height_border, world.maxy - height_border), z_level)
var/valid = TRUE
for(var/turf/check in chosen_template.get_affected_turfs(T,1))
world << "Attempting to place [chosen_template.name] at ([T.x], [T.y], [T.z])"
for(var/turf/check in chosen_template.get_affected_turfs(T,TRUE,orientation))
var/area/new_area = get_area(check)
// world << "Checking ([check.x], [check.y], [check.z])\t area = [new_area.type]"
if(!(istype(new_area, whitelist)))
valid = FALSE // Probably overlapping something important.
// world << "Invalid due to overlapping with area [new_area.type], when wanting area [whitelist]."
// world << "Invalid due to overlapping with area [new_area.type] at ([check.x], [check.y], [check.z]), when attempting to place at ([T.x], [T.y], [T.z])."
break
CHECK_TICK
@@ -244,10 +250,10 @@ var/list/global/map_templates = list()
if(!valid)
continue
admin_notice("Submap \"[chosen_template.name]\" placed at ([T.x], [T.y], [T.z])", R_DEBUG)
admin_notice("Submap \"[chosen_template.name]\" placed at ([T.x], [T.y], [T.z])\n", R_DEBUG)
// Do loading here.
chosen_template.load(T, centered = TRUE, pick(cardinal)) // This is run before the main map's initialization routine, so that can initilize our submaps for us instead.
chosen_template.load(T, centered = TRUE, orientation=orientation) // This is run before the main map's initialization routine, so that can initilize our submaps for us instead.
CHECK_TICK