using Content.Server.Disease.Components; using JetBrains.Annotations; using Content.Shared.Disease; namespace Content.Server.Disease.Effects { /// /// Handles a disease which incubates over a period of time /// before adding another component to the infected entity /// currently used for zombie virus /// [UsedImplicitly] public sealed class DiseaseProgression : DiseaseEffect { /// /// The rate that's increased over time. Defaults to 1% so the probability can be varied in yaml /// [DataField("rate")] [ViewVariables(VVAccess.ReadWrite)] public float Rate = 0.01f; /// /// The component that is added at the end of build up /// [DataField("comp")] public string? Comp = null; public override void Effect(DiseaseEffectArgs args) { args.EntityManager.EnsureComponent(args.DiseasedEntity, out var buildup); if (buildup.Progression < 1) //increases steadily until 100% { buildup.Progression += Rate; } else if (Comp != null)//adds the component for the later stage of the disease. { EntityUid uid = args.DiseasedEntity; var newComponent = (Component) IoCManager.Resolve().GetComponent(Comp); newComponent.Owner = uid; if (!args.EntityManager.HasComponent(uid, newComponent.GetType())) args.EntityManager.AddComponent(uid, newComponent); } } } }