mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 03:27:05 +01:00
Merge pull request #6349 from Fox-McCloud/ttv-cleanup
Tank Transfer Valve Cleanup and In-Hands
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
icon = 'icons/obj/assemblies.dmi'
|
||||
name = "tank transfer valve"
|
||||
icon_state = "valve_1"
|
||||
item_state = "ttv"
|
||||
desc = "Regulates the transfer of air between two tanks"
|
||||
var/obj/item/weapon/tank/tank_one
|
||||
var/obj/item/weapon/tank/tank_two
|
||||
var/obj/item/device/attached_device
|
||||
var/mob/attacher = null
|
||||
var/obj/item/weapon/tank/tank_one = null
|
||||
var/obj/item/weapon/tank/tank_two = null
|
||||
var/obj/item/device/assembly/attached_device = null
|
||||
var/mob/living/attacher = null
|
||||
var/valve_open = 0
|
||||
var/toggle = 1
|
||||
origin_tech = "materials=1;engineering=1"
|
||||
@@ -21,75 +22,79 @@
|
||||
if(attached_device)
|
||||
qdel(attached_device)
|
||||
attached_device = null
|
||||
attacher = null
|
||||
return ..()
|
||||
|
||||
/obj/item/device/transfer_valve/proc/process_activation(var/obj/item/device/D)
|
||||
|
||||
/obj/item/device/transfer_valve/IsAssemblyHolder()
|
||||
return 1
|
||||
|
||||
/obj/item/device/transfer_valve/attackby(obj/item/item, mob/user, params)
|
||||
if(istype(item, /obj/item/weapon/tank))
|
||||
/obj/item/device/transfer_valve/attackby(obj/item/I, mob/user, params)
|
||||
if(istype(I, /obj/item/weapon/tank))
|
||||
if(tank_one && tank_two)
|
||||
to_chat(user, "<span class='warning'>There are already two tanks attached, remove one first.</span>")
|
||||
return
|
||||
|
||||
if(!tank_one)
|
||||
tank_one = item
|
||||
user.drop_item()
|
||||
item.loc = src
|
||||
if(!user.unEquip(I))
|
||||
return
|
||||
tank_one = I
|
||||
I.forceMove(src)
|
||||
to_chat(user, "<span class='notice'>You attach the tank to the transfer valve.</span>")
|
||||
if(I.w_class > w_class)
|
||||
w_class = I.w_class
|
||||
else if(!tank_two)
|
||||
tank_two = item
|
||||
user.drop_item()
|
||||
item.loc = src
|
||||
if(!user.unEquip(I))
|
||||
return
|
||||
tank_two = I
|
||||
I.forceMove(src)
|
||||
to_chat(user, "<span class='notice'>You attach the tank to the transfer valve.</span>")
|
||||
if(I.w_class > w_class)
|
||||
w_class = I.w_class
|
||||
|
||||
update_icon()
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
//TODO: Have this take an assemblyholder
|
||||
else if(isassembly(item))
|
||||
var/obj/item/device/assembly/A = item
|
||||
else if(isassembly(I))
|
||||
var/obj/item/device/assembly/A = I
|
||||
if(A.secured)
|
||||
to_chat(user, "<span class='notice'>The device is secured.</span>")
|
||||
return
|
||||
if(attached_device)
|
||||
to_chat(user, "<span class='warning'>There is already a device attached to the valve, remove it first.</span>")
|
||||
return
|
||||
user.remove_from_mob(item)
|
||||
user.remove_from_mob(A)
|
||||
attached_device = A
|
||||
A.loc = src
|
||||
to_chat(user, "<span class='notice'>You attach the [item] to the valve controls and secure it.</span>")
|
||||
A.forceMove(src)
|
||||
to_chat(user, "<span class='notice'>You attach the [A] to the valve controls and secure it.</span>")
|
||||
A.holder = src
|
||||
A.toggle_secure() //this calls update_icon(), which calls update_icon() on the holder (i.e. the bomb).
|
||||
|
||||
bombers += "[key_name(user)] attached a [item] to a transfer valve."
|
||||
msg_admin_attack("[key_name_admin(user)]attached [item] to a transfer valve.")
|
||||
log_game("[key_name_admin(user)] attached [item] to a transfer valve.")
|
||||
bombers += "[key_name(user)] attached a [A] to a transfer valve."
|
||||
msg_admin_attack("[key_name_admin(user)]attached [A] to a transfer valve.")
|
||||
log_game("[key_name_admin(user)] attached [A] to a transfer valve.")
|
||||
attacher = user
|
||||
nanomanager.update_uis(src) // update all UIs attached to src
|
||||
return
|
||||
|
||||
|
||||
/obj/item/device/transfer_valve/HasProximity(atom/movable/AM as mob|obj)
|
||||
if(!attached_device) return
|
||||
/obj/item/device/transfer_valve/HasProximity(atom/movable/AM)
|
||||
if(!attached_device)
|
||||
return
|
||||
attached_device.HasProximity(AM)
|
||||
return
|
||||
|
||||
/obj/item/device/transfer_valve/hear_talk(mob/living/M as mob, msg)
|
||||
/obj/item/device/transfer_valve/hear_talk(mob/living/M, msg)
|
||||
..()
|
||||
for(var/obj/O in contents)
|
||||
O.hear_talk(M, msg)
|
||||
|
||||
/obj/item/device/transfer_valve/hear_message(mob/living/M as mob, msg)
|
||||
/obj/item/device/transfer_valve/hear_message(mob/living/M, msg)
|
||||
..()
|
||||
for(var/obj/O in contents)
|
||||
O.hear_message(M, msg)
|
||||
|
||||
/obj/item/device/transfer_valve/attack_self(mob/user as mob)
|
||||
/obj/item/device/transfer_valve/attack_self(mob/user)
|
||||
ui_interact(user)
|
||||
|
||||
/obj/item/device/transfer_valve/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
/obj/item/device/transfer_valve/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
@@ -113,36 +118,40 @@
|
||||
|
||||
/obj/item/device/transfer_valve/Topic(href, href_list)
|
||||
..()
|
||||
if( usr.stat || usr.restrained() )
|
||||
if(usr.incapacitated())
|
||||
return 0
|
||||
if(src.loc != usr)
|
||||
if(loc != usr)
|
||||
return 0
|
||||
if(tank_one && href_list["tankone"])
|
||||
split_gases()
|
||||
valve_open = 0
|
||||
tank_one.loc = get_turf(src)
|
||||
tank_one.forceMove(get_turf(src))
|
||||
tank_one = null
|
||||
update_icon()
|
||||
if((!tank_two || tank_two.w_class < 4) && (w_class > 3))
|
||||
w_class = 3
|
||||
else if(tank_two && href_list["tanktwo"])
|
||||
split_gases()
|
||||
valve_open = 0
|
||||
tank_two.loc = get_turf(src)
|
||||
tank_two.forceMove(get_turf(src))
|
||||
tank_two = null
|
||||
update_icon()
|
||||
if((!tank_one || tank_one.w_class < 4) && (w_class > 3))
|
||||
w_class = 3
|
||||
else if(href_list["open"])
|
||||
toggle_valve()
|
||||
else if(attached_device)
|
||||
if(href_list["rem_device"])
|
||||
attached_device.loc = get_turf(src)
|
||||
attached_device:holder = null
|
||||
attached_device.forceMove(get_turf(src))
|
||||
attached_device.holder = null
|
||||
attached_device = null
|
||||
update_icon()
|
||||
if(href_list["device"])
|
||||
attached_device.attack_self(usr)
|
||||
src.add_fingerprint(usr)
|
||||
add_fingerprint(usr)
|
||||
return 1 // Returning 1 sends an update to attached UIs
|
||||
|
||||
/obj/item/device/transfer_valve/process_activation(var/obj/item/device/D)
|
||||
/obj/item/device/transfer_valve/proc/process_activation(obj/item/device/D)
|
||||
if(toggle)
|
||||
toggle = 0
|
||||
toggle_valve()
|
||||
@@ -188,7 +197,7 @@
|
||||
*/
|
||||
|
||||
/obj/item/device/transfer_valve/proc/toggle_valve()
|
||||
if(valve_open==0 && (tank_one && tank_two))
|
||||
if(!valve_open && tank_one && tank_two)
|
||||
valve_open = 1
|
||||
var/turf/bombturf = get_turf(src)
|
||||
var/area/A = get_area(bombturf)
|
||||
@@ -206,17 +215,12 @@
|
||||
log_game("Bomb valve opened at [A.name] ([bombturf.x],[bombturf.y],[bombturf.z]) with [attached_device ? attached_device : "no device"], attached by [attacher_name]. Last touched by: [key_name(mob)]")
|
||||
merge_gases()
|
||||
spawn(20) // In case one tank bursts
|
||||
for(var/i=0,i<5,i++)
|
||||
src.update_icon()
|
||||
for(var/i in 1 to 5)
|
||||
update_icon()
|
||||
sleep(10)
|
||||
src.update_icon()
|
||||
update_icon()
|
||||
|
||||
else if(valve_open==1 && (tank_one && tank_two))
|
||||
else if(valve_open && tank_one && tank_two)
|
||||
split_gases()
|
||||
valve_open = 0
|
||||
src.update_icon()
|
||||
|
||||
// this doesn't do anything but the timer etc. expects it to be here
|
||||
// eventually maybe have it update icon to show state (timer, prox etc.) like old bombs
|
||||
/obj/item/device/transfer_valve/proc/c_state()
|
||||
return
|
||||
update_icon()
|
||||
Reference in New Issue
Block a user