Пример #1
0
  private void fastForwardWorld() {
    _loadingScreen.setVisible(true);
    _hud.setVisible(false);
    _metrics.setVisible(false);
    Display.update();

    int chunksGenerated = 0;

    while (chunksGenerated < 64) {
      getWorldRenderer().generateChunk();
      chunksGenerated++;

      _loadingScreen.updateStatus(
          String.format("Fast forwarding world... %.2f%%! :-)", (chunksGenerated / 64f) * 100f));

      renderUserInterface();
      updateUserInterface();
      Display.update();
    }

    _loadingScreen.setVisible(false);
    _hud.setVisible(true);
    _metrics.setVisible(true);
  }
Пример #2
0
  public void init() {
    _hud = new UIHeadsUpDisplay();
    _hud.setVisible(true);

    _pauseMenu = new UIPauseMenu();
    _loadingScreen = new UILoadingScreen();
    _statusScreen = new UIStatusScreen();
    _inventoryScreen = new UIInventoryScreen();
    _metrics = new UIMetrics();

    _metrics.setVisible(true);

    _guiScreens.add(_metrics);
    _guiScreens.add(_hud);
    _guiScreens.add(_pauseMenu);
    _guiScreens.add(_loadingScreen);
    _guiScreens.add(_inventoryScreen);
    _guiScreens.add(_statusScreen);

    PojoEntityManager entityManager = new PojoEntityManager();

    entityManager.registerTypeHandler(BlockFamily.class, new BlockFamilyTypeHandler());
    entityManager.registerTypeHandler(Color4f.class, new Color4fTypeHandler());
    entityManager.registerTypeHandler(Quat4f.class, new Quat4fTypeHandler());
    entityManager.registerTypeHandler(
        Sound.class, new SoundTypeHandler(AudioManager.getInstance()));
    entityManager.registerTypeHandler(Vector3f.class, new Vector3fTypeHandler());
    entityManager.registerTypeHandler(Vector2f.class, new Vector2fTypeHandler());
    entityManager.registerTypeHandler(Vector3i.class, new Vector3iTypeHandler());

    // TODO: Use reflection pending mod support
    entityManager.registerComponentClass(ExplosionActionComponent.class);
    entityManager.registerComponentClass(PlaySoundActionComponent.class);
    entityManager.registerComponentClass(TunnelActionComponent.class);
    entityManager.registerComponentClass(AABBCollisionComponent.class);
    entityManager.registerComponentClass(BlockComponent.class);
    entityManager.registerComponentClass(BlockItemComponent.class);
    entityManager.registerComponentClass(BlockParticleEffectComponent.class);
    entityManager.registerComponentClass(CameraComponent.class);
    entityManager.registerComponentClass(CharacterMovementComponent.class);
    entityManager.registerComponentClass(CharacterSoundComponent.class);
    entityManager.registerComponentClass(HealthComponent.class);
    entityManager.registerComponentClass(InventoryComponent.class);
    entityManager.registerComponentClass(ItemComponent.class);
    entityManager.registerComponentClass(LightComponent.class);
    entityManager.registerComponentClass(LocalPlayerComponent.class);
    entityManager.registerComponentClass(LocationComponent.class);
    entityManager.registerComponentClass(MeshComponent.class);
    entityManager.registerComponentClass(PlayerComponent.class);
    entityManager.registerComponentClass(SimpleAIComponent.class);
    entityManager.registerComponentClass(AccessInventoryActionComponent.class);
    _entityManager = entityManager;

    _entityManager.setEventSystem(new PojoEventSystem(_entityManager));
    CoreRegistry.put(EntityManager.class, _entityManager);
    _componentSystemManager = new ComponentSystemManager();
    CoreRegistry.put(ComponentSystemManager.class, _componentSystemManager);

    PrefabManager prefabManager = new PojoPrefabManager();
    CoreRegistry.put(PrefabManager.class, prefabManager);
    entityManager.setPrefabManager(prefabManager);

    loadPrefabs();

    _componentSystemManager.register(new BlockEntityRegistry());
    _componentSystemManager.register(new CharacterMovementSystem());
    _componentSystemManager.register(new SimpleAISystem());
    _componentSystemManager.register(new ItemSystem());
    _componentSystemManager.register(new CharacterSoundSystem());
    _localPlayerSys = new LocalPlayerSystem();
    _componentSystemManager.register(_localPlayerSys);
    _componentSystemManager.register(new FirstPersonRenderer());
    _componentSystemManager.register(new HealthSystem());
    _componentSystemManager.register(new BlockEntitySystem());
    _componentSystemManager.register(new BlockParticleEmitterSystem());
    _componentSystemManager.register(new BlockDamageRenderer());
    _componentSystemManager.register(new InventorySystem());
    _componentSystemManager.register(new MeshRenderer());
    _componentSystemManager.register(new ExplosionAction());
    _componentSystemManager.register(new PlaySoundAction());
    _componentSystemManager.register(new TunnelAction());
    _componentSystemManager.register(new AccessInventoryAction());
  }