package com.zivilon.cinder_loe.carriage.gui;

import lotr.client.gui.LOTRGuiScreenBase;
import net.minecraft.client.gui.GuiScreen;

public class GuiCarriageFade extends LOTRGuiScreenBase {
    private int ticksPassed = 0;
    private final int totalTicks = 60;

    public GuiCarriageFade() {
        // no destination name needed anymore
    }

    @Override
    public void updateScreen() {
        ticksPassed++;
        if (ticksPassed == 10 || ticksPassed == 30) {
            mc.thePlayer.playSound("mob.horse.gallop", 1.0F, 1.0F);
        }
        if (ticksPassed == 50) {
            mc.thePlayer.playSound("mob.horse.angry", 1.0F, 1.0F);
        }
        if (ticksPassed >= totalTicks) {
            mc.displayGuiScreen(null);
        }
    }

    @Override
    public void drawScreen(int mouseX, int mouseY, float partialTicks) {
        int alpha = (ticksPassed < totalTicks / 2)
                ? (int)(255 * (ticksPassed / (float)(totalTicks / 2)))
                : (int)(255 * ((totalTicks - ticksPassed) / (float)(totalTicks / 2)));

        alpha = Math.min(255, Math.max(0, alpha));
        drawRect(0, 0, width, height, (alpha << 24));
    }

    @Override
    public boolean doesGuiPauseGame() {
        return false;
    }
}
