Files
BatrachophrenoandGitHub 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
Repaths obj/machinery to obj/structure/machinery. **Note for
reviewers:** the only meaningful changed code exists within
**code/game/objects/structures.dm** and
**code/game/objects/structures/_machinery.dm**, largely concerning
damage procs. With the exception of moving airlock defines to their own
file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES.

Objects, _categorically_, are largely divided between those you can hold
in your hand/inventory and those you can't. Machinery objects are
already subtypes of Structures behaviorally, this PR just makes their
pathing reflect that, and allows for future work (tool actions, more
health/destruction functionality) to be developed without unnecessary
code duplication.

I have tested this PR by loading up the Horizon and dismantling various
machines and structures with tools, shooting guns of various types
throughout the ship, and detonating a bunch of explosions throughout the
ship.
2026-05-26 19:35:48 +00:00

95 lines
2.5 KiB
Plaintext

//electric engine, should be very rare
/datum/ship_engine/ion
name = "ion thruster"
var/obj/structure/machinery/ion_engine/thruster
/datum/ship_engine/ion/New(obj/structure/machinery/_holder)
..()
thruster = _holder
/datum/ship_engine/ion/Destroy()
thruster = null
. = ..()
/datum/ship_engine/ion/get_status()
return thruster.get_status()
/datum/ship_engine/ion/get_thrust()
return thruster.get_thrust()
/datum/ship_engine/ion/burn(var/power_modifier = 1)
return thruster.burn(power_modifier)
/datum/ship_engine/ion/set_thrust_limit(new_limit)
thruster.thrust_limit = new_limit
/datum/ship_engine/ion/get_thrust_limit()
return thruster.thrust_limit
/datum/ship_engine/ion/is_on()
return thruster.on && thruster.powered()
/datum/ship_engine/ion/toggle()
thruster.on = !thruster.on
/datum/ship_engine/ion/can_burn()
return thruster.on && thruster.powered()
/obj/structure/machinery/ion_engine
name = "ion propulsion device"
desc = "An advanced ion propulsion device, using energy and a minute amount of gas to generate thrust."
icon = 'icons/obj/ship_engine.dmi'
icon_state = "nozzle"
power_channel = AREA_USAGE_ENVIRON
idle_power_usage = 19600
anchored = TRUE
component_types = list(
/obj/item/circuitboard/engine/ion,
/obj/item/stack/cable_coil = 2,
/obj/item/stock_parts/matter_bin,
/obj/item/stock_parts/capacitor = 2
)
var/datum/ship_engine/ion/controller
var/thrust_limit = 1
var/on = TRUE
var/burn_cost = 36000
var/generated_thrust = 2.5
/obj/structure/machinery/ion_engine/Initialize()
. = ..()
controller = new(src)
/obj/structure/machinery/ion_engine/Destroy()
QDEL_NULL(controller)
. = ..()
/obj/structure/machinery/ion_engine/proc/get_status()
. = list()
. += list(list(
"text" = "Location: [get_area(src)].",
"severity" = "info"
))
if(!powered())
. += list(list("text" = "Insufficient power to operate.", "severity" = "bad"))
/obj/structure/machinery/ion_engine/proc/burn(var/power_modifier = 1)
if(!on && !powered())
return 0
use_power_oneoff(thrust_limit * burn_cost * power_modifier)
. = thrust_limit * generated_thrust * power_modifier
/obj/structure/machinery/ion_engine/proc/get_thrust()
return thrust_limit * generated_thrust * on
/obj/structure/machinery/ion_engine/attackby(obj/item/attacking_item, mob/user)
. = ..()
if(default_deconstruction_screwdriver(user, attacking_item))
return TRUE
if(default_deconstruction_crowbar(user, attacking_item))
return TRUE
if(default_part_replacement(user, attacking_item))
return TRUE