diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs index 979e8565e8..c6449f9a88 100644 --- a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs @@ -1,3 +1,4 @@ +using Content.Server.Administration.Logs; using Content.Server.Singularity.Events; using Content.Shared.Singularity.Components; using Content.Shared.Tag; @@ -5,6 +6,7 @@ using Robust.Server.GameObjects; using Robust.Shared.Physics; using Content.Server.Popups; using Content.Shared.Construction.Components; +using Content.Shared.Database; using Content.Shared.Examine; using Content.Shared.Interaction; using Content.Shared.Popups; @@ -15,6 +17,7 @@ namespace Content.Server.Singularity.EntitySystems; public sealed class ContainmentFieldGeneratorSystem : EntitySystem { + [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly TagSystem _tags = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly PhysicsSystem _physics = default!; @@ -38,7 +41,8 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem { base.Update(frameTime); - foreach (var generator in EntityQuery()) + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var generator)) { if (generator.PowerBuffer <= 0) //don't drain power if there's no power, or if it's somehow less than 0. continue; @@ -47,7 +51,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem if (generator.Accumulator >= generator.Threshold) { - LosePower(generator.PowerLoss, generator); + LosePower(uid, generator.PowerLoss, generator); generator.Accumulator -= generator.Threshold; } } @@ -99,12 +103,12 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem private void OnAnchorChanged(EntityUid uid, ContainmentFieldGeneratorComponent component, ref AnchorStateChangedEvent args) { if (!args.Anchored) - RemoveConnections(component); + RemoveConnections(uid, component); } private void OnReanchorEvent(EntityUid uid, ContainmentFieldGeneratorComponent component, ref ReAnchorEvent args) { - GridCheck(component); + GridCheck(uid, component); } private void OnUnanchorAttempt(EntityUid uid, ContainmentFieldGeneratorComponent component, @@ -133,13 +137,13 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem private void OnComponentRemoved(EntityUid uid, ContainmentFieldGeneratorComponent component, ComponentRemove args) { - RemoveConnections(component); + RemoveConnections(uid, component); } /// /// Deletes the fields and removes the respective connections for the generators. /// - private void RemoveConnections(ContainmentFieldGeneratorComponent component) + private void RemoveConnections(EntityUid uid, ContainmentFieldGeneratorComponent component) { foreach (var (direction, value) in component.Connections) { @@ -161,6 +165,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem component.IsConnected = false; ChangeOnLightVisualizer(component); ChangeFieldVisualizer(component); + _adminLogger.Add(LogType.FieldGeneration, LogImpact.Medium, $"{ToPrettyString(uid)} lost field connections"); // Ideally LogImpact would depend on if there is a singulo nearby _popupSystem.PopupEntity(Loc.GetString("comp-containment-disconnected"), component.Owner, PopupType.LargeCaution); } @@ -195,13 +200,13 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem ChangePowerVisualizer(power, component); } - public void LosePower(int power, ContainmentFieldGeneratorComponent component) + public void LosePower(EntityUid uid, int power, ContainmentFieldGeneratorComponent component) { component.PowerBuffer -= power; if (component.PowerBuffer < component.PowerMinimum && component.Connections.Count != 0) { - RemoveConnections(component); + RemoveConnections(uid, component); } ChangePowerVisualizer(power, component); @@ -329,7 +334,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem /// /// Checks to see if this or the other gens connected to a new grid. If they did, remove connection. /// - public void GridCheck(ContainmentFieldGeneratorComponent component) + public void GridCheck(EntityUid uid, ContainmentFieldGeneratorComponent component) { var xFormQuery = GetEntityQuery(); @@ -339,7 +344,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem var gent2ParentGrid = xFormQuery.GetComponent(generators.Item1.Owner).ParentUid; if (gen1ParentGrid != gent2ParentGrid) - RemoveConnections(component); + RemoveConnections(uid, component); } } diff --git a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs index 14344091f1..7a86154dd0 100644 --- a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs @@ -88,7 +88,7 @@ namespace Content.Server.Singularity.EntitySystems ("target", uid)), uid, args.User); } - _adminLogger.Add(LogType.Emitter, + _adminLogger.Add(LogType.FieldGeneration, component.IsOn ? LogImpact.Medium : LogImpact.High, $"{ToPrettyString(args.User):player} toggled {ToPrettyString(uid):emitter}"); args.Handled = true; diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index 97e9fb9f31..3f3c83b47e 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -1,3 +1,4 @@ +using Content.Server.Administration.Logs; using Robust.Shared.Containers; using Robust.Shared.Timing; using Robust.Shared.Map; @@ -8,9 +9,12 @@ using Content.Shared.Singularity.Components; using Content.Shared.Singularity.EntitySystems; using Content.Server.Ghost.Components; +using Content.Server.Mind.Components; using Content.Server.Station.Components; using Content.Server.Singularity.Components; using Content.Server.Singularity.Events; +using Content.Shared.Database; +using Content.Shared.Tag; namespace Content.Server.Singularity.EntitySystems; @@ -24,7 +28,9 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IMapManager _mapMan = default!; + [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; + [Dependency] private readonly TagSystem _tagSystem = default!; #endregion Dependencies /// @@ -123,8 +129,16 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem /// The innermost container of the entity to consume that isn't also being consumed by the event horizon. public void ConsumeEntity(EntityUid uid, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) { + var eventHorizonOwner = eventHorizon.Owner; + + if (!EntityManager.IsQueuedForDeletion(uid) && // I saw it log twice a few times for some reason? + (HasComp(uid) || + _tagSystem.HasTag(uid, "HighRiskItem") || + HasComp(uid))) + _adminLogger.Add(LogType.EntityDelete, LogImpact.Extreme, $"{ToPrettyString(uid)} entered the event horizon of {ToPrettyString(eventHorizonOwner)} and was deleted"); + EntityManager.QueueDeleteEntity(uid); - RaiseLocalEvent(eventHorizon.Owner, new EntityConsumedByEventHorizonEvent(uid, eventHorizon, outerContainer)); + RaiseLocalEvent(eventHorizonOwner, new EntityConsumedByEventHorizonEvent(uid, eventHorizon, outerContainer)); RaiseLocalEvent(uid, new EventHorizonConsumedEntityEvent(uid, eventHorizon, outerContainer)); } diff --git a/Content.Shared.Database/LogType.cs b/Content.Shared.Database/LogType.cs index 4b69a0bb44..48f8bf6a04 100644 --- a/Content.Shared.Database/LogType.cs +++ b/Content.Shared.Database/LogType.cs @@ -60,7 +60,7 @@ public enum LogType AtmosVolumeChanged = 56, AtmosFilterChanged = 57, AtmosRatioChanged = 58, - Emitter = 59, + FieldGeneration = 59, GhostRoleTaken = 60, Chat = 61, Action = 62,