Remove many resolves on Content.Server
This commit is contained in:
@@ -9,6 +9,8 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
{
|
||||
public class SwingMeleeWeaponOperator : AiOperator
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private readonly float _burstTime;
|
||||
private float _elapsedTime;
|
||||
|
||||
@@ -17,6 +19,8 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
|
||||
public SwingMeleeWeaponOperator(EntityUid owner, EntityUid target, float burstTime = 1.0f)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_owner = owner;
|
||||
_target = target;
|
||||
_burstTime = burstTime;
|
||||
@@ -29,7 +33,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
if (!_entMan.TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -47,7 +51,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
if (!base.Shutdown(outcome))
|
||||
return false;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
if (_entMan.TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
combatModeComponent.IsInCombatMode = false;
|
||||
}
|
||||
@@ -62,15 +66,15 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
return Outcome.Success;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out HandsComponent? hands) || hands.GetActiveHand == null)
|
||||
if (!_entMan.TryGetComponent(_owner, out HandsComponent? hands) || hands.GetActiveHand == null)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
var meleeWeapon = hands.GetActiveHand.Owner;
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent(meleeWeapon, out MeleeWeaponComponent? meleeWeaponComponent);
|
||||
_entMan.TryGetComponent(meleeWeapon, out MeleeWeaponComponent? meleeWeaponComponent);
|
||||
|
||||
if ((IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_target).Coordinates.Position - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_owner).Coordinates.Position).Length >
|
||||
if ((_entMan.GetComponent<TransformComponent>(_target).Coordinates.Position - _entMan.GetComponent<TransformComponent>(_owner).Coordinates.Position).Length >
|
||||
meleeWeaponComponent?.Range)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
@@ -78,7 +82,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
|
||||
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
|
||||
|
||||
interactionSystem.AiUseInteraction(_owner, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_target).Coordinates, _target);
|
||||
interactionSystem.AiUseInteraction(_owner, _entMan.GetComponent<TransformComponent>(_target).Coordinates, _target);
|
||||
_elapsedTime += frameTime;
|
||||
return Outcome.Continuing;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
{
|
||||
public sealed class UnarmedCombatOperator : AiOperator
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private readonly float _burstTime;
|
||||
private float _elapsedTime;
|
||||
|
||||
@@ -17,6 +19,8 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
|
||||
public UnarmedCombatOperator(EntityUid owner, EntityUid target, float burstTime = 1.0f)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_owner = owner;
|
||||
_target = target;
|
||||
_burstTime = burstTime;
|
||||
@@ -29,7 +33,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
if (!_entMan.TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -39,7 +43,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
combatModeComponent.IsInCombatMode = true;
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out UnarmedCombatComponent? unarmedCombatComponent))
|
||||
if (_entMan.TryGetComponent(_owner, out UnarmedCombatComponent? unarmedCombatComponent))
|
||||
{
|
||||
_unarmedCombat = unarmedCombatComponent;
|
||||
}
|
||||
@@ -56,7 +60,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
if (!base.Shutdown(outcome))
|
||||
return false;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
if (_entMan.TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
combatModeComponent.IsInCombatMode = false;
|
||||
}
|
||||
@@ -76,14 +80,14 @@ namespace Content.Server.AI.Operators.Combat.Melee
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if ((IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_target).Coordinates.Position - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_owner).Coordinates.Position).Length >
|
||||
if ((_entMan.GetComponent<TransformComponent>(_target).Coordinates.Position - _entMan.GetComponent<TransformComponent>(_owner).Coordinates.Position).Length >
|
||||
_unarmedCombat.Range)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
|
||||
interactionSystem.AiUseInteraction(_owner, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_target).Coordinates, _target);
|
||||
interactionSystem.AiUseInteraction(_owner, _entMan.GetComponent<TransformComponent>(_target).Coordinates, _target);
|
||||
_elapsedTime += frameTime;
|
||||
return Outcome.Continuing;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,15 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
/// </summary>
|
||||
public class InteractWithEntityOperator : AiOperator
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private readonly EntityUid _owner;
|
||||
private readonly EntityUid _useTarget;
|
||||
|
||||
public InteractWithEntityOperator(EntityUid owner, EntityUid useTarget)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_owner = owner;
|
||||
_useTarget = useTarget;
|
||||
|
||||
@@ -23,7 +27,9 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_useTarget).GridID != IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_owner).GridID)
|
||||
var targetTransform = _entMan.GetComponent<TransformComponent>(_useTarget);
|
||||
|
||||
if (targetTransform.GridID != _entMan.GetComponent<TransformComponent>(_owner).GridID)
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
@@ -33,14 +39,14 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
if (_entMan.TryGetComponent(_owner, out CombatModeComponent? combatModeComponent))
|
||||
{
|
||||
combatModeComponent.IsInCombatMode = false;
|
||||
}
|
||||
|
||||
// Click on da thing
|
||||
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
|
||||
interactionSystem.AiUseInteraction(_owner, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(_useTarget).Coordinates, _useTarget);
|
||||
var interactionSystem = EntitySystem.Get<InteractionSystem>();
|
||||
interactionSystem.AiUseInteraction(_owner, targetTransform.Coordinates, _useTarget);
|
||||
|
||||
return Outcome.Success;
|
||||
}
|
||||
|
||||
@@ -22,15 +22,17 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(_target) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(_target).EntityLifeStage) >= EntityLifeStage.Deleted ||
|
||||
!IoCManager.Resolve<IEntityManager>().HasComponent<ItemComponent>(_target) ||
|
||||
_target.IsInContainer() ||
|
||||
!_owner.InRangeUnobstructed(_target, popup: true))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (entMan.Deleted(_target)
|
||||
|| !entMan.HasComponent<ItemComponent>(_target)
|
||||
|| _target.IsInContainer()
|
||||
|| !_owner.InRangeUnobstructed(_target, popup: true))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out HandsComponent? handsComponent))
|
||||
if (!entMan.TryGetComponent(_owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
@@ -56,7 +58,7 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
|
||||
var interactionSystem = EntitySystem.Get<InteractionSystem>();
|
||||
interactionSystem.InteractHand(_owner, _target);
|
||||
return Outcome.Success;
|
||||
}
|
||||
|
||||
@@ -21,13 +21,15 @@ namespace Content.Server.AI.Operators.Inventory
|
||||
|
||||
public override Outcome Execute(float frameTime)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
// TODO: Also have this check storage a la backpack etc.
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_owner, out HandsComponent? handsComponent))
|
||||
if (!entMan.TryGetComponent(_owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(_target, out ItemComponent? itemComponent))
|
||||
if (!entMan.TryGetComponent(_target, out ItemComponent? itemComponent))
|
||||
{
|
||||
return Outcome.Failed;
|
||||
}
|
||||
|
||||
@@ -28,14 +28,15 @@ namespace Content.Server.AI.Pathfinding.Accessible
|
||||
public static ReachableArgs GetArgs(EntityUid entity)
|
||||
{
|
||||
var collisionMask = 0;
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out IPhysBody? physics))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (entMan.TryGetComponent(entity, out IPhysBody? physics))
|
||||
{
|
||||
collisionMask = physics.CollisionMask;
|
||||
}
|
||||
|
||||
var accessSystem = EntitySystem.Get<AccessReaderSystem>();
|
||||
var access = accessSystem.FindAccessTags(entity);
|
||||
var visionRadius = IoCManager.Resolve<IEntityManager>().GetComponent<AiControllerComponent>(entity).VisionRadius;
|
||||
var visionRadius = entMan.GetComponent<AiControllerComponent>(entity).VisionRadius;
|
||||
|
||||
return new ReachableArgs(visionRadius, access, collisionMask);
|
||||
}
|
||||
|
||||
@@ -260,14 +260,15 @@ namespace Content.Server.AI.Pathfinding
|
||||
/// TODO: Could probably optimise this slightly more.
|
||||
public void AddEntity(EntityUid entity, IPhysBody physicsComponent)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
// If we're a door
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<AirlockComponent>(entity) || IoCManager.Resolve<IEntityManager>().HasComponent<ServerDoorComponent>(entity))
|
||||
if (entMan.HasComponent<AirlockComponent>(entity) || entMan.HasComponent<ServerDoorComponent>(entity))
|
||||
{
|
||||
// If we need access to traverse this then add to readers, otherwise no point adding it (except for maybe tile costs in future)
|
||||
// TODO: Check for powered I think (also need an event for when it's depowered
|
||||
// AccessReader calls this whenever opening / closing but it can seem to get called multiple times
|
||||
// Which may or may not be intended?
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out AccessReader? accessReader) && !_accessReaders.ContainsKey(entity))
|
||||
if (entMan.TryGetComponent(entity, out AccessReader? accessReader) && !_accessReaders.ContainsKey(entity))
|
||||
{
|
||||
_accessReaders.Add(entity, accessReader);
|
||||
ParentChunk.Dirty();
|
||||
|
||||
@@ -19,8 +19,9 @@ namespace Content.Server.AI.Utility.Actions.Test
|
||||
|
||||
public override void SetupOperators(Blackboard context)
|
||||
{
|
||||
var currentPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
var nextPosition = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates.Offset(new Vector2(10.0f, 0.0f));
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var currentPosition = entMan.GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
var nextPosition = entMan.GetComponent<TransformComponent>(Owner).Coordinates.Offset(new Vector2(10.0f, 0.0f));
|
||||
var originalPosOp = new MoveToGridOperator(Owner, currentPosition, 0.25f);
|
||||
var newPosOp = new MoveToGridOperator(Owner, nextPosition, 0.25f);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Content.Server.AI.Utility.Considerations.Combat
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().EntityExists(target) || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target, out DamageableComponent? damageableComponent))
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(target, out DamageableComponent? damageableComponent))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Drink
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null
|
||||
|| (!IoCManager.Resolve<IEntityManager>().EntityExists(target) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(target).EntityLifeStage) >= EntityLifeStage.Deleted
|
||||
|| IoCManager.Resolve<IEntityManager>().Deleted(target)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, DrinkComponent.DefaultSolutionName, out var drink))
|
||||
{
|
||||
return 0.0f;
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace Content.Server.AI.Utility.Considerations.Nutrition.Food
|
||||
{
|
||||
var target = context.GetState<TargetEntityState>().GetValue();
|
||||
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().EntityExists(target)
|
||||
|| !IoCManager.Resolve<IEntityManager>().TryGetComponent<FoodComponent?>(target, out var foodComp)
|
||||
if (target == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent<FoodComponent?>(target, out var foodComp)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(target, foodComp.SolutionName, out var food))
|
||||
{
|
||||
return 0.0f;
|
||||
|
||||
@@ -12,8 +12,9 @@ namespace Content.Server.AI.Utils
|
||||
// Should this be in robust or something? Fark it
|
||||
public static IEnumerable<EntityUid> GetNearestEntities(EntityCoordinates grid, Type component, float range)
|
||||
{
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
var inRange = GetEntitiesInRange(grid, component, range).ToList();
|
||||
var sortedInRange = inRange.OrderBy(o => (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(o).Coordinates.Position - grid.Position).Length);
|
||||
var sortedInRange = inRange.OrderBy(o => (entMan.GetComponent<TransformComponent>(o).Coordinates.Position - grid.Position).Length);
|
||||
|
||||
return sortedInRange;
|
||||
}
|
||||
@@ -23,12 +24,14 @@ namespace Content.Server.AI.Utils
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
foreach (var entity in entityManager.GetAllComponents(component).Select(c => c.Owner))
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.GetGridId(entityManager) != grid.GetGridId(entityManager))
|
||||
var transform = entityManager.GetComponent<TransformComponent>(entity);
|
||||
|
||||
if (transform.Coordinates.GetGridId(entityManager) != grid.GetGridId(entityManager))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.Position - grid.Position).Length <= range)
|
||||
if ((transform.Coordinates.Position - grid.Position).Length <= range)
|
||||
{
|
||||
yield return entity;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@ namespace Content.Server.AI.WorldState.States.Clothing
|
||||
{
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(ClothingComponent), controller.VisionRadius))
|
||||
foreach (var entity in Visibility.GetNearestEntities(entMan.GetComponent<TransformComponent>(Owner).Coordinates, typeof(ClothingComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity.TryGetContainer(out var container))
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner))
|
||||
if (!entMan.HasComponent<EntityStorageComponent>(container.Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Content.Server.AI.WorldState.States.Combat.Nearby
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<EntityUid>();
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
if (!entMan.TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(MeleeWeaponComponent), controller.VisionRadius))
|
||||
foreach (var entity in Visibility.GetNearestEntities(entMan.GetComponent<TransformComponent>(Owner).Coordinates, typeof(MeleeWeaponComponent), controller.VisionRadius))
|
||||
{
|
||||
result.Add(entity);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@ namespace Content.Server.AI.WorldState.States.Inventory
|
||||
|
||||
public override IEnumerable<EntityUid> GetValue()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (entMan.TryGetComponent(Owner, out HandsComponent? handsComponent))
|
||||
{
|
||||
foreach (var item in handsComponent.GetAllHeldItems())
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(item.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(item.Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
if (entMan.Deleted(item.Owner))
|
||||
continue;
|
||||
|
||||
yield return item.Owner;
|
||||
|
||||
@@ -16,13 +16,14 @@ namespace Content.Server.AI.WorldState.States.Mobs
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<EntityUid>();
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
if (!entMan.TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(SharedBodyComponent), controller.VisionRadius))
|
||||
foreach (var entity in Visibility.GetEntitiesInRange(entMan.GetComponent<TransformComponent>(Owner).Coordinates, typeof(SharedBodyComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity == Owner) continue;
|
||||
result.Add(entity);
|
||||
|
||||
@@ -17,13 +17,14 @@ namespace Content.Server.AI.WorldState.States.Mobs
|
||||
{
|
||||
var result = new List<EntityUid>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var nearbyPlayers = Filter.Empty()
|
||||
.AddInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).MapPosition, controller.VisionRadius)
|
||||
.AddInRange(entMan.GetComponent<TransformComponent>(Owner).MapPosition, controller.VisionRadius)
|
||||
.Recipients;
|
||||
|
||||
foreach (var player in nearbyPlayers)
|
||||
@@ -33,7 +34,7 @@ namespace Content.Server.AI.WorldState.States.Mobs
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player.AttachedEntity != Owner && IoCManager.Resolve<IEntityManager>().HasComponent<DamageableComponent>(playerEntity))
|
||||
if (player.AttachedEntity != Owner && entMan.HasComponent<DamageableComponent>(playerEntity))
|
||||
{
|
||||
result.Add(playerEntity);
|
||||
}
|
||||
|
||||
@@ -18,18 +18,19 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<EntityUid>();
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
if (!entMan.TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(DrinkComponent), controller.VisionRadius))
|
||||
.GetNearestEntities(entMan.GetComponent<TransformComponent>(Owner).Coordinates, typeof(DrinkComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity.TryGetContainer(out var container))
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner))
|
||||
if (!entMan.HasComponent<EntityStorageComponent>(container.Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,18 +18,19 @@ namespace Content.Server.AI.WorldState.States.Nutrition
|
||||
protected override List<EntityUid> GetTrueValue()
|
||||
{
|
||||
var result = new List<EntityUid>();
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
if (!entMan.TryGetComponent(Owner, out AiControllerComponent? controller))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var entity in Visibility
|
||||
.GetNearestEntities(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates, typeof(FoodComponent), controller.VisionRadius))
|
||||
.GetNearestEntities(entMan.GetComponent<TransformComponent>(Owner).Coordinates, typeof(FoodComponent), controller.VisionRadius))
|
||||
{
|
||||
if (entity.TryGetContainer(out var container))
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<EntityStorageComponent>(container.Owner))
|
||||
if (!entMan.HasComponent<EntityStorageComponent>(container.Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user