Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all implants unable to be implanted more than once #26250

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Content.Server/Implants/ImplanterSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Popups;
using Content.Shared.DoAfter;
using Content.Shared.IdentityManagement;
Expand Down Expand Up @@ -57,6 +58,17 @@ private void OnImplanterAfterInteract(EntityUid uid, ImplanterComponent componen
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);
Expand All @@ -67,6 +79,15 @@ private void OnImplanterAfterInteract(EntityUid uid, ImplanterComponent componen
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>
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Implants/Components/ImplanterComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ public sealed partial class ImplanterComponent : Component
[DataField]
public (string, string) ImplantData;

/// <summary>
/// If the <see cref="Implant"/> is already implanted, should it be allowed to be implanted again?
/// </summary>
[DataField]
public bool AllowMultipleImplants = false;

/// <summary>
/// The <see cref="ItemSlot"/> for this implanter
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/implant/implant.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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-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
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Entities/Objects/Misc/implanters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
components:
- type: Implanter
implant: SadTromboneImplant
allowMultipleImplants: true # WOMP WOMP

- type: entity
id: LightImplanter
Expand All @@ -139,6 +140,7 @@
components:
- type: Implanter
implant: LightImplant
allowMultipleImplants: true # ok this might be a bad idea. How to win against your enemies? Crash their game with 50 lights!

- type: entity
id: BikeHornImplanter
Expand All @@ -147,6 +149,7 @@
components:
- type: Implanter
implant: BikeHornImplant
allowMultipleImplants: true # This implant can be implanted multiple times HONK HONK

#Security implanters

Expand Down
Loading