Files
vgstation13/code/modules/power/battery_port.dm
ComicIronic 2bf2ea1f6f SMES Cleanup + Portable Batteries
SMESs now fall under a battery type, which is a charge-storing power machine.
The battery charges and outputs in an OOP way.
SMESs now make terminals in the general way, which is also used for APCs.
Terminal is now a power machinery level var.
Currently impossible to get but fully functional are portable batteries.

Portable batteries:
 - Only work when connected to battery ports, but can be pushed around otherwise
 - Charge from the battery port's terminal, and output onto its tile, like SMESs.
 - That's basically it. What more do you want? It's a movable SMES, essentially.

Known issue with the portable batteries: they don't show load in the UI, because they never proc resolve(), but it's not major.
2015-05-20 16:26:30 +01:00

93 lines
2.2 KiB
Plaintext

/obj/machinery/power/battery_port
name = "power connector"
desc = "A user-safe high-current contact port, used for attaching compatible machinery."
icon_state = "battery_port"
density = 0
anchored = 1
use_power = 0
var/obj/machinery/power/battery/portable/connected = null
machine_flags = SCREWTOGGLE | CROWDESTROY
/obj/machinery/power/battery_port/New()
. = ..()
/*
component_parts = newlist(
/obj/item/weapon/circuitboard/battery_port
)
RefreshParts()
*/
connect_to_network()
/obj/machinery/power/battery_port/Destroy()
disconnect_battery()
..()
/obj/machinery/power/battery_port/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/stack/cable_coil) && !terminal)
var/obj/item/stack/cable_coil/CC = W
if (CC.amount < 10)
user << "<span class=\"warning\">You need 10 length cable coil to make a terminal.</span>"
return
if(make_terminal(user))
CC.use(10)
terminal.connect_to_network()
user.visible_message(\
"<span class='warning'>[user.name] has added cables to the SMES!</span>",\
"You added cables the SMES.")
src.stat = 0
return 1
return ..()
/obj/machinery/power/battery_port/update_icon()
overlays.len = 0
if(stat & BROKEN) return
if(connected && connected.charging)
overlays += image('icons/obj/power.dmi', "bp-c")
else
if(connected)
if(connected.charge > 0)
overlays += image('icons/obj/power.dmi', "bp-o")
else
overlays += image('icons/obj/power.dmi', "bp-d")
/obj/machinery/power/battery_port/add_load(var/amount)
if(terminal && terminal.get_powernet())
terminal.powernet.load += amount
return 1
return 0
/obj/machinery/power/battery_port/surplus()
if(terminal)
return terminal.surplus()
return 0
/obj/machinery/power/battery_port/crowbarDestroy(mob/user)
if(connected)
user << "You can't disconnect \the [src] while it has \the [connected] attached."
return -1
return ..()
/obj/machinery/power/battery_port/proc/connect_battery(obj/machinery/power/battery/portable/portable)
if(portable)
connected = portable
portable.connected_to = src
connected.update_icon()
/obj/machinery/power/battery_port/proc/disconnect_battery()
if(connected)
connected.connected_to = null
connected.update_icon()
connected = null
update_icon()