-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathshuttle_engines.dm
183 lines (153 loc) · 5.59 KB
/
shuttle_engines.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
#define ENGINE_UNWRENCHED 0
#define ENGINE_WRENCHED 1
#define ENGINE_WELDED 2
#define ENGINE_WELDTIME 200
/obj/structure/shuttle
name = "shuttle"
icon = 'icons/turf/shuttle.dmi'
resistance_flags = LAVA_PROOF | FIRE_PROOF | ACID_PROOF
max_integrity = 500
armor = list(MELEE = 100, BULLET = 10, LASER = 10, ENERGY = 0, BOMB = 0, BIO = 0, RAD = 0, FIRE = 50, ACID = 70) //default + ignores melee
/obj/structure/shuttle/engine
name = "engine"
desc = "A bluespace engine used to make shuttles move."
density = TRUE
anchored = TRUE
///How well the engine affects the ship's speed.
var/engine_power = 1
///Construction state of the Engine.
var/state = ENGINE_WELDED //welding shmelding //i love welding //i love welding charlie! I LOVE WELDING!!!!!!!!
///The mobile ship we are connected to.
var/datum/weakref/connected_ship_ref
/obj/structure/shuttle/engine/connect_to_shuttle(mapload, obj/docking_port/mobile/port, obj/docking_port/stationary/dock)
. = ..()
if(!port)
return FALSE
connected_ship_ref = WEAKREF(port)
port.engine_list += src
port.current_engines += engine_power
if(mapload)
port.initial_engines += engine_power
/**
* Called on destroy and when we need to unsync an engine from their ship.
*/
/obj/structure/shuttle/engine/proc/unsync_ship()
var/obj/docking_port/mobile/port = connected_ship_ref?.resolve()
if(port)
port.engine_list -= src
port.current_engines -= initial(engine_power)
connected_ship_ref = null
//Ugh this is a lot of copypasta from emitters, welding need some boilerplate reduction
/obj/structure/shuttle/engine/can_be_unfasten_wrench(mob/user, silent)
if(state == ENGINE_WELDED)
if(!silent)
to_chat(user, span_warning("[src] is welded to the floor!"))
return FAILED_UNFASTEN
return ..()
/obj/structure/shuttle/engine/default_unfasten_wrench(mob/user, obj/item/I, time = 20)
. = ..()
if(. == SUCCESSFUL_UNFASTEN)
if(anchored)
state = ENGINE_WRENCHED
connect_to_shuttle(port = SSshuttle.get_containing_shuttle(src)) //connect to a new ship, if needed
else
unsync_ship() //not part of the ship anymore
state = ENGINE_UNWRENCHED
/obj/structure/shuttle/engine/wrench_act(mob/living/user, obj/item/I)
default_unfasten_wrench(user, I)
return TRUE
/obj/structure/shuttle/engine/welder_act(mob/living/user, obj/item/I)
switch(state)
if(ENGINE_UNWRENCHED)
to_chat(user, span_warning("The [src.name] needs to be wrenched to the floor!"))
if(ENGINE_WRENCHED)
if(!I.tool_start_check(user, amount=0))
return TRUE
user.visible_message("[user.name] starts to weld the [name] to the floor.", \
span_notice("You start to weld \the [src] to the floor..."), \
span_italics("You hear welding."))
if(I.use_tool(src, user, ENGINE_WELDTIME, volume=50))
state = ENGINE_WELDED
to_chat(user, span_notice("You weld \the [src] to the floor."))
alter_engine_power(engine_power)
if(ENGINE_WELDED)
if(!I.tool_start_check(user, amount=0))
return TRUE
user.visible_message("[user.name] starts to cut the [name] free from the floor.", \
span_notice("You start to cut \the [src] free from the floor..."), \
span_italics("You hear welding."))
if(I.use_tool(src, user, ENGINE_WELDTIME, volume=50))
state = ENGINE_WRENCHED
to_chat(user, span_notice("You cut \the [src] free from the floor."))
alter_engine_power(-engine_power)
return TRUE
/obj/structure/shuttle/engine/Destroy()
if(state == ENGINE_WELDED)
alter_engine_power(-engine_power)
. = ..()
//Propagates the change to the shuttle.
/obj/structure/shuttle/engine/proc/alter_engine_power(mod)
if(!mod)
return
var/obj/docking_port/mobile/port = connected_ship_ref?.resolve()
if(port)
port.alter_engines(mod)
/obj/structure/shuttle/engine/heater
name = "engine heater"
icon_state = "heater"
desc = "Directs energy into compressed particles in order to power engines."
engine_power = 0 // todo make these into 2x1 parts
/obj/structure/shuttle/engine/platform
name = "engine platform"
icon_state = "platform"
desc = "A platform for engine components."
engine_power = 0
/obj/structure/shuttle/engine/propulsion
name = "propulsion engine"
icon_state = "propulsion"
desc = "A standard reliable bluespace engine used by many forms of shuttles."
opacity = TRUE
/obj/structure/shuttle/engine/propulsion/left
name = "left propulsion engine"
icon_state = "propulsion_l"
/obj/structure/shuttle/engine/propulsion/right
name = "right propulsion engine"
icon_state = "propulsion_r"
/obj/structure/shuttle/engine/propulsion/burst
name = "burst engine"
desc = "An engine that releases a large bluespace burst to propel it."
/obj/structure/shuttle/engine/propulsion/burst/cargo
state = ENGINE_UNWRENCHED
anchored = FALSE
/obj/structure/shuttle/engine/propulsion/burst/left
name = "left burst engine"
icon_state = "burst_l"
/obj/structure/shuttle/engine/propulsion/burst/right
name = "right burst engine"
icon_state = "burst_r"
/obj/structure/shuttle/engine/router
name = "engine router"
icon_state = "router"
desc = "Redirects around energized particles in engine structures."
/obj/structure/shuttle/engine/large
name = "engine"
opacity = TRUE
icon = 'icons/obj/2x2.dmi'
icon_state = "large_engine"
desc = "A very large bluespace engine used to propel very large ships."
bound_width = 64
bound_height = 64
appearance_flags = 0
/obj/structure/shuttle/engine/huge
name = "engine"
opacity = TRUE
icon = 'icons/obj/3x3.dmi'
icon_state = "huge_engine"
desc = "An extremely large bluespace engine used to propel extremely large ships."
bound_width = 96
bound_height = 96
appearance_flags = 0
#undef ENGINE_UNWRENCHED
#undef ENGINE_WRENCHED
#undef ENGINE_WELDED
#undef ENGINE_WELDTIME