mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
* update icon and update appearance * update name * fixes * Removes double parent calls from many things * More fixes * minor fixes * fuck * A! * general annoyances in this PR * going in specific fixes * remove remaining update icons and hud fixes * Mass replace update icon with update icon state/overlays * compile * push my work so far * goes back on things I broke * a * goes through like 80 more cases * going through more update icons * compile again * thank you tattax * Goes through the remaining update icon * fix CI cries * Fixes cigs, canisters and guncases * Fixes airlock unres sides * Fixes the flash * Fixes cryo cells * gun fix * Egun fixes * fixes mini eguns * Update energy.dm * Fixes MMIs * Fixes security level interface * Fixes cigar cases * Bow & Critter crate fixes * Fixes signalers * Fix canisters again * re-adds blinking red * Fixes solar panels * Fixes cryogenics (and forced standing) * Update cryo.dm * sechailer fix * Maybe fixes pitch black roundstart APCs * Update apc.dm * yet another egun fix * Fixes plasmamen helmets among other stuff * Fixes canisters for good * Fixes booze dispensers * Fixes new icon updates people added * Probably fixes ballistic guns * i give up lol
155 lines
4.2 KiB
Plaintext
155 lines
4.2 KiB
Plaintext
/obj/machinery/cell_charger
|
|
name = "cell charger"
|
|
desc = "It charges power cells."
|
|
icon = 'icons/obj/power.dmi'
|
|
icon_state = "ccharger"
|
|
use_power = IDLE_POWER_USE
|
|
idle_power_usage = 5
|
|
active_power_usage = 60
|
|
power_channel = AREA_USAGE_EQUIP
|
|
circuit = /obj/item/circuitboard/machine/cell_charger
|
|
pass_flags = PASSTABLE
|
|
var/obj/item/stock_parts/cell/charging = null
|
|
var/chargelevel = -1
|
|
var/charge_rate = 250
|
|
|
|
/obj/machinery/cell_charger/update_overlays()
|
|
. = ..()
|
|
if(charging)
|
|
. += image(charging.icon, charging.icon_state)
|
|
. += "ccharger-on"
|
|
if(!(stat & (BROKEN|NOPOWER)))
|
|
var/newlevel = round(charging.percent() * 4 / 100)
|
|
chargelevel = newlevel
|
|
. += "ccharger-o[newlevel]"
|
|
|
|
/obj/machinery/cell_charger/examine(mob/user)
|
|
. = ..()
|
|
. += "There's [charging ? "a" : "no"] cell in the charger."
|
|
if(charging)
|
|
. += "Current charge: [round(charging.percent(), 1)]%."
|
|
if(in_range(user, src) || isobserver(user))
|
|
. += "<span class='notice'>The status display reads: Charging power: <b>[charge_rate]W</b>.<span>"
|
|
|
|
/obj/machinery/cell_charger/attackby(obj/item/W, mob/user, params)
|
|
if(istype(W, /obj/item/crowbar) && !panel_open)
|
|
if(!charging)
|
|
return
|
|
user.put_in_hands(charging)
|
|
user.visible_message("[user] removes [charging] from [src].", span_notice("You remove [charging] from [src]."))
|
|
removecell()
|
|
if(istype(W, /obj/item/stock_parts/cell) && !panel_open)
|
|
if(stat & BROKEN)
|
|
to_chat(user, span_warning("[src] is broken!"))
|
|
return
|
|
if(!anchored)
|
|
to_chat(user, span_warning("[src] isn't attached to the ground!"))
|
|
return
|
|
if(charging)
|
|
to_chat(user, span_warning("There is already a cell in the charger!"))
|
|
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_warning("[src] blinks red as you try to insert the cell!"))
|
|
return
|
|
if(!user.transferItemToLoc(W,src))
|
|
return
|
|
|
|
charging = W
|
|
user.visible_message("[user] inserts a cell into [src].", span_notice("You insert a cell into [src]."))
|
|
chargelevel = -1
|
|
update_appearance(UPDATE_ICON)
|
|
else
|
|
if(!charging && default_deconstruction_screwdriver(user, icon_state, icon_state, W))
|
|
return
|
|
if(default_deconstruction_crowbar(W))
|
|
return
|
|
if(!charging && default_unfasten_wrench(user, W))
|
|
return
|
|
return ..()
|
|
|
|
/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/removecell()
|
|
charging.update_appearance(UPDATE_ICON)
|
|
charging = null
|
|
chargelevel = -1
|
|
update_appearance(UPDATE_ICON)
|
|
|
|
/obj/machinery/cell_charger/attack_hand(mob/user)
|
|
. = ..()
|
|
if(.)
|
|
return
|
|
if(!charging)
|
|
return
|
|
|
|
user.put_in_hands(charging)
|
|
charging.add_fingerprint(user)
|
|
|
|
user.visible_message("[user] removes [charging] from [src].", span_notice("You remove [charging] from [src]."))
|
|
|
|
removecell()
|
|
|
|
/obj/machinery/cell_charger/attack_tk(mob/user)
|
|
if(!charging)
|
|
return
|
|
|
|
charging.forceMove(loc)
|
|
to_chat(user, span_notice("You telekinetically remove [charging] from [src]."))
|
|
|
|
removecell()
|
|
|
|
/obj/machinery/cell_charger/attack_ai(mob/user)
|
|
if(!charging)
|
|
return
|
|
|
|
charging.forceMove(loc)
|
|
to_chat(user, "<span class='notice'>You remotely disconnect the battery port and eject [charging] from [src].</span>")
|
|
|
|
removecell()
|
|
return
|
|
|
|
/obj/machinery/cell_charger/attack_robot(mob/user)
|
|
attack_ai(user)
|
|
|
|
/obj/machinery/cell_charger/emp_act(severity)
|
|
. = ..()
|
|
|
|
if(stat & (BROKEN|NOPOWER) || . & EMP_PROTECT_CONTENTS)
|
|
return
|
|
|
|
if(charging)
|
|
charging.emp_act(severity)
|
|
|
|
/obj/machinery/cell_charger/MouseDrop_T(atom/dropping, mob/user)
|
|
if(istype(dropping, /obj/item/stock_parts/cell))
|
|
attackby(dropping, user)
|
|
else
|
|
..()
|
|
|
|
/obj/machinery/cell_charger/RefreshParts()
|
|
charge_rate = 500
|
|
for(var/obj/item/stock_parts/capacitor/C in component_parts)
|
|
charge_rate *= C.rating
|
|
|
|
/obj/machinery/cell_charger/process(delta_time)
|
|
if(!charging || !anchored || (stat & (BROKEN|NOPOWER)))
|
|
return
|
|
|
|
if(charging.percent() >= 100)
|
|
return
|
|
use_power(charge_rate * delta_time)
|
|
charging.give(charge_rate * delta_time) //this is 2558, efficient batteries exist
|
|
|
|
update_appearance(UPDATE_ICON)
|