1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-26 00:46:54 +00:00

Merge pull request #182 from SquidDev-CC/feature/turtle-upgrade-both

Allow turtle upgrades to act as tools and peripherals
This commit is contained in:
Daniel Ratcliffe 2017-05-04 22:02:09 +01:00 committed by GitHub
commit 4b0a976bd6
5 changed files with 22 additions and 4 deletions

View File

@ -24,4 +24,22 @@ public enum TurtleUpgradeType
* and can be interacted with the peripheral API (Such as the modem on Wireless Turtles).
*/
Peripheral,
/**
* An upgrade which provides both a tool and a peripheral. This can be used when you wish
* your upgrade to also provide methods. For example, a pickaxe could provide methods
* determining whether it can break the given block or not.
*/
Both,
;
public boolean isTool()
{
return this == Tool || this == Both;
}
public boolean isPeripheral()
{
return this == Peripheral || this == Both;
}
}

View File

@ -126,7 +126,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy
{
if( family == ComputerFamily.Beginners )
{
return upgrade.getType() == TurtleUpgradeType.Tool;
return upgrade.getType().isTool();
}
else
{

View File

@ -691,7 +691,7 @@ public class TileTurtle extends TileComputerBase
case 5: upgrade = getUpgrade( TurtleSide.Left ); break;
default: return false;
}
if( upgrade != null && upgrade.getType() == TurtleUpgradeType.Peripheral )
if( upgrade != null && upgrade.getType().isPeripheral() )
{
return true;
}

View File

@ -966,7 +966,7 @@ public class TurtleBrain implements ITurtleAccess
{
ITurtleUpgrade upgrade = getUpgrade( side );
IPeripheral peripheral = null;
if( upgrade != null && upgrade.getType() == TurtleUpgradeType.Peripheral )
if( upgrade != null && upgrade.getType().isPeripheral() )
{
peripheral = upgrade.createPeripheral( this, side );
}

View File

@ -31,7 +31,7 @@ public class TurtleToolCommand implements ITurtleCommand
if( !m_side.isPresent() || m_side.get() == side )
{
ITurtleUpgrade upgrade = turtle.getUpgrade( side );
if( upgrade != null && upgrade.getType() == TurtleUpgradeType.Tool )
if( upgrade != null && upgrade.getType().isTool() )
{
TurtleCommandResult result = upgrade.useTool( turtle, side, m_verb, m_direction.toWorldDir( turtle ) );
if( result.isSuccess() )