コード例 #1
0
 /// <summary>
 /// Replace logic determining item drop-in actions on garden bed objects.
 /// </summary>
 public static bool Utility_IsThereAnObjectHereWhichAcceptsThisItem_Prefix(
     ref bool __result,
     GameLocation location,
     Item item,
     int x,
     int y)
 {
     try
     {
         Vector2 tileLocation = new Vector2(x / Game1.tileSize, y / Game1.tileSize);
         if (location.Objects.TryGetValue(tileLocation, out StardewValley.Object o) && o != null && o is OutdoorPot op)
         {
             if (!OutdoorPot.CanAcceptItemOrSeed(item: item) && OutdoorPot.CanAcceptAnything(op: op))
             {
                 __result = op.performObjectDropInAction(dropInItem: (StardewValley.Object)item, probe: true, who: Game1.player);
             }
             else
             {
                 __result = false;
             }
             return(false);
         }
     }
     catch (Exception e)
     {
         HarmonyPatches.ErrorHandler(e);
     }
     return(true);
 }
コード例 #2
0
 /// <summary>
 /// Replace logic for choosing whether objects can be placed into a custom garden bed.
 /// </summary>
 public static void GameLocation_IsTileOccupiedForPlacement_Postfix(
     GameLocation __instance,
     ref bool __result,
     Vector2 tileLocation,
     StardewValley.Object toPlace)
 {
     if (__instance.Objects.TryGetValue(tileLocation, out StardewValley.Object o) && o != null && o is OutdoorPot op)
     {
         bool isPlantable = OutdoorPot.CanAcceptItemOrSeed(toPlace) &&
                            op.hoeDirt.Value.canPlantThisSeedHere(toPlace.ParentSheetIndex, (int)tileLocation.X, (int)tileLocation.Y, toPlace.Category == -19);
         if (OutdoorPot.CanAcceptAnything(op: op) && isPlantable)
         {
             __result = false;
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Replace logic for garden bed objects being watered by sprinklers.
 /// </summary>
 public static bool Object_ApplySprinkler_Prefix(
     GameLocation location,
     Vector2 tile)
 {
     try
     {
         if (ModEntry.Config.SprinklersEnabled &&
             location.Objects.TryGetValue(tile, out StardewValley.Object o) && o != null && o is OutdoorPot op)
         {
             if (OutdoorPot.CanAcceptAnything(op: op, ignoreCrops: true))
             {
                 op.Water();
             }
             return(false);
         }
     }
     catch (Exception e)
     {
         HarmonyPatches.ErrorHandler(e);
     }
     return(true);
 }
コード例 #4
0
 /// <summary>
 /// Add logic to consider new conditions for planting seeds in garden bed objects.
 /// </summary>
 public static bool Utility_IsViableSeedSpot_Prefix(
     GameLocation location,
     Vector2 tileLocation,
     Item item)
 {
     try
     {
         if (location.Objects.TryGetValue(tileLocation, out StardewValley.Object o) && o != null && o is OutdoorPot op)
         {
             return(OutdoorPot.CanAcceptItemOrSeed(item) && OutdoorPot.CanAcceptSeed(item: item, op: op) && OutdoorPot.CanAcceptAnything(op: op));
         }
     }
     catch (Exception e)
     {
         HarmonyPatches.ErrorHandler(e);
     }
     return(true);
 }