SharedBorgSystem.Relay.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Content.Shared.Damage;
  2. using Content.Shared.Silicons.Borgs.Components;
  3. namespace Content.Shared.Silicons.Borgs;
  4. public abstract partial class SharedBorgSystem
  5. {
  6. public void InitializeRelay()
  7. {
  8. SubscribeLocalEvent<BorgChassisComponent, DamageModifyEvent>(RelayToModule);
  9. }
  10. protected void RelayToModule<T>(EntityUid uid, BorgChassisComponent component, T args) where T : class
  11. {
  12. var ev = new BorgModuleRelayedEvent<T>(args);
  13. foreach (var module in component.ModuleContainer.ContainedEntities)
  14. {
  15. RaiseLocalEvent(module, ref ev);
  16. }
  17. }
  18. protected void RelayRefToModule<T>(EntityUid uid, BorgChassisComponent component, ref T args) where T : class
  19. {
  20. var ev = new BorgModuleRelayedEvent<T>(args);
  21. foreach (var module in component.ModuleContainer.ContainedEntities)
  22. {
  23. RaiseLocalEvent(module, ref ev);
  24. }
  25. }
  26. }
  27. [ByRefEvent]
  28. public record struct BorgModuleRelayedEvent<TEvent>(TEvent Args)
  29. {
  30. public readonly TEvent Args = Args;
  31. }