Files
Batrachophreno 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

83 lines
2.6 KiB
Plaintext

//Solar tracker
//Machine that tracks the sun and reports it's direction to the solar controllers
//As long as this is working, solar panels on same powernet will track automatically
/obj/structure/machinery/power/tracker
name = "solar tracker"
desc = "A solar directional tracker."
icon = 'icons/obj/power.dmi'
icon_state = "tracker"
anchored = 1
density = 1
use_power = POWER_USE_OFF
var/id = 0
var/sun_angle = 0 // sun angle as set by sun datum
var/obj/structure/machinery/power/solar_control/control = null
/obj/structure/machinery/power/tracker/Initialize(mapload, obj/item/solar_assembly/S)
. = ..()
Make(S)
connect_to_network()
/obj/structure/machinery/power/tracker/Destroy()
unset_control() //remove from control computer
return ..()
//set the control of the tracker to a given computer if closer than SOLAR_MAX_DIST
/obj/structure/machinery/power/tracker/proc/set_control(var/obj/structure/machinery/power/solar_control/SC)
if(SC && (get_dist(src, SC) > SOLAR_MAX_DIST))
return 0
control = SC
return 1
//set the control of the tracker to null and removes it from the previous control computer if needed
/obj/structure/machinery/power/tracker/proc/unset_control()
if(control)
control.connected_tracker = null
control = null
/obj/structure/machinery/power/tracker/proc/Make(var/obj/item/solar_assembly/S)
if(!S)
S = new /obj/item/solar_assembly(src)
S.glass_type = /obj/item/stack/material/glass
S.tracker = 1
S.anchored = 1
S.forceMove(src)
update_icon()
//updates the tracker icon and the facing angle for the control computer
/obj/structure/machinery/power/tracker/proc/modify_angle(var/angle)
sun_angle = angle
//set icon dir to show sun illumination
set_dir(turn(NORTH, -angle - 22.5)) // 22.5 deg bias ensures, e.g. 67.5-112.5 is EAST
if(powernet && (powernet == control?.powernet)) //update if we're still in the same powernet
control.cdir = angle
/obj/structure/machinery/power/tracker/attackby(obj/item/attacking_item, mob/user)
if(attacking_item.tool_behaviour == TOOL_CROWBAR)
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
user.visible_message(SPAN_NOTICE("[user] begins to take the glass off the solar tracker."))
if(attacking_item.use_tool(src, user, 50, volume = 50))
var/obj/item/solar_assembly/S = locate() in src
if(S)
S.forceMove(src.loc)
S.give_glass()
playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1)
user.visible_message(SPAN_NOTICE("[user] takes the glass off the tracker."))
qdel(src)
return
..()
// Tracker Electronic
/obj/item/tracker_electronics
name = "tracker electronics"
icon = 'icons/obj/module.dmi'
icon_state = "door_electronics"
w_class = WEIGHT_CLASS_SMALL