<commit_before>﻿using Roguelike.Entities.Commands;
using Roguelike.Input;
using Roguelike.States;
using RogueSharp;
using System.Linq;

namespace Roguelike.Entities.Components
{
    public class PlayerInputComponent : ActorComponent
    {
        private Path currentPath;

        public override Command GetCommand()
        {
            if (currentPath != null)
            {
                if (Program.Entities.Any(e => e != Entity && Program.Map.IsInFov(e.X, e.Y)) || InputManager.LastCommand == InputAction.ClickMove)
                {
                    currentPath = null;
                    return null;
                }

                var destination = currentPath.StepForward();

                if (!Program.Map.CanEnter(destination.X, destination.Y))
                {
                    currentPath = null;
                    return null;
                }

                var x = destination.X - Entity.X;
                var y = destination.Y - Entity.Y;

                if (destination == currentPath.End)
                {
                    currentPath = null;
                }

                return new MoveCommand(x, y);
            }
            else
            {
                switch (InputManager.LastCommand)
                {
                    case InputAction.MoveEast:
                        return new MoveCommand(1, 0);<commit_msg>Only living entities stop player from following path.<commit_after>﻿using Roguelike.Entities.Commands;
using Roguelike.Input;
using Roguelike.States;
using RogueSharp;
using System.Linq;

namespace Roguelike.Entities.Components
{
    public class PlayerInputComponent : ActorComponent
    {
        private Path currentPath;

        public override Command GetCommand()
        {
            if (currentPath != null)
            {
                if (Program.Entities.Any(e => e != Entity && e.HasComponent<ActorComponent>() && Program.Map.IsInFov(e.X, e.Y)) || InputManager.LastCommand == InputAction.ClickMove)
                {
                    currentPath = null;
                    return null;
                }

                var destination = currentPath.StepForward();

                if (!Program.Map.CanEnter(destination.X, destination.Y))
                {
                    currentPath = null;
                    return null;
                }

                var x = destination.X - Entity.X;
                var y = destination.Y - Entity.Y;

                if (destination == currentPath.End)
                {
                    currentPath = null;
                }

                return new MoveCommand(x, y);
            }
            else
            {
                switch (InputManager.LastCommand)
                {
                    case InputAction.MoveEast:
                        return new MoveCommand(1, 0);
{'fraction_non_alphanumeric': 0.0823943661971831, 'fraction_numerical': 0.0014084507042253522, 'mean_word_length': 1.2911290322580644, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '1087116', 'n_tokens_mistral': 713, 'n_tokens_neox': 658, 'n_words': 155}