Merge pull request #5680 from Zumorica/2021-12-03-remove-IEntity-komm-süsser-todd
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Content.Client.AI
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
|
||||
private AiDebugMode _tooltips = AiDebugMode.None;
|
||||
private readonly Dictionary<IEntity, PanelContainer> _aiBoxes = new();
|
||||
private readonly Dictionary<EntityUid, PanelContainer> _aiBoxes = new();
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
@@ -37,22 +37,22 @@ namespace Content.Client.AI
|
||||
return;
|
||||
}
|
||||
|
||||
var deletedEntities = new List<IEntity>(0);
|
||||
var deletedEntities = new List<EntityUid>(0);
|
||||
foreach (var (entity, panel) in _aiBoxes)
|
||||
{
|
||||
if (entity.Deleted)
|
||||
if (Deleted(entity))
|
||||
{
|
||||
deletedEntities.Add(entity);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_eyeManager.GetWorldViewport().Contains(entity.Transform.WorldPosition))
|
||||
if (!_eyeManager.GetWorldViewport().Contains(EntityManager.GetComponent<TransformComponent>(entity).WorldPosition))
|
||||
{
|
||||
panel.Visible = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
var (x, y) = _eyeManager.CoordinatesToScreen(entity.Transform.Coordinates).Position;
|
||||
var (x, y) = _eyeManager.CoordinatesToScreen(EntityManager.GetComponent<TransformComponent>(entity).Coordinates).Position;
|
||||
var offsetPosition = new Vector2(x - panel.Width / 2, y - panel.Height - 50f);
|
||||
panel.Visible = true;
|
||||
|
||||
@@ -78,8 +78,7 @@ namespace Content.Client.AI
|
||||
if ((_tooltips & AiDebugMode.Thonk) != 0)
|
||||
{
|
||||
// I guess if it's out of range we don't know about it?
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var entity = entityManager.GetEntity(message.EntityUid);
|
||||
var entity = message.EntityUid;
|
||||
TryCreatePanel(entity);
|
||||
|
||||
// Probably shouldn't access by index but it's a debugging tool so eh
|
||||
@@ -95,8 +94,7 @@ namespace Content.Client.AI
|
||||
{
|
||||
if ((_tooltips & AiDebugMode.Paths) != 0)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var entity = entityManager.GetEntity(message.EntityUid);
|
||||
var entity = message.EntityUid;
|
||||
TryCreatePanel(entity);
|
||||
|
||||
var label = (Label) _aiBoxes[entity].GetChild(0).GetChild(1);
|
||||
@@ -110,8 +108,7 @@ namespace Content.Client.AI
|
||||
{
|
||||
if ((_tooltips & AiDebugMode.Paths) != 0)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var entity = entityManager.GetEntity(message.EntityUid);
|
||||
var entity = message.EntityUid;
|
||||
TryCreatePanel(entity);
|
||||
|
||||
var label = (Label) _aiBoxes[entity].GetChild(0).GetChild(1);
|
||||
@@ -154,7 +151,7 @@ namespace Content.Client.AI
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryCreatePanel(IEntity entity)
|
||||
private bool TryCreatePanel(EntityUid entity)
|
||||
{
|
||||
if (!_aiBoxes.ContainsKey(entity))
|
||||
{
|
||||
|
||||
@@ -18,6 +18,12 @@ namespace Content.Client.AI
|
||||
#if DEBUG
|
||||
public class ClientPathfindingDebugSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IOverlayManager _overlayManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
|
||||
private PathfindingDebugMode _modes = PathfindingDebugMode.None;
|
||||
private float _routeDuration = 4.0f; // How long before we remove a route from the overlay
|
||||
private DebugPathfindingOverlay? _overlay;
|
||||
@@ -91,7 +97,7 @@ namespace Content.Client.AI
|
||||
}
|
||||
|
||||
var overlayManager = IoCManager.Resolve<IOverlayManager>();
|
||||
_overlay = new DebugPathfindingOverlay {Modes = _modes};
|
||||
_overlay = new DebugPathfindingOverlay(EntityManager, _eyeManager, _playerManager, _prototypeManager) {Modes = _modes};
|
||||
overlayManager.AddOverlay(_overlay);
|
||||
|
||||
return _overlay;
|
||||
@@ -179,6 +185,7 @@ namespace Content.Client.AI
|
||||
{
|
||||
private readonly IEyeManager _eyeManager;
|
||||
private readonly IPlayerManager _playerManager;
|
||||
private readonly IEntityManager _entities;
|
||||
|
||||
// TODO: Add a box like the debug one and show the most recent path stuff
|
||||
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
||||
@@ -209,11 +216,12 @@ namespace Content.Client.AI
|
||||
public readonly List<SharedAiDebug.AStarRouteMessage> AStarRoutes = new();
|
||||
public readonly List<SharedAiDebug.JpsRouteMessage> JpsRoutes = new();
|
||||
|
||||
public DebugPathfindingOverlay()
|
||||
public DebugPathfindingOverlay(IEntityManager entities, IEyeManager eyeManager, IPlayerManager playerManager, IPrototypeManager prototypeManager)
|
||||
{
|
||||
_shader = IoCManager.Resolve<IPrototypeManager>().Index<ShaderPrototype>("unshaded").Instance();
|
||||
_eyeManager = IoCManager.Resolve<IEyeManager>();
|
||||
_playerManager = IoCManager.Resolve<IPlayerManager>();
|
||||
_entities = entities;
|
||||
_eyeManager = eyeManager;
|
||||
_playerManager = playerManager;
|
||||
_shader = prototypeManager.Index<ShaderPrototype>("unshaded").Instance();
|
||||
}
|
||||
|
||||
#region Graph
|
||||
@@ -286,8 +294,8 @@ namespace Content.Client.AI
|
||||
|
||||
private void DrawCachedRegions(DrawingHandleScreen screenHandle, Box2 viewport)
|
||||
{
|
||||
var attachedEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (attachedEntity == null || !CachedRegions.TryGetValue(attachedEntity.Transform.GridID, out var entityRegions))
|
||||
var transform = _entities.GetComponentOrNull<TransformComponent>(_playerManager.LocalPlayer?.ControlledEntity);
|
||||
if (transform == null || !CachedRegions.TryGetValue(transform.GridID, out var entityRegions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -305,7 +313,7 @@ namespace Content.Client.AI
|
||||
screenTile.X + 15.0f,
|
||||
screenTile.Y + 15.0f);
|
||||
|
||||
screenHandle.DrawRect(box, _cachedRegionColors[attachedEntity.Transform.GridID][region]);
|
||||
screenHandle.DrawRect(box, _cachedRegionColors[transform.GridID][region]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,7 +344,8 @@ namespace Content.Client.AI
|
||||
private void DrawRegions(DrawingHandleScreen screenHandle, Box2 viewport)
|
||||
{
|
||||
var attachedEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (attachedEntity == null || !Regions.TryGetValue(attachedEntity.Transform.GridID, out var entityRegions))
|
||||
if (!_entities.TryGetComponent(attachedEntity, out TransformComponent? transform) ||
|
||||
!Regions.TryGetValue(transform.GridID, out var entityRegions))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -356,7 +365,7 @@ namespace Content.Client.AI
|
||||
screenTile.X + 15.0f,
|
||||
screenTile.Y + 15.0f);
|
||||
|
||||
screenHandle.DrawRect(box, _regionColors[attachedEntity.Transform.GridID][chunk][region]);
|
||||
screenHandle.DrawRect(box, _regionColors[_entities.GetComponent<TransformComponent>(attachedEntity.Value).GridID][chunk][region]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using static Content.Shared.AME.SharedAMEControllerComponent;
|
||||
|
||||
namespace Content.Client.AME.Visualizers
|
||||
@@ -8,10 +9,10 @@ namespace Content.Client.AME.Visualizers
|
||||
[UsedImplicitly]
|
||||
public class AMEControllerVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
|
||||
sprite.LayerMapSet(Layers.Display, sprite.AddLayerState("control_on"));
|
||||
sprite.LayerSetVisible(Layers.Display, false);
|
||||
@@ -20,7 +21,7 @@ namespace Content.Client.AME.Visualizers
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
if (component.TryGetData<string>(AMEControllerVisuals.DisplayState, out var state))
|
||||
{
|
||||
switch (state)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using static Content.Shared.AME.SharedAMEShieldComponent;
|
||||
|
||||
namespace Content.Client.AME.Visualizers
|
||||
@@ -8,10 +9,10 @@ namespace Content.Client.AME.Visualizers
|
||||
[UsedImplicitly]
|
||||
public class AMEVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
sprite.LayerMapSet(Layers.Core, sprite.AddLayerState("core"));
|
||||
sprite.LayerSetVisible(Layers.Core, false);
|
||||
sprite.LayerMapSet(Layers.CoreState, sprite.AddLayerState("core_weak"));
|
||||
@@ -21,7 +22,7 @@ namespace Content.Client.AME.Visualizers
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
if (component.TryGetData<string>(AMEShieldVisuals.Core, out var core))
|
||||
{
|
||||
if (core == "isCore")
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Content.Client.Access.UI
|
||||
public class IdCardConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public IdCardConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace Content.Client.Access.UI
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_window = new IdCardConsoleWindow(this, _prototypeManager) {Title = Owner.Owner.Name};
|
||||
_window = new IdCardConsoleWindow(this, _prototypeManager) {Title = _entityManager.GetComponent<MetaDataComponent>(Owner.Owner).EntityName};
|
||||
_window.OnClose += Close;
|
||||
_window.OpenCentered();
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Content.Client.Actions
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>(out var actionsComponent)) return false;
|
||||
!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return false;
|
||||
|
||||
actionsComponent.HandleHotbarKeybind(slot, args);
|
||||
return true;
|
||||
@@ -98,8 +98,7 @@ namespace Content.Client.Actions
|
||||
return new((in PointerInputCmdHandler.PointerInputCmdArgs args) =>
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false;
|
||||
if (!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return false;
|
||||
|
||||
actionsComponent.HandleChangeHotbarKeybind(hotbar, args);
|
||||
return true;
|
||||
@@ -110,8 +109,7 @@ namespace Content.Client.Actions
|
||||
private bool TargetingOnUse(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return false;
|
||||
if (!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return false;
|
||||
|
||||
return actionsComponent.TargetingOnUse(args);
|
||||
}
|
||||
@@ -119,8 +117,7 @@ namespace Content.Client.Actions
|
||||
private void ToggleActionsMenu()
|
||||
{
|
||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (playerEntity == null ||
|
||||
!playerEntity.TryGetComponent<ClientActionsComponent>( out var actionsComponent)) return;
|
||||
if (!EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return;
|
||||
|
||||
actionsComponent.ToggleActionsMenu();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Content.Client.Actions.Assignments;
|
||||
using Content.Client.Actions.UI;
|
||||
using Content.Client.Hands;
|
||||
using Content.Client.Inventory;
|
||||
using Content.Client.Items.Managers;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Content.Shared.Actions.Prototypes;
|
||||
@@ -226,17 +224,17 @@ namespace Content.Client.Actions
|
||||
/// Highlights the item slot (inventory or hand) that contains this item
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void HighlightItemSlot(IEntity item)
|
||||
public void HighlightItemSlot(EntityUid item)
|
||||
{
|
||||
StopHighlightingItemSlots();
|
||||
|
||||
_highlightedEntity = item.Uid;
|
||||
_itemSlotManager.HighlightEntity(item.Uid);
|
||||
_highlightedEntity = item;
|
||||
_itemSlotManager.HighlightEntity(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops highlighting any item slots we are currently highlighting.
|
||||
/// </summary>
|
||||
/// </summary>H
|
||||
public void StopHighlightingItemSlots()
|
||||
{
|
||||
if (_highlightedEntity == default)
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Content.Client.Actions.UI
|
||||
/// Item the action is provided by, only valid if Action is an ItemActionPrototype. May be null
|
||||
/// if the item action is not yet tied to an item.
|
||||
/// </summary>
|
||||
public IEntity? Item { get; private set; }
|
||||
public EntityUid? Item { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the action in this slot should be shown as toggled on. Separate from Depressed.
|
||||
@@ -231,8 +231,8 @@ namespace Content.Client.Actions.UI
|
||||
{
|
||||
ActionPrototype actionPrototype => new ActionAttempt(actionPrototype),
|
||||
ItemActionPrototype itemActionPrototype =>
|
||||
(Item != null && Item.TryGetComponent<ItemActionsComponent>(out var itemActions)) ?
|
||||
new ItemActionAttempt(itemActionPrototype, Item, itemActions) : null,
|
||||
(Item != null && IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemActionsComponent?>(Item, out var itemActions)) ?
|
||||
new ItemActionAttempt(itemActionPrototype, Item.Value, itemActions) : null,
|
||||
_ => null
|
||||
};
|
||||
return attempt;
|
||||
@@ -246,7 +246,7 @@ namespace Content.Client.Actions.UI
|
||||
DrawModeChanged();
|
||||
if (Action is not ItemActionPrototype) return;
|
||||
if (Item == null) return;
|
||||
_actionsComponent.HighlightItemSlot(Item);
|
||||
_actionsComponent.HighlightItemSlot(Item.Value);
|
||||
}
|
||||
|
||||
protected override void MouseExited()
|
||||
@@ -376,7 +376,7 @@ namespace Content.Client.Actions.UI
|
||||
if (Action != null && Action == action) return;
|
||||
|
||||
Action = action;
|
||||
Item = null;
|
||||
Item = default;
|
||||
_depressed = false;
|
||||
ToggledOn = false;
|
||||
ActionEnabled = actionEnabled;
|
||||
@@ -395,10 +395,10 @@ namespace Content.Client.Actions.UI
|
||||
public void Assign(ItemActionPrototype action)
|
||||
{
|
||||
// already assigned
|
||||
if (Action != null && Action == action && Item == null) return;
|
||||
if (Action != null && Action == action && Item == default) return;
|
||||
|
||||
Action = action;
|
||||
Item = null;
|
||||
Item = default;
|
||||
_depressed = false;
|
||||
ToggledOn = false;
|
||||
ActionEnabled = false;
|
||||
@@ -415,7 +415,7 @@ namespace Content.Client.Actions.UI
|
||||
/// <param name="action">action to assign</param>
|
||||
/// <param name="item">item the action is provided by</param>
|
||||
/// <param name="actionEnabled">whether action should initially appear enable or disabled</param>
|
||||
public void Assign(ItemActionPrototype action, IEntity item, bool actionEnabled)
|
||||
public void Assign(ItemActionPrototype action, EntityUid item, bool actionEnabled)
|
||||
{
|
||||
// already assigned
|
||||
if (Action != null && Action == action && Item == item) return;
|
||||
@@ -439,7 +439,7 @@ namespace Content.Client.Actions.UI
|
||||
{
|
||||
if (!HasAssignment) return;
|
||||
Action = null;
|
||||
Item = null;
|
||||
Item = default;
|
||||
ToggledOn = false;
|
||||
_depressed = false;
|
||||
Cooldown = null;
|
||||
@@ -502,9 +502,9 @@ namespace Content.Client.Actions.UI
|
||||
SetActionIcon(Action.Icon.Frame0());
|
||||
}
|
||||
|
||||
if (Item != null)
|
||||
if (Item != default)
|
||||
{
|
||||
SetItemIcon(Item.TryGetComponent<ISpriteComponent>(out var spriteComponent) ? spriteComponent : null);
|
||||
SetItemIcon(IoCManager.Resolve<IEntityManager>().TryGetComponent<ISpriteComponent?>(Item, out var spriteComponent) ? spriteComponent : null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -378,10 +378,10 @@ namespace Content.Client.Actions.UI
|
||||
private void UpdateActionSlot(EntityUid item, ItemActionType itemActionType, ActionSlot actionSlot,
|
||||
ActionAssignment? assignedActionType)
|
||||
{
|
||||
if (!_entityManager.TryGetEntity(item, out var itemEntity)) return;
|
||||
if (!_entityManager.EntityExists(item)) return;
|
||||
if (_actionManager.TryGet(itemActionType, out var action))
|
||||
{
|
||||
actionSlot.Assign(action, itemEntity, true);
|
||||
actionSlot.Assign(action, item, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -420,7 +420,7 @@ namespace Content.Client.Actions.UI
|
||||
|
||||
// if we are targeting with an action now on cooldown, stop targeting if we should
|
||||
if (SelectingTargetFor?.Action != null && SelectingTargetFor.Action == action &&
|
||||
SelectingTargetFor.Item == itemEntity &&
|
||||
SelectingTargetFor.Item == item &&
|
||||
actionState.IsOnCooldown(_gameTiming) && action.DeselectOnCooldown)
|
||||
{
|
||||
StopTargeting();
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Administration.Events;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Administration
|
||||
@@ -35,13 +34,14 @@ namespace Content.Client.Administration
|
||||
foreach (var playerInfo in _system.PlayerList)
|
||||
{
|
||||
// Otherwise the entity can not exist yet
|
||||
if (!_entityManager.TryGetEntity(playerInfo.EntityUid, out var entity))
|
||||
var entity = playerInfo.EntityUid;
|
||||
if (!_entityManager.EntityExists(entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// if not on the same map, continue
|
||||
if (entity.Transform.MapID != _eyeManager.CurrentMap)
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID != _eyeManager.CurrentMap)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
@@ -7,8 +9,6 @@ using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Client.Administration.UI.ManageSolutions
|
||||
{
|
||||
@@ -46,8 +46,8 @@ namespace Content.Client.Administration.UI.ManageSolutions
|
||||
{
|
||||
_target = target;
|
||||
|
||||
var targetName = _entityManager.TryGetEntity(target, out var entity)
|
||||
? entity.Name
|
||||
var targetName = _entityManager.EntityExists(target)
|
||||
? IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target).EntityName
|
||||
: string.Empty;
|
||||
|
||||
Title = Loc.GetString("admin-solutions-window-title", ("targetName", targetName));
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -22,7 +23,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.Atmos.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Prototypes;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
@@ -28,7 +27,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_gridData = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.Atmos.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Prototypes;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.AutoGenerated;
|
||||
@@ -28,7 +27,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_gridData = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _gridData)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
@@ -22,7 +23,8 @@ namespace Content.Client.Administration.UI.Tabs.AtmosTab
|
||||
_data = IoCManager.Resolve<IMapManager>().GetAllGrids().Where(g => (int) g.Index != 0);
|
||||
foreach (var grid in _data)
|
||||
{
|
||||
var playerGrid = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity?.Transform.GridID;
|
||||
var player = IoCManager.Resolve<IPlayerManager>().LocalPlayer?.ControlledEntity;
|
||||
var playerGrid = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<TransformComponent>(player)?.GridID;
|
||||
GridOptions.AddItem($"{grid.Index} {(playerGrid == grid.Index ? " (Current)" : "")}");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Animations
|
||||
@@ -16,7 +17,7 @@ namespace Content.Client.Animations
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
var animations = Owner.GetComponent<AnimationPlayerComponent>();
|
||||
var animations = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(Owner);
|
||||
animations.Play(new Animation
|
||||
{
|
||||
Length = TimeSpan.FromSeconds(20),
|
||||
|
||||
@@ -3,6 +3,7 @@ using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -11,22 +12,24 @@ namespace Content.Client.Animations
|
||||
{
|
||||
public static class ReusableAnimations
|
||||
{
|
||||
public static void AnimateEntityPickup(IEntity entity, EntityCoordinates initialPosition, Vector2 finalPosition)
|
||||
public static void AnimateEntityPickup(EntityUid entity, EntityCoordinates initialPosition, Vector2 finalPosition, IEntityManager? entMan = null)
|
||||
{
|
||||
var animatableClone = entity.EntityManager.SpawnEntity("clientsideclone", initialPosition);
|
||||
animatableClone.Name = entity.Name;
|
||||
IoCManager.Resolve(ref entMan);
|
||||
var animatableClone = entMan.SpawnEntity("clientsideclone", initialPosition);
|
||||
string val = entMan.GetComponent<MetaDataComponent>(entity).EntityName;
|
||||
entMan.GetComponent<MetaDataComponent>(animatableClone).EntityName = val;
|
||||
|
||||
if (!entity.TryGetComponent(out SpriteComponent? sprite0))
|
||||
if (!entMan.TryGetComponent(entity, out SpriteComponent? sprite0))
|
||||
{
|
||||
Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entity.Name, nameof(SpriteComponent));
|
||||
Logger.Error("Entity ({0}) couldn't be animated for pickup since it doesn't have a {1}!", entMan.GetComponent<MetaDataComponent>(entity).EntityName, nameof(SpriteComponent));
|
||||
return;
|
||||
}
|
||||
var sprite = animatableClone.GetComponent<SpriteComponent>();
|
||||
var sprite = entMan.GetComponent<SpriteComponent>(animatableClone);
|
||||
sprite.CopyFrom(sprite0);
|
||||
|
||||
var animations = animatableClone.GetComponent<AnimationPlayerComponent>();
|
||||
var animations = entMan.GetComponent<AnimationPlayerComponent>(animatableClone);
|
||||
animations.AnimationCompleted += (_) => {
|
||||
animatableClone.Delete();
|
||||
entMan.DeleteEntity(animatableClone);
|
||||
};
|
||||
|
||||
animations.Play(new Animation
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -12,18 +13,18 @@ namespace Content.Client.Atmos.Visualizers
|
||||
[DataField("layer")]
|
||||
private int Layer { get; }
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
entity.GetComponentOrNull<SpriteComponent>()?.LayerMapReserveBlank(Layer);
|
||||
IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SpriteComponent>(entity);
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -20,7 +21,8 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if(component.TryGetData(DataKey, out bool enabled) && sprite.LayerMapTryGet(LayerMap, out var layer))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -22,11 +22,11 @@ namespace Content.Client.Atmos.Visualizers
|
||||
[DataField("sprite")]
|
||||
private string? _sprite;
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
|
||||
sprite.LayerMapReserveBlank(FireVisualLayers.Fire);
|
||||
sprite.LayerSetVisible(FireVisualLayers.Fire, false);
|
||||
@@ -49,7 +49,7 @@ namespace Content.Client.Atmos.Visualizers
|
||||
|
||||
private void SetOnFire(AppearanceComponent component, bool onFire, float fireStacks)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
if (_sprite != null)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -18,7 +19,8 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -15,11 +16,11 @@ namespace Content.Client.Atmos.Visualizers
|
||||
[DataField("insertedTankState")]
|
||||
private readonly string _insertedTankState = string.Empty;
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
|
||||
sprite.LayerMapSet(Layers.PressureLight, sprite.AddLayerState(_statePressure[0]));
|
||||
sprite.LayerSetShader(Layers.PressureLight, "unshaded");
|
||||
@@ -31,7 +32,8 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -12,11 +13,11 @@ namespace Content.Client.Atmos.Visualizers
|
||||
[DataField("stateConnected")]
|
||||
private string? _stateConnected;
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
|
||||
if (_stateConnected != null)
|
||||
{
|
||||
@@ -29,7 +30,8 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Atmos.Piping;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
@@ -13,7 +14,7 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if (component.TryGetData(PipeColorVisuals.Color, out Color color))
|
||||
|
||||
@@ -37,11 +37,12 @@ namespace Content.Client.Atmos.Visualizers
|
||||
Logger.Error($"{nameof(PipeConnectorVisualizer)} could not load to load RSI {rsiString}.");
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!entity.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent<ISpriteComponent?>(entity, out var sprite))
|
||||
return;
|
||||
|
||||
if (_connectorRsi == null)
|
||||
@@ -52,7 +53,7 @@ namespace Content.Client.Atmos.Visualizers
|
||||
sprite.LayerMapReserveBlank(layerKey);
|
||||
var layer = sprite.LayerMapGet(layerKey);
|
||||
sprite.LayerSetRSI(layer, _connectorRsi);
|
||||
var layerState = _baseState + ((PipeDirection) layerKey).ToString();
|
||||
var layerState = _baseState + ((PipeDirection) layerKey);
|
||||
sprite.LayerSetState(layer, layerState);
|
||||
}
|
||||
}
|
||||
@@ -61,10 +62,11 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent<TransformComponent>(out var xform))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent<TransformComponent>(component.Owner, out var xform))
|
||||
return;
|
||||
|
||||
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
if (!entities.TryGetComponent<ISpriteComponent>(component.Owner, out var sprite))
|
||||
return;
|
||||
|
||||
if (!component.TryGetData(PipeColorVisuals.Color, out Color color))
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Atmos.Piping.Unary.Visuals;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
@@ -18,7 +19,8 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if (!component.TryGetData(ScrubberVisuals.State, out ScrubberState state))
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Atmos.Visuals;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
@@ -17,7 +18,8 @@ namespace Content.Client.Atmos.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if (!component.TryGetData(VentPumpVisuals.State, out VentPumpState state))
|
||||
|
||||
@@ -90,17 +90,17 @@ namespace Content.Client.Audio
|
||||
_accumulator -= _cooldown;
|
||||
|
||||
var player = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (player == null)
|
||||
if (!EntityManager.TryGetComponent(player, out TransformComponent? playerManager))
|
||||
{
|
||||
ClearSounds();
|
||||
return;
|
||||
}
|
||||
|
||||
var coordinates = player.Transform.Coordinates;
|
||||
var coordinates = playerManager.Coordinates;
|
||||
|
||||
foreach (var (comp, (stream, _)) in _playingSounds.ToArray())
|
||||
{
|
||||
if (!comp.Deleted && comp.Enabled && comp.Owner.Transform.Coordinates.TryDistance(EntityManager, coordinates, out var range) &&
|
||||
if (!comp.Deleted && comp.Enabled && EntityManager.GetComponent<TransformComponent>(comp.Owner).Coordinates.TryDistance(EntityManager, coordinates, out var range) &&
|
||||
range <= comp.Range)
|
||||
{
|
||||
continue;
|
||||
@@ -136,11 +136,11 @@ namespace Content.Client.Audio
|
||||
foreach (var entity in _lookup.GetEntitiesInRange(coordinates, _maxAmbientRange,
|
||||
LookupFlags.Approximate | LookupFlags.IncludeAnchored))
|
||||
{
|
||||
if (!entity.TryGetComponent(out AmbientSoundComponent? ambientComp) ||
|
||||
if (!EntityManager.TryGetComponent(entity, out AmbientSoundComponent? ambientComp) ||
|
||||
_playingSounds.ContainsKey(ambientComp) ||
|
||||
!ambientComp.Enabled ||
|
||||
// We'll also do this crude distance check because it's what we're doing in the active loop above.
|
||||
!entity.Transform.Coordinates.TryDistance(EntityManager, coordinates, out var range) ||
|
||||
!EntityManager.GetComponent<TransformComponent>(entity).Coordinates.TryDistance(EntityManager, coordinates, out var range) ||
|
||||
range > ambientComp.Range - RangeBuffer)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Body.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.Body.UI
|
||||
@@ -14,7 +15,7 @@ namespace Content.Client.Body.UI
|
||||
private BodyScannerDisplay? _display;
|
||||
|
||||
[ViewVariables]
|
||||
private IEntity? _entity;
|
||||
private EntityUid _entity;
|
||||
|
||||
public BodyScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { }
|
||||
|
||||
@@ -35,9 +36,11 @@ namespace Content.Client.Body.UI
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Owner.Owner.EntityManager.TryGetEntity(scannerState.Uid, out _entity))
|
||||
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.Uid} at {Owner.Owner.Transform.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);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
@@ -14,11 +13,9 @@ namespace Content.Client.Body.UI
|
||||
{
|
||||
public sealed class BodyScannerDisplay : SS14Window
|
||||
{
|
||||
private IEntity? _currentEntity;
|
||||
private EntityUid _currentEntity;
|
||||
private SharedBodyPartComponent? _currentBodyPart;
|
||||
|
||||
private SharedBodyComponent? CurrentBody => _currentEntity?.GetComponentOrNull<SharedBodyComponent>();
|
||||
|
||||
public BodyScannerDisplay(BodyScannerBoundUserInterface owner)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
@@ -105,12 +102,15 @@ namespace Content.Client.Body.UI
|
||||
|
||||
private RichTextLabel MechanismInfoLabel { get; }
|
||||
|
||||
public void UpdateDisplay(IEntity entity)
|
||||
public void UpdateDisplay(EntityUid entity)
|
||||
{
|
||||
if(entity == null)
|
||||
return;
|
||||
|
||||
_currentEntity = entity;
|
||||
BodyPartList.Clear();
|
||||
|
||||
var body = CurrentBody;
|
||||
var body = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SharedBodyComponent>(_currentEntity);
|
||||
|
||||
if (body == null)
|
||||
{
|
||||
@@ -125,7 +125,10 @@ namespace Content.Client.Body.UI
|
||||
|
||||
public void BodyPartOnItemSelected(ItemListSelectedEventArgs args)
|
||||
{
|
||||
var body = CurrentBody;
|
||||
if (_currentEntity == null)
|
||||
return;
|
||||
|
||||
var body = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SharedBodyComponent>(_currentEntity);
|
||||
|
||||
if (body == null)
|
||||
{
|
||||
@@ -143,10 +146,11 @@ namespace Content.Client.Body.UI
|
||||
|
||||
private void UpdateBodyPartBox(SharedBodyPartComponent part, string slotName)
|
||||
{
|
||||
BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(part.Owner.Name)}";
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
BodyPartLabel.Text = $"{Loc.GetString(slotName)}: {Loc.GetString(entMan.GetComponent<MetaDataComponent>(part.Owner).EntityName)}";
|
||||
|
||||
// TODO BODY Part damage
|
||||
if (part.Owner.TryGetComponent(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));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Botany;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Botany
|
||||
@@ -9,11 +10,11 @@ namespace Content.Client.Botany
|
||||
[UsedImplicitly]
|
||||
public class PlantHolderVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
|
||||
sprite.LayerMapReserveBlank(PlantHolderLayers.Plant);
|
||||
sprite.LayerMapReserveBlank(PlantHolderLayers.HealthLight);
|
||||
@@ -55,7 +56,7 @@ namespace Content.Client.Botany
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
if (component.TryGetData<SpriteSpecifier>(PlantHolderVisuals.Plant, out var specifier))
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
{
|
||||
@@ -13,7 +14,7 @@ namespace Content.Client.Buckle
|
||||
|
||||
public override bool Buckled => _buckled;
|
||||
|
||||
public override bool TryBuckle(IEntity? user, IEntity to)
|
||||
public override bool TryBuckle(EntityUid user, EntityUid to)
|
||||
{
|
||||
// TODO: Prediction
|
||||
return false;
|
||||
@@ -29,8 +30,7 @@ namespace Content.Client.Buckle
|
||||
_buckled = buckle.Buckled;
|
||||
LastEntityBuckledTo = buckle.LastEntityBuckledTo;
|
||||
DontCollide = buckle.DontCollide;
|
||||
|
||||
if (!Owner.TryGetComponent(out SpriteComponent? ownerSprite))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out SpriteComponent? ownerSprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Animations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Buckle
|
||||
@@ -30,9 +31,9 @@ namespace Content.Client.Buckle
|
||||
|
||||
private void SetRotation(AppearanceComponent component, Angle rotation)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent? animation))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(sprite.Owner, out AnimationPlayerComponent? animation))
|
||||
{
|
||||
sprite.Rotation = rotation;
|
||||
return;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Cabinet;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Cabinet
|
||||
@@ -19,7 +20,8 @@ namespace Content.Client.Cabinet
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (component.Owner.TryGetComponent<SpriteComponent>(out var sprite)
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (entities.TryGetComponent(component.Owner, out SpriteComponent sprite)
|
||||
&& component.TryGetData(ItemCabinetVisuals.IsOpen, out bool isOpen)
|
||||
&& component.TryGetData(ItemCabinetVisuals.ContainsItem, out bool contains))
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Content.Client.Camera
|
||||
{
|
||||
if (float.IsNaN(recoil.X) || float.IsNaN(recoil.Y))
|
||||
{
|
||||
Logger.Error($"CameraRecoilComponent on entity {Owner.Uid} passed a NaN recoil value. Ignoring.");
|
||||
Logger.Error($"CameraRecoilComponent on entity {Owner} passed a NaN recoil value. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using static Content.Shared.Cargo.Components.SharedCargoConsoleComponent;
|
||||
using static Robust.Client.UserInterface.Controls.BaseButton;
|
||||
@@ -49,8 +50,9 @@ namespace Content.Client.Cargo
|
||||
{
|
||||
base.Open();
|
||||
|
||||
if (!Owner.Owner.TryGetComponent(out GalacticMarketComponent? market) ||
|
||||
!Owner.Owner.TryGetComponent(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,7 +50,7 @@ namespace Content.Client.CharacterAppearance.Systems
|
||||
{
|
||||
foreach (var (part, _) in body.Parts)
|
||||
{
|
||||
if (part.Owner.TryGetComponent(out SpriteComponent? partSprite))
|
||||
if (EntityManager.TryGetComponent(part.Owner, out SpriteComponent? partSprite))
|
||||
{
|
||||
partSprite!.Color = component.Appearance.SkinColor;
|
||||
}
|
||||
@@ -107,13 +107,12 @@ namespace Content.Client.CharacterAppearance.Systems
|
||||
// Scaffolding until Body is moved to ECS.
|
||||
private void BodyPartAdded(HumanoidAppearanceBodyPartAddedEvent args)
|
||||
{
|
||||
if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return;
|
||||
if (!owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (!EntityManager.TryGetComponent(args.Uid, out SpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Args.Part.Owner.HasComponent<SpriteComponent>())
|
||||
if (!EntityManager.HasComponent<SpriteComponent>(args.Args.Part.Owner))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -131,13 +130,12 @@ namespace Content.Client.CharacterAppearance.Systems
|
||||
|
||||
private void BodyPartRemoved(HumanoidAppearanceBodyPartRemovedEvent args)
|
||||
{
|
||||
if(!EntityManager.TryGetEntity(args.Uid, out var owner)) return;
|
||||
if (!owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (!EntityManager.TryGetComponent(args.Uid, out SpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Args.Part.Owner.HasComponent<SpriteComponent>())
|
||||
if (!EntityManager.HasComponent<SpriteComponent>(args.Args.Part.Owner))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,12 +50,13 @@ namespace Content.Client.CharacterInfo.Components
|
||||
{
|
||||
case CharacterInfoMessage characterInfoMessage:
|
||||
_control.UpdateUI(characterInfoMessage);
|
||||
if (Owner.TryGetComponent(out ISpriteComponent? spriteComponent))
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
if (entityManager.TryGetComponent(Owner, out ISpriteComponent? spriteComponent))
|
||||
{
|
||||
_control.SpriteView.Sprite = spriteComponent;
|
||||
}
|
||||
|
||||
_control.NameLabel.Text = Owner.Name;
|
||||
_control.NameLabel.Text = entityManager.GetComponent<MetaDataComponent>(Owner).EntityName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Content.Client.CharacterInterface
|
||||
base.Initialize();
|
||||
|
||||
//Use all the character ui interfaced components to create the character window
|
||||
_uiComponents = Owner.GetAllComponents<ICharacterUI>().ToList();
|
||||
_uiComponents = IoCManager.Resolve<IEntityManager>().GetComponents<ICharacterUI>(Owner).ToList();
|
||||
if (_uiComponents.Count == 0)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace Content.Client.CharacterInterface
|
||||
|
||||
private void HandleOpenCharacterMenu()
|
||||
{
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity == null
|
||||
|| !_playerManager.LocalPlayer.ControlledEntity.TryGetComponent(out CharacterInterfaceComponent? characterInterface))
|
||||
if (!EntityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out CharacterInterfaceComponent? characterInterface))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,9 @@ namespace Content.Client.Chat.Managers
|
||||
ChatPermissionsUpdated?.Invoke(new ChatPermissionsUpdatedEventArgs {OldSelectableChannels = oldSelectable});
|
||||
}
|
||||
|
||||
public bool IsGhost => _playerManager.LocalPlayer?.ControlledEntity?.HasComponent<GhostComponent>() ?? false;
|
||||
public bool IsGhost => _playerManager.LocalPlayer?.ControlledEntity is {} uid &&
|
||||
uid.IsValid() &&
|
||||
_entityManager.HasComponent<GhostComponent>(uid);
|
||||
|
||||
public void FrameUpdate(FrameEventArgs delta)
|
||||
{
|
||||
@@ -241,11 +243,11 @@ namespace Content.Client.Chat.Managers
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (entityUid, queueData) in _queuedSpeechBubbles.ShallowClone())
|
||||
foreach (var (entity, queueData) in _queuedSpeechBubbles.ShallowClone())
|
||||
{
|
||||
if (!_entityManager.TryGetEntity(entityUid, out var entity))
|
||||
if (!_entityManager.EntityExists(entity))
|
||||
{
|
||||
_queuedSpeechBubbles.Remove(entityUid);
|
||||
_queuedSpeechBubbles.Remove(entity);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -257,7 +259,7 @@ namespace Content.Client.Chat.Managers
|
||||
|
||||
if (queueData.MessageQueue.Count == 0)
|
||||
{
|
||||
_queuedSpeechBubbles.Remove(entityUid);
|
||||
_queuedSpeechBubbles.Remove(entity);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -412,7 +414,7 @@ namespace Content.Client.Chat.Managers
|
||||
|
||||
private void AddSpeechBubble(MsgChatMessage msg, SpeechBubble.SpeechType speechType)
|
||||
{
|
||||
if (!_entityManager.TryGetEntity(msg.SenderEntity, out var entity))
|
||||
if (!_entityManager.EntityExists(msg.SenderEntity))
|
||||
{
|
||||
Logger.WarningS("chat", "Got local chat message with invalid sender entity: {0}", msg.SenderEntity);
|
||||
return;
|
||||
@@ -422,7 +424,7 @@ namespace Content.Client.Chat.Managers
|
||||
|
||||
foreach (var message in messages)
|
||||
{
|
||||
EnqueueSpeechBubble(entity, message, speechType);
|
||||
EnqueueSpeechBubble(msg.SenderEntity, message, speechType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,16 +474,16 @@ namespace Content.Client.Chat.Managers
|
||||
return messages;
|
||||
}
|
||||
|
||||
private void EnqueueSpeechBubble(IEntity 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?
|
||||
if (entity.Transform.MapID != _eyeManager.CurrentMap)
|
||||
if (_entityManager.GetComponent<TransformComponent>(entity).MapID != _eyeManager.CurrentMap)
|
||||
return;
|
||||
|
||||
if (!_queuedSpeechBubbles.TryGetValue(entity.Uid, out var queueData))
|
||||
if (!_queuedSpeechBubbles.TryGetValue(entity, out var queueData))
|
||||
{
|
||||
queueData = new SpeechBubbleQueueData();
|
||||
_queuedSpeechBubbles.Add(entity.Uid, queueData);
|
||||
_queuedSpeechBubbles.Add(entity, queueData);
|
||||
}
|
||||
|
||||
queueData.MessageQueue.Enqueue(new SpeechBubbleData
|
||||
@@ -491,12 +493,12 @@ namespace Content.Client.Chat.Managers
|
||||
});
|
||||
}
|
||||
|
||||
private void CreateSpeechBubble(IEntity entity, SpeechBubbleData speechData)
|
||||
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.Uid, out var existing))
|
||||
if (_activeSpeechBubbles.TryGetValue(entity, out var existing))
|
||||
{
|
||||
// Push up existing bubbles above the mob's head.
|
||||
foreach (var existingBubble in existing)
|
||||
@@ -507,7 +509,7 @@ namespace Content.Client.Chat.Managers
|
||||
else
|
||||
{
|
||||
existing = new List<SpeechBubble>();
|
||||
_activeSpeechBubbles.Add(entity.Uid, existing);
|
||||
_activeSpeechBubbles.Add(entity, existing);
|
||||
}
|
||||
|
||||
existing.Add(bubble);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -35,8 +36,9 @@ namespace Content.Client.Chat.UI
|
||||
private const float EntityVerticalOffset = 0.5f;
|
||||
|
||||
private readonly IEyeManager _eyeManager;
|
||||
private readonly IEntity _senderEntity;
|
||||
private readonly EntityUid _senderEntity;
|
||||
private readonly IChatManager _chatManager;
|
||||
private readonly IEntityManager _entityManager;
|
||||
|
||||
private float _timeLeft = TotalTime;
|
||||
|
||||
@@ -45,26 +47,27 @@ namespace Content.Client.Chat.UI
|
||||
|
||||
public float ContentHeight { get; private set; }
|
||||
|
||||
public static SpeechBubble CreateSpeechBubble(SpeechType type, string text, IEntity 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, IEntity 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;
|
||||
@@ -98,7 +101,7 @@ namespace Content.Client.Chat.UI
|
||||
_verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds);
|
||||
}
|
||||
|
||||
if (!_senderEntity.Transform.Coordinates.IsValid(_senderEntity.EntityManager))
|
||||
if (!_entityManager.GetComponent<TransformComponent>(_senderEntity).Coordinates.IsValid(_entityManager))
|
||||
{
|
||||
Modulate = Color.White.WithAlpha(0);
|
||||
return;
|
||||
@@ -115,14 +118,14 @@ namespace Content.Client.Chat.UI
|
||||
Modulate = Color.White;
|
||||
}
|
||||
|
||||
if (_senderEntity.Deleted || _timeLeft <= 0)
|
||||
if (_entityManager.Deleted(_senderEntity) || _timeLeft <= 0)
|
||||
{
|
||||
// Timer spawn to prevent concurrent modification exception.
|
||||
Timer.Spawn(0, Die);
|
||||
return;
|
||||
}
|
||||
|
||||
var worldPos = _senderEntity.Transform.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;
|
||||
@@ -143,7 +146,7 @@ namespace Content.Client.Chat.UI
|
||||
return;
|
||||
}
|
||||
|
||||
_chatManager.RemoveSpeechBubble(_senderEntity.Uid, this);
|
||||
_chatManager.RemoveSpeechBubble(_senderEntity, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,8 +164,8 @@ namespace Content.Client.Chat.UI
|
||||
public class EmoteSpeechBubble : SpeechBubble
|
||||
|
||||
{
|
||||
public EmoteSpeechBubble(string text, IEntity 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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -187,8 +190,8 @@ namespace Content.Client.Chat.UI
|
||||
|
||||
public class SaySpeechBubble : SpeechBubble
|
||||
{
|
||||
public SaySpeechBubble(string text, IEntity 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -36,11 +37,12 @@ namespace Content.Client.Chemistry.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (component.TryGetData<bool>(FoamVisuals.State, out var state))
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
if (component.Owner.TryGetComponent(out AnimationPlayerComponent? animPlayer))
|
||||
if (entities.TryGetComponent(component.Owner, out AnimationPlayerComponent? animPlayer))
|
||||
{
|
||||
if (!animPlayer.HasRunningAnimation(AnimationKey))
|
||||
animPlayer.Play(_foamDissolve, AnimationKey);
|
||||
@@ -50,7 +52,7 @@ namespace Content.Client.Chemistry.Visualizers
|
||||
|
||||
if (component.TryGetData<Color>(FoamVisuals.Color, out var color))
|
||||
{
|
||||
if (component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
if (entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
sprite.Color = color;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Chemistry.Visualizers
|
||||
@@ -13,9 +14,10 @@ namespace Content.Client.Chemistry.Visualizers
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (component.TryGetData<Color>(SmokeVisuals.Color, out var color))
|
||||
{
|
||||
if (component.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
if (entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
sprite.Color = color;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Chemistry;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -25,7 +26,8 @@ namespace Content.Client.Chemistry.Visualizers
|
||||
if (!component.TryGetData(SolutionContainerVisuals.VisualState,
|
||||
out SolutionContainerVisualState state)) return;
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite)) return;
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite)) return;
|
||||
if (!sprite.LayerMapTryGet(_layer, out var fillLayer)) return;
|
||||
|
||||
var fillPercent = state.FilledVolumePercent;
|
||||
|
||||
@@ -4,6 +4,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -53,7 +54,7 @@ namespace Content.Client.Chemistry.Visualizers
|
||||
{
|
||||
if (!state) return;
|
||||
|
||||
var animPlayer = component.Owner.GetComponent<AnimationPlayerComponent>();
|
||||
var animPlayer = IoCManager.Resolve<IEntityManager>().GetComponent<AnimationPlayerComponent>(component.Owner);
|
||||
|
||||
if(!animPlayer.HasRunningAnimation(AnimationKey))
|
||||
animPlayer.Play(VaporFlick, AnimationKey);
|
||||
@@ -61,7 +62,7 @@ namespace Content.Client.Chemistry.Visualizers
|
||||
|
||||
private void SetColor(AppearanceComponent component, Color color)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
sprite.Color = color;
|
||||
}
|
||||
|
||||
@@ -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 (!Owner.TryGetComponent(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 = Owner.Transform;
|
||||
var transform = entMan.GetComponent<TransformComponent>(Owner);
|
||||
var localPos = transform.InvWorldMatrix.Transform(worldPos);
|
||||
var spriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix());
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Content.Client.Clothing
|
||||
|
||||
if (!Owner.TryGetContainer(out IContainer? container))
|
||||
return;
|
||||
if (!container.Owner.TryGetComponent(out ClientInventoryComponent? inventory))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(container.Owner, out ClientInventoryComponent? inventory))
|
||||
return;
|
||||
if (!inventory.TryFindItemSlots(Owner, out EquipmentSlotDefines.Slots? slots))
|
||||
return;
|
||||
|
||||
@@ -33,13 +33,8 @@ namespace Content.Client.CombatMode
|
||||
|
||||
public bool IsInCombatMode()
|
||||
{
|
||||
var entity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (entity == null || !entity.TryGetComponent(out CombatModeComponent? combatMode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return combatMode.IsInCombatMode;
|
||||
return EntityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out CombatModeComponent? combatMode) &&
|
||||
combatMode.IsInCombatMode;
|
||||
}
|
||||
|
||||
private void OnTargetingZoneChanged(TargetingZone obj)
|
||||
@@ -47,4 +42,8 @@ namespace Content.Client.CombatMode
|
||||
EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetTargetZoneMessage(obj));
|
||||
}
|
||||
}
|
||||
|
||||
public static class A
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 (component.Owner.TryGetComponent(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 (!mechanism.Owner.TryGetComponent(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 (mechanism.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (entityManager.TryGetComponent(mechanism.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
sprite.ContainerOccluded = false;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Computer;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Computer
|
||||
@@ -19,11 +20,11 @@ namespace Content.Client.Computer
|
||||
private string BodyBrokenState = "broken";
|
||||
private string ScreenBroken = "computer_broken";
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
||||
sprite.LayerSetState(Layers.Screen, ScreenState);
|
||||
|
||||
if (!string.IsNullOrEmpty(KeyboardState))
|
||||
@@ -37,7 +38,7 @@ namespace Content.Client.Computer
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
if (!component.TryGetData(ComputerVisuals.Powered, out bool powered))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Client.Graphics;
|
||||
using Robust.Client.Placement;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.Construction
|
||||
@@ -35,9 +36,9 @@ namespace Content.Client.Construction
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool HijackDeletion(IEntity entity)
|
||||
public override bool HijackDeletion(EntityUid entity)
|
||||
{
|
||||
if (entity.TryGetComponent(out ConstructionGhostComponent? ghost))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ConstructionGhostComponent? ghost))
|
||||
{
|
||||
_constructionSystem.ClearGhost(ghost.GhostId);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
|
||||
namespace Content.Client.Construction
|
||||
{
|
||||
/// <summary>
|
||||
@@ -111,7 +110,7 @@ namespace Content.Client.Construction
|
||||
|
||||
private void HandlePlayerAttached(PlayerAttachSysMessage msg)
|
||||
{
|
||||
var available = IsCrafingAvailable(msg.AttachedEntity);
|
||||
var available = IsCraftingAvailable(msg.AttachedEntity);
|
||||
UpdateCraftingAvailability(available);
|
||||
}
|
||||
|
||||
@@ -131,9 +130,9 @@ namespace Content.Client.Construction
|
||||
CraftingEnabled = available;
|
||||
}
|
||||
|
||||
private static bool IsCrafingAvailable(IEntity? entity)
|
||||
private static bool IsCraftingAvailable(EntityUid? entity)
|
||||
{
|
||||
if (entity == null)
|
||||
if (entity == default)
|
||||
return false;
|
||||
|
||||
// TODO: Decide if entity can craft, using capabilities or something
|
||||
@@ -145,9 +144,7 @@ namespace Content.Client.Construction
|
||||
if (!args.EntityUid.IsValid() || !args.EntityUid.IsClientSide())
|
||||
return false;
|
||||
|
||||
var entity = EntityManager.GetEntity(args.EntityUid);
|
||||
|
||||
if (!entity.TryGetComponent<ConstructionGhostComponent>(out var ghostComp))
|
||||
if (!EntityManager.TryGetComponent<ConstructionGhostComponent?>(args.EntityUid, out var ghostComp))
|
||||
return false;
|
||||
|
||||
TryStartConstruction(ghostComp.GhostId);
|
||||
@@ -159,10 +156,14 @@ namespace Content.Client.Construction
|
||||
/// </summary>
|
||||
public void SpawnGhost(ConstructionPrototype prototype, EntityCoordinates loc, Direction dir)
|
||||
{
|
||||
var user = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user ||
|
||||
!user.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// This InRangeUnobstructed should probably be replaced with "is there something blocking us in that tile?"
|
||||
if (user == null || GhostPresent(loc) || !user.InRangeUnobstructed(loc, 20f, ignoreInsideBlocker: prototype.CanBuildInImpassable)) return;
|
||||
if (GhostPresent(loc) || !user.InRangeUnobstructed(loc, 20f, ignoreInsideBlocker: prototype.CanBuildInImpassable)) return;
|
||||
|
||||
foreach (var condition in prototype.Conditions)
|
||||
{
|
||||
@@ -171,12 +172,12 @@ namespace Content.Client.Construction
|
||||
}
|
||||
|
||||
var ghost = EntityManager.SpawnEntity("constructionghost", loc);
|
||||
var comp = ghost.GetComponent<ConstructionGhostComponent>();
|
||||
var comp = EntityManager.GetComponent<ConstructionGhostComponent>(ghost);
|
||||
comp.Prototype = prototype;
|
||||
comp.GhostId = _nextId++;
|
||||
ghost.Transform.LocalRotation = dir.ToAngle();
|
||||
EntityManager.GetComponent<TransformComponent>(ghost).LocalRotation = dir.ToAngle();
|
||||
_ghosts.Add(comp.GhostId, comp);
|
||||
var sprite = ghost.GetComponent<SpriteComponent>();
|
||||
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);
|
||||
@@ -191,7 +192,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
foreach (var ghost in _ghosts)
|
||||
{
|
||||
if (ghost.Value.Owner.Transform.Coordinates.Equals(loc)) return true;
|
||||
if (EntityManager.GetComponent<TransformComponent>(ghost.Value.Owner).Coordinates.Equals(loc)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -206,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 = ghost.Owner.Transform;
|
||||
var transform = EntityManager.GetComponent<TransformComponent>(ghost.Owner);
|
||||
var msg = new TryStartStructureConstructionMessage(transform.Coordinates, ghost.Prototype.ID, transform.LocalRotation, ghostId);
|
||||
RaiseNetworkEvent(msg);
|
||||
}
|
||||
@@ -226,7 +227,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
if (_ghosts.TryGetValue(ghostId, out var ghost))
|
||||
{
|
||||
ghost.Owner.QueueDelete();
|
||||
EntityManager.QueueDeleteEntity(ghost.Owner);
|
||||
_ghosts.Remove(ghostId);
|
||||
}
|
||||
}
|
||||
@@ -238,7 +239,7 @@ namespace Content.Client.Construction
|
||||
{
|
||||
foreach (var (_, ghost) in _ghosts)
|
||||
{
|
||||
ghost.Owner.QueueDelete();
|
||||
EntityManager.QueueDeleteEntity(ghost.Owner);
|
||||
}
|
||||
|
||||
_ghosts.Clear();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Construction
|
||||
{
|
||||
@@ -14,7 +15,7 @@ namespace Content.Client.Construction
|
||||
|
||||
if (component.TryGetData<int>(MachineFrameVisuals.State, out var data))
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
sprite.LayerSetState(0, $"box_{data}");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Client.Stylesheets;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.ContextMenu.UI
|
||||
@@ -10,10 +10,12 @@ 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>
|
||||
public IEntity? Entity;
|
||||
public EntityUid Entity;
|
||||
|
||||
/// <summary>
|
||||
/// How many entities are accessible through this element's sub-menus.
|
||||
@@ -23,11 +25,13 @@ namespace Content.Client.ContextMenu.UI
|
||||
/// </remarks>
|
||||
public int Count;
|
||||
|
||||
public Label CountLabel;
|
||||
public SpriteView EntityIcon = new SpriteView { OverrideDirection = Direction.South};
|
||||
public readonly Label CountLabel;
|
||||
public readonly SpriteView EntityIcon = new() { OverrideDirection = Direction.South};
|
||||
|
||||
public EntityMenuElement(IEntity? entity = null) : base()
|
||||
public EntityMenuElement(EntityUid entity = default)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
CountLabel = new Label { StyleClasses = { StyleClassEntityMenuCountText } };
|
||||
Icon.AddChild(new LayoutContainer() { Children = { EntityIcon, CountLabel } });
|
||||
|
||||
@@ -36,7 +40,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
LayoutContainer.SetGrowVertical(CountLabel, LayoutContainer.GrowDirection.Begin);
|
||||
|
||||
Entity = entity;
|
||||
if (Entity != null)
|
||||
if (Entity != default)
|
||||
{
|
||||
Count = 1;
|
||||
CountLabel.Visible = false;
|
||||
@@ -47,7 +51,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
Entity = null;
|
||||
Entity = default;
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
@@ -55,17 +59,23 @@ namespace Content.Client.ContextMenu.UI
|
||||
/// Update the icon and text of this element based on the given entity or this element's own entity if none
|
||||
/// is provided.
|
||||
/// </summary>
|
||||
public void UpdateEntity(IEntity? entity = null)
|
||||
public void UpdateEntity(EntityUid entity = default)
|
||||
{
|
||||
if (Entity != null && !Entity.Deleted)
|
||||
entity ??= Entity;
|
||||
if (Entity != default && _entityManager.EntityExists(Entity) && !entity.Valid)
|
||||
entity = Entity;
|
||||
|
||||
EntityIcon.Sprite = entity?.GetComponentOrNull<ISpriteComponent>();
|
||||
if (entity == default)
|
||||
{
|
||||
Text = string.Empty;
|
||||
return;
|
||||
}
|
||||
|
||||
EntityIcon.Sprite = _entityManager.GetComponentOrNull<ISpriteComponent>(entity);
|
||||
|
||||
if (UserInterfaceManager.DebugMonitors.Visible)
|
||||
Text = $"{entity?.Name} ({entity?.Uid})";
|
||||
Text = $"{_entityManager.GetComponent<MetaDataComponent>(entity!).EntityName} ({entity})";
|
||||
else
|
||||
Text = entity?.Name ?? string.Empty;
|
||||
Text = _entityManager.GetComponent<MetaDataComponent>(entity!).EntityName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.ContextMenu.UI
|
||||
{
|
||||
/// <summary>
|
||||
@@ -50,7 +51,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
/// <remarks>
|
||||
/// This is used remove GUI elements when the entities are deleted. or leave the LOS.
|
||||
/// </remarks>
|
||||
public Dictionary<IEntity, EntityMenuElement> Elements = new();
|
||||
public Dictionary<EntityUid, EntityMenuElement> Elements = new();
|
||||
|
||||
public EntityMenuPresenter(VerbSystem verbSystem) : base()
|
||||
{
|
||||
@@ -76,7 +77,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
/// <summary>
|
||||
/// Given a list of entities, sort them into groups and them to a new entity menu.
|
||||
/// </summary>
|
||||
public void OpenRootMenu(List<IEntity> entities)
|
||||
public void OpenRootMenu(List<EntityUid> entities)
|
||||
{
|
||||
// close any old menus first.
|
||||
if (RootMenu.Visible)
|
||||
@@ -84,7 +85,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
|
||||
var entitySpriteStates = GroupEntities(entities);
|
||||
var orderedStates = entitySpriteStates.ToList();
|
||||
orderedStates.Sort((x, y) => string.CompareOrdinal(x.First().Prototype?.Name, y.First().Prototype?.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);
|
||||
|
||||
@@ -100,8 +101,12 @@ namespace Content.Client.ContextMenu.UI
|
||||
|
||||
// get an entity associated with this element
|
||||
var entity = entityElement.Entity;
|
||||
entity ??= GetFirstEntityOrNull(element.SubMenu);
|
||||
if (entity == null)
|
||||
if (!entity.Valid)
|
||||
{
|
||||
entity = GetFirstEntityOrNull(element.SubMenu);
|
||||
}
|
||||
|
||||
if (!entity.Valid)
|
||||
return;
|
||||
|
||||
// open verb menu?
|
||||
@@ -134,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, entity.Transform.Coordinates, args.PointerLocation, entity.Uid);
|
||||
BoundKeyState.Down, _entityManager.GetComponent<TransformComponent>(entity).Coordinates, args.PointerLocation, entity);
|
||||
|
||||
var session = _playerManager.LocalPlayer?.Session;
|
||||
if (session != null)
|
||||
@@ -172,9 +177,8 @@ namespace Content.Client.ContextMenu.UI
|
||||
if (!RootMenu.Visible)
|
||||
return;
|
||||
|
||||
var player = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (player == null)
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not { } player ||
|
||||
!player.IsValid())
|
||||
return;
|
||||
|
||||
// Do we need to do in-range unOccluded checks?
|
||||
@@ -183,16 +187,16 @@ namespace Content.Client.ContextMenu.UI
|
||||
|
||||
foreach (var entity in Elements.Keys.ToList())
|
||||
{
|
||||
if (entity.Deleted || !ignoreFov && !_examineSystem.CanExamine(player, entity))
|
||||
if (_entityManager.Deleted(entity) || !ignoreFov && !_examineSystem.CanExamine(player, entity))
|
||||
RemoveEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add menu elements for a list of grouped entities;
|
||||
/// Add menu elements for a list of grouped entities;
|
||||
/// </summary>
|
||||
/// <param name="entityGroups"> A list of entity groups. Entities are grouped together based on prototype.</param>
|
||||
private void AddToUI(List<List<IEntity>> entityGroups)
|
||||
private void AddToUI(List<List<EntityUid>> entityGroups)
|
||||
{
|
||||
// If there is only a single group. We will just directly list individual entities
|
||||
if (entityGroups.Count == 1)
|
||||
@@ -219,13 +223,13 @@ namespace Content.Client.ContextMenu.UI
|
||||
AddElement(RootMenu, element);
|
||||
Elements.TryAdd(group[0], element);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given a group of entities, add a menu element that has a pop-up sub-menu listing group members
|
||||
/// </summary>
|
||||
private void AddGroupToUI(List<IEntity> group)
|
||||
private void AddGroupToUI(List<EntityUid> group)
|
||||
{
|
||||
EntityMenuElement element = new();
|
||||
ContextMenuPopup subMenu = new(this, element);
|
||||
@@ -244,12 +248,12 @@ namespace Content.Client.ContextMenu.UI
|
||||
/// <summary>
|
||||
/// Remove an entity from the entity context menu.
|
||||
/// </summary>
|
||||
private void RemoveEntity(IEntity entity)
|
||||
private void RemoveEntity(EntityUid entity)
|
||||
{
|
||||
// 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: {entity.Name} ({entity.Uid})");
|
||||
Logger.Error($"Attempted to remove unknown entity from the entity menu: {_entityManager.GetComponent<MetaDataComponent>(entity).EntityName} ({entity})");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -263,7 +267,7 @@ namespace Content.Client.ContextMenu.UI
|
||||
UpdateElement(e);
|
||||
|
||||
// if the verb menu is open and targeting this entity, close it.
|
||||
if (_verbSystem.VerbMenu.CurrentTarget == entity.Uid)
|
||||
if (_verbSystem.VerbMenu.CurrentTarget == entity)
|
||||
_verbSystem.VerbMenu.Close();
|
||||
|
||||
// If this was the last entity, close the entity menu
|
||||
@@ -322,30 +326,30 @@ namespace Content.Client.ContextMenu.UI
|
||||
/// <summary>
|
||||
/// Recursively look through a sub-menu and return the first entity.
|
||||
/// </summary>
|
||||
private IEntity? GetFirstEntityOrNull(ContextMenuPopup? menu)
|
||||
private EntityUid GetFirstEntityOrNull(ContextMenuPopup? menu)
|
||||
{
|
||||
if (menu == null)
|
||||
return null;
|
||||
return default;
|
||||
|
||||
foreach (var element in menu.MenuBody.Children)
|
||||
{
|
||||
if (element is not EntityMenuElement entityElement)
|
||||
continue;
|
||||
|
||||
if (entityElement.Entity != null)
|
||||
if (entityElement.Entity != default)
|
||||
{
|
||||
if (!entityElement.Entity.Deleted)
|
||||
if (!_entityManager.Deleted(entityElement.Entity))
|
||||
return entityElement.Entity;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the element has no entity, its a group of entities with another attached sub-menu.
|
||||
var entity = GetFirstEntityOrNull(entityElement.SubMenu);
|
||||
if (entity != null)
|
||||
if (entity != default)
|
||||
return entity;
|
||||
}
|
||||
|
||||
return null;
|
||||
return default;
|
||||
}
|
||||
|
||||
public override void OpenSubMenu(ContextMenuElement element)
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.ContextMenu.UI
|
||||
{
|
||||
@@ -16,29 +17,29 @@ namespace Content.Client.ContextMenu.UI
|
||||
GroupingContextMenuType = obj;
|
||||
}
|
||||
|
||||
private List<List<IEntity>> GroupEntities(IEnumerable<IEntity> entities, int depth = 0)
|
||||
private List<List<EntityUid>> GroupEntities(IEnumerable<EntityUid> entities, int depth = 0)
|
||||
{
|
||||
if (GroupingContextMenuType == 0)
|
||||
{
|
||||
var newEntities = entities.GroupBy(e => e.Name + (e.Prototype?.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<IEntity>
|
||||
private sealed class PrototypeAndStatesContextMenuComparer : IEqualityComparer<EntityUid>
|
||||
{
|
||||
private static readonly List<Func<IEntity, IEntity, bool>> EqualsList = new()
|
||||
private static readonly List<Func<EntityUid, EntityUid, IEntityManager, bool>> EqualsList = new()
|
||||
{
|
||||
(a, b) => a.Prototype!.ID == b.Prototype!.ID,
|
||||
(a, b) =>
|
||||
(a, b, entMan) => entMan.GetComponent<MetaDataComponent>(a).EntityPrototype!.ID == entMan.GetComponent<MetaDataComponent>(b).EntityPrototype!.ID,
|
||||
(a, b, entMan) =>
|
||||
{
|
||||
a.TryGetComponent<ISpriteComponent>(out var spriteA);
|
||||
b.TryGetComponent<ISpriteComponent>(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;
|
||||
@@ -49,13 +50,13 @@ namespace Content.Client.ContextMenu.UI
|
||||
return xStates.OrderBy(t => t).SequenceEqual(yStates.OrderBy(t => t));
|
||||
},
|
||||
};
|
||||
private static readonly List<Func<IEntity, int>> GetHashCodeList = new()
|
||||
private static readonly List<Func<EntityUid, IEntityManager, int>> GetHashCodeList = new()
|
||||
{
|
||||
e => EqualityComparer<string>.Default.GetHashCode(e.Prototype!.ID),
|
||||
e =>
|
||||
(e, entMan) => EqualityComparer<string>.Default.GetHashCode(entMan.GetComponent<MetaDataComponent>(e).EntityPrototype!.ID),
|
||||
(e, entMan) =>
|
||||
{
|
||||
var hash = 0;
|
||||
foreach (var element in e.GetComponent<ISpriteComponent>().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!);
|
||||
}
|
||||
@@ -66,24 +67,28 @@ 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(IEntity? x, IEntity? y)
|
||||
public bool Equals(EntityUid x, EntityUid y)
|
||||
{
|
||||
if (x == null)
|
||||
if (x == default)
|
||||
{
|
||||
return y == null;
|
||||
return y == default;
|
||||
}
|
||||
|
||||
return y != null && EqualsList[_depth](x, y);
|
||||
return y != default && EqualsList[_depth](x, y, _entMan);
|
||||
}
|
||||
|
||||
public int GetHashCode(IEntity e)
|
||||
public int GetHashCode(EntityUid e)
|
||||
{
|
||||
return GetHashCodeList[_depth](e);
|
||||
return GetHashCodeList[_depth](e, _entMan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System;
|
||||
using Content.Shared.Conveyor;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Conveyor.Visualizers
|
||||
@@ -21,7 +22,8 @@ namespace Content.Client.Conveyor.Visualizers
|
||||
|
||||
private void ChangeState(AppearanceComponent appearance)
|
||||
{
|
||||
if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(appearance.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -40,11 +42,11 @@ namespace Content.Client.Conveyor.Visualizers
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var appearance = entity.EnsureComponent<ClientAppearanceComponent>();
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
var appearance = entities.EnsureComponent<ClientAppearanceComponent>(entity);
|
||||
ChangeState(appearance);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.MachineLinking;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Conveyor.Visualizers
|
||||
@@ -20,7 +21,8 @@ namespace Content.Client.Conveyor.Visualizers
|
||||
|
||||
private void ChangeState(AppearanceComponent appearance)
|
||||
{
|
||||
if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(appearance.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -38,11 +40,12 @@ namespace Content.Client.Conveyor.Visualizers
|
||||
sprite.LayerSetState(0, texture);
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var appearance = entity.EnsureComponent<ClientAppearanceComponent>();
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
var appearance = entities.EnsureComponent<ClientAppearanceComponent>(entity);
|
||||
ChangeState(appearance);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Cuffs.Components
|
||||
{
|
||||
@@ -21,7 +22,7 @@ namespace Content.Client.Cuffs.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent<SpriteComponent>(out var sprite))
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(Owner, out var sprite))
|
||||
{
|
||||
sprite.LayerSetState(0, new RSI.StateId(state.IconState)); // TODO: safety check to see if RSI contains the state?
|
||||
}
|
||||
|
||||
@@ -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,7 +195,7 @@ namespace Content.Client.Damage
|
||||
public readonly string? Color;
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace Content.Client.Damage
|
||||
InitializeVisualizer(entity, damageData);
|
||||
}
|
||||
|
||||
private void VerifyVisualizerSetup(IEntity entity, DamageVisualizerDataComponent damageData)
|
||||
private void VerifyVisualizerSetup(EntityUid entity, DamageVisualizerDataComponent damageData)
|
||||
{
|
||||
if (_thresholds.Count < 1)
|
||||
{
|
||||
@@ -289,11 +289,11 @@ namespace Content.Client.Damage
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeVisualizer(IEntity entity, DamageVisualizerDataComponent damageData)
|
||||
private void InitializeVisualizer(EntityUid entity, DamageVisualizerDataComponent damageData)
|
||||
{
|
||||
if (!entity.TryGetComponent<SpriteComponent>(out SpriteComponent? spriteComponent)
|
||||
|| !entity.TryGetComponent<DamageableComponent>(out var damageComponent)
|
||||
|| !entity.HasComponent<AppearanceComponent>())
|
||||
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 +504,8 @@ namespace Content.Client.Damage
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
if (!component.Owner.TryGetComponent<DamageVisualizerDataComponent>(out var damageData))
|
||||
var entities = _entityManager;
|
||||
if (!entities.TryGetComponent(component.Owner, out DamageVisualizerDataComponent damageData))
|
||||
return;
|
||||
|
||||
if (!damageData.Valid)
|
||||
@@ -525,8 +526,9 @@ namespace Content.Client.Damage
|
||||
|
||||
private void HandleDamage(AppearanceComponent component, DamageVisualizerDataComponent damageData)
|
||||
{
|
||||
if (!component.Owner.TryGetComponent<SpriteComponent>(out var spriteComponent)
|
||||
|| !component.Owner.TryGetComponent<DamageableComponent>(out var damageComponent))
|
||||
var entities = _entityManager;
|
||||
if (!entities.TryGetComponent(component.Owner, out SpriteComponent spriteComponent)
|
||||
|| !entities.TryGetComponent(component.Owner, out DamageableComponent damageComponent))
|
||||
return;
|
||||
|
||||
if (_targetLayers != null && _damageOverlayGroups != null)
|
||||
|
||||
@@ -3,6 +3,8 @@ using Content.Client.Disposal.Components;
|
||||
using Content.Client.Disposal.UI;
|
||||
using Content.Shared.Disposal;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Disposal.Systems
|
||||
{
|
||||
@@ -38,7 +40,7 @@ namespace Content.Client.Disposal.Systems
|
||||
{
|
||||
if (component.Deleted) return true;
|
||||
|
||||
if (!component.Owner.TryGetComponent(out ClientUserInterfaceComponent? userInterface)) return true;
|
||||
if (!EntityManager.TryGetComponent(component.Owner, out ClientUserInterfaceComponent? userInterface)) return true;
|
||||
|
||||
var state = component.UiState;
|
||||
if (state == null) return true;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Client.Disposal.Systems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using static Content.Shared.Disposal.Components.SharedDisposalUnitComponent;
|
||||
|
||||
namespace Content.Client.Disposal.UI
|
||||
@@ -52,7 +53,7 @@ namespace Content.Client.Disposal.UI
|
||||
Window?.UpdateState(cast);
|
||||
|
||||
// Kinda icky but we just want client to handle its own lerping and not flood bandwidth for it.
|
||||
if (!Owner.Owner.TryGetComponent(out DisposalUnitComponent? component)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Owner, out DisposalUnitComponent? component)) return;
|
||||
|
||||
component.UiState = cast;
|
||||
EntitySystem.Get<DisposalUnitSystem>().UpdateActive(component, true);
|
||||
|
||||
@@ -4,6 +4,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using static Content.Shared.Disposal.Components.SharedDisposalUnitComponent;
|
||||
@@ -69,7 +70,8 @@ namespace Content.Client.Disposal.Visualizers
|
||||
return;
|
||||
}
|
||||
|
||||
if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(appearance.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +90,7 @@ namespace Content.Client.Disposal.Visualizers
|
||||
case VisualState.Flushing:
|
||||
sprite.LayerSetState(DisposalUnitVisualLayers.Base, _stateAnchored);
|
||||
|
||||
var animPlayer = appearance.Owner.GetComponent<AnimationPlayerComponent>();
|
||||
var animPlayer = entities.GetComponent<AnimationPlayerComponent>(appearance.Owner);
|
||||
|
||||
if (!animPlayer.HasRunningAnimation(AnimationKey))
|
||||
{
|
||||
@@ -143,12 +145,12 @@ namespace Content.Client.Disposal.Visualizers
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
entity.EnsureComponent<AnimationPlayerComponent>();
|
||||
var appearance = entity.EnsureComponent<ClientAppearanceComponent>();
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
entities.EnsureComponent<AnimationPlayerComponent>(entity);
|
||||
var appearance = entities.EnsureComponent<ClientAppearanceComponent>(entity);
|
||||
|
||||
ChangeState(appearance);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.SubFloor;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Disposal.Visualizers
|
||||
@@ -22,7 +23,8 @@ namespace Content.Client.Disposal.Visualizers
|
||||
|
||||
private void ChangeState(AppearanceComponent appearance)
|
||||
{
|
||||
if (!appearance.Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(appearance.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -46,17 +48,17 @@ namespace Content.Client.Disposal.Visualizers
|
||||
{
|
||||
appearance.Owner.EnsureComponent<SubFloorHideComponent>();
|
||||
}
|
||||
else if (appearance.Owner.HasComponent<SubFloorHideComponent>())
|
||||
else if (entities.HasComponent<SubFloorHideComponent>(appearance.Owner))
|
||||
{
|
||||
appearance.Owner.RemoveComponent<SubFloorHideComponent>();
|
||||
entities.RemoveComponent<SubFloorHideComponent>(appearance.Owner);
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var appearance = entity.EnsureComponent<ClientAppearanceComponent>();
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var appearance = entityManager.EnsureComponent<ClientAppearanceComponent>(entity);
|
||||
ChangeState(appearance);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Content.Client.DoAfter
|
||||
/// </summary>
|
||||
public const float ExcessTime = 0.5f;
|
||||
|
||||
private IEntity? _attachedEntity;
|
||||
private EntityUid? _attachedEntity;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace Content.Client.DoAfter
|
||||
var currentTime = _gameTiming.CurTime;
|
||||
|
||||
// Can't see any I guess?
|
||||
if (_attachedEntity == null || _attachedEntity.Deleted)
|
||||
if (_attachedEntity is not {Valid: true} entity || Deleted(entity))
|
||||
return;
|
||||
|
||||
var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f);
|
||||
@@ -59,23 +59,23 @@ namespace Content.Client.DoAfter
|
||||
foreach (var comp in EntityManager.EntityQuery<DoAfterComponent>(true))
|
||||
{
|
||||
var doAfters = comp.DoAfters.ToList();
|
||||
var compPos = comp.Owner.Transform.WorldPosition;
|
||||
var compPos = EntityManager.GetComponent<TransformComponent>(comp.Owner).WorldPosition;
|
||||
|
||||
if (doAfters.Count == 0 ||
|
||||
comp.Owner.Transform.MapID != _attachedEntity.Transform.MapID ||
|
||||
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapID != EntityManager.GetComponent<TransformComponent>(entity).MapID ||
|
||||
!viewbox.Contains(compPos))
|
||||
{
|
||||
comp.Disable();
|
||||
continue;
|
||||
}
|
||||
|
||||
var range = (compPos - _attachedEntity.Transform.WorldPosition).Length +
|
||||
var range = (compPos - EntityManager.GetComponent<TransformComponent>(entity).WorldPosition).Length +
|
||||
0.01f;
|
||||
|
||||
if (comp.Owner != _attachedEntity &&
|
||||
!ExamineSystemShared.InRangeUnOccluded(
|
||||
_attachedEntity.Transform.MapPosition,
|
||||
comp.Owner.Transform.MapPosition, range,
|
||||
EntityManager.GetComponent<TransformComponent>(entity).MapPosition,
|
||||
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapPosition, range,
|
||||
entity => entity == comp.Owner || entity == _attachedEntity))
|
||||
{
|
||||
comp.Disable();
|
||||
@@ -84,7 +84,7 @@ namespace Content.Client.DoAfter
|
||||
|
||||
comp.Enable();
|
||||
|
||||
var userGrid = comp.Owner.Transform.Coordinates;
|
||||
var userGrid = EntityManager.GetComponent<TransformComponent>(comp.Owner).Coordinates;
|
||||
|
||||
// Check cancellations / finishes
|
||||
foreach (var (id, doAfter) in doAfters)
|
||||
@@ -116,8 +116,8 @@ namespace Content.Client.DoAfter
|
||||
|
||||
if (doAfter.BreakOnTargetMove)
|
||||
{
|
||||
if (EntityManager.TryGetEntity(doAfter.TargetUid, out var targetEntity) &&
|
||||
!targetEntity.Transform.Coordinates.InRange(EntityManager, doAfter.TargetGrid,
|
||||
if (EntityManager.EntityExists(doAfter.TargetUid) &&
|
||||
!EntityManager.GetComponent<TransformComponent>(doAfter.TargetUid).Coordinates.InRange(EntityManager, doAfter.TargetGrid,
|
||||
doAfter.MovementThreshold))
|
||||
{
|
||||
comp.Cancel(id, currentTime);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.DoAfter.UI
|
||||
// We'll store cancellations for a little bit just so we can flash the graphic to indicate it's cancelled
|
||||
private readonly Dictionary<byte, TimeSpan> _cancelledDoAfters = new();
|
||||
|
||||
public IEntity? AttachedEntity { get; set; }
|
||||
public EntityUid AttachedEntity { get; set; }
|
||||
private ScreenCoordinates _playerPosition;
|
||||
|
||||
public DoAfterGui()
|
||||
@@ -146,8 +146,8 @@ namespace Content.Client.DoAfter.UI
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
if (AttachedEntity?.IsValid() != true ||
|
||||
!AttachedEntity.TryGetComponent(out DoAfterComponent? doAfterComponent))
|
||||
if (!AttachedEntity.IsValid() ||
|
||||
!_entityManager.TryGetComponent(AttachedEntity, out DoAfterComponent? doAfterComponent))
|
||||
{
|
||||
Visible = false;
|
||||
return;
|
||||
@@ -160,8 +160,9 @@ namespace Content.Client.DoAfter.UI
|
||||
return;
|
||||
}
|
||||
|
||||
if (_eyeManager.CurrentMap != AttachedEntity.Transform.MapID ||
|
||||
!AttachedEntity.Transform.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(AttachedEntity.Transform.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));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using Content.Client.Wires.Visualizers;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Doors;
|
||||
using Content.Shared.Sound;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -15,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")]
|
||||
@@ -49,6 +50,8 @@ namespace Content.Client.Doors
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
CloseAnimation = new Animation {Length = TimeSpan.FromSeconds(_delay)};
|
||||
{
|
||||
var flick = new AnimationTrackSpriteFlick();
|
||||
@@ -109,11 +112,11 @@ namespace Content.Client.Doors
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
if (!entity.HasComponent<AnimationPlayerComponent>())
|
||||
if (!_entMan.HasComponent<AnimationPlayerComponent>(entity))
|
||||
{
|
||||
entity.AddComponent<AnimationPlayerComponent>();
|
||||
_entMan.AddComponent<AnimationPlayerComponent>(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,8 +124,8 @@ namespace Content.Client.Doors
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var animPlayer = component.Owner.GetComponent<AnimationPlayerComponent>();
|
||||
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;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using Content.Shared.Doors;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using DrawDepthTag = Robust.Shared.GameObjects.DrawDepth;
|
||||
@@ -38,7 +39,7 @@ namespace Content.Client.Doors
|
||||
|
||||
base.State = value;
|
||||
|
||||
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new DoorStateChangedEvent(State), false);
|
||||
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new DoorStateChangedEvent(State), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ namespace Content.Client.DragDrop
|
||||
|
||||
// entity performing the drag action
|
||||
|
||||
private IEntity? _dragger;
|
||||
private EntityUid _dragger;
|
||||
private readonly List<IDraggable> _draggables = new();
|
||||
private IEntity? _dragShadow;
|
||||
private EntityUid _dragShadow;
|
||||
|
||||
// time since mouse down over the dragged entity
|
||||
private float _mouseDownTime;
|
||||
@@ -68,7 +68,7 @@ namespace Content.Client.DragDrop
|
||||
// can ignore any events sent to this system
|
||||
private bool _isReplaying;
|
||||
|
||||
private DragDropHelper<IEntity> _dragDropHelper = default!;
|
||||
private DragDropHelper<EntityUid> _dragDropHelper = default!;
|
||||
|
||||
private ShaderInstance? _dropTargetInRangeShader;
|
||||
private ShaderInstance? _dropTargetOutOfRangeShader;
|
||||
@@ -77,7 +77,7 @@ namespace Content.Client.DragDrop
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
_dragDropHelper = new DragDropHelper<IEntity>(OnBeginDrag, OnContinueDrag, OnEndDrag);
|
||||
_dragDropHelper = new DragDropHelper<EntityUid>(OnBeginDrag, OnContinueDrag, OnEndDrag);
|
||||
|
||||
_dropTargetInRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetInRange).Instance();
|
||||
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
|
||||
@@ -118,33 +118,32 @@ namespace Content.Client.DragDrop
|
||||
|
||||
private bool OnUseMouseDown(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
if (args.Session?.AttachedEntity == null)
|
||||
if (args.Session?.AttachedEntity is not {Valid: true} dragger)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var dragger = args.Session.AttachedEntity;
|
||||
// cancel any current dragging if there is one (shouldn't be because they would've had to have lifted
|
||||
// the mouse, canceling the drag, but just being cautious)
|
||||
_dragDropHelper.EndDrag();
|
||||
|
||||
// possibly initiating a drag
|
||||
// check if the clicked entity is draggable
|
||||
if (!EntityManager.TryGetEntity(args.EntityUid, out var entity))
|
||||
if (!EntityManager.EntityExists(args.EntityUid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if the entity is reachable
|
||||
if (!_interactionSystem.InRangeUnobstructed(dragger, entity))
|
||||
if (!_interactionSystem.InRangeUnobstructed(dragger, args.EntityUid))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var canDrag = false;
|
||||
foreach (var draggable in entity.GetAllComponents<IDraggable>())
|
||||
foreach (var draggable in EntityManager.GetComponents<IDraggable>(args.EntityUid))
|
||||
{
|
||||
var dragEventArgs = new StartDragDropEvent(dragger, entity);
|
||||
var dragEventArgs = new StartDragDropEvent(dragger, args.EntityUid);
|
||||
|
||||
if (!draggable.CanStartDrag(dragEventArgs))
|
||||
{
|
||||
@@ -161,7 +160,7 @@ namespace Content.Client.DragDrop
|
||||
}
|
||||
|
||||
// wait to initiate a drag
|
||||
_dragDropHelper.MouseDown(entity);
|
||||
_dragDropHelper.MouseDown(args.EntityUid);
|
||||
_dragger = dragger;
|
||||
_mouseDownTime = 0;
|
||||
|
||||
@@ -176,19 +175,19 @@ namespace Content.Client.DragDrop
|
||||
|
||||
private bool OnBeginDrag()
|
||||
{
|
||||
if (_dragDropHelper.Dragged == null || _dragDropHelper.Dragged.Deleted)
|
||||
if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged))
|
||||
{
|
||||
// something happened to the clicked entity or we moved the mouse off the target so
|
||||
// we shouldn't replay the original click
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_dragDropHelper.Dragged.TryGetComponent<SpriteComponent>(out var draggedSprite))
|
||||
if (EntityManager.TryGetComponent<SpriteComponent?>(_dragDropHelper.Dragged, out var draggedSprite))
|
||||
{
|
||||
// pop up drag shadow under mouse
|
||||
var mousePos = _eyeManager.ScreenToMap(_dragDropHelper.MouseScreenPosition);
|
||||
_dragShadow = EntityManager.SpawnEntity("dragshadow", mousePos);
|
||||
var dragSprite = _dragShadow.GetComponent<SpriteComponent>();
|
||||
var dragSprite = EntityManager.GetComponent<SpriteComponent>(_dragShadow);
|
||||
dragSprite.CopyFrom(draggedSprite);
|
||||
dragSprite.RenderOrder = EntityManager.CurrentTick.Value;
|
||||
dragSprite.Color = dragSprite.Color.WithAlpha(0.7f);
|
||||
@@ -196,7 +195,7 @@ namespace Content.Client.DragDrop
|
||||
dragSprite.DrawDepth = (int) DrawDepth.Overlays;
|
||||
if (!dragSprite.NoRotation)
|
||||
{
|
||||
_dragShadow.Transform.WorldRotation = _dragDropHelper.Dragged.Transform.WorldRotation;
|
||||
EntityManager.GetComponent<TransformComponent>(_dragShadow).WorldRotation = EntityManager.GetComponent<TransformComponent>(_dragDropHelper.Dragged).WorldRotation;
|
||||
}
|
||||
|
||||
HighlightTargets();
|
||||
@@ -207,13 +206,13 @@ namespace Content.Client.DragDrop
|
||||
}
|
||||
|
||||
Logger.Warning("Unable to display drag shadow for {0} because it" +
|
||||
" has no sprite component.", _dragDropHelper.Dragged.Name);
|
||||
" has no sprite component.", EntityManager.GetComponent<MetaDataComponent>(_dragDropHelper.Dragged).EntityName);
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool OnContinueDrag(float frameTime)
|
||||
{
|
||||
if (_dragDropHelper.Dragged == null || _dragDropHelper.Dragged.Deleted)
|
||||
if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -221,7 +220,7 @@ namespace Content.Client.DragDrop
|
||||
DebugTools.AssertNotNull(_dragger);
|
||||
|
||||
// still in range of the thing we are dragging?
|
||||
if (!_interactionSystem.InRangeUnobstructed(_dragger!, _dragDropHelper.Dragged))
|
||||
if (!_interactionSystem.InRangeUnobstructed(_dragger, _dragDropHelper.Dragged))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -230,10 +229,10 @@ namespace Content.Client.DragDrop
|
||||
var mousePos = _eyeManager.ScreenToMap(_dragDropHelper.MouseScreenPosition);
|
||||
// TODO: would use MapPosition instead if it had a setter, but it has no setter.
|
||||
// is that intentional, or should we add a setter for Transform.MapPosition?
|
||||
if (_dragShadow == null)
|
||||
if (_dragShadow == default)
|
||||
return false;
|
||||
|
||||
_dragShadow.Transform.WorldPosition = mousePos.Position;
|
||||
EntityManager.GetComponent<TransformComponent>(_dragShadow).WorldPosition = mousePos.Position;
|
||||
|
||||
_targetRecheckTime += frameTime;
|
||||
if (_targetRecheckTime > TargetRecheckInterval)
|
||||
@@ -248,22 +247,22 @@ namespace Content.Client.DragDrop
|
||||
private void OnEndDrag()
|
||||
{
|
||||
RemoveHighlights();
|
||||
if (_dragShadow != null)
|
||||
if (_dragShadow != default)
|
||||
{
|
||||
EntityManager.DeleteEntity(_dragShadow);
|
||||
}
|
||||
|
||||
EntityManager.EventBus.RaiseEvent(EventSource.Local, new OutlineToggleMessage(true));
|
||||
_dragShadow = null;
|
||||
_dragShadow = default;
|
||||
_draggables.Clear();
|
||||
_dragger = null;
|
||||
_dragger = default;
|
||||
_mouseDownTime = 0;
|
||||
_savedMouseDown = null;
|
||||
}
|
||||
|
||||
private bool OnUseMouseUp(in PointerInputCmdHandler.PointerInputCmdArgs args)
|
||||
{
|
||||
if (_dragDropHelper.IsDragging == false || _dragDropHelper.Dragged == null)
|
||||
if (_dragDropHelper.IsDragging == false || _dragDropHelper.Dragged == default)
|
||||
{
|
||||
// haven't started the drag yet, quick mouseup, definitely treat it as a normal click by
|
||||
// replaying the original cmd
|
||||
@@ -287,7 +286,7 @@ namespace Content.Client.DragDrop
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_dragger == null)
|
||||
if (_dragger == default)
|
||||
{
|
||||
_dragDropHelper.EndDrag();
|
||||
return false;
|
||||
@@ -295,7 +294,7 @@ namespace Content.Client.DragDrop
|
||||
|
||||
// now when ending the drag, we will not replay the click because
|
||||
// by this time we've determined the input was actually a drag attempt
|
||||
var range = (args.Coordinates.ToMapPos(EntityManager) - _dragger.Transform.MapPosition.Position).Length + 0.01f;
|
||||
var range = (args.Coordinates.ToMapPos(EntityManager) - EntityManager.GetComponent<TransformComponent>(_dragger).MapPosition.Position).Length + 0.01f;
|
||||
// tell the server we are dropping if we are over a valid drop target in range.
|
||||
// We don't use args.EntityUid here because drag interactions generally should
|
||||
// work even if there's something "on top" of the drop target
|
||||
@@ -330,8 +329,8 @@ namespace Content.Client.DragDrop
|
||||
if (!draggable.CanDrop(dropArgs)) continue;
|
||||
|
||||
// tell the server about the drop attempt
|
||||
RaiseNetworkEvent(new DragDropRequestEvent(args.Coordinates, _dragDropHelper.Dragged!.Uid,
|
||||
entity.Uid));
|
||||
RaiseNetworkEvent(new DragDropRequestEvent(args.Coordinates, _dragDropHelper.Dragged,
|
||||
entity));
|
||||
|
||||
draggable.Drop(dropArgs);
|
||||
|
||||
@@ -340,9 +339,11 @@ namespace Content.Client.DragDrop
|
||||
}
|
||||
}
|
||||
|
||||
if (outOfRange)
|
||||
if (outOfRange &&
|
||||
_playerManager.LocalPlayer?.ControlledEntity is { } player &&
|
||||
player.IsValid())
|
||||
{
|
||||
_playerManager.LocalPlayer?.ControlledEntity?.PopupMessage(Loc.GetString("drag-drop-system-out-of-range-text"));
|
||||
player.PopupMessage(Loc.GetString("drag-drop-system-out-of-range-text"));
|
||||
}
|
||||
|
||||
_dragDropHelper.EndDrag();
|
||||
@@ -351,10 +352,8 @@ namespace Content.Client.DragDrop
|
||||
|
||||
private void HighlightTargets()
|
||||
{
|
||||
if (_dragDropHelper.Dragged == null ||
|
||||
_dragDropHelper.Dragged.Deleted ||
|
||||
_dragShadow == null ||
|
||||
_dragShadow.Deleted)
|
||||
if (_dragDropHelper.Dragged == default || Deleted(_dragDropHelper.Dragged) ||
|
||||
_dragShadow == default || Deleted(_dragShadow))
|
||||
{
|
||||
Logger.Warning("Programming error. Can't highlight drag and drop targets, not currently " +
|
||||
"dragging anything or dragged entity / shadow was deleted.");
|
||||
@@ -374,12 +373,12 @@ namespace Content.Client.DragDrop
|
||||
var pvsEntities = IoCManager.Resolve<IEntityLookup>().GetEntitiesIntersecting(_eyeManager.CurrentMap, bounds, LookupFlags.Approximate | LookupFlags.IncludeAnchored);
|
||||
foreach (var pvsEntity in pvsEntities)
|
||||
{
|
||||
if (!pvsEntity.TryGetComponent(out ISpriteComponent? inRangeSprite) ||
|
||||
if (!EntityManager.TryGetComponent(pvsEntity, out ISpriteComponent? inRangeSprite) ||
|
||||
!inRangeSprite.Visible ||
|
||||
pvsEntity == _dragDropHelper.Dragged) continue;
|
||||
|
||||
// check if it's able to be dropped on by current dragged entity
|
||||
var dropArgs = new DragDropEvent(_dragger!, pvsEntity.Transform.Coordinates, _dragDropHelper.Dragged, pvsEntity);
|
||||
var dropArgs = new DragDropEvent(_dragger, EntityManager.GetComponent<TransformComponent>(pvsEntity).Coordinates, _dragDropHelper.Dragged, pvsEntity);
|
||||
|
||||
var valid = ValidDragDrop(dropArgs);
|
||||
if (valid == null) continue;
|
||||
@@ -415,14 +414,14 @@ namespace Content.Client.DragDrop
|
||||
/// <returns>null if the target doesn't support IDragDropOn</returns>
|
||||
private bool? ValidDragDrop(DragDropEvent eventArgs)
|
||||
{
|
||||
if (!_actionBlockerSystem.CanInteract(eventArgs.User.Uid))
|
||||
if (!_actionBlockerSystem.CanInteract(eventArgs.User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool? valid = null;
|
||||
|
||||
foreach (var comp in eventArgs.Target.GetAllComponents<IDragDropOn>())
|
||||
foreach (var comp in EntityManager.GetComponents<IDragDropOn>(eventArgs.Target))
|
||||
{
|
||||
if (!comp.CanDragDropOn(eventArgs))
|
||||
{
|
||||
@@ -440,7 +439,7 @@ namespace Content.Client.DragDrop
|
||||
// Need at least one IDraggable to return true or else we can't do shit
|
||||
valid = false;
|
||||
|
||||
foreach (var comp in eventArgs.User.GetAllComponents<IDraggable>())
|
||||
foreach (var comp in EntityManager.GetComponents<IDraggable>(eventArgs.User))
|
||||
{
|
||||
if (!comp.CanDrop(eventArgs)) continue;
|
||||
valid = true;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
eventArgs.NewEntity.AddComponent<CharacterInterfaceComponent>();
|
||||
// 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 (!eventArgs.OldEntity.Deleted)
|
||||
// TODO This is shitcode. Move this to an entity system, FOR FUCK'S SAKE
|
||||
if (!_entityManager.Deleted(eventArgs.OldEntity))
|
||||
{
|
||||
eventArgs.OldEntity.RemoveComponent<CharacterInterfaceComponent>();
|
||||
_entityManager.RemoveComponent<CharacterInterfaceComponent>(eventArgs.OldEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -33,8 +32,8 @@ namespace Content.Client.Examine
|
||||
|
||||
public const string StyleClassEntityTooltip = "entity-tooltip";
|
||||
|
||||
private IEntity? _examinedEntity;
|
||||
private IEntity? _playerEntity;
|
||||
private EntityUid _examinedEntity;
|
||||
private EntityUid _playerEntity;
|
||||
private Popup? _examineTooltipOpen;
|
||||
private CancellationTokenSource? _requestCancelTokenSource;
|
||||
|
||||
@@ -51,8 +50,8 @@ namespace Content.Client.Examine
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
if (_examineTooltipOpen == null || !_examineTooltipOpen.Visible) return;
|
||||
if (_examinedEntity == null || _playerEntity == null) return;
|
||||
if (_examineTooltipOpen is not {Visible: true}) return;
|
||||
if (!_examinedEntity.Valid || !_playerEntity.Valid) return;
|
||||
|
||||
if (!CanExamine(_playerEntity, _examinedEntity))
|
||||
CloseTooltip();
|
||||
@@ -64,7 +63,7 @@ namespace Content.Client.Examine
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
public override bool CanExamine(IEntity examiner, MapCoordinates target, Ignored? predicate = null)
|
||||
public override bool CanExamine(EntityUid examiner, MapCoordinates target, Ignored? predicate = null)
|
||||
{
|
||||
var b = _eyeManager.GetWorldViewbounds();
|
||||
if (!b.Contains(target.Position))
|
||||
@@ -73,16 +72,16 @@ namespace Content.Client.Examine
|
||||
return base.CanExamine(examiner, target, predicate);
|
||||
}
|
||||
|
||||
private bool HandleExamine(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
|
||||
private bool HandleExamine(ICommonSession? session, EntityCoordinates coords, EntityUid entity)
|
||||
{
|
||||
if (!uid.IsValid() || !EntityManager.TryGetEntity(uid, out var entity))
|
||||
if (!entity.IsValid() || !EntityManager.EntityExists(entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
_playerEntity = _playerManager.LocalPlayer?.ControlledEntity ?? default;
|
||||
|
||||
if (_playerEntity == null || !CanExamine(_playerEntity, entity))
|
||||
if (_playerEntity == default || !CanExamine(_playerEntity, entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -104,7 +103,7 @@ namespace Content.Client.Examine
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
public async void DoExamine(IEntity entity)
|
||||
public async void DoExamine(EntityUid entity)
|
||||
{
|
||||
// Close any examine tooltip that might already be opened
|
||||
CloseTooltip();
|
||||
@@ -136,14 +135,14 @@ namespace Content.Client.Examine
|
||||
};
|
||||
vBox.AddChild(hBox);
|
||||
|
||||
if (entity.TryGetComponent(out ISpriteComponent? sprite))
|
||||
if (EntityManager.TryGetComponent(entity, out ISpriteComponent? sprite))
|
||||
{
|
||||
hBox.AddChild(new SpriteView { Sprite = sprite, OverrideDirection = Direction.South });
|
||||
}
|
||||
|
||||
hBox.AddChild(new Label
|
||||
{
|
||||
Text = entity.Name,
|
||||
Text = EntityManager.GetComponent<MetaDataComponent>(entity).EntityName,
|
||||
HorizontalExpand = true,
|
||||
});
|
||||
|
||||
@@ -153,14 +152,14 @@ namespace Content.Client.Examine
|
||||
_examineTooltipOpen.Open(UIBox2.FromDimensions(popupPos.Position, size));
|
||||
|
||||
FormattedMessage message;
|
||||
if (entity.Uid.IsClientSide())
|
||||
if (entity.IsClientSide())
|
||||
{
|
||||
message = GetExamineText(entity, _playerManager.LocalPlayer?.ControlledEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ask server for extra examine info.
|
||||
RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity.Uid));
|
||||
RaiseNetworkEvent(new ExamineSystemMessages.RequestExamineInfoMessage(entity));
|
||||
|
||||
ExamineSystemMessages.ExamineInfoResponseMessage response;
|
||||
try
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Explosion;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Explosion
|
||||
@@ -17,7 +18,8 @@ namespace Content.Client.Explosion
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent<ISpriteComponent>(component.Owner, out var sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Extinguisher;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Extinguisher
|
||||
@@ -26,7 +27,7 @@ namespace Content.Client.Extinguisher
|
||||
|
||||
private void SetSafety(AppearanceComponent component, bool safety)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
||||
|
||||
sprite.LayerSetState(FireExtinguisherVisualLayers.Base, safety ? _safetyOnState : _safetyOffState);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Content.Client.Flash
|
||||
return;
|
||||
|
||||
// Yes, this code is awful. I'm just porting it to an entity system so don't blame me.
|
||||
if (_playerManager.LocalPlayer != null && _playerManager.LocalPlayer.Session.AttachedEntityUid != uid)
|
||||
if (_playerManager.LocalPlayer != null && _playerManager.LocalPlayer.Session.AttachedEntity != uid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
|
||||
namespace Content.Client.Fluids
|
||||
{
|
||||
[UsedImplicitly]
|
||||
@@ -21,13 +20,13 @@ namespace Content.Client.Fluids
|
||||
// Whether the underlying solution color should be used
|
||||
[DataField("recolor")] public bool Recolor;
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!entity.TryGetComponent(out SpriteComponent? spriteComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SpriteComponent? spriteComponent))
|
||||
{
|
||||
Logger.Warning($"Missing SpriteComponent for PuddleVisualizer on entityUid = {entity.Uid}");
|
||||
Logger.Warning($"Missing SpriteComponent for PuddleVisualizer on entityUid = {entity}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,8 +45,9 @@ namespace Content.Client.Fluids
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (component.TryGetData<float>(PuddleVisuals.VolumeScale, out var volumeScale) &&
|
||||
component.Owner.TryGetComponent<SpriteComponent>(out var spriteComponent))
|
||||
entities.TryGetComponent<SpriteComponent>(component.Owner, out var spriteComponent))
|
||||
{
|
||||
var cappedScale = Math.Min(1.0f, volumeScale * 0.75f +0.25f);
|
||||
UpdateVisual(component, spriteComponent, cappedScale);
|
||||
@@ -69,5 +69,5 @@ namespace Content.Client.Fluids
|
||||
spriteComponent.Color = newColor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using Content.Client.Ghost.UI;
|
||||
using Content.Client.Ghost.UI;
|
||||
using Content.Client.HUD;
|
||||
using Content.Shared.Ghost;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -36,7 +35,7 @@ namespace Content.Client.Ghost
|
||||
|
||||
foreach (var ghost in EntityManager.GetAllComponents(typeof(GhostComponent), true))
|
||||
{
|
||||
if (ghost.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (EntityManager.TryGetComponent(ghost.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
sprite.Visible = value;
|
||||
}
|
||||
@@ -60,7 +59,7 @@ namespace Content.Client.Ghost
|
||||
|
||||
private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args)
|
||||
{
|
||||
if (component.Owner.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (EntityManager.TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
sprite.Visible = GhostVisibility;
|
||||
}
|
||||
@@ -104,7 +103,7 @@ namespace Content.Client.Ghost
|
||||
var entity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (entity == null ||
|
||||
!entity.TryGetComponent(out GhostComponent? ghost))
|
||||
!EntityManager.TryGetComponent(entity.Value, out GhostComponent? ghost))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Gravity;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -37,11 +38,11 @@ namespace Content.Client.Gravity
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
public override void InitializeEntity(EntityUid entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
if (!entity.TryGetComponent(out SpriteComponent? sprite))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
sprite.LayerMapReserveBlank(GravityGeneratorVisualLayers.Base);
|
||||
@@ -52,7 +53,7 @@ namespace Content.Client.Gravity
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var sprite = component.Owner.GetComponent<SpriteComponent>();
|
||||
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(component.Owner);
|
||||
|
||||
if (component.TryGetData(GravityGeneratorVisuals.State, out GravityGeneratorStatus state))
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using Robust.Client.GameObjects;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -33,7 +34,7 @@ namespace Content.Client.Gravity.UI
|
||||
OnButton.OnPressed += _ => _owner.SetPowerSwitch(true);
|
||||
OffButton.OnPressed += _ => _owner.SetPowerSwitch(false);
|
||||
|
||||
EntityView.Sprite = component.Owner.GetComponent<SpriteComponent>();
|
||||
EntityView.Sprite = IoCManager.Resolve<IEntityManager>().GetComponent<SpriteComponent>(component.Owner);
|
||||
}
|
||||
|
||||
public void UpdateState(SharedGravityGeneratorComponent.GeneratorState state)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.Hands.Components;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Hands
|
||||
{
|
||||
@@ -37,7 +38,7 @@ namespace Content.Client.Hands
|
||||
|
||||
public void UpdateHandContainers()
|
||||
{
|
||||
if (!Owner.TryGetComponent<ContainerManagerComponent>(out var containerMan))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ContainerManagerComponent?>(Owner, out var containerMan))
|
||||
return;
|
||||
|
||||
foreach (var hand in Hands)
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Content.Client.Hands
|
||||
|
||||
// Show blocked overlay if hand is blocked.
|
||||
newButton.Blocked.Visible =
|
||||
hand.HeldItem != null && hand.HeldItem.HasComponent<HandVirtualItemComponent>();
|
||||
hand.HeldItem != null && IoCManager.Resolve<IEntityManager>().HasComponent<HandVirtualItemComponent>(hand.HeldItem);
|
||||
}
|
||||
|
||||
if (TryGetActiveHand(out var activeHand))
|
||||
@@ -250,7 +250,7 @@ namespace Content.Client.Hands
|
||||
/// The item being held in this hand.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public IEntity? HeldItem { get; }
|
||||
public EntityUid HeldItem { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The button in the gui associated with this hand. Assumed to be set by gui shortly after being received from the client HandsComponent.
|
||||
@@ -258,7 +258,7 @@ namespace Content.Client.Hands
|
||||
[ViewVariables]
|
||||
public HandButton HandButton { get; set; } = default!;
|
||||
|
||||
public GuiHand(string name, HandLocation handLocation, IEntity? heldItem)
|
||||
public GuiHand(string name, HandLocation handLocation, EntityUid heldItem)
|
||||
{
|
||||
Name = name;
|
||||
HandLocation = handLocation;
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
using System;
|
||||
using Content.Shared.Hands.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Client.Hands
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class HandsVisualizer : AppearanceVisualizer
|
||||
{
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite)) return;
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent<ISpriteComponent>(component.Owner, out var sprite)) return;
|
||||
if (!component.TryGetData(HandsVisuals.VisualState, out HandsVisualState visualState)) return;
|
||||
|
||||
foreach (HandLocation location in Enum.GetValues(typeof(HandLocation)))
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Content.Client.Hands
|
||||
var sys = EntitySystem.Get<HandsSystem>();
|
||||
var handEntity = sys.GetActiveHandEntity();
|
||||
|
||||
if (handEntity == null || !_cfg.GetCVar(CCVars.HudHeldItemShow) || !handEntity.HasComponent<ISpriteComponent>())
|
||||
if (handEntity == default || !_cfg.GetCVar(CCVars.HudHeldItemShow) || !IoCManager.Resolve<IEntityManager>().HasComponent<ISpriteComponent>(handEntity))
|
||||
return;
|
||||
|
||||
var screen = args.ScreenHandle;
|
||||
|
||||
@@ -50,19 +50,19 @@ namespace Content.Client.Hands
|
||||
|
||||
protected override void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args)
|
||||
{
|
||||
if (uid == _playerManager.LocalPlayer?.ControlledEntity?.Uid)
|
||||
if (uid == _playerManager.LocalPlayer?.ControlledEntity)
|
||||
GuiStateUpdated?.Invoke();
|
||||
}
|
||||
|
||||
private void HandlePickupAnimation(PickupAnimationMessage msg)
|
||||
{
|
||||
if (!EntityManager.TryGetEntity(msg.EntityUid, out var entity))
|
||||
if (!msg.EntityUid.IsValid())
|
||||
return;
|
||||
|
||||
if (!_gameTiming.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
ReusableAnimations.AnimateEntityPickup(entity, msg.InitialPosition, msg.FinalPosition);
|
||||
ReusableAnimations.AnimateEntityPickup(msg.EntityUid, msg.InitialPosition, msg.FinalPosition, EntityManager);
|
||||
}
|
||||
|
||||
public HandsGuiState GetGuiState()
|
||||
@@ -77,10 +77,10 @@ namespace Content.Client.Hands
|
||||
return new HandsGuiState(states, hands.ActiveHand);
|
||||
}
|
||||
|
||||
public IEntity? GetActiveHandEntity()
|
||||
public EntityUid GetActiveHandEntity()
|
||||
{
|
||||
if (GetPlayerHandsComponent() is not { ActiveHand: { } active } hands)
|
||||
return null;
|
||||
return default;
|
||||
|
||||
return hands.GetHand(active).HeldEntity;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace Content.Client.Hands
|
||||
{
|
||||
var player = _playerManager.LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (player == null || !player.TryGetComponent(out HandsComponent? hands))
|
||||
if (player is not {Valid: true} || !EntityManager.TryGetComponent(player.Value, out HandsComponent? hands))
|
||||
return null;
|
||||
|
||||
return hands;
|
||||
@@ -106,7 +106,7 @@ namespace Content.Client.Hands
|
||||
var pressedEntity = pressedHand.HeldEntity;
|
||||
var activeEntity = activeHand.HeldEntity;
|
||||
|
||||
if (pressedHand == activeHand && activeEntity != null)
|
||||
if (pressedHand == activeHand && activeEntity != default)
|
||||
{
|
||||
// use item in hand
|
||||
// it will always be attack_self() in my heart.
|
||||
@@ -114,21 +114,21 @@ namespace Content.Client.Hands
|
||||
return;
|
||||
}
|
||||
|
||||
if (pressedHand != activeHand && pressedEntity == null)
|
||||
if (pressedHand != activeHand && pressedEntity == default)
|
||||
{
|
||||
// change active hand
|
||||
RaiseNetworkEvent(new RequestSetHandEvent(handName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (pressedHand != activeHand && pressedEntity != null && activeEntity != null)
|
||||
if (pressedHand != activeHand && pressedEntity != default && activeEntity != default)
|
||||
{
|
||||
// use active item on held item
|
||||
RaiseNetworkEvent(new ClientInteractUsingInHandMsg(pressedHand.Name));
|
||||
return;
|
||||
}
|
||||
|
||||
if (pressedHand != activeHand && pressedEntity != null && activeEntity == null)
|
||||
if (pressedHand != activeHand && pressedEntity != default && activeEntity == default)
|
||||
{
|
||||
// use active item on held item
|
||||
RaiseNetworkEvent(new MoveItemFromHandMsg(pressedHand.Name));
|
||||
|
||||
@@ -15,9 +15,10 @@ namespace Content.Client.HealthOverlay
|
||||
public class HealthOverlaySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
private readonly Dictionary<EntityUid, HealthOverlayGui> _guis = new();
|
||||
private IEntity? _attachedEntity;
|
||||
private EntityUid? _attachedEntity;
|
||||
private bool _enabled;
|
||||
|
||||
public bool Enabled
|
||||
@@ -55,7 +56,7 @@ namespace Content.Client.HealthOverlay
|
||||
}
|
||||
|
||||
_guis.Clear();
|
||||
_attachedEntity = null;
|
||||
_attachedEntity = default;
|
||||
}
|
||||
|
||||
private void HandlePlayerAttached(PlayerAttachSysMessage message)
|
||||
@@ -72,7 +73,7 @@ namespace Content.Client.HealthOverlay
|
||||
return;
|
||||
}
|
||||
|
||||
if (_attachedEntity == null || _attachedEntity.Deleted)
|
||||
if (_attachedEntity is not {} ent || Deleted(ent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -83,25 +84,25 @@ namespace Content.Client.HealthOverlay
|
||||
{
|
||||
var entity = mobState.Owner;
|
||||
|
||||
if (_attachedEntity.Transform.MapID != entity.Transform.MapID ||
|
||||
!viewBox.Contains(entity.Transform.WorldPosition))
|
||||
if (_entities.GetComponent<TransformComponent>(ent).MapID != _entities.GetComponent<TransformComponent>(entity).MapID ||
|
||||
!viewBox.Contains(_entities.GetComponent<TransformComponent>(entity).WorldPosition))
|
||||
{
|
||||
if (_guis.TryGetValue(entity.Uid, out var oldGui))
|
||||
if (_guis.TryGetValue(entity, out var oldGui))
|
||||
{
|
||||
_guis.Remove(entity.Uid);
|
||||
oldGui.Dispose();
|
||||
_guis.Remove(entity);
|
||||
oldGui.Dispose();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_guis.ContainsKey(entity.Uid))
|
||||
if (_guis.ContainsKey(entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var gui = new HealthOverlayGui(entity);
|
||||
_guis.Add(entity.Uid, gui);
|
||||
_guis.Add(entity, gui);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace Content.Client.HealthOverlay.UI
|
||||
public class HealthOverlayGui : BoxContainer
|
||||
{
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public HealthOverlayGui(IEntity entity)
|
||||
public HealthOverlayGui(EntityUid entity)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
IoCManager.Resolve<IUserInterfaceManager>().StateRoot.AddChild(this);
|
||||
@@ -62,7 +63,7 @@ namespace Content.Client.HealthOverlay.UI
|
||||
|
||||
public HealthOverlayBar CritBar { get; }
|
||||
|
||||
public IEntity Entity { get; }
|
||||
public EntityUid Entity { get; }
|
||||
|
||||
public void SetVisibility(bool val)
|
||||
{
|
||||
@@ -72,13 +73,13 @@ namespace Content.Client.HealthOverlay.UI
|
||||
|
||||
private void MoreFrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
if (Entity.Deleted)
|
||||
if (_entities.Deleted(Entity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Entity.TryGetComponent(out MobStateComponent? mobState) ||
|
||||
!Entity.TryGetComponent(out DamageableComponent? damageable))
|
||||
if (!_entities.TryGetComponent(Entity, out MobStateComponent? mobState) ||
|
||||
!_entities.TryGetComponent(Entity, out DamageableComponent? damageable))
|
||||
{
|
||||
CritBar.Visible = false;
|
||||
HealthBar.Visible = false;
|
||||
@@ -138,8 +139,7 @@ namespace Content.Client.HealthOverlay.UI
|
||||
|
||||
MoreFrameUpdate(args);
|
||||
|
||||
if (Entity.Deleted ||
|
||||
_eyeManager.CurrentMap != Entity.Transform.MapID)
|
||||
if (_entities.Deleted(Entity) || _eyeManager.CurrentMap != _entities.GetComponent<TransformComponent>(Entity).MapID)
|
||||
{
|
||||
Visible = false;
|
||||
return;
|
||||
@@ -147,7 +147,7 @@ namespace Content.Client.HealthOverlay.UI
|
||||
|
||||
Visible = true;
|
||||
|
||||
var screenCoordinates = _eyeManager.CoordinatesToScreen(Entity.Transform.Coordinates);
|
||||
var screenCoordinates = _eyeManager.CoordinatesToScreen(_entities.GetComponent<TransformComponent>(Entity).Coordinates);
|
||||
var playerPosition = UserInterfaceManager.ScreenToUIPosition(screenCoordinates);
|
||||
LayoutContainer.SetPosition(this, new Vector2(playerPosition.X - Width / 2, playerPosition.Y - Height - 30.0f));
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Content.Client.IconSmoothing
|
||||
[RegisterComponent]
|
||||
public class IconSmoothComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
[DataField("mode")]
|
||||
@@ -63,7 +64,7 @@ namespace Content.Client.IconSmoothing
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
Sprite = Owner.GetComponent<ISpriteComponent>();
|
||||
Sprite = _entMan.GetComponent<ISpriteComponent>(Owner);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -71,12 +72,12 @@ namespace Content.Client.IconSmoothing
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
if (Owner.Transform.Anchored)
|
||||
if (_entMan.GetComponent<TransformComponent>(Owner).Anchored)
|
||||
{
|
||||
// ensures lastposition initial value is populated on spawn. Just calling
|
||||
// the hook here would cause a dirty event to fire needlessly
|
||||
UpdateLastPosition();
|
||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, null, Mode));
|
||||
_entMan.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, null, Mode));
|
||||
}
|
||||
|
||||
if (Sprite != null && Mode == IconSmoothingMode.Corners)
|
||||
@@ -95,9 +96,9 @@ namespace Content.Client.IconSmoothing
|
||||
|
||||
private void UpdateLastPosition()
|
||||
{
|
||||
if (_mapManager.TryGetGrid(Owner.Transform.GridID, out var grid))
|
||||
if (_mapManager.TryGetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridID, out var grid))
|
||||
{
|
||||
_lastPosition = (Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates));
|
||||
_lastPosition = (_entMan.GetComponent<TransformComponent>(Owner).GridID, grid.TileIndicesFor(_entMan.GetComponent<TransformComponent>(Owner).Coordinates));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -109,9 +110,9 @@ namespace Content.Client.IconSmoothing
|
||||
|
||||
internal virtual void CalculateNewSprite()
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(Owner.Transform.GridID, out var grid))
|
||||
if (!_mapManager.TryGetGrid(_entMan.GetComponent<TransformComponent>(Owner).GridID, out var grid))
|
||||
{
|
||||
Logger.Error($"Failed to calculate IconSmoothComponent sprite in {Owner} because grid {Owner.Transform.GridID} was missing.");
|
||||
Logger.Error($"Failed to calculate IconSmoothComponent sprite in {Owner} because grid {_entMan.GetComponent<TransformComponent>(Owner).GridID} was missing.");
|
||||
return;
|
||||
}
|
||||
CalculateNewSprite(grid);
|
||||
@@ -136,14 +137,14 @@ namespace Content.Client.IconSmoothing
|
||||
|
||||
private void CalculateNewSpriteCardinal(IMapGrid grid)
|
||||
{
|
||||
if (!Owner.Transform.Anchored || Sprite == null)
|
||||
if (!_entMan.GetComponent<TransformComponent>(Owner).Anchored || Sprite == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dirs = CardinalConnectDirs.None;
|
||||
|
||||
var position = Owner.Transform.Coordinates;
|
||||
var position = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
if (MatchingEntity(grid.GetInDir(position, Direction.North)))
|
||||
dirs |= CardinalConnectDirs.North;
|
||||
if (MatchingEntity(grid.GetInDir(position, Direction.South)))
|
||||
@@ -173,12 +174,12 @@ namespace Content.Client.IconSmoothing
|
||||
|
||||
protected (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill(IMapGrid grid)
|
||||
{
|
||||
if (!Owner.Transform.Anchored)
|
||||
if (!_entMan.GetComponent<TransformComponent>(Owner).Anchored)
|
||||
{
|
||||
return (CornerFill.None, CornerFill.None, CornerFill.None, CornerFill.None);
|
||||
}
|
||||
|
||||
var position = Owner.Transform.Coordinates;
|
||||
var position = _entMan.GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
var n = MatchingEntity(grid.GetInDir(position, Direction.North));
|
||||
var ne = MatchingEntity(grid.GetInDir(position, Direction.NorthEast));
|
||||
var e = MatchingEntity(grid.GetInDir(position, Direction.East));
|
||||
@@ -240,7 +241,7 @@ namespace Content.Client.IconSmoothing
|
||||
}
|
||||
|
||||
// Local is fine as we already know it's parented to the grid (due to the way anchoring works).
|
||||
switch (Owner.Transform.LocalRotation.GetCardinalDir())
|
||||
switch (_entMan.GetComponent<TransformComponent>(Owner).LocalRotation.GetCardinalDir())
|
||||
{
|
||||
case Direction.North:
|
||||
return (cornerSW, cornerSE, cornerNE, cornerNW);
|
||||
@@ -258,17 +259,17 @@ namespace Content.Client.IconSmoothing
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
if (Owner.Transform.Anchored)
|
||||
if (_entMan.GetComponent<TransformComponent>(Owner).Anchored)
|
||||
{
|
||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
|
||||
_entMan.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
|
||||
}
|
||||
}
|
||||
|
||||
public void AnchorStateChanged()
|
||||
{
|
||||
if (Owner.Transform.Anchored)
|
||||
if (_entMan.GetComponent<TransformComponent>(Owner).Anchored)
|
||||
{
|
||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
|
||||
_entMan.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode));
|
||||
UpdateLastPosition();
|
||||
}
|
||||
}
|
||||
@@ -278,7 +279,7 @@ namespace Content.Client.IconSmoothing
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (!Owner.EntityManager.TryGetComponent(entity, out IconSmoothComponent? other))
|
||||
if (!_entMan.TryGetComponent(entity, out IconSmoothComponent? other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ namespace Content.Client.IconSmoothing
|
||||
// Yes, we updates ALL smoothing entities surrounding us even if they would never smooth with us.
|
||||
// This is simpler to implement. If you want to optimize it be my guest.
|
||||
var senderEnt = ev.Sender;
|
||||
if (senderEnt.IsValid() &&
|
||||
_mapManager.TryGetGrid(senderEnt.Transform.GridID, out var grid1) &&
|
||||
senderEnt.TryGetComponent(out IconSmoothComponent? iconSmooth)
|
||||
if (EntityManager.EntityExists(senderEnt) &&
|
||||
_mapManager.TryGetGrid(EntityManager.GetComponent<TransformComponent>(senderEnt).GridID, out var grid1) &&
|
||||
EntityManager.TryGetComponent(senderEnt, out IconSmoothComponent? iconSmooth)
|
||||
&& iconSmooth.Running)
|
||||
{
|
||||
var coords = senderEnt.Transform.Coordinates;
|
||||
var coords = EntityManager.GetComponent<TransformComponent>(senderEnt).Coordinates;
|
||||
|
||||
_dirtyEntities.Enqueue(senderEnt.Uid);
|
||||
_dirtyEntities.Enqueue(senderEnt);
|
||||
AddValidEntities(grid1.GetInDir(coords, Direction.North));
|
||||
AddValidEntities(grid1.GetInDir(coords, Direction.South));
|
||||
AddValidEntities(grid1.GetInDir(coords, Direction.East));
|
||||
@@ -130,7 +130,7 @@ namespace Content.Client.IconSmoothing
|
||||
/// </summary>
|
||||
public sealed class IconSmoothDirtyEvent : EntityEventArgs
|
||||
{
|
||||
public IconSmoothDirtyEvent(IEntity sender, (GridId grid, Vector2i pos)? lastPosition, IconSmoothingMode mode)
|
||||
public IconSmoothDirtyEvent(EntityUid sender, (GridId grid, Vector2i pos)? lastPosition, IconSmoothingMode mode)
|
||||
{
|
||||
LastPosition = lastPosition;
|
||||
Mode = mode;
|
||||
@@ -139,6 +139,6 @@ namespace Content.Client.IconSmoothing
|
||||
|
||||
public (GridId grid, Vector2i pos)? LastPosition { get; }
|
||||
public IconSmoothingMode Mode { get; }
|
||||
public IEntity Sender { get; }
|
||||
public EntityUid Sender { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace Content.Client.Instruments
|
||||
foreach (var instrument in EntityManager.EntityQuery<InstrumentComponent>(true))
|
||||
{
|
||||
if (instrument.DirtyRenderer && instrument.Renderer != null)
|
||||
UpdateRenderer(instrument.OwnerUid, instrument);
|
||||
UpdateRenderer(instrument.Owner, instrument);
|
||||
|
||||
if (!instrument.IsMidiOpen && !instrument.IsInputOpen)
|
||||
continue;
|
||||
@@ -366,7 +366,7 @@ namespace Content.Client.Instruments
|
||||
if (eventCount == 0)
|
||||
continue;
|
||||
|
||||
RaiseNetworkEvent(new InstrumentMidiEventEvent(instrument.OwnerUid, events));
|
||||
RaiseNetworkEvent(new InstrumentMidiEventEvent(instrument.Owner, events));
|
||||
|
||||
instrument.SentWithinASec += eventCount;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.Instruments.UI
|
||||
@@ -16,7 +18,7 @@ namespace Content.Client.Instruments.UI
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
if (!Owner.Owner.TryGetComponent<InstrumentComponent>(out var instrument)) return;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<InstrumentComponent?>(Owner.Owner, out var instrument)) return;
|
||||
|
||||
Instrument = instrument;
|
||||
_instrumentMenu = new InstrumentMenu(this);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Content.Client.Instruments.UI
|
||||
if (_owner.Instrument != null)
|
||||
{
|
||||
_owner.Instrument.OnMidiPlaybackEnded += InstrumentOnMidiPlaybackEnded;
|
||||
Title = _owner.Instrument.Owner.Name;
|
||||
Title = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_owner.Instrument.Owner).EntityName;
|
||||
LoopButton.Disabled = !_owner.Instrument.IsMidiOpen;
|
||||
LoopButton.Pressed = _owner.Instrument.LoopMidi;
|
||||
StopButton.Disabled = !_owner.Instrument.IsMidiOpen;
|
||||
@@ -104,7 +104,7 @@ namespace Content.Client.Instruments.UI
|
||||
await Task.WhenAll(Timer.Delay(100), file.CopyToAsync(memStream));
|
||||
|
||||
if (_owner.Instrument is not {} instrument
|
||||
|| !EntitySystem.Get<InstrumentSystem>().OpenMidi(instrument.OwnerUid, memStream.GetBuffer().AsSpan(0, (int) memStream.Length), instrument))
|
||||
|| !EntitySystem.Get<InstrumentSystem>().OpenMidi(instrument.Owner, memStream.GetBuffer().AsSpan(0, (int) memStream.Length), instrument))
|
||||
return;
|
||||
|
||||
MidiPlaybackSetButtonsDisabled(false);
|
||||
@@ -123,10 +123,10 @@ namespace Content.Client.Instruments.UI
|
||||
|
||||
MidiStopButtonOnPressed(null);
|
||||
if(_owner.Instrument is {} instrument)
|
||||
instrumentSystem.OpenInput(instrument.OwnerUid, instrument);
|
||||
instrumentSystem.OpenInput(instrument.Owner, instrument);
|
||||
}
|
||||
else if(_owner.Instrument is {} instrument)
|
||||
instrumentSystem.CloseInput(instrument.OwnerUid, false, instrument);
|
||||
instrumentSystem.CloseInput(instrument.Owner, false, instrument);
|
||||
}
|
||||
|
||||
private bool PlayCheck()
|
||||
@@ -139,7 +139,7 @@ namespace Content.Client.Instruments.UI
|
||||
return false;
|
||||
|
||||
// If we're a handheld instrument, we might be in a container. Get it just in case.
|
||||
instrumentEnt.TryGetContainerMan(out var conMan);
|
||||
instrumentEnt.Value.TryGetContainerMan(out var conMan);
|
||||
|
||||
var localPlayer = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace Content.Client.Instruments.UI
|
||||
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
|
||||
|
||||
// We check that we're in range unobstructed just in case.
|
||||
return localPlayer.InRangeUnobstructed(instrumentEnt,
|
||||
return localPlayer.InRangeUnobstructed(instrumentEnt.Value,
|
||||
predicate: (e) => e == instrumentEnt || e == localPlayer.ControlledEntity);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Content.Client.Instruments.UI
|
||||
if (_owner.Instrument is not { } instrument)
|
||||
return;
|
||||
|
||||
EntitySystem.Get<InstrumentSystem>().CloseMidi(instrument.OwnerUid, false, instrument);
|
||||
EntitySystem.Get<InstrumentSystem>().CloseMidi(instrument.Owner, false, instrument);
|
||||
}
|
||||
|
||||
private void MidiLoopButtonOnOnToggled(ButtonToggledEventArgs obj)
|
||||
@@ -179,14 +179,14 @@ namespace Content.Client.Instruments.UI
|
||||
// Do not seek while still grabbing.
|
||||
if (PlaybackSlider.Grabbed || _owner.Instrument is not {} instrument) return;
|
||||
|
||||
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(instrument.OwnerUid, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
|
||||
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(instrument.Owner, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
|
||||
}
|
||||
|
||||
private void PlaybackSliderKeyUp(GUIBoundKeyEventArgs args)
|
||||
{
|
||||
if (args.Function != EngineKeyFunctions.UIClick || _owner.Instrument is not {} instrument) return;
|
||||
|
||||
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(instrument.OwnerUid, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
|
||||
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(instrument.Owner, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
|
||||
@@ -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 (Owner.TryGetComponent(out ISpriteComponent? sprite))
|
||||
if (_entMan.TryGetComponent(Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
sprite.PostShader = MakeNewShader(inInteractionRange, renderScale);
|
||||
sprite.RenderOrder = Owner.EntityManager.CurrentTick.Value;
|
||||
sprite.RenderOrder = _entMan.CurrentTick.Value;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMouseLeave()
|
||||
{
|
||||
if (Owner.TryGetComponent(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 (Owner.TryGetComponent(out ISpriteComponent? sprite)
|
||||
if (_entMan.TryGetComponent(Owner, out ISpriteComponent? sprite)
|
||||
&& (inInteractionRange != _inRange || _lastRenderScale != renderScale))
|
||||
{
|
||||
_inRange = inInteractionRange;
|
||||
|
||||
@@ -9,13 +9,13 @@ namespace Content.Client.Interactable
|
||||
{
|
||||
public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
|
||||
{
|
||||
if (!EntityManager.TryGetEntity(target, out var entity))
|
||||
if (!EntityManager.EntityExists(target))
|
||||
return false;
|
||||
|
||||
if (!entity.TryGetContainer(out var container))
|
||||
if (!target.TryGetContainer(out var container))
|
||||
return false;
|
||||
|
||||
if (!EntityManager.TryGetComponent(container.Owner.Uid, out ClientStorageComponent storage))
|
||||
if (!EntityManager.TryGetComponent(container.Owner, out ClientStorageComponent storage))
|
||||
return false;
|
||||
|
||||
// we don't check if the user can access the storage entity itself. This should be handed by the UI system.
|
||||
|
||||
@@ -15,14 +15,14 @@ namespace Content.Client.Interactable
|
||||
|
||||
public static bool InRangeUnobstructed(
|
||||
this LocalPlayer origin,
|
||||
IEntity other,
|
||||
EntityUid other,
|
||||
float range = InteractionRange,
|
||||
CollisionGroup collisionMask = CollisionGroup.Impassable,
|
||||
Ignored? predicate = null,
|
||||
bool ignoreInsideBlocker = false,
|
||||
bool popup = false)
|
||||
{
|
||||
var otherPosition = other.Transform.MapPosition;
|
||||
var otherPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(other).MapPosition;
|
||||
|
||||
return origin.InRangeUnobstructed(otherPosition, range, collisionMask, predicate, ignoreInsideBlocker,
|
||||
popup);
|
||||
@@ -84,7 +84,7 @@ namespace Content.Client.Interactable
|
||||
return false;
|
||||
}
|
||||
|
||||
return SharedInteractionSystem.InRangeUnobstructed(originEntity, other, range, collisionMask, predicate,
|
||||
return SharedInteractionSystem.InRangeUnobstructed(originEntity.Value, other, range, collisionMask, predicate,
|
||||
ignoreInsideBlocker, popup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Client.Clothing;
|
||||
using Content.Shared.CharacterAppearance;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.EntitySystems;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -24,9 +22,11 @@ namespace Content.Client.Inventory
|
||||
[ComponentReference(typeof(SharedInventoryComponent))]
|
||||
public class ClientInventoryComponent : SharedInventoryComponent
|
||||
{
|
||||
private readonly Dictionary<Slots, IEntity> _slots = new();
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public IReadOnlyDictionary<Slots, IEntity> AllSlots => _slots;
|
||||
private readonly Dictionary<Slots, EntityUid> _slots = new();
|
||||
|
||||
public IReadOnlyDictionary<Slots, EntityUid> AllSlots => _slots;
|
||||
|
||||
[ViewVariables] public InventoryInterfaceController InterfaceController { get; private set; } = default!;
|
||||
|
||||
@@ -78,9 +78,9 @@ namespace Content.Client.Inventory
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsEquipped(IEntity item)
|
||||
public override bool IsEquipped(EntityUid item)
|
||||
{
|
||||
return item != null && _slots.Values.Any(e => e == item);
|
||||
return item != default && _slots.Values.Any(e => e == item);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
@@ -92,9 +92,9 @@ namespace Content.Client.Inventory
|
||||
|
||||
var doneSlots = new HashSet<Slots>();
|
||||
|
||||
foreach (var (slot, entityUid) in state.Entities)
|
||||
foreach (var (slot, entity) in state.Entities)
|
||||
{
|
||||
if (!Owner.EntityManager.TryGetEntity(entityUid, out var entity))
|
||||
if (!_entMan.EntityExists(entity))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -108,9 +108,7 @@ namespace Content.Client.Inventory
|
||||
|
||||
if (state.HoverEntity != null)
|
||||
{
|
||||
var (slot, (entityUid, fits)) = state.HoverEntity.Value;
|
||||
var entity = Owner.EntityManager.GetEntity(entityUid);
|
||||
|
||||
var (slot, (entity, fits)) = state.HoverEntity.Value;
|
||||
InterfaceController?.HoverInSlot(slot, entity, fits);
|
||||
}
|
||||
|
||||
@@ -123,24 +121,24 @@ namespace Content.Client.Inventory
|
||||
}
|
||||
}
|
||||
|
||||
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(OwnerUid);
|
||||
EntitySystem.Get<MovementSpeedModifierSystem>().RefreshMovementSpeedModifiers(Owner);
|
||||
}
|
||||
|
||||
private void _setSlot(Slots slot, IEntity entity)
|
||||
private void _setSlot(Slots slot, EntityUid entity)
|
||||
{
|
||||
SetSlotVisuals(slot, entity);
|
||||
|
||||
InterfaceController?.AddToSlot(slot, entity);
|
||||
}
|
||||
|
||||
internal void SetSlotVisuals(Slots slot, IEntity entity)
|
||||
internal void SetSlotVisuals(Slots slot, EntityUid entity)
|
||||
{
|
||||
if (_sprite == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out ClothingComponent? clothing))
|
||||
if (_entMan.TryGetComponent(entity, out ClothingComponent? clothing))
|
||||
{
|
||||
var flag = SlotMasks[slot];
|
||||
var data = clothing.GetEquippedStateInfo(flag, SpeciesId);
|
||||
@@ -230,12 +228,12 @@ namespace Content.Client.Inventory
|
||||
_playerAttached = true;
|
||||
}
|
||||
|
||||
public bool TryGetSlot(Slots slot, [NotNullWhen(true)] out IEntity? item)
|
||||
public bool TryGetSlot(Slots slot, [NotNullWhen(true)] out EntityUid item)
|
||||
{
|
||||
return _slots.TryGetValue(slot, out item);
|
||||
}
|
||||
|
||||
public bool TryFindItemSlots(IEntity item, [NotNullWhen(true)] out Slots? slots)
|
||||
public bool TryFindItemSlots(EntityUid item, [NotNullWhen(true)] out Slots? slots)
|
||||
{
|
||||
slots = null;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Client.HUD;
|
||||
using Content.Client.Items.Components;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Movement.EntitySystems;
|
||||
@@ -36,9 +35,9 @@ namespace Content.Client.Inventory
|
||||
// jesus christ, this is duplicated to server/client, should really just be shared..
|
||||
private void OnSlipAttemptEvent(EntityUid uid, ClientInventoryComponent component, SlipAttemptEvent args)
|
||||
{
|
||||
if (component.TryGetSlot(EquipmentSlotDefines.Slots.SHOES, out IEntity? shoes))
|
||||
if (component.TryGetSlot(EquipmentSlotDefines.Slots.SHOES, out EntityUid shoes))
|
||||
{
|
||||
RaiseLocalEvent(shoes.Uid, args, false);
|
||||
RaiseLocalEvent(shoes, args, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,9 +45,9 @@ namespace Content.Client.Inventory
|
||||
{
|
||||
foreach (var (_, ent) in component.AllSlots)
|
||||
{
|
||||
if (ent != null)
|
||||
if (ent != default)
|
||||
{
|
||||
RaiseLocalEvent(ent.Uid, args, false);
|
||||
RaiseLocalEvent(ent, args, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ using System.Linq;
|
||||
using Content.Client.HUD;
|
||||
using Content.Client.Items.Managers;
|
||||
using Content.Client.Items.UI;
|
||||
using Content.Shared;
|
||||
using Content.Shared.CCVar;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
@@ -15,7 +13,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Inventory.EquipmentSlotDefines;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
|
||||
@@ -155,7 +152,7 @@ namespace Content.Client.Inventory
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public override void AddToSlot(Slots slot, IEntity entity)
|
||||
public override void AddToSlot(Slots slot, EntityUid entity)
|
||||
{
|
||||
base.AddToSlot(slot, entity);
|
||||
|
||||
@@ -184,7 +181,7 @@ namespace Content.Client.Inventory
|
||||
}
|
||||
}
|
||||
|
||||
public override void HoverInSlot(Slots slot, IEntity entity, bool fits)
|
||||
public override void HoverInSlot(Slots slot, EntityUid entity, bool fits)
|
||||
{
|
||||
base.HoverInSlot(slot, entity, fits);
|
||||
|
||||
@@ -213,7 +210,7 @@ namespace Content.Client.Inventory
|
||||
private void ClearButton(ItemSlotButton button, Slots slot)
|
||||
{
|
||||
button.OnPressed = (e) => AddToInventory(e, slot);
|
||||
_itemSlotManager.SetItemSlot(button, null);
|
||||
_itemSlotManager.SetItemSlot(button, default);
|
||||
}
|
||||
|
||||
public override void PlayerAttached()
|
||||
|
||||
@@ -46,11 +46,11 @@ namespace Content.Client.Inventory
|
||||
/// specified slot, if any. Empty if none.</returns>
|
||||
public abstract IEnumerable<ItemSlotButton> GetItemSlotButtons(EquipmentSlotDefines.Slots slot);
|
||||
|
||||
public virtual void AddToSlot(EquipmentSlotDefines.Slots slot, IEntity entity)
|
||||
public virtual void AddToSlot(EquipmentSlotDefines.Slots slot, EntityUid entity)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void HoverInSlot(EquipmentSlotDefines.Slots slot, IEntity entity, bool fits)
|
||||
public virtual void HoverInSlot(EquipmentSlotDefines.Slots slot, EntityUid entity, bool fits)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user