mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-28 06:28:01 +01:00
Allows reactions to happen with any level of the required chems
Rather than an arbitrary 1u cutoff below which reactions will not happen, reactions will now happen at whatever level of chems are present.
This commit is contained in:
@@ -6,14 +6,14 @@
|
||||
var/reacting = 0 // Reacting right now
|
||||
|
||||
/datum/reagents/New(var/max = 100)
|
||||
maximum_volume = max
|
||||
maximum_volume = max
|
||||
//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
|
||||
var/paths = typesof(/datum/reagent) - /datum/reagent
|
||||
chemical_reagents_list = list()
|
||||
for(var/path in paths)
|
||||
var/datum/reagent/D = new path()
|
||||
var/datum/reagent/D = new path()
|
||||
if(!D.name)
|
||||
continue
|
||||
chemical_reagents_list[D.id] = D
|
||||
@@ -40,16 +40,16 @@
|
||||
for(var/id in reaction_ids)
|
||||
if(!chemical_reactions_list[id])
|
||||
chemical_reactions_list[id] = list()
|
||||
chemical_reactions_list[id] += D
|
||||
break // Don't bother adding ourselves to other reagent ids, it is redundant.
|
||||
|
||||
/datum/reagents/Destroy()
|
||||
..()
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
qdel(R)
|
||||
reagent_list.Cut()
|
||||
reagent_list = null
|
||||
if(my_atom && my_atom.reagents == src)
|
||||
chemical_reactions_list[id] += D
|
||||
break // Don't bother adding ourselves to other reagent ids, it is redundant.
|
||||
|
||||
/datum/reagents/Destroy()
|
||||
..()
|
||||
for(var/datum/reagent/R in reagent_list)
|
||||
qdel(R)
|
||||
reagent_list.Cut()
|
||||
reagent_list = null
|
||||
if(my_atom && my_atom.reagents == src)
|
||||
my_atom.reagents = null
|
||||
|
||||
/* Internal procs */
|
||||
@@ -116,7 +116,7 @@
|
||||
for(var/datum/chemical_reaction/C in chemical_reactions_list[R.id])
|
||||
var/reagents_suitable = 1
|
||||
for(var/B in C.required_reagents)
|
||||
if(!has_reagent(B, C.required_reagents[B]))
|
||||
if(!has_reagent(B))
|
||||
reagents_suitable = 0
|
||||
for(var/B in C.catalysts)
|
||||
if(!has_reagent(B, C.catalysts[B]))
|
||||
@@ -169,7 +169,7 @@
|
||||
if(!isnull(data)) // For all we know, it could be zero or empty string and meaningful
|
||||
current.mix_data(data, amount)
|
||||
update_total()
|
||||
if(!safety)
|
||||
if(!safety)
|
||||
handle_reactions()
|
||||
if(my_atom)
|
||||
my_atom.on_reagent_change()
|
||||
@@ -183,7 +183,7 @@
|
||||
R.initialize_data(data)
|
||||
update_total()
|
||||
if(!safety)
|
||||
handle_reactions()
|
||||
handle_reactions()
|
||||
if(my_atom)
|
||||
my_atom.on_reagent_change()
|
||||
return 1
|
||||
@@ -218,7 +218,7 @@
|
||||
/datum/reagents/proc/has_reagent(var/id, var/amount = 0)
|
||||
for(var/datum/reagent/current in reagent_list)
|
||||
if(current.id == id)
|
||||
if(current.volume >= amount)
|
||||
if(current.volume >= amount)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
@@ -234,12 +234,12 @@
|
||||
if(current.id == id)
|
||||
return current.volume
|
||||
return 0
|
||||
|
||||
|
||||
/datum/reagents/proc/get_data(var/id)
|
||||
for(var/datum/reagent/current in reagent_list)
|
||||
if(current.id == id)
|
||||
return current.get_data()
|
||||
return 0
|
||||
return 0
|
||||
|
||||
/datum/reagents/proc/get_reagents()
|
||||
var/res = ""
|
||||
@@ -255,14 +255,14 @@
|
||||
amount = min(amount, total_volume)
|
||||
|
||||
if(!amount)
|
||||
return
|
||||
return
|
||||
|
||||
var/part = amount / total_volume
|
||||
|
||||
|
||||
for(var/datum/reagent/current in reagent_list)
|
||||
var/amount_to_remove = current.volume * part
|
||||
remove_reagent(current.id, amount_to_remove, 1)
|
||||
|
||||
|
||||
update_total()
|
||||
handle_reactions()
|
||||
return amount
|
||||
@@ -431,6 +431,6 @@
|
||||
|
||||
/* Atom reagent creation - use it all the time */
|
||||
|
||||
/atom/proc/create_reagents(var/max_vol)
|
||||
/atom/proc/create_reagents(var/max_vol)
|
||||
reagents = new/datum/reagents(max_vol)
|
||||
reagents.my_atom = src
|
||||
reagents.my_atom = src
|
||||
|
||||
Reference in New Issue
Block a user