Example #1
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type)
        {
            int vWidth; int vHeight;

            IntRange vBounds;

            try { vBounds = Def_Extensions.CropVertical((graphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + graphic.path + "_east", ex); }

            //Plants only care for verts
            //This is assuming PLANTS TAKE UP A FULL TILE!!
            // TODO : Refactor
            if (type == GraphicType.Plant)
            {
                return(new Vector2(
                           1f,
                           (float)(vBounds.max - vBounds.min) / (float)vHeight));
            }

            int hWidth; int hHeight;

            IntRange hBounds;

            try { hBounds = Def_Extensions.CropHorizontal((graphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + graphic.path + "_south", ex); }

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }
Example #2
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset)
        {
            int vWidth; int vHeight;

            IntRange vBounds;

            try { vBounds = Def_Extensions.CropVertical((graphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + graphic.path + "_east", ex); }

            int hWidth; int hHeight;

            IntRange hBounds;

            try { hBounds = Def_Extensions.CropHorizontal((graphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + graphic.path + "_south", ex); }

            int vWidthHead; int vHeightHead;

            IntRange vBoundsHead;

            try { vBoundsHead = Def_Extensions.CropVertical((headGraphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidthHead, out vHeightHead), vWidthHead, vHeightHead); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + headGraphic.path + "_east", ex); }

            vBoundsHead.min -= (int)(headOffset.y * (float)vHeightHead);
            vBoundsHead.max -= (int)(headOffset.y * (float)vHeightHead);

            vBounds.min = Math.Min(vBounds.min, (int)((float)vBoundsHead.min * (float)vHeight / (float)vHeightHead));
            vBounds.max = Math.Max(vBounds.max, (int)((float)vBoundsHead.max * (float)vHeight / (float)vHeightHead));

            int hWidthHead; int hHeightHead;

            IntRange hBoundsHead;

            try { hBoundsHead = Def_Extensions.CropHorizontal((headGraphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidthHead, out hHeightHead), hWidthHead, hHeightHead); }
            catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + headGraphic.path + "_south", ex); }

            hBoundsHead.min += (int)(headOffset.x * (float)hWidthHead);
            hBoundsHead.max += (int)(headOffset.x * (float)hWidthHead);

            hBounds.max = Math.Max(hBounds.max, (int)((float)hBoundsHead.max * (float)hWidth / (float)hWidthHead));
            hBounds.min = Math.Min(hBounds.min, (int)((float)hBoundsHead.min * (float)hWidth / (float)hWidthHead));

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }
Example #3
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type)
        {
            int vWidth; int vHeight;

            var vBounds = Def_Extensions.CropVertical((graphic.MatSide.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight);

            //Plants only care for verts
            //This is assuming PLANTS TAKE UP A FULL TILE!!
            // TODO : Refactor
            if (type == GraphicType.Plant)
            {
                return(new Vector2(
                           1f,
                           (float)(vBounds.max - vBounds.min) / (float)vHeight));
            }

            int hWidth; int hHeight;

            var hBounds = Def_Extensions.CropHorizontal((graphic.MatFront.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight);

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }
Example #4
0
        private static Vector2 ExtractBounds(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset)
        {
            int vWidth; int vHeight;

            var vBounds = Def_Extensions.CropVertical((graphic.MatSide.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight);

            int hWidth; int hHeight;

            var hBounds = Def_Extensions.CropHorizontal((graphic.MatFront.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight);

            int vWidthHead; int vHeightHead;

            var vTexHead    = headGraphic.MatSide.mainTexture as Texture2D;
            var vBoundsHead = Def_Extensions.CropVertical(vTexHead.GetColorSafe(out vWidthHead, out vHeightHead), vWidthHead, vHeightHead);

            vBoundsHead.min += (int)(headOffset.y * (float)vHeightHead);
            vBoundsHead.max += (int)(headOffset.y * (float)vHeightHead);

            vBounds.max = Math.Max(vBounds.max, (int)((float)vBoundsHead.max * (float)vHeight / (float)vHeightHead));
            vBounds.min = Math.Min(vBounds.min, (int)((float)vBoundsHead.min * (float)vHeight / (float)vHeightHead));

            int hWidthHead; int hHeightHead;

            var hTexHead    = headGraphic.MatFront.mainTexture as Texture2D;
            var hBoundsHead = Def_Extensions.CropVertical(hTexHead.GetColorSafe(out hWidthHead, out hHeightHead), hWidthHead, hHeightHead);

            hBoundsHead.min += (int)(headOffset.x * (float)hWidthHead);
            hBoundsHead.max += (int)(headOffset.x * (float)hWidthHead);

            hBounds.max = Math.Max(hBounds.max, (int)((float)hBoundsHead.max * (float)hWidth / (float)hWidthHead));
            hBounds.min = Math.Min(hBounds.min, (int)((float)hBoundsHead.min * (float)hWidth / (float)hWidthHead));

            return(new Vector2(
                       (float)(hBounds.max - hBounds.min) / (float)hWidth,
                       (float)(vBounds.max - vBounds.min) / (float)vHeight));
        }