RandomSpawnRule.cs 677 B

12345678910111213141516171819
  1. using Content.Server.GameTicking.Rules.Components;
  2. using Content.Server.StationEvents.Components;
  3. using Content.Shared.GameTicking.Components;
  4. namespace Content.Server.StationEvents.Events;
  5. public sealed class RandomSpawnRule : StationEventSystem<RandomSpawnRuleComponent>
  6. {
  7. protected override void Started(EntityUid uid, RandomSpawnRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
  8. {
  9. base.Started(uid, comp, gameRule, args);
  10. if (TryFindRandomTile(out _, out _, out _, out var coords))
  11. {
  12. Sawmill.Info($"Spawning {comp.Prototype} at {coords}");
  13. Spawn(comp.Prototype, coords);
  14. }
  15. }
  16. }