using Content.Shared.Mind; using Content.Shared.Store; using Content.Shared.Whitelist; namespace Content.Server.Store.Conditions; /// /// Filters out an entry based on the objectives of an entity. /// public sealed partial class BuyerObjectiveWhitelistCondition : ListingCondition { /// /// A whitelist of objective types. /// If there is no whitelist, the object will appear by default. /// [DataField] public EntityWhitelist? Whitelist; /// /// A blacklist of objective types. /// If an objective is both whitelisted and blacklisted the blacklist will take priority and the entry will not appear. /// [DataField] public EntityWhitelist? Blacklist; public override bool Condition(ListingConditionArgs args) { var ent = args.EntityManager; var whitelistSystem = ent.System(); if (!args.EntityManager.TryGetComponent(args.Buyer, out var mindComp)) return true; // inanimate objects don't have minds var whitelisted = false; foreach (var objective in mindComp.Objectives) { if (whitelistSystem.IsWhitelistPass(Blacklist, objective)) return false; if (whitelistSystem.IsWhitelistPass(Whitelist, objective)) whitelisted = true; } return Whitelist == null || whitelisted; } }