Skip to content

How To Spawn a Disease

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

All _gc references in these examples are instances of a IGameController

More about diseases here

To spawn any disease, you need to call

var disease = new ZaraEngine.Diseases.Flu(); // any disease that is a descendant of the DiseaseDefinitionBase
var timeWhenBecomeActive = _gc.WorldTime.Value;

_gc.Health.Status.ActiveDiseases.Add(new ZaraEngine.Diseases.ActiveDisease(_gc, disease, timeWhenBecomeActive));

If disease requires a bodypart to be present (RequiresBodyPart=true), you need to create ActiveInjury as well and link them:

var disease = new ZaraEngine.Diseases.VenomPoisoning();
var timeWhenBecomeActive = _gc.WorldTime.Value;
var injuryThatCausedDesease = new ZaraEngine.Injuries.ActiveInjury(_gc, typeof(ZaraEngine.Injuries.LightCut), BodyParts.LeftForearm, timeWhenBecomeActive);

_gc.Health.Status.ActiveDiseases.Add(new ZaraEngine.Diseases.ActiveDisease(_gc, disease, timeWhenBecomeActive));

// Don't forget to add this injury to your health state as well
_gc.Hhealth.Status.ActiveInjuries.Add(injuryThatCausedDesease);
Clone this wiki locally