Moves metabolism to a holder subtype

This commit is contained in:
mwerezak
2015-06-13 18:37:51 -04:00
committed by HarpyEagle
parent 70433b4367
commit 73333ac9c8
8 changed files with 43 additions and 54 deletions

View File

@@ -1472,6 +1472,7 @@
#include "code\modules\reagents\Chemistry-Colours.dm"
#include "code\modules\reagents\Chemistry-Holder.dm"
#include "code\modules\reagents\Chemistry-Machinery.dm"
#include "code\modules\reagents\Chemistry-Metabolism.dm"
#include "code\modules\reagents\Chemistry-Readme.dm"
#include "code\modules\reagents\Chemistry-Reagents.dm"
#include "code\modules\reagents\Chemistry-Recipes.dm"

View File

@@ -108,12 +108,9 @@
chem_effects.Cut()
analgesic = 0
if(touching)
touching.metabolize(0, CHEM_TOUCH)
if(ingested)
ingested.metabolize(0, CHEM_INGEST)
if(reagents)
reagents.metabolize(0, CHEM_BLOOD)
if(touching) touching.metabolize()
if(ingested) ingested.metabolize()
if(bloodstr) bloodstr.metabolize()
if(CE_PAINKILLER in chem_effects)
analgesic = chem_effects[CE_PAINKILLER]

View File

@@ -1,11 +1,10 @@
/mob/living/carbon/New()
create_reagents(1000)
var/datum/reagents/R1 = new/datum/reagents(1000)
var/datum/reagents/R2 = new/datum/reagents(1000)
ingested = R1
touching = R2
R1.my_atom = src
R2.my_atom = src
//setup reagent holders
bloodstr = new/datum/reagents/metabolism(1000, src, CHEM_BLOOD)
ingested = new/datum/reagents/metabolism(1000, src, CHEM_INGEST)
touching = new/datum/reagents/metabolism(1000, src, CHEM_TOUCH)
reagents = bloodstr
..()
/mob/living/carbon/Life()

View File

@@ -18,7 +18,8 @@
//Active emote/pose
var/pose = null
var/list/chem_effects = list()
var/datum/reagents/ingested = null
var/datum/reagents/touching = null
var/datum/reagents/metabolism/bloodstr = null
var/datum/reagents/metabolism/ingested = null
var/datum/reagents/metabolism/touching = null
var/pulse = PULSE_NORM //current pulse level

View File

@@ -858,15 +858,14 @@
proc/handle_chemicals_in_body()
if(reagents && !(species.flags & IS_SYNTHETIC)) //Synths don't process reagents.
if(!(species.flags & IS_SYNTHETIC)) //Synths don't process reagents.
chem_effects.Cut()
analgesic = 0
var/alien = 0
if(species && species.reagent_tag)
alien = species.reagent_tag
touching.metabolize(alien, CHEM_TOUCH)
ingested.metabolize(alien, CHEM_INGEST)
reagents.metabolize(alien, CHEM_BLOOD)
if(touching) touching.metabolize()
if(ingested) ingested.metabolize()
if(bloodstr) bloodstr.metabolize()
if(CE_PAINKILLER in chem_effects)
analgesic = chem_effects[CE_PAINKILLER]

View File

@@ -85,12 +85,9 @@
chem_effects.Cut()
analgesic = 0
if(touching)
touching.metabolize(0, CHEM_TOUCH)
if(ingested)
ingested.metabolize(0, CHEM_INGEST)
if(reagents)
reagents.metabolize(0, CHEM_BLOOD)
if(touching) touching.metabolize()
if(ingested) ingested.metabolize()
if(bloodstr) bloodstr.metabolize()
if(CE_PAINKILLER in chem_effects)
analgesic = chem_effects[CE_PAINKILLER]

View File

@@ -4,8 +4,10 @@
var/maximum_volume = 100
var/atom/my_atom = null
/datum/reagents/New(var/max = 100)
maximum_volume = max
/datum/reagents/New(var/max = 100, atom/A = null)
maximum_volume = max
my_atom = A
//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
@@ -414,18 +416,7 @@
return trans_to_holder(target.reagents, amount, multiplier, copy)
/datum/reagents/proc/metabolize(var/alien, var/location)
if(!iscarbon(my_atom))
return
var/mob/living/carbon/C = my_atom
if(!C || !istype(C))
return
for(var/datum/reagent/current in reagent_list)
current.on_mob_life(C, alien, location)
update_total()
/* Atom reagent creation - use it all the time */
/atom/proc/create_reagents(var/max_vol)
reagents = new/datum/reagents(max_vol)
reagents.my_atom = src
reagents = new/datum/reagents(max_vol, src)

View File

@@ -1,17 +1,21 @@
/datum/reagents/metabolism
var/metabolism_type
var/metabolism_class //CHEM_TOUCH, CHEM_INGEST, or CHEM_BLOOD
var/mob/living/carbon/parent
/datum/reagents/metabolism/New(var/max = 100, var/met_type, mob/living/carbon/parent_mob)
..()
metabolism_type = met_type
my_atom = parent_mob
/datum/reagents/metabolism/New(var/max = 100, mob/living/carbon/parent_mob, var/met_class)
..(max, parent_mob)
metabolism_class = met_class
if(istype(parent_mob))
parent = parent_mob
/datum/reagents/proc/metabolize(var/alien)
if(!iscarbon(my_atom))
return
var/mob/living/carbon/C = my_atom
if(!C || !istype(C))
return
/datum/reagents/metabolism/proc/metabolize()
var/metabolism_type = 0 //non-human mobs
if(ishuman(parent))
var/mob/living/carbon/human/H = parent
metabolism_type = H.species.reagent_tag
for(var/datum/reagent/current in reagent_list)
current.on_mob_life(C, alien, metabolism_type)
current.on_mob_life(parent, metabolism_type, metabolism_class)
update_total()