Skip to content

Consumables (pills) Treatment

Vadim Gromov edited this page Jan 5, 2021 · 8 revisions

Treatment with single type of medical consumables

To describe disease treatment by a single type of "pills" (like OseltamivirGroup), ConsumableTimedTreatment class is used. More on consumable groups here.
It takes level of seriousness that is treated by this instance, medical consumables group (see Inventory Engine), timing and count from a constructor. If consumable should be taken only once, you can omit two last parameters. For example:

_progressingStageTreatment = new ConsumableTimedTreatment(DiseaseLevels.Progressing, MedicalConsumablesGroup.OseltamivirGroup, 60, 3);

This code example means that to treat this stage, player needs to consume anything from OseltamivirGroup every 60 game minutes (plus-minus 20 minutes margin) 3 times.

Treatment with multiple types of medical consumables

To describe treatment that includes mix of a different types of "pills", ConsumableTimedTreatmentNode class is used. This class takes level of seriousness that is treated by this instance, and an array of ConsumableTimedTreatment instances in a constructor, and will declare disease as healed only if all of ConsumableTimedTreatment rules are satisfied.
Notice that for ConsumableTimedTreatment in this case level of seriousness is not passed, all ConsumableTimedTreatment instances will inherit it from parent ConsumableTimedTreatmentNode. For example, this code describes treatment with OseltamivirGroup and AntibioticsGroup items the a same time:

_worryingStageTreatment = new ConsumableTimedTreatmentNode(DiseaseLevels.Worrying,
    new ConsumableTimedTreatment(MedicalConsumablesGroup.OseltamivirGroup, 90, 3),
    new ConsumableTimedTreatment(MedicalConsumablesGroup.AntibioticGroup, 80, 4)
);

This code example means that to treat this stage, player needs to consume anything from OseltamivirGroup every 90 minutes 3 times AND anything from AntibioticGroup every 80 minutes 4 times.

No matter, what class will you use, you should pass its OnItemConsumed method to a WithConsumable method of a Treatment fluent node.

.Treatment
    .WithConsumable(_worryingStageTreatment.OnItemConsumed)
...

Then on OnResumeDisease override method of your disease class you should reset all the treatment nodes:

public override void OnResumeDisease()
{
    _initialStageTreatment.Reset();
    _progressingStageTreatment.Reset();
    _worryingStageTreatment.Reset();
    _criticalingStageTreatment.Reset();
...

And on Check override method you should call Check method of all your treatment nodes:

public override void Check(ActiveDisease disease, IGameController gc)
{
    _initialStageTreatment.Check(disease, gc);
    _progressingStageTreatment.Check(disease, gc);
    _worryingStageTreatment.Check(disease, gc);
    _criticalingStageTreatment.Check(disease, gc);
...
Clone this wiki locally