Add bomb support
This commit is contained in:
parent
98cb63b6fb
commit
35a5a1d422
|
@ -47,6 +47,7 @@
|
|||
<Compile Include="ModConfig.cs" />
|
||||
<Compile Include="ModEntry.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Rewrites\TemporaryAnimatedSpriteRewrites.cs" />
|
||||
<Compile Include="Rewrites\ResourceClumpRewrites.cs" />
|
||||
<Compile Include="Rewrites\PickaxeRewrites.cs" />
|
||||
<Compile Include="Rewrites\FruitTreeRewrites.cs" />
|
||||
|
|
|
@ -36,6 +36,12 @@ namespace CustomToolEffect
|
|||
{3, new RangeDefine(new Range(3, 3)) },
|
||||
{4, new RangeDefine(new Range(5, 5)) }
|
||||
};
|
||||
public Dictionary<int, PowerDefine> BombDefine { get; set; } = new Dictionary<int, PowerDefine>
|
||||
{
|
||||
{286, new PowerDefine(1.4f) },
|
||||
{287, new PowerDefine(1.4f) },
|
||||
{288, new PowerDefine(1.5f) },
|
||||
};
|
||||
public class PowerDefine
|
||||
{
|
||||
public PowerDefine(float power)
|
||||
|
|
|
@ -35,6 +35,13 @@ namespace CustomToolEffect
|
|||
original: AccessTools.DeclaredMethod(typeof(Tool), "tilesAffected"),
|
||||
prefix: new HarmonyMethod(typeof(ToolRewrites.TilesAffectedRewrite), nameof(ToolRewrites.TilesAffectedRewrite.Prefix))
|
||||
);
|
||||
AccessTools.GetDeclaredConstructors(typeof(TemporaryAnimatedSprite)).ForEach(ctor =>
|
||||
{
|
||||
harmony.Patch(
|
||||
original: ctor,
|
||||
postfix: new HarmonyMethod(typeof(ToolRewrites.TilesAffectedRewrite), nameof(TemporaryAnimatedSpriteRewrites.ConstructorRewrite.Postfix))
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
using CustomToolEffect;
|
||||
using Microsoft.Xna.Framework;
|
||||
using StardewValley;
|
||||
using StardewValley.TerrainFeatures;
|
||||
using StardewValley.Tools;
|
||||
using System;
|
||||
|
||||
namespace StardewModdingAPI.Mods.CustomLocalization.Rewrites
|
||||
{
|
||||
public class TemporaryAnimatedSpriteRewrites
|
||||
{
|
||||
public class ConstructorRewrite
|
||||
{
|
||||
public static void Postfix(TemporaryAnimatedSprite __instance)
|
||||
{
|
||||
if(__instance.bombRadius > 0)
|
||||
{
|
||||
if (ModEntry.ModConfig.BombDefine.TryGetValue(__instance.initialParentTileIndex, out ModConfig.PowerDefine define))
|
||||
{
|
||||
if (define.Power < 0)
|
||||
{
|
||||
define.Power = 1f;
|
||||
}
|
||||
__instance.bombRadius = (int)(__instance.bombRadius * define.Power);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"Name": "Custom Tool Effect",
|
||||
"Author": "ZaneYork",
|
||||
"Version": "1.0.2",
|
||||
"Version": "1.1.0",
|
||||
"Description": "Custom tool effect range and power",
|
||||
"UniqueID": "ZaneYork.CustomToolEffect",
|
||||
"EntryDll": "CustomToolEffect.dll",
|
||||
|
|
|
@ -11,6 +11,7 @@ Mod's config file instructions:
|
|||
| PickaxeDefine | Define an pickaxe's effect |
|
||||
| HoeDefine | Define an hoe's effect |
|
||||
| WateringCanDefine | Define an watering can's effect |
|
||||
| BombDefine | Define an bomb's effect, id as key(286 Cherry Bomb/287 Bomb/288 Mega Bomb) |
|
||||
| Power | The power of this tool when break items, 1.3 means modify to 130% of the origin power |
|
||||
| Range.Length | The length of effect range |
|
||||
| Range.Width | The width of effect range |
|
||||
|
|
Loading…
Reference in New Issue