Search in sources :

Example 1 with TelescopeRotationDrawArea

use of hellfirepvp.astralsorcery.client.screen.telescope.TelescopeRotationDrawArea in project AstralSorcery by HellFirePvP.

the class ScreenTelescope method fillConstellations.

@Override
protected void fillConstellations(WorldContext ctx, List<TelescopeRotationDrawArea> drawAreas) {
    Random gen = ctx.getDayRandom();
    PlayerProgress prog = ResearchHelper.getClientProgress();
    List<IWeakConstellation> cst = new ArrayList<>();
    for (IConstellation active : ctx.getActiveCelestialsHandler().getCurrentRenderPositions().keySet()) {
        if (active instanceof IWeakConstellation && active.canDiscover(Minecraft.getInstance().player, prog)) {
            cst.add((IWeakConstellation) active);
        }
    }
    Collections.shuffle(cst, gen);
    cst = cst.subList(0, Math.min(drawAreas.size(), cst.size()));
    for (IWeakConstellation constellation : cst) {
        Point foundPoint;
        TelescopeRotationDrawArea associatedArea;
        do {
            associatedArea = MiscUtils.getRandomEntry(drawAreas, gen);
            foundPoint = findEmptySpace(gen, associatedArea);
        } while (foundPoint == null);
        associatedArea.addConstellationToArea(constellation, foundPoint, DEFAULT_CONSTELLATION_SIZE);
    }
}
Also used : TelescopeRotationDrawArea(hellfirepvp.astralsorcery.client.screen.telescope.TelescopeRotationDrawArea) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) IWeakConstellation(hellfirepvp.astralsorcery.common.constellation.IWeakConstellation) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation)

Example 2 with TelescopeRotationDrawArea

use of hellfirepvp.astralsorcery.client.screen.telescope.TelescopeRotationDrawArea in project AstralSorcery by HellFirePvP.

the class ScreenTelescope method drawConstellationCell.

private void drawConstellationCell(MatrixStack renderStack, float pTicks) {
    boolean canSeeSky = this.canObserverSeeSky(this.getTile().getPos(), 1);
    RenderSystem.disableAlphaTest();
    RenderSystem.enableBlend();
    Blending.DEFAULT.apply();
    this.setBlitOffset(-10);
    this.drawSkyBackground(renderStack, pTicks, canSeeSky);
    if (!this.isInitialized()) {
        this.setBlitOffset(0);
        Blending.DEFAULT.apply();
        RenderSystem.disableBlend();
        RenderSystem.enableAlphaTest();
        return;
    }
    WorldContext ctx = this.getContext();
    if (ctx != null && canSeeSky) {
        Random gen = ctx.getDayRandom();
        PlayerProgress prog = ResearchHelper.getClientProgress();
        for (int i = 0; i < this.rotation.ordinal(); i++) {
            // Flush
            gen.nextFloat();
        }
        this.setBlitOffset(-9);
        float starSize = 5F;
        TexturesAS.TEX_STAR_1.bindTexture();
        RenderingUtils.draw(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX, buf -> {
            for (int i = 0; i < 72 + gen.nextInt(108); i++) {
                float innerOffsetX = starSize + gen.nextFloat() * (guiWidth - starSize * 2) + this.getGuiLeft();
                float innerOffsetY = starSize + gen.nextFloat() * (guiHeight - starSize * 2) + this.getGuiTop();
                float brightness = 0.4F + (RenderingConstellationUtils.stdFlicker(ClientScheduler.getClientTick(), pTicks, 10 + gen.nextInt(20))) * 0.5F;
                brightness = this.multiplyStarBrightness(pTicks, brightness);
                RenderingGuiUtils.rect(buf, renderStack, this).at(innerOffsetX, innerOffsetY).dim(starSize, starSize).color(brightness, brightness, brightness, brightness).draw();
            }
        });
        this.setBlitOffset(-7);
        for (TelescopeRotationDrawArea area : this.getVisibleDrawAreas()) {
            for (IConstellation cst : area.getDisplayMap().keySet()) {
                ConstellationDisplayInformation info = area.getDisplayMap().get(cst);
                info.getFrameDrawInformation().clear();
                Point pos = info.getRenderPosition();
                int size = (int) info.getRenderSize();
                float rainBr = 1F - Minecraft.getInstance().world.getRainStrength(pTicks);
                Map<StarLocation, Rectangle.Float> cstRenderInfo = RenderingConstellationUtils.renderConstellationIntoGUI(cst, renderStack, pos.x + guiLeft, pos.y + guiTop, this.getGuiZLevel(), size, size, 2.5F, () -> RenderingConstellationUtils.conCFlicker(ClientScheduler.getClientTick(), pTicks, 5 + gen.nextInt(15)) * rainBr, prog.hasConstellationDiscovered(cst), true);
                info.getFrameDrawInformation().putAll(cstRenderInfo);
            }
        }
        this.setBlitOffset(-5);
        this.renderDrawnLines(renderStack, gen, pTicks);
    }
    this.setBlitOffset(0);
    Blending.DEFAULT.apply();
    RenderSystem.disableBlend();
    RenderSystem.enableAlphaTest();
}
Also used : TelescopeRotationDrawArea(hellfirepvp.astralsorcery.client.screen.telescope.TelescopeRotationDrawArea) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation) StarLocation(hellfirepvp.astralsorcery.common.constellation.star.StarLocation) WorldContext(hellfirepvp.astralsorcery.common.constellation.world.WorldContext)

Aggregations

TelescopeRotationDrawArea (hellfirepvp.astralsorcery.client.screen.telescope.TelescopeRotationDrawArea)2 IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)2 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)2 IWeakConstellation (hellfirepvp.astralsorcery.common.constellation.IWeakConstellation)1 StarLocation (hellfirepvp.astralsorcery.common.constellation.star.StarLocation)1 WorldContext (hellfirepvp.astralsorcery.common.constellation.world.WorldContext)1