mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* documentation pass on content.server -> E! * APi pass on content.server for the E folder. * documentation pass on content.shared for e. * Apply suggestions from code review Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> * fixing documentation according to review part 1. * typo * Very minor fixes * And a short explanation about EUI --------- Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using Content.Shared.Nutrition.Components;
|
|
using Content.Shared.Nutrition.EntitySystems;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.EntityConditions.Conditions.Body;
|
|
|
|
/// <summary>
|
|
/// Returns true if this entity's hunger is within a specified minimum and maximum.
|
|
/// </summary>
|
|
/// <inheritdoc cref="EntityConditionSystem{T, TCondition}"/>
|
|
public sealed partial class TotalHungerEntityConditionSystem : EntityConditionSystem<HungerComponent, HungerCondition>
|
|
{
|
|
[Dependency] private HungerSystem _hunger = default!;
|
|
|
|
protected override void Condition(Entity<HungerComponent> entity, ref EntityConditionEvent<HungerCondition> args)
|
|
{
|
|
var total = _hunger.GetHunger(entity.Comp);
|
|
args.Result = total >= args.Condition.Min && total <= args.Condition.Max;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc cref="EntityCondition"/>
|
|
public sealed partial class HungerCondition : EntityConditionBase<HungerCondition>
|
|
{
|
|
/// <summary>
|
|
/// Minimum hunger required to fulfill this condition.
|
|
/// </summary>
|
|
[DataField]
|
|
public float Min;
|
|
|
|
/// <summary>
|
|
/// Maximum hunger required to fulfill this condition.
|
|
/// </summary>
|
|
[DataField]
|
|
public float Max = float.PositiveInfinity;
|
|
|
|
public override string EntityConditionGuidebookText(IPrototypeManager prototype) =>
|
|
Loc.GetString("entity-condition-guidebook-total-hunger", ("max", float.IsPositiveInfinity(Max) ? int.MaxValue : Max), ("min", Min));
|
|
}
|