PolymorphSystem.Map.cs 966 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Content.Shared.GameTicking;
  2. namespace Content.Server.Polymorph.Systems;
  3. public sealed partial class PolymorphSystem
  4. {
  5. public EntityUid? PausedMap { get; private set; }
  6. /// <summary>
  7. /// Used to subscribe to the round restart event
  8. /// </summary>
  9. private void InitializeMap()
  10. {
  11. SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
  12. }
  13. private void OnRoundRestart(RoundRestartCleanupEvent _)
  14. {
  15. if (PausedMap == null || !Exists(PausedMap))
  16. return;
  17. Del(PausedMap.Value);
  18. }
  19. /// <summary>
  20. /// Used internally to ensure a paused map that is
  21. /// stores polymorphed entities.
  22. /// </summary>
  23. private void EnsurePausedMap()
  24. {
  25. if (PausedMap != null && Exists(PausedMap))
  26. return;
  27. var newmap = _mapManager.CreateMap();
  28. _mapManager.SetMapPaused(newmap, true);
  29. PausedMap = _mapManager.GetMapEntityId(newmap);
  30. }
  31. }