-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
construction.dm
234 lines (194 loc) · 6.59 KB
/
construction.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*CONTENTS
Buildable pipes
Buildable meters
*/
//construction defines are in __defines/pipe_construction.dm
//update those defines ANY TIME an atmos path is changed...
//...otherwise construction will stop working
/obj/item/pipe
name = "pipe"
desc = "A pipe."
var/pipe_type
var/pipename
force = 7
throwforce = 7
icon = 'icons/obj/atmospherics/pipes/pipe_item.dmi'
icon_state = "simple"
item_state = "buildpipe"
w_class = WEIGHT_CLASS_NORMAL
///Piping layer that we are going to be on
var/piping_layer = PIPING_LAYER_DEFAULT
///Type of pipe-object made, selected from the RPD
var/RPD_type
var/disposable = TRUE // yogs
/obj/item/pipe/directional
RPD_type = PIPE_UNARY
/obj/item/pipe/binary
RPD_type = PIPE_STRAIGHT
/obj/item/pipe/binary/bendable
RPD_type = PIPE_BENDABLE
/obj/item/pipe/trinary
RPD_type = PIPE_TRINARY
/obj/item/pipe/trinary/flippable
RPD_type = PIPE_TRIN_M
var/flipped = FALSE
/obj/item/pipe/quaternary
RPD_type = PIPE_ONEDIR
/obj/item/pipe/Initialize(mapload, _pipe_type, _dir, obj/machinery/atmospherics/make_from)
if(make_from)
make_from_existing(make_from)
else if(_pipe_type) // yogs - only change if _pipe_type is set
pipe_type = _pipe_type
setDir(_dir)
update()
pixel_x += rand(-5, 5)
pixel_y += rand(-5, 5)
//Flipping handled manually due to custom handling for trinary pipes
AddComponent(/datum/component/simple_rotation, ROTATION_ALTCLICK | ROTATION_CLOCKWISE)
return ..()
/obj/item/pipe/proc/make_from_existing(obj/machinery/atmospherics/make_from)
setDir(make_from.dir)
pipename = make_from.name
add_atom_colour(make_from.color, FIXED_COLOUR_PRIORITY)
pipe_type = make_from.type
/obj/item/pipe/trinary/flippable/make_from_existing(obj/machinery/atmospherics/components/trinary/make_from)
..()
if(make_from.flipped)
do_a_flip()
/obj/item/pipe/dropped()
if(loc)
set_piping_layer(piping_layer)
return ..()
/obj/item/pipe/proc/set_piping_layer(new_layer = PIPING_LAYER_DEFAULT)
var/obj/machinery/atmospherics/fakeA = pipe_type
if(initial(fakeA.pipe_flags) & PIPING_ALL_LAYER)
new_layer = PIPING_LAYER_DEFAULT
piping_layer = new_layer
PIPING_LAYER_SHIFT(src, piping_layer)
layer = initial(layer) + ((piping_layer - PIPING_LAYER_DEFAULT) * PIPING_LAYER_LCHANGE)
/obj/item/pipe/proc/update()
var/obj/machinery/atmospherics/fakeA = pipe_type
name = "[initial(fakeA.name)] fitting"
icon_state = initial(fakeA.pipe_state)
if(ispath(pipe_type,/obj/machinery/atmospherics/pipe/heat_exchanging))
resistance_flags |= FIRE_PROOF | LAVA_PROOF
/obj/item/pipe/verb/flip()
set category = "Object"
set name = "Flip Pipe"
set src in view(1)
if ( usr.incapacitated() )
return
do_a_flip()
/obj/item/pipe/proc/do_a_flip()
setDir(turn(dir, -180))
/obj/item/pipe/trinary/flippable/do_a_flip()
setDir(turn(dir, flipped ? 45 : -45))
flipped = !flipped
/obj/item/pipe/Move()
var/old_dir = dir
..()
setDir(old_dir) //pipes changing direction when moved is just annoying and buggy
// Convert dir of fitting into dir of built component
/obj/item/pipe/proc/fixed_dir()
return dir
/obj/item/pipe/binary/fixed_dir()
. = dir
if(dir == SOUTH)
. = NORTH
else if(dir == WEST)
. = EAST
/obj/item/pipe/trinary/flippable/fixed_dir()
. = dir
if(dir in GLOB.diagonals)
. = turn(dir, 45)
/obj/item/pipe/attack_self(mob/user)
setDir(turn(dir,-90))
/obj/item/pipe/wrench_act(mob/living/user, obj/item/wrench/W)
if(!isturf(loc))
return TRUE
add_fingerprint(user)
var/obj/machinery/atmospherics/fakeA = pipe_type
var/flags = initial(fakeA.pipe_flags)
for(var/obj/machinery/atmospherics/M in loc)
if((M.pipe_flags & flags & PIPING_ONE_PER_TURF)) //Only one dense/requires density object per tile, eg connectors/cryo/heater/coolers.
to_chat(user, span_warning("Something is hogging the tile!"))
return TRUE
if((M.piping_layer != piping_layer) && !((M.pipe_flags | flags) & PIPING_ALL_LAYER)) //don't continue if either pipe goes across all layers
continue
if(M.get_init_directions() & SSair.get_init_dirs(pipe_type, fixed_dir())) // matches at least one direction on either type of pipe
to_chat(user, span_warning("There is already a pipe at that location!"))
return TRUE
// no conflicts found
var/obj/machinery/atmospherics/A = new pipe_type(loc)
build_pipe(A)
A.on_construction(color, piping_layer)
transfer_fingerprints_to(A)
W.play_tool_sound(src)
user.visible_message( \
"[user] fastens \the [src].", \
span_notice("You fasten \the [src]."), \
span_italics("You hear ratcheting."))
qdel(src)
/obj/item/pipe/proc/build_pipe(obj/machinery/atmospherics/A)
A.setDir(fixed_dir())
A.set_init_directions()
if(pipename)
A.name = pipename
if(A.on)
// Certain pre-mapped subtypes are on by default, we want to preserve
// every other aspect of these subtypes (name, pre-set filters, etc.)
// but they shouldn't turn on automatically when wrenched.
A.on = FALSE
/obj/item/pipe/trinary/flippable/build_pipe(obj/machinery/atmospherics/components/trinary/T)
..()
T.flipped = flipped
/obj/item/pipe/directional/suicide_act(mob/user)
user.visible_message(span_suicide("[user] shoves [src] in [user.p_their()] mouth and turns it on! It looks like [user.p_theyre()] trying to commit suicide!"))
if(iscarbon(user))
var/mob/living/carbon/C = user
for(var/i=1 to 20)
C.vomit(0, TRUE, FALSE, 4, FALSE)
if(prob(20))
C.spew_organ()
sleep(0.5 SECONDS)
C.blood_volume = 0
return(OXYLOSS|BRUTELOSS)
/obj/item/pipe_meter
name = "meter"
desc = "A meter that can be laid on pipes."
icon = 'icons/obj/atmospherics/pipes/pipe_item.dmi'
icon_state = "meter"
item_state = "buildpipe"
w_class = WEIGHT_CLASS_BULKY
var/piping_layer = PIPING_LAYER_DEFAULT
/obj/item/pipe_meter/wrench_act(mob/living/user, obj/item/wrench/W)
var/obj/machinery/atmospherics/pipe/pipe
for(var/obj/machinery/atmospherics/pipe/P in loc)
if(P.piping_layer == piping_layer)
pipe = P
break
if(!pipe)
to_chat(user, span_warning("You need to fasten it to a pipe!"))
return TRUE
new /obj/machinery/meter(loc, piping_layer)
W.play_tool_sound(src)
to_chat(user, span_notice("You fasten the meter to the pipe."))
qdel(src)
/obj/item/pipe_meter/screwdriver_act(mob/living/user, obj/item/S)
. = ..()
if(.)
return TRUE
if(!isturf(loc))
to_chat(user, span_warning("You need to fasten it to the floor!"))
return TRUE
new /obj/machinery/meter/turf(loc, piping_layer)
S.play_tool_sound(src)
to_chat(user, span_notice("You fasten the meter to the [loc.name]."))
qdel(src)
/obj/item/pipe_meter/dropped()
. = ..()
if(loc)
setAttachLayer(piping_layer)
/obj/item/pipe_meter/proc/setAttachLayer(new_layer = PIPING_LAYER_DEFAULT)
piping_layer = new_layer
PIPING_LAYER_DOUBLE_SHIFT(src, piping_layer)