Fix 3000 errors

This commit is contained in:
DrSmugleaf
2021-12-05 18:09:01 +01:00
parent 2bfec7ec62
commit 2a3b7d809d
569 changed files with 2979 additions and 3280 deletions

View File

@@ -24,7 +24,7 @@ namespace Content.Server.Chat.Commands
return;
}
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
if (player.Status != SessionStatus.InGame || !player.AttachedEntity.HasValue)
return;
if (args.Length < 1)

View File

@@ -19,14 +19,13 @@ namespace Content.Server.Chat.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
if (shell.Player is not IPlayerSession player)
{
shell.WriteLine("This command cannot be run from the server.");
return;
}
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
if (player.Status != SessionStatus.InGame || !player.AttachedEntity.HasValue)
return;
if (args.Length < 1)
@@ -38,9 +37,8 @@ namespace Content.Server.Chat.Commands
var chat = IoCManager.Resolve<IChatManager>();
var chatSanitizer = IoCManager.Resolve<IChatSanitizationManager>();
var playerEntity = player.AttachedEntity;
if (playerEntity == null)
if (player.AttachedEntity is not {Valid: true} playerEntity)
{
shell.WriteLine("You don't have an entity!");
return;
@@ -58,7 +56,7 @@ namespace Content.Server.Chat.Commands
return;
}
if (mindComponent.OwnedEntity == null)
if (mindComponent.OwnedEntity == default)
{
shell.WriteError("You don't have an entity!");
return;

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.Linq;
using Content.Server.Act;
using Content.Server.Administration;
@@ -9,7 +8,6 @@ using Content.Server.Hands.Components;
using Content.Server.Items;
using Content.Server.Players;
using Content.Server.Popups;
using Content.Shared.Administration.Logs;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Database;
@@ -27,13 +25,15 @@ namespace Content.Server.Chat.Commands
[AnyCommand]
internal class SuicideCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
public string Command => "suicide";
public string Description => Loc.GetString("suicide-command-description");
public string Help => Loc.GetString("suicide-command-help-text");
private void DealDamage(ISuicideAct suicide, IChatManager chat, IEntity target)
private void DealDamage(ISuicideAct suicide, IChatManager chat, EntityUid target)
{
var kind = suicide.Suicide(target, chat);
if (kind != SuicideKind.Special)
@@ -73,10 +73,9 @@ namespace Content.Server.Chat.Commands
var chat = IoCManager.Resolve<IChatManager>();
var mind = player.ContentData()?.Mind;
var owner = mind?.OwnedComponent?.Owner;
// This check also proves mind not-null for at the end when the mob is ghosted.
if (owner == null)
if (mind?.OwnedComponent?.Owner is not {Valid: true} owner)
{
shell.WriteLine("You don't have a mind!");
return;
@@ -88,11 +87,11 @@ namespace Content.Server.Chat.Commands
EntitySystem.Get<AdminLogSystem>().Add(LogType.Suicide, $"{player.AttachedEntity} is committing suicide");
// Held item suicide
var handsComponent = IoCManager.Resolve<IEntityManager>().GetComponent<HandsComponent>(owner);
var handsComponent = _entities.GetComponent<HandsComponent>(owner);
var itemComponent = handsComponent.GetActiveHand;
if (itemComponent != null)
{
var suicide = IoCManager.Resolve<IEntityManager>().GetComponents<ISuicideAct>(itemComponent.Owner).FirstOrDefault();
var suicide = _entities.GetComponents<ISuicideAct>(itemComponent.Owner).FirstOrDefault();
if (suicide != null)
{
@@ -107,9 +106,9 @@ namespace Content.Server.Chat.Commands
{
foreach (var entity in entities)
{
if (IoCManager.Resolve<IEntityManager>().HasComponent<ItemComponent>(entity))
if (_entities.HasComponent<ItemComponent>(entity))
continue;
var suicide = IoCManager.Resolve<IEntityManager>().GetComponents<ISuicideAct>(entity).FirstOrDefault();
var suicide = _entities.GetComponents<ISuicideAct>(entity).FirstOrDefault();
if (suicide != null)
{
DealDamage(suicide, chat, owner);