From 3a182033d1dcb6d4ecd6ec0d6f08d5d97c1c9c36 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 9 May 2021 17:23:12 -0400 Subject: [PATCH] v0.9.3: improved performance of particle effects from ConeAOEs --- .../actors/hero/abilities/warrior/Shockwave.java | 2 +- .../items/potions/exotic/PotionOfDragonsBreath.java | 2 +- .../shatteredpixeldungeon/items/wands/WandOfFireblast.java | 2 +- .../shatteredpixeldungeon/items/wands/WandOfRegrowth.java | 2 +- .../shatteredpixeldungeon/mechanics/ConeAOE.java | 6 ++++++ 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/warrior/Shockwave.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/warrior/Shockwave.java index 96645d1ac..3ca2880fa 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/warrior/Shockwave.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/warrior/Shockwave.java @@ -76,7 +76,7 @@ public class Shockwave extends ArmorAbility { Ballistica.STOP_SOLID | Ballistica.STOP_TARGET); //cast to cells at the tip, rather than all cells, better performance. - for (Ballistica ray : cone.rays){ + for (Ballistica ray : cone.outerRays){ ((MagicMissile)hero.sprite.parent.recycle( MagicMissile.class )).reset( MagicMissile.FORCE_CONE, hero.sprite, diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java index ae3551350..a1743f25e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/exotic/PotionOfDragonsBreath.java @@ -90,7 +90,7 @@ public class PotionOfDragonsBreath extends ExoticPotion { final ConeAOE cone = new ConeAOE(bolt, 6, 60, Ballistica.STOP_SOLID | Ballistica.STOP_TARGET | Ballistica.IGNORE_SOFT_SOLID); //cast to cells at the tip, rather than all cells, better performance. - for (Ballistica ray : cone.rays){ + for (Ballistica ray : cone.outerRays){ ((MagicMissile)curUser.sprite.parent.recycle( MagicMissile.class )).reset( MagicMissile.FIRE_CONE, curUser.sprite, diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java index 556f3c197..429b3179e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfFireblast.java @@ -151,7 +151,7 @@ public class WandOfFireblast extends DamageWand { Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID); //cast to cells at the tip, rather than all cells, better performance. - for (Ballistica ray : cone.rays){ + for (Ballistica ray : cone.outerRays){ ((MagicMissile)curUser.sprite.parent.recycle( MagicMissile.class )).reset( MagicMissile.FIRE_CONE, curUser.sprite, diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java index c4ed1f962..4b48bef26 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfRegrowth.java @@ -243,7 +243,7 @@ public class WandOfRegrowth extends Wand { Ballistica.STOP_SOLID | Ballistica.STOP_TARGET); //cast to cells at the tip, rather than all cells, better performance. - for (Ballistica ray : cone.rays){ + for (Ballistica ray : cone.outerRays){ ((MagicMissile)curUser.sprite.parent.recycle( MagicMissile.class )).reset( MagicMissile.FOLIAGE_CONE, curUser.sprite, diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ConeAOE.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ConeAOE.java index 9f85a98b8..5a8f15bb4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ConeAOE.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ConeAOE.java @@ -35,6 +35,7 @@ public class ConeAOE { public Ballistica coreRay; + public ArrayList outerRays = new ArrayList<>(); public ArrayList rays = new ArrayList<>(); public HashSet cells = new HashSet<>(); @@ -72,6 +73,7 @@ public class ConeAOE { float initalAngle = PointF.angle(fromP, toP)/PointF.G2R; //want to preserve order so that our collection of rays is going clockwise LinkedHashSet targetCells = new LinkedHashSet<>(); + LinkedHashSet outerCells = new LinkedHashSet<>(); //cast a ray every 0.5 degrees in a clockwise arc, to find cells along the cone's outer arc for (float a = initalAngle+degrees/2f; a >= initalAngle-degrees/2f; a-=0.5f){ @@ -83,6 +85,7 @@ public class ConeAOE { (int)GameMath.gate(0, (int)Math.floor(scan.x), Dungeon.level.width()-1), (int)GameMath.gate(0, (int)Math.floor(scan.y), Dungeon.level.height()-1)); targetCells.add(Dungeon.level.pointToCell(scanInt)); + outerCells.add(Dungeon.level.pointToCell(scanInt)); //if the cone is large enough, also cast rays to cells just inside of the outer arc // this helps fill in any holes when casting rays if (circleRadius >= 4) { @@ -103,6 +106,9 @@ public class ConeAOE { Ballistica ray = new Ballistica(core.sourcePos, c, ballisticaParams); cells.addAll(ray.subPath(1, ray.dist)); rays.add(ray); + if (outerCells.contains(c)){ + outerRays.add(ray); + } } }