Susser Todd: Robust.Client/Robust.Server: Error Pass 1

This commit is contained in:
20kdc
2021-12-03 19:57:19 +00:00
parent add06753e9
commit 7b6d9bd719
10 changed files with 37 additions and 64 deletions

View File

@@ -15,7 +15,7 @@ namespace Robust.Client.GameObjects
[Dependency] private readonly IRobustSerializer _serializer = default!;
[Dependency] private readonly IDynamicTypeFactoryInternal _dynFactory = default!;
private readonly HashSet<IEntity> _updateQueue = new();
private readonly HashSet<EntityUid> _updateQueue = new();
public readonly Dictionary<EntityUid, IContainer> ExpectedEntities = new();
@@ -89,12 +89,12 @@ namespace Robust.Client.GameObjects
container.OccludesLight = occludesLight;
// Remove gone entities.
List<IEntity>? toRemove = null;
List<EntityUid>? toRemove = null;
foreach (var entity in container.ContainedEntities)
{
if (!entityUids.Contains(entity))
{
toRemove ??= new List<IEntity>();
toRemove ??= new List<EntityUid>();
toRemove.Add(entity);
}
}

View File

@@ -119,8 +119,6 @@ namespace Robust.Client.GameObjects
/// <summary>
/// Entity that the effect is attached to
/// </summary>
public IEntity? AttachedEntity { get; set; }
public EntityUid? AttachedEntityUid { get; }
/// <summary>

View File

@@ -99,7 +99,7 @@ namespace Robust.Client.Placement
/// Colour of this gets swapped around in PlacementMode.
/// This entity needs to stay in nullspace.
/// </summary>
public IEntity? CurrentPlacementOverlayEntity { get; set; }
public EntityUid? CurrentPlacementOverlayEntity { get; set; }
/// <summary>
/// A BAD way to explicitly control the icons used!!!

View File

@@ -62,8 +62,8 @@ internal partial class PVSSystem : EntitySystem
/// </summary>
private readonly Dictionary<ICommonSession, Dictionary<EntityUid, PVSEntityVisiblity>> _playerVisibleSets = new();
private PVSCollection<EntityUid, IEntity> _entityPvsCollection = default!;
public PVSCollection<EntityUid, IEntity> EntityPVSCollection => _entityPvsCollection;
private PVSCollection<EntityUid, EntityUid> _entityPvsCollection = default!;
public PVSCollection<EntityUid, EntityUid> EntityPVSCollection => _entityPvsCollection;
private readonly Dictionary<Type, IPVSCollection> _pvsCollections = new();
private readonly ObjectPool<Dictionary<EntityUid, PVSEntityVisiblity>> _visSetPool =
@@ -78,7 +78,7 @@ internal partial class PVSSystem : EntitySystem
{
base.Initialize();
_entityPvsCollection = RegisterPVSCollection<EntityUid, IEntity>(EntityManager.GetEntity);
_entityPvsCollection = RegisterPVSCollection<EntityUid, EntityUid>(EntityManager.GetEntity);
_mapManager.MapCreated += OnMapCreated;
_mapManager.MapDestroyed += OnMapDestroyed;
_mapManager.OnGridCreated += OnGridCreated;

View File

@@ -973,30 +973,6 @@ namespace Robust.Server.Maps
}
}
DeserializationResult ITypeReader<EntityUid, ValueDataNode>.Read(ISerializationManager serializationManager,
ValueDataNode node,
IDependencyCollection dependencies,
bool skipHook,
ISerializationContext? context)
{
if (node.Value == "null")
{
return new DeserializedValue<EntityUid>(EntityUid.Invalid);
}
var val = int.Parse(node.Value);
if (val >= Entities.Count)
{
Logger.ErrorS("map", "Error in map file: found local entity UID '{0}' which does not exist.", val);
}
else
{
return new DeserializedValue<EntityUid>(UidEntityMap[val]);
}
return new DeserializedValue<EntityUid>(EntityUid.Invalid);
}
DeserializationResult ITypeReader<EntityUid, ValueDataNode>.Read(ISerializationManager serializationManager,
ValueDataNode node,
IDependencyCollection dependencies,

View File

@@ -21,47 +21,47 @@ namespace Robust.Server.Placement
/// <summary>
/// Places mob in entity placement mode with given settings.
/// </summary>
void SendPlacementBegin(IEntity mob, int range, string objectType, string alignOption);
void SendPlacementBegin(EntityUid mob, int range, string objectType, string alignOption);
/// <summary>
/// Places mob in tile placement mode with given settings.
/// </summary>
void SendPlacementBeginTile(IEntity mob, int range, string tileType, string alignOption);
void SendPlacementBeginTile(EntityUid mob, int range, string tileType, string alignOption);
/// <summary>
/// Cancels object placement mode for given mob.
/// </summary>
void SendPlacementCancel(IEntity mob);
void SendPlacementCancel(EntityUid mob);
/// <summary>
/// Gives Mob permission to place entity and places it in object placement mode.
/// </summary>
void StartBuilding(IEntity mob, int range, string objectType, string alignOption);
void StartBuilding(EntityUid mob, int range, string objectType, string alignOption);
/// <summary>
/// Gives Mob permission to place tile and places it in object placement mode.
/// </summary>
void StartBuildingTile(IEntity mob, int range, string tileType, string alignOption);
void StartBuildingTile(EntityUid mob, int range, string tileType, string alignOption);
/// <summary>
/// Revokes open placement Permission and cancels object placement mode.
/// </summary>
void CancelBuilding(IEntity mob);
void CancelBuilding(EntityUid mob);
/// <summary>
/// Gives a mob a permission to place a given Entity.
/// </summary>
void AssignBuildPermission(IEntity mob, int range, string objectType, string alignOption);
void AssignBuildPermission(EntityUid mob, int range, string objectType, string alignOption);
/// <summary>
/// Gives a mob a permission to place a given Tile.
/// </summary>
void AssignBuildPermissionTile(IEntity mob, int range, string tileType, string alignOption);
void AssignBuildPermissionTile(EntityUid mob, int range, string tileType, string alignOption);
/// <summary>
/// Removes all building Permissions for given mob.
/// </summary>
void RevokeAllBuildPermissions(IEntity mob);
void RevokeAllBuildPermissions(EntityUid mob);
Func<MsgPlacement, bool>? AllowPlacementFunc { get; set; }
}

View File

@@ -209,7 +209,7 @@ namespace Robust.Server.Placement
{
EntityCoordinates start = msg.EntityCoordinates;
Vector2 rectSize = msg.RectSize;
foreach (IEntity entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesIntersecting(start.GetMapId(_entityManager),
foreach (EntityUid entity in IoCManager.Resolve<EntityUidLookup>().GetEntitiesIntersecting(start.GetMapId(_entityManager),
new Box2(start.Position, start.Position + rectSize)))
{
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || IoCManager.Resolve<IEntityManager>().HasComponent<IMapGridComponent>(entity) || IoCManager.Resolve<IEntityManager>().HasComponent<ActorComponent>(entity))
@@ -221,7 +221,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Places mob in entity placement mode with given settings.
/// </summary>
public void SendPlacementBegin(IEntity mob, int range, string objectType, string alignOption)
public void SendPlacementBegin(EntityUid mob, int range, string objectType, string alignOption)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(mob, out var actor))
return;
@@ -242,7 +242,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Places mob in tile placement mode with given settings.
/// </summary>
public void SendPlacementBeginTile(IEntity mob, int range, string tileType, string alignOption)
public void SendPlacementBeginTile(EntityUid mob, int range, string tileType, string alignOption)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(mob, out var actor))
return;
@@ -263,7 +263,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Cancels object placement mode for given mob.
/// </summary>
public void SendPlacementCancel(IEntity mob)
public void SendPlacementCancel(EntityUid mob)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<ActorComponent?>(mob, out var actor))
return;
@@ -280,7 +280,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Gives Mob permission to place entity and places it in object placement mode.
/// </summary>
public void StartBuilding(IEntity mob, int range, string objectType, string alignOption)
public void StartBuilding(EntityUid mob, int range, string objectType, string alignOption)
{
AssignBuildPermission(mob, range, objectType, alignOption);
SendPlacementBegin(mob, range, objectType, alignOption);
@@ -289,7 +289,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Gives Mob permission to place tile and places it in object placement mode.
/// </summary>
public void StartBuildingTile(IEntity mob, int range, string tileType, string alignOption)
public void StartBuildingTile(EntityUid mob, int range, string tileType, string alignOption)
{
AssignBuildPermission(mob, range, tileType, alignOption);
SendPlacementBeginTile(mob, range, tileType, alignOption);
@@ -298,7 +298,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Revokes open placement Permission and cancels object placement mode.
/// </summary>
public void CancelBuilding(IEntity mob)
public void CancelBuilding(EntityUid mob)
{
RevokeAllBuildPermissions(mob);
SendPlacementCancel(mob);
@@ -307,7 +307,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Gives a mob a permission to place a given Entity.
/// </summary>
public void AssignBuildPermission(IEntity mob, int range, string objectType, string alignOption)
public void AssignBuildPermission(EntityUid mob, int range, string objectType, string alignOption)
{
var newPermission = new PlacementInformation
{
@@ -336,7 +336,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Gives a mob a permission to place a given Tile.
/// </summary>
public void AssignBuildPermissionTile(IEntity mob, int range, string tileType, string alignOption)
public void AssignBuildPermissionTile(EntityUid mob, int range, string tileType, string alignOption)
{
var newPermission = new PlacementInformation
{
@@ -365,7 +365,7 @@ namespace Robust.Server.Placement
/// <summary>
/// Removes all building Permissions for given mob.
/// </summary>
public void RevokeAllBuildPermissions(IEntity mob)
public void RevokeAllBuildPermissions(EntityUid mob)
{
var mobPermissions = BuildPermissions
.Where(permission => permission.MobUid == mob)

View File

@@ -23,7 +23,7 @@ namespace Robust.Server.Player
/// Do not call this directly for most content code.
/// </summary>
/// <param name="entity">The entity to attach to.</param>
void AttachToEntity(IEntity? entity);
void AttachToEntity(EntityUid? entity);
/// <summary>
/// Attaches this player to an entity.
@@ -54,7 +54,7 @@ namespace Robust.Server.Player
/// Do NOT use this unless you know what you're doing, you probably want <see cref="AttachToEntity"/>
/// and <see cref="DetachFromEntity"/> instead.
/// </summary>
internal void SetAttachedEntity(IEntity? entity);
internal void SetAttachedEntity(EntityUid? entity);
/// <summary>
/// Internal method to add an entity Uid to <see cref="ViewSubscriptions"/>.

View File

@@ -42,9 +42,8 @@ namespace Robust.Server.Player
[ViewVariables] public INetChannel ConnectedClient { get; }
[ViewVariables] public IEntity? AttachedEntity { get; set; }
[ViewVariables] public EntityUid? AttachedEntityUid => AttachedEntity;
/// <inheritdoc />
[ViewVariables] public EntityUid? AttachedEntityUid { get; set; }
private SessionStatus _status = SessionStatus.Connecting;
@@ -113,7 +112,7 @@ namespace Robust.Server.Player
public event EventHandler<SessionStatusEventArgs>? PlayerStatusChanged;
/// <inheritdoc />
public void AttachToEntity(IEntity? entity)
public void AttachToEntity(EntityUid? entity)
{
DetachFromEntity();
@@ -154,7 +153,7 @@ namespace Robust.Server.Player
if (!EntitySystem.Get<ActorSystem>().Detach(AttachedEntityUid.Value))
{
Logger.Warning($"Couldn't detach player \"{this}\" from entity \"{AttachedEntity}\"! Is it missing an ActorComponent?");
Logger.Warning($"Couldn't detach player \"{this}\" from entity \"{AttachedEntityUid}\"! Is it missing an ActorComponent?");
}
}
@@ -178,9 +177,9 @@ namespace Robust.Server.Player
private void SetAttachedEntityName()
{
if (Name != null && AttachedEntity != null)
if (Name != null && AttachedEntityUid != null)
{
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(AttachedEntity).EntityName = Name;
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(AttachedEntityUid!.Value).EntityName = Name;
}
}
@@ -199,7 +198,7 @@ namespace Robust.Server.Player
public LoginType AuthType => ConnectedClient.AuthType;
/// <inheritdoc />
void IPlayerSession.SetAttachedEntity(IEntity? entity)
void IPlayerSession.SetAttachedEntity(EntityUid? entity)
{
// TODO: Use EntityUid for this.
AttachedEntity = entity;

View File

@@ -10,11 +10,11 @@ namespace Robust.Server.ViewVariables.Traits
{
internal sealed class ViewVariablesTraitEntity : ViewVariablesTrait
{
private readonly IEntity _entity;
private readonly EntityUid _entity;
public ViewVariablesTraitEntity(IViewVariablesSession session) : base(session)
{
_entity = (IEntity) Session.Object;
_entity = (EntityUid) Session.Object;
}
public override ViewVariablesBlob? DataRequest(ViewVariablesRequest viewVariablesRequest)