-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathLINDA_system.dm
220 lines (174 loc) · 6.9 KB
/
LINDA_system.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
/atom
///Check if atmos can pass in this atom (ATMOS_PASS_YES, ATMOS_PASS_NO, ATMOS_PASS_DENSITY, ATMOS_PASS_PROC)
var/can_atmos_pass = ATMOS_PASS_YES
/atom/proc/can_atmos_pass(turf/T)
switch (can_atmos_pass)
if (ATMOS_PASS_PROC)
return ATMOS_PASS_YES
if (ATMOS_PASS_DENSITY)
return !density
else
return can_atmos_pass
/turf
can_atmos_pass = ATMOS_PASS_NO
/turf/open
can_atmos_pass = ATMOS_PASS_PROC
/turf/open/can_atmos_pass(turf/target_turf, vertical = FALSE)
var/can_pass = TRUE
var/direction = vertical ? get_dir_multiz(src, target_turf) : get_dir(src, target_turf)
var/opposite_direction = REVERSE_DIR(direction)
if(vertical && !(zAirOut(direction, target_turf) && target_turf.zAirIn(direction, src)))
can_pass = FALSE
if(blocks_air || target_turf.blocks_air)
can_pass = FALSE
//This path is a bit weird, if we're just checking with ourselves no sense asking objects on the turf
if (target_turf == src)
return can_pass
//Can't just return if canpass is false here, we need to set superconductivity
for(var/obj/checked_object in contents + target_turf.contents)
var/turf/other = (checked_object.loc == src ? target_turf : src)
if(CANATMOSPASS(checked_object, other, vertical))
continue
can_pass = FALSE
//the direction and open/closed are already checked on can_atmos_pass() so there are no arguments
if(checked_object.BlockThermalConductivity())
conductivity_blocked_directions |= direction
target_turf.conductivity_blocked_directions |= opposite_direction
return FALSE //no need to keep going, we got all we asked (Is this even faster? fuck you it's soul)
//Superconductivity is a bitfield of directions we can't conduct with
//Yes this is really weird. Fuck you
conductivity_blocked_directions &= ~direction
target_turf.conductivity_blocked_directions &= ~opposite_direction
return can_pass
/turf/proc/update_conductivity(turf/T)
var/dir = get_dir_multiz(src, T)
var/opp = REVERSE_DIR(dir)
if(T == src)
return
//all these must be above zero for auxmos to even consider them
if(!thermal_conductivity || !heat_capacity || !T.thermal_conductivity || !T.heat_capacity)
conductivity_blocked_directions |= dir
T.conductivity_blocked_directions |= opp
return
for(var/obj/O in contents+T.contents)
if(O.BlockThermalConductivity(opp)) //the direction and open/closed are already checked on can_atmos_pass() so there are no arguments
conductivity_blocked_directions |= dir
T.conductivity_blocked_directions |= opp
/turf/proc/block_all_conductivity()
conductivity_blocked_directions |= NORTH | SOUTH | EAST | WEST | UP | DOWN
//dir of this obj to the other turf
/atom/movable/proc/BlockThermalConductivity(dir) // Objects that don't let heat through.
return FALSE
/turf/proc/immediate_calculate_adjacent_turfs()
LAZYINITLIST(src.atmos_adjacent_turfs)
var/list/atmos_adjacent_turfs = src.atmos_adjacent_turfs
var/canpass = CANATMOSPASS(src, src, FALSE)
conductivity_blocked_directions = 0
var/src_contains_firelock = 1
if(locate(/obj/machinery/door/firedoor) in src)
src_contains_firelock |= 2
for(var/direction in GLOB.cardinals_multiz)
var/turf/current_turf = get_step_multiz(src, direction)
if(!istype(current_turf))
conductivity_blocked_directions |= direction
continue
var/other_contains_firelock = 1
if(locate(/obj/machinery/door/firedoor) in current_turf)
other_contains_firelock |= 2
update_conductivity(current_turf)
if(canpass && CANATMOSPASS(current_turf, src, (direction & (UP|DOWN))) && !(blocks_air || current_turf.blocks_air))
LAZYINITLIST(current_turf.atmos_adjacent_turfs)
atmos_adjacent_turfs[current_turf] = other_contains_firelock | src_contains_firelock
current_turf.atmos_adjacent_turfs[src] = src_contains_firelock
else
atmos_adjacent_turfs -= current_turf
if (current_turf.atmos_adjacent_turfs)
current_turf.atmos_adjacent_turfs -= src
UNSETEMPTY(current_turf.atmos_adjacent_turfs)
SEND_SIGNAL(current_turf, COMSIG_TURF_CALCULATED_ADJACENT_ATMOS)
current_turf.__update_auxtools_turf_adjacency_info()
UNSETEMPTY(atmos_adjacent_turfs)
src.atmos_adjacent_turfs = atmos_adjacent_turfs
SEND_SIGNAL(src, COMSIG_TURF_CALCULATED_ADJACENT_ATMOS)
__update_auxtools_turf_adjacency_info()
/turf/proc/clear_adjacencies()
block_all_conductivity()
for(var/turf/current_turf as anything in atmos_adjacent_turfs)
LAZYREMOVE(current_turf.atmos_adjacent_turfs, src)
current_turf.__update_auxtools_turf_adjacency_info()
LAZYNULL(atmos_adjacent_turfs)
__update_auxtools_turf_adjacency_info()
//Only gets a list of adjacencies, does NOT update
/turf/proc/get_atmos_adjacent_turfs(alldir = 0)
var/adjacent_turfs
if (atmos_adjacent_turfs)
adjacent_turfs = atmos_adjacent_turfs.Copy()
else
adjacent_turfs = list()
if (!alldir)
return adjacent_turfs
var/turf/current_location = src
for (var/direction in GLOB.diagonals_multiz)
var/matching_directions = 0
var/turf/checked_turf = get_step_multiz(current_location, direction)
if(!checked_turf)
continue
for (var/check_direction in GLOB.cardinals_multiz)
var/turf/secondary_turf = get_step(checked_turf, check_direction)
if(!checked_turf.atmos_adjacent_turfs || !checked_turf.atmos_adjacent_turfs[secondary_turf])
continue
if (adjacent_turfs[secondary_turf])
matching_directions++
if (matching_directions >= 2)
adjacent_turfs += checked_turf
break
return adjacent_turfs
//returns a list of adjacent turfs that can share air with this one.
//alldir includes adjacent diagonal tiles that can share
// air with both of the related adjacent cardinal tiles
/turf/proc/GetAtmosAdjacentTurfs(alldir = 0)
var/adjacent_turfs
if (atmos_adjacent_turfs)
adjacent_turfs = atmos_adjacent_turfs.Copy()
else
adjacent_turfs = list()
if (!alldir)
return adjacent_turfs
var/turf/curloc = src
for (var/direction in GLOB.diagonals_multiz)
var/matchingDirections = 0
var/turf/S = get_step_multiz(curloc, direction)
if(!S)
continue
for (var/checkDirection in GLOB.cardinals_multiz)
var/turf/checkTurf = get_step(S, checkDirection)
if(!S.atmos_adjacent_turfs || !S.atmos_adjacent_turfs[checkTurf])
continue
if (adjacent_turfs[checkTurf])
matchingDirections++
if (matchingDirections >= 2)
adjacent_turfs += S
break
return adjacent_turfs
/atom/proc/air_update_turf()
var/turf/local_turf = get_turf(loc)
if(!local_turf)
return
local_turf.air_update_turf()
/turf/air_update_turf()
immediate_calculate_adjacent_turfs()
/atom/movable/proc/move_update_air(turf/target_turf)
if(isturf(target_turf))
target_turf.air_update_turf() //You're empty now
air_update_turf() //You aren't
/atom/proc/atmos_spawn_air(text) //because a lot of people loves to copy paste awful code lets just make an easy proc to spawn your plasma fires
var/turf/open/T = get_turf(src)
if(!istype(T))
return
T.atmos_spawn_air(text)
/turf/open/atmos_spawn_air(text)
if(!text || !air)
return
var/datum/gas_mixture/G = new
G.parse_gas_string(text)
assume_air(G)