EntityWhitelistCondition.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Content.Shared.Construction.EntitySystems;
  2. using Content.Shared.Whitelist;
  3. using Robust.Shared.Map;
  4. using Robust.Shared.Utility;
  5. namespace Content.Shared.Construction.Conditions;
  6. /// <summary>
  7. /// A check to see if the entity itself can be crafted.
  8. /// </summary>
  9. [DataDefinition]
  10. public sealed partial class EntityWhitelistCondition : IConstructionCondition
  11. {
  12. /// <summary>
  13. /// What is told to the player attempting to construct the recipe using this condition. This will be localised.
  14. /// </summary>
  15. [DataField("conditionString")]
  16. public string ConditionString = "construction-step-condition-entity-whitelist";
  17. /// <summary>
  18. /// The icon shown to the player beside the condition string.
  19. /// </summary>
  20. [DataField("conditionIcon")]
  21. public SpriteSpecifier? ConditionIcon = null;
  22. /// <summary>
  23. /// The whitelist that allows only certain entities to use this.
  24. /// </summary>
  25. [DataField("whitelist", required: true)]
  26. public EntityWhitelist Whitelist = new();
  27. public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
  28. {
  29. var whitelistSystem = IoCManager.Resolve<IEntityManager>().System<EntityWhitelistSystem>();
  30. return whitelistSystem.IsWhitelistPass(Whitelist, user);
  31. }
  32. public ConstructionGuideEntry GenerateGuideEntry()
  33. {
  34. return new ConstructionGuideEntry
  35. {
  36. Localization = ConditionString,
  37. Icon = ConditionIcon
  38. };
  39. }
  40. }