Files
tbd-station-14/Content.Server/Traits/Assorted/UncontrollableSnoughSystem.cs
Morb 3c06b87572 Use chat emotes for disease (#15134)
* Use chat emote system for disease

* Use chat emotes in prototypes

* Fix sound path

* Fix prototype ids

* Update Content.Server/Disease/DiseaseSystem.cs

Co-authored-by: Flipp Syder <76629141+vulppine@users.noreply.github.com>

---------

Co-authored-by: Flipp Syder <76629141+vulppine@users.noreply.github.com>
2023-04-07 16:17:30 -07:00

46 lines
1.4 KiB
C#

using Content.Server.Disease;
using Robust.Shared.Random;
namespace Content.Server.Traits.Assorted;
/// <summary>
/// This handles making people randomly cough/sneeze without a disease.
/// </summary>
public sealed class UncontrollableSnoughSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly DiseaseSystem _diseaseSystem = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<UncontrollableSnoughComponent, ComponentStartup>(SetupSnough);
}
private void SetupSnough(EntityUid uid, UncontrollableSnoughComponent component, ComponentStartup args)
{
component.NextIncidentTime =
_random.NextFloat(component.TimeBetweenIncidents.X, component.TimeBetweenIncidents.Y);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<UncontrollableSnoughComponent>();
while (query.MoveNext(out var ent, out var snough))
{
snough.NextIncidentTime -= frameTime;
if (snough.NextIncidentTime >= 0)
continue;
// Set the new time.
snough.NextIncidentTime +=
_random.NextFloat(snough.TimeBetweenIncidents.X, snough.TimeBetweenIncidents.Y);
_diseaseSystem.SneezeCough(ent, null, snough.EmoteId, false);
}
}
}