Visualized regions for NavMapControl (#31910)

* Atmospheric alerts computer

* Moved components, restricted access to them

* Minor tweaks

* The screen will now turn off when the computer is not powered

* Bug fix

* Adjusted label

* Updated to latest master version

* Initial commit

* Tidy up

* Add firelocks to the nav map

* Add nav map regions to atmos alerts computer

* Added support for multiple region overlay sets per grid

* Fixed issue where console values were not updating correctly

* Fixing merge conflict

* Fixing merge conflicts

* Finished all major features

* Removed station map regions (to be re-added in a separate PR)

* Improved clarity

* Adjusted the color saturation of the regions displayed on the atmos alerts computer
This commit is contained in:
chromiumboy
2024-10-23 07:49:58 -05:00
committed by GitHub
parent 3b0d8e63a1
commit d2216835d8
9 changed files with 649 additions and 22 deletions

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Shared.Pinpointer;
using Robust.Shared.GameStates;
@@ -16,6 +17,7 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
{
Dictionary<Vector2i, int[]> modifiedChunks;
Dictionary<NetEntity, NavMapBeacon> beacons;
Dictionary<NetEntity, NavMapRegionProperties> regions;
switch (args.Current)
{
@@ -23,6 +25,8 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
{
modifiedChunks = delta.ModifiedChunks;
beacons = delta.Beacons;
regions = delta.Regions;
foreach (var index in component.Chunks.Keys)
{
if (!delta.AllChunks!.Contains(index))
@@ -35,6 +39,8 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
{
modifiedChunks = state.Chunks;
beacons = state.Beacons;
regions = state.Regions;
foreach (var index in component.Chunks.Keys)
{
if (!state.Chunks.ContainsKey(index))
@@ -47,13 +53,54 @@ public sealed partial class NavMapSystem : SharedNavMapSystem
return;
}
// Update region data and queue new regions for flooding
var prevRegionOwners = component.RegionProperties.Keys.ToList();
var validRegionOwners = new List<NetEntity>();
component.RegionProperties.Clear();
foreach (var (regionOwner, regionData) in regions)
{
if (!regionData.Seeds.Any())
continue;
component.RegionProperties[regionOwner] = regionData;
validRegionOwners.Add(regionOwner);
if (component.RegionOverlays.ContainsKey(regionOwner))
continue;
if (component.QueuedRegionsToFlood.Contains(regionOwner))
continue;
component.QueuedRegionsToFlood.Enqueue(regionOwner);
}
// Remove stale region owners
var regionOwnersToRemove = prevRegionOwners.Except(validRegionOwners);
foreach (var regionOwnerRemoved in regionOwnersToRemove)
RemoveNavMapRegion(uid, component, regionOwnerRemoved);
// Modify chunks
foreach (var (origin, chunk) in modifiedChunks)
{
var newChunk = new NavMapChunk(origin);
Array.Copy(chunk, newChunk.TileData, chunk.Length);
component.Chunks[origin] = newChunk;
// If the affected chunk intersects one or more regions, re-flood them
if (!component.ChunkToRegionOwnerTable.TryGetValue(origin, out var affectedOwners))
continue;
foreach (var affectedOwner in affectedOwners)
{
if (!component.QueuedRegionsToFlood.Contains(affectedOwner))
component.QueuedRegionsToFlood.Enqueue(affectedOwner);
}
}
// Refresh beacons
component.Beacons.Clear();
foreach (var (nuid, beacon) in beacons)
{