use of pneumaticCraft.common.progwidgets.ICondition in project PneumaticCraft by MineMaarten.
the class GuiProgWidgetCondition method initGui.
@Override
public void initGui() {
super.initGui();
if (isSidedWidget()) {
for (int i = 0; i < 6; i++) {
String sideName = PneumaticCraftUtils.getOrientationName(ForgeDirection.getOrientation(i));
GuiCheckBox checkBox = new GuiCheckBox(i, guiLeft + 4, guiTop + 30 + i * 12, 0xFF000000, sideName);
checkBox.checked = ((ISidedWidget) widget).getSides()[i];
addWidget(checkBox);
}
}
int baseX = isSidedWidget() ? 90 : 4;
int baseY = isUsingAndOr() ? 60 : 30;
List<GuiRadioButton> radioButtons;
GuiRadioButton radioButton;
if (isUsingAndOr()) {
radioButtons = new ArrayList<GuiRadioButton>();
radioButton = new GuiRadioButton(6, guiLeft + baseX, guiTop + 30, 0xFF000000, "Any block");
radioButton.checked = !((ICondition) widget).isAndFunction();
addWidget(radioButton);
radioButtons.add(radioButton);
radioButton.otherChoices = radioButtons;
radioButton = new GuiRadioButton(7, guiLeft + baseX, guiTop + 42, 0xFF000000, "All blocks");
radioButton.checked = ((ICondition) widget).isAndFunction();
addWidget(radioButton);
radioButtons.add(radioButton);
radioButton.otherChoices = radioButtons;
}
if (requiresNumber()) {
radioButtons = new ArrayList<GuiRadioButton>();
for (int i = 0; i < ICondition.Operator.values().length; i++) {
radioButton = new GuiRadioButton(8 + i, guiLeft + baseX, guiTop + baseY + i * 12, 0xFF000000, ICondition.Operator.values()[i].toString());
radioButton.checked = ((ICondition) widget).getOperator().ordinal() == i;
addWidget(radioButton);
radioButtons.add(radioButton);
radioButton.otherChoices = radioButtons;
}
textField = new WidgetTextField(Minecraft.getMinecraft().fontRenderer, guiLeft + baseX, guiTop + baseY + 30, 50, 11);
textField.setText(((ICondition) widget).getRequiredCount() + "");
addWidget(textField);
}
}
use of pneumaticCraft.common.progwidgets.ICondition in project PneumaticCraft by MineMaarten.
the class ProgWidgetRFCondition method getEvaluator.
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {
@Override
protected boolean evaluate(ChunkPosition pos) {
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
int energy = 0;
if (te instanceof IEnergyReceiver) {
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (getSides()[d.ordinal()]) {
energy = Math.max(((IEnergyReceiver) te).getEnergyStored(d), energy);
}
}
}
if (te instanceof IEnergyProvider) {
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (getSides()[d.ordinal()]) {
energy = Math.max(((IEnergyProvider) te).getEnergyStored(d), energy);
}
}
}
return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ? energy == ((ICondition) widget).getRequiredCount() : energy >= ((ICondition) widget).getRequiredCount();
}
};
}
Aggregations