CatStation/Content.Server/Administration/Systems/AdminSystem.cs
lzk228 0af3e04fd8 Merge commit '3551eb04115854cdbbf1841f5960c3cdbc508583' into 02-19-upstream
# Conflicts:
#	Content.Server/Administration/Systems/AdminSystem.cs
#	Content.Server/Doors/Systems/AirlockSystem.cs
#	Content.Server/Holopad/HolopadSystem.cs
#	Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs
#	Resources/Prototypes/Catalog/Fills/Lockers/heads.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/curadrobe.yml
#	Resources/Prototypes/Datasets/Names/borg.yml
#	Resources/Prototypes/Datasets/ion_storm.yml
#	Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml
#	Resources/Prototypes/Entities/Clothing/Neck/mantles.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml
#	Resources/Prototypes/Entities/Stations/base.yml
#	Resources/Prototypes/Entities/Structures/Machines/lathe.yml
#	Resources/Prototypes/Maps/amber.yml
#	Resources/Prototypes/Maps/box.yml
#	Resources/Prototypes/Maps/convex.yml
#	Resources/Prototypes/Maps/fland.yml
#	Resources/Prototypes/Maps/meta.yml
#	Resources/Prototypes/Maps/plasma.yml
#	Resources/ServerInfo/Guidebook/Engineering/AME.xml
#	Resources/ServerInfo/Guidebook/Engineering/AirlockSecurity.xml
#	Resources/ServerInfo/Guidebook/Engineering/Atmospherics.xml
#	Resources/ServerInfo/Guidebook/Engineering/Construction.xml
#	Resources/ServerInfo/Guidebook/Engineering/Engineering.xml
#	Resources/ServerInfo/Guidebook/Engineering/Fires.xml
#	Resources/ServerInfo/Guidebook/Engineering/NetworkConfigurator.xml
#	Resources/ServerInfo/Guidebook/Engineering/Networking.xml
#	Resources/ServerInfo/Guidebook/Engineering/PortableGenerator.xml
#	Resources/ServerInfo/Guidebook/Engineering/Power.xml
#	Resources/ServerInfo/Guidebook/Engineering/RTG.xml
#	Resources/ServerInfo/Guidebook/Engineering/Shuttlecraft.xml
#	Resources/ServerInfo/Guidebook/Engineering/Singularity.xml
#	Resources/ServerInfo/Guidebook/Engineering/TEG.xml
#	Resources/ServerInfo/Guidebook/NewPlayer/Controls/Controls.xml
#	Resources/Textures/Clothing/Head/Helmets/paramedhelm.rsi/icon.png
#	Resources/Textures/Clothing/Head/Helmets/paramedhelm.rsi/inhand-left.png
#	Resources/Textures/Clothing/Head/Helmets/paramedhelm.rsi/inhand-right.png
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/goliath.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/paramed.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/equipped-OUTERCLOTHING.png
#	Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/icon.png
#	Resources/Textures/Clothing/OuterClothing/Vests/hazard.rsi/meta.json
#	Resources/Textures/Clothing/Uniforms/Jumpsuit/ancient.rsi/meta.json
#	Resources/Textures/Clothing/Uniforms/Jumpsuit/security_trooper.rsi/inhand-right.png
#	Resources/Textures/Interface/Actions/actions_fakemindshield.rsi/icon-on.png
#	Resources/Textures/Objects/Storage/Briefcases/briefcase_brown.rsi/icon.png
#	Resources/Textures/Objects/Storage/Briefcases/briefcase_brown.rsi/meta.json
#	Resources/Textures/Objects/Storage/boxes.rsi/beaker.png
#	Resources/Textures/Objects/Storage/boxes.rsi/bodybags.png
#	Resources/Textures/Objects/Storage/boxes.rsi/bottle.png
#	Resources/Textures/Objects/Storage/boxes.rsi/box.png
#	Resources/Textures/Objects/Storage/boxes.rsi/box_hug.png
#	Resources/Textures/Objects/Storage/boxes.rsi/box_of_doom.png
#	Resources/Textures/Objects/Storage/boxes.rsi/box_of_doom_big.png
#	Resources/Textures/Objects/Storage/boxes.rsi/box_science.png
#	Resources/Textures/Objects/Storage/boxes.rsi/box_security.png
#	Resources/Textures/Objects/Storage/boxes.rsi/boxwide.png
#	Resources/Textures/Objects/Storage/boxes.rsi/boxwidetoy.png
#	Resources/Textures/Objects/Storage/boxes.rsi/candle.png
#	Resources/Textures/Objects/Storage/boxes.rsi/circuit.png
#	Resources/Textures/Objects/Storage/boxes.rsi/clown.png
#	Resources/Textures/Objects/Storage/boxes.rsi/darts.png
#	Resources/Textures/Objects/Storage/boxes.rsi/disk.png
#	Resources/Textures/Objects/Storage/boxes.rsi/emergencytank.png
#	Resources/Textures/Objects/Storage/boxes.rsi/encryptokey.png
#	Resources/Textures/Objects/Storage/boxes.rsi/evidence_markers.png
#	Resources/Textures/Objects/Storage/boxes.rsi/extendedtank.png
#	Resources/Textures/Objects/Storage/boxes.rsi/flare.png
#	Resources/Textures/Objects/Storage/boxes.rsi/flashbang.png
#	Resources/Textures/Objects/Storage/boxes.rsi/forensic.png
#	Resources/Textures/Objects/Storage/boxes.rsi/glasses.png
#	Resources/Textures/Objects/Storage/boxes.rsi/handcuff.png
#	Resources/Textures/Objects/Storage/boxes.rsi/headset.png
#	Resources/Textures/Objects/Storage/boxes.rsi/heart.png
#	Resources/Textures/Objects/Storage/boxes.rsi/holo.png
#	Resources/Textures/Objects/Storage/boxes.rsi/implant.png
#	Resources/Textures/Objects/Storage/boxes.rsi/inflatable.png
#	Resources/Textures/Objects/Storage/boxes.rsi/internals.png
#	Resources/Textures/Objects/Storage/boxes.rsi/latex.png
#	Resources/Textures/Objects/Storage/boxes.rsi/light.png
#	Resources/Textures/Objects/Storage/boxes.rsi/lightmixed.png
#	Resources/Textures/Objects/Storage/boxes.rsi/lighttube.png
#	Resources/Textures/Objects/Storage/boxes.rsi/magazine.png
#	Resources/Textures/Objects/Storage/boxes.rsi/meson.png
#	Resources/Textures/Objects/Storage/boxes.rsi/meta.json
#	Resources/Textures/Objects/Storage/boxes.rsi/mousetraps.png
#	Resources/Textures/Objects/Storage/boxes.rsi/nitrile.png
#	Resources/Textures/Objects/Storage/boxes.rsi/omegacart.png
#	Resources/Textures/Objects/Storage/boxes.rsi/pda.png
#	Resources/Textures/Objects/Storage/boxes.rsi/pillbox.png
#	Resources/Textures/Objects/Storage/boxes.rsi/sechud.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shellbeanbag.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shellflare.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shellflash.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shellincendiary.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shelllethal.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shellpractice.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shellslug.png
#	Resources/Textures/Objects/Storage/boxes.rsi/shelltoy.png
#	Resources/Textures/Objects/Storage/boxes.rsi/solution_trays.png
#	Resources/Textures/Objects/Storage/boxes.rsi/sterile.png
#	Resources/Textures/Objects/Storage/boxes.rsi/swab.png
#	Resources/Textures/Objects/Storage/boxes.rsi/syringe.png
#	Resources/Textures/Objects/Storage/boxes.rsi/trashbag.png
#	Resources/Textures/Objects/Storage/boxes.rsi/vials.png
#	Resources/Textures/Objects/Storage/boxes.rsi/writing.png
#	Resources/Textures/Objects/Storage/boxes.rsi/writing_of_doom.png
#	Resources/Textures/Objects/Storage/boxes.rsi/ziptie.png
#	Resources/Textures/Objects/Tiles/tile.rsi/meta.json
#	Resources/Textures/Objects/Weapons/Grenades/empgrenade.rsi/icon.png
#	Resources/Textures/Objects/Weapons/Grenades/empgrenade.rsi/meta.json
#	Resources/Textures/Objects/Weapons/Grenades/empgrenade.rsi/primed.png
#	Resources/Textures/Objects/Weapons/Grenades/flashbang.rsi/icon.png
#	Resources/Textures/Objects/Weapons/Grenades/flashbang.rsi/meta.json
#	Resources/Textures/Objects/Weapons/Grenades/flashbang.rsi/primed.png
#	Resources/Textures/Objects/Weapons/Grenades/stingergrenade.rsi/icon.png
#	Resources/Textures/Objects/Weapons/Grenades/stingergrenade.rsi/meta.json
#	Resources/Textures/Objects/Weapons/Grenades/stingergrenade.rsi/primed.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/antiquelasergun.rsi/base.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/antiquelasergun.rsi/icon.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/antiquelasergun.rsi/mag-unshaded-1.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/antiquelasergun.rsi/mag-unshaded-2.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/antiquelasergun.rsi/mag-unshaded-3.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/antiquelasergun.rsi/mag-unshaded-4.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/antiquelasergun.rsi/meta.json
#	Resources/Textures/Objects/Weapons/Guns/Rifles/lecter.rsi/equipped-BACKPACK.png
#	Resources/Textures/Objects/Weapons/Guns/SMGs/vector.rsi/equipped-BACKPACK.png
#	Resources/Textures/Objects/Weapons/Guns/Shotguns/pump.rsi/equipped-BACKPACK.png
2025-02-19 03:00:13 +01:00

439 lines
16 KiB
C#

using System.Linq;
using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers;
using Content.Server.Forensics;
using Content.Server.GameTicking;
using Content.Server.Hands.Systems;
using Content.Server.Mind;
using Content.Server.Players.PlayTimeTracking;
using Content.Server.Popups;
using Content.Server.StationRecords.Systems;
using Content.Shared.Administration;
using Content.Shared.Administration.Events;
using Content.Shared.CCVar;
using Content.Shared.Corvax.CCCVars;
using Content.Shared.Forensics.Components;
using Content.Shared.GameTicking;
using Content.Shared.Hands.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Inventory;
using Content.Shared.Mind;
using Content.Shared.PDA;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Popups;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Content.Shared.StationRecords;
using Content.Shared.Throwing;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
namespace Content.Server.Administration.Systems;
public sealed class AdminSystem : EntitySystem
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly SharedJobSystem _jobs = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly PhysicsSystem _physics = default!;
[Dependency] private readonly PlayTimeTrackingManager _playTime = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedRoleSystem _role = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly StationRecordsSystem _stationRecords = default!;
[Dependency] private readonly TransformSystem _transform = default!;
private readonly Dictionary<NetUserId, PlayerInfo> _playerList = new();
/// <summary>
/// Set of players that have participated in this round.
/// </summary>
public IReadOnlySet<NetUserId> RoundActivePlayers => _roundActivePlayers;
private readonly HashSet<NetUserId> _roundActivePlayers = new();
public readonly PanicBunkerStatus PanicBunker = new();
public override void Initialize()
{
base.Initialize();
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
_adminManager.OnPermsChanged += OnAdminPermsChanged;
_playTime.SessionPlayTimeUpdated += OnSessionPlayTimeUpdated;
// Panic Bunker Settings
Subs.CVar(_config, CCVars.PanicBunkerEnabled, OnPanicBunkerChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerDisableWithAdmins, OnPanicBunkerDisableWithAdminsChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerEnableWithoutAdmins, OnPanicBunkerEnableWithoutAdminsChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerCountDeadminnedAdmins, OnPanicBunkerCountDeadminnedAdminsChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerShowReason, OnPanicBunkerShowReasonChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerMinAccountAge, OnPanicBunkerMinAccountAgeChanged, true);
Subs.CVar(_config, CCVars.PanicBunkerMinOverallMinutes, OnPanicBunkerMinOverallMinutesChanged, true);
Subs.CVar(_config, CCCVars.PanicBunkerDenyVPN, OnPanicBunkerDenyVpnChanged, true); // Corvax-VPNGuard
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<RoleAddedEvent>(OnRoleEvent);
SubscribeLocalEvent<RoleRemovedEvent>(OnRoleEvent);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestartCleanup);
SubscribeLocalEvent<ActorComponent, EntityRenamedEvent>(OnPlayerRenamed);
SubscribeLocalEvent<ActorComponent, IdentityChangedEvent>(OnIdentityChanged);
}
private void OnRoundRestartCleanup(RoundRestartCleanupEvent ev)
{
_roundActivePlayers.Clear();
foreach (var (id, data) in _playerList)
{
if (!data.ActiveThisRound)
continue;
if (!_playerManager.TryGetPlayerData(id, out var playerData))
return;
_playerManager.TryGetSessionById(id, out var session);
_playerList[id] = GetPlayerInfo(playerData, session);
}
var updateEv = new FullPlayerListEvent() { PlayersInfo = _playerList.Values.ToList() };
foreach (var admin in _adminManager.ActiveAdmins)
{
RaiseNetworkEvent(updateEv, admin.Channel);
}
}
private void OnPlayerRenamed(Entity<ActorComponent> ent, ref EntityRenamedEvent args)
{
UpdatePlayerList(ent.Comp.PlayerSession);
}
public void UpdatePlayerList(ICommonSession player)
{
_playerList[player.UserId] = GetPlayerInfo(player.Data, player);
var playerInfoChangedEvent = new PlayerInfoChangedEvent
{
PlayerInfo = _playerList[player.UserId]
};
foreach (var admin in _adminManager.ActiveAdmins)
{
RaiseNetworkEvent(playerInfoChangedEvent, admin.Channel);
}
}
public PlayerInfo? GetCachedPlayerInfo(NetUserId? netUserId)
{
if (netUserId == null)
return null;
_playerList.TryGetValue(netUserId.Value, out var value);
return value ?? null;
}
private void OnIdentityChanged(Entity<ActorComponent> ent, ref IdentityChangedEvent ev)
{
UpdatePlayerList(ent.Comp.PlayerSession);
}
private void OnRoleEvent(RoleEvent ev)
{
var session = _minds.GetSession(ev.Mind);
if (!ev.RoleTypeUpdate || session == null)
return;
UpdatePlayerList(session);
}
private void OnAdminPermsChanged(AdminPermsChangedEventArgs obj)
{
UpdatePanicBunker();
if (!obj.IsAdmin)
{
RaiseNetworkEvent(new FullPlayerListEvent(), obj.Player.Channel);
return;
}
SendFullPlayerList(obj.Player);
}
private void OnPlayerDetached(PlayerDetachedEvent ev)
{
// If disconnected then the player won't have a connected entity to get character name from.
// The disconnected state gets sent by OnPlayerStatusChanged.
if (ev.Player.Status == SessionStatus.Disconnected)
return;
UpdatePlayerList(ev.Player);
}
private void OnPlayerAttached(PlayerAttachedEvent ev)
{
if (ev.Player.Status == SessionStatus.Disconnected)
return;
_roundActivePlayers.Add(ev.Player.UserId);
UpdatePlayerList(ev.Player);
}
public override void Shutdown()
{
base.Shutdown();
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
_adminManager.OnPermsChanged -= OnAdminPermsChanged;
_playTime.SessionPlayTimeUpdated -= OnSessionPlayTimeUpdated;
}
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
{
UpdatePlayerList(e.Session);
UpdatePanicBunker();
}
private void SendFullPlayerList(ICommonSession playerSession)
{
var ev = new FullPlayerListEvent();
ev.PlayersInfo = _playerList.Values.ToList();
RaiseNetworkEvent(ev, playerSession.Channel);
}
private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session)
{
var name = data.UserName;
var entityName = string.Empty;
var identityName = string.Empty;
if (session?.AttachedEntity != null)
{
entityName = EntityManager.GetComponent<MetaDataComponent>(session.AttachedEntity.Value).EntityName;
identityName = Identity.Name(session.AttachedEntity.Value, EntityManager);
}
var antag = false;
RoleTypePrototype roleType = new();
var startingRole = string.Empty;
if (_minds.TryGetMind(session, out var mindId, out var mindComp))
{
if (_proto.TryIndex(mindComp.RoleType, out var role))
roleType = role;
else
Log.Error($"{ToPrettyString(mindId)} has invalid Role Type '{mindComp.RoleType}'. Displaying '{Loc.GetString(roleType.Name)}' instead");
antag = _role.MindIsAntagonist(mindId);
startingRole = _jobs.MindTryGetJobName(mindId);
}
var connected = session != null && session.Status is SessionStatus.Connected or SessionStatus.InGame;
TimeSpan? overallPlaytime = null;
if (session != null &&
_playTime.TryGetTrackerTimes(session, out var playTimes) &&
playTimes.TryGetValue(PlayTimeTrackingShared.TrackerOverall, out var playTime))
{
overallPlaytime = playTime;
}
return new PlayerInfo(name, entityName, identityName, startingRole, antag, roleType, GetNetEntity(session?.AttachedEntity), data.UserId,
connected, _roundActivePlayers.Contains(data.UserId), overallPlaytime);
}
private void OnPanicBunkerChanged(bool enabled)
{
PanicBunker.Enabled = enabled;
_chat.SendAdminAlert(Loc.GetString(enabled
? "admin-ui-panic-bunker-enabled-admin-alert"
: "admin-ui-panic-bunker-disabled-admin-alert"
));
SendPanicBunkerStatusAll();
}
private void OnPanicBunkerDisableWithAdminsChanged(bool enabled)
{
PanicBunker.DisableWithAdmins = enabled;
UpdatePanicBunker();
}
private void OnPanicBunkerEnableWithoutAdminsChanged(bool enabled)
{
PanicBunker.EnableWithoutAdmins = enabled;
UpdatePanicBunker();
}
private void OnPanicBunkerCountDeadminnedAdminsChanged(bool enabled)
{
PanicBunker.CountDeadminnedAdmins = enabled;
UpdatePanicBunker();
}
private void OnPanicBunkerShowReasonChanged(bool enabled)
{
PanicBunker.ShowReason = enabled;
SendPanicBunkerStatusAll();
}
private void OnPanicBunkerMinAccountAgeChanged(int minutes)
{
PanicBunker.MinAccountAgeMinutes = minutes;
SendPanicBunkerStatusAll();
}
private void OnPanicBunkerMinOverallMinutesChanged(int minutes)
{
PanicBunker.MinOverallMinutes = minutes;
SendPanicBunkerStatusAll();
}
// Corvax-VPNGuard-Start
private void OnPanicBunkerDenyVpnChanged(bool deny)
{
PanicBunker.DenyVpn = deny;
SendPanicBunkerStatusAll();
}
// Corvax-VPNGuard-End
private void UpdatePanicBunker()
{
var hasAdmins = false;
foreach (var admin in _adminManager.AllAdmins)
{
if (_adminManager.HasAdminFlag(admin, AdminFlags.Admin, includeDeAdmin: PanicBunker.CountDeadminnedAdmins))
{
hasAdmins = true;
break;
}
}
// TODO Fix order dependent Cvars
// Please for the sake of my sanity don't make cvars & order dependent.
// Just make a bool field on the system instead of having some cvars automatically modify other cvars.
//
// I.e., this:
// /sudo cvar game.panic_bunker.enabled true
// /sudo cvar game.panic_bunker.disable_with_admins true
// and this:
// /sudo cvar game.panic_bunker.disable_with_admins true
// /sudo cvar game.panic_bunker.enabled true
//
// should have the same effect, but currently setting the disable_with_admins can modify enabled.
if (hasAdmins && PanicBunker.DisableWithAdmins)
{
_config.SetCVar(CCVars.PanicBunkerEnabled, false);
}
else if (!hasAdmins && PanicBunker.EnableWithoutAdmins)
{
_config.SetCVar(CCVars.PanicBunkerEnabled, true);
}
SendPanicBunkerStatusAll();
}
private void SendPanicBunkerStatusAll()
{
var ev = new PanicBunkerChangedEvent(PanicBunker);
foreach (var admin in _adminManager.AllAdmins)
{
RaiseNetworkEvent(ev, admin);
}
}
/// <summary>
/// Erases a player from the round.
/// This removes them and any trace of them from the round, deleting their
/// chat messages and showing a popup to other players.
/// Their items are dropped on the ground.
/// </summary>
public void Erase(NetUserId uid)
{
_chat.DeleteMessagesBy(uid);
if (!_minds.TryGetMind(uid, out var mindId, out var mind) || mind.OwnedEntity == null || TerminatingOrDeleted(mind.OwnedEntity.Value))
return;
var entity = mind.OwnedEntity.Value;
if (TryComp(entity, out TransformComponent? transform))
{
var coordinates = _transform.GetMoverCoordinates(entity, transform);
var name = Identity.Entity(entity, EntityManager);
_popup.PopupCoordinates(Loc.GetString("admin-erase-popup", ("user", name)), coordinates, PopupType.LargeCaution);
var filter = Filter.Pvs(coordinates, 1, EntityManager, _playerManager);
var audioParams = new AudioParams().WithVolume(3);
_audio.PlayStatic("/Audio/Effects/pop_high.ogg", filter, coordinates, true, audioParams);
}
foreach (var item in _inventory.GetHandOrInventoryEntities(entity))
{
if (TryComp(item, out PdaComponent? pda) &&
TryComp(pda.ContainedId, out StationRecordKeyStorageComponent? keyStorage) &&
keyStorage.Key is { } key &&
_stationRecords.TryGetRecord(key, out GeneralStationRecord? record))
{
if (TryComp(entity, out DnaComponent? dna) &&
dna.DNA != record.DNA)
{
continue;
}
if (TryComp(entity, out FingerprintComponent? fingerPrint) &&
fingerPrint.Fingerprint != record.Fingerprint)
{
continue;
}
_stationRecords.RemoveRecord(key);
Del(item);
}
}
if (_inventory.TryGetContainerSlotEnumerator(entity, out var enumerator))
{
while (enumerator.NextItem(out var item, out var slot))
{
if (_inventory.TryUnequip(entity, entity, slot.Name, true, true))
_physics.ApplyAngularImpulse(item, ThrowingSystem.ThrowAngularImpulse);
}
}
if (TryComp(entity, out HandsComponent? hands))
{
foreach (var hand in _hands.EnumerateHands(entity, hands))
{
_hands.TryDrop(entity, hand, checkActionBlocker: false, doDropInteraction: false, handsComp: hands);
}
}
_minds.WipeMind(mindId, mind);
QueueDel(entity);
if (_playerManager.TryGetSessionById(uid, out var session))
_gameTicker.SpawnObserver(session);
}
private void OnSessionPlayTimeUpdated(ICommonSession session)
{
UpdatePlayerList(session);
}
}