Added buildlist command

master
Mohammad Shoaib 2022-02-03 16:42:58 +05:30
parent 547f6290c4
commit ec08f2c019
4 changed files with 16 additions and 7 deletions

View File

@ -342,9 +342,16 @@ namespace stardew_access
string toPrint = ""; string toPrint = "";
Farm farm = (Farm)Game1.getLocationFromName("Farm"); Farm farm = (Farm)Game1.getLocationFromName("Farm");
Netcode.NetCollection<Building> buildings = farm.buildings; Netcode.NetCollection<Building> buildings = farm.buildings;
int buildingIndex = 0;
for (int i = 0; i < buildings.Count; i++) for (int i = 0; i < buildings.Count; i++)
{ {
toPrint = $"{toPrint},\t{buildings[i].nameOfIndoorsWithoutUnique}: At {buildings[i].tileX}x and {buildings[i].tileY}y"; string? name = buildings[i].nameOfIndoorsWithoutUnique;
name = (name == "null") ? buildings[i].buildingType.Value : name;
BuildingNAnimalMenuPatches.availableBuildings[buildingIndex] = buildings[i];
toPrint = $"{toPrint}\nIndex {buildingIndex}: {name}: At {buildings[i].tileX}x and {buildings[i].tileY}y";
++buildingIndex;
} }
if (toPrint == "") if (toPrint == "")
@ -353,7 +360,7 @@ namespace stardew_access
} }
else else
{ {
MainClass.monitor.Log($"Available buildings: {toPrint}", LogLevel.Info); MainClass.monitor.Log($"Available buildings:{toPrint}\nOpen the command menu and use pageup and pagedown to check the list", LogLevel.Info);
} }
}); });
#endregion #endregion

View File

@ -268,7 +268,7 @@ namespace stardew_access.Game
if (Game1.currentLocation is Farm) if (Game1.currentLocation is Farm)
{ {
Building building = (Game1.currentLocation as Farm).getBuildingAt(new Vector2(x, y)); Building building = ((Farm)Game1.currentLocation).getBuildingAt(new Vector2(x, y));
if (building != null) if (building != null)
{ {
return (CATEGORY.Buildings, building.buildingType.Value); return (CATEGORY.Buildings, building.buildingType.Value);

View File

@ -1,6 +1,7 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using StardewModdingAPI; using StardewModdingAPI;
using StardewValley; using StardewValley;
using StardewValley.Buildings;
using StardewValley.Menus; using StardewValley.Menus;
namespace stardew_access.Patches namespace stardew_access.Patches
@ -8,6 +9,7 @@ namespace stardew_access.Patches
internal class BuildingNAnimalMenuPatches internal class BuildingNAnimalMenuPatches
{ {
internal static Vector2[] marked = new Vector2[10]; internal static Vector2[] marked = new Vector2[10];
internal static Building[] availableBuildings = new Building[100];
internal static string carpenterMenuQuery = ""; internal static string carpenterMenuQuery = "";
internal static bool isSayingBlueprintInfo = false; internal static bool isSayingBlueprintInfo = false;
internal static string prevBlueprintInfo = ""; internal static string prevBlueprintInfo = "";

View File

@ -25,11 +25,11 @@ namespace stardew_access.Patches
#region To narrate previous and next chat messages #region To narrate previous and next chat messages
if (isNextArrowPressed && !isChatRunning) if (isNextArrowPressed && !isChatRunning)
{ {
_ = CycleThroughChatMessages(true, ___messages); CycleThroughChatMessages(true, ___messages);
} }
else if (isPrevArrowPressed && !isChatRunning) else if (isPrevArrowPressed && !isChatRunning)
{ {
_ = CycleThroughChatMessages(false, ___messages); CycleThroughChatMessages(false, ___messages);
} }
#endregion #endregion
} }
@ -52,10 +52,9 @@ namespace stardew_access.Patches
} }
} }
private static async Task CycleThroughChatMessages(bool increase, List<ChatMessage> ___messages) private static async void CycleThroughChatMessages(bool increase, List<ChatMessage> ___messages)
{ {
isChatRunning = true; isChatRunning = true;
await Task.Delay(200);
string toSpeak = " "; string toSpeak = " ";
if (increase) if (increase)
{ {
@ -79,6 +78,7 @@ namespace stardew_access.Patches
}); });
MainClass.screenReader.Say(toSpeak, true); MainClass.screenReader.Say(toSpeak, true);
await Task.Delay(200);
isChatRunning = false; isChatRunning = false;
} }
} }