mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* somewhat functional yes * some cleanup * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * review * missed one * why not params… * review 2 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
30 lines
973 B
C#
30 lines
973 B
C#
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
|
|
namespace Content.Shared._DV.Tips.Conditions;
|
|
|
|
/// <summary>
|
|
/// Condition that checks if the player entity has a specific component.
|
|
/// </summary>
|
|
public sealed partial class HasCompCondition : TipCondition
|
|
{
|
|
private ISawmill _sawmill = default!;
|
|
|
|
/// <summary>
|
|
/// The component name to check for.
|
|
/// </summary>
|
|
[DataField(required: true, customTypeSerializer: typeof(ComponentNameSerializer))]
|
|
public string Comp = string.Empty;
|
|
|
|
protected override bool EvaluateImplementation(TipConditionContext ctx)
|
|
{
|
|
_sawmill = ctx.LogMan.GetSawmill("HasCompCondition");
|
|
if (!ctx.CompFactory.TryGetRegistration(Comp, out var registration))
|
|
{
|
|
_sawmill.Warning("tip", $"Tip condition references unknown component: {Comp}");
|
|
return false;
|
|
}
|
|
|
|
return ctx.EntMan.HasComponent(ctx.Player, registration.Type);
|
|
}
|
|
}
|