-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatcher.cs
52 lines (48 loc) · 1.72 KB
/
Patcher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using Harmony;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using StardewValley;
using Microsoft.Xna.Framework;
namespace SDVX3
{
class Patcher
{
public static void InstallPatches()
{
var harmony = HarmonyInstance.Create("avarisc.sdvx3");
harmony.PatchAll(Assembly.GetCallingAssembly());
}
//patch: Farmer.showHoldingItem for SimpleItem support
class Patch_Farmer_ShowHoldingItem
{
[HarmonyTargetMethod]
static MethodInfo getTargetMethod()
{
return typeof(StardewValley.Farmer).GetMethod("showHoldingItem");
}
[HarmonyPrefix]
public static bool showHoldingItemPrefix(ref StardewValley.Farmer who)
{
if(who.mostRecentlyGrabbedItem is SimpleObject)
{
//item sprite
var tas = (who.mostRecentlyGrabbedItem as SimpleObject).getTemporarySpriteForAnimation(who);
Game1.currentLocation.temporarySprites.Add(tas);
//poof
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(10, who.position + new Vector2((float)(Game1.tileSize / 2), (float)(-(float)Game1.tileSize * 3 / 2)), Color.White, 8, false, 100f, 0, -1, -1f, -1, 0)
{
motion = new Vector2(0f, -0.1f)
});
return false; //we have handled it ourselves
} else
{
return true; //run the original method
}
}
}
}
}