add resources for overheat gate, move redstone actions to their respective classes (for #1891)

This commit is contained in:
asiekierka 2014-11-23 15:00:22 +01:00
parent ba20bea0ec
commit 3437d57818
6 changed files with 41 additions and 43 deletions

View file

@ -115,6 +115,7 @@ gate.trigger.engine.blue=Engine Blue
gate.trigger.engine.green=Engine Green
gate.trigger.engine.yellow=Engine Yellow
gate.trigger.engine.red=Engine Red
gate.trigger.engine.overheat=Engine Overheat
gate.trigger.fluid.empty=Tank Empty
gate.trigger.fluid.contains=Fluid in Tank
gate.trigger.fluid.space=Space for Fluid

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

View file

@ -15,9 +15,15 @@ import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.Gate;
public class ActionRedstoneOutput extends BCStatement implements IActionInternal {
public ActionRedstoneOutput(String s) {
// Used by fader output
super(s);
}
public ActionRedstoneOutput() {
super("buildcraft:redstone.output", "buildcraft.redstone.output");
}
@ -43,10 +49,24 @@ public class ActionRedstoneOutput extends BCStatement implements IActionInternal
return 1;
}
protected boolean isSideOnly(IStatementParameter[] parameters) {
if (parameters != null && parameters.length >= 1 && parameters[0] instanceof StatementParameterRedstoneGateSideOnly) {
return ((StatementParameterRedstoneGateSideOnly) parameters[0]).isOn;
}
return false;
}
@Override
public void actionActivate(IStatementContainer source,
IStatementParameter[] parameters) {
if (source instanceof Gate) {
((Gate) source).setRedstoneOutput(isSideOnly(parameters), getSignalLevel());
}
}
protected int getSignalLevel() {
return 15;
}
@Override

View file

@ -346,7 +346,15 @@ public final class Gate implements IGate, IStatementContainer {
public int getSidedRedstoneOutput() {
return redstoneOutputSide;
}
public void setRedstoneOutput(boolean sideOnly, int value) {
redstoneOutputSide = value;
if (!sideOnly) {
redstoneOutput = value;
}
}
public void startResolution() {
for (GateExpansionController expansion : expansions.values()) {
expansion.startResolution();
@ -465,33 +473,17 @@ public final class Gate implements IGate, IStatementContainer {
} else {
continue;
}
// TODO: A lot of the code below should be removed in favor
// of calls to actionActivate
// Custom gate actions take precedence over defaults.
if (resolveAction(action)) {
continue;
}
if (action instanceof ActionRedstoneOutput || action instanceof ActionRedstoneFaderOutput) {
if (slot.parameters != null && slot.parameters.length >= 1 &&
slot.parameters[0] instanceof StatementParameterRedstoneGateSideOnly &&
((StatementParameterRedstoneGateSideOnly) slot.parameters[0]).isOn) {
redstoneOutputSide = (action instanceof ActionRedstoneFaderOutput) ? ((ActionRedstoneFaderOutput) action).level : 15;
} else {
redstoneOutput = (action instanceof ActionRedstoneFaderOutput) ? ((ActionRedstoneFaderOutput) action).level : 15;
if (redstoneOutput > redstoneOutputSide) {
redstoneOutputSide = redstoneOutput;
}
}
} else {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = pipe.container.getTile(side);
if (tile instanceof IActionReceptor) {
IActionReceptor recept = (IActionReceptor) tile;
recept.actionActivated(action, slot.parameters);
}
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = pipe.container.getTile(side);
if (tile instanceof IActionReceptor) {
IActionReceptor recept = (IActionReceptor) tile;
recept.actionActivated(action, slot.parameters);
}
}
}

View file

@ -15,11 +15,13 @@ import cpw.mods.fml.relauncher.SideOnly;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.core.statements.ActionRedstoneOutput;
import buildcraft.core.statements.BCStatement;
import buildcraft.core.statements.StatementParameterRedstoneGateSideOnly;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.Gate;
public class ActionRedstoneFaderOutput extends BCStatement implements IActionInternal {
public class ActionRedstoneFaderOutput extends ActionRedstoneOutput implements IActionInternal {
public final int level;
@ -45,26 +47,9 @@ public class ActionRedstoneFaderOutput extends BCStatement implements IActionInt
public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level));
}
@Override
public IStatementParameter createParameter(int index) {
IStatementParameter param = null;
if (index == 0) {
param = new StatementParameterRedstoneGateSideOnly();
}
return param;
}
@Override
public int maxParameters() {
return 1;
}
@Override
public void actionActivate(IStatementContainer source,
IStatementParameter[] parameters) {
protected int getSignalLevel() {
return level;
}
}