// Computes the actions depending on the triggers
for (int it = 0; it < MAX_STATEMENTS; ++it) {
actionsState[it] = ActionActiveState.Deactivated;
IStatement trigger = triggers[it];
IStatementParameter[] parameter = triggerParameters[it];
if (trigger != null) {
if (isTriggerActive(trigger, parameter)) {
actionsState[it] = ActionActiveState.Partial;
}
}
}
activeActions = new ArrayList<StatementSlot>();
for (int it = 0; it < MAX_STATEMENTS; ++it) {
boolean allActive = true;
boolean oneActive = false;
if (actions[it] == null) {
continue;
}
for (int j = 0; j < MAX_STATEMENTS; ++j) {
if (actionGroups[j] == it) {
if (actionsState[j] != ActionActiveState.Partial) {
allActive = false;
} else {
oneActive = true;
}
}
}
if ((logic == GateLogic.AND && allActive && oneActive) || (logic == GateLogic.OR && oneActive)) {
if (logic == GateLogic.AND) {
for (int j = 0; j < MAX_STATEMENTS; ++j) {
if (actionGroups[j] == it) {
actionsState[j] = ActionActiveState.Activated;
}
}
}
StatementSlot slot = new StatementSlot();
slot.statement = actions[it];
slot.parameters = actionParameters[it];
activeActions.add(slot);
}
if (logic == GateLogic.OR && actionsState[it] == ActionActiveState.Partial) {
actionsState[it] = ActionActiveState.Activated;
}
}
// Activate the actions
for (StatementSlot slot : activeActions) {
IStatement action = slot.statement;
if (action instanceof IActionInternal) {
((IActionInternal) action).actionActivate(this, slot.parameters);
} else if (action instanceof IActionExternal) {
for (ForgeDirection side: ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = this.getPipe().getTile().getAdjacentTile(side);