v3.3.0: improved how Goo's sprite emitters handle Goo being pushed
This commit is contained in:
@@ -43,6 +43,9 @@ public class GooSprite extends MobSprite {
|
||||
private Animation pumpAttack;
|
||||
|
||||
private Emitter spray;
|
||||
|
||||
private int pumpUpEmitterDist = 0;
|
||||
private int lastPumpUpPos = -1;
|
||||
private ArrayList<Emitter> pumpUpEmitters = new ArrayList<>();
|
||||
|
||||
public GooSprite() {
|
||||
@@ -88,20 +91,27 @@ public class GooSprite extends MobSprite {
|
||||
}
|
||||
|
||||
public void pumpUp( int warnDist ) {
|
||||
if (warnDist == 0){
|
||||
clearEmitters();
|
||||
} else {
|
||||
pumpUpEmitterDist = warnDist;
|
||||
if (warnDist > 0){
|
||||
play(pump);
|
||||
Sample.INSTANCE.play( Assets.Sounds.CHARGEUP, 1f, warnDist == 1 ? 0.8f : 1f );
|
||||
if (ch.fieldOfView == null || ch.fieldOfView.length != Dungeon.level.length()){
|
||||
}
|
||||
updateEmitters();
|
||||
}
|
||||
|
||||
public void updateEmitters( ){
|
||||
clearEmitters();
|
||||
if (pumpUpEmitterDist > 0 && ch != null) {
|
||||
lastPumpUpPos = ch.pos;
|
||||
if (ch.fieldOfView == null || ch.fieldOfView.length != Dungeon.level.length()) {
|
||||
ch.fieldOfView = new boolean[Dungeon.level.length()];
|
||||
Dungeon.level.updateFieldOfView( ch, ch.fieldOfView );
|
||||
Dungeon.level.updateFieldOfView(ch, ch.fieldOfView);
|
||||
}
|
||||
for (int i = 0; i < Dungeon.level.length(); i++){
|
||||
for (int i = 0; i < Dungeon.level.length(); i++) {
|
||||
if (ch.fieldOfView != null && ch.fieldOfView[i]
|
||||
&& Dungeon.level.distance(i, ch.pos) <= warnDist
|
||||
&& new Ballistica( ch.pos, i, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == i
|
||||
&& new Ballistica( i, ch.pos, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == ch.pos){
|
||||
&& Dungeon.level.distance(i, ch.pos) <= pumpUpEmitterDist
|
||||
&& new Ballistica(ch.pos, i, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == i
|
||||
&& new Ballistica(i, ch.pos, Ballistica.STOP_TARGET | Ballistica.STOP_SOLID | Ballistica.IGNORE_SOFT_SOLID).collisionPos == ch.pos) {
|
||||
Emitter e = CellEmitter.get(i);
|
||||
e.pour(GooParticle.FACTORY, 0.04f);
|
||||
pumpUpEmitters.add(e);
|
||||
@@ -122,6 +132,7 @@ public class GooSprite extends MobSprite {
|
||||
e.burst(ElmoParticle.FACTORY, 10);
|
||||
}
|
||||
Sample.INSTANCE.play( Assets.Sounds.BURNING );
|
||||
pumpUpEmitterDist = 0;
|
||||
pumpUpEmitters.clear();
|
||||
}
|
||||
|
||||
@@ -130,6 +141,7 @@ public class GooSprite extends MobSprite {
|
||||
@Override
|
||||
public void play(Animation anim) {
|
||||
if (anim != pump && anim != pumpAttack){
|
||||
pumpUpEmitterDist = 0;
|
||||
clearEmitters();
|
||||
}
|
||||
super.play(anim);
|
||||
@@ -151,6 +163,9 @@ public class GooSprite extends MobSprite {
|
||||
spray.pos(center());
|
||||
spray.visible = visible;
|
||||
}
|
||||
if (pumpUpEmitterDist > 0 && ch != null && ch.pos != lastPumpUpPos){
|
||||
updateEmitters();
|
||||
}
|
||||
}
|
||||
|
||||
public static class GooParticle extends PixelParticle.Shrinking {
|
||||
|
||||
Reference in New Issue
Block a user