Exosuit Nuclear Power Cores (#18268)

* Added power cores, a type of large battery cell that get used by
exosuits. The nuclear and phoron variants are self-charging.
* Combat mechs now start with nuclear power cores, allowing them to
sustain themselves indefinitely, so long as they stay out of the action
for a bit.
* Removed basic power cells from the mechfab, replaced with the mech
powercores.
* Mech cell statuses now instantly update as soon as the cell charges or
discharges.
* Added a stack of 10 uranium to the machinist's workshop, which can
print two nuclear power cores.
This commit is contained in:
Geeves
2024-06-09 23:14:59 +02:00
committed by GitHub
parent 566aeaa2da
commit 2bf39c7ee9
22 changed files with 178 additions and 74 deletions
+25
View File
@@ -4,9 +4,30 @@
/obj/item/cell/Initialize()
. = ..()
charge = maxcharge
if(self_charge_percentage)
START_PROCESSING(SSprocessing, src)
update_icon()
/obj/item/cell/Destroy()
if(self_charge_percentage)
STOP_PROCESSING(SSprocessing, src)
return ..()
/obj/item/cell/process(seconds_per_tick)
if(self_charge_percentage)
// we wanna recharge [self_charge_percentage% of the max charge] amount every 60 seconds
var/recharge_amount_per_minute = (maxcharge / 100) * self_charge_percentage
// since process fires every ~2 seconds, we wanna get the recharge amount per second
var/recharge_amount_per_second = recharge_amount_per_minute / 60
// multiply the amount per second with how many seconds this tick took, then round it to prevent float errors
var/recharge_for_this_process = round(recharge_amount_per_second * (seconds_per_tick / 10)) // divides seconds_per_tick by 10 to turn deciseconds into seconds
// finally, charge the cell
give(recharge_for_this_process)
/obj/item/cell/Created()
//Newly built cells spawn with no charge to prevent power exploits
charge = 0
@@ -59,6 +80,7 @@
return 0
var/used = min(charge, amount)
charge -= used
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
return used
// Checks if the specified amount can be provided. If it can, it removes the amount
@@ -78,6 +100,7 @@
var/amount_used = min(maxcharge-charge,amount)
charge += amount_used
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
return amount_used
@@ -180,6 +203,7 @@
charge -= maxcharge / severity
if (charge < 0)
charge = 0
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
/**
* Drains a percentage of the power from the battery
@@ -196,6 +220,7 @@
charge -= maxcharge / divisor
if (charge < 0)
charge = 0
SEND_SIGNAL(src, COMSIG_CELL_CHARGE, charge)
/obj/item/cell/ex_act(severity)