mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 02:09:41 +00:00
TTV Refactor
Ensures TTV icon update occurs properly and removes the need for sleep() by updating tank Destroy() to account for TTVs. Collects duplicated code into a transfer_valve/remove_tank() proc.
This commit is contained in:
@@ -99,17 +99,9 @@
|
|||||||
if (src.loc != usr)
|
if (src.loc != usr)
|
||||||
return 0
|
return 0
|
||||||
if(tank_one && href_list["tankone"])
|
if(tank_one && href_list["tankone"])
|
||||||
split_gases()
|
remove_tank(tank_one)
|
||||||
valve_open = 0
|
|
||||||
tank_one.loc = get_turf(src)
|
|
||||||
tank_one = null
|
|
||||||
update_icon()
|
|
||||||
else if(tank_two && href_list["tanktwo"])
|
else if(tank_two && href_list["tanktwo"])
|
||||||
split_gases()
|
remove_tank(tank_two)
|
||||||
valve_open = 0
|
|
||||||
tank_two.loc = get_turf(src)
|
|
||||||
tank_two = null
|
|
||||||
update_icon()
|
|
||||||
else if(href_list["open"])
|
else if(href_list["open"])
|
||||||
toggle_valve()
|
toggle_valve()
|
||||||
else if(attached_device)
|
else if(attached_device)
|
||||||
@@ -148,29 +140,51 @@
|
|||||||
if(attached_device)
|
if(attached_device)
|
||||||
overlays += "device"
|
overlays += "device"
|
||||||
|
|
||||||
|
/obj/item/device/transfer_valve/proc/remove_tank(obj/item/weapon/tank/T)
|
||||||
|
if(tank_one == T)
|
||||||
|
split_gases()
|
||||||
|
tank_one = null
|
||||||
|
else if(tank_two == T)
|
||||||
|
split_gases()
|
||||||
|
tank_two = null
|
||||||
|
else
|
||||||
|
return
|
||||||
|
|
||||||
|
T.loc = get_turf(src)
|
||||||
|
update_icon()
|
||||||
|
|
||||||
/obj/item/device/transfer_valve/proc/merge_gases()
|
/obj/item/device/transfer_valve/proc/merge_gases()
|
||||||
|
if(valve_open)
|
||||||
|
return
|
||||||
tank_two.air_contents.volume += tank_one.air_contents.volume
|
tank_two.air_contents.volume += tank_one.air_contents.volume
|
||||||
var/datum/gas_mixture/temp
|
var/datum/gas_mixture/temp
|
||||||
temp = tank_one.air_contents.remove_ratio(1)
|
temp = tank_one.air_contents.remove_ratio(1)
|
||||||
tank_two.air_contents.merge(temp)
|
tank_two.air_contents.merge(temp)
|
||||||
|
valve_open = 1
|
||||||
|
|
||||||
/obj/item/device/transfer_valve/proc/split_gases()
|
/obj/item/device/transfer_valve/proc/split_gases()
|
||||||
if (!valve_open || !tank_one || !tank_two)
|
if(!valve_open)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
valve_open = 0
|
||||||
|
|
||||||
|
if(deleted(tank_one) || deleted(tank_two))
|
||||||
|
return
|
||||||
|
|
||||||
var/ratio1 = tank_one.air_contents.volume/tank_two.air_contents.volume
|
var/ratio1 = tank_one.air_contents.volume/tank_two.air_contents.volume
|
||||||
var/datum/gas_mixture/temp
|
var/datum/gas_mixture/temp
|
||||||
temp = tank_two.air_contents.remove_ratio(ratio1)
|
temp = tank_two.air_contents.remove_ratio(ratio1)
|
||||||
tank_one.air_contents.merge(temp)
|
tank_one.air_contents.merge(temp)
|
||||||
tank_two.air_contents.volume -= tank_one.air_contents.volume
|
tank_two.air_contents.volume -= tank_one.air_contents.volume
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Exadv1: I know this isn't how it's going to work, but this was just to check
|
Exadv1: I know this isn't how it's going to work, but this was just to check
|
||||||
it explodes properly when it gets a signal (and it does).
|
it explodes properly when it gets a signal (and it does).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/obj/item/device/transfer_valve/proc/toggle_valve()
|
/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/turf/bombturf = get_turf(src)
|
||||||
var/area/A = get_area(bombturf)
|
var/area/A = get_area(bombturf)
|
||||||
|
|
||||||
@@ -196,15 +210,10 @@
|
|||||||
message_admins(log_str, 0, 1)
|
message_admins(log_str, 0, 1)
|
||||||
log_game(log_str)
|
log_game(log_str)
|
||||||
merge_gases()
|
merge_gases()
|
||||||
spawn(20) // In case one tank bursts
|
|
||||||
for (var/i=0,i<5,i++)
|
|
||||||
src.update_icon()
|
|
||||||
sleep(10)
|
|
||||||
src.update_icon()
|
|
||||||
|
|
||||||
else if(valve_open==1 && (tank_one && tank_two))
|
else if(valve_open==1 && (tank_one && tank_two))
|
||||||
split_gases()
|
split_gases()
|
||||||
valve_open = 0
|
|
||||||
src.update_icon()
|
src.update_icon()
|
||||||
|
|
||||||
// this doesn't do anything but the timer etc. expects it to be here
|
// this doesn't do anything but the timer etc. expects it to be here
|
||||||
|
|||||||
@@ -37,6 +37,10 @@
|
|||||||
|
|
||||||
processing_objects.Remove(src)
|
processing_objects.Remove(src)
|
||||||
|
|
||||||
|
if(istype(loc, /obj/item/device/transfer_valve))
|
||||||
|
var/obj/item/device/transfer_valve/TTV = loc
|
||||||
|
TTV.remove_tank(src)
|
||||||
|
|
||||||
..()
|
..()
|
||||||
|
|
||||||
/obj/item/weapon/tank/examine(mob/user)
|
/obj/item/weapon/tank/examine(mob/user)
|
||||||
@@ -280,7 +284,10 @@
|
|||||||
qdel(src)
|
qdel(src)
|
||||||
|
|
||||||
else if(pressure > TANK_RUPTURE_PRESSURE)
|
else if(pressure > TANK_RUPTURE_PRESSURE)
|
||||||
//world << "\blue[x],[y] tank is rupturing: [pressure] kPa, integrity [integrity]"
|
#ifdef FIREDBG
|
||||||
|
log_debug("\blue[x],[y] tank is rupturing: [pressure] kPa, integrity [integrity]")
|
||||||
|
#endif
|
||||||
|
|
||||||
if(integrity <= 0)
|
if(integrity <= 0)
|
||||||
var/turf/simulated/T = get_turf(src)
|
var/turf/simulated/T = get_turf(src)
|
||||||
if(!T)
|
if(!T)
|
||||||
@@ -292,7 +299,10 @@
|
|||||||
integrity--
|
integrity--
|
||||||
|
|
||||||
else if(pressure > TANK_LEAK_PRESSURE)
|
else if(pressure > TANK_LEAK_PRESSURE)
|
||||||
//world << "\blue[x],[y] tank is leaking: [pressure] kPa, integrity [integrity]"
|
#ifdef FIREDBG
|
||||||
|
log_debug("\blue[x],[y] tank is leaking: [pressure] kPa, integrity [integrity]")
|
||||||
|
#endif
|
||||||
|
|
||||||
if(integrity <= 0)
|
if(integrity <= 0)
|
||||||
var/turf/simulated/T = get_turf(src)
|
var/turf/simulated/T = get_turf(src)
|
||||||
if(!T)
|
if(!T)
|
||||||
|
|||||||
Reference in New Issue
Block a user