Skip to content

Commit

Permalink
Mirror 26250: Make all implants unable to be implanted more than once (
Browse files Browse the repository at this point in the history
…#445)

## Mirror of PR #26250: [Make all implants unable to be implanted more
than once](space-wizards/space-station-14#26250)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `771390bb6741074935e5f24c0aa9c87bc7b5ad09`

PR opened by <img
src="https://avatars.githubusercontent.com/u/63975668?v=4"
width="16"/><a href="https://github.com/Simyon264"> Simyon264</a> at
2024-03-19 00:44:21 UTC - merged at 2024-03-26 00:16:19 UTC

---

PR changed 3 files with 28 additions and 0 deletions.

The PR had the following labels:
- Status: Needs Review


---

<details open="true"><summary><h1>Original Body</h1></summary>

> <!-- Please read these guidelines before opening your PR:
https://docs.spacestation14.io/en/getting-started/pr-guideline -->
> <!-- The text between the arrows are comments - they will not be
visible on your PR. -->
> 
> ## About the PR
> This PR makes mind shields unable to be implanted more than once.
> ## Why / Balance
> <!-- Why was it changed? Link any discussions or issues here. Please
discuss how this would affect game balance. -->
> PJB complained and people waste implants by injecting already injected
people.
> 
> ## Technical details
> <!-- If this is a code change, summarize at high level how your new
code works. This makes it easier to review. -->
> Adds a new datafield to the Implanter component which is checked in
implanter system.
> 
> ## Media
> <!-- 
> PRs which make ingame changes (adding clothing, items, new features,
etc) are required to have media attached that showcase the changes.
> Small fixes/refactors are exempt.
> Any media may be used in SS14 progress reports, with clear credit
given.
> 
> If you're unsure whether your PR will require media, ask a maintainer.
> 
> Check the box below to confirm that you have in fact seen this (put an
X in the brackets, like [X]):
> -->
>
![image](https://github.com/space-wizards/space-station-14/assets/63975668/4907ddb2-de2f-490c-a35d-07c4f3b6c79b)
> 
> - [x] I have added screenshots/videos to this PR showcasing its
changes ingame, **or** this PR does not require an ingame showcase
> 
> ## Breaking changes
> <!--
> List any breaking changes, including namespace, public
class/method/field changes, prototype renames; and provide instructions
for fixing them. This will be pasted in #codebase-changes.
> -->
> N/A
> 
> **Changelog**
> <!--
> Make players aware of new features and changes that could affect how
they play the game by adding a Changelog entry. Please read the
Changelog guidelines located at:
https://docs.spacestation14.io/en/getting-started/pr-guideline#changelog
> -->
> 
> 🆑 Simyon
> - tweak: All implants are now unable to be implanted more than once.
> 


</details>

Co-authored-by: SimpleStation14 <Unknown>
  • Loading branch information
SimpleStation14 authored Jun 20, 2024
1 parent d42cd67 commit 4b8036c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
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>
/// 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>
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

0 comments on commit 4b8036c

Please sign in to comment.