mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* traits ui things * fluent * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update Resources/Locale/en-US/_DV/traits/traits-ui.ftl Co-authored-by: Tobias Berger <toby@tobot.dev> Signed-off-by: wesker <53323309+weskified@users.noreply.github.com> * i hate toby * newline * pattern matching * made simpler * 2sleepy4myowngood * kl;jasglkknf.,/.sa/.mmmmmmmmm --------- Signed-off-by: wesker <53323309+weskified@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tobias Berger <toby@tobot.dev>
75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using Content.Shared.Preferences;
|
|
using Content.Shared.StatusEffectNew;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared._DV.Traits.Conditions;
|
|
|
|
/// <summary>
|
|
/// Base class for trait conditions. Implementations check if a trait can be applied to a player.
|
|
/// </summary>
|
|
[ImplicitDataDefinitionForInheritors, UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
|
public abstract partial class BaseTraitCondition
|
|
{
|
|
/// <summary>
|
|
/// If true, inverts the result of the condition.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool Invert;
|
|
|
|
/// <summary>
|
|
/// Evaluates the condition, applying inversion if configured.
|
|
/// </summary>
|
|
[PublicAPI]
|
|
public bool Evaluate(TraitConditionContext ctx)
|
|
{
|
|
var result = EvaluateImplementation(ctx);
|
|
return result ^ Invert;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generates a human-readable tooltip describing this condition's requirements.
|
|
/// </summary>
|
|
[PublicAPI]
|
|
public abstract string GetTooltip(IPrototypeManager proto, ILocalizationManager loc);
|
|
|
|
protected abstract bool EvaluateImplementation(TraitConditionContext ctx);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Context passed to trait conditions for evaluation.
|
|
/// Contains references to the player and relevant systems.
|
|
/// </summary>
|
|
public sealed class TraitConditionContext
|
|
{
|
|
public required EntityUid Player { get; init; }
|
|
public required ICommonSession? Session { get; init; }
|
|
public required IEntityManager EntMan { get; init; }
|
|
public required IPrototypeManager Proto { get; init; }
|
|
public required IComponentFactory CompFactory { get; init; }
|
|
public required ILogManager LogMan { get; init; }
|
|
public required StatusEffectsSystem StatusEffects { get; init; }
|
|
|
|
/// <summary>
|
|
/// The job ID of the player, if available.
|
|
/// </summary>
|
|
public string? JobId { get; init; }
|
|
|
|
/// <summary>
|
|
/// The species ID of the player, if available.
|
|
/// </summary>
|
|
public string? SpeciesId { get; init; }
|
|
|
|
/// <summary>
|
|
/// The <see cref="HumanoidCharacterProfile"/> of the player, if available.
|
|
/// </summary>
|
|
public HumanoidCharacterProfile? Profile { get; init; }
|
|
|
|
/// <summary>
|
|
/// The set of trait IDs currently selected by the player, if available.
|
|
/// Used by <see cref="TraitDependencyCondition"/> to check conflicts and requirements.
|
|
/// </summary>
|
|
public IReadOnlySet<ProtoId<TraitPrototype>>? SelectedTraits { get; init; }
|
|
}
|