-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathradioactive_emitter.dm
71 lines (52 loc) · 2.31 KB
/
radioactive_emitter.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/// Minimum duration between pulses for the radioactive emitter component.
/// This is chosen arbitrarily. It can theoretically go down to 0.1 SECONDS but god please don't
#define MIN_PULSE_COOLDOWN 0.5 SECONDS
/**
* # Radioactive Emitter
*
* Simple component that you can attach to something to make it emit radiation pulses over time.
*/
/datum/component/radioactive_emitter
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
/// The actual cooldown between rad pulses
COOLDOWN_DECLARE(rad_pulse_cooldown)
/// The length of the cooldown between radiation pulses
var/cooldown_time = 5 SECONDS
/// How much radiation power is provided to the pulse (see: [proc/radiation_pulse])
var/power = 20
/// Optional - What is shown on examine of the parent?
var/examine_text
/datum/component/radioactive_emitter/Initialize(cooldown_time = 5 SECONDS, power = 20, examine_text)
if(!isturf(parent) && !ismovable(parent))
return COMPONENT_INCOMPATIBLE
src.cooldown_time = max(cooldown_time, MIN_PULSE_COOLDOWN)
src.power = power
src.examine_text = examine_text
// We process on fastprocess even though we're on a cooldown based system.
// Easier to handle edits to the cooldown duration, prevents timer spam for short cooldown emitters
START_PROCESSING(SSfastprocess, src)
/datum/component/radioactive_emitter/Destroy(force)
STOP_PROCESSING(SSfastprocess, src)
return ..()
/datum/component/radioactive_emitter/RegisterWithParent()
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
/datum/component/radioactive_emitter/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ATOM_EXAMINE)
/datum/component/radioactive_emitter/InheritComponent(datum/component/new_comp, i_am_original, cooldown_time = 5 SECONDS, power = 20, examine_text)
if(!i_am_original)
return
// Only care about modifying our rad wave argument.
src.cooldown_time = cooldown_time
src.power = power
// Don't touch examine text or whatever else.
/datum/component/radioactive_emitter/process(seconds_per_tick)
if(!COOLDOWN_FINISHED(src, rad_pulse_cooldown))
return
COOLDOWN_START(src, rad_pulse_cooldown, cooldown_time)
radiation_pulse(parent, power)
/datum/component/radioactive_emitter/proc/on_examine(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER
if(!examine_text)
return
examine_list += examine_text
#undef MIN_PULSE_COOLDOWN