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