Inline TryGetComponent completely, for real

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:17:01 +01:00
parent 2ff4ec65d5
commit 69b270017b
425 changed files with 1143 additions and 995 deletions

View File

@@ -85,7 +85,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!playerEntity.TryGetComponent<ClientActionsComponent>(out var actionsComponent)) return false; !IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity.Uid, out var actionsComponent)) return false;
actionsComponent.HandleHotbarKeybind(slot, args); actionsComponent.HandleHotbarKeybind(slot, args);
return true; return true;
@@ -99,7 +99,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false; !IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity.Uid, out var actionsComponent)) return false;
actionsComponent.HandleChangeHotbarKeybind(hotbar, args); actionsComponent.HandleChangeHotbarKeybind(hotbar, args);
return true; return true;
@@ -111,7 +111,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false; !IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity.Uid, out var actionsComponent)) return false;
return actionsComponent.TargetingOnUse(args); return actionsComponent.TargetingOnUse(args);
} }
@@ -120,7 +120,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return; !IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity.Uid, out var actionsComponent)) return;
actionsComponent.ToggleActionsMenu(); actionsComponent.ToggleActionsMenu();
} }

View File

@@ -231,7 +231,7 @@ namespace Content.Client.Actions.UI
{ {
ActionPrototype actionPrototype => new ActionAttempt(actionPrototype), ActionPrototype actionPrototype => new ActionAttempt(actionPrototype),
ItemActionPrototype itemActionPrototype => ItemActionPrototype itemActionPrototype =>
(Item != null && Item.TryGetComponent<ItemActionsComponent>(out var itemActions)) ? (Item != null && IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemActionsComponent?>(Item.Uid, out var itemActions)) ?
new ItemActionAttempt(itemActionPrototype, Item, itemActions) : null, new ItemActionAttempt(itemActionPrototype, Item, itemActions) : null,
_ => null _ => null
}; };
@@ -504,7 +504,7 @@ namespace Content.Client.Actions.UI
if (Item != null) if (Item != null)
{ {
SetItemIcon(Item.TryGetComponent<ISpriteComponent>(out var spriteComponent) ? spriteComponent : null); SetItemIcon(IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(Item.Uid, out var spriteComponent) ? spriteComponent : null);
} }
else else
{ {

View File

@@ -17,7 +17,7 @@ namespace Content.Client.Animations
var animatableClone = IoCManager.Resolve<IEntityManager>().SpawnEntity("clientsideclone", initialPosition); var animatableClone = IoCManager.Resolve<IEntityManager>().SpawnEntity("clientsideclone", initialPosition);
animatableClone.Name = entity.Name; animatableClone.Name = entity.Name;
if (!entity.TryGetComponent(out SpriteComponent? sprite0)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SpriteComponent? sprite0))
{ {
Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entity.Name, nameof(SpriteComponent)); Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entity.Name, nameof(SpriteComponent));
return; return;

View File

@@ -41,7 +41,7 @@ namespace Content.Client.Atmos.Visualizers
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent<ISpriteComponent>(out var sprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(entity.Uid, out var sprite))
return; return;
if (_connectorRsi == null) if (_connectorRsi == null)

View File

@@ -136,7 +136,7 @@ namespace Content.Client.Audio
foreach (var entity in _lookup.GetEntitiesInRange(coordinates, _maxAmbientRange, foreach (var entity in _lookup.GetEntitiesInRange(coordinates, _maxAmbientRange,
LookupFlags.Approximate | LookupFlags.IncludeAnchored)) LookupFlags.Approximate | LookupFlags.IncludeAnchored))
{ {
if (!entity.TryGetComponent(out AmbientSoundComponent? ambientComp) || if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AmbientSoundComponent? ambientComp) ||
_playingSounds.ContainsKey(ambientComp) || _playingSounds.ContainsKey(ambientComp) ||
!ambientComp.Enabled || !ambientComp.Enabled ||
// We'll also do this crude distance check because it's what we're doing in the active loop above. // We'll also do this crude distance check because it's what we're doing in the active loop above.

View File

@@ -1,6 +1,7 @@
using Content.Shared.Buckle.Components; using Content.Shared.Buckle.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Buckle namespace Content.Client.Buckle
{ {
@@ -30,7 +31,7 @@ namespace Content.Client.Buckle
LastEntityBuckledTo = buckle.LastEntityBuckledTo; LastEntityBuckledTo = buckle.LastEntityBuckledTo;
DontCollide = buckle.DontCollide; DontCollide = buckle.DontCollide;
if (!Owner.TryGetComponent(out SpriteComponent? ownerSprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SpriteComponent? ownerSprite))
{ {
return; return;
} }

View File

@@ -33,7 +33,7 @@ namespace Content.Client.Buckle
{ {
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner.Uid); var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner.Uid);
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(sprite.Owner.Uid, out AnimationPlayerComponent? animation))
{ {
sprite.Rotation = rotation; sprite.Rotation = rotation;
return; return;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Cargo;
using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.Cargo.Components.SharedCargoConsoleComponent; using static Content.Shared.Cargo.Components.SharedCargoConsoleComponent;
using static Robust.Client.UserInterface.Controls.BaseButton; using static Robust.Client.UserInterface.Controls.BaseButton;
@@ -49,8 +50,8 @@ namespace Content.Client.Cargo
{ {
base.Open(); base.Open();
if (!Owner.Owner.TryGetComponent(out GalacticMarketComponent? market) || if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out GalacticMarketComponent? market) ||
!Owner.Owner.TryGetComponent(out CargoOrderDatabaseComponent? orders)) return; !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out CargoOrderDatabaseComponent? orders)) return;
Market = market; Market = market;
Orders = orders; Orders = orders;

View File

@@ -50,7 +50,7 @@ namespace Content.Client.CharacterAppearance.Systems
{ {
foreach (var (part, _) in body.Parts) foreach (var (part, _) in body.Parts)
{ {
if (part.Owner.TryGetComponent(out SpriteComponent? partSprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(part.Owner.Uid, out SpriteComponent? partSprite))
{ {
partSprite!.Color = component.Appearance.SkinColor; partSprite!.Color = component.Appearance.SkinColor;
} }
@@ -108,7 +108,7 @@ namespace Content.Client.CharacterAppearance.Systems
private void BodyPartAdded(HumanoidAppearanceBodyPartAddedEvent args) private void BodyPartAdded(HumanoidAppearanceBodyPartAddedEvent args)
{ {
if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return; if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return;
if (!owner.TryGetComponent(out SpriteComponent? sprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out SpriteComponent? sprite))
{ {
return; return;
} }
@@ -132,7 +132,7 @@ namespace Content.Client.CharacterAppearance.Systems
private void BodyPartRemoved(HumanoidAppearanceBodyPartRemovedEvent args) private void BodyPartRemoved(HumanoidAppearanceBodyPartRemovedEvent args)
{ {
if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return; if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return;
if (!owner.TryGetComponent(out SpriteComponent? sprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner.Uid, out SpriteComponent? sprite))
{ {
return; return;
} }

View File

@@ -50,7 +50,7 @@ namespace Content.Client.CharacterInfo.Components
{ {
case CharacterInfoMessage characterInfoMessage: case CharacterInfoMessage characterInfoMessage:
_control.UpdateUI(characterInfoMessage); _control.UpdateUI(characterInfoMessage);
if (Owner.TryGetComponent(out ISpriteComponent? spriteComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ISpriteComponent? spriteComponent))
{ {
_control.SpriteView.Sprite = spriteComponent; _control.SpriteView.Sprite = spriteComponent;
} }

View File

@@ -38,7 +38,7 @@ namespace Content.Client.CharacterInterface
private void HandleOpenCharacterMenu() private void HandleOpenCharacterMenu()
{ {
if (_playerManager.LocalPlayer?.ControlledEntity == null if (_playerManager.LocalPlayer?.ControlledEntity == null
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out CharacterInterfaceComponent? characterInterface)) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(_playerManager.LocalPlayer.ControlledEntity.Uid, out CharacterInterfaceComponent? characterInterface))
{ {
return; return;
} }

View File

@@ -29,7 +29,7 @@ namespace Content.Client.Clickable
/// <returns>True if the click worked, false otherwise.</returns> /// <returns>True if the click worked, false otherwise.</returns>
public bool CheckClick(Vector2 worldPos, out int drawDepth, out uint renderOrder) public bool CheckClick(Vector2 worldPos, out int drawDepth, out uint renderOrder)
{ {
if (!Owner.TryGetComponent(out ISpriteComponent? sprite) || !sprite.Visible) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite) || !sprite.Visible)
{ {
drawDepth = default; drawDepth = default;
renderOrder = default; renderOrder = default;

View File

@@ -42,7 +42,7 @@ namespace Content.Client.Clothing
if (!Owner.TryGetContainer(out IContainer? container)) if (!Owner.TryGetContainer(out IContainer? container))
return; return;
if (!container.Owner.TryGetComponent(out ClientInventoryComponent? inventory)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(container.Owner.Uid, out ClientInventoryComponent? inventory))
return; return;
if (!inventory.TryFindItemSlots(Owner, out EquipmentSlotDefines.Slots? slots)) if (!inventory.TryFindItemSlots(Owner, out EquipmentSlotDefines.Slots? slots))
return; return;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Targeting;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -34,7 +35,7 @@ namespace Content.Client.CombatMode
public bool IsInCombatMode() public bool IsInCombatMode()
{ {
var entity = _playerManager.LocalPlayer?.ControlledEntity; var entity = _playerManager.LocalPlayer?.ControlledEntity;
if (entity == null || !entity.TryGetComponent(out CombatModeComponent? combatMode)) if (entity == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out CombatModeComponent? combatMode))
{ {
return false; return false;
} }

View File

@@ -55,7 +55,7 @@ namespace Content.Client.Commands
foreach (var component in components) foreach (var component in components)
{ {
if (component.Owner.TryGetComponent(out ISpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out ISpriteComponent? sprite))
{ {
sprite.DrawDepth = (int) DrawDepth.Overlays; sprite.DrawDepth = (int) DrawDepth.Overlays;
} }

View File

@@ -21,7 +21,7 @@ namespace Content.Client.Commands
foreach (var mechanism in mechanisms) foreach (var mechanism in mechanisms)
{ {
if (!mechanism.Owner.TryGetComponent(out SpriteComponent? sprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(mechanism.Owner.Uid, out SpriteComponent? sprite))
{ {
continue; continue;
} }

View File

@@ -23,7 +23,7 @@ namespace Content.Client.Commands
foreach (var mechanism in mechanisms) foreach (var mechanism in mechanisms)
{ {
if (mechanism.Owner.TryGetComponent(out SpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(mechanism.Owner.Uid, out SpriteComponent? sprite))
{ {
sprite.ContainerOccluded = false; sprite.ContainerOccluded = false;
} }

View File

@@ -5,6 +5,7 @@ using Robust.Client.Graphics;
using Robust.Client.Placement; using Robust.Client.Placement;
using Robust.Client.Utility; using Robust.Client.Utility;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
namespace Content.Client.Construction namespace Content.Client.Construction
@@ -37,7 +38,7 @@ namespace Content.Client.Construction
/// <inheritdoc /> /// <inheritdoc />
public override bool HijackDeletion(IEntity entity) public override bool HijackDeletion(IEntity entity)
{ {
if (entity.TryGetComponent(out ConstructionGhostComponent? ghost)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ConstructionGhostComponent? ghost))
{ {
_constructionSystem.ClearGhost(ghost.GhostId); _constructionSystem.ClearGhost(ghost.GhostId);
} }

View File

@@ -147,7 +147,7 @@ namespace Content.Client.Construction
var entity = EntityManager.GetEntity(args.EntityUid); var entity = EntityManager.GetEntity(args.EntityUid);
if (!entity.TryGetComponent<ConstructionGhostComponent>(out var ghostComp)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ConstructionGhostComponent?>(entity.Uid, out var ghostComp))
return false; return false;
TryStartConstruction(ghostComp.GhostId); TryStartConstruction(ghostComp.GhostId);

View File

@@ -39,8 +39,8 @@ namespace Content.Client.ContextMenu.UI
(a, b) => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(a.Uid).EntityPrototype!.ID == IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(b.Uid).EntityPrototype!.ID, (a, b) => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(a.Uid).EntityPrototype!.ID == IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(b.Uid).EntityPrototype!.ID,
(a, b) => (a, b) =>
{ {
a.TryGetComponent<ISpriteComponent>(out var spriteA); IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(a.Uid, out var spriteA);
b.TryGetComponent<ISpriteComponent>(out var spriteB); IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(b.Uid, out var spriteB);
if (spriteA == null || spriteB == null) if (spriteA == null || spriteB == null)
return spriteA == spriteB; return spriteA == spriteB;

View File

@@ -2,6 +2,7 @@
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Cuffs.Components namespace Content.Client.Cuffs.Components
{ {
@@ -21,7 +22,7 @@ namespace Content.Client.Cuffs.Components
return; return;
} }
if (Owner.TryGetComponent<SpriteComponent>(out var sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(Owner.Uid, out var sprite))
{ {
sprite.LayerSetState(0, new RSI.StateId(state.IconState)); // TODO: safety check to see if RSI contains the state? sprite.LayerSetState(0, new RSI.StateId(state.IconState)); // TODO: safety check to see if RSI contains the state?
} }

View File

@@ -291,8 +291,8 @@ namespace Content.Client.Damage
private void InitializeVisualizer(IEntity entity, DamageVisualizerDataComponent damageData) private void InitializeVisualizer(IEntity entity, DamageVisualizerDataComponent damageData)
{ {
if (!entity.TryGetComponent<SpriteComponent>(out SpriteComponent? spriteComponent) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SpriteComponent? spriteComponent)
|| !entity.TryGetComponent<DamageableComponent>(out var damageComponent) || !IoCManager.Resolve<IEntityManager>().TryGetComponent<DamageableComponent?>(entity.Uid, out var damageComponent)
|| !IoCManager.Resolve<IEntityManager>().HasComponent<AppearanceComponent>(entity.Uid)) || !IoCManager.Resolve<IEntityManager>().HasComponent<AppearanceComponent>(entity.Uid))
return; return;

View File

@@ -3,6 +3,8 @@ using Content.Client.Disposal.Components;
using Content.Client.Disposal.UI; using Content.Client.Disposal.UI;
using Content.Shared.Disposal; using Content.Shared.Disposal;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Disposal.Systems namespace Content.Client.Disposal.Systems
{ {
@@ -38,7 +40,7 @@ namespace Content.Client.Disposal.Systems
{ {
if (component.Deleted) return true; if (component.Deleted) return true;
if (!component.Owner.TryGetComponent(out ClientUserInterfaceComponent? userInterface)) return true; if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out ClientUserInterfaceComponent? userInterface)) return true;
var state = component.UiState; var state = component.UiState;
if (state == null) return true; if (state == null) return true;

View File

@@ -3,6 +3,7 @@ using Content.Client.Disposal.Systems;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using static Content.Shared.Disposal.Components.SharedDisposalUnitComponent; using static Content.Shared.Disposal.Components.SharedDisposalUnitComponent;
namespace Content.Client.Disposal.UI namespace Content.Client.Disposal.UI
@@ -52,7 +53,7 @@ namespace Content.Client.Disposal.UI
Window?.UpdateState(cast); Window?.UpdateState(cast);
// Kinda icky but we just want client to handle its own lerping and not flood bandwidth for it. // Kinda icky but we just want client to handle its own lerping and not flood bandwidth for it.
if (!Owner.Owner.TryGetComponent(out DisposalUnitComponent? component)) return; if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out DisposalUnitComponent? component)) return;
component.UiState = cast; component.UiState = cast;
EntitySystem.Get<DisposalUnitSystem>().UpdateActive(component, true); EntitySystem.Get<DisposalUnitSystem>().UpdateActive(component, true);

View File

@@ -153,7 +153,7 @@ namespace Content.Client.DoAfter.UI
} }
if (RETURNED_VALUE != true || if (RETURNED_VALUE != true ||
!AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent)) !IoCManager.Resolve<IEntityManager>().TryGetComponent(AttachedEntity.Uid, out DoAfterComponent? doAfterComponent))
{ {
Visible = false; Visible = false;
return; return;

View File

@@ -183,7 +183,7 @@ namespace Content.Client.DragDrop
return false; return false;
} }
if (_dragDropHelper.Dragged.TryGetComponent<SpriteComponent>(out var draggedSprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(_dragDropHelper.Dragged.Uid, out var draggedSprite))
{ {
// pop up drag shadow under mouse // pop up drag shadow under mouse
var mousePos = _eyeManager.ScreenToMap(_dragDropHelper.MouseScreenPosition); var mousePos = _eyeManager.ScreenToMap(_dragDropHelper.MouseScreenPosition);
@@ -374,7 +374,7 @@ namespace Content.Client.DragDrop
var pvsEntities = IoCManager.Resolve<IEntityLookup>().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.IncludeAnchored); var pvsEntities = IoCManager.Resolve<IEntityLookup>().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.IncludeAnchored);
foreach (var pvsEntity in pvsEntities) foreach (var pvsEntity in pvsEntities)
{ {
if (!pvsEntity.TryGetComponent(out ISpriteComponent? inRangeSprite) || if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pvsEntity.Uid, out ISpriteComponent? inRangeSprite) ||
!inRangeSprite.Visible || !inRangeSprite.Visible ||
pvsEntity == _dragDropHelper.Dragged) continue; pvsEntity == _dragDropHelper.Dragged) continue;

View File

@@ -136,7 +136,7 @@ namespace Content.Client.Examine
}; };
vBox.AddChild(hBox); vBox.AddChild(hBox);
if (entity.TryGetComponent(out ISpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ISpriteComponent? sprite))
{ {
hBox.AddChild(new SpriteView { Sprite = sprite, OverrideDirection = Direction.South }); hBox.AddChild(new SpriteView { Sprite = sprite, OverrideDirection = Direction.South });
} }

View File

@@ -36,7 +36,7 @@ namespace Content.Client.Ghost
foreach (var ghost in EntityManager.GetAllComponents(typeof(GhostComponent), true)) foreach (var ghost in EntityManager.GetAllComponents(typeof(GhostComponent), true))
{ {
if (ghost.Owner.TryGetComponent(out SpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(ghost.Owner.Uid, out SpriteComponent? sprite))
{ {
sprite.Visible = value; sprite.Visible = value;
} }
@@ -60,7 +60,7 @@ namespace Content.Client.Ghost
private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args) private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args)
{ {
if (component.Owner.TryGetComponent(out SpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner.Uid, out SpriteComponent? sprite))
{ {
sprite.Visible = GhostVisibility; sprite.Visible = GhostVisibility;
} }
@@ -104,7 +104,7 @@ namespace Content.Client.Ghost
var entity = _playerManager.LocalPlayer?.ControlledEntity; var entity = _playerManager.LocalPlayer?.ControlledEntity;
if (entity == null || if (entity == null ||
!entity.TryGetComponent(out GhostComponent? ghost)) !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out GhostComponent? ghost))
{ {
return; return;
} }

View File

@@ -42,7 +42,7 @@ namespace Content.Client.Gravity
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent(out SpriteComponent? sprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SpriteComponent? sprite))
return; return;
sprite.LayerMapReserveBlank(GravityGeneratorVisualLayers.Base); sprite.LayerMapReserveBlank(GravityGeneratorVisualLayers.Base);

View File

@@ -1,6 +1,7 @@
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Hands namespace Content.Client.Hands
{ {
@@ -37,7 +38,7 @@ namespace Content.Client.Hands
public void UpdateHandContainers() public void UpdateHandContainers()
{ {
if (!Owner.TryGetComponent<ContainerManagerComponent>(out var containerMan)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(Owner.Uid, out var containerMan))
return; return;
foreach (var hand in Hands) foreach (var hand in Hands)

View File

@@ -89,7 +89,7 @@ namespace Content.Client.Hands
{ {
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalPlayer?.ControlledEntity;
if (player == null || !player.TryGetComponent(out HandsComponent? hands)) if (player == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(player.Uid, out HandsComponent? hands))
return null; return null;
return hands; return hands;

View File

@@ -77,8 +77,8 @@ namespace Content.Client.HealthOverlay.UI
return; return;
} }
if (!Entity.TryGetComponent(out MobStateComponent? mobState) || if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Entity.Uid, out MobStateComponent? mobState) ||
!Entity.TryGetComponent(out DamageableComponent? damageable)) !IoCManager.Resolve<IEntityManager>().TryGetComponent(Entity.Uid, out DamageableComponent? damageable))
{ {
CritBar.Visible = false; CritBar.Visible = false;
HealthBar.Visible = false; HealthBar.Visible = false;

View File

@@ -53,7 +53,7 @@ namespace Content.Client.IconSmoothing
var senderEnt = ev.Sender; var senderEnt = ev.Sender;
if (IoCManager.Resolve<IEntityManager>().EntityExists(senderEnt.Uid) && if (IoCManager.Resolve<IEntityManager>().EntityExists(senderEnt.Uid) &&
_mapManager.TryGetGrid(senderEnt.Transform.GridID, out var grid1) && _mapManager.TryGetGrid(senderEnt.Transform.GridID, out var grid1) &&
senderEnt.TryGetComponent(out IconSmoothComponent? iconSmooth) IoCManager.Resolve<IEntityManager>().TryGetComponent(senderEnt.Uid, out IconSmoothComponent? iconSmooth)
&& iconSmooth.Running) && iconSmooth.Running)
{ {
var coords = senderEnt.Transform.Coordinates; var coords = senderEnt.Transform.Coordinates;

View File

@@ -1,4 +1,6 @@
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Client.Instruments.UI namespace Content.Client.Instruments.UI
@@ -16,7 +18,7 @@ namespace Content.Client.Instruments.UI
protected override void Open() protected override void Open()
{ {
if (!Owner.Owner.TryGetComponent<InstrumentComponent>(out var instrument)) return; if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<InstrumentComponent?>(Owner.Owner.Uid, out var instrument)) return;
Instrument = instrument; Instrument = instrument;
_instrumentMenu = new InstrumentMenu(this); _instrumentMenu = new InstrumentMenu(this);

View File

@@ -25,7 +25,7 @@ namespace Content.Client.Interactable.Components
{ {
_lastRenderScale = renderScale; _lastRenderScale = renderScale;
_inRange = inInteractionRange; _inRange = inInteractionRange;
if (Owner.TryGetComponent(out ISpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite))
{ {
sprite.PostShader = MakeNewShader(inInteractionRange, renderScale); sprite.PostShader = MakeNewShader(inInteractionRange, renderScale);
sprite.RenderOrder = IoCManager.Resolve<IEntityManager>().CurrentTick.Value; sprite.RenderOrder = IoCManager.Resolve<IEntityManager>().CurrentTick.Value;
@@ -34,7 +34,7 @@ namespace Content.Client.Interactable.Components
public void OnMouseLeave() public void OnMouseLeave()
{ {
if (Owner.TryGetComponent(out ISpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite))
{ {
sprite.PostShader = null; sprite.PostShader = null;
sprite.RenderOrder = 0; sprite.RenderOrder = 0;
@@ -46,7 +46,7 @@ namespace Content.Client.Interactable.Components
public void UpdateInRange(bool inInteractionRange, int renderScale) public void UpdateInRange(bool inInteractionRange, int renderScale)
{ {
if (Owner.TryGetComponent(out ISpriteComponent? sprite) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite)
&& (inInteractionRange != _inRange || _lastRenderScale != renderScale)) && (inInteractionRange != _inRange || _lastRenderScale != renderScale))
{ {
_inRange = inInteractionRange; _inRange = inInteractionRange;

View File

@@ -140,7 +140,7 @@ namespace Content.Client.Inventory
return; return;
} }
if (entity.TryGetComponent(out ClothingComponent? clothing)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothing))
{ {
var flag = SlotMasks[slot]; var flag = SlotMasks[slot];
var data = clothing.GetEquippedStateInfo(flag, SpeciesId); var data = clothing.GetEquippedStateInfo(flag, SpeciesId);

View File

@@ -2,6 +2,7 @@ using Content.Client.Hands;
using Content.Shared.Item; using Content.Shared.Item;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Items.Components namespace Content.Client.Items.Components
{ {
@@ -14,7 +15,7 @@ namespace Content.Client.Items.Components
if (!Owner.TryGetContainer(out var container)) if (!Owner.TryGetContainer(out var container))
return; return;
if (container.Owner.TryGetComponent(out HandsComponent? hands)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(container.Owner.Uid, out HandsComponent? hands))
hands.UpdateHandVisualizer(); hands.UpdateHandVisualizer();
} }
} }

View File

@@ -42,12 +42,12 @@ namespace Content.Client.Items.Managers
else else
{ {
ISpriteComponent? sprite; ISpriteComponent? sprite;
if (entity.TryGetComponent(out HandVirtualItemComponent? virtPull) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out HandVirtualItemComponent? virtPull)
&& _entityManager.TryGetComponent(virtPull.BlockingEntity, out ISpriteComponent pulledSprite)) && _entityManager.TryGetComponent(virtPull.BlockingEntity, out ISpriteComponent pulledSprite))
{ {
sprite = pulledSprite; sprite = pulledSprite;
} }
else if (!entity.TryGetComponent(out sprite)) else if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out sprite))
{ {
return false; return false;
} }
@@ -105,7 +105,7 @@ namespace Content.Client.Items.Managers
if (entity == null || if (entity == null ||
(!IoCManager.Resolve<IEntityManager>().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || (!IoCManager.Resolve<IEntityManager>().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
!entity.TryGetComponent(out ItemCooldownComponent? cooldown) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ItemCooldownComponent? cooldown) ||
!cooldown.CooldownStart.HasValue || !cooldown.CooldownStart.HasValue ||
!cooldown.CooldownEnd.HasValue) !cooldown.CooldownEnd.HasValue)
{ {

View File

@@ -156,7 +156,7 @@ namespace Content.Client.Items.UI
if (_entity == null) if (_entity == null)
return; return;
if (_entity.TryGetComponent(out HandVirtualItemComponent? virtualItem) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_entity.Uid, out HandVirtualItemComponent? virtualItem)
&& _entityManager.TryGetEntity(virtualItem.BlockingEntity, out var blockEnt)) && _entityManager.TryGetEntity(virtualItem.BlockingEntity, out var blockEnt))
{ {
_itemNameLabel.Text = blockEnt.Name; _itemNameLabel.Text = blockEnt.Name;

View File

@@ -121,11 +121,11 @@ namespace Content.Client.Kitchen.UI
} }
Texture? texture; Texture? texture;
if (entity.TryGetComponent(out IconComponent? iconComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IconComponent? iconComponent))
{ {
texture = iconComponent.Icon?.Default; texture = iconComponent.Icon?.Default;
} }
else if (entity.TryGetComponent(out SpriteComponent? spriteComponent)) else if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SpriteComponent? spriteComponent))
{ {
texture = spriteComponent.Icon?.Default; texture = spriteComponent.Icon?.Default;
} }

View File

@@ -37,9 +37,9 @@ namespace Content.Client.Lathe.UI
{ {
base.Open(); base.Open();
if (!Owner.Owner.TryGetComponent(out MaterialStorageComponent? storage) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out MaterialStorageComponent? storage)
|| !Owner.Owner.TryGetComponent(out SharedLatheComponent? lathe) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out SharedLatheComponent? lathe)
|| !Owner.Owner.TryGetComponent(out SharedLatheDatabaseComponent? database)) return; || !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out SharedLatheDatabaseComponent? database)) return;
Storage = storage; Storage = storage;
Lathe = lathe; Lathe = lathe;

View File

@@ -58,7 +58,7 @@ namespace Content.Client.Light.Components
_random = random; _random = random;
_parent = parent; _parent = parent;
if (Enabled && _parent.TryGetComponent(out PointLightComponent? light)) if (Enabled && IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent.Uid, out PointLightComponent? light))
{ {
light.Enabled = true; light.Enabled = true;
} }
@@ -68,7 +68,7 @@ namespace Content.Client.Light.Components
public void UpdatePlaybackValues(Animation owner) public void UpdatePlaybackValues(Animation owner)
{ {
if (_parent.TryGetComponent(out PointLightComponent? light)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent.Uid, out PointLightComponent? light))
{ {
light.Enabled = true; light.Enabled = true;
} }
@@ -99,7 +99,7 @@ namespace Content.Client.Light.Components
throw new InvalidOperationException("Property parameter is null! Check the prototype!"); throw new InvalidOperationException("Property parameter is null! Check the prototype!");
} }
if (_parent.TryGetComponent(out PointLightComponent? light)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent.Uid, out PointLightComponent? light))
{ {
AnimationHelper.SetAnimatableProperty(light, Property, value); AnimationHelper.SetAnimatableProperty(light, Property, value);
} }
@@ -395,7 +395,7 @@ namespace Content.Client.Light.Components
// TODO: Do NOT ensure component here. And use eventbus events instead... // TODO: Do NOT ensure component here. And use eventbus events instead...
Owner.EnsureComponent<AnimationPlayerComponent>(); Owner.EnsureComponent<AnimationPlayerComponent>();
if (Owner.TryGetComponent(out AnimationPlayerComponent? animation)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{ {
#pragma warning disable 618 #pragma warning disable 618
animation.AnimationCompleted += OnAnimationCompleted; animation.AnimationCompleted += OnAnimationCompleted;
@@ -430,7 +430,7 @@ namespace Content.Client.Light.Components
{ {
container.LightBehaviour.UpdatePlaybackValues(container.Animation); container.LightBehaviour.UpdatePlaybackValues(container.Animation);
if (Owner.TryGetComponent(out AnimationPlayerComponent? animation)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{ {
animation.Play(container.Animation, container.FullKey); animation.Play(container.Animation, container.FullKey);
} }
@@ -442,7 +442,7 @@ namespace Content.Client.Light.Components
/// </summary> /// </summary>
private void CopyLightSettings() private void CopyLightSettings()
{ {
if (Owner.TryGetComponent(out PointLightComponent? light)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PointLightComponent? light))
{ {
_originalColor = light.Color; _originalColor = light.Color;
_originalEnabled = light.Enabled; _originalEnabled = light.Enabled;
@@ -463,7 +463,7 @@ namespace Content.Client.Light.Components
/// </summary> /// </summary>
public void StartLightBehaviour(string id = "") public void StartLightBehaviour(string id = "")
{ {
if (!Owner.TryGetComponent(out AnimationPlayerComponent? animation)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{ {
return; return;
} }
@@ -491,7 +491,7 @@ namespace Content.Client.Light.Components
/// <param name="resetToOriginalSettings">Should the light have its original settings applied?</param> /// <param name="resetToOriginalSettings">Should the light have its original settings applied?</param>
public void StopLightBehaviour(string id = "", bool removeBehaviour = false, bool resetToOriginalSettings = false) public void StopLightBehaviour(string id = "", bool removeBehaviour = false, bool resetToOriginalSettings = false)
{ {
if (!Owner.TryGetComponent(out AnimationPlayerComponent? animation)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AnimationPlayerComponent? animation))
{ {
return; return;
} }
@@ -519,7 +519,7 @@ namespace Content.Client.Light.Components
_animations.Remove(container); _animations.Remove(container);
} }
if (resetToOriginalSettings && Owner.TryGetComponent(out PointLightComponent? light)) if (resetToOriginalSettings && IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out PointLightComponent? light))
{ {
light.Color = _originalColor; light.Color = _originalColor;
light.Enabled = _originalEnabled; light.Enabled = _originalEnabled;

View File

@@ -2,6 +2,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Client.MachineLinking namespace Content.Client.MachineLinking
@@ -16,7 +17,7 @@ namespace Content.Client.MachineLinking
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (entity.TryGetComponent(out SpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SpriteComponent? sprite))
{ {
sprite.LayerMapReserveBlank(Layer); sprite.LayerMapReserveBlank(Layer);
} }

View File

@@ -1,5 +1,6 @@
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Markers namespace Content.Client.Markers
{ {
@@ -19,7 +20,7 @@ namespace Content.Client.Markers
{ {
var system = EntitySystem.Get<MarkerSystem>(); var system = EntitySystem.Get<MarkerSystem>();
if (Owner.TryGetComponent(out ISpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ISpriteComponent? sprite))
{ {
sprite.Visible = system.MarkersVisible; sprite.Visible = system.MarkersVisible;
} }

View File

@@ -2,6 +2,7 @@ using Content.Shared.MobState.Components;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
@@ -31,7 +32,7 @@ namespace Content.Client.MobState.Overlays
return false; return false;
} }
if (playerEntity.TryGetComponent<MobStateComponent>(out var mobState)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent<MobStateComponent?>(playerEntity.Uid, out var mobState))
{ {
if (critical) if (critical)
if (mobState.IsCritical()) if (mobState.IsCritical())

View File

@@ -4,6 +4,7 @@ using Content.Shared.Singularity.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
@@ -35,7 +36,7 @@ namespace Content.Client.ParticleAccelerator
public override void InitializeEntity(IEntity entity) public override void InitializeEntity(IEntity entity)
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent<ISpriteComponent>(out var sprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(entity.Uid, out var sprite))
{ {
throw new EntityCreationException("No sprite component found in entity that has ParticleAcceleratorPartVisualizer"); throw new EntityCreationException("No sprite component found in entity that has ParticleAcceleratorPartVisualizer");
} }

View File

@@ -19,8 +19,8 @@ namespace Content.Client.Physics.Controllers
var player = _playerManager.LocalPlayer?.ControlledEntity; var player = _playerManager.LocalPlayer?.ControlledEntity;
if (player == null || if (player == null ||
!player.TryGetComponent(out IMoverComponent? mover) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(player.Uid, out IMoverComponent? mover) ||
!player.TryGetComponent(out PhysicsComponent? body)) return; !IoCManager.Resolve<IEntityManager>().TryGetComponent(player.Uid, out PhysicsComponent? body)) return;
// Essentially we only want to set our mob to predicted so every other entity we just interpolate // Essentially we only want to set our mob to predicted so every other entity we just interpolate
// (i.e. only see what the server has sent us). // (i.e. only see what the server has sent us).
@@ -30,7 +30,7 @@ namespace Content.Client.Physics.Controllers
// We set joints to predicted given these can affect how our mob moves. // We set joints to predicted given these can affect how our mob moves.
// I would only recommend disabling this if you make pulling not use joints anymore (someday maybe?) // I would only recommend disabling this if you make pulling not use joints anymore (someday maybe?)
if (player.TryGetComponent(out JointComponent? jointComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player.Uid, out JointComponent? jointComponent))
{ {
foreach (var joint in jointComponent.GetJoints) foreach (var joint in jointComponent.GetJoints)
{ {
@@ -40,10 +40,10 @@ namespace Content.Client.Physics.Controllers
} }
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother. // If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
if (player.TryGetComponent(out SharedPullableComponent? pullableComp)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player.Uid, out SharedPullableComponent? pullableComp))
{ {
var puller = pullableComp.Puller; var puller = pullableComp.Puller;
if (puller != null && puller.TryGetComponent<PhysicsComponent>(out var pullerBody)) if (puller != null && IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(puller.Uid, out var pullerBody))
{ {
pullerBody.Predict = false; pullerBody.Predict = false;
body.Predict = false; body.Predict = false;
@@ -51,20 +51,20 @@ namespace Content.Client.Physics.Controllers
} }
// If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up. // If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up.
if (player.TryGetComponent(out SharedPullerComponent? pullerComp)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player.Uid, out SharedPullerComponent? pullerComp))
{ {
var pulling = pullerComp.Pulling; var pulling = pullerComp.Pulling;
if (pulling != null && if (pulling != null &&
IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(pulling.Uid) && IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(pulling.Uid) &&
pulling.TryGetComponent(out PhysicsComponent? pullingBody)) IoCManager.Resolve<IEntityManager>().TryGetComponent(pulling.Uid, out PhysicsComponent? pullingBody))
{ {
pullingBody.Predict = false; pullingBody.Predict = false;
} }
} }
// Server-side should just be handled on its own so we'll just do this shizznit // Server-side should just be handled on its own so we'll just do this shizznit
if (player.TryGetComponent(out IMobMoverComponent? mobMover)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(player.Uid, out IMobMoverComponent? mobMover))
{ {
HandleMobMovement(mover, body, mobMover); HandleMobMovement(mover, body, mobMover);
return; return;

View File

@@ -1,6 +1,7 @@
using Content.Shared.Pointing.Components; using Content.Shared.Pointing.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth; using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Client.Pointing.Components namespace Content.Client.Pointing.Components
@@ -12,7 +13,7 @@ namespace Content.Client.Pointing.Components
{ {
base.Startup(); base.Startup();
if (Owner.TryGetComponent(out SpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SpriteComponent? sprite))
{ {
sprite.DrawDepth = (int) DrawDepth.Overlays; sprite.DrawDepth = (int) DrawDepth.Overlays;
} }

View File

@@ -1,6 +1,7 @@
using Content.Shared.Pointing.Components; using Content.Shared.Pointing.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth; using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Client.Pointing.Components namespace Content.Client.Pointing.Components
@@ -12,7 +13,7 @@ namespace Content.Client.Pointing.Components
{ {
base.Startup(); base.Startup();
if (Owner.TryGetComponent(out SpriteComponent? sprite)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out SpriteComponent? sprite))
{ {
sprite.DrawDepth = (int) DrawDepth.Overlays; sprite.DrawDepth = (int) DrawDepth.Overlays;
} }

View File

@@ -27,7 +27,7 @@ namespace Content.Client.Pointing
{ {
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner.Uid); var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner.Uid);
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(sprite.Owner.Uid, out AnimationPlayerComponent? animation))
{ {
sprite.Rotation = rotation; sprite.Rotation = rotation;
return; return;

View File

@@ -3,6 +3,7 @@ using Content.Shared.Recycling;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Client.Recycling namespace Content.Client.Recycling
@@ -20,8 +21,8 @@ namespace Content.Client.Recycling
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (!entity.TryGetComponent(out ISpriteComponent? sprite) || if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ISpriteComponent? sprite) ||
!entity.TryGetComponent(out AppearanceComponent? appearance)) !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AppearanceComponent? appearance))
{ {
return; return;
} }

View File

@@ -2,6 +2,7 @@ using Content.Shared.Research.Prototypes;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using static Content.Shared.Research.Components.SharedResearchConsoleComponent; using static Content.Shared.Research.Components.SharedResearchConsoleComponent;
namespace Content.Client.Research.UI namespace Content.Client.Research.UI
@@ -23,7 +24,7 @@ namespace Content.Client.Research.UI
{ {
base.Open(); base.Open();
if (!Owner.Owner.TryGetComponent(out _technologyDatabase)) return; if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out _technologyDatabase)) return;
_consoleMenu = new ResearchConsoleMenu(this); _consoleMenu = new ResearchConsoleMenu(this);

View File

@@ -35,7 +35,7 @@ namespace Content.Client.Rotation
{ {
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner.Uid); var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner.Uid);
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(sprite.Owner.Uid, out AnimationPlayerComponent? animation))
{ {
sprite.Rotation = rotation; sprite.Rotation = rotation;
return; return;

View File

@@ -1,6 +1,7 @@
using Content.Shared.Singularity.Components; using Content.Shared.Singularity.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
namespace Content.Client.Singularity.Components namespace Content.Client.Singularity.Components
@@ -17,7 +18,7 @@ namespace Content.Client.Singularity.Components
{ {
base.Initialize(); base.Initialize();
if (!Owner.TryGetComponent(out _spriteComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out _spriteComponent))
{ {
Logger.Error($"{nameof(ContainmentFieldComponent)} created without {nameof(SpriteComponent)}"); Logger.Error($"{nameof(ContainmentFieldComponent)} created without {nameof(SpriteComponent)}");
} }

View File

@@ -95,7 +95,7 @@ namespace Content.Client.Singularity
} }
else else
{ {
if (!singuloEntity.TryGetComponent<SingularityDistortionComponent>(out var distortion)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SingularityDistortionComponent?>(singuloEntity.Uid, out var distortion))
{ {
_singularities.Remove(activeSinguloUid); _singularities.Remove(activeSinguloUid);
} }

View File

@@ -5,6 +5,7 @@ using Content.Shared.Stacks;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -83,7 +84,7 @@ namespace Content.Client.Stack
if (_isComposite if (_isComposite
&& _spriteLayers.Count > 0 && _spriteLayers.Count > 0
&& entity.TryGetComponent<ISpriteComponent>(out var spriteComponent)) && IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(entity.Uid, out var spriteComponent))
{ {
var spritePath = _spritePath ?? spriteComponent.BaseRSI!.Path!; var spritePath = _spritePath ?? spriteComponent.BaseRSI!.Path!;

View File

@@ -108,7 +108,7 @@ namespace Content.Client.StationEvents
{ {
if (_entityManager.TryGetEntity(activePulseUid, out var pulseEntity) && if (_entityManager.TryGetEntity(activePulseUid, out var pulseEntity) &&
PulseQualifies(pulseEntity, currentEyeLoc) && PulseQualifies(pulseEntity, currentEyeLoc) &&
pulseEntity.TryGetComponent<RadiationPulseComponent>(out var pulse)) IoCManager.Resolve<IEntityManager>().TryGetComponent<RadiationPulseComponent?>(pulseEntity.Uid, out var pulse))
{ {
var shaderInstance = _pulses[activePulseUid]; var shaderInstance = _pulses[activePulseUid];
shaderInstance.instance.CurrentMapCoords = pulseEntity.Transform.MapPosition.Position; shaderInstance.instance.CurrentMapCoords = pulseEntity.Transform.MapPosition.Position;

View File

@@ -5,6 +5,7 @@ using Content.Shared.Storage.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
@@ -31,7 +32,7 @@ namespace Content.Client.Storage.Visualizers
base.InitializeEntity(entity); base.InitializeEntity(entity);
if (_openIcon != null && if (_openIcon != null &&
entity.TryGetComponent<SpriteComponent>(out var spriteComponent) && IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(entity.Uid, out var spriteComponent) &&
spriteComponent.BaseRSI?.Path != null) spriteComponent.BaseRSI?.Path != null)
{ {
spriteComponent.LayerMapReserveBlank(OpenIcon); spriteComponent.LayerMapReserveBlank(OpenIcon);

View File

@@ -65,7 +65,7 @@ namespace Content.Client.Suspicion
return false; return false;
} }
return _playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out suspicion); return IoCManager.Resolve<IEntityManager>().TryGetComponent(_playerManager.LocalPlayer.ControlledEntity.Uid, out suspicion);
} }
public void UpdateLabel() public void UpdateLabel()

View File

@@ -41,7 +41,7 @@ namespace Content.Client.Suspicion
var viewport = _eyeManager.GetWorldViewport(); var viewport = _eyeManager.GetWorldViewport();
var ent = _playerManager.LocalPlayer?.ControlledEntity; var ent = _playerManager.LocalPlayer?.ControlledEntity;
if (ent == null || ent.TryGetComponent(out SuspicionRoleComponent? sus) != true) if (ent == null || IoCManager.Resolve<IEntityManager>().TryGetComponent(ent.Uid, out SuspicionRoleComponent? sus) != true)
{ {
return; return;
} }
@@ -54,7 +54,7 @@ namespace Content.Client.Suspicion
continue; continue;
} }
if (!ally.TryGetComponent(out IPhysBody? physics)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(ally.Uid, out IPhysBody? physics))
{ {
continue; continue;
} }

View File

@@ -2,6 +2,7 @@
using Content.Shared.VendingMachines; using Content.Shared.VendingMachines;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.VendingMachines.SharedVendingMachineComponent; using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
@@ -22,7 +23,7 @@ namespace Content.Client.VendingMachines
{ {
base.Open(); base.Open();
if (!Owner.Owner.TryGetComponent(out SharedVendingMachineComponent? vendingMachine)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner.Uid, out SharedVendingMachineComponent? vendingMachine))
{ {
return; return;
} }

View File

@@ -115,7 +115,7 @@ namespace Content.Client.Viewport
InteractionOutlineComponent? outline; InteractionOutlineComponent? outline;
if(!_outlineEnabled || !ConfigurationManager.GetCVar(CCVars.OutlineEnabled)) if(!_outlineEnabled || !ConfigurationManager.GetCVar(CCVars.OutlineEnabled))
{ {
if(entityToClick != null && entityToClick.TryGetComponent(out outline)) if(entityToClick != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(entityToClick.Uid, out outline))
{ {
outline.OnMouseLeave(); //Prevent outline remains from persisting post command. outline.OnMouseLeave(); //Prevent outline remains from persisting post command.
} }
@@ -124,7 +124,7 @@ namespace Content.Client.Viewport
if (entityToClick == _lastHoveredEntity) if (entityToClick == _lastHoveredEntity)
{ {
if (entityToClick != null && entityToClick.TryGetComponent(out outline)) if (entityToClick != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(entityToClick.Uid, out outline))
{ {
outline.UpdateInRange(inRange, renderScale); outline.UpdateInRange(inRange, renderScale);
} }
@@ -133,14 +133,14 @@ namespace Content.Client.Viewport
} }
if (_lastHoveredEntity != null && !((!IoCManager.Resolve<IEntityManager>().EntityExists(_lastHoveredEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_lastHoveredEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) && if (_lastHoveredEntity != null && !((!IoCManager.Resolve<IEntityManager>().EntityExists(_lastHoveredEntity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_lastHoveredEntity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted) &&
_lastHoveredEntity.TryGetComponent(out outline)) IoCManager.Resolve<IEntityManager>().TryGetComponent(_lastHoveredEntity.Uid, out outline))
{ {
outline.OnMouseLeave(); outline.OnMouseLeave();
} }
_lastHoveredEntity = entityToClick; _lastHoveredEntity = entityToClick;
if (_lastHoveredEntity != null && _lastHoveredEntity.TryGetComponent(out outline)) if (_lastHoveredEntity != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(_lastHoveredEntity.Uid, out outline))
{ {
outline.OnMouseEnter(inRange, renderScale); outline.OnMouseEnter(inRange, renderScale);
} }
@@ -167,7 +167,7 @@ namespace Content.Client.Viewport
var foundEntities = new List<(IEntity clicked, int drawDepth, uint renderOrder)>(); var foundEntities = new List<(IEntity clicked, int drawDepth, uint renderOrder)>();
foreach (var entity in entities) foreach (var entity in entities)
{ {
if (entity.TryGetComponent<ClickableComponent>(out var component) if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ClickableComponent?>(entity.Uid, out var component)
&& !entity.IsInContainer() && !entity.IsInContainer()
&& component.CheckClick(coordinates.Position, out var drawDepthClicked, out var renderOrder)) && component.CheckClick(coordinates.Position, out var drawDepthClicked, out var renderOrder))
{ {

View File

@@ -39,7 +39,7 @@ namespace Content.Client.Weapons.Melee.Components
offset *= (ResetTime - _time) / ResetTime; offset *= (ResetTime - _time) / ResetTime;
} }
if (Owner.TryGetComponent(out ISpriteComponent? spriteComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out ISpriteComponent? spriteComponent))
{ {
spriteComponent.Offset = offset; spriteComponent.Offset = offset;
} }

View File

@@ -65,7 +65,7 @@ namespace Content.Client.Weapons.Melee
// Due to ISpriteComponent limitations, weapons that don't use an RSI won't have this effect. // Due to ISpriteComponent limitations, weapons that don't use an RSI won't have this effect.
if (EntityManager.TryGetEntity(msg.Source, out var source) && if (EntityManager.TryGetEntity(msg.Source, out var source) &&
msg.TextureEffect && msg.TextureEffect &&
source.TryGetComponent(out ISpriteComponent? sourceSprite) && IoCManager.Resolve<IEntityManager>().TryGetComponent(source.Uid, out ISpriteComponent? sourceSprite) &&
sourceSprite.BaseRSI?.Path != null) sourceSprite.BaseRSI?.Path != null)
{ {
var curTime = _gameTiming.CurTime; var curTime = _gameTiming.CurTime;
@@ -93,7 +93,7 @@ namespace Content.Client.Weapons.Melee
continue; continue;
} }
if (!hitEntity.TryGetComponent(out ISpriteComponent? sprite)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(hitEntity.Uid, out ISpriteComponent? sprite))
{ {
continue; continue;
} }

View File

@@ -48,12 +48,12 @@ namespace Content.Client.Weapons.Ranged
} }
var entity = _playerManager.LocalPlayer?.ControlledEntity; var entity = _playerManager.LocalPlayer?.ControlledEntity;
if (entity == null || !entity.TryGetComponent(out SharedHandsComponent? hands)) if (entity == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out SharedHandsComponent? hands))
{ {
return; return;
} }
if (!hands.TryGetActiveHeldEntity(out var held) || !held.TryGetComponent(out ClientRangedWeaponComponent? weapon)) if (!hands.TryGetActiveHeldEntity(out var held) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(held.Uid, out ClientRangedWeaponComponent? weapon))
{ {
_blocked = true; _blocked = true;
return; return;

View File

@@ -48,8 +48,8 @@ namespace Content.IntegrationTests.Tests.Body
var entityManager = IoCManager.Resolve<IEntityManager>(); var entityManager = IoCManager.Resolve<IEntityManager>();
var human = entityManager.SpawnEntity("HumanBodyAndAppearanceDummy", new MapCoordinates(Vector2.Zero, mapId)); var human = entityManager.SpawnEntity("HumanBodyAndAppearanceDummy", new MapCoordinates(Vector2.Zero, mapId));
Assert.That(human.TryGetComponent(out SharedBodyComponent body)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out SharedBodyComponent body));
Assert.That(human.TryGetComponent(out appearance)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out appearance));
Assert.That(!appearance.TryGetData(RotationVisuals.RotationState, out RotationState _)); Assert.That(!appearance.TryGetData(RotationVisuals.RotationState, out RotationState _));

View File

@@ -66,11 +66,11 @@ namespace Content.IntegrationTests.Tests.Body
var bodySys = EntitySystem.Get<BodySystem>(); var bodySys = EntitySystem.Get<BodySystem>();
var lungSys = EntitySystem.Get<LungSystem>(); var lungSys = EntitySystem.Get<LungSystem>();
Assert.That(human.TryGetComponent(out SharedBodyComponent body)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out SharedBodyComponent body));
var lungs = bodySys.GetComponentsOnMechanisms<LungComponent>(human.Uid, body).ToArray(); var lungs = bodySys.GetComponentsOnMechanisms<LungComponent>(human.Uid, body).ToArray();
Assert.That(lungs.Count, Is.EqualTo(1)); Assert.That(lungs.Count, Is.EqualTo(1));
Assert.That(human.TryGetComponent(out BloodstreamComponent bloodstream)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out BloodstreamComponent bloodstream));
var gas = new GasMixture(1); var gas = new GasMixture(1);
@@ -172,7 +172,7 @@ namespace Content.IntegrationTests.Tests.Body
human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", coordinates); human = entityManager.SpawnEntity("HumanBodyAndBloodstreamDummy", coordinates);
Assert.True(IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(human.Uid)); Assert.True(IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(human.Uid));
Assert.True(human.TryGetComponent(out respirator)); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out respirator));
Assert.False(respirator.Suffocating); Assert.False(respirator.Suffocating);
}); });

View File

@@ -82,13 +82,13 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
device1 = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace); device1 = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace);
Assert.That(device1.TryGetComponent(out networkComponent1), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device1.Uid, out networkComponent1), Is.True);
Assert.That(networkComponent1.Open, Is.True); Assert.That(networkComponent1.Open, Is.True);
Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty)); Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty));
device2 = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace); device2 = entityManager.SpawnEntity("DummyNetworkDevice", MapCoordinates.Nullspace);
Assert.That(device2.TryGetComponent(out networkComponent2), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device2.Uid, out networkComponent2), Is.True);
Assert.That(networkComponent2.Open, Is.True); Assert.That(networkComponent2.Open, Is.True);
Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty)); Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty));
@@ -145,14 +145,14 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
device1 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace); device1 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", MapCoordinates.Nullspace);
Assert.That(device1.TryGetComponent(out networkComponent1), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device1.Uid, out networkComponent1), Is.True);
Assert.That(device1.TryGetComponent(out wirelessNetworkComponent), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device1.Uid, out wirelessNetworkComponent), Is.True);
Assert.That(networkComponent1.Open, Is.True); Assert.That(networkComponent1.Open, Is.True);
Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty)); Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty));
device2 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", new MapCoordinates(new Robust.Shared.Maths.Vector2(0,50), MapId.Nullspace)); device2 = entityManager.SpawnEntity("DummyWirelessNetworkDevice", new MapCoordinates(new Robust.Shared.Maths.Vector2(0,50), MapId.Nullspace));
Assert.That(device2.TryGetComponent(out networkComponent2), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device2.Uid, out networkComponent2), Is.True);
Assert.That(networkComponent2.Open, Is.True); Assert.That(networkComponent2.Open, Is.True);
Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty)); Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty));
@@ -232,14 +232,14 @@ namespace Content.IntegrationTests.Tests.DeviceNetwork
device1 = entityManager.SpawnEntity("DummyWiredNetworkDevice", MapCoordinates.Nullspace); device1 = entityManager.SpawnEntity("DummyWiredNetworkDevice", MapCoordinates.Nullspace);
Assert.That(device1.TryGetComponent(out networkComponent1), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device1.Uid, out networkComponent1), Is.True);
Assert.That(device1.TryGetComponent(out wiredNetworkComponent), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device1.Uid, out wiredNetworkComponent), Is.True);
Assert.That(networkComponent1.Open, Is.True); Assert.That(networkComponent1.Open, Is.True);
Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty)); Assert.That(networkComponent1.Address, Is.Not.EqualTo(string.Empty));
device2 = entityManager.SpawnEntity("DummyWiredNetworkDevice", new MapCoordinates(new Robust.Shared.Maths.Vector2(0, 2), MapId.Nullspace)); device2 = entityManager.SpawnEntity("DummyWiredNetworkDevice", new MapCoordinates(new Robust.Shared.Maths.Vector2(0, 2), MapId.Nullspace));
Assert.That(device2.TryGetComponent(out networkComponent2), Is.True); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(device2.Uid, out networkComponent2), Is.True);
Assert.That(networkComponent2.Open, Is.True); Assert.That(networkComponent2.Open, Is.True);
Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty)); Assert.That(networkComponent2.Address, Is.Not.EqualTo(string.Empty));

View File

@@ -146,7 +146,8 @@ namespace Content.IntegrationTests.Tests.Disposal
disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", disposalUnit.Transform.MapPosition); disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", disposalUnit.Transform.MapPosition);
// Test for components existing // Test for components existing
Assert.True(disposalUnit.TryGetComponent(out unit!)); ref DisposalUnitComponent? comp = ref unit!;
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(disposalUnit.Uid, out comp));
Assert.True(IoCManager.Resolve<IEntityManager>().HasComponent<DisposalEntryComponent>(disposalTrunk.Uid)); Assert.True(IoCManager.Resolve<IEntityManager>().HasComponent<DisposalEntryComponent>(disposalTrunk.Uid));
// Can't insert, unanchored and unpowered // Can't insert, unanchored and unpowered
@@ -190,7 +191,7 @@ namespace Content.IntegrationTests.Tests.Disposal
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
// Remove power need // Remove power need
Assert.True(disposalUnit.TryGetComponent(out ApcPowerReceiverComponent power)); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(disposalUnit.Uid, out ApcPowerReceiverComponent power));
power!.NeedsPower = false; power!.NeedsPower = false;
Assert.True(unit.Powered); Assert.True(unit.Powered);

View File

@@ -65,7 +65,7 @@ namespace Content.IntegrationTests.Tests.Doors
airlock = entityManager.SpawnEntity("AirlockDummy", MapCoordinates.Nullspace); airlock = entityManager.SpawnEntity("AirlockDummy", MapCoordinates.Nullspace);
Assert.True(airlock.TryGetComponent(out doorComponent)); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(airlock.Uid, out doorComponent));
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed)); Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
}); });
@@ -136,9 +136,9 @@ namespace Content.IntegrationTests.Tests.Doors
airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates((0, 0), mapId)); airlock = entityManager.SpawnEntity("AirlockDummy", new MapCoordinates((0, 0), mapId));
Assert.True(physicsDummy.TryGetComponent(out physBody)); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(physicsDummy.Uid, out physBody));
Assert.True(airlock.TryGetComponent(out doorComponent)); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(airlock.Uid, out doorComponent));
Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed)); Assert.That(doorComponent.State, Is.EqualTo(SharedDoorComponent.DoorState.Closed));
}); });

View File

@@ -66,11 +66,13 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
human.Transform.WorldPosition = otherHuman.Transform.WorldPosition; human.Transform.WorldPosition = otherHuman.Transform.WorldPosition;
// Test for components existing // Test for components existing
Assert.True(human.TryGetComponent(out cuffed!), $"Human has no {nameof(CuffableComponent)}"); ref CuffableComponent? comp = ref cuffed!;
Assert.True(human.TryGetComponent(out hands!), $"Human has no {nameof(HandsComponent)}"); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out comp), $"Human has no {nameof(CuffableComponent)}");
Assert.True(human.TryGetComponent(out SharedBodyComponent? _), $"Human has no {nameof(SharedBodyComponent)}"); ref HandsComponent? comp1 = ref hands!;
Assert.True(cuffs.TryGetComponent(out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}"); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out comp1), $"Human has no {nameof(HandsComponent)}");
Assert.True(secondCuffs.TryGetComponent(out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}"); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out SharedBodyComponent? _), $"Human has no {nameof(SharedBodyComponent)}");
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(cuffs.Uid, out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}");
Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(secondCuffs.Uid, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
// Test to ensure cuffed players register the handcuffs // Test to ensure cuffed players register the handcuffs
cuffed.TryAddNewCuffs(human, cuffs); cuffed.TryAddNewCuffs(human, cuffs);

View File

@@ -251,7 +251,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
// spawn and give them an item that has actions // spawn and give them an item that has actions
serverFlashlight = serverEntManager.SpawnEntity("TestFlashlight", serverFlashlight = serverEntManager.SpawnEntity("TestFlashlight",
new EntityCoordinates(serverPlayerEnt.Uid, (0, 0))); new EntityCoordinates(serverPlayerEnt.Uid, (0, 0)));
Assert.That(serverFlashlight.TryGetComponent<ItemActionsComponent>(out var itemActions)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemActionsComponent?>(serverFlashlight.Uid, out var itemActions));
// we expect this only to have a toggle light action initially // we expect this only to have a toggle light action initially
var actionConfigs = itemActions.ActionConfigs.ToList(); var actionConfigs = itemActions.ActionConfigs.ToList();
Assert.That(actionConfigs.Count == 1); Assert.That(actionConfigs.Count == 1);

View File

@@ -54,8 +54,9 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
// Test for climb components existing // Test for climb components existing
// Players and tables should have these in their prototypes. // Players and tables should have these in their prototypes.
Assert.That(human.TryGetComponent(out climbing!), "Human has no climbing"); ref ClimbingComponent? comp = ref climbing!;
Assert.That(table.TryGetComponent(out ClimbableComponent? _), "Table has no climbable"); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out comp), "Human has no climbing");
Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(table.Uid, out ClimbableComponent? _), "Table has no climbable");
// Now let's make the player enter a climbing transitioning state. // Now let's make the player enter a climbing transitioning state.
climbing.IsClimbing = true; climbing.IsClimbing = true;

View File

@@ -6,6 +6,7 @@ using Content.Shared.Alert;
using Content.Shared.Coordinates; using Content.Shared.Coordinates;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
namespace Content.IntegrationTests.Tests.Gravity namespace Content.IntegrationTests.Tests.Gravity
@@ -52,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Gravity
var coordinates = grid.ToCoordinates(); var coordinates = grid.ToCoordinates();
human = entityManager.SpawnEntity("HumanDummy", coordinates); human = entityManager.SpawnEntity("HumanDummy", coordinates);
Assert.True(human.TryGetComponent(out alerts)); Assert.True(IoCManager.Resolve<IEntityManager>().TryGetComponent(human.Uid, out alerts));
}); });
// Let WeightlessSystem and GravitySystem tick // Let WeightlessSystem and GravitySystem tick

View File

@@ -95,7 +95,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
Assert.That(interactUsing, Is.False); Assert.That(interactUsing, Is.False);
Assert.That(interactHand); Assert.That(interactHand);
Assert.That(user.TryGetComponent<HandsComponent>(out var hands)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user.Uid, out var hands));
Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid))); Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid)));
interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid);
@@ -167,7 +167,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
Assert.That(interactUsing, Is.False); Assert.That(interactUsing, Is.False);
Assert.That(interactHand, Is.False); Assert.That(interactHand, Is.False);
Assert.That(user.TryGetComponent<HandsComponent>(out var hands)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user.Uid, out var hands));
Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid))); Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid)));
interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid);
@@ -236,7 +236,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
Assert.That(interactUsing, Is.False); Assert.That(interactUsing, Is.False);
Assert.That(interactHand); Assert.That(interactHand);
Assert.That(user.TryGetComponent<HandsComponent>(out var hands)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user.Uid, out var hands));
Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid))); Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid)));
interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid);
@@ -306,7 +306,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
Assert.That(interactUsing, Is.False); Assert.That(interactUsing, Is.False);
Assert.That(interactHand, Is.False); Assert.That(interactHand, Is.False);
Assert.That(user.TryGetComponent<HandsComponent>(out var hands)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user.Uid, out var hands));
Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid))); Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid)));
interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid);
@@ -391,7 +391,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
Assert.That(interactUsing, Is.False); Assert.That(interactUsing, Is.False);
Assert.That(interactHand); Assert.That(interactHand);
Assert.That(user.TryGetComponent<HandsComponent>(out var hands)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user.Uid, out var hands));
Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid))); Assert.That(hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(item.Uid)));
interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid); interactionSystem.UserInteraction(user, target.Transform.Coordinates, target.Uid);

View File

@@ -4,6 +4,7 @@ using Content.Server.Shuttles;
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics; using Robust.Shared.Physics;
@@ -30,8 +31,8 @@ namespace Content.IntegrationTests.Tests
var grid = mapMan.CreateGrid(mapId); var grid = mapMan.CreateGrid(mapId);
gridEnt = entMan.GetEntity(grid.GridEntityId); gridEnt = entMan.GetEntity(grid.GridEntityId);
Assert.That(gridEnt.TryGetComponent(out ShuttleComponent? shuttleComponent)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(gridEnt.Uid, out ShuttleComponent? shuttleComponent));
Assert.That(gridEnt.TryGetComponent(out PhysicsComponent? physicsComponent)); Assert.That(IoCManager.Resolve<IEntityManager>().TryGetComponent(gridEnt.Uid, out PhysicsComponent? physicsComponent));
Assert.That(physicsComponent!.BodyType, Is.EqualTo(BodyType.Dynamic)); Assert.That(physicsComponent!.BodyType, Is.EqualTo(BodyType.Dynamic));
Assert.That(gridEnt.Transform.LocalPosition, Is.EqualTo(Vector2.Zero)); Assert.That(gridEnt.Transform.LocalPosition, Is.EqualTo(Vector2.Zero));
physicsComponent.ApplyLinearImpulse(Vector2.One); physicsComponent.ApplyLinearImpulse(Vector2.One);

View File

@@ -61,7 +61,7 @@ namespace Content.Server.AI.Components
{ {
get get
{ {
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out MovementSpeedModifierComponent? component))
{ {
return component.CurrentWalkSpeed; return component.CurrentWalkSpeed;
} }
@@ -78,7 +78,7 @@ namespace Content.Server.AI.Components
{ {
get get
{ {
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? component)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out MovementSpeedModifierComponent? component))
{ {
return component.CurrentSprintSpeed; return component.CurrentSprintSpeed;
} }

View File

@@ -55,7 +55,7 @@ namespace Content.Server.AI.EntitySystems
public Faction GetHostileFactions(Faction faction) => _hostileFactions.TryGetValue(faction, out var hostiles) ? hostiles : Faction.None; public Faction GetHostileFactions(Faction faction) => _hostileFactions.TryGetValue(faction, out var hostiles) ? hostiles : Faction.None;
public Faction GetFactions(IEntity entity) => public Faction GetFactions(IEntity entity) =>
entity.TryGetComponent(out AiFactionTagComponent? factionTags) IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AiFactionTagComponent? factionTags)
? factionTags.Factions ? factionTags.Factions
: Faction.None; : Faction.None;

View File

@@ -52,7 +52,7 @@ namespace Content.Server.AI.EntitySystems
{ {
// TODO: Need to generecise this but that will be part of a larger cleanup later anyway. // TODO: Need to generecise this but that will be part of a larger cleanup later anyway.
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(message.Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(message.Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(message.Entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(message.Entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
!message.Entity.TryGetComponent(out UtilityAi? controller)) !IoCManager.Resolve<IEntityManager>().TryGetComponent(message.Entity.Uid, out UtilityAi? controller))
{ {
continue; continue;
} }

View File

@@ -29,7 +29,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
return true; return true;
} }
if (!_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
{ {
return false; return false;
} }
@@ -47,7 +47,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
if (!base.Shutdown(outcome)) if (!base.Shutdown(outcome))
return false; return false;
if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
{ {
combatModeComponent.IsInCombatMode = false; combatModeComponent.IsInCombatMode = false;
} }
@@ -62,13 +62,13 @@ namespace Content.Server.AI.Operators.Combat.Melee
return Outcome.Success; return Outcome.Success;
} }
if (!_owner.TryGetComponent(out HandsComponent? hands) || hands.GetActiveHand == null) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? hands) || hands.GetActiveHand == null)
{ {
return Outcome.Failed; return Outcome.Failed;
} }
var meleeWeapon = hands.GetActiveHand.Owner; var meleeWeapon = hands.GetActiveHand.Owner;
meleeWeapon.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent); IoCManager.Resolve<IEntityManager>().TryGetComponent(meleeWeapon.Uid, out MeleeWeaponComponent? meleeWeaponComponent);
if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length > if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length >
meleeWeaponComponent?.Range) meleeWeaponComponent?.Range)

View File

@@ -29,7 +29,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
return true; return true;
} }
if (!_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
{ {
return false; return false;
} }
@@ -39,7 +39,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
combatModeComponent.IsInCombatMode = true; combatModeComponent.IsInCombatMode = true;
} }
if (_owner.TryGetComponent(out UnarmedCombatComponent? unarmedCombatComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out UnarmedCombatComponent? unarmedCombatComponent))
{ {
_unarmedCombat = unarmedCombatComponent; _unarmedCombat = unarmedCombatComponent;
} }
@@ -56,7 +56,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
if (!base.Shutdown(outcome)) if (!base.Shutdown(outcome))
return false; return false;
if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
{ {
combatModeComponent.IsInCombatMode = false; combatModeComponent.IsInCombatMode = false;
} }

View File

@@ -4,6 +4,7 @@ using Content.Server.Storage.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Operators.Inventory namespace Content.Server.AI.Operators.Inventory
{ {
@@ -58,7 +59,7 @@ namespace Content.Server.AI.Operators.Inventory
return Outcome.Failed; return Outcome.Failed;
} }
if (!_target.TryGetComponent(out EntityStorageComponent? storageComponent) || if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out EntityStorageComponent? storageComponent) ||
storageComponent.IsWeldedShut) storageComponent.IsWeldedShut)
{ {
return Outcome.Failed; return Outcome.Failed;

View File

@@ -1,5 +1,6 @@
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Operators.Inventory namespace Content.Server.AI.Operators.Inventory
{ {
@@ -20,7 +21,7 @@ namespace Content.Server.AI.Operators.Inventory
/// <returns></returns> /// <returns></returns>
public override Outcome Execute(float frameTime) public override Outcome Execute(float frameTime)
{ {
if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }

View File

@@ -1,5 +1,6 @@
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Operators.Inventory namespace Content.Server.AI.Operators.Inventory
{ {
@@ -14,7 +15,7 @@ namespace Content.Server.AI.Operators.Inventory
public override Outcome Execute(float frameTime) public override Outcome Execute(float frameTime)
{ {
if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }

View File

@@ -1,5 +1,6 @@
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Operators.Inventory namespace Content.Server.AI.Operators.Inventory
{ {
@@ -15,7 +16,7 @@ namespace Content.Server.AI.Operators.Inventory
public override Outcome Execute(float frameTime) public override Outcome Execute(float frameTime)
{ {
if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }

View File

@@ -33,7 +33,7 @@ namespace Content.Server.AI.Operators.Inventory
return Outcome.Failed; return Outcome.Failed;
} }
if (_owner.TryGetComponent(out CombatModeComponent? combatModeComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out CombatModeComponent? combatModeComponent))
{ {
combatModeComponent.IsInCombatMode = false; combatModeComponent.IsInCombatMode = false;
} }

View File

@@ -5,6 +5,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Operators.Inventory namespace Content.Server.AI.Operators.Inventory
{ {
@@ -34,7 +35,7 @@ namespace Content.Server.AI.Operators.Inventory
return Outcome.Failed; return Outcome.Failed;
} }
if (!container.Owner.TryGetComponent(out EntityStorageComponent? storageComponent) || if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(container.Owner.Uid, out EntityStorageComponent? storageComponent) ||
storageComponent.IsWeldedShut) storageComponent.IsWeldedShut)
{ {
return Outcome.Failed; return Outcome.Failed;

View File

@@ -30,7 +30,7 @@ namespace Content.Server.AI.Operators.Inventory
return Outcome.Failed; return Outcome.Failed;
} }
if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }

View File

@@ -1,6 +1,7 @@
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Items; using Content.Server.Items;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Operators.Inventory namespace Content.Server.AI.Operators.Inventory
{ {
@@ -21,12 +22,12 @@ namespace Content.Server.AI.Operators.Inventory
public override Outcome Execute(float frameTime) public override Outcome Execute(float frameTime)
{ {
// TODO: Also have this check storage a la backpack etc. // TODO: Also have this check storage a la backpack etc.
if (!_owner.TryGetComponent(out HandsComponent? handsComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }
if (!_target.TryGetComponent(out ItemComponent? itemComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out ItemComponent? itemComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }

View File

@@ -31,8 +31,8 @@ namespace Content.Server.AI.Operators.Nutrition
// TODO: Also have this check storage a la backpack etc. // TODO: Also have this check storage a la backpack etc.
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
!_owner.TryGetComponent(out HandsComponent? handsComponent) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent) ||
!_target.TryGetComponent(out ItemComponent? itemComponent)) !IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out ItemComponent? itemComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }
@@ -43,7 +43,7 @@ namespace Content.Server.AI.Operators.Nutrition
{ {
if (handsComponent.GetItem(slot) != itemComponent) continue; if (handsComponent.GetItem(slot) != itemComponent) continue;
handsComponent.ActiveHand = slot; handsComponent.ActiveHand = slot;
if (!_target.TryGetComponent(out drinkComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out drinkComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }
@@ -59,7 +59,7 @@ namespace Content.Server.AI.Operators.Nutrition
} }
if (drinkComponent.Deleted || EntitySystem.Get<DrinkSystem>().IsEmpty(drinkComponent.Owner.Uid, drinkComponent) if (drinkComponent.Deleted || EntitySystem.Get<DrinkSystem>().IsEmpty(drinkComponent.Owner.Uid, drinkComponent)
|| _owner.TryGetComponent(out ThirstComponent? thirstComponent) && || IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out ThirstComponent? thirstComponent) &&
thirstComponent.CurrentThirst >= thirstComponent.ThirstThresholds[ThirstThreshold.Okay]) thirstComponent.CurrentThirst >= thirstComponent.ThirstThresholds[ThirstThreshold.Okay])
{ {
return Outcome.Success; return Outcome.Success;

View File

@@ -30,8 +30,8 @@ namespace Content.Server.AI.Operators.Nutrition
// TODO: Also have this check storage a la backpack etc. // TODO: Also have this check storage a la backpack etc.
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
!_owner.TryGetComponent(out HandsComponent? handsComponent) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HandsComponent? handsComponent) ||
!_target.TryGetComponent(out ItemComponent? itemComponent)) !IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out ItemComponent? itemComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }
@@ -42,7 +42,7 @@ namespace Content.Server.AI.Operators.Nutrition
{ {
if (handsComponent.GetItem(slot) != itemComponent) continue; if (handsComponent.GetItem(slot) != itemComponent) continue;
handsComponent.ActiveHand = slot; handsComponent.ActiveHand = slot;
if (!_target.TryGetComponent(out foodComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target.Uid, out foodComponent))
{ {
return Outcome.Failed; return Outcome.Failed;
} }
@@ -59,7 +59,7 @@ namespace Content.Server.AI.Operators.Nutrition
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
foodComponent.UsesRemaining == 0 || foodComponent.UsesRemaining == 0 ||
_owner.TryGetComponent(out HungerComponent? hungerComponent) && IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner.Uid, out HungerComponent? hungerComponent) &&
hungerComponent.CurrentHunger >= hungerComponent.HungerThresholds[HungerThreshold.Okay]) hungerComponent.CurrentHunger >= hungerComponent.HungerThresholds[HungerThreshold.Okay])
{ {
return Outcome.Success; return Outcome.Success;

View File

@@ -181,7 +181,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
var targetNode = _pathfindingSystem.GetNode(targetTile); var targetNode = _pathfindingSystem.GetNode(targetTile);
var collisionMask = 0; var collisionMask = 0;
if (entity.TryGetComponent(out IPhysBody? physics)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics))
{ {
collisionMask = physics.CollisionMask; collisionMask = physics.CollisionMask;
} }

View File

@@ -29,7 +29,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
public static ReachableArgs GetArgs(IEntity entity) public static ReachableArgs GetArgs(IEntity entity)
{ {
var collisionMask = 0; var collisionMask = 0;
if (entity.TryGetComponent(out IPhysBody? physics)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics))
{ {
collisionMask = physics.CollisionMask; collisionMask = physics.CollisionMask;
} }

View File

@@ -267,7 +267,7 @@ namespace Content.Server.AI.Pathfinding
// TODO: Check for powered I think (also need an event for when it's depowered // TODO: Check for powered I think (also need an event for when it's depowered
// AccessReader calls this whenever opening / closing but it can seem to get called multiple times // AccessReader calls this whenever opening / closing but it can seem to get called multiple times
// Which may or may not be intended? // Which may or may not be intended?
if (entity.TryGetComponent(out AccessReader? accessReader) && !_accessReaders.ContainsKey(entity)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AccessReader? accessReader) && !_accessReaders.ContainsKey(entity))
{ {
_accessReaders.Add(entity, accessReader); _accessReaders.Add(entity, accessReader);
ParentChunk.Dirty(); ParentChunk.Dirty();

View File

@@ -267,7 +267,7 @@ namespace Content.Server.AI.Pathfinding
{ {
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
_lastKnownPositions.ContainsKey(entity) || _lastKnownPositions.ContainsKey(entity) ||
!entity.TryGetComponent(out IPhysBody? physics) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics) ||
!PathfindingNode.IsRelevant(entity, physics)) !PathfindingNode.IsRelevant(entity, physics))
{ {
return; return;
@@ -306,7 +306,7 @@ namespace Content.Server.AI.Pathfinding
{ {
// If we've moved to space or the likes then remove us. // If we've moved to space or the likes then remove us.
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(moveEvent.Sender.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(moveEvent.Sender.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(moveEvent.Sender.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(moveEvent.Sender.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
!moveEvent.Sender.TryGetComponent(out IPhysBody? physics) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(moveEvent.Sender.Uid, out IPhysBody? physics) ||
!PathfindingNode.IsRelevant(moveEvent.Sender, physics) || !PathfindingNode.IsRelevant(moveEvent.Sender, physics) ||
moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid) moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid)
{ {
@@ -371,7 +371,7 @@ namespace Content.Server.AI.Pathfinding
public bool CanTraverse(IEntity entity, PathfindingNode node) public bool CanTraverse(IEntity entity, PathfindingNode node)
{ {
if (entity.TryGetComponent(out IPhysBody? physics) && if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics) &&
(physics.CollisionMask & node.BlockedCollisionMask) != 0) (physics.CollisionMask & node.BlockedCollisionMask) != 0)
{ {
return false; return false;

View File

@@ -129,7 +129,7 @@ namespace Content.Server.AI.Steering
/// <exception cref="InvalidOperationException"></exception> /// <exception cref="InvalidOperationException"></exception>
public void Unregister(IEntity entity) public void Unregister(IEntity entity)
{ {
if (entity.TryGetComponent(out AiControllerComponent? controller)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AiControllerComponent? controller))
{ {
controller.VelocityDir = Vector2.Zero; controller.VelocityDir = Vector2.Zero;
} }
@@ -249,7 +249,7 @@ namespace Content.Server.AI.Steering
{ {
// Main optimisation to be done below is the redundant calls and adding more variables // Main optimisation to be done below is the redundant calls and adding more variables
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity.Uid) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity.Uid).EntityLifeStage) >= EntityLifeStage.Deleted ||
!entity.TryGetComponent(out AiControllerComponent? controller) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out AiControllerComponent? controller) ||
!EntitySystem.Get<ActionBlockerSystem>().CanMove(entity.Uid) || !EntitySystem.Get<ActionBlockerSystem>().CanMove(entity.Uid) ||
!entity.Transform.GridID.IsValid()) !entity.Transform.GridID.IsValid())
{ {
@@ -420,7 +420,7 @@ namespace Content.Server.AI.Steering
var startTile = gridManager.GetTileRef(entity.Transform.Coordinates); var startTile = gridManager.GetTileRef(entity.Transform.Coordinates);
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid); var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
var collisionMask = 0; var collisionMask = 0;
if (entity.TryGetComponent(out IPhysBody? physics)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics))
{ {
collisionMask = physics.CollisionMask; collisionMask = physics.CollisionMask;
} }
@@ -606,7 +606,7 @@ namespace Content.Server.AI.Steering
return Vector2.Zero; return Vector2.Zero;
} }
if (target.TryGetComponent(out IPhysBody? physics)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out IPhysBody? physics))
{ {
var targetDistance = (targetPos.Position - entityPos.Position); var targetDistance = (targetPos.Position - entityPos.Position);
targetPos = targetPos.Offset(physics.LinearVelocity * targetDistance); targetPos = targetPos.Offset(physics.LinearVelocity * targetDistance);
@@ -624,7 +624,7 @@ namespace Content.Server.AI.Steering
/// <returns></returns> /// <returns></returns>
private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<IEntity> ignoredTargets) private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<IEntity> ignoredTargets)
{ {
if (direction == Vector2.Zero || !entity.TryGetComponent(out IPhysBody? physics)) if (direction == Vector2.Zero || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out IPhysBody? physics))
{ {
return Vector2.Zero; return Vector2.Zero;
} }
@@ -665,7 +665,7 @@ namespace Content.Server.AI.Steering
// if we're moving in the same direction then ignore // if we're moving in the same direction then ignore
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction // So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction
// i.e. towards the right // i.e. towards the right
if (physicsEntity.TryGetComponent(out IPhysBody? otherPhysics) && if (IoCManager.Resolve<IEntityManager>().TryGetComponent(physicsEntity.Uid, out IPhysBody? otherPhysics) &&
Vector2.Dot(otherPhysics.LinearVelocity, direction) > 0) Vector2.Dot(otherPhysics.LinearVelocity, direction) > 0)
{ {
continue; continue;

View File

@@ -27,7 +27,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
{ {
MoveToEntityOperator moveOperator; MoveToEntityOperator moveOperator;
var equipped = context.GetState<EquippedEntityState>().GetValue(); var equipped = context.GetState<EquippedEntityState>().GetValue();
if (equipped != null && equipped.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) if (equipped != null && IoCManager.Resolve<IEntityManager>().TryGetComponent(equipped.Uid, out MeleeWeaponComponent? meleeWeaponComponent))
{ {
moveOperator = new MoveToEntityOperator(Owner, Target, meleeWeaponComponent.Range - 0.01f); moveOperator = new MoveToEntityOperator(Owner, Target, meleeWeaponComponent.Range - 0.01f);
} }

View File

@@ -24,7 +24,7 @@ namespace Content.Server.AI.Utility.Actions.Combat.Melee
public override void SetupOperators(Blackboard context) public override void SetupOperators(Blackboard context)
{ {
MoveToEntityOperator moveOperator; MoveToEntityOperator moveOperator;
if (Owner.TryGetComponent(out UnarmedCombatComponent? unarmedCombatComponent)) if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out UnarmedCombatComponent? unarmedCombatComponent))
{ {
moveOperator = new MoveToEntityOperator(Owner, Target, unarmedCombatComponent.Range - 0.01f); moveOperator = new MoveToEntityOperator(Owner, Target, unarmedCombatComponent.Range - 0.01f);
} }

View File

@@ -3,6 +3,8 @@ using Content.Server.AI.WorldState.States.Clothing;
using Content.Server.AI.WorldState.States.Inventory; using Content.Server.AI.WorldState.States.Inventory;
using Content.Server.Clothing.Components; using Content.Server.Clothing.Components;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.Considerations.Clothing namespace Content.Server.AI.Utility.Considerations.Clothing
{ {
@@ -23,7 +25,7 @@ namespace Content.Server.AI.Utility.Considerations.Clothing
foreach (var entity in context.GetState<EnumerableInventoryState>().GetValue()) foreach (var entity in context.GetState<EnumerableInventoryState>().GetValue())
{ {
if (!entity.TryGetComponent(out ClothingComponent? clothingComponent)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Uid, out ClothingComponent? clothingComponent))
{ {
continue; continue;
} }

View File

@@ -1,6 +1,8 @@
using Content.Server.AI.WorldState; using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States.Combat; using Content.Server.AI.WorldState.States.Combat;
using Content.Server.Weapon.Melee.Components; using Content.Server.Weapon.Melee.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.Utility.Considerations.Combat.Melee namespace Content.Server.AI.Utility.Considerations.Combat.Melee
{ {
@@ -10,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat.Melee
{ {
var target = context.GetState<WeaponEntityState>().GetValue(); var target = context.GetState<WeaponEntityState>().GetValue();
if (target == null || !target.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target.Uid, out MeleeWeaponComponent? meleeWeaponComponent))
{ {
return 0.0f; return 0.0f;
} }

Some files were not shown because too many files have changed in this diff Show More