moved timermanger to app

This commit is contained in:
Cedric Beck
2024-12-10 13:38:26 +01:00
parent bc2c80dd27
commit 888b52f314
2 changed files with 17 additions and 10 deletions

View File

@@ -5,6 +5,7 @@
import com.sun.tools.javac.Main;
import pp.mdga.client.acoustic.AcousticHandler;
import com.jme3.system.AppSettings;
import pp.mdga.client.animation.TimerManager;
import pp.mdga.client.dialog.JoinDialog;
import pp.mdga.client.view.*;
@@ -66,6 +67,9 @@ public class MdgaApp extends SimpleApplication {
private ServerConnection networkConnection;
private final TimerManager timerManager = new TimerManager();
public static final int DEBUG_MULTIPLIER = 0;
public MdgaApp() {
@@ -144,6 +148,7 @@ public void simpleUpdate(float tpf) {
acousticHandler.update();
notificationSynchronizer.update();
inputSynchronizer.update(tpf);
timerManager.update(tpf);
}
/**
@@ -324,5 +329,9 @@ public void afterGameCleanup() {
public GameView getGameView(){
return gameView;
}
public TimerManager getTimerManager() {
return timerManager;
}
}

View File

@@ -21,7 +21,6 @@ public class MatrixAnimation extends ActionControl {
private List<ParticleEmitter> activeEmitter = new ArrayList<>();
private ParticleEmitter radarEmitter = null;
private float timeElapsed = 0f;
private final TimerManager timerManager = new TimerManager();
private enum MatrixState{
@@ -61,8 +60,9 @@ protected void controlUpdate(float tpf) {
state = MatrixState.RADAR_OFF;
timeElapsed = 0;
radarEmitter.setParticlesPerSec(0);
timerManager.addTask(3f, () -> app.enqueue(() -> {
app.getTimerManager().addTask(3f, () -> app.enqueue(() -> {
app.getRootNode().detachChild(radarEmitter);
System.out.println("delete radar");
return null;
}));
}
@@ -80,14 +80,13 @@ protected void controlUpdate(float tpf) {
state = MatrixState.MATRIX_OFF;
timeElapsed = 0;
turnOff();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
for (ParticleEmitter particleEmitter : activeEmitter){
app.getRootNode().detachChild(particleEmitter);
}
app.getTimerManager().addTask(3f, () -> app.enqueue(() -> {
for (ParticleEmitter particleEmitter : activeEmitter){
app.getRootNode().detachChild(particleEmitter);
}
}, 3000);
System.out.println("delete particle");
return null;
}));
}
}
case MATRIX_OFF -> {
@@ -98,7 +97,6 @@ public void run() {
}
}
}
timerManager.update(tpf);
}
private void turnOff(){