-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathopenspace.dm
197 lines (171 loc) · 6.65 KB
/
openspace.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
/turf/open/openspace
name = "open space"
desc = "Watch your step!"
// We don't actually draw openspace, but it needs to have color
// In its icon state so we can count it as a "non black" tile
icon_state = MAP_SWITCH("pure_white", "invisible")
baseturfs = /turf/open/openspace
overfloor_placed = FALSE
underfloor_accessibility = UNDERFLOOR_INTERACTABLE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
plane = TRANSPARENT_FLOOR_PLANE
var/can_cover_up = TRUE
var/can_build_on = TRUE
/turf/open/openspace/airless
initial_gas_mix = AIRLESS_ATMOS
/turf/open/openspace/airless/planetary
planetary_atmos = TRUE
// Reminder, any behavior code written here needs to be duped to /turf/open/space/openspace
// I am so sorry
/turf/open/openspace/Initialize(mapload) // handle plane and layer here so that they don't cover other obs/turfs in Dream Maker
. = ..()
if(PERFORM_ALL_TESTS(focus_only/openspace_clear) && !GET_TURF_BELOW(src))
stack_trace("[src] was inited as openspace with nothing below it at ([x], [y], [z])")
RegisterSignal(src, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON, PROC_REF(on_atom_created))
var/area/our_area = loc
if(istype(our_area, /area/space))
force_no_gravity = TRUE
return INITIALIZE_HINT_LATELOAD
/turf/open/openspace/LateInitialize()
. = ..()
AddElement(/datum/element/turf_z_transparency)
/turf/open/openspace/ChangeTurf(path, list/new_baseturfs, flags)
UnregisterSignal(src, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON)
return ..()
/**
* Prepares a moving movable to be precipitated if Move() is successful.
* This is done in Enter() and not Entered() because there's no easy way to tell
* if the latter was called by Move() or forceMove() while the former is only called by Move().
*/
/turf/open/openspace/Enter(atom/movable/movable, atom/oldloc, no_side_effects = FALSE)
. = ..()
if(.)
//higher priority than CURRENTLY_Z_FALLING so the movable doesn't fall on Entered()
movable.set_currently_z_moving(CURRENTLY_Z_FALLING_FROM_MOVE)
///Makes movables fall when forceMove()'d to this turf.
/turf/open/openspace/Entered(atom/movable/movable)
. = ..()
if(movable.set_currently_z_moving(CURRENTLY_Z_FALLING))
zFall(movable, falling_from_move = TRUE)
/**
* Drops movables spawned on this turf after they are successfully initialized.
* so that spawned movables that should fall to gravity, will fall.
*/
/turf/open/openspace/proc/on_atom_created(datum/source, atom/created_atom)
SIGNAL_HANDLER
if(ismovable(created_atom))
zfall_if_on_turf(created_atom)
/turf/open/openspace/proc/zfall_if_on_turf(atom/movable/movable)
if(QDELETED(movable) || movable.loc != src)
return
zFall(movable)
/turf/open/openspace/zAirIn(direction, turf/source)
return TRUE
/turf/open/openspace/zAirOut(direction, turf/source)
return TRUE
/turf/open/openspace/zPassIn(direction)
if(direction == DOWN)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_IN_DOWN)
return FALSE
return TRUE
if(direction == UP)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_IN_UP)
return FALSE
return TRUE
return FALSE
/turf/open/openspace/zPassOut(direction)
if(direction == DOWN)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_OUT_DOWN)
return FALSE
return TRUE
if(direction == UP)
for(var/obj/contained_object in contents)
if(contained_object.obj_flags & BLOCK_Z_OUT_UP)
return FALSE
return TRUE
return FALSE
/turf/open/openspace/proc/CanCoverUp()
return can_cover_up
/turf/open/openspace/proc/CanBuildHere()
return can_build_on
/turf/open/openspace/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.construction_mode)
if(RCD_FLOORWALL)
return list("mode" = RCD_FLOORWALL, "delay" = 0, "cost" = 3)
return FALSE
/turf/open/openspace/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, passed_mode)
switch(passed_mode)
if(RCD_FLOORWALL)
to_chat(user, span_notice("You build a floor."))
place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
return TRUE
return FALSE
/turf/open/openspace/attackby(obj/item/C, mob/user, params)
..()
if(!CanBuildHere())
return
if(istype(C, /obj/item/stack/rods))
build_with_rods(C, user)
if(istype(C, /obj/item/stack/tile/plasteel))
if(!CanCoverUp())
return
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
var/obj/item/stack/tile/plasteel/S = C
if(S.use(1))
qdel(L)
playsound(src, 'sound/weapons/genhit.ogg', 50, 1)
to_chat(user, span_notice("You build a floor."))
place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
else
to_chat(user, span_warning("You need one floor tile to build a floor!"))
else
to_chat(user, span_warning("The plating is going to need some support! Place metal rods first."))
/turf/open/openspace/build_with_floor_tiles(obj/item/stack/tile/plasteel/used_tiles)
if(!CanCoverUp())
return
return ..()
/turf/open/openspace/rust_heretic_act()
return FALSE
/turf/open/openspace/replace_floor(turf/open/new_floor_path, flags)
if (!initial(new_floor_path.overfloor_placed))
ChangeTurf(new_floor_path, flags = flags)
return
// Create plating under tiled floor we try to create directly onto the air
place_on_top(/turf/open/floor/plating, flags = flags)
place_on_top(new_floor_path, flags = flags)
/turf/open/openspace/can_cross_safely(atom/movable/crossing)
return HAS_TRAIT(crossing, TRAIT_MOVE_FLYING)
/turf/open/openspace/icemoon
name = "ice chasm"
baseturfs = /turf/open/openspace/icemoon
initial_gas_mix = ICEMOON_DEFAULT_ATMOS
/// Replaces itself with replacement_turf if the turf has the no ruins allowed flag (usually ruins themselves)
var/protect_ruin = TRUE
/// The turf that will replace this one if the turf below has the no ruins allowed flag. we use this one so we don't get any potential double whammies
var/replacement_turf = /turf/open/floor/plating/asteroid/snow/icemoon/do_not_chasm
/// If true mineral turfs below this openspace turf will be mined automatically
var/drill_below = TRUE
/turf/open/openspace/icemoon/Initialize(mapload)
. = ..()
var/turf/T = GET_TURF_BELOW(src)
//I wonder if I should error here
if(!T)
return
if(T.turf_flags & NO_RUINS && protect_ruin)
ChangeTurf(replacement_turf, null, CHANGETURF_IGNORE_AIR)
return
if(!ismineralturf(T) || !drill_below)
return
var/turf/closed/mineral/M = T
M.mineralAmt = 0
M.gets_drilled()
baseturfs = /turf/open/openspace/icemoon //This is to ensure that IF random turf generation produces a openturf, there won't be other turfs assigned other than openspace.
/turf/open/openspace/icemoon/keep_below
drill_below = FALSE
/turf/open/openspace/icemoon/ruins
protect_ruin = FALSE
drill_below = FALSE