Fix more errors

This commit is contained in:
DrSmugleaf
2021-12-06 00:52:58 +01:00
parent 2b1fecbe02
commit 215cae5655
55 changed files with 262 additions and 297 deletions

View File

@@ -25,6 +25,8 @@ namespace Content.Server.PowerCell.Components
public class PowerCellSlotComponent : Component, IExamine, IMapInit
#pragma warning restore 618
{
[Dependency] private readonly IEntityManager _entities = default!;
public override string Name => "PowerCellSlot";
/// <summary>
@@ -81,7 +83,7 @@ namespace Content.Server.PowerCell.Components
get
{
if (_cellContainer.ContainedEntity == null) return null;
return IoCManager.Resolve<IEntityManager>().TryGetComponent(_cellContainer.ContainedEntity, out PowerCellComponent? cell) ? cell : null;
return _entities.TryGetComponent(_cellContainer.ContainedEntity.Value, out PowerCellComponent? cell) ? cell : null;
}
}
@@ -134,14 +136,14 @@ namespace Content.Server.PowerCell.Components
//Dirty();
if (user != null)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(cell.Owner)))
if (!_entities.TryGetComponent(user, out HandsComponent? hands) || !hands.PutInHand(_entities.GetComponent<ItemComponent>(cell.Owner)))
{
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(cell.Owner).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).Coordinates;
_entities.GetComponent<TransformComponent>(cell.Owner).Coordinates = _entities.GetComponent<TransformComponent>(user).Coordinates;
}
}
else
{
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(cell.Owner).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
_entities.GetComponent<TransformComponent>(cell.Owner).Coordinates = _entities.GetComponent<TransformComponent>(Owner).Coordinates;
}
if (playSound)
@@ -149,7 +151,7 @@ namespace Content.Server.PowerCell.Components
SoundSystem.Play(Filter.Pvs(Owner), CellRemoveSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f));
}
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new PowerCellChangedEvent(true), false);
_entities.EventBus.RaiseLocalEvent(Owner, new PowerCellChangedEvent(true), false);
return cell;
}
@@ -162,8 +164,8 @@ namespace Content.Server.PowerCell.Components
public bool InsertCell(EntityUid cell, bool playSound = true)
{
if (Cell != null) return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent((EntityUid) cell, out (ItemComponent?) var _)) return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<PowerCellComponent?>(cell, out var cellComponent)) return false;
if (!_entities.HasComponent<ItemComponent>(cell)) return false;
if (!_entities.TryGetComponent<PowerCellComponent?>(cell, out var cellComponent)) return false;
if (cellComponent.CellSize != SlotSize) return false;
if (!_cellContainer.Insert(cell)) return false;
//Dirty();
@@ -172,7 +174,7 @@ namespace Content.Server.PowerCell.Components
SoundSystem.Play(Filter.Pvs(Owner), CellInsertSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f));
}
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(Owner, new PowerCellChangedEvent(false), false);
_entities.EventBus.RaiseLocalEvent(Owner, new PowerCellChangedEvent(false), false);
return true;
}
@@ -199,7 +201,7 @@ namespace Content.Server.PowerCell.Components
};
}
var cell = IoCManager.Resolve<IEntityManager>().SpawnEntity(type, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
var cell = _entities.SpawnEntity(type, _entities.GetComponent<TransformComponent>(Owner).Coordinates);
_cellContainer.Insert(cell);
}
}