Exemplo n.º 1
0
  @Override
  public void init(GameEngine engine) {
    EngineTime time = (EngineTime) CoreRegistry.get(Time.class);
    time.setPaused(true);
    time.setGameTime(0);

    CoreRegistry.get(Game.class).load(gameManifest);
    switch (netMode) {
      case CLIENT:
        initClient();
        break;
      default:
        initHost();
        break;
    }

    progress = 0;
    maxProgress = 0;
    for (LoadProcess process : loadProcesses) {
      maxProgress += process.getExpectedCost();
    }

    popStep();
    loadingScreen = nuiManager.setScreen("engine:loadingScreen", LoadingScreen.class);
    loadingScreen.updateStatus(current.getMessage(), current.getProgress());
  }
Exemplo n.º 2
0
 @Override
 public boolean step() {
   if (worldRenderer.pregenerateChunks()) {
     return true;
   }
   EngineTime time = (EngineTime) context.get(Time.class);
   long totalTime = time.getRawTimeInMs() - startTime;
   return totalTime > 5000;
 }
Exemplo n.º 3
0
  private void processMessages() {
    List<NetData.NetMessage> messages = Lists.newArrayListWithExpectedSize(queuedMessages.size());
    queuedMessages.drainTo(messages);

    for (NetData.NetMessage message : messages) {
      if (message.hasTime()) {
        time.updateTimeFromServer(message.getTime());
      }
      processBlockRegistrations(message);
      processReceivedChunks(message);
      processInvalidatedChunks(message);
      processBlockChanges(message);
      processBiomeChanges(message);
      processRemoveEntities(message);
      for (NetData.CreateEntityMessage createEntity : message.getCreateEntityList()) {
        createEntityMessage(createEntity);
      }
      for (NetData.UpdateEntityMessage updateEntity : message.getUpdateEntityList()) {
        updateEntity(updateEntity);
      }
      for (NetData.EventMessage event : message.getEventList()) {
        try {
          processEvent(event);
        } catch (RuntimeException e) {
          logger.error("Error processing server event", e);
        }
      }
    }
  }
Exemplo n.º 4
0
  @Override
  public void update(boolean netTick) {
    processReceivedChunks();
    if (entityManager != null) {
      if (netTick) {
        NetData.NetMessage.Builder message = NetData.NetMessage.newBuilder();
        message.setTime(time.getGameTimeInMs());
        sendEntities(message);
        sendEvents(message);
        send(message.build());
      } else if (!queuedOutgoingEvents.isEmpty()) {
        NetData.NetMessage.Builder message = NetData.NetMessage.newBuilder();
        message.setTime(time.getGameTimeInMs());
        sendEvents(message);
        send(message.build());
      }

      processMessages();
    }
  }
Exemplo n.º 5
0
 @Override
 public void dispose() {
   EngineTime time = (EngineTime) CoreRegistry.get(Time.class);
   time.setPaused(false);
 }
Exemplo n.º 6
0
 @Override
 public void begin() {
   worldRenderer = context.get(WorldRenderer.class);
   EngineTime time = (EngineTime) context.get(Time.class);
   startTime = time.getRawTimeInMs();
 }