Skip to content

Commit

Permalink
I guess?
Browse files Browse the repository at this point in the history
  • Loading branch information
atravita-mods committed Oct 30, 2022
1 parent ce3f9bc commit bc070bb
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions MoonMisadventures/Patches/Necklaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public static class InventoryPageNecklaceHoverPatch
{
public static void Postfix( InventoryPage __instance, int x, int y, ref Item ___hoveredItem, ref string ___hoverText, ref string ___hoverTitle )
{
var necklaceSlot = __instance.equipmentIcons.First( cc => cc.myID == 123450101 );
var necklaceSlot = __instance.equipmentIcons.FirstOrDefault( cc => cc.myID == 123450101 );

if (necklaceSlot is null)
return;

if ( necklaceSlot.containsPoint( x, y ) && Game1.player.get_necklaceItem().Value != null )
{
var necklaceItem = Game1.player.get_necklaceItem().Value;
Expand All @@ -56,7 +60,10 @@ public static class InventoryPageNecklaceLeftClickPatch
{
public static bool Prefix( InventoryPage __instance, int x, int y )
{
var necklaceSlot = __instance.equipmentIcons.First( cc => cc.myID == 123450101 );
var necklaceSlot = __instance.equipmentIcons.FirstOrDefault( cc => cc.myID == 123450101 );

if (necklaceSlot is null)
return true;
if ( necklaceSlot.containsPoint( x, y ) )
{
var necklaceItem = Game1.player.get_necklaceItem();
Expand Down Expand Up @@ -94,7 +101,11 @@ public static void Postfix( InventoryPage __instance, SpriteBatch b, Item ___hov
if (___hoveredItem != null && ___hoveredItem != Game1.player.get_necklaceItem().Value)
return;

var necklaceSlot = __instance.equipmentIcons.First( cc => cc.myID == 123450101 );
var necklaceSlot = __instance.equipmentIcons.FirstOrDefault( cc => cc.myID == 123450101 );

if (necklaceSlot is null)
return;

if ( Game1.player.get_necklaceItem().Value != null )
{
b.Draw( Game1.menuTexture, necklaceSlot.bounds, Game1.getSourceRectForStandardTileSheet( Game1.menuTexture, 10 ), Color.White );
Expand All @@ -116,13 +127,13 @@ private static void OnFeatureAdded( Vector2 key, TerrainFeature value )
hd.state.Value = HoeDirt.watered;
}

public static void Prefix( Hoe __instance, GameLocation location, Farmer who )
public static void Prefix(GameLocation location, Farmer who )
{
if ( who.HasNecklace( Necklace.Type.Water ) )
location.terrainFeatures.OnValueAdded += OnFeatureAdded;
}

public static void Postfix( Hoe __instance, GameLocation location, Farmer who )
public static void Postfix(GameLocation location, Farmer who )
{
if ( who.HasNecklace( Necklace.Type.Water ) )
location.terrainFeatures.OnValueAdded -= OnFeatureAdded;
Expand Down

0 comments on commit bc070bb

Please sign in to comment.