DEADSOFTWARE

Delete old GameItems
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / GameProc.java
1 package ru.deadsoftware.cavedroid.game;
3 import com.badlogic.gdx.utils.Disposable;
4 import com.badlogic.gdx.utils.Timer;
5 import ru.deadsoftware.cavedroid.game.mobs.MobsController;
6 import ru.deadsoftware.cavedroid.game.world.GameWorldBlocksLogicControllerTask;
7 import ru.deadsoftware.cavedroid.game.world.GameWorldFluidsLogicControllerTask;
8 import ru.deadsoftware.cavedroid.misc.utils.AssetLoader;
10 import javax.inject.Inject;
12 @GameScope
13 public class GameProc implements Disposable {
15 private final GamePhysics mGamePhysics;
16 private final GameInput mGameInput;
17 private final GameRenderer mGameRenderer;
18 private final MobsController mMobsController;
19 private final GameWorldFluidsLogicControllerTask mGameWorldFluidsLogicControllerTask;
20 private final GameWorldBlocksLogicControllerTask mGameWorldBlocksLogicControllerTask;
21 private final GameItemsHolder mGameItemsHolder;
23 private final Timer mWorldLogicTimer = new Timer();
25 @Inject
26 public GameProc(GamePhysics gamePhysics,
27 GameInput gameInput,
28 GameRenderer gameRenderer,
29 MobsController mobsController,
30 GameWorldFluidsLogicControllerTask gameWorldFluidsLogicControllerTask,
31 GameWorldBlocksLogicControllerTask gameWorldBlocksLogicControllerTask,
32 GameItemsHolder gameItemsHolder,
33 AssetLoader assetLoader
34 ) {
35 mGamePhysics = gamePhysics;
36 mGameInput = gameInput;
37 mGameRenderer = gameRenderer;
38 mMobsController = mobsController;
39 mGameWorldFluidsLogicControllerTask = gameWorldFluidsLogicControllerTask;
40 mGameWorldBlocksLogicControllerTask = gameWorldBlocksLogicControllerTask;
41 mGameItemsHolder = gameItemsHolder;
43 mGameItemsHolder.initialize();
45 mWorldLogicTimer.scheduleTask(gameWorldFluidsLogicControllerTask, 0,
46 GameWorldFluidsLogicControllerTask.FLUID_UPDATE_INTERVAL_SEC);
47 mWorldLogicTimer.scheduleTask(gameWorldBlocksLogicControllerTask, 0,
48 GameWorldBlocksLogicControllerTask.WORLD_BLOCKS_LOGIC_UPDATE_INTERVAL_SEC);
49 }
51 public void setPlayerGameMode(int gameMode) {
52 mMobsController.getPlayer().gameMode = gameMode;
53 }
55 public void update(float delta) {
56 mGamePhysics.update(delta);
57 mGameInput.update();
58 mGameRenderer.render(delta);
59 }
61 @Override
62 public void dispose() {
63 mWorldLogicTimer.stop();
64 mGameWorldFluidsLogicControllerTask.cancel();
65 mGameWorldBlocksLogicControllerTask.cancel();
66 }
67 }