Search in sources :

Example 1 with ILimitVelCart

use of club.nsdn.nyasamarailway.entity.ILimitVelCart in project NyaSamaRailway by NSDN.

the class NSCxMRenderer method doRenderHUD.

private void doRenderHUD(EntityMinecart cart) {
    if (cart instanceof ILocomotive) {
        ILocomotive loco = (ILocomotive) cart;
        if (cart instanceof ILimitVelCart) {
            ILimitVelCart velLoco = (ILimitVelCart) cart;
            float v = (float) loco.getEngineVel();
            float lim = (float) velLoco.getMaxVelocity();
            float a = v - (float) loco.getEnginePrevVel();
            float angle;
            int d = loco.getEngineDir(), p = loco.getEnginePower(), r = loco.getEngineBrake();
            String dir = d == 1 ? "F" : (d == 0 ? "N" : "R");
            String pwr = String.format("%2d", p);
            String brk = String.format("%2d", 10 - r);
            String sv = String.format("%1.2f", v);
            String sl = String.format("%1.2f", lim);
            GL11.glPushMatrix();
            GL11.glRotated(45, 0, 1, 0);
            RendererHelper.renderPartWithResource(modelScreen, "base", textureScreen);
            // HUD1406
            doRenderText(0, "-= NSR--NTP =-");
            doRenderText(1, "dir:  " + dir);
            doRenderText(2, "pwr: " + pwr + (r <= 1 ? " STOP" : "  RUN"));
            doRenderText(3, "brk: " + brk + (r == 1 ? " EME" : ""));
            doRenderText(4, "vel:" + sv + "m/t");
            doRenderText(5, "lim:" + sl + "m/t");
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glRotated(-45, 0, 1, 0);
            RendererHelper.renderPartWithResource(modelScreen, "base", textureScreen);
            // HUD1406
            doRenderText(0, "-= NTP--EXT =-");
            doRenderText(1, "vel:" + String.format("%1.2f", v * 72) + "km/h");
            doRenderText(2, "acc:" + String.format("%1.2f", a * 400) + "m/s2");
            doRenderText(3, "id: " + String.format("%x", cart.getEntityId()));
            doRenderText(4, "dim:" + String.format("%x", cart.dimension));
            doRenderText(5, "yaw:" + String.format("%1.2f", cart.rotationYaw));
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glRotated(30, 0, 0, 1);
            GL11.glTranslated(0.5, 0, 0);
            RendererHelper.renderWithResource(modelMeterV, textureMeterV);
            angle = v / 9.0F * ANGLE_HALF * 2 - ANGLE_HALF;
            if (angle > ANGLE_HALF)
                angle = ANGLE_HALF;
            GL11.glPushMatrix();
            GL11.glTranslatef(0.625F, 0.9375F, -0.625F);
            GL11.glTranslatef(-0.00625F, 0.0F, 0.00625F);
            GL11.glPushMatrix();
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
            GL11.glPushMatrix();
            GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
            RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
            GL11.glPopMatrix();
            GL11.glPopMatrix();
            GL11.glPopMatrix();
            RendererHelper.renderWithResource(modelMeterA, textureMeterA);
            angle = a / 0.03F * ANGLE_HALF;
            if (Math.abs(angle) > ANGLE_HALF)
                angle = Math.signum(angle) * ANGLE_HALF;
            GL11.glPushMatrix();
            GL11.glTranslatef(0.625F, 0.9375F, 0.625F);
            GL11.glTranslatef(-0.00625F, 0.0F, -0.00625F);
            GL11.glPushMatrix();
            GL11.glRotatef(-45.0F, 0.0F, 1.0F, 0.0F);
            GL11.glPushMatrix();
            GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
            RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
            GL11.glPopMatrix();
            GL11.glPopMatrix();
            GL11.glPopMatrix();
            GL11.glPopMatrix();
        }
    }
}
Also used : ILimitVelCart(club.nsdn.nyasamarailway.entity.ILimitVelCart) ILocomotive(club.nsdn.nyasamarailway.entity.ILocomotive)

Example 2 with ILimitVelCart

use of club.nsdn.nyasamarailway.entity.ILimitVelCart in project NyaSamaRailway by NSDN.

the class NSCxRenderer method doRenderHUD.

private void doRenderHUD(EntityMinecart cart) {
    if (cart instanceof IMotorCart) {
        IMotorCart motorCart = (IMotorCart) cart;
        if (cart instanceof ILimitVelCart) {
            ILimitVelCart velCart = (ILimitVelCart) cart;
            float v = (float) motorCart.getMotorVel();
            float lim = (float) velCart.getMaxVelocity();
            float a = Math.signum(v) / 3;
            float angle;
            int d = motorCart.getMotorDir(), p = motorCart.getMotorPower(), r = motorCart.getMotorBrake();
            boolean isOff = !motorCart.getMotorState();
            RendererHelper.renderPartWithResource(modelScreen, "base", textureScreen);
            String dir = d == 1 ? "F" : (d == 0 ? "N" : "R");
            String pwr = String.format("%2d", p);
            String brk = String.format("%2d", 10 - r);
            String sv = String.format("%1.2f", v);
            String sl = String.format("%1.2f", lim);
            // HUD1406
            doRenderText(0, "-= NSR--NTP =-");
            doRenderText(1, "dir:  " + dir);
            doRenderText(2, "pwr: " + pwr + (isOff ? " IDLE" : "  RUN"));
            doRenderText(3, "brk: " + brk + (r == 1 ? " EME" : ""));
            doRenderText(4, "vel:" + sv + "m/t");
            doRenderText(5, "lim:" + sl + "m/t");
            RendererHelper.renderWithResource(modelMeterV, textureMeterV);
            angle = v / 9.0F * ANGLE_HALF * 2 - ANGLE_HALF;
            if (angle > ANGLE_HALF)
                angle = ANGLE_HALF;
            GL11.glPushMatrix();
            GL11.glTranslatef(0.625F, 0.9375F, -0.625F);
            GL11.glTranslatef(-0.00625F, 0.0F, 0.00625F);
            GL11.glPushMatrix();
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
            GL11.glPushMatrix();
            GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
            RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
            GL11.glPopMatrix();
            GL11.glPopMatrix();
            GL11.glPopMatrix();
            RendererHelper.renderWithResource(modelMeterA, textureMeterA);
            angle = a / 0.03F * ANGLE_HALF;
            if (Math.abs(angle) > ANGLE_HALF)
                angle = Math.signum(angle) * ANGLE_HALF;
            GL11.glPushMatrix();
            GL11.glTranslatef(0.625F, 0.9375F, 0.625F);
            GL11.glTranslatef(-0.00625F, 0.0F, -0.00625F);
            GL11.glPushMatrix();
            GL11.glRotatef(-45.0F, 0.0F, 1.0F, 0.0F);
            GL11.glPushMatrix();
            GL11.glRotatef(angle, 1.0F, 0.0F, 0.0F);
            RendererHelper.renderWithResource(modelMeterPointer, textureMeterPointer);
            GL11.glPopMatrix();
            GL11.glPopMatrix();
            GL11.glPopMatrix();
        }
    }
}
Also used : IMotorCart(club.nsdn.nyasamarailway.entity.IMotorCart) ILimitVelCart(club.nsdn.nyasamarailway.entity.ILimitVelCart)

Example 3 with ILimitVelCart

use of club.nsdn.nyasamarailway.entity.ILimitVelCart in project NyaSamaRailway by NSDN.

the class BlockRailNoSleeperRFID method onMinecartPass.

@Override
public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z) {
    if (world.getTileEntity(x, y, z) instanceof TileEntityRailRFID) {
        TileEntityRailRFID rfid = (TileEntityRailRFID) world.getTileEntity(x, y, z);
        if (cart instanceof LocoBase) {
            LocoBase loco = (LocoBase) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                loco.setEnginePower(rfid.P);
                loco.setEngineBrake(rfid.R);
            }
        } else if (cart instanceof IMotorCart) {
            IMotorCart motorCart = (IMotorCart) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                motorCart.setMotorPower(rfid.P);
                motorCart.setMotorBrake(rfid.R);
                motorCart.setMotorState(rfid.state);
            }
        }
        if (cart instanceof ILimitVelCart) {
            ILimitVelCart limitVelCart = (ILimitVelCart) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                limitVelCart.setMaxVelocity(rfid.vel);
            }
        }
        if (cart instanceof IExtendedInfoCart) {
            IExtendedInfoCart infoCart = (IExtendedInfoCart) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                if (!rfid.cartSide.equals("null"))
                    infoCart.setExtendedInfo("side", rfid.cartSide);
                if (!rfid.cartStr.equals("null"))
                    infoCart.setExtendedInfo("str", rfid.cartStr);
                if (!rfid.cartJet.equals("null"))
                    infoCart.setExtendedInfo("jet", rfid.cartJet);
            }
        }
    }
}
Also used : IMotorCart(club.nsdn.nyasamarailway.entity.IMotorCart) ILimitVelCart(club.nsdn.nyasamarailway.entity.ILimitVelCart) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) IExtendedInfoCart(club.nsdn.nyasamarailway.entity.IExtendedInfoCart)

Example 4 with ILimitVelCart

use of club.nsdn.nyasamarailway.entity.ILimitVelCart in project NyaSamaRailway by NSDN.

the class BlockRailRFID method onMinecartPass.

@Override
public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z) {
    if (world.getTileEntity(x, y, z) instanceof TileEntityRailRFID) {
        TileEntityRailRFID rfid = (TileEntityRailRFID) world.getTileEntity(x, y, z);
        if (cart instanceof LocoBase) {
            LocoBase loco = (LocoBase) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                loco.setEnginePower(rfid.P);
                loco.setEngineBrake(rfid.R);
            }
        } else if (cart instanceof IMotorCart) {
            IMotorCart motorCart = (IMotorCart) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                motorCart.setMotorPower(rfid.P);
                motorCart.setMotorBrake(rfid.R);
                motorCart.setMotorState(rfid.state);
            }
        }
        if (cart instanceof ILimitVelCart) {
            ILimitVelCart limitVelCart = (ILimitVelCart) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                limitVelCart.setMaxVelocity(rfid.vel);
            }
        }
        if (cart instanceof IExtendedInfoCart) {
            IExtendedInfoCart infoCart = (IExtendedInfoCart) cart;
            if (isRailPowered(world, x, y, z) || rfid.senderIsPowered()) {
                if (!rfid.cartSide.equals("null"))
                    infoCart.setExtendedInfo("side", rfid.cartSide);
                if (!rfid.cartStr.equals("null"))
                    infoCart.setExtendedInfo("str", rfid.cartStr);
                if (!rfid.cartJet.equals("null"))
                    infoCart.setExtendedInfo("jet", rfid.cartJet);
            }
        }
    }
}
Also used : IMotorCart(club.nsdn.nyasamarailway.entity.IMotorCart) ILimitVelCart(club.nsdn.nyasamarailway.entity.ILimitVelCart) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) IExtendedInfoCart(club.nsdn.nyasamarailway.entity.IExtendedInfoCart)

Aggregations

ILimitVelCart (club.nsdn.nyasamarailway.entity.ILimitVelCart)4 IMotorCart (club.nsdn.nyasamarailway.entity.IMotorCart)3 IExtendedInfoCart (club.nsdn.nyasamarailway.entity.IExtendedInfoCart)2 LocoBase (club.nsdn.nyasamarailway.entity.LocoBase)2 ILocomotive (club.nsdn.nyasamarailway.entity.ILocomotive)1