示例#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());
  }
示例#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;
 }
示例#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);
        }
      }
    }
  }
示例#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();
    }
  }
示例#5
0
 @Override
 public void dispose() {
   EngineTime time = (EngineTime) CoreRegistry.get(Time.class);
   time.setPaused(false);
 }
示例#6
0
 @Override
 public void begin() {
   worldRenderer = context.get(WorldRenderer.class);
   EngineTime time = (EngineTime) context.get(Time.class);
   startTime = time.getRawTimeInMs();
 }