Files
RobustToolbox/Robust.Shared/Map/MapManager.Pause.cs
Leon Friedrich fbc706f37b Refactor map loading & saving (#5572)
* Refactor map loading & saving

* test fixes

* ISerializationManager tweaks

* Fix component composition

* Try fix entity deserialization component composition

* comments

* CL

* error preinit

* a

* cleanup

* error if version is too new

* Add AlwaysPushSerializationTest

* Add auto-inclusion test

* Better categorization

* Combine test components

* Save -> TrySave

Also better handling for saving multiple entities individually

* Create new partial class for map loading

* Add OrphanSerializationTest

* Include MapIds in BeforeSerializationEvent

* Addd LifetimeSerializationTest

* Add TestMixedLifetimeSerialization

* Add CategorizationTest

* explicitly serialize list of nullspace entities

* Add backwards compatibility test

* Version comments

also fixes wrong v4 format

* add MapMergeTest

* Add NetEntity support

* Optimize EntityDeserializer

Avoid unnecessary component deserialization

* fix assert & other bugs

* fucking containers strike again

* Fix deletion of pre-init entities

* fix release note merge conflict

* Update Robust.Shared/Map/MapManager.GridCollection.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* VV

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-02-16 21:25:07 +11:00

107 lines
3.1 KiB
C#

using System.Globalization;
using Robust.Shared.GameObjects;
namespace Robust.Shared.Map
{
internal partial class MapManager
{
public void SetMapPaused(MapId mapId, bool paused)
{
_mapSystem.SetPaused(mapId, paused);
}
public void SetMapPaused(EntityUid uid, bool paused)
{
_mapSystem.SetPaused(uid, paused);
}
public void DoMapInitialize(MapId mapId)
{
_mapSystem.InitializeMap(mapId);
}
public bool IsMapInitialized(MapId mapId)
{
return _mapSystem.IsInitialized(mapId);
}
/// <inheritdoc />
public bool IsMapPaused(MapId mapId)
{
return _mapSystem.IsPaused(mapId);
}
/// <inheritdoc />
public bool IsMapPaused(EntityUid uid)
{
return _mapSystem.IsPaused(uid);
}
/// <summary>
/// Initializes the map pausing system.
/// </summary>
private void InitializeMapPausing()
{
_conhost.RegisterCommand("pausemap",
"Pauses a map, pausing all simulation processing on it.",
"pausemap <map ID>",
(shell, _, args) =>
{
if (args.Length != 1)
{
shell.WriteError("Need to supply a valid MapId");
return;
}
var mapId = new MapId(int.Parse(args[0], CultureInfo.InvariantCulture));
if (!MapExists(mapId))
{
shell.WriteError("That map does not exist.");
return;
}
SetMapPaused(mapId, true);
});
_conhost.RegisterCommand("querymappaused",
"Check whether a map is paused or not.",
"querymappaused <map ID>",
(shell, _, args) =>
{
var mapId = new MapId(int.Parse(args[0], CultureInfo.InvariantCulture));
if (!MapExists(mapId))
{
shell.WriteError("That map does not exist.");
return;
}
shell.WriteLine(_mapSystem.IsPaused(mapId).ToString());
});
_conhost.RegisterCommand("unpausemap",
"unpauses a map, resuming all simulation processing on it.",
"Usage: unpausemap <map ID>",
(shell, _, args) =>
{
if (args.Length != 1)
{
shell.WriteLine("Need to supply a valid MapId");
return;
}
var mapId = new MapId(int.Parse(args[0], CultureInfo.InvariantCulture));
if (!MapExists(mapId))
{
shell.WriteLine("That map does not exist.");
return;
}
SetMapPaused(mapId, false);
});
}
}
}