Some refactoring.

This commit is contained in:
AlgorithmX2 2014-07-23 14:20:47 -05:00
parent 298ae41198
commit 50b0285c15
11 changed files with 32 additions and 60 deletions

View file

@ -58,11 +58,6 @@ public class EnergyGridCache implements IEnergyGrid
double tickDrainPerTick = 0;
double tickInjectionPerTick = 0;
// Double[] totalDrainPastTicks = new Double[] { 0.0, 0.0, 0.0, 0.0, 0.0,
// 0.0, 0.0, 0.0, 0.0, 0.0 };
// Double[] totalInjectionPastTicks = new Double[] { 0.0, 0.0, 0.0, 0.0,
// 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
/**
* power status
*/
@ -76,13 +71,15 @@ public class EnergyGridCache implements IEnergyGrid
double extra = 0;
IAEPowerStorage lastProvider;
Set<IAEPowerStorage> providers = new LinkedHashSet();
final Set<IAEPowerStorage> providers = new LinkedHashSet();
IAEPowerStorage lastRequestor;
Set<IAEPowerStorage> requesters = new LinkedHashSet();
final Set<IAEPowerStorage> requesters = new LinkedHashSet();
public TreeSet<EnergyThreshold> interests = new TreeSet<EnergyThreshold>();
private HashMap<IGridNode, IEnergyWatcher> watchers = new HashMap<IGridNode, IEnergyWatcher>();
final public TreeSet<EnergyThreshold> interests = new TreeSet<EnergyThreshold>();
final private HashMap<IGridNode, IEnergyWatcher> watchers = new HashMap<IGridNode, IEnergyWatcher>();
final private Set<IEnergyGrid> localSeen = new HashSet();
private double buffer()
{
@ -111,7 +108,7 @@ public class EnergyGridCache implements IEnergyGrid
return lastProvider;
}
Multiset<IEnergyGridProvider> gproviders = HashMultiset.create();
final Multiset<IEnergyGridProvider> gproviders = HashMultiset.create();
final IGrid myGrid;
PathGridCache pgc;
@ -259,8 +256,6 @@ public class EnergyGridCache implements IEnergyGrid
return Math.max( 0.0, amt - buffer() );
}
Set<IEnergyGrid> localSeen = new HashSet();
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
{
@ -388,15 +383,6 @@ public class EnergyGridCache implements IEnergyGrid
tickDrainPerTick = 0;
tickInjectionPerTick = 0;
// next tick is here...
// for (int x = 0; x < totalDrainPastTicks.length - 1; x++)
// totalDrainPastTicks[x + 1] = totalDrainPastTicks[x];
// totalDrainPastTicks[0] = 0.0;
// for (int x = 0; x < totalInjectionPastTicks.length - 1; x++)
// totalInjectionPastTicks[x + 1] = totalInjectionPastTicks[x];
// totalInjectionPastTicks[0] = 0.0;
// power information.
double drained = extractAEPower( getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
boolean currentlyHasPower = drained >= drainPerTick - 0.001;
@ -417,8 +403,6 @@ public class EnergyGridCache implements IEnergyGrid
publicPowerState( false, myGrid );
availableTicksSinceUpdate++;
// if ( extra > 32 )
// injectPower( 0.0, Actionable.MODULATE );
}
private void publicPowerState(boolean newState, IGrid grid)
@ -559,25 +543,13 @@ public class EnergyGridCache implements IEnergyGrid
@Override
public double getAvgPowerUsage()
{
return avgDrainPerTick;/*
* double out = 0;
*
* for (double x : totalDrainPastTicks) out += x;
*
* return out / totalDrainPastTicks.length;
*/
return avgDrainPerTick;
}
@Override
public double getAvgPowerInjection()
{
return avgInjectionPerTick;/*
* double out = 0;
*
* for (double x : totalInjectionPastTicks) out += x;
*
* return out / totalInjectionPastTicks.length;
*/
return avgInjectionPerTick;
}
@Override

View file

@ -39,16 +39,16 @@ public class PathGridCache implements IPathingGrid
boolean updateNetwork = true;
boolean booting = false;
LinkedList<PathSegment> active = new LinkedList();
final LinkedList<PathSegment> active = new LinkedList();
ControllerState controllerState = ControllerState.NO_CONTROLLER;
int instance = Integer.MIN_VALUE;
int ticksUntilReady = 20;
Set<TileController> controllers = new HashSet();
Set<IGridNode> requireChannels = new HashSet();
Set<IGridNode> blockDense = new HashSet();
final Set<TileController> controllers = new HashSet();
final Set<IGridNode> requireChannels = new HashSet();
final Set<IGridNode> blockDense = new HashSet();
final IGrid myGrid;
private HashSet<IPathItem> semiOpen = new HashSet();

View file

@ -22,8 +22,8 @@ import appeng.me.GridNode;
public class SecurityCache implements IGridCache, ISecurityGrid
{
private List<ISecurityProvider> securityProvider = new ArrayList();
private HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
final private List<ISecurityProvider> securityProvider = new ArrayList();
final private HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
public SecurityCache(IGrid g) {
myGrid = g;

View file

@ -24,12 +24,12 @@ public class TickManagerCache implements ITickManager
myGrid = g;
}
HashMap<IGridNode, TickTracker> alertable = new HashMap<IGridNode, TickTracker>();
final HashMap<IGridNode, TickTracker> alertable = new HashMap<IGridNode, TickTracker>();
HashMap<IGridNode, TickTracker> sleeping = new HashMap<IGridNode, TickTracker>();
HashMap<IGridNode, TickTracker> awake = new HashMap<IGridNode, TickTracker>();
final HashMap<IGridNode, TickTracker> sleeping = new HashMap<IGridNode, TickTracker>();
final HashMap<IGridNode, TickTracker> awake = new HashMap<IGridNode, TickTracker>();
PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<TickTracker>();
final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<TickTracker>();
public long getCurrentTick()
{

View file

@ -10,7 +10,7 @@ import appeng.util.Platform;
public abstract class MBCalculator
{
private IAEMultiBlock target;
final private IAEMultiBlock target;
public MBCalculator(IAEMultiBlock t) {
target = t;

View file

@ -17,8 +17,8 @@ import appeng.tile.crafting.TileCraftingTile;
public class CraftingCPUCalculator extends MBCalculator
{
TileCraftingTile tqb;
final TileCraftingTile tqb;
public CraftingCPUCalculator(IAEMultiBlock t) {
super( t );

View file

@ -75,9 +75,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
IItemList<IAEItemStack> waitingFor = AEApi.instance().storage().createItemList();
// instance sate
private LinkedList<TileCraftingTile> tiles = new LinkedList();
private LinkedList<TileCraftingTile> storage = new LinkedList<TileCraftingTile>();
private LinkedList<TileCraftingMonitorTile> status = new LinkedList<TileCraftingMonitorTile>();
final private LinkedList<TileCraftingTile> tiles = new LinkedList();
final private LinkedList<TileCraftingTile> storage = new LinkedList<TileCraftingTile>();
final private LinkedList<TileCraftingMonitorTile> status = new LinkedList<TileCraftingMonitorTile>();
long availableStorage = 0;
public ICraftingLink myLastLink;

View file

@ -13,7 +13,7 @@ import appeng.util.Platform;
public class QuantumCalculator extends MBCalculator
{
TileQuantumBridge tqb;
final private TileQuantumBridge tqb;
public QuantumCalculator(IAEMultiBlock t) {
super( t );

View file

@ -26,8 +26,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class QuantumCluster implements ILocatable, IAECluster
{
public WorldCoord min;
public WorldCoord max;
final public WorldCoord min;
final public WorldCoord max;
public boolean isDestroyed = false;
public boolean updateStatus = true;

View file

@ -12,7 +12,7 @@ import appeng.tile.spatial.TileSpatialPylon;
public class SpatialPylonCalculator extends MBCalculator
{
TileSpatialPylon tqb;
private final TileSpatialPylon tqb;
public SpatialPylonCalculator(IAEMultiBlock t) {
super( t );

View file

@ -17,13 +17,13 @@ public class SpatialPylonCluster implements IAECluster
X, Y, Z, UNFORMED
};
public DimensionalCoord min;
public DimensionalCoord max;
final public DimensionalCoord min;
final public DimensionalCoord max;
public boolean isDestroyed = false;
public Axis currentAxis = Axis.UNFORMED;
List<TileSpatialPylon> line = new ArrayList();
final List<TileSpatialPylon> line = new ArrayList();
public boolean isValid;
public boolean hasPower;
public boolean hasChannel;