From ea8080e6c9af2c5cdd971505d4884a3a63c05f7b Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Sat, 14 Jan 2017 20:09:49 -0500 Subject: [PATCH] Makes Reagents Holder Process and Refactors NOREACT --- code/__DEFINES/flags.dm | 4 +-- .../mecha/equipment/tools/medical_tools.dm | 5 ++-- code/game/objects/items/weapons/cigs.dm | 8 +++--- .../objects/items/weapons/storage/fancy.dm | 2 +- .../kitchen_machinery/kitchen_machine.dm | 3 ++- .../kitchen_machinery/smartfridge.dm | 3 ++- code/modules/lighting/lighting_overlay.dm | 1 - .../projectiles/ammunition/ammo_casings.dm | 2 +- code/modules/projectiles/guns/dartgun.dm | 2 +- .../modules/projectiles/projectile/bullets.dm | 4 +-- code/modules/reagents/chemistry/holder.dm | 27 ++++++++++++++----- code/modules/reagents/reagent_containers.dm | 6 ----- .../reagent_containers/glass_containers.dm | 6 ++++- 13 files changed, 45 insertions(+), 28 deletions(-) diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm index aaf98516fa8..3da3a2874ed 100644 --- a/code/__DEFINES/flags.dm +++ b/code/__DEFINES/flags.dm @@ -24,8 +24,8 @@ #define BLOCK_GAS_SMOKE_EFFECT 8192 // blocks the effect that chemical clouds would have on a mob --glasses, mask and helmets ONLY! #define THICKMATERIAL 8192 //prevents syringes, parapens and hypos if the external suit or helmet (if targeting head) has this flag. Example: space suits, biosuit, bombsuits, thick suits that cover your body. (NOTE: flag shared with BLOCK_GAS_SMOKE_EFFECT) - -#define NOREACT 16384 //Reagents dont' react inside this container. +//Reagent flags +#define REAGENT_NOREACT 1 //Species flags. diff --git a/code/game/mecha/equipment/tools/medical_tools.dm b/code/game/mecha/equipment/tools/medical_tools.dm index d95570cf88f..13602957de1 100644 --- a/code/game/mecha/equipment/tools/medical_tools.dm +++ b/code/game/mecha/equipment/tools/medical_tools.dm @@ -243,7 +243,6 @@ desc = "Equipment for medical exosuits. A chem synthesizer with syringe gun. Reagents inside are held in stasis, so no reactions will occur." icon = 'icons/obj/guns/projectile.dmi' icon_state = "syringegun" - flags = NOREACT var/list/syringes var/list/known_reagents var/list/processed_reagents @@ -259,6 +258,7 @@ /obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/New() ..() create_reagents(max_volume) + reagents.set_reacting(FALSE) syringes = new known_reagents = list("epinephrine"="Epinephrine","charcoal"="Charcoal") processed_reagents = new @@ -273,7 +273,8 @@ /obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/critfail() ..() - flags &= ~NOREACT + if(reagents) + reagents.set_reacting(TRUE) /obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/can_attach(obj/mecha/medical/M) if(..()) diff --git a/code/game/objects/items/weapons/cigs.dm b/code/game/objects/items/weapons/cigs.dm index 8449e17a9db..26bb243f0d1 100644 --- a/code/game/objects/items/weapons/cigs.dm +++ b/code/game/objects/items/weapons/cigs.dm @@ -42,11 +42,13 @@ LIGHTERS ARE IN LIGHTERS.DM /obj/item/clothing/mask/cigarette/New() ..() - flags |= NOREACT // so it doesn't react until you light it create_reagents(chem_volume) // making the cigarrete a chemical holder with a maximum volume of 30 + reagents.set_reacting(FALSE) // so it doesn't react until you light it /obj/item/clothing/mask/cigarette/Destroy() - qdel(reagents) + if(reagents) + qdel(reagents) + processing_objects -= src return ..() /obj/item/clothing/mask/cigarette/attack(var/mob/living/M, var/mob/living/user, def_zone) @@ -135,7 +137,7 @@ LIGHTERS ARE IN LIGHTERS.DM M.unEquip(src, 1) qdel(src) return - flags &= ~NOREACT // allowing reagents to react after being lit + reagents.set_reacting(TRUE) reagents.handle_reactions() icon_state = icon_on item_state = icon_on diff --git a/code/game/objects/items/weapons/storage/fancy.dm b/code/game/objects/items/weapons/storage/fancy.dm index 1d8990875a4..9a9cf319319 100644 --- a/code/game/objects/items/weapons/storage/fancy.dm +++ b/code/game/objects/items/weapons/storage/fancy.dm @@ -176,8 +176,8 @@ /obj/item/weapon/storage/fancy/cigarettes/New() ..() - flags |= NOREACT create_reagents(30 * storage_slots)//so people can inject cigarettes without opening a packet, now with being able to inject the whole one + reagents.set_reacting(FALSE) for(var/i = 1 to storage_slots) var/obj/item/clothing/mask/cigarette/C = new cigarette_type(src) unlaced_cigarettes += C diff --git a/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm b/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm index ef7591e3955..54f3bc739ab 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/kitchen_machine.dm @@ -8,7 +8,7 @@ use_power = 1 idle_power_usage = 5 active_power_usage = 100 - flags = OPENCONTAINER | NOREACT + flags = OPENCONTAINER var/operating = 0 // Is it on? var/dirty = 0 // = {0..100} Does it need cleaning? var/broken = 0 // ={0,1,2} How broken is it??? @@ -33,6 +33,7 @@ /obj/machinery/kitchen_machine/New() create_reagents(100) + reagents.set_reacting(FALSE) if(!available_recipes) available_recipes = new acceptable_items = new diff --git a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm index 149744675a9..6760edca407 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/smartfridge.dm @@ -10,7 +10,6 @@ use_power = 1 idle_power_usage = 5 active_power_usage = 100 - flags = NOREACT var/max_n_of_items = 1500 var/icon_on = "smartfridge" var/icon_off = "smartfridge-off" @@ -25,6 +24,8 @@ /obj/machinery/smartfridge/New() ..() + create_reagents() + reagents.set_reacting(FALSE) component_parts = list() var/obj/item/weapon/circuitboard/smartfridge/board = new(null) board.set_type(type) diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm index 525de63a0af..24854085c1a 100644 --- a/code/modules/lighting/lighting_overlay.dm +++ b/code/modules/lighting/lighting_overlay.dm @@ -3,7 +3,6 @@ mouse_opacity = 0 simulated = 0 anchored = 1 - flags = NOREACT icon = LIGHTING_ICON layer = LIGHTING_LAYER invisibility = INVISIBILITY_LIGHTING diff --git a/code/modules/projectiles/ammunition/ammo_casings.dm b/code/modules/projectiles/ammunition/ammo_casings.dm index df34a279caf..45e53a89f83 100644 --- a/code/modules/projectiles/ammunition/ammo_casings.dm +++ b/code/modules/projectiles/ammunition/ammo_casings.dm @@ -233,9 +233,9 @@ /obj/item/ammo_casing/shotgun/dart/New() ..() - flags |= NOREACT flags |= OPENCONTAINER create_reagents(30) + reagents.set_reacting(FALSE) /obj/item/ammo_casing/shotgun/dart/attackby() return diff --git a/code/modules/projectiles/guns/dartgun.dm b/code/modules/projectiles/guns/dartgun.dm index b8f659eb09f..3a6dd8feded 100644 --- a/code/modules/projectiles/guns/dartgun.dm +++ b/code/modules/projectiles/guns/dartgun.dm @@ -154,7 +154,7 @@ qdel(S) D.icon_state = "syringeproj" D.name = "syringe" - D.flags |= NOREACT + D.reagents.set_reacting(FALSE) playsound(user.loc, 'sound/items/syringeproj.ogg', 50, 1) for(var/i=0, i<6, i++) diff --git a/code/modules/projectiles/projectile/bullets.dm b/code/modules/projectiles/projectile/bullets.dm index 9c3475d2141..68fc1a1744a 100644 --- a/code/modules/projectiles/projectile/bullets.dm +++ b/code/modules/projectiles/projectile/bullets.dm @@ -234,8 +234,8 @@ /obj/item/projectile/bullet/dart/New() ..() - flags |= NOREACT create_reagents(50) + reagents.set_reacting(FALSE) /obj/item/projectile/bullet/dart/on_hit(var/atom/target, var/blocked = 0, var/hit_zone) if(iscarbon(target)) @@ -251,7 +251,7 @@ target.visible_message("The [name] was deflected!", \ "You were protected against the [name]!") ..(target, blocked, hit_zone) - flags &= ~NOREACT + reagents.set_reacting(TRUE) reagents.handle_reactions() return 1 diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 9c0c14014e4..c9a05f263a2 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -13,10 +13,12 @@ var/const/INGEST = 2 var/atom/my_atom = null var/chem_temp = 300 var/list/datum/reagent/addiction_list = new/list() + var/flags -/datum/reagents/New(maximum=100) +/datum/reagents/New(maximum = 100) maximum_volume = maximum - + if(!(flags & REAGENT_NOREACT)) + processing_objects |= src //I dislike having these here but map-objects are initialised before world/New() is called. >_> if(!chemical_reagents_list) //Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id @@ -288,11 +290,24 @@ var/const/INGEST = 2 od_chems.Add(R.id) return od_chems +/datum/reagents/proc/process() + if(flags & REAGENT_NOREACT) + processing_objects -= src + return -/datum/reagents/proc/reagent_on_tick() for(var/datum/reagent/R in reagent_list) R.on_tick() - return + +/datum/reagents/proc/set_reacting(react = TRUE) + if(react) + // Order is important, process() can remove from processing if + // the flag is present + flags &= ~(REAGENT_NOREACT) + processing_objects |= src + else + processing_objects -= src + flags |= REAGENT_NOREACT + /* if(!target) return var/total_transfered = 0 @@ -337,7 +352,7 @@ var/const/INGEST = 2 update_total() /datum/reagents/proc/handle_reactions() - if(my_atom.flags & NOREACT) + if(flags & REAGENT_NOREACT) return //Yup, no reactions here. No siree. var/reaction_occured = 0 @@ -721,7 +736,7 @@ atom/proc/create_reagents(max_vol) /datum/reagents/Destroy() . = ..() - processing_objects.Remove(src) + processing_objects -= src for(var/datum/reagent/R in reagent_list) qdel(R) reagent_list.Cut() diff --git a/code/modules/reagents/reagent_containers.dm b/code/modules/reagents/reagent_containers.dm index f46d4010e69..727574fed16 100644 --- a/code/modules/reagents/reagent_containers.dm +++ b/code/modules/reagents/reagent_containers.dm @@ -30,7 +30,6 @@ if(!possible_transfer_amounts) verbs -= /obj/item/weapon/reagent_containers/verb/set_APTFT create_reagents(volume) - processing_objects.Add(src) if(spawned_disease) var/datum/disease/F = new spawned_disease(0) var/list/data = list("viruses" = list(F), "blood_colour" = "#A10808") @@ -38,11 +37,6 @@ if(list_reagents) reagents.add_reagent_list(list_reagents) -/obj/item/weapon/reagent_containers/process() - if(reagents) - reagents.reagent_on_tick() - return - /obj/item/weapon/reagent_containers/ex_act() if(reagents) for(var/datum/reagent/R in reagents.reagent_list) diff --git a/code/modules/reagents/reagent_containers/glass_containers.dm b/code/modules/reagents/reagent_containers/glass_containers.dm index 60c924e0515..73b297d3e59 100644 --- a/code/modules/reagents/reagent_containers/glass_containers.dm +++ b/code/modules/reagents/reagent_containers/glass_containers.dm @@ -290,7 +290,11 @@ materials = list(MAT_GLASS=500) volume = 50 amount_per_transfer_from_this = 10 - flags = OPENCONTAINER | NOREACT + flags = OPENCONTAINER + +/obj/item/weapon/reagent_containers/glass/beaker/noreact/New() + ..() + reagents.set_reacting(FALSE) /obj/item/weapon/reagent_containers/glass/beaker/bluespace name = "bluespace beaker"