v0.8.2d: refactored emitter freezing
This commit is contained in:
parent
7e9ac9d5c9
commit
d4968a7e01
|
@ -21,7 +21,6 @@
|
|||
|
||||
package com.watabou.noosa;
|
||||
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.utils.Random;
|
||||
import com.watabou.utils.Reflection;
|
||||
|
||||
|
@ -34,8 +33,6 @@ public class Group extends Gizmo {
|
|||
// Accessing it is a little faster,
|
||||
// than calling members.getSize()
|
||||
public int length;
|
||||
|
||||
public static boolean freezeEmitters = false;
|
||||
|
||||
public Group() {
|
||||
members = new ArrayList<>();
|
||||
|
@ -63,10 +60,7 @@ public class Group extends Gizmo {
|
|||
public synchronized void update() {
|
||||
for (int i=0; i < length; i++) {
|
||||
Gizmo g = members.get( i );
|
||||
if (g != null && g.exists && g.active
|
||||
//functionality for the freezing of emitters(particle effects), effects are given a second
|
||||
//from load to get started so they aren't frozen before anything is generated.
|
||||
&& !(freezeEmitters && Game.timeTotal > 1f && g instanceof Emitter)) {
|
||||
if (g != null && g.exists && g.active) {
|
||||
g.update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,9 +102,19 @@ public class Emitter extends Group {
|
|||
|
||||
on = true;
|
||||
}
|
||||
|
||||
public static boolean freezeEmitters = false;
|
||||
|
||||
protected boolean isFrozen(){
|
||||
return Game.timeTotal > 1 && freezeEmitters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
if (isFrozen()){
|
||||
return;
|
||||
}
|
||||
|
||||
if (on) {
|
||||
time += Game.elapsed;
|
||||
|
|
|
@ -211,7 +211,12 @@ public class MagicMissile extends Emitter {
|
|||
}
|
||||
return missile;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean isFrozen() {
|
||||
return false; //cannot be frozen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
|
|
@ -23,8 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.noosa.particles.Emitter.Factory;
|
||||
import com.watabou.noosa.particles.PixelParticle;
|
||||
|
@ -69,28 +67,20 @@ public class FlowParticle extends PixelParticle {
|
|||
am = (p < 0.5f ? p : 1 - p) * 0.6f;
|
||||
size( (1 - p) * 4 );
|
||||
}
|
||||
|
||||
public static class Flow extends Group {
|
||||
|
||||
private static final float DELAY = 0.1f;
|
||||
|
||||
public static class Flow extends Emitter {
|
||||
|
||||
private int pos;
|
||||
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
private float delay;
|
||||
|
||||
public Flow( int pos ) {
|
||||
super();
|
||||
|
||||
this.pos = pos;
|
||||
|
||||
|
||||
PointF p = DungeonTilemap.tileToWorld( pos );
|
||||
x = p.x;
|
||||
y = p.y + DungeonTilemap.SIZE - 1;
|
||||
|
||||
delay = Random.Float( DELAY );
|
||||
pos( p.x, p.y + DungeonTilemap.SIZE - 1, DungeonTilemap.SIZE, 0);
|
||||
|
||||
pour(FACTORY, 0.05f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,14 +89,7 @@ public class FlowParticle extends PixelParticle {
|
|||
if (visible = (pos < Dungeon.level.heroFOV.length && Dungeon.level.heroFOV[pos])) {
|
||||
|
||||
super.update();
|
||||
|
||||
if ((delay -= Game.elapsed) <= 0) {
|
||||
|
||||
delay = Random.Float( DELAY );
|
||||
|
||||
((FlowParticle)recycle( FlowParticle.class )).reset(
|
||||
x + Random.Float( DungeonTilemap.SIZE ), y );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.noosa.particles.Emitter.Factory;
|
||||
import com.watabou.noosa.particles.PixelParticle;
|
||||
|
@ -75,25 +73,19 @@ public class WindParticle extends PixelParticle {
|
|||
float p = left / lifespan;
|
||||
am = (p < 0.5f ? p : 1 - p) * size * 0.2f;
|
||||
}
|
||||
|
||||
public static class Wind extends Group {
|
||||
|
||||
public static class Wind extends Emitter {
|
||||
|
||||
private int pos;
|
||||
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
private float delay;
|
||||
|
||||
public Wind( int pos ) {
|
||||
super();
|
||||
|
||||
|
||||
this.pos = pos;
|
||||
PointF p = DungeonTilemap.tileToWorld( pos );
|
||||
x = p.x;
|
||||
y = p.y;
|
||||
pos(p.x, p.y, DungeonTilemap.SIZE, DungeonTilemap.SIZE);
|
||||
|
||||
delay = Random.Float( 5 );
|
||||
pour(FACTORY, 2.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,15 +94,7 @@ public class WindParticle extends PixelParticle {
|
|||
if (visible = (pos < Dungeon.level.heroFOV.length && Dungeon.level.heroFOV[pos])) {
|
||||
|
||||
super.update();
|
||||
|
||||
if ((delay -= Game.elapsed) <= 0) {
|
||||
|
||||
delay = Random.Float( 5 );
|
||||
|
||||
((WindParticle)recycle( WindParticle.class )).reset(
|
||||
x + Random.Float( DungeonTilemap.SIZE ),
|
||||
y + Random.Float( DungeonTilemap.SIZE ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
|
@ -334,25 +335,8 @@ public class TimekeepersHourglass extends Artifact {
|
|||
presses = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
if (super.attachTo(target)){
|
||||
if (Dungeon.level != null)
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
mob.sprite.add(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(){
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
if (mob.paralysed <= 0) mob.sprite.remove(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = false;
|
||||
|
||||
updateQuickslot();
|
||||
super.detach();
|
||||
activeBuff = null;
|
||||
|
@ -360,6 +344,20 @@ public class TimekeepersHourglass extends Artifact {
|
|||
target.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fx(boolean on) {
|
||||
Emitter.freezeEmitters = on;
|
||||
if (on){
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
|
||||
if (mob.sprite != null) mob.sprite.add(CharSprite.State.PARALYSED);
|
||||
}
|
||||
} else {
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
|
||||
if (mob.paralysed <= 0) mob.sprite.remove(CharSprite.State.PARALYSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String PRESSES = "presses";
|
||||
private static final String TURNSTOCOST = "turnsToCost";
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ public class SewerLevel extends RegularLevel {
|
|||
|
||||
super.update();
|
||||
|
||||
if ((rippleDelay -= Game.elapsed) <= 0) {
|
||||
if (!isFrozen() && (rippleDelay -= Game.elapsed) <= 0) {
|
||||
Ripple ripple = GameScene.ripple( pos + Dungeon.level.width() );
|
||||
if (ripple != null) {
|
||||
ripple.y -= DungeonTilemap.SIZE / 2;
|
||||
|
|
|
@ -28,10 +28,10 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -118,29 +118,26 @@ public class Swiftthistle extends Plant {
|
|||
presses = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
if (super.attachTo(target)){
|
||||
if (Dungeon.level != null)
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
mob.sprite.add(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach(){
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
|
||||
if (mob.paralysed <= 0) mob.sprite.remove(CharSprite.State.PARALYSED);
|
||||
GameScene.freezeEmitters = false;
|
||||
|
||||
super.detach();
|
||||
triggerPresses();
|
||||
target.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fx(boolean on) {
|
||||
Emitter.freezeEmitters = on;
|
||||
if (on){
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
|
||||
if (mob.sprite != null) mob.sprite.add(CharSprite.State.PARALYSED);
|
||||
}
|
||||
} else {
|
||||
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
|
||||
if (mob.paralysed <= 0) mob.sprite.remove(CharSprite.State.PARALYSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String PRESSES = "presses";
|
||||
private static final String LEFT = "left";
|
||||
|
|
|
@ -520,8 +520,8 @@ public class GameScene extends PixelScene {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
freezeEmitters = false;
|
||||
|
||||
Emitter.freezeEmitters = false;
|
||||
|
||||
scene = null;
|
||||
Badges.saveGlobal();
|
||||
|
@ -562,7 +562,7 @@ public class GameScene extends PixelScene {
|
|||
|
||||
super.update();
|
||||
|
||||
if (!freezeEmitters) water.offset( 0, -5 * Game.elapsed );
|
||||
if (!Emitter.freezeEmitters) water.offset( 0, -5 * Game.elapsed );
|
||||
|
||||
if (!Actor.processing() && Dungeon.hero.isAlive()) {
|
||||
if (actorThread == null || !actorThread.isAlive()) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user