Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream merge 21/12 #2496

Open
wants to merge 160 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
18ec5ac
Give silicons proper lobby/character editor previews (#33763)
PJB3005 Dec 8, 2024
294e796
Automatic changelog update
PJBot Dec 8, 2024
d3e498f
Revert "Simplify separated screen top menu (#33047)"
VasilisThePikachu Dec 8, 2024
b2742a7
Singularity equipment can now be activated with E interact (#33762)
PJB3005 Dec 8, 2024
3621e6f
Automatic changelog update
PJBot Dec 8, 2024
f05aa8d
Fix detective Vox spawning with their chosen outer clothing on the fl…
ArtisticRoomba Dec 8, 2024
589a488
Automatic changelog update
PJBot Dec 8, 2024
23ba1f6
Fix gas pipe leaking when unanchoring or breaking them (#33774)
slarticodefast Dec 8, 2024
d76eb6c
Automatic changelog update
PJBot Dec 8, 2024
581b4a2
Signal timer duration limit (#33781)
Errant-4 Dec 9, 2024
551e2d0
Automatic changelog update
PJBot Dec 9, 2024
99e0bcb
Popup when being pulled shows who is pulling you (#33612)
Plykiya Dec 9, 2024
e29c169
Automatic changelog update
PJBot Dec 9, 2024
4c20f92
Fix Disposals Ejections (#33468)
sleepyyapril Dec 9, 2024
3c9b179
Adds an introductory message to the user-facing ahelp chat window (#3…
deathride58 Dec 9, 2024
69f89f8
Automatic changelog update
PJBot Dec 9, 2024
fd318a6
Derelict icon hotfix (#33768)
ScarKy0 Dec 9, 2024
a71732a
You can now pet the AI core. (#33788)
ScarKy0 Dec 9, 2024
614a214
Automatic changelog update
PJBot Dec 9, 2024
b6a1f84
Bar related tweaks (#33505)
joshepvodka Dec 9, 2024
4fcd9eb
Automatic changelog update
PJBot Dec 9, 2024
6a9d301
Fix: SMES now has wirepanels visuals (#33808)
ArtisticRoomba Dec 10, 2024
ef1f226
Automatic changelog update
PJBot Dec 10, 2024
fb1a729
Fix blank newline on empty examine groups (#33813)
metalgearsloth Dec 10, 2024
0a2ed72
Automatic changelog update
PJBot Dec 10, 2024
9a9b6f2
Made anchor visuals generic (#33810)
TGRCdev Dec 11, 2024
6605017
Fix greytide virus hitting other maps (#33806)
slarticodefast Dec 11, 2024
2504fe3
Automatic changelog update
PJBot Dec 11, 2024
97b5e8c
Names camera routers (#33496)
IamVelcroboy Dec 11, 2024
7ac3f58
Fix battery self-recharge mispredicts (#33384)
metalgearsloth Dec 11, 2024
845c69f
Automatic changelog update
PJBot Dec 11, 2024
e0636a8
Rework the HoS's Energy Shotgun (Varying energy consumption depending…
BramvanZijp Dec 11, 2024
eab41b2
Automatic changelog update
PJBot Dec 11, 2024
fd06717
Warden headdresses In-hand Sprites (#33521)
onesch Dec 12, 2024
d308494
Update APE guidebook to contain Sigma particles, Transformation and c…
Winkarst-cpu Dec 12, 2024
2cbb990
Automatic changelog update
PJBot Dec 12, 2024
62a3def
fix ghost command error string (#33838)
lzk228 Dec 12, 2024
6589a5d
Safari hat In-hand Sprites (#33464)
onesch Dec 12, 2024
356ed91
Increase war ops evac time (#33628)
lzk228 Dec 13, 2024
c38c9f9
Automatic changelog update
PJBot Dec 13, 2024
7f050f7
Add meat tag to Five Alarm Burger (#33848)
LevitatingTree Dec 13, 2024
c1d3566
Automatic changelog update
PJBot Dec 13, 2024
5b57004
Monospace Support for Rich Text (#33830)
southbridge-fur Dec 13, 2024
a3f03fc
Automatic changelog update
PJBot Dec 13, 2024
6daddc6
Secret stash wrench anchoring fix (#31779)
godisdeadLOL Dec 13, 2024
65221e2
Automatic changelog update
PJBot Dec 13, 2024
bfc4820
Other colour of the binary channel (#33841)
Nimfar11 Dec 14, 2024
759730b
Automatic changelog update
PJBot Dec 14, 2024
6464bad
Separate RGlass recipe for autolathe and ore processor (#33876)
Tayrtahn Dec 15, 2024
82bfed4
Rename Dungeon Master Laws to not run into copyright problems (#33678)
Litraxx Dec 16, 2024
07e9d4e
Zombies can see Initial Infected (#33665)
psykana Dec 16, 2024
5e0d4e5
Automatic changelog update
PJBot Dec 16, 2024
cd4d729
Automatic changelog update
PJBot Dec 16, 2024
db7955b
Bug fixes for Store UIs with multiple currencies (#33565)
TGRCdev Dec 16, 2024
e62d937
Cluster grenade refactor and contra markings (#31108)
Plykiya Dec 16, 2024
9129581
Automatic changelog update
PJBot Dec 16, 2024
c8780dc
Wizard Mind Swap Spell (#33416)
ActiveMammmoth Dec 16, 2024
c52db7d
add SpawnTableOnUse (#32620)
deltanedas Dec 16, 2024
8479b58
LightOnCollide entityquery (#33886)
metalgearsloth Dec 16, 2024
9a36746
Add generator scrap (Plasma / uranium scrap) (#32198)
beck-thompson Dec 16, 2024
c5c8751
Add a test to check that lathe recipes are possible (#33868)
Tayrtahn Dec 16, 2024
22a71e3
Automatic changelog update
PJBot Dec 16, 2024
b55171f
Fix udder wooly reagent creation V2 (#32905)
Baa14453 Dec 16, 2024
cb29b82
Automatic changelog update
PJBot Dec 16, 2024
3ef2bfa
Prevent pulling when teleporting (#33252)
thetolbean Dec 16, 2024
6521e0a
Automatic changelog update
PJBot Dec 16, 2024
802f0d1
Add an in-hand sprite for the lizard plushie (#32583)
KieueCaprie Dec 16, 2024
625ca5e
Automatic changelog update
PJBot Dec 16, 2024
2e162df
Makes admins not count towards the playercount cap (#33424)
deathride58 Dec 16, 2024
c465552
Automatic changelog update
PJBot Dec 16, 2024
413264e
Add the Zombie, a new cocktail (#32802)
dragonryan06 Dec 16, 2024
6c4bdeb
Automatic changelog update
PJBot Dec 16, 2024
37666f8
Add Holy damage (#32755)
SlamBamActionman Dec 16, 2024
a80f0ce
Holy water (#22524)
UbaserB Dec 15, 2023
b24d62b
Automatic changelog update
PJBot Dec 16, 2024
f027354
Add Explosion Resistance to SecBelts (#33253)
Vexerot Dec 16, 2024
401d970
Automatic changelog update
PJBot Dec 16, 2024
1071fc7
Chem master UI (#33328)
Intoxicating-Innocence Dec 16, 2024
61e0a8a
Spaceshroom grilling (#31872)
goet Dec 16, 2024
cd867cc
Automatic changelog update
PJBot Dec 16, 2024
ab1b173
Figures can now be activated remotely (#32769)
beck-thompson Dec 16, 2024
3e34243
Automatic changelog update
PJBot Dec 16, 2024
e4db6ec
Flora clean up (#33839)
TheShuEd Dec 16, 2024
0feb5d1
Christmas anomaly (#33889)
TheShuEd Dec 16, 2024
1fa8442
Automatic changelog update
PJBot Dec 16, 2024
e977f87
Atmospheric network monitor (#32294)
chromiumboy Dec 17, 2024
bdb55fd
Automatic changelog update
PJBot Dec 17, 2024
471948c
Automatic changelog update
PJBot Dec 17, 2024
55baf52
Zombies keep their anomalies on zombification (#33867)
pcaessayrs Dec 17, 2024
81436e5
Automatic changelog update
PJBot Dec 17, 2024
f14f020
Anomaly Scanner In-hand Sprites (#33427)
TiniestShark Dec 17, 2024
b8f5c7b
Automatic changelog update
PJBot Dec 17, 2024
dc44048
Holopads (#32711)
chromiumboy Dec 17, 2024
ed04793
Automatic changelog update
PJBot Dec 17, 2024
39da901
Fix horrible lag in Zombies mode (#33818)
psykana Dec 17, 2024
9339275
Automatic changelog update
PJBot Dec 17, 2024
1ef104d
Adds Advanced SMES, an SMES with higher capacity for mapping (#33757)
ArtisticRoomba Dec 17, 2024
01041b0
Automatic changelog update
PJBot Dec 18, 2024
4129851
Ground Light Post Crafting Description Fix (#33920)
TiniestShark Dec 18, 2024
1cb39e3
Fix admins not being able to health scan slimes (#33884)
slarticodefast Dec 18, 2024
487efdc
Automatic changelog update
PJBot Dec 18, 2024
ec9cc2e
Cargo Shuttle/ATS Update (#33927)
spanky-spanky Dec 18, 2024
5e37de1
Make safes craftable (#32694)
lzk228 Dec 18, 2024
875f975
Automatic changelog update
PJBot Dec 18, 2024
8e1f722
Holopad prototypes for mapping (#33931)
ScarKy0 Dec 18, 2024
8a1574c
Reduce network burden of the hunger system (#32986)
Centronias Dec 18, 2024
88f7e91
Only disable panicbunker for admins with AdminFlags.Admin (#33879)
slarticodefast Dec 18, 2024
6230d53
Automatic changelog update
PJBot Dec 18, 2024
1c1765f
Fix hugging buckled mobs instead of unbuckling (#33635)
MilenVolf Dec 18, 2024
ee278b2
Automatic changelog update
PJBot Dec 18, 2024
64af278
Replace Cellular Slime mob damage with Caustic (#33104)
SlamBamActionman Dec 18, 2024
c918999
Automatic changelog update
PJBot Dec 18, 2024
bbbd0f1
Mercenary gear contraband tweaks. (#33647)
RedBookcase Dec 18, 2024
a683bce
Automatic changelog update
PJBot Dec 18, 2024
3a4dcb9
Sprite Movement working with AI movement (#33494)
TheShuEd Dec 18, 2024
fa7682b
New Drazil plushie (inverse lizard plushie) (#33776)
ArtisticRoomba Dec 18, 2024
b327829
Automatic changelog update
PJBot Dec 18, 2024
54aa904
[Christmas] Y'all want a Smite Cranberry? (#33922)
FairlySadPanda Dec 19, 2024
a9735bf
Automatic changelog update
PJBot Dec 19, 2024
ede7356
Comment LogTypes (#33497)
Winkarst-cpu Dec 19, 2024
1737f9e
Show battery level for selected devices in Power Monitoring Console (…
ArtisticRoomba Dec 19, 2024
33c3e6e
Automatic changelog update
PJBot Dec 19, 2024
4307345
Automatic changelog update
PJBot Dec 19, 2024
2925b0e
Food Container Size Increase (#33842)
SpaceLizard24 Dec 19, 2024
eeba6b3
Logic Gate Compatibility with Non-Logic Signals bugfix (#33792)
Centronias Dec 19, 2024
d88a112
Automatic changelog update
PJBot Dec 19, 2024
36a6003
Remove plushie_lizard_mirrored.png (#33855)
LevitatingTree Dec 19, 2024
8de252e
Tweaks for the holopad (#33928)
chromiumboy Dec 19, 2024
51e262b
Fix: Update armor crate description (#33414)
Plykiya Dec 19, 2024
15d5c37
Automatic changelog update
PJBot Dec 19, 2024
656eea1
Minor fixes for the holopad (#33969)
chromiumboy Dec 20, 2024
a71796c
add man-o-war shuttle (#32105)
IProduceWidgets Dec 20, 2024
2ede8c6
Add MovementSound (#31313)
metalgearsloth Dec 20, 2024
6ef26f6
Remove Clearly Nuclear on Author's Request (#33971)
Piras314 Dec 20, 2024
7f004a5
Automatic changelog update
PJBot Dec 20, 2024
12cf70a
Fix communication console menu (#33655)
VlaDOS1408 Dec 20, 2024
383cf47
Automatic changelog update
PJBot Dec 20, 2024
314946f
combine licence files for StationEvents audio (#33972)
Errant-4 Dec 20, 2024
a75b15d
All hostile turret (#33970)
CaptainMaru Dec 20, 2024
271942c
Automatic changelog update
PJBot Dec 20, 2024
ae8e1d9
Add clearer defib cooldowns! (#31251)
beck-thompson Dec 20, 2024
cdc25b8
Automatic changelog update
PJBot Dec 20, 2024
4fb611f
Nanotrasen, Syndicate factions are now hostile to Dragons and Carps (…
AverageNotDoingAnythingEnjoyer Dec 20, 2024
6969906
Automatic changelog update
PJBot Dec 20, 2024
a968a32
Add description of tool qualities to entity (#32436)
lzk228 Dec 20, 2024
bec763c
Automatic changelog update
PJBot Dec 20, 2024
a5f3c17
Diona chirping & Nymph vocals (#32511)
Pinkbat5 Dec 20, 2024
d519392
Automatic changelog update
PJBot Dec 20, 2024
3267b26
Increase syndicate uplink discount amount to 6. (#33950)
ScarKy0 Dec 21, 2024
078cb2b
Automatic changelog update
PJBot Dec 21, 2024
3fc1074
Wood walls from barricades (#33902)
JustinWinningham Dec 21, 2024
faa8cd6
Automatic changelog update
PJBot Dec 21, 2024
57628b8
Implement some field-level deltas (#28242)
metalgearsloth Dec 21, 2024
c6cc429
Update submodule to 237.4.0 (#33976)
metalgearsloth Dec 21, 2024
a41c511
Toolshed refactor (#33598)
ElectroJr Dec 21, 2024
22a3f63
Automatic changelog update
PJBot Dec 21, 2024
33202e7
Update engine to v238.0.0 (#33980)
ElectroJr Dec 21, 2024
9a55d3b
Automatic changelog update
PJBot Dec 21, 2024
3bcbea6
:trollface:
Dec 21, 2024
ad56a1f
:trollface:
Dec 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 2 additions & 16 deletions Content.Client/Atmos/Consoles/AtmosAlarmEntryContainer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ public sealed partial class AtmosAlarmEntryContainer : BoxContainer
[AtmosAlarmType.Danger] = "atmos-alerts-window-danger-state",
};

private Dictionary<Gas, string> _gasShorthands = new Dictionary<Gas, string>()
{
[Gas.Ammonia] = "NH₃",
[Gas.CarbonDioxide] = "CO₂",
[Gas.Frezon] = "F",
[Gas.Nitrogen] = "N₂",
[Gas.NitrousOxide] = "N₂O",
[Gas.Oxygen] = "O₂",
[Gas.Plasma] = "P",
[Gas.Tritium] = "T",
[Gas.WaterVapor] = "H₂O",
};

public AtmosAlarmEntryContainer(NetEntity uid, EntityCoordinates? coordinates)
{
RobustXamlLoader.Load(this);
Expand Down Expand Up @@ -162,12 +149,11 @@ public void UpdateEntry(AtmosAlertsComputerEntry entry, bool isFocus, AtmosAlert
foreach ((var gas, (var mol, var percent, var alert)) in keyValuePairs)
{
FixedPoint2 gasPercent = percent * 100f;

var gasShorthand = _gasShorthands.GetValueOrDefault(gas, "X");
var gasAbbreviation = Atmospherics.GasAbbreviations.GetValueOrDefault(gas, Loc.GetString("gas-unknown-abbreviation"));

var gasLabel = new Label()
{
Text = Loc.GetString("atmos-alerts-window-other-gases-value", ("shorthand", gasShorthand), ("value", gasPercent)),
Text = Loc.GetString("atmos-alerts-window-other-gases-value", ("shorthand", gasAbbreviation), ("value", gasPercent)),
FontOverride = normalFont,
FontColorOverride = GetAlarmStateColor(alert),
HorizontalAlignment = HAlignment.Center,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Content.Shared.Atmos.Components;

namespace Content.Client.Atmos.Consoles;

public sealed class AtmosMonitoringConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private AtmosMonitoringConsoleWindow? _menu;

public AtmosMonitoringConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { }

protected override void Open()
{
base.Open();

_menu = new AtmosMonitoringConsoleWindow(this, Owner);
_menu.OpenCentered();
_menu.OnClose += Close;
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not AtmosMonitoringConsoleBoundInterfaceState castState)
return;

EntMan.TryGetComponent<TransformComponent>(Owner, out var xform);
_menu?.UpdateUI(xform?.Coordinates, castState.AtmosNetworks);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

_menu?.Dispose();
}
}
295 changes: 295 additions & 0 deletions Content.Client/Atmos/Consoles/AtmosMonitoringConsoleNavMapControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
using Content.Client.Pinpointer.UI;
using Content.Shared.Atmos.Components;
using Content.Shared.Pinpointer;
using Robust.Client.Graphics;
using Robust.Shared.Collections;
using Robust.Shared.Map.Components;
using System.Linq;
using System.Numerics;

namespace Content.Client.Atmos.Consoles;

public sealed partial class AtmosMonitoringConsoleNavMapControl : NavMapControl
{
[Dependency] private readonly IEntityManager _entManager = default!;

public bool ShowPipeNetwork = true;
public int? FocusNetId = null;

private const int ChunkSize = 4;

private readonly Color _basePipeNetColor = Color.LightGray;
private readonly Color _unfocusedPipeNetColor = Color.DimGray;

private List<AtmosMonitoringConsoleLine> _atmosPipeNetwork = new();
private Dictionary<Color, Color> _sRGBLookUp = new Dictionary<Color, Color>();

// Look up tables for merging continuous lines. Indexed by line color
private Dictionary<Color, Dictionary<Vector2i, Vector2i>> _horizLines = new();
private Dictionary<Color, Dictionary<Vector2i, Vector2i>> _horizLinesReversed = new();
private Dictionary<Color, Dictionary<Vector2i, Vector2i>> _vertLines = new();
private Dictionary<Color, Dictionary<Vector2i, Vector2i>> _vertLinesReversed = new();

public AtmosMonitoringConsoleNavMapControl() : base()
{
PostWallDrawingAction += DrawAllPipeNetworks;
}

protected override void UpdateNavMap()
{
base.UpdateNavMap();

if (!_entManager.TryGetComponent<AtmosMonitoringConsoleComponent>(Owner, out var console))
return;

if (!_entManager.TryGetComponent<MapGridComponent>(MapUid, out var grid))
return;

_atmosPipeNetwork = GetDecodedAtmosPipeChunks(console.AtmosPipeChunks, grid);
}

private void DrawAllPipeNetworks(DrawingHandleScreen handle)
{
if (!ShowPipeNetwork)
return;

// Draw networks
if (_atmosPipeNetwork != null && _atmosPipeNetwork.Any())
DrawPipeNetwork(handle, _atmosPipeNetwork);
}

private void DrawPipeNetwork(DrawingHandleScreen handle, List<AtmosMonitoringConsoleLine> atmosPipeNetwork)
{
var offset = GetOffset();
offset = offset with { Y = -offset.Y };

if (WorldRange / WorldMaxRange > 0.5f)
{
var pipeNetworks = new Dictionary<Color, ValueList<Vector2>>();

foreach (var chunkedLine in atmosPipeNetwork)
{
var start = ScalePosition(chunkedLine.Origin - offset);
var end = ScalePosition(chunkedLine.Terminus - offset);

if (!pipeNetworks.TryGetValue(chunkedLine.Color, out var subNetwork))
subNetwork = new ValueList<Vector2>();

subNetwork.Add(start);
subNetwork.Add(end);

pipeNetworks[chunkedLine.Color] = subNetwork;
}

foreach ((var color, var subNetwork) in pipeNetworks)
{
if (subNetwork.Count > 0)
handle.DrawPrimitives(DrawPrimitiveTopology.LineList, subNetwork.Span, color);
}
}

else
{
var pipeVertexUVs = new Dictionary<Color, ValueList<Vector2>>();

foreach (var chunkedLine in atmosPipeNetwork)
{
var leftTop = ScalePosition(new Vector2
(Math.Min(chunkedLine.Origin.X, chunkedLine.Terminus.X) - 0.1f,
Math.Min(chunkedLine.Origin.Y, chunkedLine.Terminus.Y) - 0.1f)
- offset);

var rightTop = ScalePosition(new Vector2
(Math.Max(chunkedLine.Origin.X, chunkedLine.Terminus.X) + 0.1f,
Math.Min(chunkedLine.Origin.Y, chunkedLine.Terminus.Y) - 0.1f)
- offset);

var leftBottom = ScalePosition(new Vector2
(Math.Min(chunkedLine.Origin.X, chunkedLine.Terminus.X) - 0.1f,
Math.Max(chunkedLine.Origin.Y, chunkedLine.Terminus.Y) + 0.1f)
- offset);

var rightBottom = ScalePosition(new Vector2
(Math.Max(chunkedLine.Origin.X, chunkedLine.Terminus.X) + 0.1f,
Math.Max(chunkedLine.Origin.Y, chunkedLine.Terminus.Y) + 0.1f)
- offset);

if (!pipeVertexUVs.TryGetValue(chunkedLine.Color, out var pipeVertexUV))
pipeVertexUV = new ValueList<Vector2>();

pipeVertexUV.Add(leftBottom);
pipeVertexUV.Add(leftTop);
pipeVertexUV.Add(rightBottom);
pipeVertexUV.Add(leftTop);
pipeVertexUV.Add(rightBottom);
pipeVertexUV.Add(rightTop);

pipeVertexUVs[chunkedLine.Color] = pipeVertexUV;
}

foreach ((var color, var pipeVertexUV) in pipeVertexUVs)
{
if (pipeVertexUV.Count > 0)
handle.DrawPrimitives(DrawPrimitiveTopology.TriangleList, pipeVertexUV.Span, color);
}
}
}

private List<AtmosMonitoringConsoleLine> GetDecodedAtmosPipeChunks(Dictionary<Vector2i, AtmosPipeChunk>? chunks, MapGridComponent? grid)
{
var decodedOutput = new List<AtmosMonitoringConsoleLine>();

if (chunks == null || grid == null)
return decodedOutput;

// Clear stale look up table values
_horizLines.Clear();
_horizLinesReversed.Clear();
_vertLines.Clear();
_vertLinesReversed.Clear();

// Generate masks
var northMask = (ulong)1 << 0;
var southMask = (ulong)1 << 1;
var westMask = (ulong)1 << 2;
var eastMask = (ulong)1 << 3;

foreach ((var chunkOrigin, var chunk) in chunks)
{
var list = new List<AtmosMonitoringConsoleLine>();

foreach (var ((netId, hexColor), atmosPipeData) in chunk.AtmosPipeData)
{
// Determine the correct coloration for the pipe
var color = Color.FromHex(hexColor) * _basePipeNetColor;

if (FocusNetId != null && FocusNetId != netId)
color *= _unfocusedPipeNetColor;

// Get the associated line look up tables
if (!_horizLines.TryGetValue(color, out var horizLines))
{
horizLines = new();
_horizLines[color] = horizLines;
}

if (!_horizLinesReversed.TryGetValue(color, out var horizLinesReversed))
{
horizLinesReversed = new();
_horizLinesReversed[color] = horizLinesReversed;
}

if (!_vertLines.TryGetValue(color, out var vertLines))
{
vertLines = new();
_vertLines[color] = vertLines;
}

if (!_vertLinesReversed.TryGetValue(color, out var vertLinesReversed))
{
vertLinesReversed = new();
_vertLinesReversed[color] = vertLinesReversed;
}

// Loop over the chunk
for (var tileIdx = 0; tileIdx < ChunkSize * ChunkSize; tileIdx++)
{
if (atmosPipeData == 0)
continue;

var mask = (ulong)SharedNavMapSystem.AllDirMask << tileIdx * SharedNavMapSystem.Directions;

if ((atmosPipeData & mask) == 0)
continue;

var relativeTile = GetTileFromIndex(tileIdx);
var tile = (chunk.Origin * ChunkSize + relativeTile) * grid.TileSize;
tile = tile with { Y = -tile.Y };

// Calculate the draw point offsets
var vertLineOrigin = (atmosPipeData & northMask << tileIdx * SharedNavMapSystem.Directions) > 0 ?
new Vector2(grid.TileSize * 0.5f, -grid.TileSize * 1f) : new Vector2(grid.TileSize * 0.5f, -grid.TileSize * 0.5f);

var vertLineTerminus = (atmosPipeData & southMask << tileIdx * SharedNavMapSystem.Directions) > 0 ?
new Vector2(grid.TileSize * 0.5f, -grid.TileSize * 0f) : new Vector2(grid.TileSize * 0.5f, -grid.TileSize * 0.5f);

var horizLineOrigin = (atmosPipeData & eastMask << tileIdx * SharedNavMapSystem.Directions) > 0 ?
new Vector2(grid.TileSize * 1f, -grid.TileSize * 0.5f) : new Vector2(grid.TileSize * 0.5f, -grid.TileSize * 0.5f);

var horizLineTerminus = (atmosPipeData & westMask << tileIdx * SharedNavMapSystem.Directions) > 0 ?
new Vector2(grid.TileSize * 0f, -grid.TileSize * 0.5f) : new Vector2(grid.TileSize * 0.5f, -grid.TileSize * 0.5f);

// Since we can have pipe lines that have a length of a half tile,
// double the vectors and convert to vector2i so we can merge them
AddOrUpdateNavMapLine(ConvertVector2ToVector2i(tile + horizLineOrigin, 2), ConvertVector2ToVector2i(tile + horizLineTerminus, 2), horizLines, horizLinesReversed);
AddOrUpdateNavMapLine(ConvertVector2ToVector2i(tile + vertLineOrigin, 2), ConvertVector2ToVector2i(tile + vertLineTerminus, 2), vertLines, vertLinesReversed);
}
}
}

// Scale the vector2is back down and convert to vector2
foreach (var (color, horizLines) in _horizLines)
{
// Get the corresponding sRBG color
var sRGB = GetsRGBColor(color);

foreach (var (origin, terminal) in horizLines)
decodedOutput.Add(new AtmosMonitoringConsoleLine
(ConvertVector2iToVector2(origin, 0.5f), ConvertVector2iToVector2(terminal, 0.5f), sRGB));
}

foreach (var (color, vertLines) in _vertLines)
{
// Get the corresponding sRBG color
var sRGB = GetsRGBColor(color);

foreach (var (origin, terminal) in vertLines)
decodedOutput.Add(new AtmosMonitoringConsoleLine
(ConvertVector2iToVector2(origin, 0.5f), ConvertVector2iToVector2(terminal, 0.5f), sRGB));
}

return decodedOutput;
}

private Vector2 ConvertVector2iToVector2(Vector2i vector, float scale = 1f)
{
return new Vector2(vector.X * scale, vector.Y * scale);
}

private Vector2i ConvertVector2ToVector2i(Vector2 vector, float scale = 1f)
{
return new Vector2i((int)MathF.Round(vector.X * scale), (int)MathF.Round(vector.Y * scale));
}

private Vector2i GetTileFromIndex(int index)
{
var x = index / ChunkSize;
var y = index % ChunkSize;
return new Vector2i(x, y);
}

private Color GetsRGBColor(Color color)
{
if (!_sRGBLookUp.TryGetValue(color, out var sRGB))
{
sRGB = Color.ToSrgb(color);
_sRGBLookUp[color] = sRGB;
}

return sRGB;
}
}

public struct AtmosMonitoringConsoleLine
{
public readonly Vector2 Origin;
public readonly Vector2 Terminus;
public readonly Color Color;

public AtmosMonitoringConsoleLine(Vector2 origin, Vector2 terminus, Color color)
{
Origin = origin;
Terminus = terminus;
Color = color;
}
}
Loading
Loading