From baa758921b4c847f297bb27863eb92bc4f164350 Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Fri, 1 May 2015 01:38:39 +0100 Subject: [PATCH] Made defineRegion() procs additive instead of overwriting, overwriting has been moved to a "replace" argument, adds undefineRegion() which makes the map list a new list. --- .../procedural mapping/mapGenerator.dm | 19 +++++++++++++++---- .../procedural mapping/mapGeneratorReadme.dm | 14 +++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index cda6f44c991..541c280fa4e 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -13,17 +13,20 @@ //Defines the region the map represents, sets map //Returns the map -/datum/mapGenerator/proc/defineRegion(var/turf/Start, var/turf/End) +/datum/mapGenerator/proc/defineRegion(var/turf/Start, var/turf/End, var/replace = 0) if(!checkRegion(Start, End)) return 0 - map = block(Start,End) + if(replace) + undefineRegion() + + map |= block(Start,End) return map //Defines the region the map represents, as a CIRCLE!, sets map //Returns the map -/datum/mapGenerator/proc/defineCircularRegion(var/turf/Start, var/turf/End) +/datum/mapGenerator/proc/defineCircularRegion(var/turf/Start, var/turf/End, var/replace = 0) if(!checkRegion(Start, End)) return 0 @@ -34,10 +37,18 @@ var/turf/center = locate(centerX, centerY, centerZ) //spherical maps! because Idk - map = circlerange(center,radius) + if(replace) + undefineRegion() + + map |= circlerange(center,radius) return map +//Empties the map list, he's dead jim. +/datum/mapGenerator/proc/undefineRegion() + map = list() //bai bai + + //Checks for and Rejects bad region coordinates //Returns 1/0 /datum/mapGenerator/proc/checkRegion(var/turf/Start, var/turf/End) diff --git a/code/modules/procedural mapping/mapGeneratorReadme.dm b/code/modules/procedural mapping/mapGeneratorReadme.dm index 636d64cd90b..bb43a331afc 100644 --- a/code/modules/procedural mapping/mapGeneratorReadme.dm +++ b/code/modules/procedural mapping/mapGeneratorReadme.dm @@ -11,18 +11,22 @@ mapGenerator: Desc: a mapGenerator is a master datum that collects and syncs all mapGeneratorModules in it's modules list - defineRegion(var/turf/Start, var/turf/End) - Example: defineRegion(locate(1,1,1),locate(5,5,5)) + defineRegion(var/turf/Start, var/turf/End, var/replace = 0) + Example: defineRegion(locate(1,1,1),locate(5,5,5),0) Desc: Sets the bounds of the mapGenerator's "map" - defineCircularRegion(var/turf/Start, var/turf/End) - Example: defineCircularRegion(locate(1,1,1),locate(5,5,5)) + defineCircularRegion(var/turf/Start, var/turf/End, var/replace = 0) + Example: defineCircularRegion(locate(1,1,1),locate(5,5,5),0) Desc: Sets the mapGenerator's "map" as a circle, with center in the middle of Start and End's X,Y,Z coordinates + undefineRegion() + Example: undefineRegion() + Desc: Empties the map generator list + checkRegion(var/turf/Start, var/turf/End) Example: checkRegion(locate(1,1,1), locate(5,5,5)) Desc: Checks if a rectangle between Start's coords and End's coords is valid - Existing Calls: mapGenerator/defineRegion() + Existing Calls: mapGenerator/defineRegion(), mapGenerator/defineCircularRegion() generate() Example: generate()