Fix weird lifestage autorefactors.

This commit is contained in:
Vera Aguilera Puerto
2021-12-09 12:29:27 +01:00
parent 3a9e1ff929
commit 8b09d55b10
43 changed files with 55 additions and 69 deletions

View File

@@ -32,7 +32,7 @@ namespace Content.Server.AI.Operators.Nutrition
var entities = IoCManager.Resolve<IEntityManager>();
// TODO: Also have this check storage a la backpack etc.
if ((!entities.EntityExists(_target) ? EntityLifeStage.Deleted : entities.GetComponent<MetaDataComponent>(_target).EntityLifeStage) >= EntityLifeStage.Deleted ||
if (entities.Deleted(_target) ||
!entities.TryGetComponent(_owner, out HandsComponent? handsComponent) ||
!entities.TryGetComponent(_target, out ItemComponent? itemComponent))
{

View File

@@ -31,7 +31,7 @@ namespace Content.Server.AI.Operators.Nutrition
var entities = IoCManager.Resolve<IEntityManager>();
// TODO: Also have this check storage a la backpack etc.
if ((!entities.EntityExists(_target) ? EntityLifeStage.Deleted : entities.GetComponent<MetaDataComponent>(_target).EntityLifeStage) >= EntityLifeStage.Deleted ||
if (entities.Deleted(_target) ||
!entities.TryGetComponent(_owner, out HandsComponent? handsComponent) ||
!entities.TryGetComponent(_target, out ItemComponent? itemComponent))
{

View File

@@ -264,7 +264,7 @@ namespace Content.Server.AI.Pathfinding
/// <param name="entity"></param>
private void HandleEntityAdd(EntityUid entity)
{
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted ||
if (Deleted(entity) ||
_lastKnownPositions.ContainsKey(entity) ||
!EntityManager.TryGetComponent(entity, out IPhysBody? physics) ||
!PathfindingNode.IsRelevant(entity, physics))

View File

@@ -246,7 +246,7 @@ namespace Content.Server.AI.Steering
private SteeringStatus Steer(EntityUid entity, IAiSteeringRequest steeringRequest, float frameTime)
{
// Main optimisation to be done below is the redundant calls and adding more variables
if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted ||
if (Deleted(entity) ||
!EntityManager.TryGetComponent(entity, out AiControllerComponent? controller) ||
!EntitySystem.Get<ActionBlockerSystem>().CanMove(entity) ||
!EntityManager.GetComponent<TransformComponent>(entity).GridID.IsValid())
@@ -658,7 +658,7 @@ namespace Content.Server.AI.Steering
// err for now we'll just assume the first entity is the center and just add a vector for it
//Pathfinding updates are deferred so this may not be done yet.
if ((!EntityManager.EntityExists(physicsEntity) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(physicsEntity).EntityLifeStage) >= EntityLifeStage.Deleted) continue;
if (Deleted(physicsEntity)) continue;
// if we're moving in the same direction then ignore
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction

View File

@@ -12,8 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Movement
var self = context.GetState<SelfState>().GetValue();
var entities = IoCManager.Resolve<IEntityManager>();
if (context.GetState<TargetEntityState>().GetValue() is not {Valid: true} target ||
(!entities.EntityExists(target) ? EntityLifeStage.Deleted : entities.GetComponent<MetaDataComponent>(target).EntityLifeStage) >= EntityLifeStage.Deleted ||
if (context.GetState<TargetEntityState>().GetValue() is not {Valid: true} target || entities.Deleted(target) ||
entities.GetComponent<TransformComponent>(target).GridID != entities.GetComponent<TransformComponent>(self).GridID)
{
return 0.0f;