From 852fae46b3667bcff335933cf10773b91c12527c Mon Sep 17 00:00:00 2001 From: SimpleStation14 <130339894+SimpleStation14@users.noreply.github.com> Date: Wed, 8 May 2024 22:45:33 -0700 Subject: [PATCH] Mirror: Fix tranq rounds injecting when reflected (#215) ## Mirror of PR #26141: [Fix tranq rounds injecting when reflected](https://github.com/space-wizards/space-station-14/pull/26141) from space-wizards [space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14) ###### `f0dfe3f6fb10e1b1f4e1a4b40c860fc0bac8427b` PR opened by Tayrtahn at 2024-03-15 13:11:00 UTC --- PR changed 2 files with 5 additions and 11 deletions. The PR had the following labels: ---

Original Body

> > > > ## About the PR > > Tranquilizer rounds no longer inject their target when they are successfully reflected. > > ## Why / Balance > > Fixes #26137 > > ## Technical details > > Changed SolutionInjectOnCollideSystem to subscribe to ProjectileHitEvent instead of StartCollideEvent. This also simplifies the logic a little and removes a component field (FixtureId), since SolutionInjectOnCollideSystem no longer has to check for fixture match or fixture hardness (these are already checked by ProjectileSystem before raising ProjectileHitEvent). > > ## Media > > > https://github.com/space-wizards/space-station-14/assets/85356/beb47792-5408-4231-ba96-97be25a96e8c > > - [X] I have added screenshots/videos to this PR showcasing its changes ingame, **or** this PR does not require an ingame showcase > > ## Breaking changes > > > **Changelog** > > > > :cl: > - fix: Reflected tranquilizer rounds no longer inject the character who reflected them.
Co-authored-by: SimpleStation14 --- .../Components/SolutionInjectOnCollideComponent.cs | 3 --- .../EntitySystems/SolutionInjectOnCollideSystem.cs | 13 +++++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs b/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs index cdba55467ae..76bb5294bce 100644 --- a/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs +++ b/Content.Server/Chemistry/Components/SolutionInjectOnCollideComponent.cs @@ -25,7 +25,4 @@ public sealed partial class SolutionInjectOnCollideComponent : Component /// [DataField("blockSlots"), ViewVariables(VVAccess.ReadWrite)] public SlotFlags BlockSlots = SlotFlags.MASK; - - [DataField] - public string FixtureId = SharedProjectileSystem.ProjectileFixture; } diff --git a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs index 0f696774ae5..fb84aca3e41 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs @@ -3,8 +3,7 @@ using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Containers.EntitySystems; using Content.Shared.Inventory; -using JetBrains.Annotations; -using Robust.Shared.Physics.Events; +using Content.Shared.Projectiles; namespace Content.Server.Chemistry.EntitySystems; @@ -17,17 +16,15 @@ public sealed class SolutionInjectOnCollideSystem : EntitySystem public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(HandleInjection); + SubscribeLocalEvent(HandleInjection); } - private void HandleInjection(Entity ent, ref StartCollideEvent args) + private void HandleInjection(Entity ent, ref ProjectileHitEvent args) { var component = ent.Comp; - var target = args.OtherEntity; + var target = args.Target; - if (!args.OtherBody.Hard || - args.OurFixtureId != ent.Comp.FixtureId || - !EntityManager.TryGetComponent(target, out var bloodstream) || + if (!TryComp(target, out var bloodstream) || !_solutionContainersSystem.TryGetInjectableSolution(ent.Owner, out var solution, out _)) { return;