Skip to content

Commit

Permalink
TinyGreenHouse
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Angel Padilla Abrego committed Jun 2, 2024
1 parent 06168e7 commit e471745
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
3 changes: 1 addition & 2 deletions BetterJunimos/BetterJunimos.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterJunimos", "BetterJunimos.csproj", "{0F382ADA-3DBB-4309-A020-8CF5326E8709}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterJunimosForestry", "BetterJunimosForestry\BetterJunimosForestry.csproj", "{754179AA-634E-473C-A40A-B1B59B5ADA2D}"
EndProject

Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
8 changes: 4 additions & 4 deletions BetterJunimos/Patches/JunimoHarvesterPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public static bool Prefix(JunimoHarvester __instance, ref int ___harvestTimer, r

int time;
var junimoAbility = Util.Abilities.IdentifyJunimoAbility(__instance.currentLocation, pos, id);
if (__instance.currentLocation.IsGreenhouse)
{
BetterJunimos.SMonitor.Log($"PatchTryToHarvestHere , Is greenhouse but {__instance.controller.pathToEndPoint != null} | {junimoAbility}", LogLevel.Debug);
// if (__instance.currentLocation.IsGreenhouse)
// {
// BetterJunimos.SMonitor.Log($"PatchTryToHarvestHere , Is greenhouse but {__instance.controller.pathToEndPoint != null} | {junimoAbility}", LogLevel.Debug);

}
// }
if (junimoAbility != null) {
// if (__instance.currentLocation.IsGreenhouse) {
// BetterJunimos.SMonitor.Log(
Expand Down
1 change: 1 addition & 0 deletions BetterJunimos/Patches/JunimoHutPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ private static bool SearchAroundHut(JunimoHut hut) {
var gh = Game1.getLocationFromName("Greenhouse");
if (ghb != null)
{
BetterJunimos.SMonitor.Log($"SearchAroundHut: Greenhouse find on location {hut.GetParentLocation().NameOrUniqueName}", LogLevel.Debug);
gh = ghb.GetIndoors();
}

Expand Down
15 changes: 15 additions & 0 deletions BetterJunimos/Utils/JunimoGreenhouse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Threading;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewValley;
Expand All @@ -25,6 +26,20 @@ public bool HutHasGreenhouse(Guid id) {
internal static GreenhouseBuilding GreenhouseBuildingAtPos(GameLocation location, Vector2 tile) {
if (!location.IsBuildableLocation()) return null;
foreach (var building in location.buildings) {
if (building.HasIndoors() && (building.GetIndoors()?.IsGreenhouse ?? false))
{
if (building is not GreenhouseBuilding)
{
var ghb = building as GreenhouseBuilding;
if (ghb != null)
{
if (ghb.occupiesTile(tile)) {
return ghb;
}
}
BetterJunimos.SMonitor.Log($"{building.GetIndoors()?.NameOrUniqueName} {(building as GreenhouseBuilding)?.parentLocationName}", LogLevel.Debug);
}
}
if (building is not GreenhouseBuilding greenhouseBuilding) continue;
if (greenhouseBuilding.occupiesTile(tile)) {
return greenhouseBuilding;
Expand Down

0 comments on commit e471745

Please sign in to comment.