OnRadiationOverlayUpdateEvent.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Content.Shared.Radiation.Components;
  2. using Content.Shared.Radiation.Systems;
  3. using Robust.Shared.Serialization;
  4. namespace Content.Shared.Radiation.Events;
  5. /// <summary>
  6. /// Raised on server as networked event when radiation system update its state
  7. /// and emitted all rays from rad sources towards rad receivers.
  8. /// Contains debug information about rad rays and all blockers on their way.
  9. /// </summary>
  10. /// <remarks>
  11. /// Will be sent only to clients that activated radiation view using console command.
  12. /// </remarks>
  13. [Serializable, NetSerializable]
  14. public sealed class OnRadiationOverlayUpdateEvent(
  15. double elapsedTimeMs,
  16. int sourcesCount,
  17. int receiversCount,
  18. List<DebugRadiationRay> rays)
  19. : EntityEventArgs
  20. {
  21. /// <summary>
  22. /// Total time in milliseconds that server took to do radiation processing.
  23. /// Exclude time of entities reacting to <see cref="OnIrradiatedEvent"/>.
  24. /// </summary>
  25. public readonly double ElapsedTimeMs = elapsedTimeMs;
  26. /// <summary>
  27. /// Total count of entities with <see cref="RadiationSourceComponent"/> on all maps.
  28. /// </summary>
  29. public readonly int SourcesCount = sourcesCount;
  30. /// <summary>
  31. /// Total count of entities with radiation receiver on all maps.
  32. /// </summary>
  33. public readonly int ReceiversCount = receiversCount;
  34. /// <summary>
  35. /// All radiation rays that was processed by radiation system.
  36. /// </summary>
  37. public readonly List<DebugRadiationRay> Rays = rays;
  38. }
  39. /// <summary>
  40. /// Raised when server enabled/disabled radiation debug view for client.
  41. /// After that client will start/stop receiving <see cref="OnRadiationOverlayUpdateEvent"/>.
  42. /// </summary>
  43. [Serializable, NetSerializable]
  44. public sealed class OnRadiationOverlayToggledEvent : EntityEventArgs
  45. {
  46. /// <summary>
  47. /// Does debug radiation view enabled.
  48. /// </summary>
  49. public readonly bool IsEnabled;
  50. public OnRadiationOverlayToggledEvent(bool isEnabled)
  51. {
  52. IsEnabled = isEnabled;
  53. }
  54. }
  55. /// <summary>
  56. /// Raised when grid resistance was update for radiation overlay visualization.
  57. /// </summary>
  58. [Serializable, NetSerializable]
  59. public sealed class OnRadiationOverlayResistanceUpdateEvent : EntityEventArgs
  60. {
  61. /// <summary>
  62. /// Key is grids uid. Values are tiles with their rad resistance.
  63. /// </summary>
  64. public readonly Dictionary<NetEntity, Dictionary<Vector2i, float>> Grids;
  65. public OnRadiationOverlayResistanceUpdateEvent(Dictionary<NetEntity, Dictionary<Vector2i, float>> grids)
  66. {
  67. Grids = grids;
  68. }
  69. }