Search in sources :

Example 1 with PktDiscoverConstellation

use of hellfirepvp.astralsorcery.common.network.play.client.PktDiscoverConstellation in project AstralSorcery by HellFirePvP.

the class ConstellationDiscoveryScreen method checkConstellationMatch.

private void checkConstellationMatch() {
    if (this.currentDrawArea == null || this.currentDrawArea.cstDisplay.isEmpty()) {
        return;
    }
    PlayerProgress progress = ResearchHelper.getClientProgress();
    for (IConstellation cst : this.currentDrawArea.cstDisplay.keySet()) {
        ConstellationDisplayInformation info = this.currentDrawArea.cstDisplay.get(cst);
        if (progress.hasConstellationDiscovered(cst) || !progress.hasSeenConstellation(cst)) {
            continue;
        }
        if (cst.getStarConnections().size() != this.drawnLines.size()) {
            continue;
        }
        if (!cst.canDiscover(Minecraft.getInstance().player, progress)) {
            continue;
        }
        boolean didMatch = true;
        for (StarConnection cstConnection : cst.getStarConnections()) {
            Rectangle.Float rctFrom = info.frameDrawInformation.get(cstConnection.getLeft());
            Rectangle.Float rctTo = info.frameDrawInformation.get(cstConnection.getRight());
            if (rctFrom == null || rctTo == null) {
                didMatch = false;
                break;
            }
            if (!hasMatchingDrawnLine(rctFrom, rctTo)) {
                didMatch = false;
                break;
            }
        }
        if (didMatch) {
            PacketChannel.CHANNEL.sendToServer(new PktDiscoverConstellation(cst));
            this.clearDrawing();
            return;
        }
    }
}
Also used : StarConnection(hellfirepvp.astralsorcery.common.constellation.star.StarConnection) PktDiscoverConstellation(hellfirepvp.astralsorcery.common.network.play.client.PktDiscoverConstellation) PlayerProgress(hellfirepvp.astralsorcery.common.data.research.PlayerProgress) IConstellation(hellfirepvp.astralsorcery.common.constellation.IConstellation)

Aggregations

IConstellation (hellfirepvp.astralsorcery.common.constellation.IConstellation)1 StarConnection (hellfirepvp.astralsorcery.common.constellation.star.StarConnection)1 PlayerProgress (hellfirepvp.astralsorcery.common.data.research.PlayerProgress)1 PktDiscoverConstellation (hellfirepvp.astralsorcery.common.network.play.client.PktDiscoverConstellation)1