Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erase verb for all entities #2032

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 74 additions & 56 deletions Content.Server/Administration/Systems/AdminSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,78 +385,96 @@ private void SendBabyJailStatusAll()
}
}

/// <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);
// DeltaV - Slight refactor as a part of #2032, licensed under MIT

if (!_minds.TryGetMind(uid, out var mindId, out var mind) || mind.OwnedEntity == null || TerminatingOrDeleted(mind.OwnedEntity.Value))
return;
/// <summary>
/// Erases an entity from the round.
/// This removes them and any trace of them from the round.
/// Their items are dropped on the ground.
/// </summary>
public void Erase(EntityUid entity)
{
if (TerminatingOrDeleted(entity))
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/DeltaV/Misc/reducedtoatmos.ogg", filter, coordinates, true, audioParams); // DeltaV
}

if (TryComp(entity, out TransformComponent? transform))
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))
{
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/DeltaV/Misc/reducedtoatmos.ogg", filter, coordinates, true, audioParams); // DeltaV
}
if (TryComp(entity, out DnaComponent? dna) && dna.DNA != record.DNA)
{
continue;
}

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 FingerprintComponent? fingerPrint) &&
fingerPrint.Fingerprint != record.Fingerprint)
{
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);
continue;
}

_stationRecords.RemoveRecord(key);
Del(item);
}
}

if (_inventory.TryGetContainerSlotEnumerator(entity, out var enumerator))
if (_inventory.TryGetContainerSlotEnumerator(entity, out var enumerator))
{
while (enumerator.NextItem(out var item, out var slot))
{
while (enumerator.NextItem(out var item, out var slot))
{
if (_inventory.TryUnequip(entity, entity, slot.Name, true, true))
_physics.ApplyAngularImpulse(item, ThrowingSystem.ThrowAngularImpulse);
}
if (_inventory.TryUnequip(entity, entity, slot.Name, true, true))
_physics.ApplyAngularImpulse(item, ThrowingSystem.ThrowAngularImpulse);
}
}

if (TryComp(entity, out HandsComponent? hands))
if (TryComp(entity, out HandsComponent? hands))
{
foreach (var hand in _hands.EnumerateHands(entity, hands))
{
foreach (var hand in _hands.EnumerateHands(entity, hands))
{
_hands.TryDrop(entity, hand, checkActionBlocker: false, doDropInteraction: false, handsComp: hands);
}
_hands.TryDrop(entity, hand, checkActionBlocker: false, doDropInteraction: false, handsComp: hands);
}
}

_minds.WipeMind(mindId, mind);
QueueDel(entity);
QueueDel(entity);
}

if (_playerManager.TryGetSessionById(uid, out var session))
_gameTicker.SpawnObserver(session);
}
/// <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;

Erase(entity);

_minds.WipeMind(mindId, mind);

if (_playerManager.TryGetSessionById(uid, out var session))
_gameTicker.SpawnObserver(session);
}
// End DeltaV Changes

private void OnSessionPlayTimeUpdated(ICommonSession session)
{
Expand Down
17 changes: 17 additions & 0 deletions Content.Server/Administration/Systems/AdminVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,23 @@ private void AddAdminVerbs(GetVerbsEvent<Verb> args)
// No logimpact as the command does it internally.
});
}
else // DeltaV - Erase verb for entities without a mind
{
args.Verbs.Add(new Verb
{
Text = Loc.GetString("admin-verbs-erase"),
Message = Loc.GetString("admin-verbs-erase-item-description"),
Category = VerbCategory.Admin,
Icon = new SpriteSpecifier.Texture(
new("/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png")),
Act = () =>
{
_adminSystem.Erase(args.Target);
},
Impact = LogImpact.Extreme,
ConfirmationPopup = true
});
}

// Freeze
var frozen = TryComp<AdminFrozenComponent>(args.Target, out var frozenComp);
Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/deltav/administration/admin-verbs.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
admin-verbs-erase-item-description = Removes the entity from the round.
Players are shown a popup indicating them to play as if it never existed.
Loading