Code documentation
This commit is contained in:
		| @@ -6,121 +6,171 @@ namespace stardew_access.Features | ||||
|     internal class CurrentPlayer | ||||
|     { | ||||
|  | ||||
|         public static int getHealth() | ||||
|         /// <summary> | ||||
|         /// Returns the percentage health remaining of player. | ||||
|         /// </summary> | ||||
|         public static int Health | ||||
|         { | ||||
|             if (Game1.player == null) | ||||
|                 return 0; | ||||
|  | ||||
|             int maxHealth = Game1.player.maxHealth; | ||||
|             int currentHealth = Game1.player.health; | ||||
|  | ||||
|             int healthPercentage = (int)(currentHealth * 100) / maxHealth; | ||||
|             return healthPercentage; | ||||
|         } | ||||
|  | ||||
|         public static int getStamina() | ||||
|         { | ||||
|             if (Game1.player == null) | ||||
|                 return 0; | ||||
|  | ||||
|             int maxStamina = Game1.player.maxStamina.Value; | ||||
|             int currentStamine = (int)Game1.player.stamina; | ||||
|  | ||||
|             int staminaPercentage = (int)(currentStamine * 100) / maxStamina; | ||||
|  | ||||
|             return staminaPercentage; | ||||
|         } | ||||
|  | ||||
|         public static Vector2 getPosition() | ||||
|         { | ||||
|             if (Game1.player == null) | ||||
|                 return Vector2.Zero; | ||||
|  | ||||
|             return Game1.player.getTileLocation(); | ||||
|         } | ||||
|  | ||||
|         public static int getPositionX() | ||||
|         { | ||||
|             if (Game1.player == null) | ||||
|                 return 0; | ||||
|  | ||||
|             return (int)getPosition().X; | ||||
|         } | ||||
|  | ||||
|         public static int getPositionY() | ||||
|         { | ||||
|             if (Game1.player == null) | ||||
|                 return 0; | ||||
|  | ||||
|             return (int)getPosition().Y; | ||||
|         } | ||||
|  | ||||
|         public static string getTimeOfDay() | ||||
|         { | ||||
|             int timeOfDay = Game1.timeOfDay; | ||||
|  | ||||
|             int minutes = timeOfDay % 100; | ||||
|             int hours = timeOfDay / 100; | ||||
|             string amOrpm = "A M"; | ||||
|             if (hours >= 12) | ||||
|             get | ||||
|             { | ||||
|                 amOrpm = "P M"; | ||||
|                 if (hours > 12) | ||||
|                     hours -= 12; | ||||
|                 if (Game1.player == null) | ||||
|                     return 0; | ||||
|  | ||||
|                 int maxHealth = Game1.player.maxHealth; | ||||
|                 int currentHealth = Game1.player.health; | ||||
|  | ||||
|                 int healthPercentage = (int)(currentHealth * 100) / maxHealth; | ||||
|                 return healthPercentage; | ||||
|             } | ||||
|  | ||||
|             return $"{hours}:{minutes} {amOrpm}"; | ||||
|         } | ||||
|  | ||||
|         public static string getSeason() | ||||
|         /// <summary> | ||||
|         /// Returns the percentage stamine/energy remaining of player. | ||||
|         /// </summary> | ||||
|         public static int Stamina | ||||
|         { | ||||
|             return Game1.CurrentSeasonDisplayName; | ||||
|         } | ||||
|  | ||||
|         public static int getDate() | ||||
|         { | ||||
|             return Game1.dayOfMonth; | ||||
|         } | ||||
|  | ||||
|         public static string getDay() | ||||
|         { | ||||
|             return Game1.Date.DayOfWeek.ToString(); | ||||
|         } | ||||
|  | ||||
|         public static int getMoney() | ||||
|         { | ||||
|             if (Game1.player == null) | ||||
|                 return -1; | ||||
|  | ||||
|             return Game1.player.Money; | ||||
|         } | ||||
|  | ||||
|         public static Vector2 getNextTile() | ||||
|         { | ||||
|             int x = Game1.player.GetBoundingBox().Center.X; | ||||
|             int y = Game1.player.GetBoundingBox().Center.Y; | ||||
|  | ||||
|             int offset = 64; | ||||
|  | ||||
|             switch (Game1.player.FacingDirection) | ||||
|             get | ||||
|             { | ||||
|                 case 0: | ||||
|                     y -= offset; | ||||
|                     break; | ||||
|                 case 1: | ||||
|                     x += offset; | ||||
|                     break; | ||||
|                 case 2: | ||||
|                     y += offset; | ||||
|                     break; | ||||
|                 case 3: | ||||
|                     x -= offset; | ||||
|                     break; | ||||
|             } | ||||
|                 if (Game1.player == null) | ||||
|                     return 0; | ||||
|  | ||||
|             x /= Game1.tileSize; | ||||
|             y /= Game1.tileSize; | ||||
|             return new Vector2(x, y); | ||||
|                 int maxStamina = Game1.player.maxStamina.Value; | ||||
|                 int currentStamine = (int)Game1.player.stamina; | ||||
|  | ||||
|                 int staminaPercentage = (int)(currentStamine * 100) / maxStamina; | ||||
|  | ||||
|                 return staminaPercentage; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Returns the tile location of the player | ||||
|         /// </summary> | ||||
|         public static Vector2 Position | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 if (Game1.player == null) | ||||
|                     return Vector2.Zero; | ||||
|  | ||||
|                 return Game1.player.getTileLocation(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Returns the X coordinate of the player | ||||
|         /// </summary> | ||||
|         public static int PositionX | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 if (Game1.player == null) | ||||
|                     return 0; | ||||
|  | ||||
|                 return (int)Position.X; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Returns the Y coordinate of the player | ||||
|         /// </summary> | ||||
|         public static int PositionY | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 if (Game1.player == null) | ||||
|                     return 0; | ||||
|  | ||||
|                 return (int)Position.Y; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Returns the time in the 12 hours format | ||||
|         /// </summary> | ||||
|         public static string TimeOfDay | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 int timeOfDay = Game1.timeOfDay; | ||||
|  | ||||
|                 int minutes = timeOfDay % 100; | ||||
|                 int hours = timeOfDay / 100; | ||||
|                 string amOrpm = "A M"; | ||||
|                 if (hours >= 12) | ||||
|                 { | ||||
|                     amOrpm = "P M"; | ||||
|                     if (hours > 12) | ||||
|                         hours -= 12; | ||||
|                 } | ||||
|  | ||||
|                 return $"{hours}:{minutes} {amOrpm}"; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Returns the current season | ||||
|         /// </summary> | ||||
|         public static string Season => Game1.CurrentSeasonDisplayName; | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Returns the current date of month | ||||
|         /// </summary> | ||||
|         public static int Date => Game1.dayOfMonth; | ||||
|  | ||||
|         /// <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) | ||||
|                     return -1; | ||||
|  | ||||
|                 return Game1.player.Money; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <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 y = Game1.player.GetBoundingBox().Center.Y; | ||||
|  | ||||
|                 int offset = 64; | ||||
|  | ||||
|                 switch (Game1.player.FacingDirection) | ||||
|                 { | ||||
|                     case 0: | ||||
|                         y -= offset; | ||||
|                         break; | ||||
|                     case 1: | ||||
|                         x += offset; | ||||
|                         break; | ||||
|                     case 2: | ||||
|                         y += offset; | ||||
|                         break; | ||||
|                     case 3: | ||||
|                         x -= offset; | ||||
|                         break; | ||||
|                 } | ||||
|  | ||||
|                 x /= Game1.tileSize; | ||||
|                 y /= Game1.tileSize; | ||||
|                 return new Vector2(x, y); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -262,7 +262,7 @@ namespace stardew_access.Features | ||||
|             #region Check whether to skip the object or not | ||||
|  | ||||
|             // Skip if player is directly looking at the tile | ||||
|             if (CurrentPlayer.getNextTile().Equals(position)) | ||||
|             if (CurrentPlayer.FacingTile.Equals(position)) | ||||
|                 return; | ||||
|  | ||||
|             if (!radarFocus) | ||||
|   | ||||
| @@ -25,12 +25,12 @@ namespace stardew_access.Features | ||||
|                 if (!playersPosition) | ||||
|                 { | ||||
|                     // Grab tile | ||||
|                     tile = CurrentPlayer.getNextTile(); | ||||
|                     tile = CurrentPlayer.FacingTile; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     // Player's standing tile | ||||
|                     tile = CurrentPlayer.getPosition(); | ||||
|                     tile = CurrentPlayer.Position; | ||||
|                 } | ||||
|                 x = (int)tile.X; | ||||
|                 y = (int)tile.Y; | ||||
|   | ||||
| @@ -220,11 +220,11 @@ namespace stardew_access | ||||
|                 string toSpeak; | ||||
|                 if (Config.VerboseCoordinates) | ||||
|                 { | ||||
|                     toSpeak = $"X: {CurrentPlayer.getPositionX()}, Y: {CurrentPlayer.getPositionY()}"; | ||||
|                     toSpeak = $"X: {CurrentPlayer.PositionX}, Y: {CurrentPlayer.PositionY}"; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     toSpeak = $"{CurrentPlayer.getPositionX()}, {CurrentPlayer.getPositionY()}"; | ||||
|                     toSpeak = $"{CurrentPlayer.PositionX}, {CurrentPlayer.PositionY}"; | ||||
|                 } | ||||
|  | ||||
|                 MainClass.ScreenReader.Say(toSpeak, true); | ||||
| @@ -234,7 +234,7 @@ namespace stardew_access | ||||
|             // Narrate health and stamina | ||||
|             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); | ||||
|                 return; | ||||
|             } | ||||
| @@ -242,7 +242,7 @@ namespace stardew_access | ||||
|             // Narrate money at hand | ||||
|             if (Config.MoneyKey.JustPressed()) | ||||
|             { | ||||
|                 string toSpeak = $"You have {CurrentPlayer.getMoney()}g"; | ||||
|                 string toSpeak = $"You have {CurrentPlayer.Money}g"; | ||||
|                 MainClass.ScreenReader.Say(toSpeak, true); | ||||
|                 return; | ||||
|             } | ||||
| @@ -250,7 +250,7 @@ namespace stardew_access | ||||
|             // Narrate time and season | ||||
|             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); | ||||
|                 return; | ||||
|             } | ||||
|   | ||||
| @@ -436,7 +436,7 @@ namespace stardew_access.Patches | ||||
|  | ||||
|                 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 (prevTile != nextTile) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user