Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battery rack update #8382

Merged
merged 21 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5c8dc18
ZAMN
Dec 29, 2022
0e0fccd
Merge branch 'master' of https://github.com/MLGTASTICa/CEV-Eris
MLGTASTICa Apr 5, 2023
38543ca
Bump webpack from 5.51.1 to 5.76.0 in /tgui
dependabot[bot] Apr 6, 2023
712a75f
Merge pull request #4 from MLGTASTICa/dependabot/npm_and_yarn/tgui/we…
MLGTASTICa Apr 6, 2023
fbc682b
Bump fastify from 3.20.2 to 3.29.4 in /tgui
dependabot[bot] Apr 6, 2023
82e5f3a
Bump json5 from 1.0.1 to 1.0.2 in /tgui
dependabot[bot] Apr 6, 2023
525ac50
Merge pull request #6 from MLGTASTICa/dependabot/npm_and_yarn/tgui/fa…
MLGTASTICa Apr 6, 2023
547341c
Merge pull request #9 from MLGTASTICa/dependabot/npm_and_yarn/tgui/js…
MLGTASTICa Apr 6, 2023
6f787e4
Merge branch 'master' of https://github.com/MLGTASTICa/CEV-Eris
MLGTASTICa Apr 15, 2023
5cced52
Merge branch 'master' of https://github.com/MLGTASTICa/CEV-Eris
MLGTASTICa Apr 21, 2023
8eb0910
Merge remote-tracking branch 'upstream/master'
MLGTASTICa May 26, 2023
8228b25
Merge remote-tracking branch 'upstream/master'
MLGTASTICa Jun 2, 2023
5a14cd0
Update batteryrack.dm
MLGTASTICa Dec 7, 2023
93947ca
zz
MLGTASTICa Dec 7, 2023
757ce46
aaaa
MLGTASTICa Dec 7, 2023
9b1df39
power gen sprites too
MLGTASTICa Dec 8, 2023
37b653c
Update code/modules/power/batteryrack.dm
hyperioo Dec 8, 2023
baeff33
Update code/modules/power/batteryrack.dm
hyperioo Dec 8, 2023
822690c
Merge remote-tracking branch 'upstream/master'
MLGTASTICa Dec 8, 2023
3c10e27
Merge branch 'master' into 4KServerRoom
MLGTASTICa Dec 8, 2023
82cbf8f
Delete bin/build_and_linter.cmd
MLGTASTICa Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
board_type = "machine"
origin_tech = list(TECH_POWER = 3, TECH_ENGINEERING = 2)
req_components = list(
/obj/item/cell/large = 3
/obj/item/stack/cable_coil = 10,
/obj/item/stock_parts/capacitor = 1
)

/obj/item/electronics/circuitboard/apc
Expand All @@ -26,7 +27,8 @@
build_path = /obj/machinery/power/smes/batteryrack/makeshift
board_type = "machine"
req_components = list(
/obj/item/cell/large = 3
/obj/item/stack/cable_coil = 15,
/obj/item/stock_parts/capacitor = 2
)
matter = list(MATERIAL_PLASTIC = 2, MATERIAL_GLASS = 3)

Expand Down
136 changes: 109 additions & 27 deletions code/modules/power/batteryrack.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,86 @@
#define OVERKEY_PSU_CAPACITORS "CapacitorOverlays"
#define OVERKEY_PSU_INPUT "InputOverlays"
#define OVERKEY_PSU_OUTPUT "OutputOverlays"
//The one that works safely.
/obj/machinery/power/smes/batteryrack
name = "power cell rack PSU"
desc = "A rack of power cells working as a PSU."
icon_state = "mpsu_closed"
charge = 0 //you dont really want to make a potato PSU which already is overloaded
output_attempt = 0
input_level = 0
output_level = 0
input_level_max = 0
output_level_max = 0
icon_state = "gsmes"
icon_state = "mpsu_closed"
circuit = /obj/item/electronics/circuitboard/batteryrack
var/cells_amount = 0
var/capacitors_amount = 0
var/global/list/br_cache = null

/obj/machinery/power/smes/batteryrack/examine(mob/user, distance, infix, suffix)
. = ..()
if(open_hatch)
to_chat(user, SPAN_NOTICE("It currently hosts [cells_amount] cells."))
if(distance <= 1)
to_chat(user, SPAN_NOTICE("Click any cell below to remove them from \the [src]:"))
for(var/obj/item/cell/battery in component_parts)
to_chat(user, SPAN_NOTICE("<a href='?src=\ref[src];remove_cell_in_hand=\ref[battery];user=\ref[user]'>\icon[battery] [battery.name]</a>"))
else
to_chat(user, SPAN_NOTICE("The hatch needs to be opened with a screwdriver to interact with the cells inside!"))
to_chat(user, SPAN_NOTICE("It currently has [capacitors_amount] capacitors installed."))
to_chat(user, SPAN_NOTICE("It has a LCD screen. Left side is for charging and right side for discharging. Green means operating. Yellow means not discharging/charging or no network."))
to_chat(user, SPAN_NOTICE("Can toggle input and output on/off with CtrlClick and AltClick. It is currently set to discharge at a maximum rate of [output_level] W, and recharge at a maximum rate of [input_level] W."))

/obj/machinery/power/smes/batteryrack/attack_hand(mob/living/user)
. = ..()
if(!istype(user))
return
if(open_hatch && !user.incapacitated(INCAPACITATION_DEFAULT))
var/list/inputs = list()
for(var/obj/item/cell/large/battery in component_parts)
inputs.Add(battery)
var/obj/item/input = input(user, "Choose cell to remove", "Cell removal UI", null) as anything in inputs
if(input)
if(!Adjacent(user))
return
if(!component_parts.Find(input))
return
input.forceMove(get_turf(user))
user.put_in_active_hand(input)

/obj/machinery/power/smes/batteryrack/Topic(href, href_list)
/// For any UI related fuckery to NanoUI/Tgui
. = ..()
if(QDELETED(src))
return
if(open_hatch)
if(href_list["remove_cell_in_hand"])
var/mob/living/target = locate(href_list["user"])
var/obj/item/cell/battery = locate(href_list["remove_cell_in_hand"])
if(!target || !battery)
return
// No funny HREF switching to grab anything in the world... or anything inside the machine.
// Don't use locate here , it searches by Type instead of reference
if(!component_parts.Find(battery) || !istype(battery))
return
if(target.incapacitated(INCAPACITATION_DEFAULT))
return
if(!Adjacent(target))
to_chat(target, SPAN_NOTICE("You are too far away from \the [src]."))
return
to_chat(target, SPAN_NOTICE("You remove \the [battery] from \the [src]."))
component_parts.Remove(battery)
battery.forceMove(get_turf(target))
target.put_in_active_hand(battery)

/obj/machinery/power/smes/batteryrack/Initialize(mapload, d)
. = ..()
var/datum/component/overlay_manager/overlay_manager = AddComponent(/datum/component/overlay_manager)
overlay_manager.addOverlay(OVERKEY_PSU_CAPACITORS, mutable_appearance(icon, "caps_0"))
overlay_manager.addOverlay(OVERKEY_PSU_INPUT, mutable_appearance(icon, "mpsu_tryinginput"))
overlay_manager.addOverlay(OVERKEY_PSU_OUTPUT, mutable_appearance(icon, "mpsu_tryingdischarge"))


/obj/machinery/power/smes/batteryrack/RefreshParts()
capacitors_amount = 0
Expand All @@ -24,6 +91,8 @@
capacitors_amount++
input_level_max = 50000 + max_level * 20000
output_level_max = 50000 + max_level * 20000
output_level = output_level_max
input_level = input_level_max

var/C = 0
for(var/obj/item/cell/large/PC in component_parts)
Expand All @@ -33,61 +102,60 @@


/obj/machinery/power/smes/batteryrack/update_icon()
overlays.Cut()
if(stat & BROKEN) return

if(!br_cache)
br_cache = list()
br_cache.len = 7
br_cache[1] = image('icons/obj/power.dmi', "gsmes_outputting")
br_cache[2] = image('icons/obj/power.dmi', "gsmes_charging")
br_cache[3] = image('icons/obj/power.dmi', "gsmes_overcharge")
br_cache[4] = image('icons/obj/power.dmi', "gsmes_og1")
br_cache[5] = image('icons/obj/power.dmi', "gsmes_og2")
br_cache[6] = image('icons/obj/power.dmi', "gsmes_og3")
br_cache[7] = image('icons/obj/power.dmi', "gsmes_og4")

if (output_attempt)
overlays += br_cache[1]
if(inputting)
overlays += br_cache[2]

var/clevel = chargedisplay()
if(clevel>0)
overlays += br_cache[3+clevel]
if(!open_hatch)
icon_state = "mpsu_closed"
else
switch(cells_amount)
if(0)
icon_state = "mpsu_0"
if(1)
icon_state = "mpsu_1"
if(2 to 3)
icon_state = "mpsu_3"
if(4 to 5)
icon_state = "mpsu_5"
var/datum/component/overlay_manager/overlay_manager = GetComponent(/datum/component/overlay_manager)
overlay_manager.updateOverlay(OVERKEY_PSU_CAPACITORS, mutable_appearance(icon, "caps_[capacitors_amount]"))
overlay_manager.updateOverlay(OVERKEY_PSU_INPUT, mutable_appearance(icon, inputting == 2 ? "mpsu_input" : "mpsu_tryinginput"))
overlay_manager.updateOverlay(OVERKEY_PSU_OUTPUT, mutable_appearance(icon, outputting == 2 ? "mpsu_discharging" : "mpsu_tryingdischarge"))
return

#undef OVERKEY_PSU_CAPACITORS


/obj/machinery/power/smes/batteryrack/chargedisplay()
return round(4 * charge/(capacity ? capacity : 5e6))


/obj/machinery/power/smes/batteryrack/attackby(var/obj/item/W as obj, var/mob/user as mob) //these can only be moved by being reconstructed, solves having to remake the powernet.
..() //SMES attackby for now handles screwdriver, cable coils and wirecutters, no need to repeat that here
// we need to update icon incase we get opened in the parent call
update_icon()
if(open_hatch)
if(istype(W, /obj/item/tool/crowbar))
if (charge < (capacity / 100))
if (charge < (capacity / 100) || capacity == 0)
if (!output_attempt && !input_attempt)
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
var/obj/machinery/constructable_frame/machine_frame/M = new /obj/machinery/constructable_frame/machine_frame(src.loc)
M.state = 2
M.icon_state = "box_1"
for(var/obj/I in component_parts)
I.loc = src.loc
I.forceMove(get_turf(src))
qdel(src)
return 1
else
to_chat(user, SPAN_WARNING("Turn off the [src] before dismantling it."))
else
to_chat(user, SPAN_WARNING("Better let [src] discharge before dismantling it."))
else if ((istype(W, /obj/item/stock_parts/capacitor) && (capacitors_amount < 5)) || (istype(W, /obj/item/cell/large) && (cells_amount < 5)))
if (charge < (capacity / 100))
if (charge < (capacity / 100) || capacity == 0)
if (!output_attempt && !input_attempt)
user.drop_item()
component_parts += W
W.loc = src
W.forceMove(src)
RefreshParts()
to_chat(user, SPAN_NOTICE("You upgrade the [src] with [W.name]."))
update_icon()
else
to_chat(user, SPAN_WARNING("Turn off the [src] before dismantling it."))
else
Expand All @@ -98,11 +166,14 @@
return 1
return

/obj/machinery/power/smes/batteryrack/attack_hand()


//The shitty one that will blow up.
/obj/machinery/power/smes/batteryrack/makeshift
name = "makeshift PSU"
desc = "A rack of batteries connected by a mess of wires posing as a PSU."
icon_state = "gsmes"
circuit = /obj/item/electronics/circuitboard/apc
var/overcharge_percent = 0

Expand All @@ -111,6 +182,17 @@
overlays.Cut()
if(stat & BROKEN) return

if(!br_cache)
br_cache = list()
br_cache.len = 7
br_cache[1] = image('icons/obj/power.dmi', "gsmes_outputting")
br_cache[2] = image('icons/obj/power.dmi', "gsmes_charging")
br_cache[3] = image('icons/obj/power.dmi', "gsmes_overcharge")
br_cache[4] = image('icons/obj/power.dmi', "gsmes_og1")
br_cache[5] = image('icons/obj/power.dmi', "gsmes_og2")
br_cache[6] = image('icons/obj/power.dmi', "gsmes_og3")
br_cache[7] = image('icons/obj/power.dmi', "gsmes_og4")

if (output_attempt)
overlays += br_cache[1]
if(inputting)
Expand Down
8 changes: 4 additions & 4 deletions code/modules/power/diesel_gen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,12 @@
if(href_list["action"])
if(href_list["action"] == "enable")
if(!active && HasFuel() && !IsBroken())
active = 1
icon_state = "portgen1"
active = TRUE
update_icon()
if(href_list["action"] == "disable")
if (active)
active = 0
icon_state = "portgen0"
active = FALSE
update_icon()
if(href_list["action"] == "eject")
if(!active)
DropFuel()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/port_gen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@
/obj/machinery/power/port_gen/pacman/super
name = "S.U.P.E.R.P.A.C.M.A.N.-type Portable Generator"
desc = "A power generator that utilizes uranium sheets as fuel. Can run for much longer than the standard PACMAN type generators. Rated for 80 kW max safe output."
icon_state = "portgen1"
icon_state = "portgen_u0"
sheet_path = /obj/item/stack/material/uranium
sheet_name = "Uranium Sheets"
time_per_fuel_unit = 576 //same power output, but a 50 sheet stack will last 2 hours at max safe power
Expand Down
Loading