Generalized Store System (#10201)
This commit is contained in:
41
Content.Server/Store/Conditions/BuyerWhitelistCondition.cs
Normal file
41
Content.Server/Store/Conditions/BuyerWhitelistCondition.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Store;
|
||||
using Content.Shared.Whitelist;
|
||||
|
||||
namespace Content.Server.Store.Conditions;
|
||||
|
||||
/// <summary>
|
||||
/// Filters out an entry based on the components or tags on an entity.
|
||||
/// </summary>
|
||||
public sealed class BuyerWhitelistCondition : ListingCondition
|
||||
{
|
||||
/// <summary>
|
||||
/// A whitelist of tags or components.
|
||||
/// </summary>
|
||||
[DataField("whitelist")]
|
||||
public EntityWhitelist? Whitelist;
|
||||
|
||||
/// <summary>
|
||||
/// A blacklist of tags or components.
|
||||
/// </summary>
|
||||
[DataField("blacklist")]
|
||||
public EntityWhitelist? Blacklist;
|
||||
|
||||
public override bool Condition(ListingConditionArgs args)
|
||||
{
|
||||
var ent = args.EntityManager;
|
||||
|
||||
if (Whitelist != null)
|
||||
{
|
||||
if (!Whitelist.IsValid(args.Buyer, ent))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Blacklist != null)
|
||||
{
|
||||
if (Blacklist.IsValid(args.Buyer, ent))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user