Added ClientScreen reference within Riiablo class and removed it from Engine and ObjectIterator constructors

This commit is contained in:
Collin Smith
2019-11-24 16:41:54 -08:00
parent d7ba715fef
commit e0bee92925
4 changed files with 17 additions and 18 deletions

View File

@ -15,6 +15,7 @@ import com.riiablo.console.RenderedConsole;
import com.riiablo.entity.Engine;
import com.riiablo.graphics.PaletteIndexedBatch;
import com.riiablo.mpq.MPQFileHandleResolver;
import com.riiablo.screen.ClientScreen;
public class Riiablo {
private Riiablo() {}
@ -54,4 +55,5 @@ public class Riiablo {
public static CharData charData;
public static Engine engine;
public static com.riiablo.engine.Engine engine2;
public static ClientScreen game;
}

View File

@ -47,7 +47,6 @@ import com.riiablo.item.Item;
import com.riiablo.map.DS1;
import com.riiablo.map.DT1;
import com.riiablo.map.Map;
import com.riiablo.screen.ClientScreen;
import com.riiablo.widget.Label;
import org.apache.commons.lang3.ArrayUtils;
@ -125,15 +124,12 @@ public class Engine extends PooledEngine {
return label;
}
private final InteractableComponent.Interactor objectInteractor;
private final InteractableComponent.Interactor itemInteractor;
private final InteractableComponent.Interactor warpInteractor;
private final InteractableComponent.Interactor objectInteractor = new ObjectInteractor();
private final InteractableComponent.Interactor itemInteractor = new ItemInteractor();
private final InteractableComponent.Interactor warpInteractor = new WarpInteractor();
public Engine(ClientScreen gameScreen) {
public Engine() {
super();
objectInteractor = new ObjectInteractor(gameScreen);
itemInteractor = new ItemInteractor();
warpInteractor = new WarpInteractor();
}
@Override

View File

@ -3,21 +3,15 @@ package com.riiablo.engine;
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.gdx.Gdx;
import com.riiablo.Riiablo;
import com.riiablo.engine.component.InteractableComponent;
import com.riiablo.engine.component.ObjectComponent;
import com.riiablo.screen.ClientScreen;
public class ObjectInteractor implements InteractableComponent.Interactor {
private static final String TAG = "ObjectInteractor";
private final ComponentMapper<ObjectComponent> objectComponent = ComponentMapper.getFor(ObjectComponent.class);
private final ClientScreen gameScreen;
public ObjectInteractor(ClientScreen gameScreen) {
this.gameScreen = gameScreen;
}
@Override
public void interact(Entity src, Entity entity) {
ObjectComponent objectComponent = this.objectComponent.get(entity);
@ -37,14 +31,14 @@ public class ObjectInteractor implements InteractableComponent.Interactor {
// sequence(MODE_OP, MODE_ON);
// Riiablo.audio.play("object_waypoint_open", true);
//} else {
gameScreen.setLeftPanel(gameScreen.waygatePanel);
Riiablo.game.setLeftPanel(Riiablo.game.waygatePanel);
//}
break;
case 24: case 25: case 26: case 27: case 28: case 29:
case 30: case 31:
break;
case 32: // stash
gameScreen.setLeftPanel(gameScreen.stashPanel);
Riiablo.game.setLeftPanel(Riiablo.game.stashPanel);
break;
case 33: case 34: case 35: case 36: case 37: case 38: case 39:
case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49:

View File

@ -358,7 +358,7 @@ public class ClientScreen extends ScreenAdapter implements LoadingScreen.Loadabl
renderer = new RenderSystem(Riiablo.batch);
iso = renderer.iso();
engine = Riiablo.engine2 = new Engine(this);
engine = Riiablo.engine2 = new Engine();
engine.addSystem(new IdSystem());
engine.addSystem(new CollisionSystem());
@ -401,6 +401,12 @@ public class ClientScreen extends ScreenAdapter implements LoadingScreen.Loadabl
engine.addSystem(new PathfindDebugSystem(iso, renderer, Riiablo.batch, Riiablo.shapes));
}
@Override
public void resume() {
Riiablo.engine2 = engine;
Riiablo.game = this;
}
@Override
public void render(float delta) {
/*
@ -557,6 +563,7 @@ public class ClientScreen extends ScreenAdapter implements LoadingScreen.Loadabl
@Override
public void show() {
Riiablo.game = this;
isDebug = DEBUG && Gdx.app.getType() == Application.ApplicationType.Desktop;
Keys.DebugMode.addStateListener(debugKeyListener);
Keys.Esc.addStateListener(mappedKeyStateListener);