* Engine namespace changes.
* Automated remove redundant using statements.
* Simplified Graphics namespace.
* Apparently the container system stores full type names in the map file.😞 This updates those names.
* API Changes to LocalizationManager.LoadCulture.
* Update submodule to v0.3.2
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using Content.Server.AI.Utils;
|
|
using Content.Server.GameObjects.Components.Items.Storage;
|
|
using Content.Server.GameObjects.Components.Movement;
|
|
using Content.Server.GameObjects.Components.Nutrition;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.Server.AI.WorldState.States.Nutrition
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class NearbyFoodState : CachedStateData<List<IEntity>>
|
|
{
|
|
public override string Name => "NearbyFood";
|
|
|
|
protected override List<IEntity> GetTrueValue()
|
|
{
|
|
var result = new List<IEntity>();
|
|
|
|
if (!Owner.TryGetComponent(out AiControllerComponent controller))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
foreach (var entity in Visibility
|
|
.GetNearestEntities(Owner.Transform.Coordinates, typeof(FoodComponent), controller.VisionRadius))
|
|
{
|
|
if (entity.TryGetContainer(out var container))
|
|
{
|
|
if (!container.Owner.HasComponent<EntityStorageComponent>())
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
result.Add(entity);
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
}
|
|
}
|