Fix errors

This commit is contained in:
DrSmugleaf
2021-12-05 21:02:04 +01:00
parent 2a3b7d809d
commit ab9d0cc6d8
94 changed files with 568 additions and 591 deletions

View File

@@ -18,6 +18,8 @@ namespace Content.Server.Storage.Components
[RegisterComponent]
public class SecretStashComponent : Component, IDestroyAct
{
[Dependency] private readonly IEntityManager _entities = default!;
public override string Name => "SecretStash";
[ViewVariables] [DataField("maxItemSize")]
@@ -76,22 +78,22 @@ namespace Content.Server.Storage.Components
/// </summary>
/// <param name="user"></param>
/// <returns>True if user recieved item</returns>
public bool TryGetItem(EntityUiduser)
public bool TryGetItem(EntityUid user)
{
if (_itemContainer.ContainedEntity == null)
if (_itemContainer.ContainedEntity is not {Valid: true} contained)
return false;
Owner.PopupMessage(user, Loc.GetString("comp-secret-stash-action-get-item-found-something", ("stash", SecretPartName)));
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands))
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_itemContainer.ContainedEntity, out ItemComponent? item))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(contained, out ItemComponent? item))
return false;
hands.PutInHandOrDrop(item);
}
else if (_itemContainer.Remove(_itemContainer.ContainedEntity))
else if (_itemContainer.Remove(contained))
{
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_itemContainer.ContainedEntity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(contained).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
}
return true;
@@ -109,9 +111,9 @@ namespace Content.Server.Storage.Components
public void OnDestroy(DestructionEventArgs eventArgs)
{
// drop item inside
if (_itemContainer.ContainedEntity != null)
if (_itemContainer.ContainedEntity is {Valid: true} contained)
{
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_itemContainer.ContainedEntity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
_entities.GetComponent<TransformComponent>(contained).Coordinates = _entities.GetComponent<TransformComponent>(Owner).Coordinates;
}
}
}

View File

@@ -452,9 +452,7 @@ namespace Content.Server.Storage.Components
{
EnsureInitialCalculated();
var player = session.AttachedEntity;
if (!player.Valid)
if (session.AttachedEntity is not {Valid: true} player)
{
break;
}
@@ -491,9 +489,7 @@ namespace Content.Server.Storage.Components
{
EnsureInitialCalculated();
var player = session.AttachedEntity;
if (player == null)
if (session.AttachedEntity is not {Valid: true} player)
{
break;
}
@@ -570,7 +566,7 @@ namespace Content.Server.Storage.Components
// Pick up all entities in a radius around the clicked location.
// The last half of the if is because carpets exist and this is terrible
if (_areaInsert && (eventArgs.Target == null || !_entityManager.HasComponent<SharedItemComponent>(eventArgs.Target)))
if (_areaInsert && (eventArgs.Target == null || !_entityManager.HasComponent<SharedItemComponent>(eventArgs.Target.Value)))
{
var validStorables = new List<EntityUid>();
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(eventArgs.ClickLocation, _areaInsertRadius, LookupFlags.None))

View File

@@ -151,13 +151,13 @@ namespace Content.Server.Storage.EntitySystems
var attachedEntity = session.AttachedEntity;
// The component manages the set of sessions, so this invalid session should be removed soon.
if (attachedEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity))
if (attachedEntity == null || !IoCManager.Resolve<IEntityManager>().EntityExists(attachedEntity.Value))
continue;
if (storageMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).MapID)
if (storageMap != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).MapID)
continue;
var distanceSquared = (storagePos - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity).WorldPosition).LengthSquared;
var distanceSquared = (storagePos - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(attachedEntity.Value).WorldPosition).LengthSquared;
if (distanceSquared > InteractionSystem.InteractionRangeSquared)
{
storageComp.UnsubscribeSession(session);