mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 03:55:11 +01:00
[MIRROR] Fixing robot upgrades not being removed from lists all times. (#1906)
* Fixing robot upgrades sometimes not being removed from lists. (#54842) * Fixing robot upgrades not being removed from lists all times. Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -852,11 +852,8 @@
|
||||
|
||||
// Remove upgrades.
|
||||
for(var/obj/item/borg/upgrade/I in upgrades)
|
||||
I.deactivate(src)
|
||||
I.forceMove(get_turf(src))
|
||||
|
||||
upgrades.Cut()
|
||||
|
||||
ionpulse = FALSE
|
||||
revert_shell()
|
||||
|
||||
@@ -904,7 +901,43 @@
|
||||
hat = null
|
||||
if(!QDELETED(src)) //Don't update icons if we are deleted.
|
||||
update_icons()
|
||||
. = ..()
|
||||
return ..()
|
||||
|
||||
///Use this to add upgrades to robots. It'll register signals for when the upgrade is moved or deleted, if not single use.
|
||||
/mob/living/silicon/robot/proc/add_to_upgrades(obj/item/borg/upgrade/new_upgrade, mob/user)
|
||||
if(new_upgrade in upgrades)
|
||||
return
|
||||
if(!new_upgrade.action(src, user))
|
||||
to_chat(user, "<span class='danger'>Upgrade error.</span>")
|
||||
return FALSE
|
||||
to_chat(user, "<span class='notice'>You apply the upgrade to [src].</span>")
|
||||
to_chat(src, "----------------\nNew hardware detected...Identified as \"<b>[new_upgrade]</b>\"...Setup complete.\n----------------")
|
||||
if(new_upgrade.one_use)
|
||||
logevent("Firmware [new_upgrade] run successfully.")
|
||||
qdel(new_upgrade)
|
||||
return FALSE
|
||||
upgrades += new_upgrade
|
||||
new_upgrade.forceMove(src)
|
||||
RegisterSignal(new_upgrade, COMSIG_MOVABLE_MOVED, .proc/remove_from_upgrades)
|
||||
RegisterSignal(new_upgrade, COMSIG_PARENT_QDELETING, .proc/on_upgrade_deleted)
|
||||
logevent("Hardware [new_upgrade] installed successfully.")
|
||||
|
||||
///Called when an upgrade is moved outside the robot. So don't call this directly, use forceMove etc.
|
||||
/mob/living/silicon/robot/proc/remove_from_upgrades(obj/item/borg/upgrade/old_upgrade)
|
||||
SIGNAL_HANDLER
|
||||
if(loc == src)
|
||||
return
|
||||
old_upgrade.deactivate(src)
|
||||
upgrades -= old_upgrade
|
||||
UnregisterSignal(old_upgrade, list(COMSIG_MOVABLE_MOVED, COMSIG_PARENT_QDELETING))
|
||||
|
||||
///Called when an applied upgrade is deleted.
|
||||
/mob/living/silicon/robot/proc/on_upgrade_deleted(obj/item/borg/upgrade/old_upgrade)
|
||||
SIGNAL_HANDLER
|
||||
if(!QDELETED(src))
|
||||
old_upgrade.deactivate(src)
|
||||
upgrades -= old_upgrade
|
||||
UnregisterSignal(old_upgrade, list(COMSIG_MOVABLE_MOVED, COMSIG_PARENT_QDELETING))
|
||||
|
||||
/**
|
||||
* make_shell: Makes an AI shell out of a cyborg unit
|
||||
|
||||
@@ -116,6 +116,9 @@ GLOBAL_LIST_INIT(blacklisted_borg_hats, typecacheof(list( //Hats that don't real
|
||||
if(!istype(module, /obj/item/robot_module/medical))
|
||||
to_chat(user, "<span class='warning'>[src] does not have correct mounting points for a defibrillator!</span>")
|
||||
return
|
||||
if(stat == DEAD)
|
||||
to_chat(user, "<span class='warning'>This defibrillator unit will not function on a deceased cyborg!</span>")
|
||||
return
|
||||
var/obj/item/defibrillator/D = W
|
||||
if(D.slot_flags != ITEM_SLOT_BACK) //belt defibs need not apply
|
||||
to_chat(user, "<span class='warning'>This defibrillator unit doesn't seem to fit correctly!</span>")
|
||||
@@ -126,13 +129,8 @@ GLOBAL_LIST_INIT(blacklisted_borg_hats, typecacheof(list( //Hats that don't real
|
||||
if(locate(/obj/item/borg/upgrade/defib) in src || locate(/obj/item/borg/upgrade/defib/backpack) in src)
|
||||
to_chat(user, "<span class='warning'>[src] already has a defibrillator!</span>")
|
||||
return
|
||||
var/obj/item/borg/upgrade/defib/backpack/B = new /obj/item/borg/upgrade/defib/backpack(src)
|
||||
B.action(src, user)
|
||||
to_chat(user, "<span class='notice'>You apply the upgrade to [src].</span>")
|
||||
to_chat(src, "----------------\nNew hardware detected...Identified as \"<b>[D]</b>\"...Setup complete.\n----------------")
|
||||
upgrades += B
|
||||
logevent("Hardware [D] detected and installed successfully.")
|
||||
qdel(D)
|
||||
var/obj/item/borg/upgrade/defib/backpack/B = new(null, D)
|
||||
add_to_upgrades(B, user)
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/ai_module))
|
||||
@@ -190,23 +188,9 @@ GLOBAL_LIST_INIT(blacklisted_borg_hats, typecacheof(list( //Hats that don't real
|
||||
to_chat(user, "<span class='warning'>The cyborg must choose a module before it can be upgraded!</span>")
|
||||
else if(U.locked)
|
||||
to_chat(user, "<span class='warning'>The upgrade is locked and cannot be used yet!</span>")
|
||||
else
|
||||
if(!user.temporarilyRemoveItemFromInventory(U))
|
||||
return
|
||||
if(U.action(src))
|
||||
to_chat(user, "<span class='notice'>You apply the upgrade to [src].</span>")
|
||||
to_chat(src, "----------------\nNew hardware detected...Identified as \"<b>[U]</b>\"...Setup complete.\n----------------")
|
||||
if(U.one_use)
|
||||
logevent("Firmware [U] run successfully.")
|
||||
qdel(U)
|
||||
else
|
||||
U.forceMove(src)
|
||||
upgrades += U
|
||||
logevent("Hardware [U] installed successfully.")
|
||||
|
||||
else
|
||||
to_chat(user, "<span class='danger'>Upgrade error.</span>")
|
||||
U.forceMove(drop_location())
|
||||
else if(user.canUnEquip(U))
|
||||
return
|
||||
add_to_upgrades(U, user)
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/toner))
|
||||
|
||||
Reference in New Issue
Block a user