Files
Paradise/code/game/machinery/cell_charger.dm
T
AffectedArc07andGitHub 04ba5c1cc9 File standardisation (#13131)
* Adds the check components

* Adds in trailing newlines

* Converts all CRLF to LF

* Post merge EOF

* Post merge line endings

* Final commit
2020-03-17 18:08:51 -04:00

138 lines
3.4 KiB
Plaintext

/obj/machinery/cell_charger
name = "cell charger"
desc = "It charges power cells."
icon = 'icons/obj/power.dmi'
icon_state = "ccharger0"
anchored = 1
use_power = IDLE_POWER_USE
idle_power_usage = 5
active_power_usage = 60
power_channel = EQUIP
pass_flags = PASSTABLE
var/obj/item/stock_parts/cell/charging = null
var/chargelevel = -1
/obj/machinery/cell_charger/deconstruct()
if(charging)
charging.forceMove(drop_location())
return ..()
/obj/machinery/cell_charger/Destroy()
QDEL_NULL(charging)
return ..()
/obj/machinery/cell_charger/proc/updateicon()
icon_state = "ccharger[charging ? 1 : 0]"
if(charging && !(stat & (BROKEN|NOPOWER)))
var/newlevel = round(charging.percent() * 4 / 100)
if(chargelevel != newlevel)
chargelevel = newlevel
overlays.Cut()
overlays += "ccharger-o[newlevel]"
else
overlays.Cut()
/obj/machinery/cell_charger/examine(mob/user)
. = ..()
. += "There's [charging ? "a" : "no"] cell in the charger."
if(charging)
. += "Current charge: [round(charging.percent(), 1)]%"
/obj/machinery/cell_charger/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/stock_parts/cell))
if(stat & BROKEN)
to_chat(user, "<span class='warning'>[src] is broken!</span>")
return
if(!anchored)
to_chat(user, "<span class='warning'>[src] isn't attached to the ground!</span>")
return
if(charging)
to_chat(user, "<span class='warning'>There is already a cell in the charger!</span>")
return
else
var/area/a = loc.loc // Gets our locations location, like a dream within a dream
if(!isarea(a))
return
if(a.power_equip == 0) // There's no APC in this area, don't try to cheat power!
to_chat(user, "<span class='warning'>[src] blinks red as you try to insert the cell!</span>")
return
if(!user.drop_item())
return
I.forceMove(src)
charging = I
user.visible_message("[user] inserts a cell into the charger.", "<span class='notice'>You insert a cell into the charger.</span>")
chargelevel = -1
updateicon()
else
return ..()
/obj/machinery/cell_charger/wrench_act(mob/user, obj/item/I)
. = TRUE
if(charging)
to_chat(user, "<span class='warning'>Remove the cell first!</span>")
return
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
anchored = !anchored
if(anchored)
WRENCH_ANCHOR_MESSAGE
else
WRENCH_UNANCHOR_MESSAGE
/obj/machinery/cell_charger/proc/removecell()
charging.update_icon()
charging = null
chargelevel = -1
updateicon()
/obj/machinery/cell_charger/attack_hand(mob/user)
if(!charging)
return
user.put_in_hands(charging)
charging.add_fingerprint(user)
user.visible_message("[user] removes [charging] from [src].", "<span class='notice'>You remove [charging] from [src].</span>")
removecell()
/obj/machinery/cell_charger/attack_tk(mob/user)
if(!charging)
return
charging.forceMove(loc)
to_chat(user, "<span class='notice'>You telekinetically remove [charging] from [src].</span>")
removecell()
/obj/machinery/cell_charger/attack_ai(mob/user)
return
/obj/machinery/cell_charger/emp_act(severity)
if(stat & (BROKEN|NOPOWER))
return
if(charging)
charging.emp_act(severity)
..(severity)
/obj/machinery/cell_charger/process()
if(!charging || !anchored || (stat & (BROKEN|NOPOWER)))
return
if(charging.percent() >= 100)
return
use_power(200) //this used to use CELLRATE, but CELLRATE is fucking awful. feel free to fix this properly!
charging.give(175) //inefficiency.
updateicon()