Add mind and ghost logs (#13306)

This commit is contained in:
Chief-Engineer
2023-01-04 00:49:15 -06:00
committed by GitHub
parent 0907989e94
commit 1ceff51a69
5 changed files with 61 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ namespace Content.Server.Chat
if (!TryComp<MobStateComponent>(victim, out var mobState) || _mobState.IsDead(victim, mobState))
return false;
_adminLogger.Add(LogType.Suicide, $"{EntityManager.ToPrettyString(victim):player} is committing suicide");
_adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(victim):player} is attempting to suicide");
var suicideEvent = new SuicideEvent(victim);
@@ -41,9 +41,12 @@ namespace Content.Server.Chat
if (SuicideAttemptBlocked(victim, suicideEvent))
return false;
bool environmentSuicide = false;
// If you are critical, you wouldn't be able to use your surroundings to suicide, so you do the default suicide
if (!_mobState.IsCritical(victim, mobState))
EnvironmentSuicideHandler(victim, suicideEvent);
{
environmentSuicide = EnvironmentSuicideHandler(victim, suicideEvent);
}
if (suicideEvent.AttemptBlocked)
return false;
@@ -51,6 +54,7 @@ namespace Content.Server.Chat
DefaultSuicideHandler(victim, suicideEvent);
ApplyDeath(victim, suicideEvent.Kind!.Value);
_adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(victim):player} suicided{(environmentSuicide ? " (environment)" : "")}");
return true;
}
@@ -87,7 +91,7 @@ namespace Content.Server.Chat
/// <summary>
/// Raise event to attempt to use held item, or surrounding entities to attempt to commit suicide
/// </summary>
private void EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
private bool EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
{
var itemQuery = GetEntityQuery<ItemComponent>();
@@ -98,7 +102,7 @@ namespace Content.Server.Chat
RaiseLocalEvent(item, suicideEvent, false);
if (suicideEvent.Handled)
return;
return true;
}
// Suicide by nearby entity (ex: Microwave)
@@ -111,8 +115,10 @@ namespace Content.Server.Chat
RaiseLocalEvent(entity, suicideEvent, false);
if (suicideEvent.Handled)
break;
return true;
}
return false;
}
private void ApplyDeath(EntityUid target, SuicideKind kind)