public override bool PushOutCollider(EHBaseCollider2D ColliderToPushOut) { EHBox2DCollider OtherRectCollier = (EHBox2DCollider)ColliderToPushOut; if (OtherRectCollier == null) { return(false); } if (RectGeometry.IsOverlappingRect(OtherRectCollier.PhysicsSweepGeometry)) { FHitData HitData = new FHitData(); HitData.OwningCollider = this; HitData.OtherCollider = ColliderToPushOut; EHBounds2D ThisCurrentBounds = RectGeometry.GetBounds(); EHBounds2D OtherCurrentBounds = OtherRectCollier.RectGeometry.GetBounds(); EHBounds2D ThisPreviousBounds = PreviousRectGeometry.GetBounds(); EHBounds2D OtherPreviousBounds = OtherRectCollier.PreviousRectGeometry.GetBounds(); Vector2 RightUpOffset = ThisCurrentBounds.MaxBounds - OtherCurrentBounds.MinBounds; Vector2 LeftBottomOffset = ThisCurrentBounds.MinBounds - OtherCurrentBounds.MaxBounds; if (ThisPreviousBounds.MaxBounds.y < OtherPreviousBounds.MinBounds.y && RightUpOffset.y > 0 && (CollisionMask & (byte)ECollisionDirection.UP) != 0) { ColliderToPushOut.transform.position += Vector3.up * RightUpOffset.y; HitData.HitDirection = Vector2.down; } else if (ThisPreviousBounds.MaxBounds.x < OtherPreviousBounds.MinBounds.x && RightUpOffset.x > 0 && (CollisionMask & (byte)ECollisionDirection.RIGHT) != 0) { ColliderToPushOut.transform.position += Vector3.right * RightUpOffset.x; HitData.HitDirection = Vector2.left; } else if (ThisPreviousBounds.MinBounds.x > OtherPreviousBounds.MaxBounds.x && LeftBottomOffset.x < 0 && (CollisionMask & (byte)ECollisionDirection.LEFT) != 0) { ColliderToPushOut.transform.position += Vector3.right * LeftBottomOffset.x; HitData.HitDirection = Vector2.right; } else if (ThisPreviousBounds.MinBounds.y > OtherPreviousBounds.MaxBounds.y && LeftBottomOffset.y < 0 && (CollisionMask & (byte)ECollisionDirection.DOWN) != 0) { ColliderToPushOut.transform.position += Vector3.up * LeftBottomOffset.y; HitData.HitDirection = Vector2.up; } if (!ContainOverlappingCollider(ColliderToPushOut) || MatchesOverlappingHitData(ColliderToPushOut, ref HitData)) { AddColliderToHitSet(ColliderToPushOut, HitData); } HitCollisionStay(ColliderToPushOut, HitData); return(true); } return(false); }
public override bool IsOverlappingRect2DSweep(EHRect2D Rect) { if (ColliderType == EColliderType.PHYSICS) { return(PhysicsSweepGeometry.IsOverlappingRect(Rect)); } return(false); }
protected override bool IsHitboxOverlapping(EHHitbox OtherHitbox) { switch (OtherHitbox.GetHitbxoShape()) { case EHGeometry.ShapeType.Rect2D: return(RectGeometry.IsOverlappingRect(((EHHitboxRect)OtherHitbox).RectGeometry)); } return(false); }