Search in sources :

Example 1 with StatementParameterRedstoneLevel

use of buildcraft.core.statements.StatementParameterRedstoneLevel in project BuildCraft by BuildCraft.

the class TriggerRedstoneFaderInput method isTriggerActive.

@Override
public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) {
    if (!(container instanceof IGate) || parameters.length < 1 || !(parameters[0] instanceof StatementParameterRedstoneLevel)) {
        return false;
    }
    int level = ((StatementParameterRedstoneLevel) parameters[0]).level;
    IGate gate = (IGate) container;
    TileGenericPipe tile = (TileGenericPipe) gate.getPipe().getTile();
    int inputLevel = tile.redstoneInput;
    if (parameters.length > 1 && parameters[1] instanceof StatementParamGateSideOnly && ((StatementParamGateSideOnly) parameters[1]).isOn) {
        inputLevel = tile.redstoneInputSide[gate.getSide().ordinal()];
    }
    switch(mode) {
        case LESS:
            return inputLevel < level;
        case EQUAL:
        default:
            return inputLevel == level;
        case GREATER:
            return inputLevel > level;
    }
}
Also used : StatementParameterRedstoneLevel(buildcraft.core.statements.StatementParameterRedstoneLevel) IGate(buildcraft.api.gates.IGate) TileGenericPipe(buildcraft.transport.TileGenericPipe) StatementParamGateSideOnly(buildcraft.core.statements.StatementParamGateSideOnly)

Aggregations

IGate (buildcraft.api.gates.IGate)1 StatementParamGateSideOnly (buildcraft.core.statements.StatementParamGateSideOnly)1 StatementParameterRedstoneLevel (buildcraft.core.statements.StatementParameterRedstoneLevel)1 TileGenericPipe (buildcraft.transport.TileGenericPipe)1