Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
34 lines
995 B
C#
34 lines
995 B
C#
using System.Collections.Generic;
|
|
using Content.Server.AI.Utils;
|
|
using Content.Server.GameObjects;
|
|
using Content.Server.GameObjects.Components.Movement;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
|
|
namespace Content.Server.AI.WorldState.States.Mobs
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class NearbySpeciesState : CachedStateData<List<IEntity>>
|
|
{
|
|
public override string Name => "NearbySpecies";
|
|
|
|
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.GridPosition, typeof(SpeciesComponent), controller.VisionRadius))
|
|
{
|
|
if (entity == Owner) continue;
|
|
result.Add(entity);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|