And a bunch more.
This commit is contained in:
@@ -36,9 +36,11 @@ namespace Content.Client.Body.UI
|
||||
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);
|
||||
|
||||
@@ -146,10 +146,11 @@ namespace Content.Client.Body.UI
|
||||
|
||||
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
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@ namespace Content.Client.Cargo
|
||||
{
|
||||
base.Open();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out GalacticMarketComponent? market) ||
|
||||
!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return;
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetComponent(Owner.Owner, out GalacticMarketComponent? market) ||
|
||||
!entMan.TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return;
|
||||
|
||||
Market = market;
|
||||
Orders = orders;
|
||||
|
||||
@@ -50,12 +50,13 @@ namespace Content.Client.CharacterInfo.Components
|
||||
{
|
||||
case CharacterInfoMessage 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.NameLabel.Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName;
|
||||
_control.NameLabel.Text = entityManager.GetComponent<MetaDataComponent>(Owner).EntityName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ namespace Content.Client.Chat.Managers
|
||||
private void EnqueueSpeechBubble(EntityUid entity, string contents, SpeechBubble.SpeechType speechType)
|
||||
{
|
||||
// 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;
|
||||
|
||||
if (!_queuedSpeechBubbles.TryGetValue(entity, out var queueData))
|
||||
@@ -496,7 +496,7 @@ namespace Content.Client.Chat.Managers
|
||||
private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData)
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Content.Client.Chat.UI
|
||||
private readonly IEyeManager _eyeManager;
|
||||
private readonly EntityUid _senderEntity;
|
||||
private readonly IChatManager _chatManager;
|
||||
private readonly IEntityManager _entityManager;
|
||||
|
||||
private float _timeLeft = TotalTime;
|
||||
|
||||
@@ -46,26 +47,27 @@ namespace Content.Client.Chat.UI
|
||||
|
||||
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)
|
||||
{
|
||||
case SpeechType.Emote:
|
||||
return new EmoteSpeechBubble(text, senderEntity, eyeManager, chatManager);
|
||||
return new EmoteSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager);
|
||||
|
||||
case SpeechType.Say:
|
||||
return new SaySpeechBubble(text, senderEntity, eyeManager, chatManager);
|
||||
return new SaySpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager);
|
||||
|
||||
default:
|
||||
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;
|
||||
_senderEntity = senderEntity;
|
||||
_eyeManager = eyeManager;
|
||||
_entityManager = entityManager;
|
||||
|
||||
// Use text clipping so new messages don't overlap old ones being pushed up.
|
||||
RectClipContent = true;
|
||||
@@ -99,7 +101,7 @@ namespace Content.Client.Chat.UI
|
||||
_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);
|
||||
return;
|
||||
@@ -116,14 +118,14 @@ namespace Content.Client.Chat.UI
|
||||
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(0, Die);
|
||||
return;
|
||||
}
|
||||
|
||||
var worldPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_senderEntity).WorldPosition;
|
||||
var worldPos = _entityManager.GetComponent<TransformComponent>(_senderEntity).WorldPosition;
|
||||
var scale = _eyeManager.MainViewport.GetRenderScale();
|
||||
var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale);
|
||||
var lowerCenter = (_eyeManager.WorldToScreen(worldPos) - offset) / UIScale;
|
||||
@@ -162,8 +164,8 @@ namespace Content.Client.Chat.UI
|
||||
public class EmoteSpeechBubble : SpeechBubble
|
||||
|
||||
{
|
||||
public EmoteSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager)
|
||||
: base(text, senderEntity, eyeManager, chatManager)
|
||||
public EmoteSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
|
||||
: base(text, senderEntity, eyeManager, chatManager, entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -188,8 +190,8 @@ namespace Content.Client.Chat.UI
|
||||
|
||||
public class SaySpeechBubble : SpeechBubble
|
||||
{
|
||||
public SaySpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager)
|
||||
: base(text, senderEntity, eyeManager, chatManager)
|
||||
public SaySpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
|
||||
: base(text, senderEntity, eyeManager, chatManager, entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
namespace Content.Client.Clickable
|
||||
{
|
||||
@@ -29,14 +30,15 @@ namespace Content.Client.Clickable
|
||||
/// <returns>True if the click worked, false otherwise.</returns>
|
||||
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;
|
||||
renderOrder = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner);
|
||||
var transform = entMan.GetComponent<TransformComponent>(Owner);
|
||||
var localPos = transform.InvWorldMatrix.Transform(worldPos);
|
||||
var spriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix());
|
||||
|
||||
|
||||
@@ -50,12 +50,12 @@ namespace Content.Client.Commands
|
||||
EntitySystem.Get<SubFloorHideSystem>()
|
||||
.ShowAll = true;
|
||||
|
||||
var components = IoCManager.Resolve<IEntityManager>()
|
||||
.EntityQuery<SubFloorHideComponent>(true);
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var components = entMan.EntityQuery<SubFloorHideComponent>(true);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Content.Client.Commands
|
||||
|
||||
foreach (var mechanism in mechanisms)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(mechanism.Owner, out SpriteComponent? sprite))
|
||||
if (!entityManager.TryGetComponent(mechanism.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Content.Client.Commands
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace Content.Client.Construction
|
||||
if (!args.EntityUid.IsValid() || !args.EntityUid.IsClientSide())
|
||||
return false;
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ConstructionGhostComponent?>(args.EntityUid, out var ghostComp))
|
||||
if (!EntityManager.TryGetComponent<ConstructionGhostComponent?>(args.EntityUid, out var ghostComp))
|
||||
return false;
|
||||
|
||||
TryStartConstruction(ghostComp.GhostId);
|
||||
@@ -172,12 +172,12 @@ namespace Content.Client.Construction
|
||||
}
|
||||
|
||||
var ghost = EntityManager.SpawnEntity("constructionghost", loc);
|
||||
var comp = IoCManager.Resolve<IEntityManager>().GetComponent<ConstructionGhostComponent>(ghost);
|
||||
var comp = EntityManager.GetComponent<ConstructionGhostComponent>(ghost);
|
||||
comp.Prototype = prototype;
|
||||
comp.GhostId = _nextId++;
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ghost).LocalRotation = dir.ToAngle();
|
||||
EntityManager.GetComponent<TransformComponent>(ghost).LocalRotation = dir.ToAngle();
|
||||
_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.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);
|
||||
@@ -192,7 +192,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
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;
|
||||
@@ -207,7 +207,7 @@ namespace Content.Client.Construction
|
||||
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);
|
||||
RaiseNetworkEvent(msg);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
if (_ghosts.TryGetValue(ghostId, out var ghost))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(ghost.Owner);
|
||||
EntityManager.QueueDeleteEntity(ghost.Owner);
|
||||
_ghosts.Remove(ghostId);
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
foreach (var (_, ghost) in _ghosts)
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(ghost.Owner);
|
||||
EntityManager.QueueDeleteEntity(ghost.Owner);
|
||||
}
|
||||
|
||||
_ghosts.Clear();
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Content.Client.ContextMenu.UI
|
||||
{
|
||||
public const string StyleClassEntityMenuCountText = "contextMenuCount";
|
||||
|
||||
[Dependency] private IEntityManager _entityManager = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The entity that can be accessed by interacting with this element.
|
||||
/// </summary>
|
||||
@@ -28,6 +30,8 @@ namespace Content.Client.ContextMenu.UI
|
||||
|
||||
public EntityMenuElement(EntityUid entity = default)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
CountLabel = new Label { StyleClasses = { StyleClassEntityMenuCountText } };
|
||||
Icon.AddChild(new LayoutContainer() { Children = { EntityIcon, CountLabel } });
|
||||
|
||||
@@ -57,7 +61,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
if (entity == default)
|
||||
@@ -66,12 +70,12 @@ namespace Content.Client.ContextMenu.UI
|
||||
return;
|
||||
}
|
||||
|
||||
EntityIcon.Sprite = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ISpriteComponent>(entity);
|
||||
EntityIcon.Sprite = _entityManager.GetComponentOrNull<ISpriteComponent>(entity);
|
||||
|
||||
if (UserInterfaceManager.DebugMonitors.Visible)
|
||||
Text = $"{IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity!).EntityName} ({entity})";
|
||||
Text = $"{_entityManager.GetComponent<MetaDataComponent>(entity!).EntityName} ({entity})";
|
||||
else
|
||||
Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity!).EntityName;
|
||||
Text = _entityManager.GetComponent<MetaDataComponent>(entity!).EntityName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
|
||||
var entitySpriteStates = GroupEntities(entities);
|
||||
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();
|
||||
AddToUI(orderedStates);
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func);
|
||||
|
||||
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;
|
||||
if (session != null)
|
||||
@@ -187,7 +187,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
// find the element associated with this entity
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -21,25 +21,25 @@ namespace Content.Client.ContextMenu.UI
|
||||
{
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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) =>
|
||||
(a, b, entMan) => entMan.GetComponent<MetaDataComponent>(a).EntityPrototype!.ID == entMan.GetComponent<MetaDataComponent>(b).EntityPrototype!.ID,
|
||||
(a, b, entMan) =>
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(a, out var spriteA);
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(b, out var spriteB);
|
||||
entMan.TryGetComponent<ISpriteComponent?>(a, out var spriteA);
|
||||
entMan.TryGetComponent<ISpriteComponent?>(b, out var spriteB);
|
||||
|
||||
if (spriteA == null || spriteB == null)
|
||||
return spriteA == spriteB;
|
||||
@@ -50,13 +50,13 @@ namespace Content.Client.ContextMenu.UI
|
||||
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 =>
|
||||
(e, entMan) => EqualityComparer<string>.Default.GetHashCode(entMan.GetComponent<MetaDataComponent>(e).EntityPrototype!.ID),
|
||||
(e, entMan) =>
|
||||
{
|
||||
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!);
|
||||
}
|
||||
@@ -67,9 +67,13 @@ namespace Content.Client.ContextMenu.UI
|
||||
private static int Count => EqualsList.Count - 1;
|
||||
|
||||
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;
|
||||
_entMan = entMan;
|
||||
}
|
||||
|
||||
public bool Equals(EntityUid x, EntityUid y)
|
||||
@@ -79,12 +83,12 @@ namespace Content.Client.ContextMenu.UI
|
||||
return y == default;
|
||||
}
|
||||
|
||||
return y != default && EqualsList[_depth](x, y);
|
||||
return y != default && EqualsList[_depth](x, y, _entMan);
|
||||
}
|
||||
|
||||
public int GetHashCode(EntityUid e)
|
||||
{
|
||||
return GetHashCodeList[_depth](e);
|
||||
return GetHashCodeList[_depth](e, _entMan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Content.Client.Damage
|
||||
/// </summary>
|
||||
public class DamageVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[Dependency] IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
private const string _name = "DamageVisualizer";
|
||||
/// <summary>
|
||||
@@ -195,12 +195,15 @@ namespace Content.Client.Damage
|
||||
public readonly string? Color;
|
||||
}
|
||||
|
||||
public DamageVisualizer()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var damageData = _entityManager.EnsureComponent<DamageVisualizerDataComponent>(entity);
|
||||
VerifyVisualizerSetup(entity, damageData);
|
||||
if (damageData.Valid)
|
||||
@@ -291,9 +294,9 @@ namespace Content.Client.Damage
|
||||
|
||||
private void InitializeVisualizer(EntityUid entity, DamageVisualizerDataComponent damageData)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SpriteComponent? spriteComponent)
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent<DamageableComponent?>(entity, out var damageComponent)
|
||||
|| !IoCManager.Resolve<IEntityManager>().HasComponent<AppearanceComponent>(entity))
|
||||
if (!_entityManager.TryGetComponent(entity, out SpriteComponent? spriteComponent)
|
||||
|| !_entityManager.TryGetComponent<DamageableComponent?>(entity, out var damageComponent)
|
||||
|| !_entityManager.HasComponent<AppearanceComponent>(entity))
|
||||
return;
|
||||
|
||||
_thresholds.Add(FixedPoint2.Zero);
|
||||
@@ -504,7 +507,7 @@ namespace Content.Client.Damage
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
var entities = _entityManager;
|
||||
if (!entities.TryGetComponent(component.Owner, out DamageVisualizerDataComponent damageData))
|
||||
return;
|
||||
|
||||
@@ -526,7 +529,7 @@ namespace Content.Client.Damage
|
||||
|
||||
private void HandleDamage(AppearanceComponent component, DamageVisualizerDataComponent damageData)
|
||||
{
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
var entities = _entityManager;
|
||||
if (!entities.TryGetComponent(component.Owner, out SpriteComponent spriteComponent)
|
||||
|| !entities.TryGetComponent(component.Owner, out DamageableComponent damageComponent))
|
||||
return;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Content.Client.Disposal.Systems
|
||||
{
|
||||
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;
|
||||
if (state == null) return true;
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Content.Client.Disposal.Visualizers
|
||||
case VisualState.Flushing:
|
||||
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))
|
||||
{
|
||||
|
||||
@@ -160,8 +160,9 @@ namespace Content.Client.DoAfter.UI
|
||||
return;
|
||||
}
|
||||
|
||||
if (_eyeManager.CurrentMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(AttachedEntity).MapID ||
|
||||
!IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(AttachedEntity).Coordinates.IsValid(_entityManager))
|
||||
var transform = _entityManager.GetComponent<TransformComponent>(AttachedEntity);
|
||||
|
||||
if (_eyeManager.CurrentMap != transform.MapID || !transform.Coordinates.IsValid(_entityManager))
|
||||
{
|
||||
Visible = false;
|
||||
return;
|
||||
@@ -211,7 +212,7 @@ namespace Content.Client.DoAfter.UI
|
||||
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);
|
||||
LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace Content.Client.Doors
|
||||
[UsedImplicitly]
|
||||
public class AirlockVisualizer : AppearanceVisualizer, ISerializationHooks
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private const string AnimationKey = "airlock_animation";
|
||||
|
||||
[DataField("animationTime")]
|
||||
@@ -46,6 +48,11 @@ namespace Content.Client.Doors
|
||||
private Animation OpenAnimation = default!;
|
||||
private Animation DenyAnimation = default!;
|
||||
|
||||
public AirlockVisualizer()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
CloseAnimation = new Animation {Length = TimeSpan.FromSeconds(_delay)};
|
||||
@@ -110,9 +117,9 @@ namespace Content.Client.Doors
|
||||
|
||||
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);
|
||||
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
var sprite = _entMan.GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = _entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
if (!component.TryGetData(DoorVisuals.VisualState, out DoorVisualState state))
|
||||
{
|
||||
state = DoorVisualState.Closed;
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace Content.Client.Entry
|
||||
[Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner = default!;
|
||||
[Dependency] private readonly IGameController _gameController = default!;
|
||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
@@ -141,19 +142,21 @@ namespace Content.Client.Entry
|
||||
/// <summary>
|
||||
/// Add the character interface master which combines all character interfaces into one window
|
||||
/// </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>
|
||||
/// Remove the character interface master from this entity now that we have detached ourselves from it
|
||||
/// </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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,14 +135,14 @@ namespace Content.Client.Examine
|
||||
};
|
||||
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 Label
|
||||
{
|
||||
Text = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityName,
|
||||
Text = EntityManager.GetComponent<MetaDataComponent>(entity).EntityName,
|
||||
HorizontalExpand = true,
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Content.Client.Interactable.Components
|
||||
public class InteractionOutlineComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private const float DefaultWidth = 1;
|
||||
private const string ShaderInRange = "SelectionOutlineInrange";
|
||||
@@ -25,16 +26,16 @@ namespace Content.Client.Interactable.Components
|
||||
{
|
||||
_lastRenderScale = renderScale;
|
||||
_inRange = inInteractionRange;
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? sprite))
|
||||
if (_entMan.TryGetComponent(Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
sprite.PostShader = MakeNewShader(inInteractionRange, renderScale);
|
||||
sprite.RenderOrder = IoCManager.Resolve<IEntityManager>().CurrentTick.Value;
|
||||
sprite.RenderOrder = _entMan.CurrentTick.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMouseLeave()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ISpriteComponent? sprite))
|
||||
if (_entMan.TryGetComponent(Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
sprite.PostShader = null;
|
||||
sprite.RenderOrder = 0;
|
||||
@@ -46,7 +47,7 @@ namespace Content.Client.Interactable.Components
|
||||
|
||||
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))
|
||||
{
|
||||
_inRange = inInteractionRange;
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Content.Client.Inventory
|
||||
[ComponentReference(typeof(SharedInventoryComponent))]
|
||||
public class ClientInventoryComponent : SharedInventoryComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private readonly Dictionary<Slots, EntityUid> _slots = new();
|
||||
|
||||
public IReadOnlyDictionary<Slots, EntityUid> AllSlots => _slots;
|
||||
@@ -92,7 +94,7 @@ namespace Content.Client.Inventory
|
||||
|
||||
foreach (var (slot, entity) in state.Entities)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().EntityExists(entity))
|
||||
if (!_entMan.EntityExists(entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -136,7 +138,7 @@ namespace Content.Client.Inventory
|
||||
return;
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ClothingComponent? clothing))
|
||||
if (_entMan.TryGetComponent(entity, out ClothingComponent? clothing))
|
||||
{
|
||||
var flag = SlotMasks[slot];
|
||||
var data = clothing.GetEquippedStateInfo(flag, SpeciesId);
|
||||
|
||||
@@ -99,9 +99,10 @@ namespace Content.Client.Kitchen.UI
|
||||
{
|
||||
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);
|
||||
_chamberVisualContents.Add(solidIndex, entity);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ namespace Content.Client.Kitchen.Visualizers
|
||||
public override void OnChangeData(AppearanceComponent 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))
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Content.Client.Lathe.UI
|
||||
{
|
||||
public class LatheBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
[ViewVariables]
|
||||
@@ -37,9 +38,9 @@ namespace Content.Client.Lathe.UI
|
||||
{
|
||||
base.Open();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out MaterialStorageComponent? storage)
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out SharedLatheComponent? lathe)
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out SharedLatheDatabaseComponent? database)) return;
|
||||
if (!_entMan.TryGetComponent(Owner.Owner, out MaterialStorageComponent? storage)
|
||||
|| !_entMan.TryGetComponent(Owner.Owner, out SharedLatheComponent? lathe)
|
||||
|| !_entMan.TryGetComponent(Owner.Owner, out SharedLatheDatabaseComponent? database)) return;
|
||||
|
||||
Storage = storage;
|
||||
Lathe = lathe;
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Content.Client.Lathe.Visualizers
|
||||
[UsedImplicitly]
|
||||
public class AutolatheVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private const string AnimationKey = "inserting_animation";
|
||||
|
||||
private Animation _buildingAnimation;
|
||||
@@ -23,6 +25,7 @@ namespace Content.Client.Lathe.Visualizers
|
||||
|
||||
public AutolatheVisualizer()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_buildingAnimation = PopulateAnimation("building", "building_unlit", 0.5f);
|
||||
_insertingMetalAnimation = PopulateAnimation("inserting_metal", "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)
|
||||
{
|
||||
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);
|
||||
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
var sprite = _entMan.GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = _entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
if (!component.TryGetData(PowerDeviceVisuals.VisualState, out LatheVisualState state))
|
||||
{
|
||||
state = LatheVisualState.Idle;
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Content.Client.Lathe.Visualizers
|
||||
[UsedImplicitly]
|
||||
public class ProtolatheVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private const string AnimationKey = "inserting_animation";
|
||||
|
||||
private Animation _buildingAnimation;
|
||||
@@ -23,6 +25,8 @@ namespace Content.Client.Lathe.Visualizers
|
||||
|
||||
public ProtolatheVisualizer()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_buildingAnimation = PopulateAnimation("building", "building_unlit", 0.8f);
|
||||
_insertingMetalAnimation = PopulateAnimation("inserting_metal", "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)
|
||||
{
|
||||
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);
|
||||
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
var sprite = _entMan.GetComponent<ISpriteComponent>(component.Owner);
|
||||
var animPlayer = _entMan.GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
if (!component.TryGetData(PowerDeviceVisuals.VisualState, out LatheVisualState state))
|
||||
{
|
||||
state = LatheVisualState.Idle;
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Content.Client.Light.Components
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class LightBehaviourAnimationTrack : AnimationTrackProperty
|
||||
{
|
||||
protected IEntityManager _entMan = default!;
|
||||
protected IRobustRandom _random = default!;
|
||||
|
||||
[DataField("id")] [ViewVariables] public string ID { get; set; } = string.Empty;
|
||||
@@ -53,12 +54,13 @@ namespace Content.Client.Light.Components
|
||||
private float _maxTime = default;
|
||||
private EntityUid _parent = default!;
|
||||
|
||||
public void Initialize(EntityUid parent, IRobustRandom random)
|
||||
public void Initialize(EntityUid parent, IRobustRandom random, IEntityManager entMan)
|
||||
{
|
||||
_random = random;
|
||||
_entMan = entMan;
|
||||
_parent = parent;
|
||||
|
||||
if (Enabled && IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent, out PointLightComponent? light))
|
||||
if (Enabled && _entMan.TryGetComponent(_parent, out PointLightComponent? light))
|
||||
{
|
||||
light.Enabled = true;
|
||||
}
|
||||
@@ -68,7 +70,7 @@ namespace Content.Client.Light.Components
|
||||
|
||||
public void UpdatePlaybackValues(Animation owner)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_parent, out PointLightComponent? light))
|
||||
if (_entMan.TryGetComponent(_parent, out PointLightComponent? light))
|
||||
{
|
||||
light.Enabled = true;
|
||||
}
|
||||
@@ -99,7 +101,7 @@ namespace Content.Client.Light.Components
|
||||
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);
|
||||
}
|
||||
@@ -340,6 +342,9 @@ namespace Content.Client.Light.Components
|
||||
[RegisterComponent]
|
||||
public class LightBehaviourComponent : SharedLightBehaviourComponent, ISerializationHooks
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private const string KeyPrefix = nameof(LightBehaviourComponent);
|
||||
|
||||
public class AnimationContainer
|
||||
@@ -395,7 +400,7 @@ namespace Content.Client.Light.Components
|
||||
// TODO: Do NOT ensure component here. And use eventbus events instead...
|
||||
Owner.EnsureComponent<AnimationPlayerComponent>();
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AnimationPlayerComponent? animation))
|
||||
if (_entMan.TryGetComponent(Owner, out AnimationPlayerComponent? animation))
|
||||
{
|
||||
#pragma warning disable 618
|
||||
animation.AnimationCompleted += OnAnimationCompleted;
|
||||
@@ -404,7 +409,7 @@ namespace Content.Client.Light.Components
|
||||
|
||||
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
|
||||
@@ -430,7 +435,7 @@ namespace Content.Client.Light.Components
|
||||
{
|
||||
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);
|
||||
}
|
||||
@@ -442,7 +447,7 @@ namespace Content.Client.Light.Components
|
||||
/// </summary>
|
||||
private void CopyLightSettings()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out PointLightComponent? light))
|
||||
if (_entMan.TryGetComponent(Owner, out PointLightComponent? light))
|
||||
{
|
||||
_originalColor = light.Color;
|
||||
_originalEnabled = light.Enabled;
|
||||
@@ -452,7 +457,7 @@ namespace Content.Client.Light.Components
|
||||
}
|
||||
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>
|
||||
public void StartLightBehaviour(string id = "")
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AnimationPlayerComponent? animation))
|
||||
if (!_entMan.TryGetComponent(Owner, out AnimationPlayerComponent? animation))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -491,7 +496,7 @@ namespace Content.Client.Light.Components
|
||||
/// <param name="resetToOriginalSettings">Should the light have its original settings applied?</param>
|
||||
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;
|
||||
}
|
||||
@@ -519,7 +524,7 @@ namespace Content.Client.Light.Components
|
||||
_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.Enabled = _originalEnabled;
|
||||
@@ -546,7 +551,7 @@ namespace Content.Client.Light.Components
|
||||
AnimationTracks = {behaviour}
|
||||
};
|
||||
|
||||
behaviour.Initialize(Owner, IoCManager.Resolve<IRobustRandom>());
|
||||
behaviour.Initialize(Owner, _random, _entMan);
|
||||
|
||||
var container = new AnimationContainer(key, animation, behaviour);
|
||||
_animations.Add(container);
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Content.Client.Lobby.UI
|
||||
{
|
||||
public class LobbyCharacterPreviewPanel : Control
|
||||
{
|
||||
private readonly IEntityManager _entMan;
|
||||
private readonly IClientPreferencesManager _preferencesManager;
|
||||
private EntityUid _previewDummy;
|
||||
private readonly Label _summaryLabel;
|
||||
@@ -31,6 +32,7 @@ namespace Content.Client.Lobby.UI
|
||||
public LobbyCharacterPreviewPanel(IEntityManager entityManager,
|
||||
IClientPreferencesManager preferencesManager)
|
||||
{
|
||||
_entMan = entityManager;
|
||||
_preferencesManager = preferencesManager;
|
||||
_previewDummy = entityManager.SpawnEntity("MobHumanDummy", MapCoordinates.Nullspace);
|
||||
|
||||
@@ -98,15 +100,15 @@ namespace Content.Client.Lobby.UI
|
||||
_preferencesManager.OnServerDataLoaded -= UpdateUI;
|
||||
|
||||
if (!disposing) return;
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(_previewDummy);
|
||||
_entMan.DeleteEntity(_previewDummy);
|
||||
_previewDummy = default;
|
||||
}
|
||||
|
||||
private static SpriteView MakeSpriteView(EntityUid entity, Direction direction)
|
||||
private SpriteView MakeSpriteView(EntityUid entity, Direction direction)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity),
|
||||
Sprite = _entMan.GetComponent<ISpriteComponent>(entity),
|
||||
OverrideDirection = direction,
|
||||
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 inventory = IoCManager.Resolve<IEntityManager>().GetComponent<ClientInventoryComponent>(dummy);
|
||||
var inventory = _entMan.GetComponent<ClientInventoryComponent>(dummy);
|
||||
|
||||
var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key;
|
||||
|
||||
@@ -151,7 +153,7 @@ namespace Content.Client.Lobby.UI
|
||||
|
||||
if (job.StartingGear != null)
|
||||
{
|
||||
var entityMan = IoCManager.Resolve<IEntityManager>();
|
||||
var entityMan = _entMan;
|
||||
var gear = protoMan.Index<StartingGearPrototype>(job.StartingGear);
|
||||
|
||||
foreach (var slot in AllSlots)
|
||||
@@ -161,7 +163,7 @@ namespace Content.Client.Lobby.UI
|
||||
{
|
||||
var item = entityMan.SpawnEntity(itemType, MapCoordinates.Nullspace);
|
||||
inventory.SetSlotVisuals(slot, item);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(item);
|
||||
_entMan.DeleteEntity(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user