Skip to content

Commit

Permalink
Prevent labelling felinids (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
DebugOk authored Nov 1, 2023
1 parent 00045c9 commit abdb523
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Content.Server/Labels/Label/HandLabelerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TagPrototype>]
private const string PreventTag = "PreventLabel";

public override void Initialize()
{
Expand All @@ -35,7 +40,8 @@ public override void Initialize()

private void OnUtilityVerb(EntityUid uid, HandLabelerComponent handLabeler, GetVerbsEvent<UtilityVerb> 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");
Expand All @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/Labels/Label/LabelSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TagPrototype>]
private const string PreventTag = "PreventLabel";

public override void Initialize()
{
Expand All @@ -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<LabelComponent>(uid);

Expand Down
16 changes: 11 additions & 5 deletions Content.Server/Nyanotrasen/Item/PseudoItem/PseudoItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TagPrototype>]
private const string PreventTag = "PreventLabel";

public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -122,19 +128,19 @@ public bool TryInsert(EntityUid storageUid, EntityUid toInsert, PseudoItemCompon
return false;

var item = EnsureComp<ItemComponent>(toInsert);
_tagSystem.TryAddTag(toInsert, PreventTag);
_itemSystem.SetSize(toInsert, component.Size, item);

if (!_storageSystem.Insert(storageUid, toInsert, out _, null, storage))
{
component.Active = false;
RemComp<ItemComponent>(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)
{
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/DeltaV/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@

- type: Tag
id: SpeedLoaderSpecial

- type: Tag
id: PreventLabel

0 comments on commit abdb523

Please sign in to comment.