-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathstairs.dm
202 lines (161 loc) · 6.05 KB
/
stairs.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
#define STAIR_TERMINATOR_AUTOMATIC 0
#define STAIR_TERMINATOR_NO 1
#define STAIR_TERMINATOR_YES 2
// dir determines the direction of travel to go upwards (due to lack of sprites, currently only 1 and 2 make sense)
// stairs require /turf/open/openspace as the tile above them to work
// multiple stair objects can be chained together; the Z level transition will happen on the final stair object in the chain
/obj/structure/stairs
name = "stairs"
icon = 'goon/icons/turfs/floors.dmi'
icon_state = "stairs_alone"
layer = BELOW_OPEN_DOOR_LAYER
anchored = TRUE
move_resist = INFINITY
var/force_open_above = FALSE // replaces the turf above this stair obj with /turf/open/openspace
var/terminator_mode = STAIR_TERMINATOR_AUTOMATIC
var/turf/listeningTo
/obj/structure/stairs/Initialize(mapload)
GLOB.stairs += src
if(force_open_above)
force_open_above()
build_signal_listener()
update_surrounding()
var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = PROC_REF(on_exit),
)
AddElement(/datum/element/connect_loc, loc_connections)
return ..()
/obj/structure/stairs/Destroy()
listeningTo = null
GLOB.stairs -= src
return ..()
/obj/structure/stairs/Move() //Look this should never happen but...
. = ..()
if(force_open_above)
build_signal_listener()
update_surrounding()
/obj/structure/stairs/proc/update_surrounding()
update_appearance()
for(var/i in GLOB.cardinals)
var/turf/T = get_step(get_turf(src), i)
var/obj/structure/stairs/S = locate() in T
if(S)
S.update_appearance()
/obj/structure/stairs/proc/on_exit(datum/source, atom/movable/leaving, direction)
SIGNAL_HANDLER
if(leaving == src)
return //Let's not block ourselves.
if(!isobserver(leaving) && isTerminator() && direction == dir)
leaving.set_currently_z_moving(CURRENTLY_Z_ASCENDING)
INVOKE_ASYNC(src, PROC_REF(stair_ascend), leaving)
leaving.Bump(src)
return COMPONENT_ATOM_BLOCK_EXIT
/obj/structure/stairs/Cross(atom/movable/AM)
if(isTerminator() && (get_dir(src, AM) == dir))
return FALSE
return ..()
/obj/structure/stairs/proc/stair_ascend(atom/movable/climber)
var/turf/checking = get_step_multiz(get_turf(src), UP)
if(!istype(checking))
return
// I'm only interested in if the pass is unobstructed, not if the mob will actually make it
if(!climber.can_z_move(UP, get_turf(src), checking, z_move_flags = ZMOVE_ALLOW_BUCKLED))
return
var/turf/target = get_step_multiz(get_turf(src), (dir|UP))
if(istype(target) && !climber.can_z_move(DOWN, target, z_move_flags = ZMOVE_FALL_FLAGS)) //Don't throw them into a tile that will just dump them back down.
climber.zMove(target = target, z_move_flags = ZMOVE_STAIRS_FLAGS)
/// Moves anything that's being dragged by src or anything buckled to it to the stairs turf.
climber.pulling?.move_from_pull(climber, loc, climber.glide_size)
for(var/mob/living/buckled as anything in climber.buckled_mobs)
buckled.pulling?.move_from_pull(buckled, loc, buckled.glide_size)
/obj/structure/stairs/vv_edit_var(var_name, var_value)
. = ..()
if(!.)
return
if(var_name != NAMEOF(src, force_open_above))
return
if(!var_value)
if(listeningTo)
UnregisterSignal(listeningTo, COMSIG_TURF_MULTIZ_NEW)
listeningTo = null
else
build_signal_listener()
force_open_above()
/obj/structure/stairs/proc/build_signal_listener()
if(listeningTo)
UnregisterSignal(listeningTo, COMSIG_TURF_MULTIZ_NEW)
var/turf/open/openspace/T = get_step_multiz(get_turf(src), UP)
RegisterSignal(T, COMSIG_TURF_MULTIZ_NEW, PROC_REF(on_multiz_new))
listeningTo = T
/obj/structure/stairs/proc/force_open_above()
var/turf/open/openspace/T = get_step_multiz(get_turf(src), UP)
if(T && !istype(T))
T.ChangeTurf(/turf/open/openspace, flags = CHANGETURF_INHERIT_AIR)
/obj/structure/stairs/proc/on_multiz_new(turf/source, dir)
SIGNAL_HANDLER
if(dir == UP)
var/turf/open/openspace/T = get_step_multiz(get_turf(src), UP)
if(T && !istype(T))
T.ChangeTurf(/turf/open/openspace, flags = CHANGETURF_INHERIT_AIR)
/obj/structure/stairs/intercept_zImpact(list/falling_movables, levels = 1)
. = ..()
if(levels == 1 && isTerminator()) // Stairs won't save you from a steep fall.
. |= FALL_INTERCEPTED | FALL_NO_MESSAGE | FALL_RETAIN_PULL
/obj/structure/stairs/proc/isTerminator() //If this is the last stair in a chain and should move mobs up
if(terminator_mode != STAIR_TERMINATOR_AUTOMATIC)
return (terminator_mode == STAIR_TERMINATOR_YES)
var/turf/T = get_turf(src)
if(!T)
return FALSE
var/turf/them = get_step(T, dir)
if(!them)
return FALSE
for(var/obj/structure/stairs/S in them)
if(S.dir == dir)
return FALSE
return TRUE
/obj/structure/stairs/wide_mid
icon_state = "stairs_middle"
base_icon_state = "stairs_middle"
/obj/structure/stairs/wide_left
icon_state = "stairs_wide"
base_icon_state = "stairs_wide"
/obj/structure/stairs/wide_right
icon_state = "stairs2_wide"
base_icon_state = "stairs2_wide"
/obj/structure/stairs/white
icon_state = "medstairs_alone"
base_icon_state = "medstairs_alone"
/obj/structure/stairs/white/wide_mid
icon_state = "medstairs_middle"
base_icon_state = "medstairs_middle"
/obj/structure/stairs/white/wide_left
icon_state = "medstairs_wide"
base_icon_state = "medstairs_wide"
/obj/structure/stairs/white/wide_right
icon_state = "medstairs2_wide"
base_icon_state = "medstairs2_wide"
/obj/structure/stairs/wood
icon_state = "woodstairs_alone"
base_icon_state = "woodstairs_alone"
/obj/structure/stairs/wood/wide_mid
icon_state = "woodstairs_middle"
base_icon_state = "woodstairs_middle"
/obj/structure/stairs/wood/wide_left
icon_state = "woodstairs_wide"
base_icon_state = "woodstairs_wide"
/obj/structure/stairs/wood/wide_right
icon_state = "woodstairs2_wide"
base_icon_state = "woodstairs2_wide"
/obj/structure/stairs/dark
icon_state = "darkstairs_alone"
base_icon_state = "darkstairs_alone"
/obj/structure/stairs/dark/wide_mid
icon_state = "darkstairs_middle"
base_icon_state = "darkstairs_middle"
/obj/structure/stairs/dark/wide_left
icon_state = "darkstairs_wide"
base_icon_state = "darkstairs_wide"
/obj/structure/stairs/dark/wide_right
icon_state = "darkstairs2_wide"
base_icon_state = "darkstairs2_wide"