diff --git a/Robust.Client/Physics/PhysicsSystem.cs b/Robust.Client/Physics/PhysicsSystem.cs index 5b4c633f21..8010f66d71 100644 --- a/Robust.Client/Physics/PhysicsSystem.cs +++ b/Robust.Client/Physics/PhysicsSystem.cs @@ -36,7 +36,7 @@ namespace Robust.Client.Physics { if (eventArgs.Map == MapId.Nullspace) return; var mapUid = MapManager.GetMapEntityId(eventArgs.Map); - IoCManager.Resolve().AddComponent(mapUid); + EntityManager.AddComponent(mapUid); } } } diff --git a/Robust.Client/Placement/Modes/AlignSimilar.cs b/Robust.Client/Placement/Modes/AlignSimilar.cs index b0771cf871..5983e01771 100644 --- a/Robust.Client/Placement/Modes/AlignSimilar.cs +++ b/Robust.Client/Placement/Modes/AlignSimilar.cs @@ -32,8 +32,8 @@ namespace Robust.Client.Placement.Modes var mapId = MouseCoords.GetMapId(pManager.EntityManager); var snapToEntities = IoCManager.Resolve().GetEntitiesInRange(MouseCoords, SnapToRange) - .Where(entity => IoCManager.Resolve().GetComponent(entity).EntityPrototype == pManager.CurrentPrototype && IoCManager.Resolve().GetComponent(entity).MapID == mapId) - .OrderBy(entity => (IoCManager.Resolve().GetComponent(entity).WorldPosition - MouseCoords.ToMapPos(pManager.EntityManager)).LengthSquared) + .Where(entity => pManager.EntityManager.GetComponent(entity).EntityPrototype == pManager.CurrentPrototype && IoCManager.Resolve().GetComponent(entity).MapID == mapId) + .OrderBy(entity => (pManager.EntityManager.GetComponent(entity).WorldPosition - MouseCoords.ToMapPos(pManager.EntityManager)).LengthSquared) .ToList(); if (snapToEntities.Count == 0) @@ -42,7 +42,8 @@ namespace Robust.Client.Placement.Modes } var closestEntity = snapToEntities[0]; - if (!IoCManager.Resolve().TryGetComponent(closestEntity, out var component) || component.BaseRSI == null) + var closestTransform = pManager.EntityManager.GetComponent(closestEntity); + if (!pManager.EntityManager.TryGetComponent(closestEntity, out var component) || component.BaseRSI == null) { return; } @@ -51,8 +52,8 @@ namespace Robust.Client.Placement.Modes var closestRect = Box2.FromDimensions( - IoCManager.Resolve().GetComponent(closestEntity).WorldPosition.X - closestBounds.X / 2f, - IoCManager.Resolve().GetComponent(closestEntity).WorldPosition.Y - closestBounds.Y / 2f, + closestTransform.WorldPosition.X - closestBounds.X / 2f, + closestTransform.WorldPosition.Y - closestBounds.Y / 2f, closestBounds.X, closestBounds.Y); var sides = new[] diff --git a/Robust.Client/UserInterface/CustomControls/DebugCoordsPanel.cs b/Robust.Client/UserInterface/CustomControls/DebugCoordsPanel.cs index c3a76d7815..72d03b4dfb 100644 --- a/Robust.Client/UserInterface/CustomControls/DebugCoordsPanel.cs +++ b/Robust.Client/UserInterface/CustomControls/DebugCoordsPanel.cs @@ -97,11 +97,11 @@ Mouse Pos: } else { - var entityTransform = IoCManager.Resolve().GetComponent(controlledEntity); + var entityTransform = _entityManager.GetComponent(controlledEntity); var playerWorldOffset = entityTransform.MapPosition; var playerScreen = _eyeManager.WorldToScreen(playerWorldOffset.Position); - var playerCoordinates = IoCManager.Resolve().GetComponent(controlledEntity).Coordinates; + var playerCoordinates = entityTransform.Coordinates; stringBuilder.AppendFormat(@" Screen: {0} {1} diff --git a/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs b/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs index 49c92fd9ff..64f1b0cc67 100644 --- a/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs +++ b/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs @@ -108,7 +108,7 @@ namespace Robust.Client.ViewVariables.Instances top = new Label {Text = stringified}; } - if (IoCManager.Resolve().TryGetComponent(_entity, out ISpriteComponent? sprite)) + if (_entityManager.TryGetComponent(_entity, out ISpriteComponent? sprite)) { var hBox = new BoxContainer { @@ -202,7 +202,7 @@ namespace Robust.Client.ViewVariables.Instances _clientComponentsAddButton.OnPressed += OnClientComponentsAddButtonPressed; _clientComponentsSearchBar.OnTextChanged += OnClientComponentsSearchBarChanged; - var componentList = IoCManager.Resolve().GetComponents(_entity).OrderBy(c => c.GetType().ToString()); + var componentList = _entityManager.GetComponents(_entity).OrderBy(c => c.GetType().ToString()); foreach (var component in componentList) { @@ -392,7 +392,7 @@ namespace Robust.Client.ViewVariables.Instances foreach (var type in componentFactory.AllRegisteredTypes) { - if (IoCManager.Resolve().HasComponent(_entity, type)) + if (_entityManager.HasComponent(_entity, type)) continue; yield return (componentFactory.GetRegistration(type).Name); diff --git a/Robust.Server/Console/Commands/AddComponentCommand.cs b/Robust.Server/Console/Commands/AddComponentCommand.cs index 6c7be2c9fd..83ff0ec128 100644 --- a/Robust.Server/Console/Commands/AddComponentCommand.cs +++ b/Robust.Server/Console/Commands/AddComponentCommand.cs @@ -37,7 +37,6 @@ namespace Robust.Server.Console.Commands var componentName = args[1]; - var entManager = IoCManager.Resolve(); var compFactory = IoCManager.Resolve(); if (!compFactory.TryGetRegistration(componentName, out var registration, true)) @@ -46,17 +45,17 @@ namespace Robust.Server.Console.Commands return; } - if (IoCManager.Resolve().HasComponent(uid, registration.Type)) + if (entityManager.HasComponent(uid, registration.Type)) { - shell.WriteLine($"Entity {entManager.GetComponent(uid).EntityName} already has a {componentName} component."); + shell.WriteLine($"Entity {entityManager.GetComponent(uid).EntityName} already has a {componentName} component."); } var component = (Component) compFactory.GetComponent(registration.Type); component.Owner = uid; - entManager.AddComponent(uid, component); + entityManager.AddComponent(uid, component); - shell.WriteLine($"Added {componentName} component to entity {entManager.GetComponent(uid).EntityName}."); + shell.WriteLine($"Added {componentName} component to entity {entityManager.GetComponent(uid).EntityName}."); } } } diff --git a/Robust.Server/Console/Commands/DeleteCommand.cs b/Robust.Server/Console/Commands/DeleteCommand.cs index 2c08cc3bc1..66e7b046a4 100644 --- a/Robust.Server/Console/Commands/DeleteCommand.cs +++ b/Robust.Server/Console/Commands/DeleteCommand.cs @@ -33,7 +33,7 @@ namespace Robust.Server.Console.Commands return; } - IoCManager.Resolve().DeleteEntity(entity); + ent.DeleteEntity(entity); } } } diff --git a/Robust.Server/Console/Commands/RemoveComponentCommand.cs b/Robust.Server/Console/Commands/RemoveComponentCommand.cs index 252cb2c8c8..466fe89dc4 100644 --- a/Robust.Server/Console/Commands/RemoveComponentCommand.cs +++ b/Robust.Server/Console/Commands/RemoveComponentCommand.cs @@ -37,7 +37,6 @@ namespace Robust.Server.Console.Commands var componentName = args[1]; - var entManager = IoCManager.Resolve(); var compFactory = IoCManager.Resolve(); if (!compFactory.TryGetRegistration(componentName, out var registration, true)) @@ -46,15 +45,15 @@ namespace Robust.Server.Console.Commands return; } - if (!entManager.HasComponent(uid, registration.Type)) + if (!entityManager.HasComponent(uid, registration.Type)) { - shell.WriteLine($"No {componentName} component found on entity {entManager.GetComponent(uid).EntityName}."); + shell.WriteLine($"No {componentName} component found on entity {entityManager.GetComponent(uid).EntityName}."); return; } - entManager.RemoveComponent(uid, registration.Type); + entityManager.RemoveComponent(uid, registration.Type); - shell.WriteLine($"Removed {componentName} component from entity {entManager.GetComponent(uid).EntityName}."); + shell.WriteLine($"Removed {componentName} component from entity {entityManager.GetComponent(uid).EntityName}."); } } } diff --git a/Robust.Server/Console/Commands/TestbedCommand.cs b/Robust.Server/Console/Commands/TestbedCommand.cs index 7310f5caee..f9d738f154 100644 --- a/Robust.Server/Console/Commands/TestbedCommand.cs +++ b/Robust.Server/Console/Commands/TestbedCommand.cs @@ -122,7 +122,7 @@ namespace Robust.Server.Console.Commands var entityManager = IoCManager.Resolve(); var groundUid = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)); - var ground = IoCManager.Resolve().AddComponent(groundUid); + var ground = entityManager.AddComponent(groundUid); var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0)); var horizontalFixture = new Fixture(ground, horizontal) @@ -163,7 +163,7 @@ namespace Robust.Server.Console.Commands var boxUid = entityManager.SpawnEntity(null, new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)); - var box = IoCManager.Resolve().AddComponent(boxUid); + var box = entityManager.AddComponent(boxUid); box.BodyType = BodyType.Dynamic; shape = new PolygonShape(); @@ -188,7 +188,7 @@ namespace Robust.Server.Console.Commands var entityManager = IoCManager.Resolve(); var groundUid = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)); - var ground = IoCManager.Resolve().AddComponent(groundUid); + var ground = entityManager.AddComponent(groundUid); var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0)); var horizontalFixture = new Fixture(ground, horizontal) @@ -228,7 +228,7 @@ namespace Robust.Server.Console.Commands var boxUid = entityManager.SpawnEntity(null, new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)); - var box = IoCManager.Resolve().AddComponent(boxUid); + var box = entityManager.AddComponent(boxUid); box.BodyType = BodyType.Dynamic; shape = new PhysShapeCircle {Radius = 0.5f}; @@ -254,7 +254,7 @@ namespace Robust.Server.Console.Commands // Setup ground var entityManager = IoCManager.Resolve(); var groundUid = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)); - var ground = IoCManager.Resolve().AddComponent(groundUid); + var ground = entityManager.AddComponent(groundUid); var horizontal = new EdgeShape(new Vector2(-40, 0), new Vector2(40, 0)); var horizontalFixture = new Fixture(ground, horizontal) @@ -284,9 +284,9 @@ namespace Robust.Server.Console.Commands for (var j = i; j < count; ++j) { var boxUid = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)); - var box = IoCManager.Resolve().AddComponent(boxUid); + var box = entityManager.AddComponent(boxUid); box.BodyType = BodyType.Dynamic; - IoCManager.Resolve().GetComponent(box.Owner).WorldPosition = y; + entityManager.GetComponent(box.Owner).WorldPosition = y; broadphase.CreateFixture(box, new Fixture(box, shape) { CollisionLayer = 2, diff --git a/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupNode.cs b/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupNode.cs index 06b1dbeeb0..53af6230b3 100644 --- a/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupNode.cs +++ b/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupNode.cs @@ -16,14 +16,18 @@ namespace Robust.Server.GameObjects { get { + var entMan = IoCManager.Resolve(); + foreach (var entity in _entities) { - if (!((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted)) + if (!entMan.Deleted(entity)) { yield return entity; } - if (!IoCManager.Resolve().TryGetComponent(entity, out ContainerManagerComponent? containerManager)) continue; + if (!entMan.TryGetComponent(entity, out ContainerManagerComponent? containerManager)) + continue; + foreach (var container in containerManager.GetAllContainers()) { foreach (var child in container.ContainedEntities) diff --git a/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupSystem.cs b/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupSystem.cs index 3d40d1afb1..dc4459a350 100644 --- a/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupSystem.cs +++ b/Robust.Server/GameObjects/EntitySystems/TileLookup/GridTileLookupSystem.cs @@ -119,9 +119,9 @@ namespace Robust.Server.GameObjects private HashSet GetOrCreateNodes(EntityUid entity) { - if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted) + if (Deleted(entity)) { - throw new InvalidOperationException($"Can't get nodes for deleted entity {IoCManager.Resolve().GetComponent(entity).EntityName}!"); + throw new InvalidOperationException($"Can't get nodes for deleted entity {EntityManager.GetComponent(entity).EntityName}!"); } if (_lastKnownNodes.TryGetValue(entity, out var nodes)) @@ -182,7 +182,7 @@ namespace Robust.Server.GameObjects var entityBounds = GetEntityBox(entity); var results = new Dictionary>(); - foreach (var grid in _mapManager.FindGridsIntersecting(IoCManager.Resolve().GetComponent(entity).MapID, GetEntityBox(entity))) + foreach (var grid in _mapManager.FindGridsIntersecting(EntityManager.GetComponent(entity).MapID, GetEntityBox(entity))) { var indices = new List(); @@ -279,7 +279,7 @@ namespace Robust.Server.GameObjects foreach (var (entity, _) in _lastKnownNodes) { - if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve().GetComponent(entity).GridID == gridId) + if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || EntityManager.GetComponent(entity).GridID == gridId) toRemove.Add(entity); } @@ -298,7 +298,7 @@ namespace Robust.Server.GameObjects /// private void HandleEntityAdd(EntityUid entity) { - if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve().GetComponent(entity).GridID == GridId.Invalid) + if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || EntityManager.GetComponent(entity).GridID == GridId.Invalid) { return; } @@ -349,7 +349,7 @@ namespace Robust.Server.GameObjects // TODO: When Acruid does TileEntities we may actually be able to delete this system if tile lookups become fast enough var gridId = moveEvent.NewPosition.GetGridId(EntityManager); - if ((!IoCManager.Resolve().EntityExists(moveEvent.Sender) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(moveEvent.Sender).EntityLifeStage) >= EntityLifeStage.Deleted || + if ((!EntityManager.EntityExists(moveEvent.Sender) ? EntityLifeStage.Deleted : EntityManager.GetComponent(moveEvent.Sender).EntityLifeStage) >= EntityLifeStage.Deleted || gridId == GridId.Invalid || !moveEvent.NewPosition.IsValid(EntityManager)) { @@ -364,7 +364,7 @@ namespace Robust.Server.GameObjects // Memory leak protection var gridBounds = _mapManager.GetGrid(gridId).WorldBounds; - if (!gridBounds.Contains(IoCManager.Resolve().GetComponent(moveEvent.Sender).WorldPosition)) + if (!gridBounds.Contains(EntityManager.GetComponent(moveEvent.Sender).WorldPosition)) { HandleEntityRemove(moveEvent.Sender); return; diff --git a/Robust.Server/Maps/MapLoader.cs b/Robust.Server/Maps/MapLoader.cs index 2f271c3307..da71409411 100644 --- a/Robust.Server/Maps/MapLoader.cs +++ b/Robust.Server/Maps/MapLoader.cs @@ -137,7 +137,7 @@ namespace Robust.Server.Maps { foreach (var entity in context.Entities) { - IoCManager.Resolve().GetComponent(entity).EntityPaused = true; + _serverEntityManager.GetComponent(entity).EntityPaused = true; } } } @@ -435,7 +435,7 @@ namespace Robust.Server.Maps /// private void ApplyGridFixtures() { - var entManager = IoCManager.Resolve(); + var entManager = _serverEntityManager; var gridFixtures = EntitySystem.Get(); var fixtureSystem = EntitySystem.Get(); @@ -444,7 +444,7 @@ namespace Robust.Server.Maps var gridInternal = (IMapGridInternal) grid; var body = entManager.EnsureComponent(grid.GridEntityId); var mapUid = _mapManager.GetMapEntityIdOrThrow(grid.ParentMapId); - body.Broadphase = IoCManager.Resolve().GetComponent(mapUid); + body.Broadphase = entManager.GetComponent(mapUid); var fixtures = entManager.EnsureComponent(grid.GridEntityId); gridFixtures.ProcessGrid(gridInternal); @@ -504,7 +504,7 @@ namespace Robust.Server.Maps var pvs = EntitySystem.Get(); foreach (var entity in Entities) { - if (IoCManager.Resolve().TryGetComponent(entity, out IMapGridComponent? grid)) + if (_serverEntityManager.TryGetComponent(entity, out IMapGridComponent? grid)) { var castGrid = (MapGrid) grid.Grid; castGrid.GridEntityId = entity; @@ -609,7 +609,7 @@ namespace Robust.Server.Maps if (_loadOptions!.StoreMapUids) { - var comp = IoCManager.Resolve().AddComponent(entity); + var comp = _serverEntityManager.AddComponent(entity); comp.Uid = uid; } } @@ -730,7 +730,7 @@ namespace Robust.Server.Maps if (IsMapSavable(entity)) { Entities.Add(entity); - if (IoCManager.Resolve().TryGetComponent(entity, out MapSaveIdComponent? mapSaveId)) + if (_serverEntityManager.TryGetComponent(entity, out MapSaveIdComponent? mapSaveId)) { withUid.Add(mapSaveId); } @@ -802,7 +802,7 @@ namespace Robust.Server.Maps var components = new YamlSequenceNode(); // See engine#636 for why the Distinct() call. - foreach (var component in IoCManager.Resolve().GetComponents(entity)) + foreach (var component in _serverEntityManager.GetComponents(entity)) { if (component is MapSaveIdComponent) continue; @@ -870,17 +870,17 @@ namespace Robust.Server.Maps private bool IsMapSavable(EntityUid entity) { - if (IoCManager.Resolve().GetComponent(entity).EntityPrototype?.MapSavable == false || !GridIDMap.ContainsKey(IoCManager.Resolve().GetComponent(entity).GridID)) + if (_serverEntityManager.GetComponent(entity).EntityPrototype?.MapSavable == false || !GridIDMap.ContainsKey(_serverEntityManager.GetComponent(entity).GridID)) { return false; } // Don't serialize things parented to un savable things. // For example clothes inside a person. - var current = IoCManager.Resolve().GetComponent(entity); + var current = _serverEntityManager.GetComponent(entity); while (current.Parent != null) { - if (IoCManager.Resolve().GetComponent(current.Parent.Owner).EntityPrototype?.MapSavable == false) + if (_serverEntityManager.GetComponent(current.Parent.Owner).EntityPrototype?.MapSavable == false) { return false; } diff --git a/Robust.Server/Placement/PlacementManager.cs b/Robust.Server/Placement/PlacementManager.cs index a29d279577..2cdbd7a122 100644 --- a/Robust.Server/Placement/PlacementManager.cs +++ b/Robust.Server/Placement/PlacementManager.cs @@ -121,7 +121,7 @@ namespace Robust.Server.Placement { var created = _entityManager.SpawnEntity(entityTemplateName, coordinates); - IoCManager.Resolve().GetComponent(created).LocalRotation = dirRcv.ToAngle(); + _entityManager.GetComponent(created).LocalRotation = dirRcv.ToAngle(); } else { @@ -212,9 +212,9 @@ namespace Robust.Server.Placement foreach (EntityUid entity in IoCManager.Resolve().GetEntitiesIntersecting(start.GetMapId(_entityManager), new Box2(start.Position, start.Position + rectSize))) { - if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve().HasComponent(entity) || IoCManager.Resolve().HasComponent(entity)) + if (_entityManager.Deleted(entity) || _entityManager.HasComponent(entity) || _entityManager.HasComponent(entity)) continue; - IoCManager.Resolve().DeleteEntity(entity); + _entityManager.DeleteEntity(entity); } } @@ -223,7 +223,7 @@ namespace Robust.Server.Placement /// public void SendPlacementBegin(EntityUid mob, int range, string objectType, string alignOption) { - if (!IoCManager.Resolve().TryGetComponent(mob, out var actor)) + if (!_entityManager.TryGetComponent(mob, out var actor)) return; var playerConnection = actor.PlayerSession.ConnectedClient; @@ -244,7 +244,7 @@ namespace Robust.Server.Placement /// public void SendPlacementBeginTile(EntityUid mob, int range, string tileType, string alignOption) { - if (!IoCManager.Resolve().TryGetComponent(mob, out var actor)) + if (!_entityManager.TryGetComponent(mob, out var actor)) return; var playerConnection = actor.PlayerSession.ConnectedClient; @@ -265,7 +265,7 @@ namespace Robust.Server.Placement /// public void SendPlacementCancel(EntityUid mob) { - if (!IoCManager.Resolve().TryGetComponent(mob, out var actor)) + if (!_entityManager.TryGetComponent(mob, out var actor)) return; var playerConnection = actor.PlayerSession.ConnectedClient; diff --git a/Robust.Server/Player/PlayerSession.cs b/Robust.Server/Player/PlayerSession.cs index 77b601865e..694becdc9a 100644 --- a/Robust.Server/Player/PlayerSession.cs +++ b/Robust.Server/Player/PlayerSession.cs @@ -4,7 +4,6 @@ using Robust.Server.GameObjects; using Robust.Shared.Enums; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; -using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Network; using Robust.Shared.Players; @@ -140,7 +139,7 @@ namespace Robust.Server.Player return; #if EXCEPTION_TOLERANCE - if (!IoCManager.Resolve().EntityExists(AttachedEntity!.Value)) + if (!IoCManager.Resolve().Deleted(AttachedEntity!.Value)) { Logger.Warning($"Player \"{this}\" was attached to an entity that was deleted. THIS SHOULD NEVER HAPPEN, BUT DOES."); // We can't contact ActorSystem because trying to fire an entity event would crash. @@ -175,14 +174,6 @@ namespace Robust.Server.Player UpdatePlayerState(); } - private void SetAttachedEntityName() - { - if (Name != null && AttachedEntity != null) - { - IoCManager.Resolve().GetComponent(AttachedEntity.Value).EntityName = Name; - } - } - /// /// Causes the session to switch from the lobby to the game. /// diff --git a/Robust.Shared/GameObjects/EntitySystem.Proxy.cs b/Robust.Shared/GameObjects/EntitySystem.Proxy.cs index 0fb68aa024..8912f17b0f 100644 --- a/Robust.Shared/GameObjects/EntitySystem.Proxy.cs +++ b/Robust.Shared/GameObjects/EntitySystem.Proxy.cs @@ -47,12 +47,15 @@ public partial class EntitySystem } /// - /// Retrieves whether the entity is deleted. Throws if the entity does not exist. + /// Retrieves whether the entity is deleted or is nonexistent. /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public bool Deleted(EntityUid uid, MetaDataComponent? metaData = null) { - return LifeStage(uid, metaData) >= EntityLifeStage.Deleted; + if (!Resolve(uid, ref metaData)) + return true; + + return metaData.EntityDeleted; } /// @@ -116,23 +119,6 @@ public partial class EntitySystem return true; } - /// - /// Attempts to retrieve whether the entity is deleted. - /// - /// Whether it could be retrieved. - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public bool TryDeleted(EntityUid uid, [NotNullWhen(true)] out bool? deleted, MetaDataComponent? metaData = null) - { - if (!TryLifeStage(uid, out var lifeStage, metaData)) - { - deleted = null; - return false; - } - - deleted = lifeStage >= EntityLifeStage.Deleted; - return true; - } - /// /// Attempts to retrieve the life-stage of the entity. ///