diff --git a/CustomToolEffect/CustomToolEffect.csproj b/CustomToolEffect/CustomToolEffect.csproj index fb25ed0..0fda26e 100644 --- a/CustomToolEffect/CustomToolEffect.csproj +++ b/CustomToolEffect/CustomToolEffect.csproj @@ -47,6 +47,7 @@ + diff --git a/CustomToolEffect/ModConfig.cs b/CustomToolEffect/ModConfig.cs index bdb5d36..5d4f43b 100644 --- a/CustomToolEffect/ModConfig.cs +++ b/CustomToolEffect/ModConfig.cs @@ -36,6 +36,12 @@ namespace CustomToolEffect {3, new RangeDefine(new Range(3, 3)) }, {4, new RangeDefine(new Range(5, 5)) } }; + public Dictionary BombDefine { get; set; } = new Dictionary + { + {286, new PowerDefine(1.4f) }, + {287, new PowerDefine(1.4f) }, + {288, new PowerDefine(1.5f) }, + }; public class PowerDefine { public PowerDefine(float power) diff --git a/CustomToolEffect/ModEntry.cs b/CustomToolEffect/ModEntry.cs index 5274b60..c30bf3c 100644 --- a/CustomToolEffect/ModEntry.cs +++ b/CustomToolEffect/ModEntry.cs @@ -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)) + ); + }); } } } diff --git a/CustomToolEffect/Rewrites/TemporaryAnimatedSpriteRewrites.cs b/CustomToolEffect/Rewrites/TemporaryAnimatedSpriteRewrites.cs new file mode 100644 index 0000000..3c02eed --- /dev/null +++ b/CustomToolEffect/Rewrites/TemporaryAnimatedSpriteRewrites.cs @@ -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); + } + } + } + } + } +} diff --git a/CustomToolEffect/manifest.json b/CustomToolEffect/manifest.json index b413231..d55cbcc 100644 --- a/CustomToolEffect/manifest.json +++ b/CustomToolEffect/manifest.json @@ -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", diff --git a/README.md b/README.md index 88b746a..5f3a215 100644 --- a/README.md +++ b/README.md @@ -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 |