Fixed issue where game would crash if trying to enter multiple games in a single instance

This commit is contained in:
Collin Smith
2019-11-28 18:08:33 -08:00
parent b1b2e3985f
commit 2139747d0c
2 changed files with 6 additions and 0 deletions

View File

@ -431,6 +431,11 @@ public class CharData {
for (EquippedListener l : EQUIPPED_LISTENERS) l.onAlternated(this, alternate, LH, RH);
}
public void clearListeners() {
EQUIPPED_LISTENERS.clear();
SKILLS_LISTENERS.clear();
}
public boolean addEquippedListener(EquippedListener l) {
EQUIPPED_LISTENERS.add(l);
return true;

View File

@ -766,6 +766,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
@Override
public void dispose() {
charData.clearListeners();
engine.removeAllEntities();
engine.removeAllSystems();
for (Actor actor : stage.getActors()) if (actor instanceof Disposable) ((Disposable) actor).dispose();