diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index 98ce5e0e13..2493c2a512 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Atmos; using JetBrains.Annotations; using Robust.Shared.Map; using Robust.Shared.Map.Components; +using Content.Shared.Destructible; namespace Content.Server.Atmos.EntitySystems { @@ -90,7 +91,7 @@ namespace Content.Server.Atmos.EntitySystems airtight.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation); UpdatePosition(airtight, ev.Component); var airtightEv = new AirtightChanged(uid, airtight); - RaiseLocalEvent(uid, ref airtightEv); + RaiseLocalEvent(uid, ref airtightEv, true); return true; } @@ -104,7 +105,7 @@ namespace Content.Server.Atmos.EntitySystems airtight.AirBlocked = airblocked; UpdatePosition(airtight, xform); var airtightEv = new AirtightChanged(uid, airtight); - RaiseLocalEvent(uid, ref airtightEv); + RaiseLocalEvent(uid, ref airtightEv, true); } public void UpdatePosition(AirtightComponent airtight, TransformComponent? xform = null) diff --git a/Content.Server/Spreader/SpreadGroupUpdateRate.cs b/Content.Server/Spreader/SpreadGroupUpdateRate.cs index 03c7c11512..091c6e5ad5 100644 --- a/Content.Server/Spreader/SpreadGroupUpdateRate.cs +++ b/Content.Server/Spreader/SpreadGroupUpdateRate.cs @@ -4,4 +4,4 @@ namespace Content.Server.Spreader; /// Raised every tick to determine how many updates a particular spreading node group is allowed. /// [ByRefEvent] -public record struct SpreadGroupUpdateRate(string Name, int UpdatesPerSecond = 16); \ No newline at end of file +public record struct SpreadGroupUpdateRate(string Name, int UpdatesPerSecond = 16); diff --git a/Content.Server/Spreader/SpreaderSystem.cs b/Content.Server/Spreader/SpreaderSystem.cs index 814275adb9..574b7b0bf4 100644 --- a/Content.Server/Spreader/SpreaderSystem.cs +++ b/Content.Server/Spreader/SpreaderSystem.cs @@ -87,7 +87,6 @@ public sealed class SpreaderSystem : EntitySystem private void OnGridInit(GridInitializeEvent ev) { var comp = EnsureComp(ev.EntityUid); - } /// @@ -95,7 +94,7 @@ public sealed class SpreaderSystem : EntitySystem { var curTime = _timing.CurTime; - // Check which grids are valid for spreading. + // Check which grids are valid for spreading var spreadable = new ValueList(); var spreadGrids = EntityQueryEnumerator(); @@ -116,10 +115,13 @@ public sealed class SpreaderSystem : EntitySystem var xformQuery = GetEntityQuery(); var gridQuery = GetEntityQuery(); - // Events and stuff + // Each INode group has a certain number of updates + // allowed per SpreadCooldown var groupUpdates = new Dictionary(); + var spreaders = new List<(EntityUid Uid, EdgeSpreaderComponent Comp)>(Count()); + // Build a list of all existing Edgespreaders, shuffle them while (query.MoveNext(out var uid, out var comp)) { spreaders.Add((uid, comp)); @@ -127,6 +129,8 @@ public sealed class SpreaderSystem : EntitySystem _robustRandom.Shuffle(spreaders); + // Remove the EdgeSpreaderComponent from any entity + // that doesn't meet a few trivial prerequisites foreach (var (uid, comp) in spreaders) { if (!xformQuery.TryGetComponent(uid, out var xform) || @@ -139,7 +143,7 @@ public sealed class SpreaderSystem : EntitySystem foreach (var sGroup in _spreaderGroups) { - // Cleanup + // Get the NodeContainer and Node from every EdgeSpreader entity found if (!nodeQuery.TryGetComponent(uid, out var nodeContainer)) { RemCompDeferred(uid); @@ -147,7 +151,9 @@ public sealed class SpreaderSystem : EntitySystem } if (!_nodeContainer.TryGetNode(nodeContainer, sGroup, out var node)) + { continue; + } // Not allowed this tick? if (node.NodeGroup == null || @@ -156,8 +162,8 @@ public sealed class SpreaderSystem : EntitySystem continue; } - // While we could check if it's an edge here the subscribing system may have its own definition - // of an edge so we'll let them handle it. + // Try get an integer update rate associated with a node group, + // getting it instead from the spreader itself on failure if (!groupUpdates.TryGetValue(node.NodeGroup, out var updates)) { var spreadEv = new SpreadGroupUpdateRate(node.Name); @@ -165,11 +171,17 @@ public sealed class SpreaderSystem : EntitySystem updates = (int) (spreadEv.UpdatesPerSecond * SpreadCooldown / TimeSpan.FromSeconds(1)); } + // "updates" integer dictates the amount of nodes that + // are to be spawned around a NodeGroup if (updates <= 0) { continue; } + // Edge detection logic is to be handled + // by the subscribing system, see KudzuSystem + // for a simple example + Spread(uid, node, node.NodeGroup, ref updates); groupUpdates[node.NodeGroup] = updates; }