diff --git a/code/modules/procedural mapping/mapGenerator.dm b/code/modules/procedural mapping/mapGenerator.dm index 9a304e5c57a..cda6f44c991 100644 --- a/code/modules/procedural mapping/mapGenerator.dm +++ b/code/modules/procedural mapping/mapGenerator.dm @@ -3,8 +3,6 @@ //Map information var/list/map = list() - var/turf/bottomLeft = null - var/turf/topRight = null //mapGeneratorModule information var/list/modules = list() @@ -13,18 +11,30 @@ ..() initialiseModules() -//Defines the region the map represents, sets map, bottomLeft, topRight +//Defines the region the map represents, sets map //Returns the map /datum/mapGenerator/proc/defineRegion(var/turf/Start, var/turf/End) if(!checkRegion(Start, End)) return 0 - if(!Start || !End) - return 0 - bottomLeft = Start - topRight = End + map = block(Start,End) + return map - map = block(bottomLeft,topRight) + +//Defines the region the map represents, as a CIRCLE!, sets map +//Returns the map +/datum/mapGenerator/proc/defineCircularRegion(var/turf/Start, var/turf/End) + if(!checkRegion(Start, End)) + return 0 + + var/centerX = abs(max(End.x-Start.x,1)) + var/centerY = abs(max(End.y-Start.y,1)) + var/centerZ = abs(max(End.z-Start.z,1)) + var/radius = abs(max(centerX,centerY)) //take the biggest displacement as the radius + + var/turf/center = locate(centerX, centerY, centerZ) //spherical maps! because Idk + + map = circlerange(center,radius) return map diff --git a/code/modules/procedural mapping/mapGeneratorModule.dm b/code/modules/procedural mapping/mapGeneratorModule.dm index 458f11cd969..b7e84b5fda8 100644 --- a/code/modules/procedural mapping/mapGeneratorModule.dm +++ b/code/modules/procedural mapping/mapGeneratorModule.dm @@ -1,8 +1,19 @@ +//clusterCheckFlags defines +//All based on clusterMin and clusterMax as guides -#define CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible -#define CLUSTER_CHECK_ATOMS 2 //Don't let atoms cluster, based on clusterMin and clusterMax as guides -#define CLUSTER_CHECK_TURFS 4 //Don't let turfs cluster, based on clusterMin and clusterMax as guides -#define CLUSTER_CHECK_ALL 6 //Don't let anything cluster, based on clusterMind and clusterMax as guides +//Individual defines +#define CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible +#define CLUSTER_CHECK_DIFFERENT_TURFS 2 //Don't let turfs of DIFFERENT types cluster +#define CLUSTER_CHECK_DIFFERENT_ATOMS 4 //Don't let atoms of DIFFERENT types cluster +#define CLUSTER_CHECK_SAME_TURFS 8 //Don't let turfs of the SAME type cluster +#define CLUSTER_CHECK_SAME_ATOMS 16 //Don't let atoms of the SAME type cluster + +//Combined defines +#define CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types +#define CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types + +//All +#define CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all /datum/mapGeneratorModule var/datum/mapGenerator/mother = null @@ -38,24 +49,47 @@ //Turfs don't care whether atoms can be placed here for(var/turfPath in spawnableTurfs) - if(clusterCheckFlags & CLUSTER_CHECK_TURFS) - if(clusterMax && clusterMin) + + //Clustering! + if(clusterMax && clusterMin) + + //You're the same as me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_SAME_TURFS) clustering = rand(clusterMin,clusterMax) - if(locate(/atom/movable) in range(clustering, T)) + if(locate(turfPath) in trange(clustering, T)) continue + + //You're DIFFERENT to me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_TURFS) + clustering = rand(clusterMin,clusterMax) + for(var/turf/F in trange(clustering,T)) + if(istype(F, turfPath)) + continue + + //Success! if(prob(spawnableTurfs[turfPath])) T.ChangeTurf(turfPath) //Atoms DO care whether atoms can be placed here if(checkPlaceAtom(T)) + for(var/atomPath in spawnableAtoms) - if(clusterCheckFlags & CLUSTER_CHECK_ATOMS) - if(clusterMax && clusterMin) - clustering = rand(clusterMin,clusterMax) - if(locate(/atom/movable) in range(clustering, T)) + + //Clustering! + if(clusterMax && clusterMin) + + //You're the same as me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_SAME_ATOMS) + clustering = rand(clusterMin, clusterMax) + if(locate(atomPath) in range(clustering,T)) continue - if(prob(spawnableAtoms[atomPath])) - new atomPath (T) + + //You're DIFFERENT from me? I hate you I'm going home + if(clusterCheckFlags & CLUSTER_CHECK_DIFFERENT_ATOMS) + clustering = rand(clusterMin, clusterMax) + for(var/atom/movable/M in range(clustering,T)) + if(istype(M, atomPath)) + continue . = 1 diff --git a/code/modules/procedural mapping/mapGeneratorReadme.dm b/code/modules/procedural mapping/mapGeneratorReadme.dm index 95fa449624e..636d64cd90b 100644 --- a/code/modules/procedural mapping/mapGeneratorReadme.dm +++ b/code/modules/procedural mapping/mapGeneratorReadme.dm @@ -11,10 +11,14 @@ mapGenerator: Desc: a mapGenerator is a master datum that collects and syncs all mapGeneratorModules in it's modules list - defineRegion(var/list/startList, var/list/endList) + defineRegion(var/turf/Start, var/turf/End) Example: defineRegion(locate(1,1,1),locate(5,5,5)) 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)) + Desc: Sets the mapGenerator's "map" as a circle, with center in the middle of Start and End's X,Y,Z coordinates + 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 @@ -108,8 +112,6 @@ Variable Breakdown (For Mappers): mapGenerator map - INTERNAL, do not touch - bottomLeft - INTERNAL, do not touch - topRight - INTERNAL, do not touch modules - A list of typepaths of mapGeneratorModules mapGeneratorModule @@ -118,13 +120,20 @@ Variable Breakdown (For Mappers): spawnableTurfs - A list of typepaths and their probability to spawn, eg: spawnableTurfs = list(/turf/unsimulated/floor/grass = 100) clusterMax - The max range to check for something being "too close" for this atom/turf to spawn, the true value is random between clusterMin and clusterMax clusterMin - The min range to check for something being "too close" for this atom/turf to spawn, the true value is random between clusterMin and clusterMax - clusterCheckFlags - A Bitfield that controls how the cluster checks work. + clusterCheckFlags - A Bitfield that controls how the cluster checks work, All based on clusterMin and clusterMax guides clusterCheckFlags flags: - CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible - CLUSTER_CHECK_ATOMS 2 //Don't let atoms cluster, based on clusterMin and clusterMax as guides - CLUSTER_CHECK_TURFS 4 //Don't let turfs cluster, based on clusterMin and clusterMax as guides - CLUSTER_CHECK_ALL 6 //Don't let anything cluster, based on clusterMind and clusterMax as guides + CLUSTER_CHECK_NONE 0 //No checks are done, cluster as much as possible + CLUSTER_CHECK_DIFFERENT_TURFS 2 //Don't let turfs of DIFFERENT types cluster + CLUSTER_CHECK_DIFFERENT_ATOMS 4 //Don't let atoms of DIFFERENT types cluster + CLUSTER_CHECK_SAME_TURFS 8 //Don't let turfs of the SAME type cluster + CLUSTER_CHECK_SAME_ATOMS 16 //Don't let atoms of the SAME type cluster + + CLUSTER_CHECK_ALL_TURFS 32 //Don't let ANY turfs cluster same and different types + CLUSTER_CHECK_ALL_ATOMS 64 //Don't let ANY atoms cluster same and different types + + CLUSTER_CHECK_ALL 96 //Don't let anything cluster, like, at all + */ \ No newline at end of file