Skip to content

Commit

Permalink
whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT committed Nov 15, 2024
1 parent 474191f commit 7616431
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Content.Server/Paint/PaintSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public void Paint(Entity<PaintComponent> entity, EntityUid target, EntityUid use
return;
}

if (!entity.Comp.Blacklist?.IsValid(target, EntityManager) != true || HasComp<HumanoidAppearanceComponent>(target) || HasComp<SubFloorHideComponent>(target))
if (!entity.Comp.Whitelist?.IsValid(target, EntityManager) == true
|| !entity.Comp.Blacklist?.IsValid(target, EntityManager) == false
|| HasComp<HumanoidAppearanceComponent>(target) || HasComp<SubFloorHideComponent>(target))
{
_popup.PopupEntity(Loc.GetString("paint-failure", ("target", target)), user, user, PopupType.Medium);
return;
Expand All @@ -133,7 +135,8 @@ public void Paint(Entity<PaintComponent> entity, EntityUid target, EntityUid use
{
if (!_inventory.TryGetSlotEntity(target, slot.Name, out var slotEnt)
|| HasComp<PaintedComponent>(slotEnt.Value)
|| !entity.Comp.Blacklist?.IsValid(slotEnt.Value, EntityManager) != true
|| !entity.Comp.Whitelist?.IsValid(slotEnt.Value, EntityManager) != true
|| !entity.Comp.Blacklist?.IsValid(slotEnt.Value, EntityManager) != false
|| HasComp<RandomSpriteComponent>(slotEnt.Value)
|| HasComp<HumanoidAppearanceComponent>(slotEnt.Value))
continue;
Expand All @@ -155,9 +158,10 @@ public void Paint(Entity<PaintComponent> entity, EntityUid target, EntityUid use
_popup.PopupEntity(Loc.GetString("paint-empty", ("used", entity)), user, user, PopupType.Medium);
}

public void Paint(EntityWhitelist blacklist, EntityUid target, Color color)
public void Paint(EntityWhitelist whitelist, EntityWhitelist blacklist, EntityUid target, Color color)
{
if (blacklist.IsValid(target, EntityManager))
if (!whitelist.IsValid(target, EntityManager)
|| blacklist.IsValid(target, EntityManager))
return;

EnsureComp<PaintedComponent>(target, out var paint);
Expand All @@ -171,6 +175,7 @@ public void Paint(EntityWhitelist blacklist, EntityUid target, Color color)
foreach (var slot in slotDefinitions)
{
if (!_inventory.TryGetSlotEntity(target, slot.Name, out var slotEnt)
|| !whitelist.IsValid(slotEnt.Value, EntityManager)
|| blacklist.IsValid(slotEnt.Value, EntityManager))
continue;

Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Paint/PaintComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public sealed partial class PaintComponent : Component
[DataField]
public SoundSpecifier Spray = new SoundPathSpecifier("/Audio/Effects/spray2.ogg");

[DataField, ViewVariables(VVAccess.ReadWrite)]
public EntityWhitelist? Whitelist;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public EntityWhitelist? Blacklist;

Expand Down

0 comments on commit 7616431

Please sign in to comment.