BluespaceArtifactRule.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Content.Server.StationEvents.Components;
  2. using Content.Shared.GameTicking.Components;
  3. using Robust.Shared.Random;
  4. namespace Content.Server.StationEvents.Events;
  5. public sealed class BluespaceArtifactRule : StationEventSystem<BluespaceArtifactRuleComponent>
  6. {
  7. protected override void Added(EntityUid uid, BluespaceArtifactRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
  8. {
  9. if (!TryComp<StationEventComponent>(uid, out var stationEvent))
  10. return;
  11. var str = Loc.GetString("bluespace-artifact-event-announcement",
  12. ("sighting", Loc.GetString(RobustRandom.Pick(component.PossibleSighting))));
  13. stationEvent.StartAnnouncement = str;
  14. base.Added(uid, component, gameRule, args);
  15. }
  16. protected override void Started(EntityUid uid, BluespaceArtifactRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
  17. {
  18. base.Started(uid, component, gameRule, args);
  19. var amountToSpawn = 1;
  20. for (var i = 0; i < amountToSpawn; i++)
  21. {
  22. if (!TryFindRandomTile(out _, out _, out _, out var coords))
  23. return;
  24. Spawn(component.ArtifactSpawnerPrototype, coords);
  25. Spawn(component.ArtifactFlashPrototype, coords);
  26. Sawmill.Info($"Spawning random artifact at {coords}");
  27. }
  28. }
  29. }