<commit_before>#nullable enable
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Observer;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using System;

namespace Content.Server.GameObjects.EntitySystems
{
    [UsedImplicitly]
    public class GhostSystem : EntitySystem
    {
        public override void Initialize()
        {
            base.Initialize();

            SubscribeLocalEvent<GhostComponent, MindRemovedMessage>(OnMindRemovedMessage);
            SubscribeLocalEvent<GhostComponent, MindUnvisitedMessage>(OnMindUnvisitedMessage);
        }

        private void OnMindRemovedMessage(EntityUid uid, GhostComponent component, MindRemovedMessage args)
        {
            if (!EntityManager.TryGetEntity(uid, out var entity))
                return;
            DeleteEntity(entity);
        }

        private void OnMindUnvisitedMessage(EntityUid uid, GhostComponent component, MindUnvisitedMessage args)
        {
            if (!EntityManager.TryGetEntity(uid, out var entity))
                return;
            DeleteEntity(entity);
        }

        private void DeleteEntity(IEntity? entity)
        {
            if (entity?.Deleted == true)
                return;

            entity?.Delete();
        }
    }
}
<commit_msg>Add shutdown and clean up GhostSystem<commit_after>using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Observer;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;

namespace Content.Server.GameObjects.EntitySystems
{
    [UsedImplicitly]
    public class GhostSystem : EntitySystem
    {
        public override void Initialize()
        {
            base.Initialize();

            SubscribeLocalEvent<GhostComponent, MindRemovedMessage>(OnMindRemovedMessage);
            SubscribeLocalEvent<GhostComponent, MindUnvisitedMessage>(OnMindUnvisitedMessage);
        }

        public override void Shutdown()
        {
            base.Shutdown();

            UnsubscribeLocalEvent<GhostComponent, MindRemovedMessage>(OnMindRemovedMessage);
            UnsubscribeLocalEvent<GhostComponent, MindUnvisitedMessage>(OnMindUnvisitedMessage);
        }

        private void OnMindRemovedMessage(EntityUid uid, GhostComponent component, MindRemovedMessage args)
        {
            if (!EntityManager.TryGetEntity(uid, out var entity))
                return;
            DeleteEntity(entity);
        }

        private void OnMindUnvisitedMessage(EntityUid uid, GhostComponent component, MindUnvisitedMessage args)
        {
            if (!EntityManager.TryGetEntity(uid, out var entity))
                return;
            DeleteEntity(entity);
        }

        private void DeleteEntity(IEntity? entity)
        {
            if (entity?.Deleted == true)
                return;

            entity?.Delete();
        }
    }
}

{'fraction_non_alphanumeric': 0.0759278175008512, 'fraction_numerical': 0.0, 'mean_word_length': 2.5483091787439616, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5996621', 'n_tokens_mistral': 755, 'n_tokens_neox': 728, 'n_words': 146}