<commit_before>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using EOLib;
using EOLib.Domain.Character;
using EOLib.Domain.Extensions;
using EOLib.Domain.NPC;

namespace EndlessClient.Rendering
{
    public class RenderOffsetCalculator : IRenderOffsetCalculator
    {
        private const int WidthFactor = 32;
        private const int HeightFactor = 16;
        private const int WalkWidthFactor = WidthFactor/4;
        private const int WalkHeightFactor = HeightFactor/4;

        public int CalculateOffsetX(ICharacterRenderProperties properties)
        {
            var multiplier = properties.IsFacing(EODirection.Left, EODirection.Down) ? -1 : 1;
            var walkAdjust = properties.IsActing(CharacterActionState.Walking) ? WalkWidthFactor * properties.WalkFrame : 0;

            //walkAdjust * multiplier is the old ViewAdjustX
            return properties.MapX*WidthFactor - properties.MapY*WidthFactor + walkAdjust*multiplier;
        }

        public int CalculateOffsetY(ICharacterRenderProperties properties)
        {
            var multiplier = properties.IsFacing(EODirection.Left, EODirection.Up) ? -1 : 1;
            var walkAdjust = properties.IsActing(CharacterActionState.Walking) ? WalkHeightFactor * properties.WalkFrame : 0;

            //walkAdjust * multiplier is the old ViewAdjustY
            return properties.MapX*HeightFactor + properties.MapY*HeightFactor + walkAdjust*multiplier;
        }

        public int CalculateOffsetX(INPC npc)
        {
            var multiplier = npc.IsFacing(EODirection.Left, EODirection.Down) ? -1 : 1;
            var walkAdjust = npc.IsActing(NPCActionState.Walking) ? WalkWidthFactor * npc.GetWalkFrame() : 0;

            //walkAdjust * multiplier is the old ViewAdjustX
            return npc.X*WidthFactor - npc.Y*WidthFactor + walkAdjust*multiplier;
        }

        public int CalculateOffsetY(INPC npc)
        {
            var multiplier = npc.IsFacing(EODirection.Left, EODirection.Down) ? -1 : 1;
            var walkAdjust = npc.IsActing(NPCActionState.Walking) ? WalkHeightFactor * npc.GetWalkFrame() : 0;

            //walkAdjust * multiplier is the old ViewAdjustY
            return npc.X*HeightFactor - npc.Y*HeightFactor + walkAdjust*multiplier;
        }
    }

    public interface IRenderOffsetCalculator
    {
        int CalculateOffsetX(ICharacterRenderProperties properties);

        int CalculateOffsetY(ICharacterRenderProperties properties);

        int CalculateOffsetX(INPC npc);

        int CalculateOffsetY(INPC npc);<commit_msg>Fix copy/paste bug in RenderOffsetCalculator<commit_after>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using EOLib;
using EOLib.Domain.Character;
using EOLib.Domain.Extensions;
using EOLib.Domain.NPC;

namespace EndlessClient.Rendering
{
    public class RenderOffsetCalculator : IRenderOffsetCalculator
    {
        private const int WidthFactor = 32;
        private const int HeightFactor = 16;
        private const int WalkWidthFactor = WidthFactor/4;
        private const int WalkHeightFactor = HeightFactor/4;

        public int CalculateOffsetX(ICharacterRenderProperties properties)
        {
            var multiplier = properties.IsFacing(EODirection.Left, EODirection.Down) ? -1 : 1;
            var walkAdjust = properties.IsActing(CharacterActionState.Walking) ? WalkWidthFactor * properties.WalkFrame : 0;

            //walkAdjust * multiplier is the old ViewAdjustX
            return properties.MapX*WidthFactor - properties.MapY*WidthFactor + walkAdjust*multiplier;
        }

        public int CalculateOffsetY(ICharacterRenderProperties properties)
        {
            var multiplier = properties.IsFacing(EODirection.Left, EODirection.Up) ? -1 : 1;
            var walkAdjust = properties.IsActing(CharacterActionState.Walking) ? WalkHeightFactor * properties.WalkFrame : 0;

            //walkAdjust * multiplier is the old ViewAdjustY
            return properties.MapX*HeightFactor + properties.MapY*HeightFactor + walkAdjust*multiplier;
        }

        public int CalculateOffsetX(INPC npc)
        {
            var multiplier = npc.IsFacing(EODirection.Left, EODirection.Down) ? -1 : 1;
            var walkAdjust = npc.IsActing(NPCActionState.Walking) ? WalkWidthFactor * npc.GetWalkFrame() : 0;

            //walkAdjust * multiplier is the old ViewAdjustX
            return npc.X*WidthFactor - npc.Y*WidthFactor + walkAdjust*multiplier;
        }

        public int CalculateOffsetY(INPC npc)
        {
            var multiplier = npc.IsFacing(EODirection.Left, EODirection.Down) ? -1 : 1;
            var walkAdjust = npc.IsActing(NPCActionState.Walking) ? WalkHeightFactor * npc.GetWalkFrame() : 0;

            //walkAdjust * multiplier is the old ViewAdjustY
            return npc.X*HeightFactor + npc.Y*HeightFactor + walkAdjust*multiplier;
        }
    }

    public interface IRenderOffsetCalculator
    {
        int CalculateOffsetX(ICharacterRenderProperties properties);

        int CalculateOffsetY(ICharacterRenderProperties properties);

        int CalculateOffsetX(INPC npc);

        int CalculateOffsetY(INPC npc);
{'fraction_non_alphanumeric': 0.07605633802816901, 'fraction_numerical': 0.010140845070422535, 'mean_word_length': 2.884755652808169, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3826671', 'n_tokens_mistral': 1530, 'n_tokens_neox': 1430, 'n_words': 355}