Merge pull request #1761 from Prototik/gate-and-ui
Fix partial state info glitches in AND gates
This commit is contained in:
commit
684c695342
1 changed files with 22 additions and 32 deletions
|
@ -37,8 +37,6 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
private final ContainerGateInterface container;
|
||||
private final Pipe pipe;
|
||||
private int numSlots;
|
||||
private TriggerSlot[] triggerSlots;
|
||||
private TriggerParameterSlot[] triggerParameterSlots;
|
||||
|
||||
class TriggerSlot extends AdvancedSlot {
|
||||
|
||||
|
@ -192,27 +190,21 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
|
||||
if (numSlots == 1) {
|
||||
slots = new AdvancedSlot[2];
|
||||
triggerSlots = new TriggerSlot[1];
|
||||
triggerParameterSlots = new TriggerParameterSlot[0];
|
||||
|
||||
slots[0] = triggerSlots[0] = new TriggerSlot(62, 26, pipe, 0);
|
||||
slots[0] = new TriggerSlot(62, 26, pipe, 0);
|
||||
slots[1] = new ActionSlot(98, 26, pipe, 0);
|
||||
} else if (numSlots == 2) {
|
||||
slots = new AdvancedSlot[4];
|
||||
triggerSlots = new TriggerSlot[2];
|
||||
triggerParameterSlots = new TriggerParameterSlot[0];
|
||||
|
||||
slots[0] = triggerSlots[0] = new TriggerSlot(62, 26, pipe, 0);
|
||||
slots[1] = triggerSlots[1] = new TriggerSlot(62, 44, pipe, 1);
|
||||
slots[0] = new TriggerSlot(62, 26, pipe, 0);
|
||||
slots[1] = new TriggerSlot(62, 44, pipe, 1);
|
||||
slots[2] = new ActionSlot(98, 26, pipe, 0);
|
||||
slots[3] = new ActionSlot(98, 44, pipe, 1);
|
||||
} else if (numSlots == 4) {
|
||||
slots = new AdvancedSlot[12];
|
||||
triggerSlots = new TriggerSlot[4];
|
||||
triggerParameterSlots = new TriggerParameterSlot[4];
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
slots[position] = triggerSlots[position] = new TriggerSlot(53, 26 + 18 * k, pipe, position);
|
||||
slots[position] = new TriggerSlot(53, 26 + 18 * k, pipe, position);
|
||||
position++;
|
||||
}
|
||||
|
||||
|
@ -222,19 +214,17 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
slots[position] = triggerParameterSlots[position - 8] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8);
|
||||
slots[position] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8);
|
||||
position++;
|
||||
|
||||
}
|
||||
} else if (numSlots == 8) {
|
||||
slots = new AdvancedSlot[24];
|
||||
triggerSlots = new TriggerSlot[8];
|
||||
triggerParameterSlots = new TriggerParameterSlot[8];
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
slots[position] = triggerSlots[position] = new TriggerSlot(8, 26 + 18 * k, pipe, position);
|
||||
slots[position] = new TriggerSlot(8, 26 + 18 * k, pipe, position);
|
||||
position++;
|
||||
slots[position] = triggerSlots[position] = new TriggerSlot(98, 26 + 18 * k, pipe, position);
|
||||
slots[position] = new TriggerSlot(98, 26 + 18 * k, pipe, position);
|
||||
position++;
|
||||
}
|
||||
|
||||
|
@ -246,9 +236,9 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
slots[position] = triggerParameterSlots[position - 16] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16);
|
||||
slots[position] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16);
|
||||
position++;
|
||||
slots[position] = triggerParameterSlots[position - 16] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16);
|
||||
slots[position] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16);
|
||||
position++;
|
||||
}
|
||||
}
|
||||
|
@ -280,12 +270,24 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
drawTexturedModalRect(cornerX, cornerY, 0, 0, xSize, ySize);
|
||||
|
||||
int triggerTracker = 0;
|
||||
boolean allTriggersActive = true;
|
||||
for (AdvancedSlot slot : slots) {
|
||||
if (slot instanceof TriggerSlot) {
|
||||
boolean active = container.triggerState[triggerTracker++];
|
||||
if (slot.isDefined() && ((TriggerSlot) slot).getTrigger() != null && !active) {
|
||||
allTriggersActive = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
triggerTracker = 0;
|
||||
for (int s = 0; s < slots.length; ++s) {
|
||||
AdvancedSlot slot = slots[s];
|
||||
|
||||
if (slot instanceof TriggerSlot) {
|
||||
ITrigger trigger = ((TriggerSlot) slot).getTrigger();
|
||||
boolean halfWidth = pipe.gate.logic == GateDefinition.GateLogic.AND && !isAllTriggersActive();
|
||||
boolean halfWidth = pipe.gate.logic == GateDefinition.GateLogic.AND && !allTriggersActive;
|
||||
|
||||
if (pipe.gate.material.hasParameterSlot) {
|
||||
|
||||
|
@ -322,18 +324,6 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
drawBackgroundSlots();
|
||||
}
|
||||
|
||||
private boolean isAllTriggersActive() {
|
||||
for (int i = 0; i < triggerSlots.length; i++) {
|
||||
TriggerSlot slot = triggerSlots[i];
|
||||
ITrigger trigger = slot.getTrigger();
|
||||
ITriggerParameter parameter = triggerParameterSlots.length > i ? triggerParameterSlots[i].getTriggerParameter() : null;
|
||||
if (trigger != null && !container.isNearbyTriggerActive(trigger, parameter)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
|
|
Loading…
Reference in a new issue