Polymorph.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. using Content.Server.Polymorph.Components;
  2. using Content.Server.Polymorph.Systems;
  3. using Content.Shared.EntityEffects;
  4. using Content.Shared.Polymorph;
  5. using Robust.Shared.Prototypes;
  6. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  7. namespace Content.Server.EntityEffects.Effects;
  8. public sealed partial class Polymorph : EntityEffect
  9. {
  10. /// <summary>
  11. /// What polymorph prototype is used on effect
  12. /// </summary>
  13. [DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer<PolymorphPrototype>))]
  14. public string PolymorphPrototype { get; set; }
  15. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  16. => Loc.GetString("reagent-effect-guidebook-make-polymorph",
  17. ("chance", Probability), ("entityname",
  18. prototype.Index<EntityPrototype>(prototype.Index<PolymorphPrototype>(PolymorphPrototype).Configuration.Entity).Name));
  19. public override void Effect(EntityEffectBaseArgs args)
  20. {
  21. var entityManager = args.EntityManager;
  22. var uid = args.TargetEntity;
  23. var polySystem = entityManager.System<PolymorphSystem>();
  24. // Make it into a prototype
  25. entityManager.EnsureComponent<PolymorphableComponent>(uid);
  26. polySystem.PolymorphEntity(uid, PolymorphPrototype);
  27. }
  28. }