From 4ecd6c855e8f560e6207a35c23f87ebf336541ca Mon Sep 17 00:00:00 2001 From: Artur Date: Sat, 22 Jul 2023 16:44:43 +0300 Subject: [PATCH] Fixed 2 test fails (#123) --- .../EntitySystems/TriggerSystem.Proximity.cs | 11 ++++++++--- Resources/Prototypes/Maps/core.yml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.Proximity.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.Proximity.cs index 6fbbd4c2641184..b16231a1d90221 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.Proximity.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.Proximity.cs @@ -68,7 +68,7 @@ private void OnMapInit(EntityUid uid, TriggerOnProximityComponent component, Map collisionLayer: component.Layer); } - private bool ShouldCollideThroughWall(EntityUid uid, TriggerOnProximityComponent component,ref StartCollideEvent args) + private bool ShouldCollideThroughWall(EntityUid uid, TriggerOnProximityComponent component, ref StartCollideEvent args) { if (component.TriggerBehindWall) return true; @@ -77,14 +77,19 @@ private bool ShouldCollideThroughWall(EntityUid uid, TriggerOnProximityComponent if (TryComp(uid, out var entTransform) && TryComp(args.OtherBody.Owner, out var otherTranform)) { - SharedPhysicsSystem physSystem = EntityManager.System(); + var physSystem = EntityManager.System(); var startPos = otherTranform.MapPosition.Position; var endPos = entTransform.MapPosition.Position; float distance = (startPos - endPos).Length(); + var direction = (endPos - startPos).Normalized(); - var rayRes = physSystem.IntersectRay(otherTranform.MapID, new CollisionRay(startPos, (endPos - startPos).Normalized(), (int)CollisionGroup.Impassable), distance/2).ToList(); + // If entity that caused activation is so close that direction becomes non-1, we assume that it can collide + if (!MathHelper.CloseToPercent(direction.LengthSquared(), 1)) + return true; + + var rayRes = physSystem.IntersectRay(otherTranform.MapID, new CollisionRay(startPos, direction, (int)CollisionGroup.Impassable), distance/2).ToList(); if (!rayRes.Any()) return true; diff --git a/Resources/Prototypes/Maps/core.yml b/Resources/Prototypes/Maps/core.yml index 47559f9300b0c8..743af3ce066395 100644 --- a/Resources/Prototypes/Maps/core.yml +++ b/Resources/Prototypes/Maps/core.yml @@ -41,7 +41,7 @@ Chaplain: [ 1, 1 ] Warden: [ 1, 1 ] Librarian: [ 1, 1 ] - Lawyer: [ 2, 2 ] + IAA: [ 1, 1 ] Quartermaster: [ 1, 1 ] SalvageSpecialist: [ 3, 3 ] Musician: [ 1, 1 ]