Files
tbd-station-14/Content.Server/AI/WorldState/States/Mobs/NearbyBodiesState.cs
DrSmugleaf 69969bbdc6 Remove IBody, IBodyPart, IMechanism and IMechanismBehavior (#4187)
* Remove IBody, IBodyPart, IMechanism and IMechanismBehavior interfaces

* Summary cleanup
2021-06-17 00:44:38 +10:00

34 lines
974 B
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;
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 (!Owner.TryGetComponent(out AiControllerComponent? controller))
{
return result;
}
foreach (var entity in Visibility.GetEntitiesInRange(Owner.Transform.Coordinates, typeof(SharedBodyComponent), controller.VisionRadius))
{
if (entity == Owner) continue;
result.Add(entity);
}
return result;
}
}
}