Skip to content

Commit

Permalink
Changed the check from number of players on server to the game being …
Browse files Browse the repository at this point in the history
…single player.
  • Loading branch information
Arihant-Joshi committed Apr 14, 2018
1 parent 9d4eb0f commit 73abcba
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import org.terasology.logic.characters.CharacterComponent;
import org.terasology.logic.characters.events.PlayerDeathEvent;
import org.terasology.network.ClientComponent;
import org.terasology.network.ClientInfoComponent;
import org.terasology.network.NetworkMode;
import org.terasology.network.NetworkSystem;
import org.terasology.registry.CoreRegistry;
import org.terasology.registry.In;
import org.terasology.rendering.nui.NUIManager;
Expand All @@ -54,32 +55,25 @@ public class MenuControlSystem extends BaseComponentSystem {
private Time time;
@In
private EntityManager entityManager;
@In
private NetworkSystem networkSystem;

@Override
public void initialise() {
nuiManager.getHUD().addHUDElement("dropItemRegion"); //Ensure the drop region is behind the toolbar
nuiManager.getHUD().addHUDElement("toolbar");
}

//TODO
//Implement this function in a separate file for reusabitility
private int getPlayerCount() {
int playerCount=entityManager.getCountOfEntitiesWith(ClientInfoComponent.class);
return playerCount;
}

@ReceiveEvent(components = ClientComponent.class)
public void onTogglePause(PauseButton event, EntityRef entity) {
if (event.getState() == ButtonState.DOWN) {
nuiManager.toggleScreen("engine:pauseMenu");
event.consume();
}
if(getPlayerCount()==1)
{
if(nuiManager.isOpen("engine:pauseMenu")) {
if (networkSystem.getMode() == NetworkMode.NONE) {
if (nuiManager.isOpen("engine:pauseMenu")) {
time.setPaused(true);
}
else{
} else {
time.setPaused(false);
}
}
Expand Down

0 comments on commit 73abcba

Please sign in to comment.