From abdb523579e46a826867d4e10d72591e86a181c0 Mon Sep 17 00:00:00 2001 From: Debug <49997488+DebugOk@users.noreply.github.com> Date: Wed, 1 Nov 2023 21:06:22 +0100 Subject: [PATCH] Prevent labelling felinids (#370) --- Content.Server/Labels/Label/HandLabelerSystem.cs | 11 +++++++++-- Content.Server/Labels/Label/LabelSystem.cs | 6 ++++++ .../Item/PseudoItem/PseudoItemSystem.cs | 16 +++++++++++----- Resources/Prototypes/DeltaV/tags.yml | 3 +++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Content.Server/Labels/Label/HandLabelerSystem.cs b/Content.Server/Labels/Label/HandLabelerSystem.cs index dc7b9de0f81..dec7d697590 100644 --- a/Content.Server/Labels/Label/HandLabelerSystem.cs +++ b/Content.Server/Labels/Label/HandLabelerSystem.cs @@ -5,6 +5,7 @@ using Content.Shared.Database; using Content.Shared.Interaction; using Content.Shared.Labels; +using Content.Shared.Tag; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -22,6 +23,10 @@ public sealed class HandLabelerSystem : EntitySystem [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly LabelSystem _labelSystem = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; + [Dependency] private readonly TagSystem _tagSystem = default!; + + [ValidatePrototypeId] + private const string PreventTag = "PreventLabel"; public override void Initialize() { @@ -35,7 +40,8 @@ public override void Initialize() private void OnUtilityVerb(EntityUid uid, HandLabelerComponent handLabeler, GetVerbsEvent args) { - if (args.Target is not { Valid: true } target || !handLabeler.Whitelist.IsValid(target) || !args.CanAccess) + if (args.Target is not { Valid: true } target || !handLabeler.Whitelist.IsValid(target) || !args.CanAccess + || _tagSystem.HasTag(target, PreventTag)) // DeltaV - Prevent labels on certain items return; string labelerText = handLabeler.AssignedLabel == string.Empty ? Loc.GetString("hand-labeler-remove-label-text") : Loc.GetString("hand-labeler-add-label-text"); @@ -56,7 +62,8 @@ private void OnUtilityVerb(EntityUid uid, HandLabelerComponent handLabeler, GetV private void AfterInteractOn(EntityUid uid, HandLabelerComponent handLabeler, AfterInteractEvent args) { - if (args.Target is not {Valid: true} target || !handLabeler.Whitelist.IsValid(target) || !args.CanReach) + if (args.Target is not {Valid: true} target || !handLabeler.Whitelist.IsValid(target) || !args.CanReach + || _tagSystem.HasTag(target, PreventTag)) // DeltaV - Prevent labels on certain items return; AddLabelTo(uid, handLabeler, target, out string? result); diff --git a/Content.Server/Labels/Label/LabelSystem.cs b/Content.Server/Labels/Label/LabelSystem.cs index 23f2851665f..8a30e989012 100644 --- a/Content.Server/Labels/Label/LabelSystem.cs +++ b/Content.Server/Labels/Label/LabelSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Containers.ItemSlots; using Content.Shared.Examine; using Content.Shared.Labels; +using Content.Shared.Tag; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Containers; @@ -19,8 +20,11 @@ public sealed class LabelSystem : EntitySystem [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; + [Dependency] private readonly TagSystem _tagSystem = default!; public const string ContainerName = "paper_label"; + [ValidatePrototypeId] + private const string PreventTag = "PreventLabel"; public override void Initialize() { @@ -45,6 +49,8 @@ public void Label(EntityUid uid, string? text, MetaDataComponent? metadata = nul { if (!Resolve(uid, ref metadata)) return; + if (_tagSystem.HasTag(uid, PreventTag)) // DeltaV - Prevent labels on certain items + return; if (!Resolve(uid, ref label, false)) label = EnsureComp(uid); diff --git a/Content.Server/Nyanotrasen/Item/PseudoItem/PseudoItemSystem.cs b/Content.Server/Nyanotrasen/Item/PseudoItem/PseudoItemSystem.cs index fe4dcb7c9df..7ef2da3b864 100644 --- a/Content.Server/Nyanotrasen/Item/PseudoItem/PseudoItemSystem.cs +++ b/Content.Server/Nyanotrasen/Item/PseudoItem/PseudoItemSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Storage; using Content.Server.Storage.EntitySystems; using Content.Server.DoAfter; +using Content.Shared.Tag; using Robust.Shared.Containers; namespace Content.Server.Item.PseudoItem; @@ -16,6 +17,11 @@ public sealed partial class PseudoItemSystem : EntitySystem [Dependency] private readonly StorageSystem _storageSystem = default!; [Dependency] private readonly ItemSystem _itemSystem = default!; [Dependency] private readonly DoAfterSystem _doAfter = default!; + [Dependency] private readonly TagSystem _tagSystem = default!; + + [ValidatePrototypeId] + private const string PreventTag = "PreventLabel"; + public override void Initialize() { base.Initialize(); @@ -122,6 +128,7 @@ public bool TryInsert(EntityUid storageUid, EntityUid toInsert, PseudoItemCompon return false; var item = EnsureComp(toInsert); + _tagSystem.TryAddTag(toInsert, PreventTag); _itemSystem.SetSize(toInsert, component.Size, item); if (!_storageSystem.Insert(storageUid, toInsert, out _, null, storage)) @@ -129,12 +136,11 @@ public bool TryInsert(EntityUid storageUid, EntityUid toInsert, PseudoItemCompon component.Active = false; RemComp(toInsert); return false; - } else - { - component.Active = true; - Transform(storageUid).AttachToGridOrMap(); - return true; } + + component.Active = true; + Transform(storageUid).AttachToGridOrMap(); + return true; } private void StartInsertDoAfter(EntityUid inserter, EntityUid toInsert, EntityUid storageEntity, PseudoItemComponent? pseudoItem = null) { diff --git a/Resources/Prototypes/DeltaV/tags.yml b/Resources/Prototypes/DeltaV/tags.yml index 94808423cf7..7b09bfd3dcd 100644 --- a/Resources/Prototypes/DeltaV/tags.yml +++ b/Resources/Prototypes/DeltaV/tags.yml @@ -23,3 +23,6 @@ - type: Tag id: SpeedLoaderSpecial + +- type: Tag + id: PreventLabel