use of icbm.classic.lib.transform.vector.Point in project ICBM-Classic by BuiltBrokenModding.
the class GuiContainerBase method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
for (Entry<Rectangle, String> entry : this.tooltips.entrySet()) {
if (entry.getKey().isWithin(new Point(mouseX - this.guiLeft, mouseY - this.guiTop))) {
this.tooltip = entry.getValue();
break;
}
}
if (this.tooltip != null && this.tooltip != "") {
java.util.List<String> lines = LanguageUtility.splitByLine(tooltip);
// TODO find a way to not have to convert to array to improve render time
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop, lines.toArray(new String[lines.size()]));
}
this.tooltip = "";
}
use of icbm.classic.lib.transform.vector.Point in project ICBM-Classic by BuiltBrokenModding.
the class Rectangle method isWithin_rotated.
public boolean isWithin_rotated(IPos2D p) {
// Rect corners
final Point cornerA = this.cornerA();
final Point cornerB = this.cornerB();
final Point cornerC = this.cornerC();
final Point cornerD = this.cornerD();
// Area of the triangles made from the corners and p
double areaAB = new Triangle(cornerA, cornerB, p).getArea();
double areaBC = new Triangle(cornerB, cornerC, p).getArea();
double areaCD = new Triangle(cornerC, cornerD, p).getArea();
double areaDA = new Triangle(cornerD, cornerA, p).getArea();
// If the area of the combined points is less and equals to area
return (areaAB + areaBC + areaCD + areaDA) <= getArea();
}
use of icbm.classic.lib.transform.vector.Point in project ICBM-Classic by BuiltBrokenModding.
the class TileRadarStation method getStrongRedstonePower.
public int getStrongRedstonePower(EnumFacing side) {
if (incomingMissiles.size() > 0) {
if (this.emitAll) {
return Math.min(15, 5 + incomingMissiles.size());
}
for (IMissile incomingMissile : this.incomingMissiles) {
Point position = new Point(incomingMissile.x(), incomingMissile.y());
EnumFacing missileTravelDirection = EnumFacing.DOWN;
double closest = -1;
for (EnumFacing rotation : EnumFacing.HORIZONTALS) {
double dist = position.distance(new Point(this.getPos().getX() + rotation.getXOffset(), this.getPos().getZ() + rotation.getZOffset()));
if (dist < closest || closest < 0) {
missileTravelDirection = rotation;
closest = dist;
}
}
if (missileTravelDirection.getOpposite().ordinal() == side.ordinal()) {
return Math.min(15, 5 + incomingMissiles.size());
}
}
}
return 0;
}
use of icbm.classic.lib.transform.vector.Point in project ICBM-Classic by BuiltBrokenModding.
the class GuiRadarStation method drawGuiContainerBackgroundLayer.
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
drawDefaultBackground();
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.containerPosX = (this.width - this.xSize) / 2;
this.containerPosY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(containerPosX, containerPosY, 0, 0, this.xSize, this.ySize);
this.radarCenter = new Point(this.containerPosX + this.xSize / 3 - 10, this.containerPosY + this.ySize / 2 + 4);
this.radarMapRadius = TileRadarStation.MAX_DETECTION_RANGE / 71f;
this.info = "";
this.info2 = "";
if (this.tileEntity.hasPower()) {
int range = 4;
for (Pos pos : tileEntity.guiDrawPoints) {
final RadarObjectType type = RadarObjectType.get(pos.zi());
final double x = pos.x();
final double z = pos.y();
Point position = new Point(radarCenter.x() + (x - this.tileEntity.getPos().getX()) / this.radarMapRadius, radarCenter.y() - (z - this.tileEntity.getPos().getZ()) / this.radarMapRadius);
switch(type) {
case MISSILE:
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_YELLOW_DOT);
break;
case MISSILE_IMPACT:
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_RED_DOT);
break;
case OTHER:
default:
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_WHITE_DOT);
break;
}
this.drawTexturedModalRect(position.xi(), position.yi(), 0, 0, 2, 2);
// Hover Detection
Point minPosition = position.add(-range);
Point maxPosition = position.add(range);
if (new Rectangle(minPosition, maxPosition).isWithin(this.mousePosition)) {
if (type == RadarObjectType.OTHER) {
this.info = String.format(LanguageUtility.getLocal("gui.misc.object"), (int) x, (int) z);
} else {
this.info = (type == RadarObjectType.MISSILE ? "\u00a76" : "\u00a74") + String.format(LanguageUtility.getLocal("gui.misc.missile"), (int) x, (int) z);
}
}
}
}
// Draw energy bar
if (tileEntity.getEnergy() > 0) {
float energyScale = tileEntity.getEnergy() / (float) tileEntity.getEnergyBufferSize();
final int textureWidth = 8;
final int textureHeight = 142 / 2;
final int height = (int) Math.min(textureHeight, Math.floor(textureHeight * energyScale));
this.drawTexturedModalRect(containerPosX + 248, containerPosY + 65 + (textureHeight - height), 0, (332 / 2) + textureHeight - height, textureWidth, height);
}
}
use of icbm.classic.lib.transform.vector.Point in project ICBM-Classic by BuiltBrokenModding.
the class GuiRadarStation method updateScreen.
@Override
public void updateScreen() {
super.updateScreen();
if (Mouse.isInsideWindow()) {
if (Mouse.getEventButton() == -1) {
this.mousePosition = new Point(Mouse.getEventX() * this.width / this.mc.displayWidth, this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1);
float difference = TileRadarStation.MAX_DETECTION_RANGE / this.radarMapRadius;
if (this.mousePosition.x() > this.radarCenter.x() - difference && this.mousePosition.x() < this.radarCenter.x() + difference && this.mousePosition.y() > this.radarCenter.y() - difference && this.mousePosition.y() < this.radarCenter.y() + difference) {
// Calculate from the mouse position the relative position
// on the grid
int xDifference = (int) (this.mousePosition.x() - this.radarCenter.x());
int yDifference = (int) (this.mousePosition.y() - this.radarCenter.y());
int xBlockDistance = (int) (xDifference * this.radarMapRadius);
int yBlockDistance = (int) (yDifference * this.radarMapRadius);
this.mouseOverCoords = new Point(this.tileEntity.getPos().getX() + xBlockDistance, this.tileEntity.getPos().getZ() - yBlockDistance);
}
}
}
if (!this.textFieldTriggerRange.isFocused()) {
this.textFieldTriggerRange.setText(this.tileEntity.safetyRange + "");
}
if (!this.textFieldDetectionRange.isFocused()) {
this.textFieldDetectionRange.setText(this.tileEntity.alarmRange + "");
}
}
Aggregations