+using System.Linq;
using Content.Server.Popups;
using Content.Shared.DoAfter;
using Content.Shared.IdentityManagement;
return;
}
+ // Check if we are trying to implant a implant which is already implanted
+ if (implant.HasValue && !component.AllowMultipleImplants && CheckSameImplant(target, implant.Value))
+ {
+ var name = Identity.Name(target, EntityManager, args.User);
+ var msg = Loc.GetString("implanter-component-implant-already", ("implant", implant), ("target", name));
+ _popup.PopupEntity(msg, target, args.User);
+ args.Handled = true;
+ return;
+ }
+
+
//Implant self instantly, otherwise try to inject the target.
if (args.User == target)
Implant(target, target, uid, component);
args.Handled = true;
}
+ public bool CheckSameImplant(EntityUid target, EntityUid implant)
+ {
+ if (!TryComp<ImplantedComponent>(target, out var implanted))
+ return false;
+
+ var implantPrototype = Prototype(implant);
+ return implanted.ImplantContainer.ContainedEntities.Any(entity => Prototype(entity) == implantPrototype);
+ }
+
/// <summary>
/// Attempt to implant someone else.
/// </summary>
[DataField]
public (string, string) ImplantData;
+ /// <summary>
+ /// Determines if the same type of implant can be implanted into an entity multiple times.
+ /// </summary>
+ [DataField]
+ public bool AllowMultipleImplants = false;
+
/// <summary>
/// The <see cref="ItemSlot"/> for this implanter
/// </summary>
implanter-component-implant-failed = The {$implant} cannot be given to {$target}!
implanter-draw-failed-permanent = The {$implant} in {$target} is fused with them and cannot be removed!
implanter-draw-failed = You tried to remove an implant but found nothing.
+implanter-component-implant-already = {$target} already has the {$implant}!
## UI
implanter-draw-text = Draw