-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathHasTagCondition.cs
31 lines (25 loc) · 1.02 KB
/
HasTagCondition.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Content.Shared.EntityEffects;
using Content.Shared.Tag;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.EntityEffects.EffectConditions;
[UsedImplicitly]
public sealed partial class HasTag : EntityEffectCondition
{
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<TagPrototype>))]
public string Tag = default!;
[DataField]
public bool Invert = false;
public override bool Condition(EntityEffectBaseArgs args)
{
if (args.EntityManager.TryGetComponent<TagComponent>(args.TargetEntity, out var tag))
return args.EntityManager.System<TagSystem>().HasTag(tag, Tag) ^ Invert;
return false;
}
public override string GuidebookExplanation(IPrototypeManager prototype)
{
// this should somehow be made (much) nicer.
return Loc.GetString("reagent-effect-condition-guidebook-has-tag", ("tag", Tag), ("invert", Invert));
}
}