Code documentation

master
Mohammad Shoaib 2022-05-11 13:14:46 +05:30
parent d27c7c749c
commit eb25243377
5 changed files with 166 additions and 116 deletions

View File

@ -6,7 +6,12 @@ namespace stardew_access.Features
internal class CurrentPlayer internal class CurrentPlayer
{ {
public static int getHealth() /// <summary>
/// Returns the percentage health remaining of player.
/// </summary>
public static int Health
{
get
{ {
if (Game1.player == null) if (Game1.player == null)
return 0; return 0;
@ -17,8 +22,14 @@ namespace stardew_access.Features
int healthPercentage = (int)(currentHealth * 100) / maxHealth; int healthPercentage = (int)(currentHealth * 100) / maxHealth;
return healthPercentage; return healthPercentage;
} }
}
public static int getStamina() /// <summary>
/// Returns the percentage stamine/energy remaining of player.
/// </summary>
public static int Stamina
{
get
{ {
if (Game1.player == null) if (Game1.player == null)
return 0; return 0;
@ -30,32 +41,56 @@ namespace stardew_access.Features
return staminaPercentage; return staminaPercentage;
} }
}
public static Vector2 getPosition() /// <summary>
/// Returns the tile location of the player
/// </summary>
public static Vector2 Position
{
get
{ {
if (Game1.player == null) if (Game1.player == null)
return Vector2.Zero; return Vector2.Zero;
return Game1.player.getTileLocation(); return Game1.player.getTileLocation();
} }
}
public static int getPositionX() /// <summary>
/// Returns the X coordinate of the player
/// </summary>
public static int PositionX
{
get
{ {
if (Game1.player == null) if (Game1.player == null)
return 0; return 0;
return (int)getPosition().X; return (int)Position.X;
}
} }
public static int getPositionY() /// <summary>
/// Returns the Y coordinate of the player
/// </summary>
public static int PositionY
{
get
{ {
if (Game1.player == null) if (Game1.player == null)
return 0; return 0;
return (int)getPosition().Y; return (int)Position.Y;
}
} }
public static string getTimeOfDay() /// <summary>
/// Returns the time in the 12 hours format
/// </summary>
public static string TimeOfDay
{
get
{ {
int timeOfDay = Game1.timeOfDay; int timeOfDay = Game1.timeOfDay;
@ -71,31 +106,45 @@ namespace stardew_access.Features
return $"{hours}:{minutes} {amOrpm}"; return $"{hours}:{minutes} {amOrpm}";
} }
public static string getSeason()
{
return Game1.CurrentSeasonDisplayName;
} }
public static int getDate() /// <summary>
{ /// Returns the current season
return Game1.dayOfMonth; /// </summary>
} public static string Season => Game1.CurrentSeasonDisplayName;
public static string getDay() /// <summary>
{ /// Returns the current date of month
return Game1.Date.DayOfWeek.ToString(); /// </summary>
} public static int Date => Game1.dayOfMonth;
public static int getMoney() /// <summary>
/// Returns the current day of week
/// </summary>
/// <returns></returns>
public static string Day => Game1.Date.DayOfWeek.ToString();
/// <summary>
/// Returns the amount of money the player has currently
/// </summary>
public static int Money
{
get
{ {
if (Game1.player == null) if (Game1.player == null)
return -1; return -1;
return Game1.player.Money; return Game1.player.Money;
} }
}
public static Vector2 getNextTile() /// <summary>
/// Returns the tile position of the tile the player is facing
/// </summary>
/// <value></value>
public static Vector2 FacingTile
{
get
{ {
int x = Game1.player.GetBoundingBox().Center.X; int x = Game1.player.GetBoundingBox().Center.X;
int y = Game1.player.GetBoundingBox().Center.Y; int y = Game1.player.GetBoundingBox().Center.Y;
@ -123,4 +172,5 @@ namespace stardew_access.Features
return new Vector2(x, y); return new Vector2(x, y);
} }
} }
}
} }

View File

@ -262,7 +262,7 @@ namespace stardew_access.Features
#region Check whether to skip the object or not #region Check whether to skip the object or not
// Skip if player is directly looking at the tile // Skip if player is directly looking at the tile
if (CurrentPlayer.getNextTile().Equals(position)) if (CurrentPlayer.FacingTile.Equals(position))
return; return;
if (!radarFocus) if (!radarFocus)

View File

@ -25,12 +25,12 @@ namespace stardew_access.Features
if (!playersPosition) if (!playersPosition)
{ {
// Grab tile // Grab tile
tile = CurrentPlayer.getNextTile(); tile = CurrentPlayer.FacingTile;
} }
else else
{ {
// Player's standing tile // Player's standing tile
tile = CurrentPlayer.getPosition(); tile = CurrentPlayer.Position;
} }
x = (int)tile.X; x = (int)tile.X;
y = (int)tile.Y; y = (int)tile.Y;

View File

@ -220,11 +220,11 @@ namespace stardew_access
string toSpeak; string toSpeak;
if (Config.VerboseCoordinates) if (Config.VerboseCoordinates)
{ {
toSpeak = $"X: {CurrentPlayer.getPositionX()}, Y: {CurrentPlayer.getPositionY()}"; toSpeak = $"X: {CurrentPlayer.PositionX}, Y: {CurrentPlayer.PositionY}";
} }
else else
{ {
toSpeak = $"{CurrentPlayer.getPositionX()}, {CurrentPlayer.getPositionY()}"; toSpeak = $"{CurrentPlayer.PositionX}, {CurrentPlayer.PositionY}";
} }
MainClass.ScreenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
@ -234,7 +234,7 @@ namespace stardew_access
// Narrate health and stamina // Narrate health and stamina
if (Config.HealthNStaminaKey.JustPressed()) if (Config.HealthNStaminaKey.JustPressed())
{ {
string toSpeak = $"Health is {CurrentPlayer.getHealth()} and Stamina is {CurrentPlayer.getStamina()}"; string toSpeak = $"Health is {CurrentPlayer.Health} and Stamina is {CurrentPlayer.Stamina}";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
return; return;
} }
@ -242,7 +242,7 @@ namespace stardew_access
// Narrate money at hand // Narrate money at hand
if (Config.MoneyKey.JustPressed()) if (Config.MoneyKey.JustPressed())
{ {
string toSpeak = $"You have {CurrentPlayer.getMoney()}g"; string toSpeak = $"You have {CurrentPlayer.Money}g";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
return; return;
} }
@ -250,7 +250,7 @@ namespace stardew_access
// Narrate time and season // Narrate time and season
if (Config.TimeNSeasonKey.JustPressed()) if (Config.TimeNSeasonKey.JustPressed())
{ {
string toSpeak = $"Time is {CurrentPlayer.getTimeOfDay()} and it is {CurrentPlayer.getDay()} {CurrentPlayer.getDate()} of {CurrentPlayer.getSeason()}"; string toSpeak = $"Time is {CurrentPlayer.TimeOfDay} and it is {CurrentPlayer.Day} {CurrentPlayer.Date} of {CurrentPlayer.Season}";
MainClass.ScreenReader.Say(toSpeak, true); MainClass.ScreenReader.Say(toSpeak, true);
return; return;
} }

View File

@ -436,7 +436,7 @@ namespace stardew_access.Patches
if (cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep") if (cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep")
{ {
Vector2 nextTile = CurrentPlayer.getNextTile(); Vector2 nextTile = CurrentPlayer.FacingTile;
if (TileInfo.isCollidingAtTile((int)nextTile.X, (int)nextTile.Y)) if (TileInfo.isCollidingAtTile((int)nextTile.X, (int)nextTile.Y))
{ {
if (prevTile != nextTile) if (prevTile != nextTile)