Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Content.Server/Anomaly/AnomalySystem.Vessel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ private void OnVesselGetPointsPerSecond(EntityUid uid, AnomalyVesselComponent co
if (!this.IsPowered(uid, EntityManager) || component.Anomaly is not {} anomaly)
return;

args.Points += (int) (GetAnomalyPointValue(anomaly) * component.PointMultiplier);
// DeltaV - start of research statistics admin logs
args.Sources.Add(new ResearchServerPointsPerSecondSource(
Source: uid,
PointsPerSecond: (int) (GetAnomalyPointValue(anomaly) * component.PointMultiplier)
));
// DeltaV - end of research statistics admin logs
}

private void OnVesselAnomalyShutdown(ref AnomalyShutdownEvent args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Shared.Abilities.Psionics;
using Content.Shared.Actions;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Psionics.Glimmer;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
Expand All @@ -23,6 +25,7 @@ public sealed class PsionicAbilitiesSystem : EntitySystem
[Dependency] private readonly SharedJitteringSystem _jittering = default!;
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -123,7 +126,13 @@ public void RemovePsionics(EntityUid uid)
}
}

_glimmerSystem.Glimmer -= _random.Next(50, 70);
var glimmerBurned = _random.Next(50, 70);
_glimmerSystem.Glimmer -= glimmerBurned;
_adminLogger.Add(
LogType.Glimmer,
LogImpact.Low,
$"{ToPrettyString(uid)} drained {glimmerBurned} glimmer through mindbreaking"
);

_statusEffectsSystem.TryAddStatusEffect(uid, "Stutter", TimeSpan.FromMinutes(1), false, "StutteringAccent");
_statusEffectsSystem.TryAddStatusEffect(uid, "KnockedDown", TimeSpan.FromSeconds(3), false, "KnockedDown");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Robust.Shared.Timing;
using Robust.Shared.Configuration;
using Content.Shared._DV.CCVars;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Psionics.Glimmer;
using Content.Shared.GameTicking;
using Content.Server.CartridgeLoader.Cartridges;
Expand All @@ -18,6 +20,7 @@ public sealed class PassiveGlimmerReductionSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly GlimmerMonitorCartridgeSystem _cartridgeSys = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;

/// List of glimmer values spaced by minute.
public List<int> GlimmerValues = new();
Expand Down Expand Up @@ -60,6 +63,14 @@ public override void Update(float frameTime)
var actualGlimmerLost = _random.Next(0, 1 + maxGlimmerLost);

_glimmerSystem.Glimmer -= actualGlimmerLost;
if (actualGlimmerLost > 0)
{
_adminLogger.Add(
LogType.Glimmer,
LogImpact.Low,
$"system drained {actualGlimmerLost} glimmer passively"
);
}

_updateIncrementor++;

Expand All @@ -68,6 +79,12 @@ public override void Update(float frameTime)
{
GlimmerValues.Add(_glimmerSystem.Glimmer);

_adminLogger.Add(
LogType.Glimmer,
LogImpact.Low,
$"current glimmer: {_glimmerSystem.Glimmer}"
);

_updateIncrementor = 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Content.Server.Anomaly.Components;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Administration.Logs;
using Content.Shared.Anomaly.Components;
using Content.Shared.Database;
using Content.Shared.Power;
using Content.Shared.Psionics.Glimmer;

Expand All @@ -14,6 +16,7 @@ public sealed class GlimmerStructuresSystem : EntitySystem
{
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -78,6 +81,11 @@ public override void Update(float frameTime)
{
_glimmerSystem.Glimmer--;
}
_adminLogger.Add(
LogType.Glimmer,
LogImpact.Low,
$"{ToPrettyString(source.Owner)} {(source.AddToGlimmer ? "produced" : "drained")} 1 glimmer passively"
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private void InitializeSource()
private void OnGetPointsPerSecond(Entity<ResearchPointSourceComponent> source, ref ResearchServerGetPointsPerSecondEvent args)
{
if (CanProduce(source))
args.Points += source.Comp.PointsPerSecond;
args.Sources.Add(new ResearchServerPointsPerSecondSource(source, source.Comp.PointsPerSecond)); // DeltaV - research statistics admin logs
}

public bool CanProduce(Entity<ResearchPointSourceComponent> source)
Expand Down
46 changes: 39 additions & 7 deletions Content.Server/Research/Systems/ResearchSystem.Server.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Linq;
using System.Text; // DeltaV
using Content.Server.Power.EntitySystems;
using Content.Shared.Database; // DeltaV
using Content.Shared.Research.Components;

namespace Content.Server.Research.Systems;
Expand Down Expand Up @@ -49,7 +51,34 @@ private void UpdateServer(EntityUid uid, int time, ResearchServerComponent? comp

if (!CanRun(uid))
return;
ModifyServerPoints(uid, GetPointsPerSecond(uid, component) * time, component);

// DeltaV - start of research statistics admin logs
int points = 0;
var sources = GetPointsPerSecond(uid, component);
if (sources.Count > 0)
{
var pointsStr = new StringBuilder();
foreach (var source in sources)
{
var sourcePoints = source.PointsPerSecond * time;
points += sourcePoints;
pointsStr.Append(sourcePoints);
pointsStr.Append(" points from ");
pointsStr.Append(ToPrettyString(source.Source));
pointsStr.Append(", ");
}
if (sources.Any(source => source.PointsPerSecond != 0))
{
_adminLogger.Add(
LogType.Research,
LogImpact.Low,
$"{ToPrettyString(uid)} collected {points} points from {sources.Count} sources over {time} seconds: {pointsStr}"
);
}
}

ModifyServerPoints(uid, points, component);
// DeltaV - end of research statistics admin logs
}

/// <summary>
Expand Down Expand Up @@ -130,22 +159,25 @@ public void UnregisterClient(EntityUid client, EntityUid server, ResearchClientC
/// <param name="uid"></param>
/// <param name="component"></param>
/// <returns></returns>
public int GetPointsPerSecond(EntityUid uid, ResearchServerComponent? component = null)
/// <remarks>
/// DeltaV - changed return type as part of research statistics admin logs
/// </remarks>
public List<ResearchServerPointsPerSecondSource> GetPointsPerSecond(EntityUid uid, ResearchServerComponent? component = null)
{
var points = 0;
var sources = new List<ResearchServerPointsPerSecondSource>(); // DeltaV - research statistics admin logs

if (!Resolve(uid, ref component))
return points;
return sources; // DeltaV - rename

if (!CanRun(uid))
return points;
return sources; // DeltaV - rename

var ev = new ResearchServerGetPointsPerSecondEvent(uid, points);
var ev = new ResearchServerGetPointsPerSecondEvent(uid, sources); // DeltaV - rename
foreach (var client in component.Clients)
{
RaiseLocalEvent(client, ref ev);
}
return ev.Points;
return ev.Sources; // DeltaV - rename
}

/// <summary>
Expand Down
26 changes: 22 additions & 4 deletions Content.Server/Research/Systems/ResearchSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using Content.Server.Radio.EntitySystems;
using Content.Shared._DV.Shuttles.Components; // DeltaV
using Content.Shared.Access.Systems;
using Content.Shared.Administration.Logs; // DeltaV
using Content.Shared.Database; // DeltaV
using Content.Shared.Popups;
using Content.Shared.Research.Components;
using Content.Shared.Research.Systems;
Expand All @@ -23,6 +25,7 @@ public sealed partial class ResearchSystem : SharedResearchSystem
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly RadioSystem _radio = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; // DeltaV - research statistics admin logs

private static readonly HashSet<Entity<ResearchServerComponent>> ClientLookup = new();

Expand Down Expand Up @@ -125,11 +128,26 @@ public override void Update(float frameTime)
var query = EntityQueryEnumerator<ResearchServerComponent>();
while (query.MoveNext(out var uid, out var server))
{
if (server.NextUpdateTime > _timing.CurTime)
continue;
server.NextUpdateTime = _timing.CurTime + server.ResearchConsoleUpdateTime;
// DeltaV - inverted the if-continue pattern to make room for research statistics admin logs
if (server.NextUpdateTime <= _timing.CurTime)
{
server.NextUpdateTime = _timing.CurTime + server.ResearchConsoleUpdateTime;

UpdateServer(uid, (int) server.ResearchConsoleUpdateTime.TotalSeconds, server);
}

// DeltaV - start of research statistics admin logs
if (server.NextAdminLogTime <= _timing.CurTime)
{
server.NextAdminLogTime = _timing.CurTime + server.ResearchServerAdminLogTime;

UpdateServer(uid, (int) server.ResearchConsoleUpdateTime.TotalSeconds, server);
_adminLogger.Add(
LogType.Research,
LogImpact.Low,
$"current points in {ToPrettyString(uid)}: {server.Points}"
);
}
// DeltaV - end of research statistics admin logs
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions Content.Server/Xenoarchaeology/Artifact/XenoArtifactSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Text; // DeltaV
using Content.Shared.Administration.Logs; // DeltaV
using Content.Shared.Cargo;
using Content.Shared.Database; // DeltaV
using Content.Shared.Xenoarchaeology.Artifact;
using Content.Shared.Xenoarchaeology.Artifact.Components;

Expand All @@ -7,6 +10,8 @@ namespace Content.Server.Xenoarchaeology.Artifact;
/// <inheritdoc cref="SharedXenoArtifactSystem"/>
public sealed partial class XenoArtifactSystem : SharedXenoArtifactSystem
{
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; // DeltaV - research statistics admin logs

/// <inheritdoc/>
public override void Initialize()
{
Expand All @@ -20,6 +25,31 @@ private void OnArtifactMapInit(Entity<XenoArtifactComponent> ent, ref MapInitEve
{
if (ent.Comp.IsGenerationRequired)
GenerateArtifactStructure(ent);

// DeltaV - start of research statistics admin logs
foreach (var node in GetAllNodes(ent))
{
var effectStatusString = node.Comp.LockedEffectTipHidden ? "Hidden" : node.Comp.LockedEffectTipVague ? "Vague" : "Specific";

var triggerStr = new StringBuilder();
var predecessors = GetPredecessorNodes((ent, ent), node);
triggerStr.Append(predecessors.Count + 1);
triggerStr.Append(" triggers: ");
triggerStr.Append(node.Comp.TriggerTip ?? "Unknown");
foreach (var predecessor in predecessors)
{
triggerStr.Append(",");
triggerStr.Append(predecessor.Comp.TriggerTip ?? "Unknown");
}

_adminLogger.Add(
LogType.ArtifactDetails,
LogImpact.Low,
// note: effect type is already logged by ToPrettyString(node)
$"{ToPrettyString(ent.Owner)} spawned with node {ToPrettyString(node)} with depth {node.Comp.Depth}; effect status {effectStatusString}; {triggerStr.ToString()}"
);
}
// DeltaV - end of research statistics admin logs
}

private void OnCalculatePrice(Entity<XenoArtifactComponent> ent, ref PriceCalculationEvent args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System; // DeltaV
using Content.Server.Research.Systems;
using Content.Server.Xenoarchaeology.Artifact;
using Content.Shared.Administration.Logs; // DeltaV
using Content.Shared.Database; // DeltaV
using Content.Shared.Popups;
using Content.Shared.Psionics.Glimmer;// DeltaV
using Content.Shared._DV.Xenoarchaeology.BUI;// DeltaV
Expand All @@ -22,6 +24,7 @@ public sealed class ArtifactAnalyzerSystem : SharedArtifactAnalyzerSystem
[Dependency] private readonly XenoArtifactSystem _xenoArtifact = default!;
[Dependency] private readonly GlimmerSystem _glimmerSystem = default!; // DeltaV
[Dependency] private readonly ArtifactAnalyzerSystem _analyzerSystem = default!; //DeltaV
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; // DeltaV

/// <inheritdoc/>
public override void Initialize()
Expand All @@ -44,20 +47,40 @@ private void OnExtractButtonPressed(Entity<AnalysisConsoleComponent> ent, ref An
var sumGlimmer = 0;
if (!_analyzerSystem.TryGetAnalyzer(ent, out var analyzer))
return;
var glimmerMultiplier = GetGlimmerMultiplier(analyzer.Value.Comp);
// End DeltaV

foreach (var node in _xenoArtifact.GetAllNodes(artifact.Value))
{
var research = _xenoArtifact.GetResearchValue(node);
_xenoArtifact.SetConsumedResearchValue(node, node.Comp.ConsumedResearchValue + research);

// Begin DeltaV - Only run if we have an artifact ready for extraction
if (analyzer != null)
// Begin DeltaV - glimmer interaction & research statistics admin logs
var subtotalResearch = research;
research = (int)(subtotalResearch * glimmerMultiplier);
var glimmer = (int)(subtotalResearch / (float)analyzer.Value.Comp.ExtractRatio);

if (research > 0 || glimmer > 0)
{
sumGlimmer += (int)(research / (float)analyzer.Value.Comp.ExtractRatio);
research = (int)(research * GetGlimmerMultiplier(analyzer.Value.Comp));
// Log all the variables that affect research value (see UpdateNodeResearchValue).
var predecessors = _xenoArtifact.GetPredecessorNodes((artifact.Value, artifact.Value), node);
_adminLogger.Add(
LogType.ArtifactDetails,
LogImpact.Low,
$"{ToPrettyString(ent.Owner)} extracted {research} points and {glimmer} glimmer from node {ToPrettyString(node)}. Details: base {node.Comp.BasePointValue}; predecessors {predecessors.Count}; durability {node.Comp.Durability}/{node.Comp.MaxDurability}; subtotal {subtotalResearch}; glimmerMultiplier {glimmerMultiplier}"
);
}
// End DeltaV
if (glimmer > 0)
{
_adminLogger.Add(
LogType.Glimmer,
LogImpact.Low,
$"{ToPrettyString(ent.Owner)} produced {glimmer} glimmer from extracting node {ToPrettyString(node)}"
);
}

sumGlimmer += glimmer;
// End DeltaV - glimmer interaction & research statistics admin logs
sumResearch += research;
}
UpdateClientUI(ent, analyzer!.Value); // DeltaV
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared.Database/LogType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ public enum LogType
BagOfHolding = 420, //Nyano - Summary: adds bag of holding.
Psionics = 421, //Nyano - Summary: ads psionic as a log type.
ObjectiveSummary = 422, // DeltaV
Glimmer = 423, // DeltaV
Research = 424, // DeltaV
ArtifactDetails = 425, // DeltaV

/// <summary>
/// A client has sent too many chat messages recently and is temporarily blocked from sending more.
Expand Down
Loading
Loading