And a bunch more.

This commit is contained in:
Vera Aguilera Puerto
2021-12-08 12:09:43 +01:00
parent 9b9babd429
commit 680ad72939
30 changed files with 176 additions and 125 deletions

View File

@@ -36,9 +36,11 @@ namespace Content.Client.Body.UI
return; return;
} }
if (!IoCManager.Resolve<IEntityManager>().EntityExists(scannerState.Uid)) var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.EntityExists(scannerState.Uid))
{ {
throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner} at {IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Owner).MapPosition}"); throw new ArgumentException($"Received an invalid entity with id {scannerState.Uid} for body scanner with id {Owner.Owner} at {entMan.GetComponent<TransformComponent>(Owner.Owner).MapPosition}");
} }
_display?.UpdateDisplay(_entity); _display?.UpdateDisplay(_entity);

View File

@@ -146,10 +146,11 @@ namespace Content.Client.Body.UI
private void UpdateBodyPartBox(SharedBodyPartComponent part, string slotName) private void UpdateBodyPartBox(SharedBodyPartComponent part, string slotName)
{ {
BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(part.Owner).EntityName)}"; var entMan = IoCManager.Resolve<IEntityManager>();
BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(entMan.GetComponent<MetaDataComponent>(part.Owner).EntityName)}";
// TODO BODY Part damage // TODO BODY Part damage
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(part.Owner, out DamageableComponent? damageable)) if (entMan.TryGetComponent(part.Owner, out DamageableComponent? damageable))
{ {
BodyPartHealth.Text = Loc.GetString("body-scanner-display-body-part-damage-text",("damage", damageable.TotalDamage)); BodyPartHealth.Text = Loc.GetString("body-scanner-display-body-part-damage-text",("damage", damageable.TotalDamage));
} }

View File

@@ -50,8 +50,9 @@ namespace Content.Client.Cargo
{ {
base.Open(); base.Open();
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out GalacticMarketComponent? market) || var entMan = IoCManager.Resolve<IEntityManager>();
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return; if (!entMan.TryGetComponent(Owner.Owner, out GalacticMarketComponent? market) ||
!entMan.TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return;
Market = market; Market = market;
Orders = orders; Orders = orders;

View File

@@ -50,12 +50,13 @@ namespace Content.Client.CharacterInfo.Components
{ {
case CharacterInfoMessage characterInfoMessage: case CharacterInfoMessage characterInfoMessage:
_control.UpdateUI(characterInfoMessage); _control.UpdateUI(characterInfoMessage);
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? spriteComponent)) var entityManager = IoCManager.Resolve<IEntityManager>();
if (entityManager.TryGetComponent(Owner, out ISpriteComponent? spriteComponent))
{ {
_control.SpriteView.Sprite = spriteComponent; _control.SpriteView.Sprite = spriteComponent;
} }
_control.NameLabel.Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName; _control.NameLabel.Text = entityManager.GetComponent<MetaDataComponent>(Owner).EntityName;
break; break;
} }
} }

View File

@@ -477,7 +477,7 @@ namespace Content.Client.Chat.Managers
private void EnqueueSpeechBubble(EntityUid entity, string contents, SpeechBubble.SpeechType speechType) private void EnqueueSpeechBubble(EntityUid entity, string contents, SpeechBubble.SpeechType speechType)
{ {
// Don't enqueue speech bubbles for other maps. TODO: Support multiple viewports/maps? // Don't enqueue speech bubbles for other maps. TODO: Support multiple viewports/maps?
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID != _eyeManager.CurrentMap) if (_entityManager.GetComponent<TransformComponent>(entity).MapID != _eyeManager.CurrentMap)
return; return;
if (!_queuedSpeechBubbles.TryGetValue(entity, out var queueData)) if (!_queuedSpeechBubbles.TryGetValue(entity, out var queueData))
@@ -496,7 +496,7 @@ namespace Content.Client.Chat.Managers
private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData) private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData)
{ {
var bubble = var bubble =
SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eyeManager, this); SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eyeManager, this, _entityManager);
if (_activeSpeechBubbles.TryGetValue(entity, out var existing)) if (_activeSpeechBubbles.TryGetValue(entity, out var existing))
{ {

View File

@@ -38,6 +38,7 @@ namespace Content.Client.Chat.UI
private readonly IEyeManager _eyeManager; private readonly IEyeManager _eyeManager;
private readonly EntityUid _senderEntity; private readonly EntityUid _senderEntity;
private readonly IChatManager _chatManager; private readonly IChatManager _chatManager;
private readonly IEntityManager _entityManager;
private float _timeLeft = TotalTime; private float _timeLeft = TotalTime;
@@ -46,26 +47,27 @@ namespace Content.Client.Chat.UI
public float ContentHeight { get; private set; } public float ContentHeight { get; private set; }
public static SpeechBubble CreateSpeechBubble(SpeechType type, string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager) public static SpeechBubble CreateSpeechBubble(SpeechType type, string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
{ {
switch (type) switch (type)
{ {
case SpeechType.Emote: case SpeechType.Emote:
return new EmoteSpeechBubble(text, senderEntity, eyeManager, chatManager); return new EmoteSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager);
case SpeechType.Say: case SpeechType.Say:
return new SaySpeechBubble(text, senderEntity, eyeManager, chatManager); return new SaySpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager);
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
} }
public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager) public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
{ {
_chatManager = chatManager; _chatManager = chatManager;
_senderEntity = senderEntity; _senderEntity = senderEntity;
_eyeManager = eyeManager; _eyeManager = eyeManager;
_entityManager = entityManager;
// Use text clipping so new messages don't overlap old ones being pushed up. // Use text clipping so new messages don't overlap old ones being pushed up.
RectClipContent = true; RectClipContent = true;
@@ -99,7 +101,7 @@ namespace Content.Client.Chat.UI
_verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds); _verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds);
} }
if (!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_senderEntity).Coordinates.IsValid(IoCManager.Resolve<IEntityManager>())) if (!_entityManager.GetComponent<TransformComponent>(_senderEntity).Coordinates.IsValid(_entityManager))
{ {
Modulate = Color.White.WithAlpha(0); Modulate = Color.White.WithAlpha(0);
return; return;
@@ -116,14 +118,14 @@ namespace Content.Client.Chat.UI
Modulate = Color.White; Modulate = Color.White;
} }
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_senderEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_senderEntity).EntityLifeStage) >= EntityLifeStage.Deleted || _timeLeft <= 0) if ((!_entityManager.EntityExists(_senderEntity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(_senderEntity).EntityLifeStage) >= EntityLifeStage.Deleted || _timeLeft <= 0)
{ {
// Timer spawn to prevent concurrent modification exception. // Timer spawn to prevent concurrent modification exception.
Timer.Spawn(0, Die); Timer.Spawn(0, Die);
return; return;
} }
var worldPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_senderEntity).WorldPosition; var worldPos = _entityManager.GetComponent<TransformComponent>(_senderEntity).WorldPosition;
var scale = _eyeManager.MainViewport.GetRenderScale(); var scale = _eyeManager.MainViewport.GetRenderScale();
var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale); var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale);
var lowerCenter = (_eyeManager.WorldToScreen(worldPos) - offset) / UIScale; var lowerCenter = (_eyeManager.WorldToScreen(worldPos) - offset) / UIScale;
@@ -162,8 +164,8 @@ namespace Content.Client.Chat.UI
public class EmoteSpeechBubble : SpeechBubble public class EmoteSpeechBubble : SpeechBubble
{ {
public EmoteSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager) public EmoteSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
: base(text, senderEntity, eyeManager, chatManager) : base(text, senderEntity, eyeManager, chatManager, entityManager)
{ {
} }
@@ -188,8 +190,8 @@ namespace Content.Client.Chat.UI
public class SaySpeechBubble : SpeechBubble public class SaySpeechBubble : SpeechBubble
{ {
public SaySpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager) public SaySpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
: base(text, senderEntity, eyeManager, chatManager) : base(text, senderEntity, eyeManager, chatManager, entityManager)
{ {
} }

View File

@@ -7,6 +7,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using TerraFX.Interop.Windows;
namespace Content.Client.Clickable namespace Content.Client.Clickable
{ {
@@ -29,14 +30,15 @@ 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 (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? sprite) || !sprite.Visible) var entMan = IoCManager.Resolve<IEntityManager>();
if (!entMan.TryGetComponent(Owner, out ISpriteComponent? sprite) || !sprite.Visible)
{ {
drawDepth = default; drawDepth = default;
renderOrder = default; renderOrder = default;
return false; return false;
} }
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner); var transform = entMan.GetComponent<TransformComponent>(Owner);
var localPos = transform.InvWorldMatrix.Transform(worldPos); var localPos = transform.InvWorldMatrix.Transform(worldPos);
var spriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix()); var spriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix());

View File

@@ -50,12 +50,12 @@ namespace Content.Client.Commands
EntitySystem.Get<SubFloorHideSystem>() EntitySystem.Get<SubFloorHideSystem>()
.ShowAll = true; .ShowAll = true;
var components = IoCManager.Resolve<IEntityManager>() var entMan = IoCManager.Resolve<IEntityManager>();
.EntityQuery<SubFloorHideComponent>(true); var components = entMan.EntityQuery<SubFloorHideComponent>(true);
foreach (var component in components) foreach (var component in components)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out ISpriteComponent? sprite)) if (entMan.TryGetComponent(component.Owner, 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 (!IoCManager.Resolve<IEntityManager>().TryGetComponent(mechanism.Owner, out SpriteComponent? sprite)) if (!entityManager.TryGetComponent(mechanism.Owner, 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 (IoCManager.Resolve<IEntityManager>().TryGetComponent(mechanism.Owner, out SpriteComponent? sprite)) if (entityManager.TryGetComponent(mechanism.Owner, out SpriteComponent? sprite))
{ {
sprite.ContainerOccluded = false; sprite.ContainerOccluded = false;
} }

View File

@@ -144,7 +144,7 @@ namespace Content.Client.Construction
if (!args.EntityUid.IsValid() || !args.EntityUid.IsClientSide()) if (!args.EntityUid.IsValid() || !args.EntityUid.IsClientSide())
return false; return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ConstructionGhostComponent?>(args.EntityUid, out var ghostComp)) if (!EntityManager.TryGetComponent<ConstructionGhostComponent?>(args.EntityUid, out var ghostComp))
return false; return false;
TryStartConstruction(ghostComp.GhostId); TryStartConstruction(ghostComp.GhostId);
@@ -172,12 +172,12 @@ namespace Content.Client.Construction
} }
var ghost = EntityManager.SpawnEntity("constructionghost", loc); var ghost = EntityManager.SpawnEntity("constructionghost", loc);
var comp = IoCManager.Resolve<IEntityManager>().GetComponent<ConstructionGhostComponent>(ghost); var comp = EntityManager.GetComponent<ConstructionGhostComponent>(ghost);
comp.Prototype = prototype; comp.Prototype = prototype;
comp.GhostId = _nextId++; comp.GhostId = _nextId++;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ghost).LocalRotation = dir.ToAngle(); EntityManager.GetComponent<TransformComponent>(ghost).LocalRotation = dir.ToAngle();
_ghosts.Add(comp.GhostId, comp); _ghosts.Add(comp.GhostId, comp);
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(ghost); var sprite = EntityManager.GetComponent<SpriteComponent>(ghost);
sprite.Color = new Color(48, 255, 48, 128); sprite.Color = new Color(48, 255, 48, 128);
sprite.AddBlankLayer(0); // There is no way to actually check if this already exists, so we blindly insert a new one sprite.AddBlankLayer(0); // There is no way to actually check if this already exists, so we blindly insert a new one
sprite.LayerSetSprite(0, prototype.Icon); sprite.LayerSetSprite(0, prototype.Icon);
@@ -192,7 +192,7 @@ namespace Content.Client.Construction
{ {
foreach (var ghost in _ghosts) foreach (var ghost in _ghosts)
{ {
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ghost.Value.Owner).Coordinates.Equals(loc)) return true; if (EntityManager.GetComponent<TransformComponent>(ghost.Value.Owner).Coordinates.Equals(loc)) return true;
} }
return false; return false;
@@ -207,7 +207,7 @@ namespace Content.Client.Construction
throw new ArgumentException($"Can't start construction for a ghost with no prototype. Ghost id: {ghostId}"); throw new ArgumentException($"Can't start construction for a ghost with no prototype. Ghost id: {ghostId}");
} }
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ghost.Owner); var transform = EntityManager.GetComponent<TransformComponent>(ghost.Owner);
var msg = new TryStartStructureConstructionMessage(transform.Coordinates, ghost.Prototype.ID, transform.LocalRotation, ghostId); var msg = new TryStartStructureConstructionMessage(transform.Coordinates, ghost.Prototype.ID, transform.LocalRotation, ghostId);
RaiseNetworkEvent(msg); RaiseNetworkEvent(msg);
} }
@@ -227,7 +227,7 @@ namespace Content.Client.Construction
{ {
if (_ghosts.TryGetValue(ghostId, out var ghost)) if (_ghosts.TryGetValue(ghostId, out var ghost))
{ {
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(ghost.Owner); EntityManager.QueueDeleteEntity(ghost.Owner);
_ghosts.Remove(ghostId); _ghosts.Remove(ghostId);
} }
} }
@@ -239,7 +239,7 @@ namespace Content.Client.Construction
{ {
foreach (var (_, ghost) in _ghosts) foreach (var (_, ghost) in _ghosts)
{ {
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(ghost.Owner); EntityManager.QueueDeleteEntity(ghost.Owner);
} }
_ghosts.Clear(); _ghosts.Clear();

View File

@@ -10,6 +10,8 @@ namespace Content.Client.ContextMenu.UI
{ {
public const string StyleClassEntityMenuCountText = "contextMenuCount"; public const string StyleClassEntityMenuCountText = "contextMenuCount";
[Dependency] private IEntityManager _entityManager = default!;
/// <summary> /// <summary>
/// The entity that can be accessed by interacting with this element. /// The entity that can be accessed by interacting with this element.
/// </summary> /// </summary>
@@ -28,6 +30,8 @@ namespace Content.Client.ContextMenu.UI
public EntityMenuElement(EntityUid entity = default) public EntityMenuElement(EntityUid entity = default)
{ {
IoCManager.InjectDependencies(this);
CountLabel = new Label { StyleClasses = { StyleClassEntityMenuCountText } }; CountLabel = new Label { StyleClasses = { StyleClassEntityMenuCountText } };
Icon.AddChild(new LayoutContainer() { Children = { EntityIcon, CountLabel } }); Icon.AddChild(new LayoutContainer() { Children = { EntityIcon, CountLabel } });
@@ -57,7 +61,7 @@ namespace Content.Client.ContextMenu.UI
/// </summary> /// </summary>
public void UpdateEntity(EntityUid entity = default) public void UpdateEntity(EntityUid entity = default)
{ {
if (Entity != default && IoCManager.Resolve<IEntityManager>().EntityExists(Entity) && !entity.Valid) if (Entity != default && _entityManager.EntityExists(Entity) && !entity.Valid)
entity = Entity; entity = Entity;
if (entity == default) if (entity == default)
@@ -66,12 +70,12 @@ namespace Content.Client.ContextMenu.UI
return; return;
} }
EntityIcon.Sprite = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ISpriteComponent>(entity); EntityIcon.Sprite = _entityManager.GetComponentOrNull<ISpriteComponent>(entity);
if (UserInterfaceManager.DebugMonitors.Visible) if (UserInterfaceManager.DebugMonitors.Visible)
Text = $"{IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity!).EntityName} ({entity})"; Text = $"{_entityManager.GetComponent<MetaDataComponent>(entity!).EntityName} ({entity})";
else else
Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity!).EntityName; Text = _entityManager.GetComponent<MetaDataComponent>(entity!).EntityName;
} }
} }
} }

View File

@@ -85,7 +85,7 @@ namespace Content.Client.ContextMenu.UI
var entitySpriteStates = GroupEntities(entities); var entitySpriteStates = GroupEntities(entities);
var orderedStates = entitySpriteStates.ToList(); var orderedStates = entitySpriteStates.ToList();
orderedStates.Sort((x, y) => string.CompareOrdinal(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(x.First()).EntityPrototype?.Name, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(y.First()).EntityPrototype?.Name)); orderedStates.Sort((x, y) => string.CompareOrdinal(_entityManager.GetComponent<MetaDataComponent>(x.First()).EntityPrototype?.Name, _entityManager.GetComponent<MetaDataComponent>(y.First()).EntityPrototype?.Name));
Elements.Clear(); Elements.Clear();
AddToUI(orderedStates); AddToUI(orderedStates);
@@ -139,7 +139,7 @@ namespace Content.Client.ContextMenu.UI
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func); var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func);
var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId, var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId,
BoundKeyState.Down, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates, args.PointerLocation, entity); BoundKeyState.Down, _entityManager.GetComponent<TransformComponent>(entity).Coordinates, args.PointerLocation, entity);
var session = _playerManager.LocalPlayer?.Session; var session = _playerManager.LocalPlayer?.Session;
if (session != null) if (session != null)
@@ -187,7 +187,7 @@ namespace Content.Client.ContextMenu.UI
foreach (var entity in Elements.Keys.ToList()) foreach (var entity in Elements.Keys.ToList())
{ {
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || !ignoreFov && !_examineSystem.CanExamine(player, entity)) if ((!_entityManager.EntityExists(entity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || !ignoreFov && !_examineSystem.CanExamine(player, entity))
RemoveEntity(entity); RemoveEntity(entity);
} }
} }
@@ -253,7 +253,7 @@ namespace Content.Client.ContextMenu.UI
// find the element associated with this entity // find the element associated with this entity
if (!Elements.TryGetValue(entity, out var element)) if (!Elements.TryGetValue(entity, out var element))
{ {
Logger.Error($"Attempted to remove unknown entity from the entity menu: {IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName} ({entity})"); Logger.Error($"Attempted to remove unknown entity from the entity menu: {_entityManager.GetComponent<MetaDataComponent>(entity).EntityName} ({entity})");
return; return;
} }
@@ -338,7 +338,7 @@ namespace Content.Client.ContextMenu.UI
if (entityElement.Entity != default) if (entityElement.Entity != default)
{ {
if (!((!IoCManager.Resolve<IEntityManager>().EntityExists(entityElement.Entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entityElement.Entity).EntityLifeStage) >= EntityLifeStage.Deleted)) if (!((!_entityManager.EntityExists(entityElement.Entity) ? EntityLifeStage.Deleted : _entityManager.GetComponent<MetaDataComponent>(entityElement.Entity).EntityLifeStage) >= EntityLifeStage.Deleted))
return entityElement.Entity; return entityElement.Entity;
continue; continue;
} }

View File

@@ -21,25 +21,25 @@ namespace Content.Client.ContextMenu.UI
{ {
if (GroupingContextMenuType == 0) if (GroupingContextMenuType == 0)
{ {
var newEntities = entities.GroupBy(e => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e).EntityName + (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e).EntityPrototype?.ID ?? string.Empty)).ToList(); var newEntities = entities.GroupBy(e => _entityManager.GetComponent<MetaDataComponent>(e).EntityName + (_entityManager.GetComponent<MetaDataComponent>(e).EntityPrototype?.ID ?? string.Empty)).ToList();
return newEntities.Select(grp => grp.ToList()).ToList(); return newEntities.Select(grp => grp.ToList()).ToList();
} }
else else
{ {
var newEntities = entities.GroupBy(e => e, new PrototypeAndStatesContextMenuComparer(depth)).ToList(); var newEntities = entities.GroupBy(e => e, new PrototypeAndStatesContextMenuComparer(depth, _entityManager)).ToList();
return newEntities.Select(grp => grp.ToList()).ToList(); return newEntities.Select(grp => grp.ToList()).ToList();
} }
} }
private sealed class PrototypeAndStatesContextMenuComparer : IEqualityComparer<EntityUid> private sealed class PrototypeAndStatesContextMenuComparer : IEqualityComparer<EntityUid>
{ {
private static readonly List<Func<EntityUid, EntityUid, bool>> EqualsList = new() private static readonly List<Func<EntityUid, EntityUid, IEntityManager, bool>> EqualsList = new()
{ {
(a, b) => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(a).EntityPrototype!.ID == IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(b).EntityPrototype!.ID, (a, b, entMan) => entMan.GetComponent<MetaDataComponent>(a).EntityPrototype!.ID == entMan.GetComponent<MetaDataComponent>(b).EntityPrototype!.ID,
(a, b) => (a, b, entMan) =>
{ {
IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(a, out var spriteA); entMan.TryGetComponent<ISpriteComponent?>(a, out var spriteA);
IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(b, out var spriteB); entMan.TryGetComponent<ISpriteComponent?>(b, out var spriteB);
if (spriteA == null || spriteB == null) if (spriteA == null || spriteB == null)
return spriteA == spriteB; return spriteA == spriteB;
@@ -50,13 +50,13 @@ namespace Content.Client.ContextMenu.UI
return xStates.OrderBy(t => t).SequenceEqual(yStates.OrderBy(t => t)); return xStates.OrderBy(t => t).SequenceEqual(yStates.OrderBy(t => t));
}, },
}; };
private static readonly List<Func<EntityUid, int>> GetHashCodeList = new() private static readonly List<Func<EntityUid, IEntityManager, int>> GetHashCodeList = new()
{ {
e => EqualityComparer<string>.Default.GetHashCode(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e).EntityPrototype!.ID), (e, entMan) => EqualityComparer<string>.Default.GetHashCode(entMan.GetComponent<MetaDataComponent>(e).EntityPrototype!.ID),
e => (e, entMan) =>
{ {
var hash = 0; var hash = 0;
foreach (var element in IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(e).AllLayers.Where(obj => obj.Visible).Select(s => s.RsiState.Name)) foreach (var element in entMan.GetComponent<ISpriteComponent>(e).AllLayers.Where(obj => obj.Visible).Select(s => s.RsiState.Name))
{ {
hash ^= EqualityComparer<string>.Default.GetHashCode(element!); hash ^= EqualityComparer<string>.Default.GetHashCode(element!);
} }
@@ -67,9 +67,13 @@ namespace Content.Client.ContextMenu.UI
private static int Count => EqualsList.Count - 1; private static int Count => EqualsList.Count - 1;
private readonly int _depth; private readonly int _depth;
public PrototypeAndStatesContextMenuComparer(int step = 0) private readonly IEntityManager _entMan;
public PrototypeAndStatesContextMenuComparer(int step = 0, IEntityManager? entMan = null)
{ {
IoCManager.Resolve(ref entMan);
_depth = step > Count ? Count : step; _depth = step > Count ? Count : step;
_entMan = entMan;
} }
public bool Equals(EntityUid x, EntityUid y) public bool Equals(EntityUid x, EntityUid y)
@@ -79,12 +83,12 @@ namespace Content.Client.ContextMenu.UI
return y == default; return y == default;
} }
return y != default && EqualsList[_depth](x, y); return y != default && EqualsList[_depth](x, y, _entMan);
} }
public int GetHashCode(EntityUid e) public int GetHashCode(EntityUid e)
{ {
return GetHashCodeList[_depth](e); return GetHashCodeList[_depth](e, _entMan);
} }
} }
} }

View File

@@ -37,8 +37,8 @@ namespace Content.Client.Damage
/// </summary> /// </summary>
public class DamageVisualizer : AppearanceVisualizer public class DamageVisualizer : AppearanceVisualizer
{ {
[Dependency] IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] IEntityManager _entityManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!;
private const string _name = "DamageVisualizer"; private const string _name = "DamageVisualizer";
/// <summary> /// <summary>
@@ -195,12 +195,15 @@ namespace Content.Client.Damage
public readonly string? Color; public readonly string? Color;
} }
public DamageVisualizer()
{
IoCManager.InjectDependencies(this);
}
public override void InitializeEntity(EntityUid entity) public override void InitializeEntity(EntityUid entity)
{ {
base.InitializeEntity(entity); base.InitializeEntity(entity);
IoCManager.InjectDependencies(this);
var damageData = _entityManager.EnsureComponent<DamageVisualizerDataComponent>(entity); var damageData = _entityManager.EnsureComponent<DamageVisualizerDataComponent>(entity);
VerifyVisualizerSetup(entity, damageData); VerifyVisualizerSetup(entity, damageData);
if (damageData.Valid) if (damageData.Valid)
@@ -291,9 +294,9 @@ namespace Content.Client.Damage
private void InitializeVisualizer(EntityUid entity, DamageVisualizerDataComponent damageData) private void InitializeVisualizer(EntityUid entity, DamageVisualizerDataComponent damageData)
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SpriteComponent? spriteComponent) if (!_entityManager.TryGetComponent(entity, out SpriteComponent? spriteComponent)
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent<DamageableComponent?>(entity, out var damageComponent) || !_entityManager.TryGetComponent<DamageableComponent?>(entity, out var damageComponent)
|| !IoCManager.Resolve<IEntityManager>().HasComponent<AppearanceComponent>(entity)) || !_entityManager.HasComponent<AppearanceComponent>(entity))
return; return;
_thresholds.Add(FixedPoint2.Zero); _thresholds.Add(FixedPoint2.Zero);
@@ -504,7 +507,7 @@ namespace Content.Client.Damage
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {
var entities = IoCManager.Resolve<IEntityManager>(); var entities = _entityManager;
if (!entities.TryGetComponent(component.Owner, out DamageVisualizerDataComponent damageData)) if (!entities.TryGetComponent(component.Owner, out DamageVisualizerDataComponent damageData))
return; return;
@@ -526,7 +529,7 @@ namespace Content.Client.Damage
private void HandleDamage(AppearanceComponent component, DamageVisualizerDataComponent damageData) private void HandleDamage(AppearanceComponent component, DamageVisualizerDataComponent damageData)
{ {
var entities = IoCManager.Resolve<IEntityManager>(); var entities = _entityManager;
if (!entities.TryGetComponent(component.Owner, out SpriteComponent spriteComponent) if (!entities.TryGetComponent(component.Owner, out SpriteComponent spriteComponent)
|| !entities.TryGetComponent(component.Owner, out DamageableComponent damageComponent)) || !entities.TryGetComponent(component.Owner, out DamageableComponent damageComponent))
return; return;

View File

@@ -40,7 +40,7 @@ namespace Content.Client.Disposal.Systems
{ {
if (component.Deleted) return true; if (component.Deleted) return true;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out ClientUserInterfaceComponent? userInterface)) return true; if (!EntityManager.TryGetComponent(component.Owner, 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

@@ -90,7 +90,7 @@ namespace Content.Client.Disposal.Visualizers
case VisualState.Flushing: case VisualState.Flushing:
sprite.LayerSetState(DisposalUnitVisualLayers.Base, _stateAnchored); sprite.LayerSetState(DisposalUnitVisualLayers.Base, _stateAnchored);
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(appearance.Owner); var animPlayer = entities.GetComponent<AnimationPlayerComponent>(appearance.Owner);
if (!animPlayer.HasRunningAnimation(AnimationKey)) if (!animPlayer.HasRunningAnimation(AnimationKey))
{ {

View File

@@ -160,8 +160,9 @@ namespace Content.Client.DoAfter.UI
return; return;
} }
if (_eyeManager.CurrentMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(AttachedEntity).MapID || var transform = _entityManager.GetComponent<TransformComponent>(AttachedEntity);
!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(AttachedEntity).Coordinates.IsValid(_entityManager))
if (_eyeManager.CurrentMap != transform.MapID || !transform.Coordinates.IsValid(_entityManager))
{ {
Visible = false; Visible = false;
return; return;
@@ -211,7 +212,7 @@ namespace Content.Client.DoAfter.UI
RemoveDoAfter(id); RemoveDoAfter(id);
} }
var screenCoordinates = _eyeManager.CoordinatesToScreen(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(AttachedEntity).Coordinates); var screenCoordinates = _eyeManager.CoordinatesToScreen(transform.Coordinates);
_playerPosition = new ScreenCoordinates(screenCoordinates.Position / UIScale, screenCoordinates.Window); _playerPosition = new ScreenCoordinates(screenCoordinates.Position / UIScale, screenCoordinates.Window);
LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f)); LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f));
} }

View File

@@ -14,6 +14,8 @@ namespace Content.Client.Doors
[UsedImplicitly] [UsedImplicitly]
public class AirlockVisualizer : AppearanceVisualizer, ISerializationHooks public class AirlockVisualizer : AppearanceVisualizer, ISerializationHooks
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private const string AnimationKey = "airlock_animation"; private const string AnimationKey = "airlock_animation";
[DataField("animationTime")] [DataField("animationTime")]
@@ -46,6 +48,11 @@ namespace Content.Client.Doors
private Animation OpenAnimation = default!; private Animation OpenAnimation = default!;
private Animation DenyAnimation = default!; private Animation DenyAnimation = default!;
public AirlockVisualizer()
{
IoCManager.InjectDependencies(this);
}
void ISerializationHooks.AfterDeserialization() void ISerializationHooks.AfterDeserialization()
{ {
CloseAnimation = new Animation {Length = TimeSpan.FromSeconds(_delay)}; CloseAnimation = new Animation {Length = TimeSpan.FromSeconds(_delay)};
@@ -110,9 +117,9 @@ namespace Content.Client.Doors
public override void InitializeEntity(EntityUid entity) public override void InitializeEntity(EntityUid entity)
{ {
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AnimationPlayerComponent>(entity)) if (!_entMan.HasComponent<AnimationPlayerComponent>(entity))
{ {
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity); _entMan.AddComponent<AnimationPlayerComponent>(entity);
} }
} }
@@ -120,8 +127,8 @@ namespace Content.Client.Doors
{ {
base.OnChangeData(component); base.OnChangeData(component);
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner); var sprite = _entMan.GetComponent<ISpriteComponent>(component.Owner);
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner); var animPlayer = _entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
if (!component.TryGetData(DoorVisuals.VisualState, out DoorVisualState state)) if (!component.TryGetData(DoorVisuals.VisualState, out DoorVisualState state))
{ {
state = DoorVisualState.Closed; state = DoorVisualState.Closed;

View File

@@ -57,6 +57,7 @@ namespace Content.Client.Entry
[Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner = default!; [Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner = default!;
[Dependency] private readonly IGameController _gameController = default!; [Dependency] private readonly IGameController _gameController = default!;
[Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override void Init() public override void Init()
{ {
@@ -141,19 +142,21 @@ namespace Content.Client.Entry
/// <summary> /// <summary>
/// Add the character interface master which combines all character interfaces into one window /// Add the character interface master which combines all character interfaces into one window
/// </summary> /// </summary>
public static void AttachPlayerToEntity(EntityAttachedEventArgs eventArgs) public void AttachPlayerToEntity(EntityAttachedEventArgs eventArgs)
{ {
IoCManager.Resolve<IEntityManager>().AddComponent<CharacterInterfaceComponent>(eventArgs.NewEntity); // TODO This is shitcode. Move this to an entity system, FOR FUCK'S SAKE
_entityManager.AddComponent<CharacterInterfaceComponent>(eventArgs.NewEntity);
} }
/// <summary> /// <summary>
/// Remove the character interface master from this entity now that we have detached ourselves from it /// Remove the character interface master from this entity now that we have detached ourselves from it
/// </summary> /// </summary>
public static void DetachPlayerFromEntity(EntityDetachedEventArgs eventArgs) public void DetachPlayerFromEntity(EntityDetachedEventArgs eventArgs)
{ {
if (!((!IoCManager.Resolve<IEntityManager>().EntityExists(eventArgs.OldEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(eventArgs.OldEntity).EntityLifeStage) >= EntityLifeStage.Deleted)) // TODO This is shitcode. Move this to an entity system, FOR FUCK'S SAKE
if (!_entityManager.Deleted(eventArgs.OldEntity))
{ {
IoCManager.Resolve<IEntityManager>().RemoveComponent<CharacterInterfaceComponent>(eventArgs.OldEntity); _entityManager.RemoveComponent<CharacterInterfaceComponent>(eventArgs.OldEntity);
} }
} }

View File

@@ -135,14 +135,14 @@ namespace Content.Client.Examine
}; };
vBox.AddChild(hBox); vBox.AddChild(hBox);
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ISpriteComponent? sprite)) if (EntityManager.TryGetComponent(entity, out ISpriteComponent? sprite))
{ {
hBox.AddChild(new SpriteView { Sprite = sprite, OverrideDirection = Direction.South }); hBox.AddChild(new SpriteView { Sprite = sprite, OverrideDirection = Direction.South });
} }
hBox.AddChild(new Label hBox.AddChild(new Label
{ {
Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName, Text = EntityManager.GetComponent<MetaDataComponent>(entity).EntityName,
HorizontalExpand = true, HorizontalExpand = true,
}); });

View File

@@ -10,6 +10,7 @@ namespace Content.Client.Interactable.Components
public class InteractionOutlineComponent : Component public class InteractionOutlineComponent : Component
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
private const float DefaultWidth = 1; private const float DefaultWidth = 1;
private const string ShaderInRange = "SelectionOutlineInrange"; private const string ShaderInRange = "SelectionOutlineInrange";
@@ -25,16 +26,16 @@ namespace Content.Client.Interactable.Components
{ {
_lastRenderScale = renderScale; _lastRenderScale = renderScale;
_inRange = inInteractionRange; _inRange = inInteractionRange;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? sprite)) if (_entMan.TryGetComponent(Owner, out ISpriteComponent? sprite))
{ {
sprite.PostShader = MakeNewShader(inInteractionRange, renderScale); sprite.PostShader = MakeNewShader(inInteractionRange, renderScale);
sprite.RenderOrder = IoCManager.Resolve<IEntityManager>().CurrentTick.Value; sprite.RenderOrder = _entMan.CurrentTick.Value;
} }
} }
public void OnMouseLeave() public void OnMouseLeave()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? sprite)) if (_entMan.TryGetComponent(Owner, out ISpriteComponent? sprite))
{ {
sprite.PostShader = null; sprite.PostShader = null;
sprite.RenderOrder = 0; sprite.RenderOrder = 0;
@@ -46,7 +47,7 @@ namespace Content.Client.Interactable.Components
public void UpdateInRange(bool inInteractionRange, int renderScale) public void UpdateInRange(bool inInteractionRange, int renderScale)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? sprite) if (_entMan.TryGetComponent(Owner, out ISpriteComponent? sprite)
&& (inInteractionRange != _inRange || _lastRenderScale != renderScale)) && (inInteractionRange != _inRange || _lastRenderScale != renderScale))
{ {
_inRange = inInteractionRange; _inRange = inInteractionRange;

View File

@@ -22,6 +22,8 @@ namespace Content.Client.Inventory
[ComponentReference(typeof(SharedInventoryComponent))] [ComponentReference(typeof(SharedInventoryComponent))]
public class ClientInventoryComponent : SharedInventoryComponent public class ClientInventoryComponent : SharedInventoryComponent
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private readonly Dictionary<Slots, EntityUid> _slots = new(); private readonly Dictionary<Slots, EntityUid> _slots = new();
public IReadOnlyDictionary<Slots, EntityUid> AllSlots => _slots; public IReadOnlyDictionary<Slots, EntityUid> AllSlots => _slots;
@@ -92,7 +94,7 @@ namespace Content.Client.Inventory
foreach (var (slot, entity) in state.Entities) foreach (var (slot, entity) in state.Entities)
{ {
if (!IoCManager.Resolve<IEntityManager>().EntityExists(entity)) if (!_entMan.EntityExists(entity))
{ {
continue; continue;
} }
@@ -136,7 +138,7 @@ namespace Content.Client.Inventory
return; return;
} }
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ClothingComponent? clothing)) if (_entMan.TryGetComponent(entity, 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

@@ -99,9 +99,10 @@ namespace Content.Client.Kitchen.UI
{ {
return; return;
} }
var texture = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(entity).Icon?.Default;
var solidItem = ChamberContentBox.BoxContents.AddItem(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName, texture); var texture = _entityManager.GetComponent<SpriteComponent>(entity).Icon?.Default;
var solidItem = ChamberContentBox.BoxContents.AddItem(_entityManager.GetComponent<MetaDataComponent>(entity).EntityName, texture);
var solidIndex = ChamberContentBox.BoxContents.IndexOf(solidItem); var solidIndex = ChamberContentBox.BoxContents.IndexOf(solidItem);
_chamberVisualContents.Add(solidIndex, entity); _chamberVisualContents.Add(solidIndex, entity);
} }

View File

@@ -16,9 +16,10 @@ namespace Content.Client.Kitchen.Visualizers
public override void OnChangeData(AppearanceComponent component) public override void OnChangeData(AppearanceComponent component)
{ {
base.OnChangeData(component); base.OnChangeData(component);
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner); var entMan = IoCManager.Resolve<IEntityManager>();
var sprite = entMan.GetComponent<ISpriteComponent>(component.Owner);
var microwaveComponent = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<MicrowaveComponent>(component.Owner); var microwaveComponent = entMan.GetComponentOrNull<MicrowaveComponent>(component.Owner);
if (!component.TryGetData(PowerDeviceVisuals.VisualState, out MicrowaveVisualState state)) if (!component.TryGetData(PowerDeviceVisuals.VisualState, out MicrowaveVisualState state))
{ {

View File

@@ -13,6 +13,7 @@ namespace Content.Client.Lathe.UI
{ {
public class LatheBoundUserInterface : BoundUserInterface public class LatheBoundUserInterface : BoundUserInterface
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[ViewVariables] [ViewVariables]
@@ -37,9 +38,9 @@ namespace Content.Client.Lathe.UI
{ {
base.Open(); base.Open();
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out MaterialStorageComponent? storage) if (!_entMan.TryGetComponent(Owner.Owner, out MaterialStorageComponent? storage)
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out SharedLatheComponent? lathe) || !_entMan.TryGetComponent(Owner.Owner, out SharedLatheComponent? lathe)
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out SharedLatheDatabaseComponent? database)) return; || !_entMan.TryGetComponent(Owner.Owner, out SharedLatheDatabaseComponent? database)) return;
Storage = storage; Storage = storage;
Lathe = lathe; Lathe = lathe;

View File

@@ -12,6 +12,8 @@ namespace Content.Client.Lathe.Visualizers
[UsedImplicitly] [UsedImplicitly]
public class AutolatheVisualizer : AppearanceVisualizer public class AutolatheVisualizer : AppearanceVisualizer
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private const string AnimationKey = "inserting_animation"; private const string AnimationKey = "inserting_animation";
private Animation _buildingAnimation; private Animation _buildingAnimation;
@@ -23,6 +25,7 @@ namespace Content.Client.Lathe.Visualizers
public AutolatheVisualizer() public AutolatheVisualizer()
{ {
IoCManager.InjectDependencies(this);
_buildingAnimation = PopulateAnimation("building", "building_unlit", 0.5f); _buildingAnimation = PopulateAnimation("building", "building_unlit", 0.5f);
_insertingMetalAnimation = PopulateAnimation("inserting_metal", "inserting_unlit", 0.5f); _insertingMetalAnimation = PopulateAnimation("inserting_metal", "inserting_unlit", 0.5f);
_insertingGlassAnimation = PopulateAnimation("inserting_glass", "inserting_unlit", 0.5f); _insertingGlassAnimation = PopulateAnimation("inserting_glass", "inserting_unlit", 0.5f);
@@ -50,9 +53,9 @@ namespace Content.Client.Lathe.Visualizers
public override void InitializeEntity(EntityUid entity) public override void InitializeEntity(EntityUid entity)
{ {
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AnimationPlayerComponent>(entity)) if (!_entMan.HasComponent<AnimationPlayerComponent>(entity))
{ {
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity); _entMan.AddComponent<AnimationPlayerComponent>(entity);
} }
} }
@@ -60,8 +63,8 @@ namespace Content.Client.Lathe.Visualizers
{ {
base.OnChangeData(component); base.OnChangeData(component);
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner); var sprite = _entMan.GetComponent<ISpriteComponent>(component.Owner);
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner); var animPlayer = _entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
if (!component.TryGetData(PowerDeviceVisuals.VisualState, out LatheVisualState state)) if (!component.TryGetData(PowerDeviceVisuals.VisualState, out LatheVisualState state))
{ {
state = LatheVisualState.Idle; state = LatheVisualState.Idle;

View File

@@ -12,6 +12,8 @@ namespace Content.Client.Lathe.Visualizers
[UsedImplicitly] [UsedImplicitly]
public class ProtolatheVisualizer : AppearanceVisualizer public class ProtolatheVisualizer : AppearanceVisualizer
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
private const string AnimationKey = "inserting_animation"; private const string AnimationKey = "inserting_animation";
private Animation _buildingAnimation; private Animation _buildingAnimation;
@@ -23,6 +25,8 @@ namespace Content.Client.Lathe.Visualizers
public ProtolatheVisualizer() public ProtolatheVisualizer()
{ {
IoCManager.InjectDependencies(this);
_buildingAnimation = PopulateAnimation("building", "building_unlit", 0.8f); _buildingAnimation = PopulateAnimation("building", "building_unlit", 0.8f);
_insertingMetalAnimation = PopulateAnimation("inserting_metal", "inserting_unlit", 0.8f); _insertingMetalAnimation = PopulateAnimation("inserting_metal", "inserting_unlit", 0.8f);
_insertingGlassAnimation = PopulateAnimation("inserting_glass", "inserting_unlit", 0.8f); _insertingGlassAnimation = PopulateAnimation("inserting_glass", "inserting_unlit", 0.8f);
@@ -50,9 +54,9 @@ namespace Content.Client.Lathe.Visualizers
public override void InitializeEntity(EntityUid entity) public override void InitializeEntity(EntityUid entity)
{ {
if (!IoCManager.Resolve<IEntityManager>().HasComponent<AnimationPlayerComponent>(entity)) if (!_entMan.HasComponent<AnimationPlayerComponent>(entity))
{ {
IoCManager.Resolve<IEntityManager>().AddComponent<AnimationPlayerComponent>(entity); _entMan.AddComponent<AnimationPlayerComponent>(entity);
} }
} }
@@ -60,8 +64,8 @@ namespace Content.Client.Lathe.Visualizers
{ {
base.OnChangeData(component); base.OnChangeData(component);
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner); var sprite = _entMan.GetComponent<ISpriteComponent>(component.Owner);
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner); var animPlayer = _entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
if (!component.TryGetData(PowerDeviceVisuals.VisualState, out LatheVisualState state)) if (!component.TryGetData(PowerDeviceVisuals.VisualState, out LatheVisualState state))
{ {
state = LatheVisualState.Idle; state = LatheVisualState.Idle;

View File

@@ -26,6 +26,7 @@ namespace Content.Client.Light.Components
[ImplicitDataDefinitionForInheritors] [ImplicitDataDefinitionForInheritors]
public abstract class LightBehaviourAnimationTrack : AnimationTrackProperty public abstract class LightBehaviourAnimationTrack : AnimationTrackProperty
{ {
protected IEntityManager _entMan = default!;
protected IRobustRandom _random = default!; protected IRobustRandom _random = default!;
[DataField("id")] [ViewVariables] public string ID { get; set; } = string.Empty; [DataField("id")] [ViewVariables] public string ID { get; set; } = string.Empty;
@@ -53,12 +54,13 @@ namespace Content.Client.Light.Components
private float _maxTime = default; private float _maxTime = default;
private EntityUid _parent = default!; private EntityUid _parent = default!;
public void Initialize(EntityUid parent, IRobustRandom random) public void Initialize(EntityUid parent, IRobustRandom random, IEntityManager entMan)
{ {
_random = random; _random = random;
_entMan = entMan;
_parent = parent; _parent = parent;
if (Enabled && IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent, out PointLightComponent? light)) if (Enabled && _entMan.TryGetComponent(_parent, out PointLightComponent? light))
{ {
light.Enabled = true; light.Enabled = true;
} }
@@ -68,7 +70,7 @@ namespace Content.Client.Light.Components
public void UpdatePlaybackValues(Animation owner) public void UpdatePlaybackValues(Animation owner)
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent, out PointLightComponent? light)) if (_entMan.TryGetComponent(_parent, out PointLightComponent? light))
{ {
light.Enabled = true; light.Enabled = true;
} }
@@ -99,7 +101,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 (IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent, out PointLightComponent? light)) if (_entMan.TryGetComponent(_parent, out PointLightComponent? light))
{ {
AnimationHelper.SetAnimatableProperty(light, Property, value); AnimationHelper.SetAnimatableProperty(light, Property, value);
} }
@@ -340,6 +342,9 @@ namespace Content.Client.Light.Components
[RegisterComponent] [RegisterComponent]
public class LightBehaviourComponent : SharedLightBehaviourComponent, ISerializationHooks public class LightBehaviourComponent : SharedLightBehaviourComponent, ISerializationHooks
{ {
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private const string KeyPrefix = nameof(LightBehaviourComponent); private const string KeyPrefix = nameof(LightBehaviourComponent);
public class AnimationContainer public class AnimationContainer
@@ -395,7 +400,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 (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AnimationPlayerComponent? animation)) if (_entMan.TryGetComponent(Owner, out AnimationPlayerComponent? animation))
{ {
#pragma warning disable 618 #pragma warning disable 618
animation.AnimationCompleted += OnAnimationCompleted; animation.AnimationCompleted += OnAnimationCompleted;
@@ -404,7 +409,7 @@ namespace Content.Client.Light.Components
foreach (var container in _animations) foreach (var container in _animations)
{ {
container.LightBehaviour.Initialize(Owner, IoCManager.Resolve<IRobustRandom>()); container.LightBehaviour.Initialize(Owner, _random, _entMan);
} }
// we need to initialize all behaviours before starting any // we need to initialize all behaviours before starting any
@@ -430,7 +435,7 @@ namespace Content.Client.Light.Components
{ {
container.LightBehaviour.UpdatePlaybackValues(container.Animation); container.LightBehaviour.UpdatePlaybackValues(container.Animation);
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AnimationPlayerComponent? animation)) if (_entMan.TryGetComponent(Owner, out AnimationPlayerComponent? animation))
{ {
animation.Play(container.Animation, container.FullKey); animation.Play(container.Animation, container.FullKey);
} }
@@ -442,7 +447,7 @@ namespace Content.Client.Light.Components
/// </summary> /// </summary>
private void CopyLightSettings() private void CopyLightSettings()
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PointLightComponent? light)) if (_entMan.TryGetComponent(Owner, out PointLightComponent? light))
{ {
_originalColor = light.Color; _originalColor = light.Color;
_originalEnabled = light.Enabled; _originalEnabled = light.Enabled;
@@ -452,7 +457,7 @@ namespace Content.Client.Light.Components
} }
else else
{ {
Logger.Warning($"{IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!"); Logger.Warning($"{_entMan.GetComponent<MetaDataComponent>(Owner).EntityName} has a {nameof(LightBehaviourComponent)} but it has no {nameof(PointLightComponent)}! Check the prototype!");
} }
} }
@@ -463,7 +468,7 @@ namespace Content.Client.Light.Components
/// </summary> /// </summary>
public void StartLightBehaviour(string id = "") public void StartLightBehaviour(string id = "")
{ {
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AnimationPlayerComponent? animation)) if (!_entMan.TryGetComponent(Owner, out AnimationPlayerComponent? animation))
{ {
return; return;
} }
@@ -491,7 +496,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 (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AnimationPlayerComponent? animation)) if (!_entMan.TryGetComponent(Owner, out AnimationPlayerComponent? animation))
{ {
return; return;
} }
@@ -519,7 +524,7 @@ namespace Content.Client.Light.Components
_animations.Remove(container); _animations.Remove(container);
} }
if (resetToOriginalSettings && IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PointLightComponent? light)) if (resetToOriginalSettings && _entMan.TryGetComponent(Owner, out PointLightComponent? light))
{ {
light.Color = _originalColor; light.Color = _originalColor;
light.Enabled = _originalEnabled; light.Enabled = _originalEnabled;
@@ -546,7 +551,7 @@ namespace Content.Client.Light.Components
AnimationTracks = {behaviour} AnimationTracks = {behaviour}
}; };
behaviour.Initialize(Owner, IoCManager.Resolve<IRobustRandom>()); behaviour.Initialize(Owner, _random, _entMan);
var container = new AnimationContainer(key, animation, behaviour); var container = new AnimationContainer(key, animation, behaviour);
_animations.Add(container); _animations.Add(container);

View File

@@ -22,6 +22,7 @@ namespace Content.Client.Lobby.UI
{ {
public class LobbyCharacterPreviewPanel : Control public class LobbyCharacterPreviewPanel : Control
{ {
private readonly IEntityManager _entMan;
private readonly IClientPreferencesManager _preferencesManager; private readonly IClientPreferencesManager _preferencesManager;
private EntityUid _previewDummy; private EntityUid _previewDummy;
private readonly Label _summaryLabel; private readonly Label _summaryLabel;
@@ -31,6 +32,7 @@ namespace Content.Client.Lobby.UI
public LobbyCharacterPreviewPanel(IEntityManager entityManager, public LobbyCharacterPreviewPanel(IEntityManager entityManager,
IClientPreferencesManager preferencesManager) IClientPreferencesManager preferencesManager)
{ {
_entMan = entityManager;
_preferencesManager = preferencesManager; _preferencesManager = preferencesManager;
_previewDummy = entityManager.SpawnEntity("MobHumanDummy", MapCoordinates.Nullspace); _previewDummy = entityManager.SpawnEntity("MobHumanDummy", MapCoordinates.Nullspace);
@@ -98,15 +100,15 @@ namespace Content.Client.Lobby.UI
_preferencesManager.OnServerDataLoaded -= UpdateUI; _preferencesManager.OnServerDataLoaded -= UpdateUI;
if (!disposing) return; if (!disposing) return;
IoCManager.Resolve<IEntityManager>().DeleteEntity(_previewDummy); _entMan.DeleteEntity(_previewDummy);
_previewDummy = default; _previewDummy = default;
} }
private static SpriteView MakeSpriteView(EntityUid entity, Direction direction) private SpriteView MakeSpriteView(EntityUid entity, Direction direction)
{ {
return new() return new()
{ {
Sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity), Sprite = _entMan.GetComponent<ISpriteComponent>(entity),
OverrideDirection = direction, OverrideDirection = direction,
Scale = (2, 2) Scale = (2, 2)
}; };
@@ -136,11 +138,11 @@ namespace Content.Client.Lobby.UI
} }
} }
public static void GiveDummyJobClothes(EntityUid dummy, HumanoidCharacterProfile profile) public void GiveDummyJobClothes(EntityUid dummy, HumanoidCharacterProfile profile)
{ {
var protoMan = IoCManager.Resolve<IPrototypeManager>(); var protoMan = IoCManager.Resolve<IPrototypeManager>();
var inventory = IoCManager.Resolve<IEntityManager>().GetComponent<ClientInventoryComponent>(dummy); var inventory = _entMan.GetComponent<ClientInventoryComponent>(dummy);
var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key; var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key;
@@ -151,7 +153,7 @@ namespace Content.Client.Lobby.UI
if (job.StartingGear != null) if (job.StartingGear != null)
{ {
var entityMan = IoCManager.Resolve<IEntityManager>(); var entityMan = _entMan;
var gear = protoMan.Index<StartingGearPrototype>(job.StartingGear); var gear = protoMan.Index<StartingGearPrototype>(job.StartingGear);
foreach (var slot in AllSlots) foreach (var slot in AllSlots)
@@ -161,7 +163,7 @@ namespace Content.Client.Lobby.UI
{ {
var item = entityMan.SpawnEntity(itemType, MapCoordinates.Nullspace); var item = entityMan.SpawnEntity(itemType, MapCoordinates.Nullspace);
inventory.SetSlotVisuals(slot, item); inventory.SetSlotVisuals(slot, item);
IoCManager.Resolve<IEntityManager>().DeleteEntity(item); _entMan.DeleteEntity(item);
} }
} }
} }