Mining RFD can now make train engine and carts (#19235)

Improved / refactored some code, particularly around RFD.
Added the ability for mining RFD to build the mining train engine and
carts.
Removed the RFD, carts and engine from the mining vendor.
Added the RFD as a roundstart printable protolathe design.
Made the mining vendor list a GLOB variable.
Resolved a runtime on vehicles trying to turn on without a cell being
present.
Mining vendor pizzas now have a random pizza subtype.
This commit is contained in:
Fluffy
2024-05-31 20:14:02 +00:00
committed by GitHub
parent f6a0f0595f
commit ad37d8d81d
6 changed files with 242 additions and 66 deletions
+11 -2
View File
@@ -6,7 +6,8 @@
- ALT-click the truck to remove the key from the ignition.<br>\
- Click the truck to open a UI menu.<br>\
- Click the resist button or type \"resist\" in the command bar at the bottom of your screen to get off the truck.<br>\
- If latched, you can use a wrench to unlatch."
- If latched, you can use a wrench to unlatch.<br>\
- Click-drag on a trolley to latch and tow it."
icon = 'icons/obj/vehicles.dmi'
icon_state = "cargo_engine"
on = 0
@@ -33,7 +34,7 @@
/obj/vehicle/train/cargo/trolley
name = "cargo train trolley"
desc_info = "You can use a wrench to unlatch this."
desc_info = "You can use a wrench to unlatch this, click-drag to link it to another trolley to tow."
icon = 'icons/obj/vehicles.dmi'
icon_state = "cargo_trailer"
anchored = 0
@@ -242,6 +243,10 @@
if(is_train_head())
if(direction == reverse_direction(dir) && tow)
//Allow the engine to rotate, but only if there's not another piece in the new direction
//Basically, to allow the first rotation at spawn to align with the rest of the convoy, without it being a CBT
if(!(locate(/obj/vehicle/train) in get_step(src, direction)))
set_dir(direction)
return 0
if(Move(get_step(src, direction)))
return 1
@@ -277,6 +282,10 @@
if("Toggle Latching")
if(tow)
tow.unattach(user)
else
var/obj/vehicle/train/cargo/trolley/nearby_trolley = locate() in orange(src, 1)
if(nearby_trolley)
src.latch(nearby_trolley)
/obj/vehicle/train/cargo/engine/AltClick(var/mob/user)
if(Adjacent(user))
+36 -29
View File
@@ -191,16 +191,16 @@
//-------------------------------------------
/obj/vehicle/proc/turn_on()
if(stat)
return 0
if(powered && cell.charge < charge_use && !organic)
return 0
on = 1
return FALSE
if(powered && cell?.charge < charge_use && !organic)
return FALSE
on = TRUE
set_light(initial(light_range))
update_icon()
return 1
return TRUE
/obj/vehicle/proc/turn_off()
on = 0
on = FALSE
set_light(0)
update_icon()
@@ -297,49 +297,56 @@
// the vehicle load() definition before
// calling this parent proc.
//-------------------------------------------
/obj/vehicle/proc/load(var/atom/movable/C)
/**
* Loads an /atom onto the vehicle
*
* * thing_to_load - The thing to load, an `/obj` or `/mob`
*
* Returns `TRUE` if the load was successful, `FALSE` otherwise
*/
/obj/vehicle/proc/load(var/atom/movable/thing_to_load)
//This loads objects onto the vehicle so they can still be interacted with.
//Define allowed items for loading in specific vehicle definitions.
if(!isturf(C.loc)) //To prevent loading things from someone's inventory, which wouldn't get handled properly.
return 0
if(load || C.anchored)
return 0
if(!isturf(thing_to_load.loc)) //To prevent loading things from someone's inventory, which wouldn't get handled properly.
return FALSE
if(load || thing_to_load.anchored)
return FALSE
// if a crate/closet, close before loading
var/obj/structure/closet/closet = C
var/obj/structure/closet/closet = thing_to_load
if(istype(closet))
closet.close()
C.forceMove(loc)
C.set_dir(dir)
C.anchored = 1
thing_to_load.forceMove(loc)
thing_to_load.set_dir(dir)
thing_to_load.anchored = TRUE
load = C
load = thing_to_load
C.layer = VEHICLE_LOAD_LAYER
thing_to_load.layer = VEHICLE_LOAD_LAYER
if(load_item_visible)
C.pixel_x += load_offset_x
if(ismob(C))
C.pixel_y += mob_offset_y
thing_to_load.pixel_x += load_offset_x
if(ismob(thing_to_load))
thing_to_load.pixel_y += mob_offset_y
else
if(istype(C, /obj/structure/closet/crate))
C.pixel_y += load_offset_y
if(istype(thing_to_load, /obj/structure/closet/crate))
thing_to_load.pixel_y += load_offset_y
else
C.pixel_y += 10
thing_to_load.pixel_y += 10
if(ismob(C))
buckle(C, C)
if(ismob(thing_to_load))
buckle(thing_to_load, thing_to_load)
return 1
return TRUE
/obj/vehicle/buckle(var/atom/movable/C, mob/user)
/obj/vehicle/buckle(atom/movable/buckling_atom, mob/user)
. = ..()
if(. && buckling_sound)
playsound(src, buckling_sound, 20)
/obj/vehicle/user_unbuckle(var/mob/user, var/direction)
/obj/vehicle/user_unbuckle(mob/user)
..()
unload(user, direction)
unload(user)
return
/obj/vehicle/proc/unload(var/mob/user, var/direction)