Skip to content

Commit

Permalink
Add CanBeArranged property to OutdoorPot/ItemDefinition.
Browse files Browse the repository at this point in the history
Replace duplicated values in OutdoorPot with lambda references to their matching entry in ItemDefinitions.
Rename some methods in OutdoorPot for clarity.
Add explicit names when referencing ModEntry members from within itself for clarity.
  • Loading branch information
b-b-blueberry committed Aug 8, 2021
1 parent e169f3a commit 346f528
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 197 deletions.
12 changes: 6 additions & 6 deletions RaisedGardenBeds/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static bool Utility_IsThereAnObjectHereWhichAcceptsThisItem_Prefix(
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.IsItemPlantable(item) && op.IsOpenForPlacement())
if (!OutdoorPot.CanAcceptItemOrSeed(item: item) && OutdoorPot.CanAcceptAnything(op: op))
{
__result = op.performObjectDropInAction(dropInItem: (StardewValley.Object)item, probe: true, who: Game1.player);
}
Expand All @@ -132,7 +132,7 @@ public static bool Utility_IsViableSeedSpot_Prefix(
{
if (location.Objects.TryGetValue(tileLocation, out StardewValley.Object o) && o != null && o is OutdoorPot op)
{
if (OutdoorPot.IsItemPlantable(item) && op.CanPlantHere(item) && op.IsOpenForPlacement())
if (OutdoorPot.CanAcceptItemOrSeed(item) && OutdoorPot.CanAcceptSeed(item: item, op: op) && OutdoorPot.CanAcceptAnything(op: op))
{
return true;
}
Expand All @@ -155,7 +155,7 @@ public static bool Object_ApplySprinkler_Prefix(
if (ModEntry.Config.SprinklersEnabled
&& location.Objects.TryGetValue(tile, out StardewValley.Object o) && o != null && o is OutdoorPot op)
{
if (op.IsOpenForPlacement(ignoreCrops: true))
if (OutdoorPot.CanAcceptAnything(op: op, ignoreCrops: true))
{
op.Water();
}
Expand All @@ -180,9 +180,9 @@ public static void GameLocation_IsTileOccupiedForPlacement_Postfix(
{
if (__instance.Objects.TryGetValue(tileLocation, out StardewValley.Object o) && o != null && o is OutdoorPot op)
{
bool isPlantable = OutdoorPot.IsItemPlantable(toPlace)
bool isPlantable = OutdoorPot.CanAcceptItemOrSeed(toPlace)
&& op.hoeDirt.Value.canPlantThisSeedHere(toPlace.ParentSheetIndex, (int)tileLocation.X, (int)tileLocation.Y, toPlace.Category == -19);
if (op.IsOpenForPlacement() && isPlantable)
if (OutdoorPot.CanAcceptAnything(op: op) && isPlantable)
{
__result = false;
}
Expand All @@ -206,7 +206,7 @@ public static void CraftingPage_LayoutRecipes_Postfix(

// Sprite
pair.Key.texture = ModEntry.Sprites[ModEntry.ItemDefinitions[variantKey].SpriteKey];
pair.Key.sourceRect = OutdoorPot.GetSourceRectangle(spriteIndex: ModEntry.ItemDefinitions[variantKey].SpriteIndex);
pair.Key.sourceRect = OutdoorPot.GetSpriteSourceRectangle(spriteIndex: ModEntry.ItemDefinitions[variantKey].SpriteIndex);

// Strings
pair.Value.DisplayName = OutdoorPot.GetDisplayNameFromName(pair.Value.name);
Expand Down
4 changes: 4 additions & 0 deletions RaisedGardenBeds/ItemDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Optional entries
/// Value is not given as number of seasons the object will last to afford lenience for late placement.
/// </summary>
public int DaysToBreak { get; set; } = 0;
/// <summary>
/// Whether this object will build up with others to form large arrangements.
/// </summary>
public bool CanBeArranged { get; set; } = true;

/********************
Code-generated values
Expand Down
Loading

0 comments on commit 346f528

Please sign in to comment.