VariationPassSystem.cs 1.0 KB

1234567891011121314151617181920212223242526272829
  1. using Content.Server.Station.Systems;
  2. using Robust.Shared.Random;
  3. namespace Content.Server.GameTicking.Rules.VariationPass;
  4. /// <summary>
  5. /// Base class for procedural variation rule passes, which apply some kind of variation to a station,
  6. /// so we simply reduce the boilerplate for the event handling a bit with this.
  7. /// </summary>
  8. public abstract class VariationPassSystem<T> : GameRuleSystem<T>
  9. where T: IComponent
  10. {
  11. [Dependency] protected readonly StationSystem Stations = default!;
  12. [Dependency] protected readonly IRobustRandom Random = default!;
  13. public override void Initialize()
  14. {
  15. base.Initialize();
  16. SubscribeLocalEvent<T, StationVariationPassEvent>(ApplyVariation);
  17. }
  18. protected bool IsMemberOfStation(Entity<TransformComponent> ent, ref StationVariationPassEvent args)
  19. {
  20. return Stations.GetOwningStation(ent, ent.Comp) == args.Station.Owner;
  21. }
  22. protected abstract void ApplyVariation(Entity<T> ent, ref StationVariationPassEvent args);
  23. }