From 57858cd6a558399c0ec19ffce932ed5967144eff Mon Sep 17 00:00:00 2001 From: Cojoke <83733158+Cojoke-dot@users.noreply.github.com> Date: Thu, 13 Jun 2024 21:04:45 -0500 Subject: [PATCH] Lasers passover objects like projectiles unless the target is clicked on (#28768) * uh... * fix * alright, there we go * Revert "alright, there we go" This reverts commit 448180bfa58cc24c42a4d59ef34c017b9941f37b. * Make lasers not hit certain objects and lying mobs unless clicked on * comment * Update Content.Server/Weapons/Ranged/Systems/GunSystem.cs * an l vanished? --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> --- .../Weapons/Ranged/Systems/GunSystem.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index cb893299a9..7f7c7ba855 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -17,6 +17,7 @@ using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Weapons.Ranged.Systems; using Content.Shared.Weapons.Reflect; +using Content.Shared.Damage.Components; using Robust.Shared.Audio; using Robust.Shared.Map; using Robust.Shared.Physics; @@ -202,6 +203,20 @@ public sealed partial class GunSystem : SharedGunSystem break; var result = rayCastResults[0]; + + // Checks if the laser should pass over unless targeted by its user + foreach (var collide in rayCastResults) + { + if (collide.HitEntity != gun.Target && + CompOrNull(collide.HitEntity)?.Active == true) + { + continue; + } + + result = collide; + break; + } + var hit = result.HitEntity; lastHit = hit; -- 2.51.2