Validate prototype ids in c# fields (#18224)

This commit is contained in:
Leon Friedrich
2023-07-30 05:34:51 +12:00
committed by GitHub
parent d4a85afb88
commit 385b587cfc
21 changed files with 116 additions and 74 deletions

View File

@@ -14,6 +14,9 @@ public abstract class ClothingSystem : EntitySystem
[Dependency] private readonly SharedHumanoidAppearanceSystem _humanoidSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[ValidatePrototypeId<TagPrototype>]
private const string HairTag = "HidesHair";
public override void Initialize()
{
base.Initialize();
@@ -27,14 +30,14 @@ public abstract class ClothingSystem : EntitySystem
protected virtual void OnGotEquipped(EntityUid uid, ClothingComponent component, GotEquippedEvent args)
{
component.InSlot = args.Slot;
if (args.Slot == "head" && _tagSystem.HasTag(args.Equipment, "HidesHair"))
if (args.Slot == "head" && _tagSystem.HasTag(args.Equipment, HairTag))
_humanoidSystem.SetLayerVisibility(args.Equipee, HumanoidVisualLayers.Hair, false);
}
protected virtual void OnGotUnequipped(EntityUid uid, ClothingComponent component, GotUnequippedEvent args)
{
component.InSlot = null;
if (args.Slot == "head" && _tagSystem.HasTag(args.Equipment, "HidesHair"))
if (args.Slot == "head" && _tagSystem.HasTag(args.Equipment, HairTag))
_humanoidSystem.SetLayerVisibility(args.Equipee, HumanoidVisualLayers.Hair, true);
}