From: Cojoke <83733158+Cojoke-dot@users.noreply.github.com> Date: Fri, 14 Jun 2024 02:04:45 +0000 (-0500) Subject: Lasers passover objects like projectiles unless the target is clicked on (#28768) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=57858cd6a558399c0ec19ffce932ed5967144eff;p=space-station-14.git 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> --- 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;