Add logs for research (#18388)

* Add logs for research

* Update Content.Server/Research/Systems/ResearchSystem.Technology.cs

Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>

* dumb but ok

* wacka wacka

* Update LogType.cs

---------

Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
This commit is contained in:
Nemanja 2023-07-29 00:14:39 -04:00 committed by GitHub
parent 3e73a7f750
commit e03974a0a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -31,7 +31,7 @@ public sealed partial class ResearchSystem
return;
}
if (!UnlockTechnology(uid, args.Id))
if (!UnlockTechnology(uid, args.Id, ent))
return;
SyncClientWithServer(uid);

View File

@ -1,3 +1,4 @@
using Content.Shared.Database;
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using JetBrains.Annotations;
@ -47,13 +48,16 @@ public sealed partial class ResearchSystem
/// Tries to add a technology to a database, checking if it is able to
/// </summary>
/// <returns>If the technology was successfully added</returns>
public bool UnlockTechnology(EntityUid client, string prototypeid, ResearchClientComponent? component = null,
public bool UnlockTechnology(EntityUid client,
string prototypeid,
EntityUid user,
ResearchClientComponent? component = null,
TechnologyDatabaseComponent? clientDatabase = null)
{
if (!PrototypeManager.TryIndex<TechnologyPrototype>(prototypeid, out var prototype))
return false;
return UnlockTechnology(client, prototype, component, clientDatabase);
return UnlockTechnology(client, prototype, user, component, clientDatabase);
}
/// <summary>
@ -62,6 +66,7 @@ public sealed partial class ResearchSystem
/// <returns>If the technology was successfully added</returns>
public bool UnlockTechnology(EntityUid client,
TechnologyPrototype prototype,
EntityUid user,
ResearchClientComponent? component = null,
TechnologyDatabaseComponent? clientDatabase = null)
{
@ -78,6 +83,9 @@ public sealed partial class ResearchSystem
TrySetMainDiscipline(prototype, serverEnt.Value);
ModifyServerPoints(serverEnt.Value, -prototype.Cost);
UpdateTechnologyCards(serverEnt.Value);
_adminLog.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(user):player} unlocked {prototype.ID} (discipline: {prototype.Discipline}, tier: {prototype.Tier}) at {ToPrettyString(client)}, for server {ToPrettyString(serverEnt.Value)}.");
return true;
}

View File

@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Shared.Access.Systems;
using Content.Shared.Popups;
using Content.Shared.Research.Components;
@ -13,6 +14,7 @@ namespace Content.Server.Research.Systems
[UsedImplicitly]
public sealed partial class ResearchSystem : SharedResearchSystem
{
[Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;