-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathtransit.dm
132 lines (104 loc) · 4.18 KB
/
transit.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
/turf/open/space/transit
name = "\proper bluespace"
desc = "What is this, light-speed? We need to go to plaid speed!" // spaceballs was a great movie
icon_state = "black"
dir = SOUTH
baseturfs = /turf/open/space/transit
turf_flags = NOJAUNT //This line goes out to every wizard that ever managed to escape the den. I'm sorry.
explosion_block = INFINITY
/turf/open/space/transit/Initialize(mapload)
. = ..()
update_appearance()
RegisterSignal(src, COMSIG_TURF_RESERVATION_RELEASED, PROC_REF(launch_contents))
RegisterSignal(src, COMSIG_ATOM_ENTERED, PROC_REF(initialize_drifting))
RegisterSignal(src, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON, PROC_REF(initialize_drifting_but_from_initialize))
/turf/open/space/transit/Destroy()
//Signals are NOT removed from turfs upon replacement, and we get replaced ALOT, so unregister our signal
UnregisterSignal(src, list(COMSIG_TURF_RESERVATION_RELEASED, COMSIG_ATOM_ENTERED, COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZED_ON))
return ..()
/turf/open/space/transit/get_smooth_underlay_icon(mutable_appearance/underlay_appearance, turf/asking_turf, adjacency_dir)
. = ..()
underlay_appearance.icon_state = "speedspace_ns_[get_transit_state(asking_turf)]"
underlay_appearance.transform = turn(matrix(), get_transit_angle(asking_turf))
/turf/open/space/transit/update_icon()
. = ..()
transform = turn(matrix(), get_transit_angle(src))
/turf/open/space/transit/update_icon_state()
icon_state = "speedspace_ns_[get_transit_state(src)]"
return ..()
/turf/open/space/transit/proc/initialize_drifting(atom/entered, atom/movable/enterer)
SIGNAL_HANDLER
if(!locate(/obj/structure/lattice) in src)
dump_in_space(enterer)
/turf/open/space/transit/proc/initialize_drifting_but_from_initialize(atom/movable/location, atom/movable/enterer, mapload)
SIGNAL_HANDLER
if(!mapload && !enterer.anchored)
INVOKE_ASYNC(src, PROC_REF(initialize_drifting), src, enterer)
/turf/open/space/transit/Exited(atom/movable/gone, direction)
. = ..()
var/turf/location = gone.loc
if(istype(location, /turf/open/space) && !istype(location, src.type))//they got forced out of transit area into default space tiles
dump_in_space(gone) //launch them into game space, away from transitspace
///Get rid of all our contents, called when our reservation is released (which in our case means the shuttle arrived)
/turf/open/space/transit/proc/launch_contents(datum/turf_reservation/reservation)
SIGNAL_HANDLER
for(var/atom/movable/movable in contents)
dump_in_space(movable)
///Dump a movable in a random valid spacetile
/proc/dump_in_space(atom/movable/dumpee)
if(HAS_TRAIT(dumpee, TRAIT_DEL_ON_SPACE_DUMP))
qdel(dumpee)
return
var/max = world.maxx-TRANSITIONEDGE
var/min = 1+TRANSITIONEDGE
var/list/possible_transtitons = list()
for(var/datum/space_level/level as anything in SSmapping.z_list)
if (level.linkage == CROSSLINKED)
possible_transtitons += level.z_value
if(!length(possible_transtitons)) //No space to throw them to - try throwing them onto mining
possible_transtitons = SSmapping.levels_by_trait(ZTRAIT_MINING)
if(!length(possible_transtitons)) //Just throw them back on station, if not just runtime.
possible_transtitons = SSmapping.levels_by_trait(ZTRAIT_STATION)
//move the dumpee to a random coordinate turf
dumpee.forceMove(locate(rand(min,max), rand(min,max), pick(possible_transtitons)))
/turf/open/space/transit/CanBuildHere()
return SSshuttle.is_in_shuttle_bounds(src)
/turf/open/space/transit/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
if(!CanBuildHere()) //no RCDing transit space if we arent part of a shuttle
return FALSE
return ..()
/turf/open/space/transit/south
dir = SOUTH
/turf/open/space/transit/north
dir = NORTH
/turf/open/space/transit/horizontal
dir = WEST
/turf/open/space/transit/west
dir = WEST
/turf/open/space/transit/east
dir = EAST
/proc/get_transit_state(turf/T)
var/p = 9
. = 1
switch(T.dir)
if(NORTH)
. = ((-p*T.x+T.y) % 15) + 1
if(. < 1)
. += 15
if(EAST)
. = ((T.x+p*T.y) % 15) + 1
if(WEST)
. = ((T.x-p*T.y) % 15) + 1
if(. < 1)
. += 15
else
. = ((p*T.x+T.y) % 15) + 1
/proc/get_transit_angle(turf/T)
. = 0
switch(T.dir)
if(NORTH)
. = 180
if(EAST)
. = 90
if(WEST)
. = -90