]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Lasers passover objects like projectiles unless the target is clicked on (#28768)
authorCojoke <83733158+Cojoke-dot@users.noreply.github.com>
Fri, 14 Jun 2024 02:04:45 +0000 (21:04 -0500)
committerGitHub <noreply@github.com>
Fri, 14 Jun 2024 02:04:45 +0000 (12:04 +1000)
* 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>
Content.Server/Weapons/Ranged/Systems/GunSystem.cs

index cb893299a9350d59414a2db6cce023d2978d2a68..7f7c7ba8557403303938dd2acd2abae36b0eb36d 100644 (file)
@@ -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<RequireProjectileTargetComponent>(collide.HitEntity)?.Active == true)
+                                {
+                                    continue;
+                                }
+
+                                result = collide;
+                                break;
+                            }
+
                             var hit = result.HitEntity;
                             lastHit = hit;