Skip to content

Commit

Permalink
Fixed 2 test fails (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheArturZh authored Jul 22, 2023
1 parent 0acdd1b commit 4ecd6c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -77,14 +77,19 @@ private bool ShouldCollideThroughWall(EntityUid uid, TriggerOnProximityComponent
if (TryComp<TransformComponent>(uid, out var entTransform) &&
TryComp<TransformComponent>(args.OtherBody.Owner, out var otherTranform))
{
SharedPhysicsSystem physSystem = EntityManager.System<SharedPhysicsSystem>();
var physSystem = EntityManager.System<SharedPhysicsSystem>();

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;
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Maps/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down

0 comments on commit 4ecd6c8

Please sign in to comment.