Skip to content

Instantly share code, notes, and snippets.

@BlueNexus
Last active December 15, 2016 20:47
Show Gist options
  • Save BlueNexus/002fe80cc2af827f3c7981e0070dced5 to your computer and use it in GitHub Desktop.
Save BlueNexus/002fe80cc2af827f3c7981e0070dced5 to your computer and use it in GitHub Desktop.
#define DECAY_RATE 0.1
#define RADDBG
var/repository/radiation/radiation_repository = new()
var/list/to_process = list()
/repository/radiation
var/list/sources = list()
var/list/irradiated = list()
/repository/radiation/proc/aprocess()
world << "1"
for(var/turf/T in irradiated)
irradiated[T] -= DECAY_RATE
for(var/obj/item/rad_tool/emitter in sources)
world << emitter.name
radiate(emitter, emitter.rad_power, emitter.rad_range)
to_process.Cut()
/repository/radiation/proc/radiate(source, power, range)
var/turf/epicentre = get_turf(source)
to_process = list()
world << "2"
//Gather turfs to try and irradiate
/*
for(var/direction in cardinal)
var/turf/T = get_step(epicentre, direction)
T.get_rad_area(epicentre, range, direction)
*/
var/list/buffer = list()
buffer = trange(range, epicentre)
for(var/turf/spot in buffer)
if(get_dist(epicentre, buffer[spot]) > range)
world << get_dist(epicentre, buffer[spot])
buffer.Remove(spot)
world << "nay"
else
spot.maptext = "yay"
world << "yay"
to_process = buffer.Copy()
to_process[epicentre] = power
world << "done"
for(var/turf/spot in to_process)
world << "tracin'"
var/turf/origin = get_turf(epicentre)
var/turf/dest = spot
var/working = power
while(origin != dest)
origin = get_step(origin, get_dir(origin, dest))
if((!to_process[origin]) && (working))
to_process[origin] = working
working -= origin.rad_resistance
else
to_process[origin] = max(to_process[origin], working)
for(var/turf/spot in to_process)
world << "calculatin'"
irradiated[spot] = max((to_process[spot] / get_dist(epicentre, spot) ** 2), irradiated[spot]) //Inverse square law
#ifdef RADDBG
world << irradiated[spot]
var/turf/T = spot
T.maptext = irradiated[spot]
#endif
/*
/turf/proc/get_rad_area(epicentre, range, direction)
var/testing = 1 //not sure if the following is necessary or not, so making sure
if(testing)
if(src in to_process)
return
to_process[src] = null
world << "yay"
#ifdef RADDBG
var/turf/D = src
D.maptext = "yay"
#endif
if(get_dist(src, epicentre) >= range)
return
var/turf/T = get_step(src, direction)
if(T)
T.get_rad_area(epicentre, range, direction)
T = get_step(src, turn(direction,90))
if(T)
T.get_rad_area(epicentre, range, direction)
T = get_step(src, turn(direction,-90))
if(T)
T.get_rad_area(epicentre, range, direction)
*/
//DEBUGGING
/obj/item/rad_tool
var/rad_power = 5000
var/rad_range = 5
/obj/item/rad_tool/New()
radiation_repository.sources.Add(src)
/obj/item/rad_tool/proc/check()
radiation_repository.aprocess()
/turf
var/rad_resistance = 0
/turf/simulated/wall
rad_resistance = 10000
#undef RADDBG
#undef DECAY_RATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment