namespace Content.Server.NPC.HTN.Preconditions;
+/// <summary>
+/// Checks for the presence of the value by the specified <see cref="KeyExistsPrecondition.Key"/> in the <see cref="NPCBlackboard"/>.
+/// Returns true if there is a value.
+/// </summary>
public sealed partial class KeyExistsPrecondition : HTNPrecondition
{
- [DataField("key", required: true)] public string Key = string.Empty;
+ [DataField(required: true), ViewVariables]
+ public string Key = string.Empty;
public override bool IsMet(NPCBlackboard blackboard)
{
namespace Content.Server.NPC.HTN.Preconditions;
+/// <summary>
+/// Checks if there is no value at the specified <see cref="KeyNotExistsPrecondition.Key"/> in the <see cref="NPCBlackboard"/>.
+/// Returns true if there is no value.
+/// </summary>
public sealed partial class KeyNotExistsPrecondition : HTNPrecondition
{
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string Key = string.Empty;
public override bool IsMet(NPCBlackboard blackboard)
namespace Content.Server.NPC.HTN.Preconditions.Math;
/// <summary>
-/// Checks for the presence of data in the blackboard and makes a comparison with the specified boolean
+/// Checks if there is a bool value for the specified <see cref="KeyBoolEqualsPrecondition.Key"/>
+/// in the <see cref="NPCBlackboard"/> and the specified value is equal to the <see cref="KeyBoolEqualsPrecondition.Value"/>.
/// </summary>
public sealed partial class KeyBoolEqualsPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string Key = string.Empty;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public bool Value;
public override bool IsMet(NPCBlackboard blackboard)
namespace Content.Server.NPC.HTN.Preconditions.Math;
+/// <summary>
+/// Checks if there is a float value for the specified <see cref="KeyFloatEqualsPrecondition.Key"/>
+/// in the <see cref="NPCBlackboard"/> and the specified value is equal to the <see cref="KeyFloatEqualsPrecondition.Value"/>.
+/// </summary>
public sealed partial class KeyFloatEqualsPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string Key = string.Empty;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public float Value;
public override bool IsMet(NPCBlackboard blackboard)
namespace Content.Server.NPC.HTN.Preconditions.Math;
+/// <summary>
+/// Checks if there is a float value for the specified <see cref="KeyFloatGreaterPrecondition.Key"/>
+/// in the <see cref="NPCBlackboard"/> and the specified value is greater then <see cref="KeyFloatGreaterPrecondition.Value"/>.
+/// </summary>
public sealed partial class KeyFloatGreaterPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string Key = string.Empty;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public float Value;
public override bool IsMet(NPCBlackboard blackboard)
namespace Content.Server.NPC.HTN.Preconditions.Math;
+/// <summary>
+/// Checks if there is a float value for the specified <see cref="KeyFloatGreaterPrecondition.Key"/>
+/// in the <see cref="NPCBlackboard"/> and the specified value is less then <see cref="KeyFloatGreaterPrecondition.Value"/>.
+/// </summary>
public sealed partial class KeyFloatLessPrecondition : HTNPrecondition
{
[Dependency] private readonly IEntityManager _entManager = default!;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string Key = string.Empty;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public float Value;
public override bool IsMet(NPCBlackboard blackboard)
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Math;
/// <summary>
-/// Gets the key, and adds the value to that float
+/// Added <see cref="AddFloatOperator.Amount"/> to float value for the
+/// specified <see cref="AddFloatOperator.TargetKey"/> in the <see cref="NPCBlackboard"/>.
/// </summary>
public sealed partial class AddFloatOperator : HTNOperator
{
[Dependency] private readonly IEntityManager _entManager = default!;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string TargetKey = string.Empty;
[DataField, ViewVariables(VVAccess.ReadWrite)]
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Math;
/// <summary>
-/// Just sets a blackboard key to a bool
+/// Set <see cref="SetBoolOperator.Value"/> to bool value for the
+/// specified <see cref="SetFloatOperator.TargetKey"/> in the <see cref="NPCBlackboard"/>.
/// </summary>
public sealed partial class SetBoolOperator : HTNOperator
{
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string TargetKey = string.Empty;
[DataField, ViewVariables(VVAccess.ReadWrite)]
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Math;
/// <summary>
-/// Just sets a blackboard key to a float
+/// Set <see cref="SetFloatOperator.Amount"/> to float value for the
+/// specified <see cref="SetFloatOperator.TargetKey"/> in the <see cref="NPCBlackboard"/>.
/// </summary>
public sealed partial class SetFloatOperator : HTNOperator
{
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string TargetKey = string.Empty;
[DataField, ViewVariables(VVAccess.ReadWrite)]
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Math;
/// <summary>
-/// Sets a random float from MinAmount to MaxAmount to blackboard
+/// Set random float value between <see cref="SetRandomFloatOperator.MinAmount"/> and
+/// <see cref="SetRandomFloatOperator.MaxAmount"/> specified <see cref="SetRandomFloatOperator.TargetKey"/>
+/// in the <see cref="NPCBlackboard"/>.
/// </summary>
public sealed partial class SetRandomFloatOperator : HTNOperator
{
[Dependency] private readonly IRobustRandom _random = default!;
- [DataField(required: true)]
+ [DataField(required: true), ViewVariables]
public string TargetKey = string.Empty;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxAmount = 1f;
[DataField, ViewVariables(VVAccess.ReadWrite)]
- public float MinAmount = 0f;
+ public float MinAmount;
public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard,
CancellationToken cancelToken)
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
- _chat = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
+
+ _chat = sysManager.GetEntitySystem<ChatSystem>();
}
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
if (!blackboard.TryGetValue<object>(Key, out var value, _entManager))
return HTNOperatorStatus.Failed;
+ var @string = value.ToString();
+ if (@string is not { })
+ return HTNOperatorStatus.Failed;
+
var speaker = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
- _chat.TrySendInGameICMessage(speaker, value.ToString() ?? "Oh no...", InGameICChatType.Speak, hideChat: Hidden, hideLog: Hidden);
+ _chat.TrySendInGameICMessage(speaker, @string, InGameICChatType.Speak, hideChat: Hidden, hideLog: Hidden);
return base.Update(blackboard, frameTime);
}
{
private ChatSystem _chat = default!;
- [DataField("speech", required: true)]
+ [DataField(required: true)]
public string Speech = string.Empty;
/// <summary>
public override void Initialize(IEntitySystemManager sysManager)
{
base.Initialize(sysManager);
- _chat = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
+
+ _chat = sysManager.GetEntitySystem<ChatSystem>();
}
public override HTNOperatorStatus Update(NPCBlackboard blackboard, float frameTime)
{
var speaker = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
-
_chat.TrySendInGameICMessage(speaker, Loc.GetString(Speech), InGameICChatType.Speak, hideChat: Hidden, hideLog: Hidden);
+
return base.Update(blackboard, frameTime);
}
}