-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OnLoseBlock hook for powers and relics
- Loading branch information
Showing
5 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ain/java/com/evacipated/cardcrawl/mod/stslib/patches/bothInterfaces/OnLoseBlockPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.evacipated.cardcrawl.mod.stslib.patches.bothInterfaces; | ||
|
||
import com.evacipated.cardcrawl.mod.stslib.powers.interfaces.OnLoseBlockPower; | ||
import com.evacipated.cardcrawl.mod.stslib.relics.OnLoseBlockRelic; | ||
import com.evacipated.cardcrawl.modthespire.lib.ByRef; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch; | ||
import com.evacipated.cardcrawl.modthespire.lib.SpireReturn; | ||
import com.megacrit.cardcrawl.cards.DamageInfo; | ||
import com.megacrit.cardcrawl.core.AbstractCreature; | ||
import com.megacrit.cardcrawl.dungeons.AbstractDungeon; | ||
import com.megacrit.cardcrawl.powers.AbstractPower; | ||
import com.megacrit.cardcrawl.relics.AbstractRelic; | ||
|
||
@SpirePatch( | ||
clz=AbstractCreature.class, | ||
method="decrementBlock" | ||
) | ||
public class OnLoseBlockPatch | ||
{ | ||
public static SpireReturn<Integer> Prefix(AbstractCreature __instance, DamageInfo info, @ByRef int[] damageAmount) | ||
{ | ||
for (AbstractPower power : __instance.powers) { | ||
if (power instanceof OnLoseBlockPower) { | ||
damageAmount[0] = ((OnLoseBlockPower) power).onLoseBlock(info, damageAmount[0]); | ||
} | ||
} | ||
if (__instance.isPlayer) { | ||
for (AbstractRelic relic : AbstractDungeon.player.relics) { | ||
if (relic instanceof OnLoseBlockRelic) { | ||
damageAmount[0] = ((OnLoseBlockRelic) relic).onLoseBlock(info, damageAmount[0]); | ||
} | ||
} | ||
} | ||
|
||
return SpireReturn.Continue(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../relicInterfaces/OnReceivePowerPatch.java → ...s/bothInterfaces/OnReceivePowerPatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/com/evacipated/cardcrawl/mod/stslib/powers/interfaces/OnLoseBlockPower.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.evacipated.cardcrawl.mod.stslib.powers.interfaces; | ||
|
||
import com.megacrit.cardcrawl.cards.DamageInfo; | ||
|
||
public interface OnLoseBlockPower | ||
{ | ||
int onLoseBlock(DamageInfo info, int damageAmount); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/evacipated/cardcrawl/mod/stslib/relics/OnLoseBlockRelic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.evacipated.cardcrawl.mod.stslib.relics; | ||
|
||
import com.megacrit.cardcrawl.cards.DamageInfo; | ||
|
||
public interface OnLoseBlockRelic | ||
{ | ||
int onLoseBlock(DamageInfo info, int damageAmount); | ||
} |