mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-21 20:11:04 +01:00
Recharger backpacks improvements (#18831)
Recharger backpacks now intuitively handle the connection with a simple item-on-backpack click. Improved backend handling, cleanly handle ref dropping to gun, localized management of the backpack, DMdoc, you know the deal. Fixes #18538
This commit is contained in:
@@ -140,22 +140,31 @@
|
||||
return null
|
||||
|
||||
/**
|
||||
* Connects the energy gun to an external power supply
|
||||
*
|
||||
* * powersource - the power supply in question. Can either be /obj/item/rig_module/recharger or /obj/item/recharger_backpack.
|
||||
*/
|
||||
* Connects the energy gun to an external power supply
|
||||
*
|
||||
* * powersource - the power supply in question. Can either be `/obj/item/rig_module/recharger` or `/obj/item/recharger_backpack`.
|
||||
*
|
||||
* Returns `TRUE` if the connection was successful, `FALSE` otherwise
|
||||
*/
|
||||
/obj/item/gun/energy/proc/connect(obj/item/powersource)
|
||||
SHOULD_NOT_SLEEP(TRUE)
|
||||
|
||||
//Validate that the type is allowed first of all
|
||||
if(!is_type_in_list(powersource, list(/obj/item/rig_module/recharger, /obj/item/recharger_backpack)))
|
||||
stack_trace("Wrong type to connect the energy gun to!")
|
||||
return FALSE
|
||||
|
||||
//If we're already connected with something, we can't connect with something else
|
||||
if(recharger)
|
||||
to_chat(usr, SPAN_WARNING("\The [src] is already connected to \the [recharger]!"))
|
||||
return
|
||||
return FALSE
|
||||
|
||||
if(istype(powersource, /obj/item/rig_module/recharger))
|
||||
var/obj/item/rig_module/recharger/rigcharge = powersource
|
||||
|
||||
if(!rigcharge.holder || !rigcharge.holder.wearer)
|
||||
to_chat(usr, SPAN_WARNING("\The [rigcharge] must be installed in a rig and active!"))
|
||||
return
|
||||
return FALSE
|
||||
|
||||
to_chat(usr, SPAN_NOTICE("You neatly plug \the [src] into \the [powersource]."))
|
||||
playsound(get_turf(src), 'sound/machines/click.ogg', 30, 0)
|
||||
@@ -164,12 +173,12 @@
|
||||
self_recharge = TRUE
|
||||
use_external_power = TRUE
|
||||
|
||||
if(istype(powersource, /obj/item/recharger_backpack))
|
||||
else if(istype(powersource, /obj/item/recharger_backpack))
|
||||
var/obj/item/recharger_backpack/back_charge = powersource
|
||||
|
||||
if(!ismob(loc))
|
||||
to_chat(usr, SPAN_WARNING("\The [back_charge] must be worn on the back before a weapon can be connected!"))
|
||||
return
|
||||
return FALSE
|
||||
|
||||
to_chat(usr, SPAN_NOTICE("You neatly plug \the [src] into \the [powersource]."))
|
||||
playsound(get_turf(src), 'sound/machines/click.ogg', 30, 0)
|
||||
@@ -178,6 +187,8 @@
|
||||
self_recharge = TRUE
|
||||
use_external_power = TRUE
|
||||
|
||||
return TRUE
|
||||
|
||||
|
||||
///Disconnects the energy gun from its external power source if one exists.
|
||||
/obj/item/gun/energy/proc/disconnect()
|
||||
@@ -200,7 +211,7 @@
|
||||
var/obj/item/recharger_backpack/backcharger = recharger
|
||||
to_chat(usr, SPAN_NOTICE("With a snap, \the [src] is disconnected from \the [recharger]."))
|
||||
playsound(get_turf(src), 'sound/machines/click.ogg', 30, 0)
|
||||
backcharger.connected = null
|
||||
backcharger.disconnect(src)
|
||||
|
||||
recharger = null
|
||||
self_recharge = initial(self_recharge)
|
||||
|
||||
Reference in New Issue
Block a user