Files
tbd-station-14/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* 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
2021-02-11 01:13:03 -08:00

28 lines
1.0 KiB
C#

using System;
using Content.Server.AI.WorldState;
using Content.Server.AI.WorldState.States.Utility;
using Robust.Shared.GameObjects;
namespace Content.Server.AI.Utility.Considerations.State
{
/// <summary>
/// Simple NullCheck on a StoredState
/// </summary>
public sealed class StoredStateEntityIsNullCon : Consideration
{
public StoredStateEntityIsNullCon Set(Type type, Blackboard context)
{
// Ideally we'd just use a variable but then if we were iterating through multiple AI at once it'd be
// Stuffed so we need to store it on the AI's context.
context.GetState<StoredStateIsNullState>().SetValue(type);
return this;
}
protected override float GetScore(Blackboard context)
{
var stateData = context.GetState<StoredStateIsNullState>().GetValue();
context.GetStoredState(stateData, out StoredStateData<IEntity> state);
return state.GetValue() == null ? 1.0f : 0.0f;
}
}
}