TestDestructibleListenerSystem.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections.Generic;
  2. using Content.Server.Destructible;
  3. using Content.Shared.GameTicking;
  4. using Robust.Shared.GameObjects;
  5. using Robust.Shared.Reflection;
  6. namespace Content.IntegrationTests.Tests.Destructible
  7. {
  8. /// <summary>
  9. /// This is just a system for testing destructible thresholds. Whenever any threshold is reached, this will add that
  10. /// threshold to a list for checking during testing.
  11. /// </summary>
  12. [Reflect(false)]
  13. public sealed class TestDestructibleListenerSystem : EntitySystem
  14. {
  15. public readonly List<DamageThresholdReached> ThresholdsReached = new();
  16. public override void Initialize()
  17. {
  18. base.Initialize();
  19. SubscribeLocalEvent<DestructibleComponent, DamageThresholdReached>(AddThresholdsToList);
  20. SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
  21. }
  22. public void AddThresholdsToList(EntityUid _, DestructibleComponent comp, DamageThresholdReached args)
  23. {
  24. ThresholdsReached.Add(args);
  25. }
  26. private void OnRoundRestart(RoundRestartCleanupEvent ev)
  27. {
  28. ThresholdsReached.Clear();
  29. }
  30. }
  31. }