Files
wwdpublic/Content.Shared/Atmos/Consoles/SharedAtmosMonitoringConsoleSystem.cs
sleepyyapril a4ab8448b9 Mapping Mini-Wizmerge & New Central Command (#1610)
# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Ports https://github.com/space-wizards/space-station-14/pull/32294
Ports https://github.com/ss14-harmony/ss14-harmony/pull/310 (and
everything needed for it to function)
Early-merges
https://github.com/space-wizards/space-station-14/pull/34302

Adds the ability for multiple central command maps that get randomly
selected.
Tested and works.

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑 Several contributors
- add: Added a new central command map that is randomly picked alongside
the old one (thank you to Spanky from Harmony)
- add: Added Advanced SMES for mappers.
- add: Added the atmospheric network monitor for seeing what the
temperature, moles, and pressure is on every pipe everywhere through a
computer.
- add: Nukie med bundle now contains a compact defibrillator.
- add: Ported a better mapping editor.
- add: Added the throngler plushie.
- remove: Removed the Throngler as a possible loot spawn for gamble
crates.

---------

Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com>

(cherry picked from commit 9272f65b64392f66a7cd4fd7c84bb152dc93b65a)
2025-01-20 21:34:45 +03:00

116 lines
3.9 KiB
C#

using Content.Shared.Atmos.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Atmos.Consoles;
public abstract class SharedAtmosMonitoringConsoleSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AtmosMonitoringConsoleComponent, ComponentGetState>(OnGetState);
}
private void OnGetState(EntityUid uid, AtmosMonitoringConsoleComponent component, ref ComponentGetState args)
{
Dictionary<Vector2i, Dictionary<(int, string), ulong>> chunks;
// Should this be a full component state or a delta-state?
if (args.FromTick <= component.CreationTick || component.ForceFullUpdate)
{
component.ForceFullUpdate = false;
// Full state
chunks = new(component.AtmosPipeChunks.Count);
foreach (var (origin, chunk) in component.AtmosPipeChunks)
{
chunks.Add(origin, chunk.AtmosPipeData);
}
args.State = new AtmosMonitoringConsoleState(chunks, component.AtmosDevices);
return;
}
chunks = new();
foreach (var (origin, chunk) in component.AtmosPipeChunks)
{
if (chunk.LastUpdate < args.FromTick)
continue;
chunks.Add(origin, chunk.AtmosPipeData);
}
args.State = new AtmosMonitoringConsoleDeltaState(chunks, component.AtmosDevices, new(component.AtmosPipeChunks.Keys));
}
#region: System messages
[Serializable, NetSerializable]
protected sealed class AtmosMonitoringConsoleState(
Dictionary<Vector2i, Dictionary<(int, string), ulong>> chunks,
Dictionary<NetEntity, AtmosDeviceNavMapData> atmosDevices)
: ComponentState
{
public Dictionary<Vector2i, Dictionary<(int, string), ulong>> Chunks = chunks;
public Dictionary<NetEntity, AtmosDeviceNavMapData> AtmosDevices = atmosDevices;
}
[Serializable, NetSerializable]
protected sealed class AtmosMonitoringConsoleDeltaState(
Dictionary<Vector2i, Dictionary<(int, string), ulong>> modifiedChunks,
Dictionary<NetEntity, AtmosDeviceNavMapData> atmosDevices,
HashSet<Vector2i> allChunks)
: ComponentState, IComponentDeltaState<AtmosMonitoringConsoleState>
{
public Dictionary<Vector2i, Dictionary<(int, string), ulong>> ModifiedChunks = modifiedChunks;
public Dictionary<NetEntity, AtmosDeviceNavMapData> AtmosDevices = atmosDevices;
public HashSet<Vector2i> AllChunks = allChunks;
public void ApplyToFullState(AtmosMonitoringConsoleState state)
{
foreach (var key in state.Chunks.Keys)
{
if (!AllChunks!.Contains(key))
state.Chunks.Remove(key);
}
foreach (var (index, data) in ModifiedChunks)
{
state.Chunks[index] = new Dictionary<(int, string), ulong>(data);
}
state.AtmosDevices.Clear();
foreach (var (nuid, atmosDevice) in AtmosDevices)
{
state.AtmosDevices.Add(nuid, atmosDevice);
}
}
public AtmosMonitoringConsoleState CreateNewFullState(AtmosMonitoringConsoleState state)
{
var chunks = new Dictionary<Vector2i, Dictionary<(int, string), ulong>>(state.Chunks.Count);
foreach (var (index, data) in state.Chunks)
{
if (!AllChunks!.Contains(index))
continue;
if (ModifiedChunks.ContainsKey(index))
chunks[index] = new Dictionary<(int, string), ulong>(ModifiedChunks[index]);
else
chunks[index] = new Dictionary<(int, string), ulong>(state.Chunks[index]);
}
return new AtmosMonitoringConsoleState(chunks, new(AtmosDevices));
}
}
#endregion
}