Ejemplo 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());
  }
  private EntityRef createResultItem(String itemResult) {
    String resultText = itemResult;
    int count = 1;
    int starIndex = resultText.indexOf("*");
    if (starIndex > -1) {
      count = Integer.parseInt(resultText.substring(0, starIndex));
      resultText = resultText.substring(starIndex + 1);
    }

    EntityManager entityManager = CoreRegistry.get(EntityManager.class);
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    PrefabManager prefabManager = CoreRegistry.get(PrefabManager.class);
    Prefab prefab = prefabManager.getPrefab(resultText);

    EntityRef result;
    if (prefab != null) {
      result = entityManager.create(prefab);
      ItemComponent item = result.getComponent(ItemComponent.class);
      item.stackCount = (byte) count;
      result.saveComponent(item);
    } else {
      BlockItemFactory blockItemFactory = new BlockItemFactory(entityManager);
      BlockFamily blockFamily = blockManager.getBlockFamily(resultText);
      result = blockItemFactory.newInstance(blockFamily, count);
    }
    return result;
  }
Ejemplo n.º 3
0
  @Override
  protected void setupStorageManager() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    EngineEntityManager engineEntityManager = CoreRegistry.get(EngineEntityManager.class);

    CoreRegistry.put(
        StorageManager.class, new StorageManagerInternal(moduleManager, engineEntityManager));
  }
Ejemplo n.º 4
0
  // TODO: verify if this can be achieved entirely in the GPU, during tone mapping perhaps?
  public void downsampleSceneAndUpdateExposure() {
    if (renderingConfig.isEyeAdaptation()) {
      PerformanceMonitor.startActivity("Updating exposure");

      downsampleSceneInto1x1pixelsBuffer();

      renderingProcess
          .getCurrentReadbackPBO()
          .copyFromFBO(
              buffers.downSampledScene[0].fboId, 1, 1, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE);

      renderingProcess.swapReadbackPBOs();

      ByteBuffer pixels = renderingProcess.getCurrentReadbackPBO().readBackPixels();

      if (pixels.limit() < 3) {
        logger.error("Failed to auto-update the exposure value.");
        return;
      }

      // TODO: make this line more readable by breaking it in smaller pieces
      currentSceneLuminance =
          0.2126f * (pixels.get(2) & 0xFF) / 255.f
              + 0.7152f * (pixels.get(1) & 0xFF) / 255.f
              + 0.0722f * (pixels.get(0) & 0xFF) / 255.f;

      float targetExposure = hdrMaxExposure;

      if (currentSceneLuminance > 0) {
        targetExposure = hdrTargetLuminance / currentSceneLuminance;
      }

      float maxExposure = hdrMaxExposure;

      if (CoreRegistry.get(BackdropProvider.class).getDaylight()
          == 0.0) { // TODO: fetch the backdropProvider earlier and only once
        maxExposure = hdrMaxExposureNight;
      }

      if (targetExposure > maxExposure) {
        targetExposure = maxExposure;
      } else if (targetExposure < hdrMinExposure) {
        targetExposure = hdrMinExposure;
      }

      currentExposure = TeraMath.lerp(currentExposure, targetExposure, hdrExposureAdjustmentSpeed);

    } else {
      if (CoreRegistry.get(BackdropProvider.class).getDaylight() == 0.0) {
        currentExposure = hdrMaxExposureNight;
      } else {
        currentExposure = hdrExposureDefault;
      }
    }
    PerformanceMonitor.endActivity();
  }
Ejemplo n.º 5
0
  @Override
  protected void setupAssetManager() {
    setupEmptyAssetManager();

    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    AudioManager audioManager = CoreRegistry.get(AudioManager.class);
    AssetType.registerAssetTypes(assetManager);

    CodeSource tsCodeSource = TerasologyEngine.class.getProtectionDomain().getCodeSource();
    assetManager.addAssetSource(
        new ClasspathSource(
            TerasologyConstants.ENGINE_MODULE,
            tsCodeSource,
            TerasologyConstants.ASSETS_SUBDIRECTORY,
            TerasologyConstants.OVERRIDES_SUBDIRECTORY));

    CodeSource thisCodeSource = HeadlessEnvironment.class.getProtectionDomain().getCodeSource();
    assetManager.addAssetSource(
        new ClasspathSource(
            "unittest",
            thisCodeSource,
            TerasologyConstants.ASSETS_SUBDIRECTORY,
            TerasologyConstants.OVERRIDES_SUBDIRECTORY));

    assetManager.setAssetFactory(
        AssetType.PREFAB,
        new AssetFactory<PrefabData, Prefab>() {

          @Override
          public Prefab buildAsset(AssetUri uri, PrefabData data) {
            return new PojoPrefab(uri, data);
          }
        });
    assetManager.setAssetFactory(
        AssetType.SHAPE,
        new AssetFactory<BlockShapeData, BlockShape>() {

          @Override
          public BlockShape buildAsset(AssetUri uri, BlockShapeData data) {
            return new BlockShapeImpl(uri, data);
          }
        });

    assetManager.setAssetFactory(
        AssetType.UI_SKIN,
        new AssetFactory<UISkinData, UISkin>() {
          @Override
          public UISkin buildAsset(AssetUri uri, UISkinData data) {
            return new UISkin(uri, data);
          }
        });

    assetManager.setAssetFactory(AssetType.SOUND, audioManager.getStaticSoundFactory());
    assetManager.setAssetFactory(AssetType.MUSIC, audioManager.getStreamingSoundFactory());
  }
Ejemplo n.º 6
0
  @Override
  protected void setupEntitySystem() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    NetworkSystem networkSystem = CoreRegistry.get(NetworkSystem.class);

    EntitySystemBuilder builder = new EntitySystemBuilder();
    EngineEntityManager engineEntityManager =
        builder.build(moduleManager, networkSystem, new ReflectionReflectFactory());

    CoreRegistry.put(EngineEntityManager.class, engineEntityManager);
  }
 @ReceiveEvent(components = ClientComponent.class)
 public void onKeyDown(KeyDownEvent event, EntityRef entity) {
   switch (event.getKey().getId()) {
     case Keyboard.KeyId.F12:
       CoreRegistry.get(LwjglRenderingProcess.class).takeScreenshot();
       CoreRegistry.get(AudioManager.class).playSound(Assets.getSound("engine:camera").get());
       break;
     default:
       break;
   }
 }
Ejemplo n.º 8
0
 void connectToEntitySystem(
     EngineEntityManager newEntityManager,
     NetworkEntitySerializer newEntitySerializer,
     EventSerializer newEventSerializer,
     BlockEntityRegistry newBlockEntityRegistry) {
   this.entityManager = newEntityManager;
   this.eventSerializer = newEventSerializer;
   this.entitySerializer = newEntitySerializer;
   this.blockEntityRegistry = newBlockEntityRegistry;
   blockManager = (BlockManagerImpl) CoreRegistry.get(BlockManager.class);
   biomeManager = CoreRegistry.get(BiomeManager.class);
 }
Ejemplo n.º 9
0
  public BlockManagerImpl(
      WorldAtlas atlas,
      List<String> registeredBlockFamilies,
      Map<String, Short> knownBlockMappings,
      boolean generateNewIds,
      BlockFamilyFactoryRegistry blockFamilyFactoryRegistry) {
    this.generateNewIds = generateNewIds;
    this.moduleManager = CoreRegistry.get(ModuleManager.class);
    blockLoader =
        new BlockLoader(CoreRegistry.get(AssetManager.class), blockFamilyFactoryRegistry, atlas);
    BlockLoader.LoadBlockDefinitionResults blockDefinitions = blockLoader.loadBlockDefinitions();
    addBlockFamily(getAirFamily(), true);
    for (BlockFamily family : blockDefinitions.families) {
      addBlockFamily(family, false);
    }
    for (FreeformFamily freeformFamily : blockDefinitions.shapelessDefinitions) {
      addFreeformBlockFamily(freeformFamily.uri, freeformFamily.categories);
    }
    if (knownBlockMappings.size() >= MAX_ID) {
      nextId = UNKNOWN_ID;
    } else if (knownBlockMappings.size() > 0) {
      nextId = (short) knownBlockMappings.size();
    }

    for (String rawFamilyUri : registeredBlockFamilies) {
      BlockUri familyUri = new BlockUri(rawFamilyUri);
      BlockFamily family;
      if (isFreeformFamily(familyUri)) {
        family = blockLoader.loadWithShape(familyUri);
      } else {
        family = getAvailableBlockFamily(familyUri);
      }
      if (family != null) {
        for (Block block : family.getBlocks()) {
          Short id = knownBlockMappings.get(block.getURI().toString());
          if (id != null) {
            block.setId(id);
          } else {
            logger.error(
                "Missing id for block {} in provided family {}", block.getURI(), family.getURI());
            if (generateNewIds) {
              block.setId(getNextId());
            } else {
              block.setId(UNKNOWN_ID);
            }
          }
        }
        registerFamily(family);
      } else {
        logger.error("Family not available: {}", rawFamilyUri);
      }
    }
  }
Ejemplo n.º 10
0
  /**
   * Activate all modules. Note: this requires that the {@link ModuleSecurityManager} gives
   * permission to do that
   */
  public void activateAllModules() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);

    // activate all modules
    for (Module m : moduleManager.getModules()) {
      moduleManager.enableModule(m);
    }

    moduleManager.applyActiveModules();
    assetManager.clear();
    assetManager.applyOverrides();
  }
Ejemplo n.º 11
0
  /**
   * Renders this AABB.
   *
   * <p>
   *
   * @param lineThickness The thickness of the line
   */
  public void render(float lineThickness) {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    glPushMatrix();
    Vector3f cameraPosition = CoreRegistry.get(WorldRenderer.class).getActiveCamera().getPosition();
    glTranslated(
        aabb.getCenter().x - cameraPosition.x,
        -cameraPosition.y,
        aabb.getCenter().z - cameraPosition.z);

    renderLocally(lineThickness);

    glPopMatrix();
  }
Ejemplo n.º 12
0
  /** Init. the HUD. */
  public UIScreenHUD() {
    setId("hud");
    maximize();
    time = CoreRegistry.get(Time.class);

    // Create hearts
    hearts = new UIImage[NUM_HEART_ICONS];
    for (int i = 0; i < NUM_HEART_ICONS; i++) {
      hearts[i] = new UIImage(Assets.getTexture("engine:icons"));
      hearts[i].setVisible(true);
      hearts[i].setTextureSize(new Vector2f(9f, 9f));
      hearts[i].setTextureOrigin(new Vector2f(52f, 0.0f)); // 106f for poison
      hearts[i].setSize(new Vector2f(18f, 18f));
      hearts[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      hearts[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      hearts[i].setPosition(new Vector2f(18f * i - 212f, -52f));

      addDisplayElement(hearts[i]);
    }

    breathBubbles = new UIImage[NUM_BUBBLE_ICONS];
    for (int i = 0; i < NUM_BUBBLE_ICONS; ++i) {
      breathBubbles[i] = new UIImage(Assets.getTexture("engine:icons"));
      breathBubbles[i].setVisible(true);
      breathBubbles[i].setTextureSize(new Vector2f(9f, 9f));
      breathBubbles[i].setTextureOrigin(new Vector2f(16f, 18f));
      breathBubbles[i].setSize(new Vector2f(18f, 18f));
      breathBubbles[i].setVerticalAlign(EVerticalAlign.BOTTOM);
      breathBubbles[i].setHorizontalAlign(EHorizontalAlign.CENTER);
      breathBubbles[i].setPosition(new Vector2f(-18f * i + 210f, -52f));

      addDisplayElement(breathBubbles[i]);
    }

    crosshair = new UIImage(Assets.getTexture("engine:gui"));
    crosshair.setId("crosshair");
    crosshair.setTextureSize(new Vector2f(20f, 20f));
    crosshair.setTextureOrigin(new Vector2f(24f, 24f));
    crosshair.setSize(new Vector2f(40f, 40f));
    crosshair.setHorizontalAlign(EHorizontalAlign.CENTER);
    crosshair.setVerticalAlign(EVerticalAlign.CENTER);
    crosshair.setVisible(true);

    addDisplayElement(crosshair);

    localPlayer = CoreRegistry.get(LocalPlayer.class);

    update();
    layout();
  }
Ejemplo n.º 13
0
  public void renderTransformed() {
    CoreRegistry.get(ShaderManager.class).enableDefault();

    if (isVisible()) {

      for (Animation animation : animations) {
        if (animation.isStarted()) {
          animation.renderBegin();
        }
      }

      if (positionType == EPositionType.RELATIVE) {
        glPushMatrix();
        glTranslatef(getPosition().x, getPosition().y, 0);
        render();
        glPopMatrix();
      } else if (positionType == EPositionType.ABSOLUTE) {
        glPushMatrix();
        glLoadIdentity();
        glTranslatef(getPosition().x, getPosition().y, 0);
        render();
        glPopMatrix();
      }

      for (Animation animation : animations) {
        if (animation.isStarted()) {
          animation.renderEnd();
        }
      }
    }
  }
Ejemplo n.º 14
0
  /**
   * Constructor for server or single player games
   *
   * @param gameManifest
   * @param netMode
   */
  public StateLoading(GameManifest gameManifest, NetworkMode netMode) {
    Preconditions.checkArgument(netMode != NetworkMode.CLIENT);

    this.gameManifest = gameManifest;
    this.nuiManager = CoreRegistry.get(NUIManager.class);
    this.netMode = netMode;
  }
  public ReadWriteStorageManager(
      Path savePath,
      ModuleEnvironment environment,
      EngineEntityManager entityManager,
      BlockManager blockManager,
      BiomeManager biomeManager,
      boolean storeChunksInZips)
      throws IOException {
    super(savePath, environment, entityManager, blockManager, biomeManager, storeChunksInZips);

    entityManager.subscribeForDestruction(this);
    entityManager.subscribeForChanges(this);
    // TODO Ensure that the component library and the type serializer library are thread save (e.g.
    // immutable)
    this.privateEntityManager = createPrivateEntityManager(entityManager.getComponentLibrary());
    Files.createDirectories(getStoragePathProvider().getStoragePathDirectory());
    this.saveTransactionHelper = new SaveTransactionHelper(getStoragePathProvider());
    this.saveThreadManager = TaskMaster.createFIFOTaskMaster("Saving", 1);
    this.config = CoreRegistry.get(Config.class);
    this.entityRefReplacingComponentLibrary =
        privateEntityManager
            .getComponentLibrary()
            .createCopyUsingCopyStrategy(EntityRef.class, new DelayedEntityRefCopyStrategy(this));
    this.entitySetDeltaRecorder =
        new EntitySetDeltaRecorder(this.entityRefReplacingComponentLibrary);
  }
Ejemplo n.º 16
0
 public void setFullscreen(boolean state) {
   if (renderingConfig.isFullscreen() != state) {
     renderingConfig.setFullscreen(state);
     DisplayDevice display = CoreRegistry.get(DisplayDevice.class);
     display.setFullscreen(state);
   }
 }
  @Override
  public boolean validateBeforeStart(
      EntityRef instigator, EntityRef workstation, EntityRef processEntity) {
    if (!workstation.hasComponent(WorkstationInventoryComponent.class)) {
      return false;
    }

    // Defer the heat calculation until it is actually needed
    Float heat = null;

    for (int slot : WorkstationInventoryUtils.getAssignedSlots(workstation, "INPUT")) {
      HeatProcessedComponent processed =
          InventoryUtils.getItemAt(workstation, slot).getComponent(HeatProcessedComponent.class);
      if (processed != null) {
        float heatRequired = processed.heatRequired;
        if (heat == null) {
          heat =
              HeatUtils.calculateHeatForEntity(
                  workstation, CoreRegistry.get(BlockEntityRegistry.class));
        }
        if (heatRequired <= heat) {
          final String result =
              processed.blockResult != null ? processed.blockResult : processed.itemResult;
          if (canOutputResult(workstation, result)) {
            processEntity.addComponent(new SpecificInputSlotComponent(slot));
            processEntity.addComponent(new OutputTypeComponent(result));
            return true;
          }
        }
      }
    }

    return false;
  }
  @Override
  public void initialise() {
    ingredientsInventory = find("ingredientsInventory", InventoryGrid.class);
    toolsInventory = find("toolsInventory", InventoryGrid.class);

    fluidContainerInput = find("fluidContainerInput", InventoryGrid.class);
    fluidContainer = find("fluidContainer", FluidContainerWidget.class);
    fluidContainerOutput = find("fluidContainerOutput", InventoryGrid.class);

    temperature = find("temperature", ThermometerWidget.class);

    burn = find("burn", VerticalTextureProgressWidget.class);
    burn.setMinY(76);
    burn.setMaxY(4);

    fuelInput = find("fuelInput", InventoryGrid.class);

    availableRecipes = find("availableRecipes", StationAvailableRecipesWidget.class);

    craftingProgress = find("craftingProgress", UILoadBar.class);

    resultInventory = find("resultInventory", InventoryGrid.class);

    InventoryGrid playerInventory = find("playerInventory", InventoryGrid.class);

    playerInventory.setTargetEntity(CoreRegistry.get(LocalPlayer.class).getCharacterEntity());
    playerInventory.setCellOffset(10);
    playerInventory.setMaxCellCount(30);
  }
Ejemplo n.º 19
0
  public List<Property<?, ?>> createProperties(Object target) {
    List<Property<?, ?>> properties = Lists.newArrayList();
    try {
      Class<?> type = target.getClass();

      ReflectFactory reflectFactory = CoreRegistry.get(ReflectFactory.class);
      CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
      ClassMetadata<?, ?> classMetadata =
          new DefaultClassMetadata<>(new SimpleUri(), type, reflectFactory, copyStrategies);
      for (Field field : getAllFields(type)) {
        Annotation annotation = getFactory(field);
        if (annotation != null) {
          FieldMetadata<Object, ?> fieldMetadata =
              (FieldMetadata<Object, ?>) classMetadata.getField(field.getName());
          PropertyFactory factory = factories.get(annotation.annotationType());
          Property property = factory.create(target, fieldMetadata, field.getName(), annotation);
          properties.add(property);
        }
      }
    } catch (NoSuchMethodException e) {
      throw new RuntimeException(e);
    }

    return properties;
  }
Ejemplo n.º 20
0
 public static <T extends Asset<U>, U extends AssetData> T generateAsset(
     AssetType type, U data, Class<T> assetClass) {
   Asset<U> asset = CoreRegistry.get(AssetManager.class).generateTemporaryAsset(type, data);
   if (assetClass.isInstance(asset)) {
     return assetClass.cast(asset);
   }
   return null;
 }
 @Override
 public boolean step() {
   try {
     CoreRegistry.get(StorageManager.class).checkAndRepairSaveIfNecessary();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
   return true;
 }
  private SaveTransaction createSaveTransaction() {
    SaveTransactionBuilder saveTransactionBuilder =
        new SaveTransactionBuilder(
            privateEntityManager,
            entitySetDeltaRecorder,
            isStoreChunksInZips(),
            getStoragePathProvider(),
            worldDirectoryWriteLock);

    ChunkProvider chunkProvider = CoreRegistry.get(ChunkProvider.class);
    NetworkSystem networkSystem = CoreRegistry.get(NetworkSystem.class);

    addChunksToSaveTransaction(saveTransactionBuilder, chunkProvider);
    addPlayersToSaveTransaction(saveTransactionBuilder, networkSystem);
    addGlobalStoreBuilderToSaveTransaction(saveTransactionBuilder);
    addGameManifestToSaveTransaction(saveTransactionBuilder);

    return saveTransactionBuilder.build();
  }
Ejemplo n.º 23
0
 public LocalChunkProvider(
     StorageManager storageManager, EntityManager entityManager, WorldGenerator generator) {
   this.blockManager = CoreRegistry.get(BlockManager.class);
   this.storageManager = storageManager;
   this.entityManager = entityManager;
   this.generator = generator;
   this.pipeline = new ChunkGenerationPipeline(new ChunkTaskRelevanceComparator());
   this.unloadRequestTaskMaster = TaskMaster.createFIFOTaskMaster("Chunk-Unloader", 4);
   ChunkMonitor.fireChunkProviderInitialized(this);
 }
Ejemplo n.º 24
0
  @Override
  protected void setupEmptyAssetManager() {
    ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);
    AssetManager assetManager = new AssetManager(moduleManager);

    // mock an empy asset factory for all asset types
    for (AssetType type : AssetType.values()) {
      assetManager.setAssetFactory(type, mock(AssetFactory.class));
    }

    CoreRegistry.put(AssetManager.class, assetManager);
  }
  private void addGameManifestToSaveTransaction(SaveTransactionBuilder saveTransactionBuilder) {
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    BiomeManager biomeManager = CoreRegistry.get(BiomeManager.class);
    WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
    Time time = CoreRegistry.get(Time.class);
    Game game = CoreRegistry.get(Game.class);

    GameManifest gameManifest =
        new GameManifest(game.getName(), game.getSeed(), time.getGameTimeInMs());
    for (Module module : CoreRegistry.get(ModuleManager.class).getEnvironment()) {
      gameManifest.addModule(module.getId(), module.getVersion());
    }

    List<String> registeredBlockFamilies = Lists.newArrayList();
    for (BlockFamily family : blockManager.listRegisteredBlockFamilies()) {
      registeredBlockFamilies.add(family.getURI().toString());
    }
    gameManifest.setRegisteredBlockFamilies(registeredBlockFamilies);
    gameManifest.setBlockIdMap(blockManager.getBlockIdMap());
    List<Biome> biomes = biomeManager.getBiomes();
    Map<String, Short> biomeIdMap = new HashMap<>(biomes.size());
    for (Biome biome : biomes) {
      short shortId = biomeManager.getBiomeShortId(biome);
      String id = biomeManager.getBiomeId(biome);
      biomeIdMap.put(id, shortId);
    }
    gameManifest.setBiomeIdMap(biomeIdMap);
    gameManifest.addWorld(worldProvider.getWorldInfo());
    saveTransactionBuilder.setGameManifest(gameManifest);
  }
Ejemplo n.º 26
0
  /**
   * This constructor initializes the engine by initializing its systems, subsystems and managers.
   * It also verifies that some required systems are up and running after they have been
   * initialized.
   *
   * @param subsystems Typical subsystems lists contain graphics, timer, audio and input subsystems.
   */
  public TerasologyEngine(Collection<EngineSubsystem> subsystems) {

    Stopwatch totalInitTime = Stopwatch.createStarted();

    this.subsystems = Queues.newArrayDeque(subsystems);

    try {
      logger.info("Initializing Terasology...");
      logEnvironmentInfo();

      SplashScreen.getInstance().post("Loading config file ...");

      initConfig();

      SplashScreen.getInstance().post("Pre-initialize subsystems ...");

      preInitSubsystems();

      // time must be set here as it is required by some of the managers.
      verifyRequiredSystemIsRegistered(Time.class);
      time = (EngineTime) CoreRegistry.get(Time.class);

      GameThread.setToCurrentThread();

      initManagers();

      SplashScreen.getInstance().post("Post-initialize subsystems ...");

      postInitSubsystems();

      verifyRequiredSystemIsRegistered(DisplayDevice.class);
      verifyRequiredSystemIsRegistered(RenderingSubsystemFactory.class);
      verifyRequiredSystemIsRegistered(InputSystem.class);

      SplashScreen.getInstance().post("Initialize assets ...");

      initAssets();

      // TODO: Review - The advanced monitor shouldn't be hooked-in this way (see issue #692)
      initAdvancedMonitor();

      engineState = EngineState.INITIALIZED;

    } catch (RuntimeException e) {
      logger.error("Failed to initialise Terasology", e);
      cleanup();
      throw e;
    }

    double seconds = 0.001 * totalInitTime.elapsed(TimeUnit.MILLISECONDS);
    logger.info("Initialization completed in {}sec.", String.format("%.2f", seconds));
  }
Ejemplo n.º 27
0
 public HaliteGeneration() {
   super(
       new UniformPocketBlockProvider(
           CoreRegistry.get(BlockManager.class).getBlock("WoodAndStone:Halite")),
       new PDist(0.45f, 0.15f),
       new PDist(4f, 1f),
       new PDist(2f, 1f),
       new PDist(1800f, 300f),
       new PDist(0f, 0.35f),
       new PDist(1f, 0f),
       new PDist(0.7f, 0.1f),
       new PDist(0.2f, 0f),
       new PDist(0f, 0f));
 }
Ejemplo n.º 28
0
 public CoalGeneration() {
   super(
       new UniformPocketBlockProvider(
           CoreRegistry.get(BlockManager.class).getBlock("CopperAndBronze:CoalOre")),
       new PDist(0.9f, 0.15f),
       new PDist(4f, 1f),
       new PDist(2f, 1f),
       new PDist(1800f, 500f),
       new PDist(0f, 0.35f),
       new PDist(1f, 0f),
       new PDist(0.7f, 0.1f),
       new PDist(0.2f, 0f),
       new PDist(0f, 0f));
 }
Ejemplo n.º 29
0
 private JsonElement readJson(AssetUri blockDefUri) {
   try (InputStream stream = CoreRegistry.get(AssetManager.class).getAssetStream(blockDefUri)) {
     if (stream != null) {
       BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8));
       return parser.parse(reader);
     } else {
       logger.error("Failed to load block definition '{}'", blockDefUri);
     }
   } catch (JsonParseException e) {
     logger.error("Failed to parse block definition '{}'", blockDefUri, e);
   } catch (IOException e) {
     logger.error("Failed to load block definition '{}'", blockDefUri, e);
   }
   return null;
 }
Ejemplo n.º 30
0
  @Override
  public void close() throws Exception {
    // it would be nice, if elements in the CoreRegistry implemented (Auto)Closeable

    // The StorageManager creates a thread pool (through TaskMaster)
    // which isn't closed automatically
    StorageManager storageManager = CoreRegistry.get(StorageManager.class);
    if (storageManager != null) {
      storageManager.shutdown();
    }

    CoreRegistry.clear();

    super.close();
  }