2018-03-30 20:46:24 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace StardustCore.Enums
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A custom class used to wrap Stardew Valley's direction conventions.
|
|
|
|
|
/// </summary>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public class Directions
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// An enum used to wrap directions.
|
|
|
|
|
/// </summary>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public enum Direction
|
|
|
|
|
{
|
|
|
|
|
[Description("Up")]
|
|
|
|
|
up,
|
|
|
|
|
[Description("Right")]
|
|
|
|
|
right,
|
|
|
|
|
[Description("Down")]
|
|
|
|
|
down,
|
|
|
|
|
[Description("Left")]
|
|
|
|
|
left
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the up direction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public static Direction GetUp()
|
|
|
|
|
{
|
|
|
|
|
return Direction.up;
|
|
|
|
|
}
|
2018-05-01 09:21:31 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the down direction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public static Direction GetDown()
|
|
|
|
|
{
|
|
|
|
|
return Direction.down;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the left direction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public static Direction GetLeft()
|
|
|
|
|
{
|
|
|
|
|
return Direction.left;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the right dirction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public static Direction GetRight()
|
|
|
|
|
{
|
|
|
|
|
return Direction.right;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Converts a direction into it's stardew valley direction equivelent.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dir"></param>
|
|
|
|
|
/// <returns></returns>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public static int DirectionToInt(Direction dir)
|
|
|
|
|
{
|
|
|
|
|
return (int)dir;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get's the direction's enum description so we can convert this to a string.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dir"></param>
|
|
|
|
|
/// <returns></returns>
|
2018-03-30 20:46:24 +08:00
|
|
|
|
public static string getString(Direction dir)
|
|
|
|
|
{
|
|
|
|
|
return dir.GetEnumDescription();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|