Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix StepTrigger error #8480

Merged
merged 6 commits into from
May 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Content.Shared/StepTrigger/StepTriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ public override void Update(float frameTime)

private bool Update(StepTriggerComponent component)
{
if (component.Deleted || !component.Active || component.Colliding.Count == 0)
if (component.Deleted ||
!component.Active ||
component.Colliding.Count == 0 ||
!TryComp<TransformComponent>(component.Owner, out var ownerTransform))
return true;


foreach (var otherUid in component.Colliding.ToArray())
{
if (!otherUid.IsValid())
if (!otherUid.IsValid() || !TryComp<TransformComponent>(otherUid, out var otherTransform))
{
component.Colliding.Remove(otherUid);
component.CurrentlySteppedOn.Remove(otherUid);
Expand All @@ -43,8 +47,8 @@ private bool Update(StepTriggerComponent component)
}

// TODO: This shouldn't be calculating based on world AABBs.
var ourAabb = _entityLookup.GetWorldAABB(component.Owner);
var otherAabb = _entityLookup.GetWorldAABB(otherUid);
var ourAabb = _entityLookup.GetWorldAABB(component.Owner, ownerTransform);
var otherAabb = _entityLookup.GetWorldAABB(otherUid, otherTransform);

if (!TryComp(otherUid, out PhysicsComponent? otherPhysics) || !ourAabb.Intersects(otherAabb))
{
Expand Down