mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Refactors reagent exposure code (#51396)
* Refactors reagent exposure code Removes istype clutter. Renames a few procs * == TRUE Adjusts COMPONENT_NO_EXPOSE_REAGENTS bitflag offset. TODO: Remove comment Co-authored-by: Rohesie <rohesie@gmail.com> * == TRUE Adjusts COMONENT_NO_EXPOSE REAGENTS bitflag offset. Removes comment Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
co-authored by
Rohesie
parent
356e369109
commit
e78d82592f
@@ -142,7 +142,7 @@
|
||||
if(O.type == src.type)
|
||||
continue
|
||||
if(lifetime % reagent_divisor)
|
||||
reagents.reaction(O, VAPOR, fraction)
|
||||
reagents.expose(O, VAPOR, fraction)
|
||||
var/hit = 0
|
||||
for(var/mob/living/L in range(0,src))
|
||||
hit += foam_mob(L)
|
||||
@@ -150,7 +150,7 @@
|
||||
lifetime++ //this is so the decrease from mobs hit and the natural decrease don't cumulate.
|
||||
var/T = get_turf(src)
|
||||
if(lifetime % reagent_divisor)
|
||||
reagents.reaction(T, VAPOR, fraction)
|
||||
reagents.expose(T, VAPOR, fraction)
|
||||
|
||||
if(--amount < 0)
|
||||
return
|
||||
@@ -163,7 +163,7 @@
|
||||
return 0
|
||||
var/fraction = 1/initial(reagent_divisor)
|
||||
if(lifetime % reagent_divisor)
|
||||
reagents.reaction(L, VAPOR, fraction)
|
||||
reagents.expose(L, VAPOR, fraction)
|
||||
lifetime--
|
||||
return 1
|
||||
|
||||
|
||||
@@ -232,9 +232,9 @@
|
||||
for(var/atom/movable/AM in T)
|
||||
if(AM.type == src.type)
|
||||
continue
|
||||
reagents.reaction(AM, TOUCH, fraction)
|
||||
reagents.expose(AM, TOUCH, fraction)
|
||||
|
||||
reagents.reaction(T, TOUCH, fraction)
|
||||
reagents.expose(T, TOUCH, fraction)
|
||||
return 1
|
||||
|
||||
/obj/effect/particle_effect/smoke/chem/smoke_mob(mob/living/carbon/M)
|
||||
@@ -247,7 +247,7 @@
|
||||
return 0
|
||||
var/fraction = 1/initial(lifetime)
|
||||
reagents.copy_to(C, fraction*reagents.total_volume)
|
||||
reagents.reaction(M, INGEST, fraction)
|
||||
reagents.expose(M, INGEST, fraction)
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
/obj/effect/particle_effect/water/Bump(atom/A)
|
||||
if(reagents)
|
||||
reagents.reaction(A)
|
||||
reagents.expose(A)
|
||||
return ..()
|
||||
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
// make some colorful reagent, and apply it to the lungs
|
||||
L.create_reagents(10)
|
||||
L.reagents.add_reagent(/datum/reagent/colorful_reagent, 10)
|
||||
L.reagents.reaction(L, TOUCH, 1)
|
||||
L.reagents.expose(L, TOUCH, 1)
|
||||
|
||||
// TODO maybe add some colorful vomit?
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
else if(can_use(user) && !L)
|
||||
user.visible_message("<span class='suicide'>[user] is spraying toner on [user.p_them()]self from [src]! It looks like [user.p_theyre()] trying to commit suicide.</span>")
|
||||
user.reagents.add_reagent(/datum/reagent/colorful_reagent, 1)
|
||||
user.reagents.reaction(user, TOUCH, 1)
|
||||
user.reagents.expose(user, TOUCH, 1)
|
||||
return TOXLOSS
|
||||
|
||||
else
|
||||
|
||||
@@ -249,7 +249,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
if (smoke_all)
|
||||
to_smoke = reagents.total_volume/((smoketime * 2) / (dragtime / 10))
|
||||
|
||||
reagents.reaction(C, INGEST, fraction)
|
||||
reagents.expose(C, INGEST, fraction)
|
||||
var/obj/item/organ/lungs/L = C.getorganslot(ORGAN_SLOT_LUNGS)
|
||||
if(L && !(L.organ_flags & ORGAN_SYNTHETIC))
|
||||
C.adjustOrganLoss(ORGAN_SLOT_LUNGS, lung_harm)
|
||||
@@ -934,7 +934,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
var/mob/living/carbon/C = loc
|
||||
if (src == C.wear_mask) // if it's in the human/monkey mouth, transfer reagents to the mob
|
||||
var/fraction = min(REAGENTS_METABOLISM/reagents.total_volume, 1) //this will react instantly, making them a little more dangerous than cigarettes
|
||||
reagents.reaction(C, INGEST, fraction)
|
||||
reagents.expose(C, INGEST, fraction)
|
||||
if(!reagents.trans_to(C, REAGENTS_METABOLISM))
|
||||
reagents.remove_any(REAGENTS_METABOLISM)
|
||||
if(reagents.get_reagent_amount(/datum/reagent/fuel))
|
||||
|
||||
@@ -425,7 +425,7 @@
|
||||
if(affected_turfs.len)
|
||||
fraction /= affected_turfs.len
|
||||
for(var/t in affected_turfs)
|
||||
reagents.reaction(t, TOUCH, fraction * volume_multiplier)
|
||||
reagents.expose(t, TOUCH, fraction * volume_multiplier)
|
||||
reagents.trans_to(t, ., volume_multiplier, transfered_by = user)
|
||||
check_empty(user)
|
||||
|
||||
@@ -446,7 +446,7 @@
|
||||
if(check_empty(user)) //Prevents divsion by zero
|
||||
return
|
||||
var/fraction = min(eaten / reagents.total_volume, 1)
|
||||
reagents.reaction(M, INGEST, fraction * volume_multiplier)
|
||||
reagents.expose(M, INGEST, fraction * volume_multiplier)
|
||||
reagents.trans_to(M, eaten, volume_multiplier, transfered_by = user)
|
||||
// check_empty() is called during afterattack
|
||||
else
|
||||
@@ -669,7 +669,7 @@
|
||||
H.update_body()
|
||||
var/used = use_charges(user, 10, FALSE)
|
||||
var/fraction = min(1, used / reagents.maximum_volume)
|
||||
reagents.reaction(user, VAPOR, fraction * volume_multiplier)
|
||||
reagents.expose(user, VAPOR, fraction * volume_multiplier)
|
||||
reagents.trans_to(user, used, volume_multiplier, transfered_by = user)
|
||||
|
||||
return (OXYLOSS)
|
||||
@@ -725,7 +725,7 @@
|
||||
|
||||
. = use_charges(user, 10, FALSE)
|
||||
var/fraction = min(1, . / reagents.maximum_volume)
|
||||
reagents.reaction(C, VAPOR, fraction * volume_multiplier)
|
||||
reagents.expose(C, VAPOR, fraction * volume_multiplier)
|
||||
|
||||
return
|
||||
|
||||
@@ -745,7 +745,7 @@
|
||||
|
||||
. = use_charges(user, 2)
|
||||
var/fraction = min(1, . / reagents.maximum_volume)
|
||||
reagents.reaction(target, TOUCH, fraction * volume_multiplier)
|
||||
reagents.expose(target, TOUCH, fraction * volume_multiplier)
|
||||
reagents.trans_to(target, ., volume_multiplier, transfered_by = user)
|
||||
|
||||
if(pre_noise || post_noise)
|
||||
|
||||
@@ -192,9 +192,9 @@
|
||||
step_towards(W,my_target)
|
||||
if(!W.reagents)
|
||||
continue
|
||||
W.reagents.reaction(get_turf(W))
|
||||
W.reagents.expose(get_turf(W))
|
||||
for(var/A in get_turf(W))
|
||||
W.reagents.reaction(A)
|
||||
W.reagents.expose(A)
|
||||
if(W.loc == my_target)
|
||||
particles -= W
|
||||
if(repetition < power)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
var/obj/effect/decal/cleanable/C = O
|
||||
cleaner?.mind.adjust_experience(/datum/skill/cleaning, max(round(C.beauty/CLEAN_SKILL_BEAUTY_ADJUSTMENT,1),0)) //it is intentional that the mop rounds xp but soap does not, USE THE SACRED TOOL
|
||||
qdel(O)
|
||||
reagents.reaction(A, TOUCH, 10) //Needed for proper floor wetting.
|
||||
reagents.expose(A, TOUCH, 10) //Needed for proper floor wetting.
|
||||
var/val2remove = 1
|
||||
if(cleaner?.mind)
|
||||
val2remove = round(cleaner.mind.get_skill_modifier(/datum/skill/cleaning, SKILL_SPEED_MODIFIER),0.1)
|
||||
|
||||
@@ -410,7 +410,7 @@
|
||||
return
|
||||
|
||||
var/used_amount = injection_amount/usage_ratio
|
||||
reagents.reaction(user, INJECT,injection_amount,0)
|
||||
reagents.expose(user, INJECT,injection_amount,0)
|
||||
reagents.trans_to(user,used_amount,multiplier=usage_ratio)
|
||||
update_icon()
|
||||
user.update_inv_back() //for overlays update
|
||||
|
||||
@@ -101,9 +101,9 @@
|
||||
else
|
||||
T = get_turf(src)
|
||||
T.visible_message("<span class='danger'>[src] bursts!</span>","<span class='hear'>You hear a pop and a splash.</span>")
|
||||
reagents.reaction(T)
|
||||
reagents.expose(T)
|
||||
for(var/atom/A in T)
|
||||
reagents.reaction(A)
|
||||
reagents.expose(A)
|
||||
icon_state = "burst"
|
||||
qdel(src)
|
||||
|
||||
|
||||
@@ -343,3 +343,13 @@
|
||||
. += GLOB.acid_overlay
|
||||
if(resistance_flags & ON_FIRE)
|
||||
. += GLOB.fire_overlay
|
||||
|
||||
/// Handles exposing an object to reagents.
|
||||
/obj/expose_reagents(list/reagents, datum/reagents/source, method=TOUCH, volume_modifier=1, show_message=TRUE)
|
||||
. = ..()
|
||||
if(. & COMPONENT_NO_EXPOSE_REAGENTS)
|
||||
return
|
||||
|
||||
for(var/reagent in reagents)
|
||||
var/datum/reagent/R = reagent
|
||||
R.expose_obj(src, reagents[R] || (R.volume * volume_modifier))
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
user.visible_message("<span class='notice'>[user] begins to empty the contents of [src].</span>", "<span class='notice'>You begin to empty the contents of [src]...</span>")
|
||||
if(I.use_tool(src, user, 30))
|
||||
to_chat(usr, "<span class='notice'>You empty the contents of [src]'s bucket onto the floor.</span>")
|
||||
reagents.reaction(src.loc)
|
||||
reagents.expose(src.loc)
|
||||
src.reagents.clear_reagents()
|
||||
else
|
||||
return ..()
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
/obj/machinery/shower/proc/wash_atom(atom/A)
|
||||
A.washed(src)
|
||||
reagents.reaction(A, TOUCH, reaction_volume)
|
||||
reagents.expose(A, TOUCH, reaction_volume)
|
||||
|
||||
if(isliving(A))
|
||||
check_heat(A)
|
||||
|
||||
@@ -359,7 +359,7 @@
|
||||
O.acid_level = 0
|
||||
create_reagents(5)
|
||||
reagents.add_reagent(dispensedreagent, 5)
|
||||
reagents.reaction(O, TOUCH)
|
||||
reagents.expose(O, TOUCH)
|
||||
user.visible_message("<span class='notice'>[user] washes [O] using [src].</span>", \
|
||||
"<span class='notice'>You wash [O] using [src].</span>")
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user