﻿namespace JLGames.RocketDriver.Actions.Component2D
{
    public static class Sortable2D
    {
        public static float ToZ(float minZ, float sizeZ, float xOrY, bool asc)
        {
            var value = (xOrY - float.MinValue) * 0.5f / float.MaxValue * sizeZ + minZ;
            return asc ? value : sizeZ + minZ - value;
        }

        public static float ToZ(float minz, float sizeZ, float first, float second, bool ase)
        {
            var firstVal = ToZ(minz + sizeZ, sizeZ, first, true);
            var secondVal = ToZ(minz, sizeZ, second, true);
            var value = (firstVal + second) * 0.5f / sizeZ + minz;
            return ase ? value : minz + sizeZ - value;
        }

        public enum SortMode
        {
            X,
            Y,
            YX,
            XY
        }

        public enum RefreshMode
        {
            SiblingIndex,
            ZIndex
        }
    }
}