Skip to content

Diseases

Vadim Gromov edited this page Dec 30, 2020 · 5 revisions

Current player diseases are available via Status.ActiveDiseases property of HealthController. To check if disease is active right now, call

Status.HasActive<T>
i.e.
Status.HasActive<Flu>

To check if disease is active or will be activated later, call

Status.HasActiveOrScheduled<T>
i.e.
Status.HasActiveOrScheduled<Flu>

To get active disease (will return ActiveDisease instance if found), call GetActive or to get disease that is active now or will be activated later, call GetActiveOrScheduled method.

All diseases are descendants from DiseaseDefinitionBase abstract class. All diseases are declared in ZaraEngine.Diseases namespace.

Every disease can contain up to 4 disease stages. Each stage is described by DiseaseStage class. StageBuilder class can be used to describe each disease stage in an easy way by using fluent syntax.
Every disease stage describes its healing procedures via Treatment fluent node and according Actions. Treatment can be described with consumables (such as pills or any food), or with appliance (such as injections or suction pump).

To read general info about how disease treatment works, see here.

Every disease has the following virtual methods:

Currently active disease is represented by ActiveDisease class. This class contains disease object itself and a time when this disease is starting to be active, so we can schedule any disease by creating ActiveDisease with a time greater than the current game time. ActiveDisease class also contains methods to invert stages chain and invert them back. Treatment actions from Treatment fluent node have access to ActiveDisease object, so chain inversion and dis-inversion can be done within those Actions.
If disease healing is started, TreatedStage property of ActiveDisease class will contain DiseaseStage that is currently being treated. If disease treatment fails or no treatment is going on, TreatedStage property will be null. If disease treatment is over, IsTreated property will be set to true. Any disease stage can have SelfHealChance. In this case (if chance of self-heal is happened -- see Probabilities) disease will disappear after this stage regardless of presence of another stages.

Player can have more than one disease. In this case, disease effects are being combined.

If you implementing some custom treatment logic, without using ConsumableTimedTreatment, ApplianceTimedTreatment, ApplianceTimedTreatmentNode or ConsumableTimedTreatmentNode, be sure to call ActiveDisease.DeclareDiseaseTreated method when the treatment is finished.

If disease should be treated with appliances, disease Stages must be initialized in override InitializeWithInjury method, not in constructor. In a constructor in this case must be initialized two properties: Name of a disease and RequiresBodyPart = true.

public VenomPoisoning()
{
    Name = "VenomPoisoning";
    RequiresBodyPart = true;
}
...
public override void InitializeWithInjury(BodyParts initialInjury)
{
    BodyPart = initialInjury;

    // Describe treatment for each stage
    _progressingStageTreatment = new ApplianceTimedTreatmentNode(DiseaseLevels.Progressing,
        new ApplianceTimedTreatment(initialInjury, InventoryController.MedicalItems.SuctionPump),
        new ApplianceTimedTreatment(null, InventoryController.MedicalItems.AntiVenomSyringe)
    );
    _worryingStageTreatment = new ApplianceTimedTreatmentNode(DiseaseLevels.Worrying,
        new ApplianceTimedTreatment(initialInjury, InventoryController.MedicalItems.SuctionPump),
        new ApplianceTimedTreatment(null, InventoryController.MedicalItems.AntiVenomSyringe, 60, 2)
    );
    _criticalingStageTreatment = new ApplianceTimedTreatmentNode(DiseaseLevels.Critical,
        new ApplianceTimedTreatment(initialInjury, InventoryController.MedicalItems.SuctionPump),
        new ApplianceTimedTreatment(null, InventoryController.MedicalItems.AntiVenomSyringe, 60, 3)
    );

            
    Stages = new List<DiseaseStage>(new[]
...

If disease should be treated with consumables, Stages must be initialized in a constructor, as well as Name.

public Flu()
{
    // Describe treatment for each stage
    _initialStageTreatment = new ConsumableTimedTreatment(DiseaseLevels.InitialStage, MedicalConsumablesGroup.OseltamivirGroup);
    _progressingStageTreatment = new ConsumableTimedTreatment(DiseaseLevels.Progressing, MedicalConsumablesGroup.OseltamivirGroup, 60, 3);
    _worryingStageTreatment = new ConsumableTimedTreatmentNode(DiseaseLevels.Worrying,
        new ConsumableTimedTreatment(MedicalConsumablesGroup.OseltamivirGroup, 90, 3),
        new ConsumableTimedTreatment(MedicalConsumablesGroup.AntibioticGroup, 90, 3)
    );
    _criticalingStageTreatment = new ConsumableTimedTreatmentNode(DiseaseLevels.Critical,
        new ConsumableTimedTreatment(MedicalConsumablesGroup.OseltamivirGroup, 90, 4),
        new ConsumableTimedTreatment(MedicalConsumablesGroup.AntibioticGroup, 90, 4)
    );

    Name = "Flu";
    Stages = new List<DiseaseStage>(new[]
...
Clone this wiki locally