Make all implants unable to be implanted more than once (#26250)
* Make mind shield implants unable to be implanted more than once * Default AllowMultipleImplants to false and update implanters.yml * Use TryComp instead of TryGetComponent * Deny multiple implants for fun implants too. * Make comment more precise
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Linq;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
@@ -57,6 +58,17 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
|||||||
return;
|
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.
|
//Implant self instantly, otherwise try to inject the target.
|
||||||
if (args.User == target)
|
if (args.User == target)
|
||||||
Implant(target, target, uid, component);
|
Implant(target, target, uid, component);
|
||||||
@@ -67,6 +79,15 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
|||||||
args.Handled = true;
|
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>
|
/// <summary>
|
||||||
/// Attempt to implant someone else.
|
/// Attempt to implant someone else.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ public sealed partial class ImplanterComponent : Component
|
|||||||
[DataField]
|
[DataField]
|
||||||
public (string, string) ImplantData;
|
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>
|
/// <summary>
|
||||||
/// The <see cref="ItemSlot"/> for this implanter
|
/// The <see cref="ItemSlot"/> for this implanter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ implanter-component-implanting-target = {$user} is trying to implant you with so
|
|||||||
implanter-component-implant-failed = The {$implant} cannot be given to {$target}!
|
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-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-draw-failed = You tried to remove an implant but found nothing.
|
||||||
|
implanter-component-implant-already = {$target} already has the {$implant}!
|
||||||
|
|
||||||
## UI
|
## UI
|
||||||
implanter-draw-text = Draw
|
implanter-draw-text = Draw
|
||||||
|
|||||||
Reference in New Issue
Block a user