mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* ready * oop forgot the HUD stuff * woooo examinable generalized tooooo * oop I forgot to rename the files * bungled the merge, I guess * this is called hubris * Verin's comments * PR comments how did I use `ProtoId<> Hunger` in more than a few spots but then just say "thirst can stay a literal :^)"? also changed a few spots to my beloved ``` functionInvocation( one param per line ) ``` ``` * Satiation effect condition now with ADDED FUNCTIONALITY?? :o * tfw you trust the markov chain recommendation because long generic type names are tough q-q * TFW YOU TRUST THE MARKOV CHAIN BUT IT DOESN'T UNDERSTAND THE DIFFERING SEMANTICS OF MAX AND MIN AHHHHH * tfw you think to yourself "i need to fix the effects", but then forget to and the code doesn't even compile. * centralize satiation constants * other small comments * The enum is dead. But at what cost? * oop * like 12 more ooperses * green checks are mine by right; I have performed the rites; I have done my part; you will not deny me this succor * oops I changed the semantics from `<=` to just `<` and didn't update the tests :) * serialization has bested me :agony: also PR comments * never trust the auto merge :agony: * literally just this * force engine back to master because idk why it's different * fix randomness and update master * submodule fuckery * fall before my might * okay I ran the linter, ARE YOU HAPPY?? * cursed ovis, trouble me no more * protoman stuff * inb4 linter bonks me * break non-critical stuff from the main satiation proto *  inb4 this breaks something somewhere lmao * my two greatest PRs COLLIDE I wonder why robust says it's changed :hmmclueless * sanity is at an all-time low * serialization, I guess * I don't believe you * field deltas on class \w*satiation\w*components * PR comments * 我做泥團子 😔 * doc + kill one property that's trivially accessible after the threshold caching changes * fixes --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: AJCM-git <ajcm_mail@disroot.org>
73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
using Content.Shared.Nutrition.Components;
|
|
using Content.Shared.Nutrition.EntitySystems;
|
|
using Content.Shared.Nutrition.Prototypes;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.EntityConditions.Conditions.Body;
|
|
|
|
/// <summary>
|
|
/// A condition which passes if the specified <see cref="SatiationTypePrototype"/> is between the specified
|
|
/// <see cref="SatiationCondition.Min"/> and <see cref="SatiationCondition.Max"/>. If the entity does not have the
|
|
/// specified satiation, the condition evaluates to false.
|
|
/// </summary>
|
|
public sealed partial class SatiationEntityConditionSystem : EntityConditionSystem<SatiationComponent, SatiationCondition>
|
|
{
|
|
[Dependency] private SatiationSystem _satiation = default!;
|
|
|
|
/// <inheritdoc/>
|
|
protected override void Condition(Entity<SatiationComponent> entity,
|
|
ref EntityConditionEvent<SatiationCondition> args)
|
|
{
|
|
if (_satiation.GetValueOrNull(entity, args.Condition.SatiationType) is not { } satiation)
|
|
return;
|
|
|
|
args.Result =
|
|
(args.Condition.MinInclusive && satiation >= args.Condition.Min || satiation > args.Condition.Min) &&
|
|
(args.Condition.MaxInclusive && satiation <= args.Condition.Max || satiation < args.Condition.Max);
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc cref="EntityCondition"/>
|
|
public sealed partial class SatiationCondition : EntityConditionBase<SatiationCondition>
|
|
{
|
|
/// <summary>
|
|
/// The value above which this condition will fail. If <see cref="MaxInclusive"/> is false, the condition will fail
|
|
/// if at that value as well.
|
|
/// </summary>
|
|
[DataField]
|
|
public float Max = float.PositiveInfinity;
|
|
|
|
/// <summary>
|
|
/// The value below which this condition will fail. If <see cref="MinInclusive"/> is false, the condition will fail
|
|
/// if at that value as well.
|
|
/// </summary>
|
|
[DataField]
|
|
public float Min = 0;
|
|
|
|
/// <summary>
|
|
/// If <c>true</c>, values exactly equal to <see cref="Max"/> will NOT fail.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool MaxInclusive = false;
|
|
|
|
/// <summary>
|
|
/// If <c>true</c>, values exactly equal to <see cref="Min"/> will NOT fail.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool MinInclusive = false;
|
|
|
|
/// <summary>
|
|
/// The type of satiation whose value will be considered.
|
|
/// </summary>
|
|
[DataField(required: true)]
|
|
public ProtoId<SatiationTypePrototype> SatiationType;
|
|
|
|
/// <inheritdoc/>
|
|
public override string EntityConditionGuidebookText(IPrototypeManager prototype)
|
|
{
|
|
return Loc.GetString("entity-condition-guidebook-total-satiation",
|
|
("max", float.IsPositiveInfinity(Max) ? int.MaxValue : Max),
|
|
("min", Min),
|
|
("type", prototype.Index(SatiationType).Name));
|
|
}
|
|
}
|