Files
Aurora.3/code/game/objects/items/recharger_backpack.dm
Matt Atlas 94d92803b4 Replaces our lighting system with CM's. (#21465)
Depends on #21458.

Ports https://github.com/cmss13-devs/cmss13/pull/4229, with the original
authors as:

- https://github.com/tgstation/TerraGov-Marine-Corps/pull/1964 for the
lighting controller (A-lexa)
- https://github.com/tgstation/TerraGov-Marine-Corps/pull/4747 and
https://github.com/tgstation/TerraGov-Marine-Corps/pull/7263 for the
lighting (TiviPlus)
- https://github.com/tgstation/tgstation/pull/54520 for the dir lighting
component
- https://github.com/tgstation/tgstation/pull/75018 for the out of
bounds fix in lighting
- https://github.com/tgstation/TerraGov-Marine-Corps/pull/6678 for the
emissives (TiviPlus)

The main driving reason behind this is that current lighting consumes
way too much processing power, especially for things like odysseys/away
sites where a billion light sources are processing/moving at once and
the game slows down to a crawl. Hopefully this improves the situation by
a good margin, but we will need some testmerging to confirm that.
<img width="1349" height="1349" alt="image"
src="https://github.com/user-attachments/assets/1059ba2b-c0c5-495a-9c76-2d75d0c42bf2"
/>
<img width="1349" height="1349" alt="image"
src="https://github.com/user-attachments/assets/9704b0f6-4cf6-4dfd-a6cb-5702ad07d677"
/>


- [x] Resolve todos
- [x] Look into open space fuckery (border objects)

---------

Co-authored-by: Matt Atlas <liermattia@gmail.com>
Co-authored-by: JohnWildkins <john.wildkins@gmail.com>
2025-11-04 21:27:42 +00:00

136 lines
4.2 KiB
Plaintext

/obj/item/recharger_backpack
name = "weapon recharger backpack"
desc = "Developed by Hephaestus Industries, the HI-92 Recharge Platform is designed for long-term field recharge of energy weapons. Due to legal concerns, the design is rarely seen outside of military hands."
icon = 'icons/obj/recharger_backpack.dmi'
icon_state = "recharger_backpack"
item_state = "recharger_backpack"
contained_sprite = TRUE
w_class = WEIGHT_CLASS_BULKY
slot_flags = SLOT_BACK
///Power cell used to recharge the gun. Empty by default.
var/obj/item/cell/powersupply
///The gun we're currently recharging. Connection handled in connect() and /obj/item/gun/energy/connect()
var/obj/item/gun/energy/connected
/obj/item/recharger_backpack/feedback_hints(mob/user, distance, is_adjacent)
. += ..()
if(powersupply)
. += SPAN_NOTICE("The backpack display shows that the installed power cell is at <b>[round(powersupply.percent())]%</b>.")
/obj/item/recharger_backpack/Initialize()
. = ..()
//To update the icon based on the power cell charge we spawn with
update_icon()
/obj/item/recharger_backpack/Destroy()
if(connected)
connected.disconnect()
QDEL_NULL(powersupply)
. = ..()
/obj/item/recharger_backpack/attackby(obj/item/attacking_item, mob/user)
if(istype(attacking_item, /obj/item/cell) && !powersupply)
to_chat(usr, SPAN_NOTICE("You slot \the [attacking_item] into \the [src]'s power socket."))
playsound(get_turf(src), 'sound/machines/click.ogg', 30, 0)
user.drop_from_inventory(attacking_item, src)
powersupply = attacking_item
update_icon()
else if(istype(attacking_item, /obj/item/screwdriver) && powersupply)
to_chat(user, SPAN_NOTICE("You remove \the [powersupply] from \the [src]'s power socket"))
powersupply.forceMove(get_turf(src))
user.put_in_hands(powersupply)
powersupply = null
update_icon()
else if(istype(attacking_item, /obj/item/gun/energy))
var/obj/item/gun/energy/gun_attempting_to_connect = attacking_item
gun_attempting_to_connect.connect(src)
else
. = ..()
/obj/item/recharger_backpack/AltClick(mob/user)
if(!connected)
to_chat(usr, SPAN_WARNING("\The [src] has no energy weapon connected!"))
return
connected.disconnect()
/obj/item/recharger_backpack/update_icon()
. = ..()
if(!powersupply)
icon_state = "recharger_backpack"
item_state = "recharger_backpack"
set_light_on(FALSE)
else
var/current_charge = powersupply.percent()
switch(current_charge)
if(70 to INFINITY)
icon_state = "recharger_backpack_full"
item_state = "recharger_backpack_full"
set_light_range_power_color(2, 0.75, LIGHT_COLOR_GREEN)
set_light_on(TRUE)
if(35 to 70)
icon_state = "recharger_backpack_med"
item_state = "recharger_backpack_med"
set_light_range_power_color(2, 0.75, LIGHT_COLOR_FIRE)
set_light_on(TRUE)
if(1 to 35)
icon_state = "recharger_backpack_low"
item_state = "recharger_backpack_low"
set_light_range_power_color(2, 0.75, LIGHT_COLOR_RED)
set_light_on(TRUE)
if(-INFINITY to 1)
icon_state = "recharger_backpack"
item_state = "recharger_backpack"
set_light_on(FALSE)
/obj/item/recharger_backpack/get_cell()
if(powersupply)
return powersupply
return ..()
/**
* Connects a gun to the backpack
*
* * newgun - An `/obj/item/gun/energy` to connect to the backpack
*
* Returns `TRUE` if the connection was successful, `FALSE` otherwise
*/
/obj/item/recharger_backpack/proc/connect(obj/item/gun/energy/newgun)
if(connected)
to_chat(usr, SPAN_WARNING("\The [src] already has an energy weapon connected!"))
return FALSE
connected = newgun
RegisterSignal(connected, COMSIG_QDELETING, PROC_REF(handle_weapon_qdel))
return TRUE
/**
* Disconnects a gun from the backpack
*
* * disconnecting_gun - An `/obj/item/gun/energy` to disconnect from the backpack
*/
/obj/item/recharger_backpack/proc/disconnect(obj/item/gun/energy/disconnecting_gun)
UnregisterSignal(connected, COMSIG_QDELETING)
connected = null
///Handles the weapon connected to the backpack being deleted
/obj/item/recharger_backpack/proc/handle_weapon_qdel()
SIGNAL_HANDLER
connected = null
/*###############
SUBTYPES
###############*/
/obj/item/recharger_backpack/high/Initialize()
. = ..()
powersupply = new /obj/item/cell/high(src)
update_icon()