Last active
December 16, 2016 15:53
-
-
Save BlueNexus/9c4f2db800340df7b334019329a8d7ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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/report_rads(var/turf/T as turf) | |
return irradiated[T] | |
/repository/radiation/proc/aprocess() | |
for(var/turf/T in irradiated) | |
irradiated[T] -= DECAY_RATE | |
for(var/thing in sources) | |
var/atom/emitter = thing | |
radiate(emitter, emitter.rad_power) | |
to_process.Cut() | |
/repository/radiation/proc/radiate(source, power) | |
var/test = 1 | |
var/range = 1 | |
while(round(test) != 0) | |
test = (power / (range ** 2)) | |
range++ | |
world << range | |
var/turf/epicentre = get_turf(source) | |
to_process = list() | |
to_process = trange(range, epicentre) | |
to_process[epicentre] = power | |
for(var/turf/spot in to_process) | |
var/turf/origin = get_turf(epicentre) | |
var/turf/dest = spot | |
var/working = power | |
while(origin != dest) | |
origin = get_step_towards(origin, dest) | |
if(!to_process[origin]) | |
to_process[origin] = working | |
working -= origin.rad_resistance | |
else | |
to_process[origin] = max(to_process[origin], working) | |
for(var/turf/spot in to_process) | |
irradiated[spot] = max((to_process[spot] / get_dist(epicentre, spot) ** 2), irradiated[spot]) //Inverse square law | |
#ifdef RADDBG | |
var/x = Clamp( irradiated[spot] / 10, 0, 255) | |
spot.color = rgb(0,x,0) | |
#endif | |
//DEBUGGING | |
/obj/item/rad_tool | |
rad_power = 200 | |
item_state = "spade" | |
icon_state = "spade" | |
/obj/item/rad_tool/New() | |
radiation_repository.sources.Add(src) | |
/obj/item/rad_tool/proc/check() | |
radiation_repository.aprocess() | |
/obj/item/rad_tool/attack_self(mob/user) | |
world << radiation_repository.report_rads(get_turf(user)) | |
/turf | |
var/rad_resistance = 0 | |
/turf/simulated/wall | |
rad_resistance = 10000 | |
/atom | |
var/rad_power = 0 | |
#undef RADDBG | |
#undef DECAY_RATE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment