Added object and crop read tile
parent
eaa626b335
commit
222a679a03
|
@ -9,7 +9,6 @@ using stardew_access.Patches;
|
||||||
using AutoHotkey.Interop;
|
using AutoHotkey.Interop;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using StardewValley.TerrainFeatures;
|
using StardewValley.TerrainFeatures;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace stardew_access
|
namespace stardew_access
|
||||||
{
|
{
|
||||||
|
@ -17,6 +16,8 @@ namespace stardew_access
|
||||||
public class MainClass : Mod
|
public class MainClass : Mod
|
||||||
{
|
{
|
||||||
private Harmony? harmony;
|
private Harmony? harmony;
|
||||||
|
private static bool isReadingTile = false;
|
||||||
|
private static Vector2 prevTile;
|
||||||
public static IMonitor? monitor;
|
public static IMonitor? monitor;
|
||||||
AutoHotkeyEngine ahk;
|
AutoHotkeyEngine ahk;
|
||||||
|
|
||||||
|
@ -115,6 +116,9 @@ namespace stardew_access
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MenuPatch.resetGlobalVars();
|
MenuPatch.resetGlobalVars();
|
||||||
|
|
||||||
|
if(!isReadingTile)
|
||||||
|
ReadTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
|
||||||
|
@ -145,33 +149,53 @@ namespace stardew_access
|
||||||
Game1.pressUseToolButton();
|
Game1.pressUseToolButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (Equals(e.Button, SButton.G))
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async void ReadTile()
|
||||||
{
|
{
|
||||||
|
isReadingTile = true;
|
||||||
if (Context.IsPlayerFree)
|
if (Context.IsPlayerFree)
|
||||||
{
|
{
|
||||||
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
|
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
|
||||||
Vector2 gt = Game1.player.GetGrabTile();
|
Vector2 gt = Game1.player.GetGrabTile();
|
||||||
|
|
||||||
StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y);
|
StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y);
|
||||||
|
if (!Equals(gt, prevTile))
|
||||||
|
{
|
||||||
|
prevTile = gt;
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
string name = obj.name;
|
||||||
|
|
||||||
if(obj != null)
|
string checkQuery = $"x:{gt.X} y:{gt.Y}";
|
||||||
monitor.Log($"obj:{obj.name}", LogLevel.Debug);
|
|
||||||
|
|
||||||
if (terrainFeature.ContainsKey(gt))
|
ScreenReader.say(name, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (terrainFeature.ContainsKey(gt))
|
||||||
{
|
{
|
||||||
Netcode.NetRef<TerrainFeature> terrain = terrainFeature[gt];
|
Netcode.NetRef<TerrainFeature> terrain = terrainFeature[gt];
|
||||||
|
|
||||||
if (terrain.Get() is HoeDirt dirt)
|
if (terrain.Get() is HoeDirt)
|
||||||
{
|
{
|
||||||
monitor.Log($"here{(terrain.Get() as HoeDirt).crop.GetType()}", LogLevel.Debug);
|
HoeDirt dirt = (HoeDirt)terrain.Get();
|
||||||
monitor.Log("here2", LogLevel.Debug);
|
if (dirt.crop != null)
|
||||||
|
{
|
||||||
|
string cropName = Game1.objectInformation[dirt.crop.indexOfHarvest];
|
||||||
|
cropName = cropName.Substring(0, cropName.IndexOf("/"));
|
||||||
|
|
||||||
|
string toSpeak = $"{cropName}";
|
||||||
|
ScreenReader.say(toSpeak, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Task.Delay(100);
|
||||||
|
isReadingTile = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue