PlayerStateData ResolveStaticCollision(FGRectCollider nextFrame, FGRectCollider other, Vector2 velocity)
    {
        PlayerStateData resolutionState = new PlayerStateData();

        if (Collides(nextFrame, other))
        {
            Vector2 overlap = CheckRectCollision(nextFrame.GetRect(), velocity, other.GetRect());
            ResolveCollision(ref resolutionState, overlap);
        }
        return(resolutionState);
    }
    public Hitbox GetFrameHitbox(FGRectCollider playerCollider)
    {
        if (_currentKeyFrame.hitBox != null)
        {
            float originalSizeToWorldSizeX = _layerRenderers[0].GetComponent <RectTransform>().rect.size.x / _currentKeyFrame.sprite.rect.size.x;
            float originalSizeToWorldSizeY = _layerRenderers[0].GetComponent <RectTransform>().rect.size.y / _currentKeyFrame.sprite.rect.size.y;

            Vector2 editorToWorld = new Vector2(originalSizeToWorldSizeX, originalSizeToWorldSizeY);

            Rect hb = new Rect(_currentKeyFrame.hitBox.position * editorToWorld, _currentKeyFrame.hitBox.size * editorToWorld);



            Hitbox worldSpaceHitbox;
            if (_reversed)
            {
                Vector2 currentSpriteBottomRight = new Vector2(playerCollider.GetRect().position.x + playerCollider.GetRect().size.x, playerCollider.GetRect().position.y);
                currentSpriteBottomRight = new Vector2(currentSpriteBottomRight.x - _originalOffset.x, currentSpriteBottomRight.y);
                //Debug.DrawLine(currentSpriteBottomRight, currentSpriteBottomRight + -Vector2.one * 1000, Color.blue, 1000000);

                //update the position because the point must remain on the top left while being on opposite side
                hb.position = new Vector2(-hb.position.x - hb.size.x, hb.position.y);

                worldSpaceHitbox = new Hitbox(currentSpriteBottomRight + hb.position, hb.size, _animations[_currentAnimation].attackData, _player);
            }
            else
            {
                Vector2 currentSpriteBottomLeft = new Vector2(playerCollider.GetRect().position.x, playerCollider.GetRect().position.y);
                currentSpriteBottomLeft = new Vector2(currentSpriteBottomLeft.x + _originalOffset.x, currentSpriteBottomLeft.y);
                //Debug.DrawLine(currentSpriteBottomLeft, currentSpriteBottomLeft + Vector2.one * 1000, Color.blue, 1000000);
                worldSpaceHitbox = new Hitbox(currentSpriteBottomLeft + hb.position, hb.size, _animations[_currentAnimation].attackData, _player);
            }


            return(worldSpaceHitbox);
        }
        return(null);
        //Hitbox hitbox = new Hitbox(hb.position, hb, _animations[_currentAnimation].attackData);
    }
    public void AddDebugCollider(FGRectCollider collider)
    {
        Rect r = collider.GetRect();

        Vector3 topLeft     = new Vector2(r.position.x, r.position.y + r.size.y);
        Vector3 bottomLeft  = new Vector2(r.position.x, r.position.y);
        Vector3 topRight    = new Vector2(r.position.x + r.size.x, r.position.y + r.size.y);
        Vector3 bottomRight = new Vector2(r.position.x + r.size.x, r.position.y);

        DrawRectRequest rect = new DrawRectRequest();

        rect.topLeft     = topLeft;
        rect.topRight    = topRight;
        rect.bottomLeft  = bottomLeft;
        rect.bottomRight = bottomRight;
        rect.color       = _colors[collider.type];

        _rectStack.Add(rect);
    }
 public static bool Collides(FGRectCollider first, FGRectCollider other)
 {
     return(first.GetRect().Overlaps(other.GetRect(), true));
 }