mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-15 14:52:35 +02:00
* [Dependency] source generator No more reflection, no more codegen at runtime Also various changes to Roslyn helpers to make this easier to write. Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback. No fallback is available for [field: Dependency] properties, due to a Roslyn bug. Code Fixes exist. We love Roslyn * Apply dependencies generator changes to all code * Release notes * Preprocessor got hands * Handle nullable dependencies These are bad but gotta deal with it. * Apply suggestions from code review Co-authored-by: Moony <moony@hellomouse.net> * Fine, let's not use collection expressions --------- Co-authored-by: Moony <moony@hellomouse.net>
79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using Robust.Shared.Console;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Physics.Collision;
|
|
using Robust.Shared.Physics.Systems;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Robust.Shared.Map;
|
|
|
|
/// <inheritdoc cref="IMapManager" />
|
|
[Virtual]
|
|
internal partial class MapManager : IMapManagerInternal, IEntityEventSubscriber
|
|
{
|
|
[Dependency] public IGameTiming GameTiming = default!;
|
|
[Dependency] public IEntityManager EntityManager = default!;
|
|
[Dependency] private IManifoldManager _manifolds = default!;
|
|
[Dependency] private ILogManager _logManager = default!;
|
|
[Dependency] private IConsoleHost _conhost = default!;
|
|
|
|
private ISawmill _sawmill = default!;
|
|
|
|
private SharedMapSystem _mapSystem = default!;
|
|
private SharedPhysicsSystem _physics = default!;
|
|
private SharedTransformSystem _transformSystem = default!;
|
|
|
|
private EntityQuery<GridTreeComponent> _gridTreeQuery;
|
|
private EntityQuery<MapGridComponent> _gridQuery;
|
|
|
|
/// <inheritdoc />
|
|
public void Initialize()
|
|
{
|
|
_gridTreeQuery = EntityManager.GetEntityQuery<GridTreeComponent>();
|
|
_gridQuery = EntityManager.GetEntityQuery<MapGridComponent>();
|
|
InitializeMapPausing();
|
|
_sawmill = _logManager.GetSawmill("system.map");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Startup()
|
|
{
|
|
_physics = EntityManager.System<SharedPhysicsSystem>();
|
|
_transformSystem = EntityManager.System<SharedTransformSystem>();
|
|
_mapSystem = EntityManager.System<SharedMapSystem>();
|
|
|
|
_sawmill.Debug("Starting...");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Shutdown()
|
|
{
|
|
_sawmill.Debug("Stopping...");
|
|
|
|
// TODO: AllEntityQuery instead???
|
|
var query = EntityManager.EntityQueryEnumerator<MapComponent>();
|
|
|
|
while (query.MoveNext(out var uid, out _))
|
|
{
|
|
EntityManager.DeleteEntity(uid);
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Restart()
|
|
{
|
|
_sawmill.Debug("Restarting...");
|
|
|
|
// Don't just call Shutdown / Startup because we don't want to touch the subscriptions on gridtrees
|
|
// Restart can be called any time during a game, whereas shutdown / startup are typically called upon connection.
|
|
var query = EntityManager.EntityQueryEnumerator<MapComponent>();
|
|
|
|
while (query.MoveNext(out var uid, out _))
|
|
{
|
|
EntityManager.DeleteEntity(uid);
|
|
}
|
|
}
|
|
}
|