mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2025-12-11 13:31:08 +00:00
* move phoronlock define * t * force rename * nuke unneeded things * don't do that * tgui sync? * changes * unit testing module * backend * tools update * aaah * go and stay go * path replace * move everything * toss out more stuff * remove * fine those can stay * dependencies.sh * ruin datum move + rename * level assets why did you guys put the turfs in my atmosphers folder grr * more moving * basemap, force stuff * fix that desync meme * move more stuff * move those too * repath * get rid of useless initializers * hacky patchy * reservations * alright * tgui * changelog example * checksum * md5 * errors * more * turf empty * stop * fix * bad kwarg * let's get those in again * alright * rid of that * huh * newlines * newlines * folder * mood * woops * readme * might as well trim now * let's go * fuck it tether isn't being used anyways lol * ok * empty files go * tether is demoted * sorry but this goes too * okay * make that work too * ok * wow. * whew * Fix * fixes * ok * sigh * fix * fix * aah. * rust_g logging * update rust g file * fix * funny * Fix * map issues * fix * initialize hints * solves some problems * those too * ok * pills * let's do that. * hit that too * runtime * add that too * alright * fix * fix * fix * Fix * add * fix * wildwest, what have they done to you... * do that too' git push * fixes * fixes * fixes * pack this tightly * let's not have empty files * sigh * fix * FUCK OFF * fix icon * rip old mapmerge * zz * woo yeah woo yeah * logging * fix * better logs * GRRRRRR * last commit?? * awful
66 lines
2.6 KiB
Plaintext
66 lines
2.6 KiB
Plaintext
/datum/random_map/automata
|
|
descriptor = "generic caves"
|
|
initial_wall_cell = 55
|
|
var/iterations = 0 // Number of times to apply the automata rule.
|
|
var/cell_live_value = WALL_CHAR // Cell is alive if it has this value.
|
|
var/cell_dead_value = FLOOR_CHAR // As above for death.
|
|
var/cell_threshold = 5 // Cell becomes alive with this many live neighbors.
|
|
|
|
// Automata-specific procs and processing.
|
|
/datum/random_map/automata/generate_map()
|
|
for(var/i=1;i<=iterations;i++)
|
|
iterate(i)
|
|
|
|
/datum/random_map/automata/get_additional_spawns(var/value, var/turf/T)
|
|
return
|
|
|
|
/datum/random_map/automata/proc/iterate(var/iteration)
|
|
var/list/next_map[limit_x*limit_y]
|
|
for(var/x = 1, x <= limit_x, x++)
|
|
for(var/y = 1, y <= limit_y, y++)
|
|
var/current_cell = get_map_cell(x,y)
|
|
next_map[current_cell] = map[current_cell]
|
|
var/count = 0
|
|
|
|
// Every attempt to place this in a proc or a list has resulted in
|
|
// the generator being totally bricked and useless. Fuck it. We're
|
|
// hardcoding this shit. Feel free to rewrite and PR a fix. ~ Z
|
|
var/tmp_cell = get_map_cell(x,y)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x+1,y+1)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x-1,y-1)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x+1,y-1)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x-1,y+1)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x-1,y)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x,y-1)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x+1,y)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
tmp_cell = get_map_cell(x,y+1)
|
|
if(tmp_cell && cell_is_alive(map[tmp_cell])) count++
|
|
|
|
if(count >= cell_threshold)
|
|
revive_cell(current_cell, next_map, (iteration == iterations))
|
|
else
|
|
kill_cell(current_cell, next_map, (iteration == iterations))
|
|
map = next_map
|
|
|
|
// Check if a given tile counts as alive for the automata generations.
|
|
/datum/random_map/automata/proc/cell_is_alive(var/value)
|
|
return (value == cell_live_value) && (value != cell_dead_value)
|
|
|
|
/datum/random_map/automata/proc/revive_cell(var/target_cell, var/list/use_next_map, var/final_iter)
|
|
if(!use_next_map)
|
|
use_next_map = map
|
|
use_next_map[target_cell] = cell_live_value
|
|
|
|
/datum/random_map/automata/proc/kill_cell(var/target_cell, var/list/use_next_map, var/final_iter)
|
|
if(!use_next_map)
|
|
use_next_map = map
|
|
use_next_map[target_cell] = cell_dead_value
|