/// <summary> /// When activated, blasts everyone in LOS within n tiles /// with a high-probability disease infection attempt /// </summary> private void OnActivate(EntityUid uid, DiseaseArtifactComponent component, ArtifactActivatedEvent args) { if (component.SpawnDisease == null) { return; } var xform = Transform(uid); var carrierQuery = GetEntityQuery <DiseaseCarrierComponent>(); foreach (var entity in _lookup.GetEntitiesInRange(xform.Coordinates, component.Range)) { if (!carrierQuery.TryGetComponent(entity, out var carrier)) { continue; } if (!_interactionSystem.InRangeUnobstructed(uid, entity, component.Range)) { continue; } _disease.TryInfect(carrier, component.SpawnDisease, forced: true); } }
/// <summary> /// Makes sure this artifact is assigned a disease /// </summary> private void OnMapInit(EntityUid uid, DiseaseArtifactComponent component, MapInitEvent args) { if (component.SpawnDisease == string.Empty && component.ArtifactDiseases.Count != 0) { var diseaseName = _random.Pick(component.ArtifactDiseases); component.SpawnDisease = diseaseName; } if (_prototypeManager.TryIndex(component.SpawnDisease, out DiseasePrototype? disease) && disease != null) { component.ResolveDisease = disease; } }
/// <summary> /// Makes sure this artifact is assigned a disease /// </summary> private void OnMapInit(EntityUid uid, DiseaseArtifactComponent component, MapInitEvent args) { if (component.SpawnDisease != null || ArtifactDiseases.Count == 0) { return; } var diseaseName = _random.Pick(ArtifactDiseases); if (!_prototypeManager.TryIndex <DiseasePrototype>(diseaseName, out var disease)) { Logger.ErrorS("disease", $"Invalid disease {diseaseName} selected from random diseases."); return; } component.SpawnDisease = disease; }
/// <summary> /// When activated, blasts everyone in LOS within 3 tiles /// with a high-probability disease infection attempt /// </summary> private void OnActivate(EntityUid uid, DiseaseArtifactComponent component, ArtifactActivatedEvent args) { var xform = Transform(uid); foreach (var entity in _lookup.GetEntitiesInRange(xform.MapID, xform.WorldPosition, 3f)) { if (!_interactionSystem.InRangeUnobstructed(uid, entity, 3f)) { continue; } if (TryComp <DiseaseCarrierComponent>(entity, out var carrier)) { EntitySystem.Get <DiseaseSystem>().TryInfect(carrier, component.ResolveDisease); } } }