mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 08:07:28 +00:00
* yeah * split2 * well * cleanup * docs fix * Dependency cleanup * Update Content.Client/Atmos/EntitySystems/GasTileFireOverlaySystem.cs Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> * Update Content.Client/Atmos/Overlays/GasTileVisibleGasOverlay.cs Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> * Update Content.Client/Atmos/Overlays/GasTileVisibleGasOverlay.cs Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> * yup * modifying a lot anyways * other cleanup --------- Co-authored-by: Pok <113675512+Pok27@users.noreply.github.com> Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
87 lines
2.4 KiB
C#
87 lines
2.4 KiB
C#
using Content.Shared.Atmos;
|
|
using Content.Shared.Atmos.Components;
|
|
using Content.Shared.Atmos.EntitySystems;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.GameStates;
|
|
|
|
namespace Content.Client.Atmos.EntitySystems;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class GasTileOverlaySystem : SharedGasTileOverlaySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeNetworkEvent<GasOverlayUpdateEvent>(HandleGasOverlayUpdate);
|
|
SubscribeLocalEvent<GasTileOverlayComponent, ComponentHandleState>(OnHandleState);
|
|
}
|
|
|
|
private void OnHandleState(EntityUid gridUid, GasTileOverlayComponent comp, ref ComponentHandleState args)
|
|
{
|
|
Dictionary<Vector2i, GasOverlayChunk> modifiedChunks;
|
|
|
|
switch (args.Current)
|
|
{
|
|
// is this a delta or full state?
|
|
case GasTileOverlayDeltaState delta:
|
|
{
|
|
modifiedChunks = delta.ModifiedChunks;
|
|
foreach (var index in comp.Chunks.Keys)
|
|
{
|
|
if (!delta.AllChunks.Contains(index))
|
|
comp.Chunks.Remove(index);
|
|
}
|
|
|
|
break;
|
|
}
|
|
case GasTileOverlayState state:
|
|
{
|
|
modifiedChunks = state.Chunks;
|
|
foreach (var index in comp.Chunks.Keys)
|
|
{
|
|
if (!state.Chunks.ContainsKey(index))
|
|
comp.Chunks.Remove(index);
|
|
}
|
|
|
|
break;
|
|
}
|
|
default:
|
|
return;
|
|
}
|
|
|
|
foreach (var (index, data) in modifiedChunks)
|
|
{
|
|
comp.Chunks[index] = data;
|
|
}
|
|
}
|
|
|
|
private void HandleGasOverlayUpdate(GasOverlayUpdateEvent ev)
|
|
{
|
|
foreach (var (nent, removedIndicies) in ev.RemovedChunks)
|
|
{
|
|
var grid = GetEntity(nent);
|
|
|
|
if (!TryComp(grid, out GasTileOverlayComponent? comp))
|
|
continue;
|
|
|
|
foreach (var index in removedIndicies)
|
|
{
|
|
comp.Chunks.Remove(index);
|
|
}
|
|
}
|
|
|
|
foreach (var (nent, gridData) in ev.UpdatedChunks)
|
|
{
|
|
var grid = GetEntity(nent);
|
|
|
|
if (!TryComp(grid, out GasTileOverlayComponent? comp))
|
|
continue;
|
|
|
|
foreach (var chunkData in gridData)
|
|
{
|
|
comp.Chunks[chunkData.Index] = chunkData;
|
|
}
|
|
}
|
|
}
|
|
}
|