Files
tbd-station-14/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs
Vera Aguilera Puerto a5b57c8e10 Inline Transform
2021-12-03 14:20:34 +01:00

35 lines
1.1 KiB
C#

using System.Collections.Generic;
using Content.Server.AI.Components;
using Content.Server.AI.Utils;
using Content.Shared.Body.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.AI.WorldState.States.Mobs
{
[UsedImplicitly]
public sealed class NearbyBodiesState : CachedStateData<List<IEntity>>
{
public override string Name => "NearbyBodies";
protected override List<IEntity> GetTrueValue()
{
var result = new List<IEntity>();
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner.Uid, out AiControllerComponent? controller))
{
return result;
}
foreach (var entity in Visibility.GetEntitiesInRange(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner.Uid).Coordinates, typeof(SharedBodyComponent), controller.VisionRadius))
{
if (entity == Owner) continue;
result.Add(entity);
}
return result;
}
}
}