mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Axes the easy IMapManager references * Axes the references to unported (obsolete) IMapManager methods * Converts salvageruler command to a LocalizedEntityCommand so it can use SharedMapSystem * Removes IMapManager from GameTicker This required axing the map nuke during restart, but that should be fine? Maps are entities so EntityManager.FlushEntities should delete them all and that's the preceding line * submodule update(?) --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
100 lines
3 KiB
C#
100 lines
3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Content.Shared.NodeContainer;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Input;
|
|
using Robust.Client.ResourceManagement;
|
|
|
|
namespace Content.Client.NodeContainer
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed partial class NodeGroupSystem : EntitySystem
|
|
{
|
|
[Dependency] private IOverlayManager _overlayManager = default!;
|
|
[Dependency] private EntityLookupSystem _entityLookup = default!;
|
|
[Dependency] private IInputManager _inputManager = default!;
|
|
[Dependency] private IResourceCache _resourceCache = default!;
|
|
|
|
public bool VisEnabled { get; private set; }
|
|
|
|
public Dictionary<int, NodeVis.GroupData> Groups { get; } = new();
|
|
public HashSet<string> Filtered { get; } = new();
|
|
|
|
public Dictionary<EntityUid, (NodeVis.GroupData group, NodeVis.NodeDatum node)[]>
|
|
Entities { get; private set; } = new();
|
|
|
|
public Dictionary<(int group, int node), NodeVis.NodeDatum> NodeLookup { get; private set; } = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeNetworkEvent<NodeVis.MsgData>(DataMsgHandler);
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
|
|
_overlayManager.RemoveOverlay<NodeVisualizationOverlay>();
|
|
}
|
|
|
|
private void DataMsgHandler(NodeVis.MsgData ev)
|
|
{
|
|
if (!VisEnabled)
|
|
return;
|
|
|
|
foreach (var deletion in ev.GroupDeletions)
|
|
{
|
|
Groups.Remove(deletion);
|
|
}
|
|
|
|
foreach (var group in ev.Groups)
|
|
{
|
|
Groups.Add(group.NetId, group);
|
|
}
|
|
|
|
foreach (var (groupId, debugData) in ev.GroupDataUpdates)
|
|
{
|
|
if (Groups.TryGetValue(groupId, out var group))
|
|
{
|
|
group.DebugData = debugData;
|
|
}
|
|
}
|
|
|
|
Entities = Groups.Values
|
|
.SelectMany(g => g.Nodes, (data, nodeData) => (data, nodeData))
|
|
.GroupBy(n => GetEntity(n.nodeData.Entity))
|
|
.ToDictionary(g => g.Key, g => g.ToArray());
|
|
|
|
NodeLookup = Groups.Values
|
|
.SelectMany(g => g.Nodes, (data, nodeData) => (data, nodeData))
|
|
.ToDictionary(n => (n.data.NetId, n.nodeData.NetId), n => n.nodeData);
|
|
}
|
|
|
|
public void SetVisEnabled(bool enabled)
|
|
{
|
|
VisEnabled = enabled;
|
|
|
|
RaiseNetworkEvent(new NodeVis.MsgEnable(enabled));
|
|
|
|
if (enabled)
|
|
{
|
|
var overlay = new NodeVisualizationOverlay(
|
|
this,
|
|
_entityLookup,
|
|
_inputManager,
|
|
_resourceCache,
|
|
EntityManager);
|
|
|
|
_overlayManager.AddOverlay(overlay);
|
|
}
|
|
else
|
|
{
|
|
Groups.Clear();
|
|
Entities.Clear();
|
|
}
|
|
}
|
|
}
|
|
}
|