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

@@ -31,7 +31,7 @@ namespace Content.Client.DoAfter
/// </summary>
public const float ExcessTime = 0.5f;
private EntityUid _attachedEntity;
private EntityUid? _attachedEntity;
public override void Initialize()
{
@@ -51,7 +51,8 @@ namespace Content.Client.DoAfter
var currentTime = _gameTiming.CurTime;
// Can't see any I guess?
if (_attachedEntity == default || (!EntityManager.EntityExists(_attachedEntity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(_attachedEntity).EntityLifeStage) >= EntityLifeStage.Deleted)
if (_attachedEntity is not {Valid: true} entity ||
(!EntityManager.EntityExists(_attachedEntity.Value) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted)
return;
var viewbox = _eyeManager.GetWorldViewport().Enlarged(2.0f);
@@ -62,19 +63,19 @@ namespace Content.Client.DoAfter
var compPos = EntityManager.GetComponent<TransformComponent>(comp.Owner).WorldPosition;
if (doAfters.Count == 0 ||
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapID != EntityManager.GetComponent<TransformComponent>(_attachedEntity).MapID ||
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapID != EntityManager.GetComponent<TransformComponent>(entity).MapID ||
!viewbox.Contains(compPos))
{
comp.Disable();
continue;
}
var range = (compPos - EntityManager.GetComponent<TransformComponent>(_attachedEntity).WorldPosition).Length +
var range = (compPos - EntityManager.GetComponent<TransformComponent>(entity).WorldPosition).Length +
0.01f;
if (comp.Owner != _attachedEntity &&
!ExamineSystemShared.InRangeUnOccluded(
EntityManager.GetComponent<TransformComponent>(_attachedEntity).MapPosition,
EntityManager.GetComponent<TransformComponent>(entity).MapPosition,
EntityManager.GetComponent<TransformComponent>(comp.Owner).MapPosition, range,
entity => entity == comp.Owner || entity == _attachedEntity))
{

View File

@@ -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 EntityUid _attachedEntity;
private EntityUid? _attachedEntity;
private bool _enabled;
public bool Enabled
@@ -72,7 +73,7 @@ namespace Content.Client.HealthOverlay
return;
}
if (_attachedEntity == null || (!IoCManager.Resolve<IEntityManager>().EntityExists(_attachedEntity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_attachedEntity).EntityLifeStage) >= EntityLifeStage.Deleted)
if (_attachedEntity == null || (!_entities.EntityExists(_attachedEntity.Value) ? EntityLifeStage.Deleted : _entities.GetComponent<MetaDataComponent>(_attachedEntity.Value).EntityLifeStage) >= EntityLifeStage.Deleted)
{
return;
}
@@ -83,8 +84,8 @@ namespace Content.Client.HealthOverlay
{
var entity = mobState.Owner;
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_attachedEntity).MapID != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID ||
!viewBox.Contains(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition))
if (_entities.GetComponent<TransformComponent>(_attachedEntity.Value).MapID != _entities.GetComponent<TransformComponent>(entity).MapID ||
!viewBox.Contains(_entities.GetComponent<TransformComponent>(entity).WorldPosition))
{
if (_guis.TryGetValue(entity, out var oldGui))
{

View File

@@ -44,8 +44,7 @@ namespace Content.Client.Physics.Controllers
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
if (EntityManager.TryGetComponent(player, out SharedPullableComponent? pullableComp))
{
var puller = pullableComp.Puller;
if (puller != default && EntityManager.TryGetComponent<PhysicsComponent?>(puller, out var pullerBody))
if (pullableComp.Puller is {Valid: true} puller && EntityManager.TryGetComponent<PhysicsComponent?>(puller, out var pullerBody))
{
pullerBody.Predict = false;
body.Predict = false;
@@ -55,9 +54,7 @@ namespace Content.Client.Physics.Controllers
// If we're pulling a mob then make sure that isn't predicted so it doesn't fuck our velocity up.
if (EntityManager.TryGetComponent(player, out SharedPullerComponent? pullerComp))
{
var pulling = pullerComp.Pulling;
if (pulling != default &&
if (pullerComp.Pulling is {Valid: true} pulling &&
EntityManager.HasComponent<MobStateComponent>(pulling) &&
EntityManager.TryGetComponent(pulling, out PhysicsComponent? pullingBody))
{