<commit_before>using System;
using System.Collections.Generic;
using System.Diagnostics;

using Behemoth.Alg;

namespace Rpg
{
  public static class Action
  {
    /// <summary>
    /// Move an entity relative to its current position.
    /// </summary>
    /// <returns>
    /// Whether moving was successful.
    /// </returns>
    public static bool MoveRel(Entity e, Vec3 delta)
    {
      var newPos = Query.Pos(e) + delta;
      var core = e.Get<CoreComponent>();
      var dir = Geom.VecToDir8(delta);

      core.Facing = (byte)dir;

      // TODO: Check here if the entity is blocked by something.

      if (!Query.CanEnter(e, newPos))
      {
        return false;
      }

      Action.Place(e, newPos);
      return true;
    }


    /// <summary>
    /// The basic method for changing the position of an entity. All entity
    /// movement should use a Place action at the bottom.
    /// </summary>
    public static void Place(Entity e, Vec3 pos)
    {
      var core = e.Get<CoreComponent>();

      // XXX: Might want to do some spatial index update stuff here.

      core.Pos = pos;
    }
  }
}<commit_msg>No longer locking character's facing when moving vertically.<commit_after>using System;
using System.Collections.Generic;
using System.Diagnostics;

using Behemoth.Alg;

namespace Rpg
{
  public static class Action
  {
    /// <summary>
    /// Move an entity relative to its current position.
    /// </summary>
    /// <returns>
    /// Whether moving was successful.
    /// </returns>
    public static bool MoveRel(Entity e, Vec3 delta)
    {
      var newPos = Query.Pos(e) + delta;
      var core = e.Get<CoreComponent>();
      var dir = Geom.VecToDir8(delta);

      // Hack: Since dirs are currently only used to flip the character icon
      // horizontally, do not impose a facing change when moving along the
      // vertical axis.

      // XXX: Remove this if facing gets any game-mechanical significance.
      if (!IsVerticalDir(dir))
      {
        core.Facing = (byte)dir;
      }

      // TODO: Check here if the entity is blocked by something.

      if (!Query.CanEnter(e, newPos))
      {
        return false;
      }

      Action.Place(e, newPos);
      return true;
    }


    /// <summary>
    /// The basic method for changing the position of an entity. All entity
    /// movement should use a Place action at the bottom.
    /// </summary>
    public static void Place(Entity e, Vec3 pos)
    {
      var core = e.Get<CoreComponent>();

      // XXX: Might want to do some spatial index update stuff here.

      core.Pos = pos;
    }


    public static bool IsVerticalDir(int dir8)
    {
      return dir8 == 0 || dir8 == 4;
    }
  }
}
{'fraction_non_alphanumeric': 0.10962962962962963, 'fraction_numerical': 0.004074074074074074, 'mean_word_length': 2.1117511520737327, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6681124', 'n_tokens_mistral': 797, 'n_tokens_neox': 768, 'n_words': 281}