Natural immunities (#9026)
This commit is contained in:
@@ -39,6 +39,7 @@ namespace Content.Server.Disease
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<DiseaseCarrierComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<DiseaseCarrierComponent, CureDiseaseAttemptEvent>(OnTryCureDisease);
|
||||
SubscribeLocalEvent<DiseasedComponent, InteractHandEvent>(OnInteractDiseasedHand);
|
||||
SubscribeLocalEvent<DiseasedComponent, InteractUsingEvent>(OnInteractDiseasedUsing);
|
||||
@@ -127,6 +128,25 @@ namespace Content.Server.Disease
|
||||
/// Event Handlers
|
||||
///
|
||||
|
||||
/// <summary>
|
||||
/// Fill in the natural immunities of this entity.
|
||||
/// </summary>
|
||||
private void OnInit(EntityUid uid, DiseaseCarrierComponent component, ComponentInit args)
|
||||
{
|
||||
if (component.NaturalImmunities == null || component.NaturalImmunities.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (var immunity in component.NaturalImmunities)
|
||||
{
|
||||
if (_prototypeManager.TryIndex<DiseasePrototype>(immunity, out var disease))
|
||||
component.PastDiseases.Add(disease);
|
||||
else
|
||||
{
|
||||
Logger.Error("Failed to index disease prototype + " + immunity + " for " + uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used when something is trying to cure ANY disease on the target,
|
||||
/// not for special disease interactions. Randomly
|
||||
|
||||
Reference in New Issue
Block a user