Inline Delete

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 11:43:03 +01:00
parent f10ed6c0c3
commit e3227546b3
53 changed files with 80 additions and 60 deletions

View File

@@ -27,7 +27,7 @@ namespace Content.Client.Animations
var animations = animatableClone.GetComponent<AnimationPlayerComponent>();
animations.AnimationCompleted += (_) => {
animatableClone.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(animatableClone.Uid);
};
animations.Play(new Animation

View File

@@ -2,6 +2,7 @@
using Content.Client.Cooldown;
using Content.Client.Items.Managers;
using Content.Client.Stylesheets;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -138,7 +139,12 @@ namespace Content.Client.Items.UI
{
if (EntityHover)
{
HoverSpriteView.Sprite?.Owner.Delete();
ISpriteComponent? tempQualifier = HoverSpriteView.Sprite;
if (tempQualifier != null)
{
IoCManager.Resolve<IEntityManager>().DeleteEntity(tempQualifier.Owner.Uid);
}
HoverSpriteView.Sprite = null;
}
}

View File

@@ -98,7 +98,7 @@ namespace Content.Client.Lobby.UI
_preferencesManager.OnServerDataLoaded -= UpdateUI;
if (!disposing) return;
_previewDummy.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(_previewDummy.Uid);
_previewDummy = null!;
}
@@ -160,7 +160,7 @@ namespace Content.Client.Lobby.UI
{
var item = entityMan.SpawnEntity(itemType, MapCoordinates.Nullspace);
inventory.SetSlotVisuals(slot, item);
item.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Uid);
}
}
}

View File

@@ -218,7 +218,7 @@ namespace Content.Client.Preferences.UI
if (!disposing)
return;
_previewDummy.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(_previewDummy.Uid);
_previewDummy = null!;
}
}

View File

@@ -482,7 +482,7 @@ namespace Content.Client.Preferences.UI
if (!disposing)
return;
_previewDummy.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(_previewDummy.Uid);
_preferencesManager.OnServerDataLoaded -= LoadServerData;
}

View File

@@ -63,7 +63,11 @@ namespace Content.Client.Wall.Components
{
base.Shutdown();
_overlayEntity?.Delete();
IEntity? tempQualifier = _overlayEntity;
if (tempQualifier != null)
{
IoCManager.Resolve<IEntityManager>().DeleteEntity(tempQualifier.Uid);
}
}
internal override void CalculateNewSprite()

View File

@@ -2,6 +2,7 @@ using Content.Shared.Weapons.Melee;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Client.Weapons.Melee.Components
@@ -71,7 +72,7 @@ namespace Content.Client.Weapons.Melee.Components
if (_meleeWeaponAnimation.Length.TotalSeconds <= _timer)
{
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
}
}
}

View File

@@ -38,7 +38,7 @@ namespace Content.IntegrationTests.Tests
Assert.That(inv.Equip(Slots.HEAD, item, false), Is.True);
// Delete parent.
container.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(container.Uid);
// Assert that child item was also deleted.
Assert.That(item.Deleted, Is.True);

View File

@@ -4,6 +4,7 @@ using Content.Server.Doors.Components;
using Content.Shared.Doors;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Physics;
@@ -96,7 +97,7 @@ namespace Content.IntegrationTests.Tests.Doors
{
Assert.DoesNotThrow(() =>
{
airlock.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(airlock.Uid);
});
});

View File

@@ -49,12 +49,12 @@ namespace Content.IntegrationTests.Tests
server.Assert(() =>
{
visitEnt.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(visitEnt.Uid);
Assert.That(mind.VisitingEntity, Is.Null);
// This used to throw so make sure it doesn't.
playerEnt.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(playerEnt.Uid);
});
await server.WaitIdleAsync();
@@ -91,7 +91,7 @@ namespace Content.IntegrationTests.Tests
server.Post(() =>
{
playerEnt.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(playerEnt.Uid);
});
server.RunTicks(1);

View File

@@ -57,7 +57,7 @@ namespace Content.Server.Actions.Spells
if (!spawnedProto.TryGetComponent(out ItemComponent? itemComponent))
{
Logger.Error($"Tried to use {nameof(GiveItemSpell)} but prototype has no {nameof(ItemComponent)}?");
spawnedProto.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(spawnedProto.Uid);
return;
}

View File

@@ -68,7 +68,7 @@ namespace Content.Server.Administration
verb.Text = Loc.GetString("delete-verb-get-data-text");
verb.Category = VerbCategory.Debug;
verb.IconTexture = "/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png";
verb.Act = () => args.Target.Delete();
verb.Act = () => IoCManager.Resolve<IEntityManager>().DeleteEntity(args.Target.Uid);
verb.Impact = LogImpact.Medium;
args.Verbs.Add(verb);
}

View File

@@ -42,7 +42,7 @@ namespace Content.Server.Administration.Commands
var count = 0;
foreach (var entity in entitiesWithAllComponents)
{
entity.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity.Uid);
count += 1;
}

View File

@@ -29,7 +29,7 @@ namespace Content.Server.Administration.Commands
foreach (var entity in entities)
{
entity.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity.Uid);
i++;
}

View File

@@ -34,7 +34,7 @@ namespace Content.Server.Administration.Commands
return;
}
entity.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity.Uid);
shell.WriteLine($"Deleted entity with id {id}.");
}
}

View File

@@ -58,7 +58,7 @@ namespace Content.Server.Chemistry.Components
{
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted)
return;
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
}
}
}

View File

@@ -87,7 +87,7 @@ namespace Content.Server.Chemistry.Components
if (!newEffect.TryGetComponent(out SolutionAreaEffectComponent? effectComponent))
{
newEffect.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(newEffect.Uid);
return;
}

View File

@@ -6,6 +6,7 @@ using JetBrains.Annotations;
using Robust.Server.Containers;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -58,7 +59,7 @@ namespace Content.Server.Construction.Completions
foreach (var ent in computerContainer.ContainedEntities.ToArray())
{
computerContainer.ForceRemove(ent);
ent.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(ent.Uid);
}
computerContainer.Insert(board);

View File

@@ -61,7 +61,7 @@ namespace Content.Server.Construction.Components
// get last owner coordinates and delete it
var resultPosition = Owner.Transform.Coordinates;
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
// spawn each result after refine
foreach (var result in _refineResult!)

View File

@@ -52,7 +52,7 @@ namespace Content.Server.Engineering.EntitySystems
hands.PutInHandOrDrop(item);
}
component.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(component.Owner.Uid);
return;
}

View File

@@ -69,7 +69,7 @@ namespace Content.Server.Engineering.EntitySystems
EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid));
if (component.RemoveOnInteract && stackComp == null && !((!IoCManager.Resolve<IEntityManager>().EntityExists(component.Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(component.Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted))
component.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(component.Owner.Uid);
}
}
}

View File

@@ -123,7 +123,7 @@ namespace Content.Server.Explosion.Components
});
}
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
});
return true;
}

View File

@@ -143,7 +143,7 @@ namespace Content.Server.Fluids.Components
// is the puddle cleaned?
if (puddleSolution.TotalVolume - transferAmount <= 0)
{
puddleComponent.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(puddleComponent.Owner.Uid);
// After cleaning the puddle, make a new puddle with solution from the mop as a "wet floor". Then evaporate it slowly.
// we do this WITHOUT adding to the existing puddle. Otherwise we have might have water puddles with the vomit sprite.

View File

@@ -363,7 +363,7 @@ namespace Content.Server.GameTicking
{
// TODO: Maybe something less naive here?
// FIXME: Actually, definitely.
entity.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity.Uid);
}
_mapManager.Restart();

View File

@@ -86,7 +86,7 @@ namespace Content.Server.GameTicking.Presets
foreach (var slot in victimSlots)
{
if (inventory.TryGetSlotItem(slot, out ItemComponent? vItem))
vItem.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(vItem.Owner.Uid);
}
// Replace their items:

View File

@@ -187,7 +187,7 @@ namespace Content.Server.Ghost
if (entity.TryGetComponent<MindComponent>(out var mind))
mind.GhostOnShutdown = false;
entity.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(entity.Uid);
}
private IEnumerable<string> GetLocationNames()

View File

@@ -58,7 +58,7 @@ namespace Content.Server.Ghost.Roles.Components
Taken = true;
if (_deleteOnSpawn)
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
return true;
}

View File

@@ -89,7 +89,7 @@ namespace Content.Server.Hands.Systems
|| virtualItem.BlockingEntity != args.Pulled.Owner.Uid)
continue;
hand.HeldEntity.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(hand.HeldEntity.Uid);
break;
}
}

View File

@@ -69,7 +69,7 @@ namespace Content.Server.Inventory.Components
{
if (TryGetSlotItem(slot, out ItemComponent? item))
{
item.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Owner.Uid);
}
RemoveSlot(slot);

View File

@@ -33,7 +33,7 @@ namespace Content.Server.Inventory
// Helper method that deletes the item and returns false.
bool DeleteItem()
{
item.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Uid);
return false;
}

View File

@@ -154,7 +154,7 @@ namespace Content.Server.Kitchen.Components
Owner.PopupMessageEveryone(Loc.GetString("comp-kitchen-spike-kill", ("user", user), ("victim", victim)));
// TODO: Need to be able to leave them on the spike to do DoT, see ss13.
victim.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(victim.Uid);
SoundSystem.Play(Filter.Pvs(Owner), SpikeSound.GetSound(), Owner);
}

View File

@@ -411,7 +411,7 @@ namespace Content.Server.Kitchen.Components
{
var item = _storage.ContainedEntities.ElementAt(i);
_storage.Remove(item);
item.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Uid);
}
}
@@ -459,7 +459,7 @@ namespace Content.Server.Kitchen.Components
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Uid).EntityPrototype.ID == recipeSolid.Key)
{
_storage.Remove(item);
item.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Uid);
break;
}
}

View File

@@ -319,7 +319,7 @@ namespace Content.Server.Kitchen.EntitySystems
solution.ScaleSolution(juiceEvent.Scalar);
_solutionsSystem.TryAddSolution(beakerEntity.Uid, component.HeldBeaker, solution);
_solutionsSystem.RemoveAllSolution(beakerEntity.Uid, solution);
item.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Uid);
}
component.Busy = false;
@@ -351,7 +351,7 @@ namespace Content.Server.Kitchen.EntitySystems
component.HeldBeaker.MaxVolume) continue;
juiceMe.JuiceSolution.ScaleSolution(juiceEvent.Scalar);
_solutionsSystem.TryAddSolution(beakerEntity.Uid, component.HeldBeaker, juiceMe.JuiceSolution);
item.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Uid);
}
bui?.SendMessage(new SharedReagentGrinderComponent.ReagentGrinderWorkCompleteMessage());

View File

@@ -202,7 +202,7 @@ namespace Content.Server.Lathe.Components
SetAppearance(LatheVisualState.Idle);
});
eventArgs.Using.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(eventArgs.Using.Uid);
return true;
}

View File

@@ -117,7 +117,7 @@ namespace Content.Server.Morgue.Components
{
var item = Contents.ContainedEntities[i];
Contents.Remove(item);
item.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(item.Uid);
}
var ash = IoCManager.Resolve<IEntityManager>().SpawnEntity("Ash", Owner.Transform.Coordinates);
@@ -148,7 +148,7 @@ namespace Content.Server.Morgue.Components
}
else
{
victim.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(victim.Uid);
}
Cremate();

View File

@@ -70,7 +70,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (_robustRandom.Prob(component.BreakChance))
{
SoundSystem.Play(Filter.Pvs(userUid), component.BreakSound.GetSound(), userUid, AudioParams.Default.WithVolume(-2f));
component.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(component.Owner.Uid);
}
}
}

View File

@@ -3,6 +3,7 @@ using Content.Server.Singularity.Components;
using Content.Shared.Singularity.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Physics.Collision;
@@ -71,7 +72,7 @@ namespace Content.Server.ParticleAccelerator.Components
.LinearVelocity = angle.ToWorldVec() * 20f;
Owner.Transform.LocalRotation = angle;
Timer.Spawn(3000, () => Owner.Delete());
Timer.Spawn(3000, () => IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid));
}
}
}

View File

@@ -81,7 +81,7 @@ namespace Content.Server.Pointing.Components
return;
}
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
return;
}

View File

@@ -47,7 +47,7 @@ namespace Content.Server.Power.Components
if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner.Uid, eventArgs.User.Uid)) return false;
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
var droppedEnt = IoCManager.Resolve<IEntityManager>().SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation);
// TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated...

View File

@@ -5,6 +5,7 @@ using Content.Shared.Examine;
using Content.Shared.PowerCell;
using Content.Shared.Rounding;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
@@ -73,7 +74,7 @@ namespace Content.Server.PowerCell.Components
CurrentCharge = 0;
EntitySystem.Get<ExplosionSystem>().SpawnExplosion(OwnerUid, 0, heavy, light, light*2);
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
}
private void UpdateVisuals()

View File

@@ -98,7 +98,7 @@ namespace Content.Server.Projectiles.Components
{
if (!((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Uid).EntityLifeStage) >= EntityLifeStage.Deleted))
{
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
}
});
}

View File

@@ -83,7 +83,7 @@ namespace Content.Server.Projectiles
if (component.TimeLeft <= 0)
{
component.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(component.Owner.Uid);
}
}
}

View File

@@ -118,7 +118,11 @@ namespace Content.Server.RCD.Systems
}
else //Delete what the user targeted
{
args.Target?.Delete();
IEntity? tempQualifier = args.Target;
if (tempQualifier != null)
{
IoCManager.Resolve<IEntityManager>().DeleteEntity(tempQualifier.Uid);
}
}
break;
//Walls are a special behaviour, and require us to build a new object with a transform rather than setting a grid tile,

View File

@@ -88,7 +88,7 @@ namespace Content.Server.Rotatable
var newTransform = entity.Transform;
newTransform.LocalRotation = oldTransform.LocalRotation;
newTransform.Anchored = false;
component.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(component.Owner.Uid);
}
}
}

View File

@@ -57,7 +57,7 @@ namespace Content.Server.Singularity.Components
if (!newEnt.TryGetComponent<ContainmentFieldComponent>(out var containmentFieldComponent))
{
Logger.Error("While creating Fields in ContainmentFieldConnection, a ContainmentField without a ContainmentFieldComponent was created. Deleting newly spawned ContainmentField...");
newEnt.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(newEnt.Uid);
continue;
}
@@ -88,7 +88,7 @@ namespace Content.Server.Singularity.Components
_powerDecreaseCancellationTokenSource.Cancel();
foreach (var field in _fields)
{
field.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(field.Uid);
}
_fields.Clear();

View File

@@ -4,6 +4,7 @@ using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
@@ -31,7 +32,7 @@ namespace Content.Server.Singularity.Components
_energy = value;
if (_energy <= 0)
{
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
return;
}

View File

@@ -189,7 +189,7 @@ namespace Content.Server.Singularity.EntitySystems
projectile.Transform.WorldRotation = component.Owner.Transform.WorldRotation;
// TODO: Move to projectile's code.
Timer.Spawn(3000, () => projectile.Delete());
Timer.Spawn(3000, () => IoCManager.Resolve<IEntityManager>().DeleteEntity(projectile.Uid));
SoundSystem.Play(Filter.Pvs(component.Owner), component.FireSound.GetSound(), component.Owner,
AudioHelpers.WithVariation(EmitterComponent.Variation).WithVolume(EmitterComponent.Volume).WithMaxDistance(EmitterComponent.Distance));

View File

@@ -63,7 +63,7 @@ namespace Content.Server.Spawners.Components
public override void MapInit()
{
Spawn();
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
}
}
}

View File

@@ -55,7 +55,7 @@ namespace Content.Server.Storage.EntitySystems
if (component.Uses == 0)
{
args.Handled = true;
owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(owner.Uid);
}
if (entityToPlaceInHands != null

View File

@@ -111,7 +111,7 @@ namespace Content.Server.TraitorDeathMatch.Components
accounts.SetBalance(victimAccount, 0);
accounts.AddToBalance(userAccount, transferAmount);
victimUplink.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(victimUplink.Owner.Uid);
Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-success-message", ("tcAmount", transferAmount)));
return true;

View File

@@ -238,7 +238,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components
if (ammoComponent.Caseless)
{
ammo.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(ammo.Uid);
}
}
else

View File

@@ -187,7 +187,7 @@ namespace Content.Server.Weapon.Ranged
user.PopupMessage(Loc.GetString("server-ranged-weapon-component-try-fire-clumsy"));
Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner.Uid);
return;
}

View File

@@ -293,7 +293,7 @@ namespace Content.Shared.Body.Components
return false;
}
mechanism.Owner.Delete();
IoCManager.Resolve<IEntityManager>().DeleteEntity(mechanism.Owner.Uid);
return true;
}