mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-25 19:46:42 +01:00
honey, it's 4PM! time for your destructive ZAS/init optimization pass! (#4140)
* oh dear * still a trainwreck but better maybe * fix * wild * fix * wild * huh * huh * huh * t * huh * wack * Update xenoarch.dm
This commit is contained in:
@@ -1,65 +1,28 @@
|
||||
/datum/random_map/automata
|
||||
descriptor = "generic caves"
|
||||
initial_wall_cell = 55
|
||||
var/generated_string
|
||||
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.
|
||||
var/cell_threshold = 4 // 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)
|
||||
generated_string = rustg_cnoise_generate("[initial_wall_cell]", "[iterations]", "[cell_threshold]", "[cell_threshold - 1]", "[limit_x]", "[limit_y]")
|
||||
var/gen = generated_string
|
||||
var/_size = limit_x * limit_y
|
||||
var/list/apply[_size]
|
||||
for(var/i in 1 to _size)
|
||||
apply[i] = (gen[i] == "1")? cell_live_value : cell_dead_value
|
||||
map = apply
|
||||
|
||||
/datum/random_map/autoamta/seed_map()
|
||||
return // nah
|
||||
|
||||
/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
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
var/list/ore_turfs = list()
|
||||
var/make_cracked_turfs = TRUE
|
||||
|
||||
/datum/random_map/automata/cave_system/generate_map()
|
||||
. = ..()
|
||||
for(var/i in 1 to map.len)
|
||||
if(map[i] == WALL_CHAR)
|
||||
ore_turfs += i
|
||||
|
||||
/datum/random_map/automata/cave_system/no_cracks
|
||||
make_cracked_turfs = FALSE
|
||||
|
||||
@@ -18,21 +24,12 @@
|
||||
return "X"
|
||||
return ..(value)
|
||||
|
||||
/datum/random_map/automata/cave_system/revive_cell(var/target_cell, var/list/use_next_map, var/final_iter)
|
||||
..()
|
||||
if(final_iter)
|
||||
ore_turfs |= target_cell
|
||||
|
||||
/datum/random_map/automata/cave_system/kill_cell(var/target_cell, var/list/use_next_map, var/final_iter)
|
||||
..()
|
||||
if(final_iter)
|
||||
ore_turfs -= target_cell
|
||||
|
||||
// Create ore turfs.
|
||||
/datum/random_map/automata/cave_system/cleanup()
|
||||
var/ore_count = round(map.len/20)
|
||||
while((ore_count>0) && (ore_turfs.len>0))
|
||||
if(!priority_process) sleep(-1)
|
||||
if(!priority_process)
|
||||
CHECK_TICK
|
||||
var/check_cell = pick(ore_turfs)
|
||||
ore_turfs -= check_cell
|
||||
if(prob(75))
|
||||
|
||||
Reference in New Issue
Block a user