mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 07:38:05 +01:00
Allows people to put their own tanks into bluespace gas vendors (#90279)
## About The Pull Request Lets people use their own tanks (of any type) in the bluespace gas vendor. Adds the sounds from canisters to inserting/removing tanks on the vendor. ## Why It's Good For The Game Allowing people to inserting their own tanks will improve use of the BSGV as before people were forced to use only the large tanks the vendor itself provided. Now people can refill their own tanks letting them do things such as refill their jetpacks with a waste gas in the vendor or letting plasmamen/fish refill their personal tanks so that they can keep breathing at any vendor. This makes giving beneficial gasses to the crew easier as they'll be able to decide what tanks they'll want to use in the vendor itself instead of having to take the tank they just bought over to a portable air pump so they can put it into their pocket tank/jetpack/whatever. ## Changelog 🆑 Goat qol: You can now insert tanks into bluespace gas vendors to fill instead of having to buy and use a large tank. sound: Bluespace gas vendors now use sounds from canisters when adding/removing tanks /🆑
This commit is contained in:
@@ -27,20 +27,24 @@
|
||||
var/obj/machinery/atmospherics/components/unary/bluespace_sender/connected_machine
|
||||
///Amount of usable tanks inside the machine
|
||||
var/empty_tanks = 10
|
||||
///Typepath to the tanks that vendor will make
|
||||
var/new_tank = /obj/item/tank/internals/generic
|
||||
///Reference to the current in use tank to be filled
|
||||
var/obj/item/tank/internals/generic/internal_tank
|
||||
var/obj/item/tank/internal_tank
|
||||
///Path of the gas selected from the UI to be pumped inside the tanks
|
||||
var/selected_gas
|
||||
///Is the vendor trying to move gases from the network to the tanks?
|
||||
var/pumping = FALSE
|
||||
///Has the user prepared a tank to be filled with gases?
|
||||
var/inserted_tank = FALSE
|
||||
///Amount of the tank already filled with gas (from 0 to 100)
|
||||
var/tank_filling_amount = 0
|
||||
///Base price of the tank
|
||||
var/tank_cost = 10
|
||||
///Has a tank been dispensed from the machine?
|
||||
var/tank_purchased = FALSE
|
||||
///Stores the current price of the gases inside the tank
|
||||
var/gas_price = 0
|
||||
///Mixture of purchased gas, used only for checking prices
|
||||
var/datum/gas_mixture/purchased_gas_mix = null
|
||||
///Helper for mappers, will automatically connect to the sender (ensure to only place one sender per map)
|
||||
var/map_spawned = TRUE
|
||||
///Current operating mode of the vendor
|
||||
@@ -68,7 +72,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
|
||||
/obj/machinery/bluespace_vendor/Initialize(mapload)
|
||||
. = ..()
|
||||
AddComponent(/datum/component/payment, tank_cost, SSeconomy.get_dep_account(ACCOUNT_ENG), PAYMENT_ANGRY)
|
||||
purchased_gas_mix = new(100)
|
||||
AddComponent(/datum/component/payment, 0, SSeconomy.get_dep_account(ACCOUNT_ENG), PAYMENT_ANGRY)
|
||||
find_and_hang_on_wall( FALSE)
|
||||
|
||||
/obj/machinery/bluespace_vendor/post_machine_initialize()
|
||||
@@ -97,6 +102,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
/obj/machinery/bluespace_vendor/Exited(atom/movable/gone, direction)
|
||||
if(gone == internal_tank)
|
||||
internal_tank = null
|
||||
purchased_gas_mix.remove_ratio(1)
|
||||
return ..()
|
||||
|
||||
/obj/machinery/bluespace_vendor/process()
|
||||
@@ -113,7 +119,9 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
update_appearance()
|
||||
return
|
||||
|
||||
connected_machine.bluespace_network.pump_gas_to(internal_tank.return_air(), (tank_filling_amount * 0.01) * 10 * ONE_ATMOSPHERE, gas_path)
|
||||
|
||||
var/datum/gas_mixture/to_merge = connected_machine.bluespace_network.pump_gas_to(internal_tank.return_air(), (tank_filling_amount * 0.01) * 10 * ONE_ATMOSPHERE, gas_path)
|
||||
purchased_gas_mix.merge(to_merge)
|
||||
|
||||
/obj/machinery/bluespace_vendor/multitool_act(mob/living/user, obj/item/multitool/multitool)
|
||||
if(!istype(multitool))
|
||||
@@ -142,18 +150,29 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
if(istype(item, /obj/item/stack/sheet/iron))
|
||||
var/obj/item/stack/sheet/iron/iron = item
|
||||
if (iron.use(1))
|
||||
user.balloon_alert(user, "sheet inserted")
|
||||
empty_tanks++
|
||||
return TRUE
|
||||
if(istype(item, /obj/item/tank) && !internal_tank && mode != BS_MODE_OFF)
|
||||
if(!user.transferItemToLoc(item, src))
|
||||
user.balloon_alert(user, "it's stuck!")
|
||||
return
|
||||
internal_tank = item
|
||||
playsound(src, 'sound/effects/compressed_air/tank_insert_clunky.ogg', 50)
|
||||
to_chat(user, span_notice("You insert [item] into the vendor."))
|
||||
return TRUE
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/machinery/bluespace_vendor/examine(mob/user)
|
||||
. = ..()
|
||||
if(empty_tanks > 1)
|
||||
. += span_notice("There are currently [empty_tanks] empty tanks available, more can be made by inserting iron sheets in the machine.")
|
||||
else if(empty_tanks == 1)
|
||||
. += span_notice("There is only one empty tank available, please refill the machine by using iron sheets.")
|
||||
else
|
||||
. += span_notice("There is no available tank, please refill the machine by using iron sheets.")
|
||||
switch(empty_tanks)
|
||||
if(2 to INFINITY)
|
||||
. += span_notice("There are currently [empty_tanks] empty tanks available, more can be made by inserting iron sheets in the machine.")
|
||||
if(1)
|
||||
. += span_notice("There is only one empty tank available, please refill the machine by using iron sheets.")
|
||||
if(0)
|
||||
. += span_notice("There is no available tank, please refill the machine by using iron sheets.")
|
||||
|
||||
///Check what is the current operating mode
|
||||
/obj/machinery/bluespace_vendor/proc/check_mode()
|
||||
@@ -185,22 +204,38 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
|
||||
///Check the price of the current tank, if the user doesn't have the money the gas will be merged back into the network
|
||||
/obj/machinery/bluespace_vendor/proc/check_price(mob/user)
|
||||
if (!purchased_gas_mix)
|
||||
if(tank_purchased)
|
||||
if(attempt_charge(src, user, tank_cost) & COMPONENT_OBJ_CANCEL_CHARGE)
|
||||
return
|
||||
if(internal_tank && Adjacent(user))
|
||||
tank_purchased = FALSE
|
||||
user.put_in_hands(internal_tank)
|
||||
playsound(src, 'sound/effects/compressed_air/tank_remove_thunk.ogg', 50)
|
||||
return
|
||||
|
||||
var/temp_price = 0
|
||||
var/datum/gas_mixture/working_mix = internal_tank.return_air()
|
||||
var/list/gases = working_mix.gases
|
||||
for(var/gas_id in gases)
|
||||
temp_price += gases[gas_id][MOLES] * connected_machine.base_prices[gas_id]
|
||||
var/list/purchased_gases = purchased_gas_mix.gases
|
||||
|
||||
for(var/gas_id in purchased_gases)
|
||||
temp_price += purchased_gases[gas_id][MOLES] * connected_machine.base_prices[gas_id]
|
||||
gas_price = temp_price
|
||||
|
||||
if(tank_purchased)
|
||||
gas_price += tank_cost
|
||||
|
||||
if(attempt_charge(src, user, gas_price) & COMPONENT_OBJ_CANCEL_CHARGE)
|
||||
var/datum/gas_mixture/remove = working_mix.remove_ratio(1)
|
||||
purchased_gas_mix.remove_ratio(1)
|
||||
connected_machine.bluespace_network.merge(remove)
|
||||
return
|
||||
connected_machine.credits_gained += gas_price + tank_cost
|
||||
connected_machine.credits_gained += gas_price
|
||||
|
||||
if(internal_tank && Adjacent(user)) //proper capitalysm take money before goods
|
||||
inserted_tank = FALSE
|
||||
tank_purchased = FALSE
|
||||
user.put_in_hands(internal_tank)
|
||||
playsound(src, 'sound/effects/compressed_air/tank_remove_thunk.ogg', 50)
|
||||
|
||||
/obj/machinery/bluespace_vendor/ui_interact(mob/user, datum/tgui/ui)
|
||||
if(!connected_machine || mode == BS_MODE_OPEN)
|
||||
@@ -234,7 +269,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
data["tank_filling_amount"] = tank_filling_amount
|
||||
data["selected_gas"] = selected_gas
|
||||
data["tank_amount"] = empty_tanks
|
||||
data["inserted_tank"] = inserted_tank
|
||||
data["inserted_tank"] = !!internal_tank
|
||||
var/total_tank_pressure
|
||||
if(internal_tank)
|
||||
var/datum/gas_mixture/working_mix = internal_tank.return_air()
|
||||
@@ -254,14 +289,14 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
|
||||
switch(action)
|
||||
if("start_pumping")
|
||||
if(inserted_tank && !pumping)
|
||||
if(internal_tank && !pumping)
|
||||
pumping = TRUE
|
||||
selected_gas = params["gas_id"]
|
||||
mode = BS_MODE_PUMPING
|
||||
update_appearance()
|
||||
. = TRUE
|
||||
if("stop_pumping")
|
||||
if(inserted_tank && pumping)
|
||||
if(internal_tank && pumping)
|
||||
pumping = FALSE
|
||||
selected_gas = null
|
||||
mode = BS_MODE_IDLE
|
||||
@@ -271,13 +306,13 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
|
||||
tank_filling_amount = clamp(params["rate"], 0, 100)
|
||||
. = TRUE
|
||||
if("tank_prepare")
|
||||
if(empty_tanks && !inserted_tank)
|
||||
inserted_tank = TRUE
|
||||
internal_tank = new(src)
|
||||
if(empty_tanks && !internal_tank)
|
||||
tank_purchased = TRUE
|
||||
internal_tank = new new_tank(src)
|
||||
empty_tanks = max(empty_tanks - 1, 0)
|
||||
. = TRUE
|
||||
if("tank_expel")
|
||||
if(inserted_tank && !pumping)
|
||||
if(internal_tank && !pumping)
|
||||
check_price(usr)
|
||||
. = TRUE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user