From 985d410657d7b20ec83f0f0e47a39e20e014a0a8 Mon Sep 17 00:00:00 2001 From: Loganbacca Date: Tue, 13 Jan 2015 23:19:58 +1300 Subject: [PATCH] Air tank interface fix - Allows tanks to be toggled on and off as internals from their UI. - If internals are off, all tanks capable of being used for internals will display "tank is connected to a mask". - If internals are on, only the tank that is actively supplying air is listed as "connected" and "open". All others will display as "not connected". - Tanks inside rigs will correctly display their status in their UI (if you open it before putting it in the rig, but cannot be toggled on through the interface. Toggling them on with the internals button works. --- .../game/objects/items/weapons/tanks/tanks.dm | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/code/game/objects/items/weapons/tanks/tanks.dm b/code/game/objects/items/weapons/tanks/tanks.dm index f6485f0a16..d7a05a7173 100644 --- a/code/game/objects/items/weapons/tanks/tanks.dm +++ b/code/game/objects/items/weapons/tanks/tanks.dm @@ -117,10 +117,16 @@ ui_interact(user) /obj/item/weapon/tank/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + var/mob/living/carbon/location = null + if(istype(loc, /obj/item/weapon/rig)) // check for tanks in rigs + if(istype(loc.loc, /mob/living/carbon)) + location = loc.loc + else if(istype(loc, /mob/living/carbon)) + location = loc + var/using_internal - if(istype(loc,/mob/living/carbon)) - var/mob/living/carbon/location = loc + if(istype(location)) if(location.internal==src) using_internal = 1 @@ -133,9 +139,20 @@ data["valveOpen"] = using_internal ? 1 : 0 data["maskConnected"] = 0 - if(istype(loc,/mob/living/carbon)) - var/mob/living/carbon/location = loc - if(location.internal == src) + + if(istype(location)) + var/mask_check = 0 + + if(location.internal == src) // if tank is current internal + mask_check = 1 + else if(src in location) // or if tank is in the mobs possession + if(!location.internal) // and they do not have any active internals + mask_check = 1 + else if(istype(src.loc, /obj/item/weapon/rig) && src.loc in location) // or the rig is in the mobs possession + if(!location.internal) // and they do not have any active internals + mask_check = 1 + + if(mask_check) if(location.wear_mask && (location.wear_mask.flags & AIRTIGHT)) data["maskConnected"] = 1 else if(istype(location, /mob/living/carbon/human))