-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathliquid_pump.dm
99 lines (90 loc) · 3.35 KB
/
liquid_pump.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//Right now it's a structure that works off of magic, as it'd require an internal power source for what its supposed to do
/obj/structure/liquid_pump
name = "portable liquid pump"
desc = "An industrial grade pump, capable of either siphoning or spewing liquids. Needs to be anchored first to work. Has a limited capacity internal storage."
icon = 'yogstation/icons/obj/structures/liquid_pump.dmi'
icon_state = "liquid_pump"
density = TRUE
max_integrity = 500
anchored = FALSE
resistance_flags = LAVA_PROOF | FIRE_PROOF | ACID_PROOF
/// How many reagents at maximum can it hold
var/max_volume = 10000
/// Whether spewing reagents out, instead of siphoning them
var/spewing_mode = FALSE
/// Whether its turned on and processing
var/turned_on = FALSE
/// How fast does the pump work, in percentages relative to the volume we're working with
var/pump_speed_percentage = 0.4
/// How fast does the pump work, in flat values. Flat values on top of percentages to help processing
var/pump_speed_flat = 20
/obj/structure/liquid_pump/wrench_act(mob/living/user, obj/item/I)
. = ..()
default_unfasten_wrench(user, I, 40)
if(!anchored && turned_on)
toggle_working()
return TRUE
/obj/structure/liquid_pump/attack_hand(mob/user)
if(!anchored)
to_chat(user, span_warning("[src] needs to be anchored first!"))
return
to_chat(user, span_notice("You turn [src] [turned_on ? "off" : "on"]."))
toggle_working()
/obj/structure/liquid_pump/AltClick(mob/living/user)
if(!user.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
return
to_chat(user, span_notice("You flick [src]'s spewing mode [spewing_mode ? "off" : "on"]."))
spewing_mode = !spewing_mode
update_icon()
/obj/structure/liquid_pump/examine(mob/user)
. = ..()
. += span_notice("It's anchor bolts are [anchored ? "down and secured" : "up"].")
. += span_notice("It's currently [turned_on ? "ON" : "OFF"].")
. += span_notice("It's mode currently is set to [spewing_mode ? "SPEWING" : "SIPHONING"]. (Alt-click to switch)")
. += span_notice("The pressure gauge shows [reagents.total_volume]/[reagents.maximum_volume].")
/obj/structure/liquid_pump/process()
if(!isturf(loc))
return
var/turf/T = loc
if(spewing_mode)
if(!reagents.total_volume)
return
var/datum/reagents/tempr = new(10000)
reagents.trans_to(tempr, (reagents.total_volume * pump_speed_percentage) + pump_speed_flat, no_react = TRUE)
T.add_liquid_from_reagents(tempr)
qdel(tempr)
else
if(!T.liquids)
return
var/free_space = reagents.maximum_volume - reagents.total_volume
if(!free_space)
return
var/target_siphon_amt = (T.liquids.liquid_group.total_reagent_volume * pump_speed_percentage) + pump_speed_flat
if(target_siphon_amt > free_space)
target_siphon_amt = free_space
T.liquids.liquid_group.transfer_to_atom(T.liquids, target_siphon_amt, src)
return
/obj/structure/liquid_pump/update_icon()
. = ..()
if(turned_on)
if(spewing_mode)
icon_state = "[initial(icon_state)]_spewing"
else
icon_state = "[initial(icon_state)]_siphoning"
else
icon_state = "[initial(icon_state)]"
/obj/structure/liquid_pump/proc/toggle_working()
if(turned_on)
STOP_PROCESSING(SSobj, src)
else
START_PROCESSING(SSobj, src)
turned_on = !turned_on
update_icon()
/obj/structure/liquid_pump/Initialize()
. = ..()
create_reagents(max_volume)
/obj/structure/liquid_pump/Destroy()
if(turned_on)
STOP_PROCESSING(SSobj, src)
qdel(reagents)
return ..()