SpawnRandomOffsetSystem.cs 671 B

1234567891011121314151617181920212223
  1. using Content.Shared.Random;
  2. using Content.Shared.Random.Helpers;
  3. using Robust.Shared.Random;
  4. namespace Content.Server.Coordinates;
  5. public sealed class SpawnRandomOffsetSystem : EntitySystem
  6. {
  7. [Dependency] private readonly RandomHelperSystem _randomHelper = default!;
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<SpawnRandomOffsetComponent, MapInitEvent>(OnMapInit);
  12. }
  13. private void OnMapInit(EntityUid uid, SpawnRandomOffsetComponent component, MapInitEvent args)
  14. {
  15. _randomHelper.RandomOffset(uid, component.Offset);
  16. EntityManager.RemoveComponentDeferred(uid, component);
  17. }
  18. }