Add mind and ghost logs (#13306)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
@@ -7,6 +8,7 @@ using Content.Server.MobState;
|
||||
using Content.Server.Objectives;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Roles;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
@@ -32,6 +34,7 @@ namespace Content.Server.Mind
|
||||
private readonly MindSystem _mindSystem = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
|
||||
private readonly ISet<Role> _roles = new HashSet<Role>();
|
||||
|
||||
@@ -177,6 +180,21 @@ namespace Content.Server.Mind
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string to represent the mind for logging
|
||||
/// </summary>
|
||||
private string MindOwnerLoggingString
|
||||
{
|
||||
get
|
||||
{
|
||||
if (OwnedEntity != null)
|
||||
return _entityManager.ToPrettyString(OwnedEntity.Value);
|
||||
if (UserId != null)
|
||||
return UserId.Value.ToString();
|
||||
return "(originally " + OriginalOwnerUserId + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gives this mind a new role.
|
||||
/// </summary>
|
||||
@@ -200,6 +218,8 @@ namespace Content.Server.Mind
|
||||
{
|
||||
_entityManager.EventBus.RaiseLocalEvent(OwnedEntity.Value, message, true);
|
||||
}
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.Low,
|
||||
$"'{role.Name}' added to mind of {MindOwnerLoggingString}");
|
||||
|
||||
return role;
|
||||
}
|
||||
@@ -226,6 +246,8 @@ namespace Content.Server.Mind
|
||||
{
|
||||
_entityManager.EventBus.RaiseLocalEvent(OwnedEntity.Value, message, true);
|
||||
}
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.Low,
|
||||
$"'{role.Name}' removed from mind of {MindOwnerLoggingString}");
|
||||
}
|
||||
|
||||
public bool HasRole<T>() where T : Role
|
||||
@@ -250,6 +272,11 @@ namespace Content.Server.Mind
|
||||
var objective = objectivePrototype.GetObjective(this);
|
||||
if (_objectives.Contains(objective))
|
||||
return false;
|
||||
|
||||
foreach (var condition in objective.Conditions)
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.Low, $"'{condition.Title}' added to mind of {MindOwnerLoggingString}");
|
||||
|
||||
|
||||
_objectives.Add(objective);
|
||||
return true;
|
||||
}
|
||||
@@ -263,6 +290,10 @@ namespace Content.Server.Mind
|
||||
if (_objectives.Count >= index) return false;
|
||||
|
||||
var objective = _objectives[index];
|
||||
|
||||
foreach (var condition in objective.Conditions)
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.Low, $"'{condition.Title}' removed from the mind of {MindOwnerLoggingString}");
|
||||
|
||||
_objectives.Remove(objective);
|
||||
return true;
|
||||
}
|
||||
@@ -404,8 +435,13 @@ namespace Content.Server.Mind
|
||||
/// </summary>
|
||||
public void UnVisit()
|
||||
{
|
||||
var currentEntity = Session?.AttachedEntity;
|
||||
Session?.AttachToEntity(OwnedEntity);
|
||||
RemoveVisitingEntity();
|
||||
|
||||
if (Session != null && OwnedEntity != null && currentEntity != OwnedEntity)
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.Low,
|
||||
$"{Session.Name} returned to {_entityManager.ToPrettyString(OwnedEntity.Value)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user