StatusEffectOrganSystem.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-FileCopyrightText: 2024 deltanedas <39013340+deltanedas@users.noreply.github.com>
  2. // SPDX-FileCopyrightText: 2024 deltanedas <@deltanedas:kde.org>
  3. // SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
  4. //
  5. // SPDX-License-Identifier: AGPL-3.0-or-later
  6. using Content.Shared.Body.Organ;
  7. using Content.Shared.StatusEffect;
  8. using Robust.Shared.Timing;
  9. namespace Content.Server._Shitmed.Body.Organ;
  10. public sealed class StatusEffectOrganSystem : EntitySystem
  11. {
  12. [Dependency] private readonly IGameTiming _timing = default!;
  13. [Dependency] private readonly StatusEffectsSystem _effects = default!;
  14. public override void Update(float frameTime)
  15. {
  16. base.Update(frameTime);
  17. var query = EntityQueryEnumerator<StatusEffectOrganComponent, OrganComponent>();
  18. var now = _timing.CurTime;
  19. while (query.MoveNext(out var uid, out var comp, out var organ))
  20. {
  21. if (now < comp.NextUpdate || organ.Body is not {} body)
  22. continue;
  23. comp.NextUpdate = now + comp.Delay;
  24. if (!TryComp<StatusEffectsComponent>(body, out var effects))
  25. continue;
  26. foreach (var (key, component) in comp.Refresh)
  27. {
  28. _effects.TryAddStatusEffect(body, key, comp.Delay, refresh: true, component, effects);
  29. }
  30. }
  31. }
  32. }