Fix 3000 errors

This commit is contained in:
DrSmugleaf
2021-12-05 18:09:01 +01:00
parent 2bfec7ec62
commit 2a3b7d809d
569 changed files with 2979 additions and 3280 deletions

View File

@@ -1,4 +1,3 @@
using Content.Client.Stylesheets;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
@@ -14,7 +13,7 @@ namespace Content.Client.ContextMenu.UI
/// <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.
@@ -24,10 +23,10 @@ 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)
{
CountLabel = new Label { StyleClasses = { StyleClassEntityMenuCountText } };
Icon.AddChild(new LayoutContainer() { Children = { EntityIcon, CountLabel } });
@@ -37,7 +36,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;
@@ -48,7 +47,7 @@ namespace Content.Client.ContextMenu.UI
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Entity = null;
Entity = default;
Count = 0;
}
@@ -56,12 +55,12 @@ 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 && IoCManager.Resolve<IEntityManager>().EntityExists(Entity))
entity ??= Entity;
if (Entity != default && IoCManager.Resolve<IEntityManager>().EntityExists(Entity) && !entity.Valid)
entity = Entity;
if (entity == null)
if (entity == default)
{
Text = string.Empty;
return;

View File

@@ -18,8 +18,8 @@ using Robust.Shared.Input.Binding;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Client.ContextMenu.UI
{
/// <summary>
@@ -51,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()
{
@@ -77,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)
@@ -101,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?
@@ -173,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?
@@ -193,7 +196,7 @@ namespace Content.Client.ContextMenu.UI
/// 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)
@@ -226,7 +229,7 @@ namespace Content.Client.ContextMenu.UI
/// <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);
@@ -245,7 +248,7 @@ 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))
@@ -323,17 +326,17 @@ 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 (!((!IoCManager.Resolve<IEntityManager>().EntityExists(entityElement.Entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entityElement.Entity).EntityLifeStage) >= EntityLifeStage.Deleted))
return entityElement.Entity;
@@ -342,11 +345,11 @@ namespace Content.Client.ContextMenu.UI
// 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)

View File

@@ -4,7 +4,6 @@ using System.Linq;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Client.ContextMenu.UI
{
@@ -18,7 +17,7 @@ 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)
{
@@ -32,9 +31,9 @@ namespace Content.Client.ContextMenu.UI
}
}
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, bool>> EqualsList = new()
{
(a, b) => IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(a).EntityPrototype!.ID == IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(b).EntityPrototype!.ID,
(a, b) =>
@@ -51,7 +50,7 @@ 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, int>> GetHashCodeList = new()
{
e => EqualityComparer<string>.Default.GetHashCode(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(e).EntityPrototype!.ID),
e =>
@@ -73,17 +72,17 @@ namespace Content.Client.ContextMenu.UI
_depth = step > Count ? Count : step;
}
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);
}
public int GetHashCode(IEntity e)
public int GetHashCode(EntityUid e)
{
return GetHashCodeList[_depth](e);
}