v0.8.2d: refactored emitter freezing
This commit is contained in:
parent
7e9ac9d5c9
commit
d4968a7e01
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
package com.watabou.noosa;
|
package com.watabou.noosa;
|
||||||
|
|
||||||
import com.watabou.noosa.particles.Emitter;
|
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
import com.watabou.utils.Reflection;
|
import com.watabou.utils.Reflection;
|
||||||
|
|
||||||
|
@ -35,8 +34,6 @@ public class Group extends Gizmo {
|
||||||
// than calling members.getSize()
|
// than calling members.getSize()
|
||||||
public int length;
|
public int length;
|
||||||
|
|
||||||
public static boolean freezeEmitters = false;
|
|
||||||
|
|
||||||
public Group() {
|
public Group() {
|
||||||
members = new ArrayList<>();
|
members = new ArrayList<>();
|
||||||
length = 0;
|
length = 0;
|
||||||
|
@ -63,10 +60,7 @@ public class Group extends Gizmo {
|
||||||
public synchronized void update() {
|
public synchronized void update() {
|
||||||
for (int i=0; i < length; i++) {
|
for (int i=0; i < length; i++) {
|
||||||
Gizmo g = members.get( i );
|
Gizmo g = members.get( i );
|
||||||
if (g != null && g.exists && g.active
|
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)) {
|
|
||||||
g.update();
|
g.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,9 +103,19 @@ public class Emitter extends Group {
|
||||||
on = true;
|
on = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean freezeEmitters = false;
|
||||||
|
|
||||||
|
protected boolean isFrozen(){
|
||||||
|
return Game.timeTotal > 1 && freezeEmitters;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
|
|
||||||
|
if (isFrozen()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
time += Game.elapsed;
|
time += Game.elapsed;
|
||||||
while (time > interval) {
|
while (time > interval) {
|
||||||
|
|
|
@ -212,6 +212,11 @@ public class MagicMissile extends Emitter {
|
||||||
return missile;
|
return missile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isFrozen() {
|
||||||
|
return false; //cannot be frozen
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
|
|
@ -23,8 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
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;
|
||||||
import com.watabou.noosa.particles.Emitter.Factory;
|
import com.watabou.noosa.particles.Emitter.Factory;
|
||||||
import com.watabou.noosa.particles.PixelParticle;
|
import com.watabou.noosa.particles.PixelParticle;
|
||||||
|
@ -70,27 +68,19 @@ public class FlowParticle extends PixelParticle {
|
||||||
size( (1 - p) * 4 );
|
size( (1 - p) * 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Flow extends Group {
|
public static class Flow extends Emitter {
|
||||||
|
|
||||||
private static final float DELAY = 0.1f;
|
|
||||||
|
|
||||||
private int pos;
|
private int pos;
|
||||||
|
|
||||||
private float x;
|
|
||||||
private float y;
|
|
||||||
|
|
||||||
private float delay;
|
|
||||||
|
|
||||||
public Flow( int pos ) {
|
public Flow( int pos ) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
|
|
||||||
PointF p = DungeonTilemap.tileToWorld( pos );
|
PointF p = DungeonTilemap.tileToWorld( pos );
|
||||||
x = p.x;
|
pos( p.x, p.y + DungeonTilemap.SIZE - 1, DungeonTilemap.SIZE, 0);
|
||||||
y = p.y + DungeonTilemap.SIZE - 1;
|
|
||||||
|
|
||||||
delay = Random.Float( DELAY );
|
pour(FACTORY, 0.05f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,13 +90,6 @@ public class FlowParticle extends PixelParticle {
|
||||||
|
|
||||||
super.update();
|
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.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
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;
|
||||||
import com.watabou.noosa.particles.Emitter.Factory;
|
import com.watabou.noosa.particles.Emitter.Factory;
|
||||||
import com.watabou.noosa.particles.PixelParticle;
|
import com.watabou.noosa.particles.PixelParticle;
|
||||||
|
@ -76,24 +74,18 @@ public class WindParticle extends PixelParticle {
|
||||||
am = (p < 0.5f ? p : 1 - p) * size * 0.2f;
|
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 int pos;
|
||||||
|
|
||||||
private float x;
|
|
||||||
private float y;
|
|
||||||
|
|
||||||
private float delay;
|
|
||||||
|
|
||||||
public Wind( int pos ) {
|
public Wind( int pos ) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
PointF p = DungeonTilemap.tileToWorld( pos );
|
PointF p = DungeonTilemap.tileToWorld( pos );
|
||||||
x = p.x;
|
pos(p.x, p.y, DungeonTilemap.SIZE, DungeonTilemap.SIZE);
|
||||||
y = p.y;
|
|
||||||
|
|
||||||
delay = Random.Float( 5 );
|
pour(FACTORY, 2.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,14 +95,6 @@ public class WindParticle extends PixelParticle {
|
||||||
|
|
||||||
super.update();
|
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.utils.GLog;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.noosa.particles.Emitter;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
@ -334,25 +335,8 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
presses = new ArrayList<>();
|
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
|
@Override
|
||||||
public void detach(){
|
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();
|
updateQuickslot();
|
||||||
super.detach();
|
super.detach();
|
||||||
activeBuff = null;
|
activeBuff = null;
|
||||||
|
@ -360,6 +344,20 @@ public class TimekeepersHourglass extends Artifact {
|
||||||
target.next();
|
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 PRESSES = "presses";
|
||||||
private static final String TURNSTOCOST = "turnsToCost";
|
private static final String TURNSTOCOST = "turnsToCost";
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class SewerLevel extends RegularLevel {
|
||||||
|
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
if ((rippleDelay -= Game.elapsed) <= 0) {
|
if (!isFrozen() && (rippleDelay -= Game.elapsed) <= 0) {
|
||||||
Ripple ripple = GameScene.ripple( pos + Dungeon.level.width() );
|
Ripple ripple = GameScene.ripple( pos + Dungeon.level.width() );
|
||||||
if (ripple != null) {
|
if (ripple != null) {
|
||||||
ripple.y -= DungeonTilemap.SIZE / 2;
|
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.hero.HeroSubClass;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||||
|
import com.watabou.noosa.particles.Emitter;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -118,30 +118,27 @@ public class Swiftthistle extends Plant {
|
||||||
presses = new ArrayList<>();
|
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
|
@Override
|
||||||
public void detach(){
|
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();
|
super.detach();
|
||||||
triggerPresses();
|
triggerPresses();
|
||||||
target.next();
|
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 PRESSES = "presses";
|
||||||
private static final String LEFT = "left";
|
private static final String LEFT = "left";
|
||||||
|
|
||||||
|
|
|
@ -521,7 +521,7 @@ public class GameScene extends PixelScene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
freezeEmitters = false;
|
Emitter.freezeEmitters = false;
|
||||||
|
|
||||||
scene = null;
|
scene = null;
|
||||||
Badges.saveGlobal();
|
Badges.saveGlobal();
|
||||||
|
@ -562,7 +562,7 @@ public class GameScene extends PixelScene {
|
||||||
|
|
||||||
super.update();
|
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 (!Actor.processing() && Dungeon.hero.isAlive()) {
|
||||||
if (actorThread == null || !actorThread.isAlive()) {
|
if (actorThread == null || !actorThread.isAlive()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user