AddComponentSpecial.cs 651 B

12345678910111213141516171819202122
  1. using Content.Shared.Roles;
  2. using Robust.Shared.Prototypes;
  3. namespace Content.Server.Jobs;
  4. public sealed partial class AddComponentSpecial : JobSpecial
  5. {
  6. [DataField(required: true)]
  7. public ComponentRegistry Components { get; private set; } = new();
  8. /// <summary>
  9. /// If this is true then existing components will be removed and replaced with these ones.
  10. /// </summary>
  11. [DataField]
  12. public bool RemoveExisting = true;
  13. public override void AfterEquip(EntityUid mob)
  14. {
  15. var entMan = IoCManager.Resolve<IEntityManager>();
  16. entMan.AddComponents(mob, Components, removeExisting: RemoveExisting);
  17. }
  18. }