mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 04:57:57 +01:00
Removes amount_list_postion from reagent containers, adds related unit test. (#76057)
We had more issues like what #76013 addressed, now they're gone. Variable transfer amount is now explicit. Amount is now inferred from current value, performance concern here is minimal. Less work and mistakes when making new types.
This commit is contained in:
@@ -4,12 +4,12 @@
|
||||
icon = 'icons/obj/medical/chemical.dmi'
|
||||
icon_state = null
|
||||
w_class = WEIGHT_CLASS_TINY
|
||||
/// The maximum amount of reagents per transfer that will be moved out of this reagent container. This value's position in possible_transfer_amounts should be reflected in amount_list_position.
|
||||
/// The maximum amount of reagents per transfer that will be moved out of this reagent container.
|
||||
var/amount_per_transfer_from_this = 5
|
||||
/// Does this container allow changing transfer amounts at all, the container can still have only one possible transfer value in possible_transfer_amounts at some point even if this is true
|
||||
var/has_variable_transfer_amount = TRUE
|
||||
/// The different possible amounts of reagent to transfer out of the container
|
||||
var/list/possible_transfer_amounts = list(5,10,15,20,25,30)
|
||||
/// Where we are in the possible transfer amount list. Number should match the position in possible_transfer_amounts corresponding to amount_per_transfer_from_this.
|
||||
var/amount_list_position = 1
|
||||
/// The maximum amount of reagents this container can hold
|
||||
var/volume = 30
|
||||
/// Reagent flags, a few examples being if the container is open or not, if its transparent, if you can inject stuff in and out of the container, and so on
|
||||
@@ -47,15 +47,15 @@
|
||||
var/datum/disease/F = new spawned_disease()
|
||||
var/list/data = list("viruses"= list(F))
|
||||
reagents.add_reagent(/datum/reagent/blood, disease_amount, data)
|
||||
|
||||
add_initial_reagents()
|
||||
|
||||
/obj/item/reagent_containers/examine()
|
||||
. = ..()
|
||||
if(possible_transfer_amounts.len > 1)
|
||||
. += span_notice("Left-click or right-click in-hand to increase or decrease its transfer amount.")
|
||||
else if(possible_transfer_amounts.len)
|
||||
. += span_notice("Left-click or right-click in-hand to view its transfer amount.")
|
||||
if(has_variable_transfer_amount)
|
||||
if(possible_transfer_amounts.len > 1)
|
||||
. += span_notice("Left-click or right-click in-hand to increase or decrease its transfer amount.")
|
||||
else if(possible_transfer_amounts.len)
|
||||
. += span_notice("Left-click or right-click in-hand to view its transfer amount.")
|
||||
|
||||
/obj/item/reagent_containers/create_reagents(max_vol, flags)
|
||||
. = ..()
|
||||
@@ -77,10 +77,12 @@
|
||||
reagents.add_reagent_list(list_reagents)
|
||||
|
||||
/obj/item/reagent_containers/attack_self(mob/user)
|
||||
change_transfer_amount(user, FORWARD)
|
||||
if(has_variable_transfer_amount)
|
||||
change_transfer_amount(user, FORWARD)
|
||||
|
||||
/obj/item/reagent_containers/attack_self_secondary(mob/user)
|
||||
change_transfer_amount(user, BACKWARD)
|
||||
if(has_variable_transfer_amount)
|
||||
change_transfer_amount(user, BACKWARD)
|
||||
|
||||
/obj/item/reagent_containers/proc/mode_change_message(mob/user)
|
||||
return
|
||||
@@ -89,14 +91,15 @@
|
||||
var/list_len = length(possible_transfer_amounts)
|
||||
if(!list_len)
|
||||
return
|
||||
var/index = possible_transfer_amounts.Find(amount_per_transfer_from_this) || 1
|
||||
switch(direction)
|
||||
if(FORWARD)
|
||||
amount_list_position = (amount_list_position % list_len) + 1
|
||||
index = (index % list_len) + 1
|
||||
if(BACKWARD)
|
||||
amount_list_position = (amount_list_position - 1) || list_len
|
||||
index = (index - 1) || list_len
|
||||
else
|
||||
CRASH("change_transfer_amount() called with invalid direction value")
|
||||
amount_per_transfer_from_this = possible_transfer_amounts[amount_list_position]
|
||||
amount_per_transfer_from_this = possible_transfer_amounts[index]
|
||||
balloon_alert(user, "transferring [amount_per_transfer_from_this]u")
|
||||
mode_change_message(user)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
resistance_flags = ACID_PROOF
|
||||
var/sealed = FALSE
|
||||
fill_icon_thresholds = list(10, 20, 30, 40, 50, 60, 70, 80, 90, 100)
|
||||
possible_transfer_amounts = list()
|
||||
has_variable_transfer_amount = FALSE
|
||||
|
||||
/obj/item/reagent_containers/chem_pack/AltClick(mob/living/user)
|
||||
if(user.can_perform_action(src, NEED_DEXTERITY) && !sealed)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
name = "open container"
|
||||
amount_per_transfer_from_this = 10
|
||||
possible_transfer_amounts = list(5, 10, 15, 20, 25, 30, 50)
|
||||
amount_list_position = 2
|
||||
volume = 50
|
||||
reagent_flags = OPENCONTAINER | DUNKABLE
|
||||
spillable = TRUE
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
throwforce = 1
|
||||
amount_per_transfer_from_this = 5
|
||||
custom_materials = list(/datum/material/iron=SMALL_MATERIAL_AMOUNT)
|
||||
possible_transfer_amounts = list(5)
|
||||
has_variable_transfer_amount = FALSE
|
||||
volume = 5
|
||||
flags_1 = CONDUCT_1
|
||||
spillable = TRUE
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
inhand_icon_state = "dropper"
|
||||
worn_icon_state = "pen"
|
||||
amount_per_transfer_from_this = 5
|
||||
amount_list_position = 5
|
||||
possible_transfer_amounts = list(1, 2, 3, 4, 5)
|
||||
volume = 5
|
||||
reagent_flags = TRANSPARENT
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi'
|
||||
righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi'
|
||||
amount_per_transfer_from_this = 15
|
||||
has_variable_transfer_amount = FALSE
|
||||
volume = 15
|
||||
ignore_flags = 1 //so you can medipen through spacesuits
|
||||
reagent_flags = DRAWABLE
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
item_flags = NOBLUDGEON
|
||||
reagent_flags = OPENCONTAINER
|
||||
amount_per_transfer_from_this = 5
|
||||
possible_transfer_amounts = list()
|
||||
has_variable_transfer_amount = FALSE
|
||||
volume = 5
|
||||
spillable = FALSE
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
worn_icon_state = "nothing"
|
||||
lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi'
|
||||
righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi'
|
||||
possible_transfer_amounts = list()
|
||||
has_variable_transfer_amount = FALSE
|
||||
volume = 50
|
||||
grind_results = list()
|
||||
var/apply_type = INGEST
|
||||
|
||||
@@ -235,7 +235,7 @@
|
||||
lefthand_file = 'icons/mob/inhands/weapons/plants_lefthand.dmi'
|
||||
righthand_file = 'icons/mob/inhands/weapons/plants_righthand.dmi'
|
||||
amount_per_transfer_from_this = 1
|
||||
possible_transfer_amounts = list(1)
|
||||
has_variable_transfer_amount = FALSE
|
||||
can_toggle_range = FALSE
|
||||
current_range = 1
|
||||
volume = 10
|
||||
|
||||
@@ -199,6 +199,7 @@
|
||||
name = "lethal injection syringe"
|
||||
desc = "A syringe used for lethal injections. It can hold up to 50 units."
|
||||
amount_per_transfer_from_this = 50
|
||||
has_variable_transfer_amount = FALSE
|
||||
volume = 50
|
||||
|
||||
/obj/item/reagent_containers/syringe/lethal/choral
|
||||
@@ -211,6 +212,7 @@
|
||||
name = "Mulligan"
|
||||
desc = "A syringe used to completely change the users identity."
|
||||
amount_per_transfer_from_this = 1
|
||||
has_variable_transfer_amount = FALSE
|
||||
volume = 1
|
||||
list_reagents = list(/datum/reagent/mulligan = 1)
|
||||
|
||||
@@ -218,6 +220,7 @@
|
||||
name = "Gluttony's Blessing"
|
||||
desc = "A syringe recovered from a dread place. It probably isn't wise to use."
|
||||
amount_per_transfer_from_this = 1
|
||||
has_variable_transfer_amount = FALSE
|
||||
volume = 1
|
||||
list_reagents = list(/datum/reagent/gluttonytoxin = 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user