Issue#45 Update buildlist on start of day
- also removed calling restrictions from buildlist command, it can now be called from any locationmaster
parent
9d9b5f5c76
commit
dccbf8b79f
|
@ -11,6 +11,7 @@ namespace stardew_access
|
||||||
{
|
{
|
||||||
internal static void Initialize()
|
internal static void Initialize()
|
||||||
{
|
{
|
||||||
|
//TODO organise this, create separate method for all commands
|
||||||
IModHelper? helper = MainClass.ModHelper;
|
IModHelper? helper = MainClass.ModHelper;
|
||||||
if (helper == null)
|
if (helper == null)
|
||||||
return;
|
return;
|
||||||
|
@ -349,35 +350,7 @@ namespace stardew_access
|
||||||
|
|
||||||
helper.ConsoleCommands.Add("buildlist", "List all buildings for selection for upgrading/demolishing/painting", (string commmand, string[] args) =>
|
helper.ConsoleCommands.Add("buildlist", "List all buildings for selection for upgrading/demolishing/painting", (string commmand, string[] args) =>
|
||||||
{
|
{
|
||||||
if ((Game1.activeClickableMenu is not CarpenterMenu && Game1.activeClickableMenu is not PurchaseAnimalsMenu && Game1.activeClickableMenu is not AnimalQueryMenu) || !BuildingNAnimalMenuPatches.isOnFarm)
|
onBuildListCalled();
|
||||||
{
|
|
||||||
MainClass.InfoLog($"Cannot list buildings.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string toPrint = "";
|
|
||||||
Farm farm = (Farm)Game1.getLocationFromName("Farm");
|
|
||||||
Netcode.NetCollection<Building> buildings = farm.buildings;
|
|
||||||
int buildingIndex = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < buildings.Count; i++)
|
|
||||||
{
|
|
||||||
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 == "")
|
|
||||||
{
|
|
||||||
MainClass.InfoLog("No appropriate buildings to list");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MainClass.InfoLog($"Available buildings:{toPrint}\nOpen command menu and use pageup and pagedown to check the list");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
helper.ConsoleCommands.Add("buildsel", "Select the building index which you want to upgrade/demolish/paint", (string commmand, string[] args) =>
|
helper.ConsoleCommands.Add("buildsel", "Select the building index which you want to upgrade/demolish/paint", (string commmand, string[] args) =>
|
||||||
|
@ -531,6 +504,33 @@ namespace stardew_access
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void onBuildListCalled()
|
||||||
|
{
|
||||||
|
string toPrint = "";
|
||||||
|
Farm farm = (Farm)Game1.getLocationFromName("Farm");
|
||||||
|
Netcode.NetCollection<Building> buildings = farm.buildings;
|
||||||
|
int buildingIndex = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < buildings.Count; i++)
|
||||||
|
{
|
||||||
|
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 == "")
|
||||||
|
{
|
||||||
|
MainClass.InfoLog("No appropriate buildings to list");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainClass.InfoLog($"Available buildings:{toPrint}\nOpen command menu and use pageup and pagedown to check the list");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace stardew_access
|
||||||
{
|
{
|
||||||
#region Global Vars & Properties
|
#region Global Vars & Properties
|
||||||
#pragma warning disable CS8603
|
#pragma warning disable CS8603
|
||||||
|
private static int prevDate = -99;
|
||||||
private static ModConfig? config;
|
private static ModConfig? config;
|
||||||
private Harmony? harmony;
|
private Harmony? harmony;
|
||||||
private static IMonitor? monitor;
|
private static IMonitor? monitor;
|
||||||
|
@ -27,6 +28,7 @@ namespace stardew_access
|
||||||
|
|
||||||
internal static ModConfig Config { get => config; set => config = value; }
|
internal static ModConfig Config { get => config; set => config = value; }
|
||||||
public static IModHelper? ModHelper { get => modHelper; }
|
public static IModHelper? ModHelper { get => modHelper; }
|
||||||
|
|
||||||
public static StaticTiles STiles
|
public static StaticTiles STiles
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -190,6 +192,16 @@ namespace stardew_access
|
||||||
Other.narrateHudMessages();
|
Other.narrateHudMessages();
|
||||||
Task.Delay(300).ContinueWith(_ => { isNarratingHudMessage = false; });
|
Task.Delay(300).ContinueWith(_ => { isNarratingHudMessage = false; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Game1.player != null)
|
||||||
|
{
|
||||||
|
if (Game1.timeOfDay >= 600 && prevDate != CurrentPlayer.Date)
|
||||||
|
{
|
||||||
|
prevDate = CurrentPlayer.Date;
|
||||||
|
DebugLog("Refreshing buildlist...");
|
||||||
|
CustomCommands.onBuildListCalled();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnButtonPressed(object? sender, ButtonPressedEventArgs? e)
|
private void OnButtonPressed(object? sender, ButtonPressedEventArgs? e)
|
||||||
|
|
Loading…
Reference in New Issue