StoreWhitelistCondition.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Content.Shared.Store;
  2. using Content.Shared.Whitelist;
  3. namespace Content.Server.Store.Conditions;
  4. /// <summary>
  5. /// Filters out an entry based on the components or tags on the store itself.
  6. /// </summary>
  7. public sealed partial class StoreWhitelistCondition : ListingCondition
  8. {
  9. /// <summary>
  10. /// A whitelist of tags or components.
  11. /// </summary>
  12. [DataField("whitelist")]
  13. public EntityWhitelist? Whitelist;
  14. /// <summary>
  15. /// A blacklist of tags or components.
  16. /// </summary>
  17. [DataField("blacklist")]
  18. public EntityWhitelist? Blacklist;
  19. public override bool Condition(ListingConditionArgs args)
  20. {
  21. if (args.StoreEntity == null)
  22. return false;
  23. var ent = args.EntityManager;
  24. var whitelistSystem = ent.System<EntityWhitelistSystem>();
  25. if (whitelistSystem.IsWhitelistFail(Whitelist, args.StoreEntity.Value) ||
  26. whitelistSystem.IsBlacklistPass(Blacklist, args.StoreEntity.Value))
  27. return false;
  28. return true;
  29. }
  30. }