Changed access to use this qualifier
This commit is contained in:
+6
-6
@@ -104,7 +104,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
findNext();
|
||||
this.findNext();
|
||||
|
||||
return this.cpuCluster != null;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
@MENetworkEventSubscribe
|
||||
public void updateCPUClusters(MENetworkCraftingPatternChange c)
|
||||
{
|
||||
updatePatterns();
|
||||
this.updatePatterns();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -253,7 +253,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
{
|
||||
ICraftingWatcherHost watcherHost = (ICraftingWatcherHost) machine;
|
||||
CraftingWatcher watcher = new CraftingWatcher( this, watcherHost );
|
||||
craftingWatchers.put( gridNode, watcher );
|
||||
this.craftingWatchers.put( gridNode, watcher );
|
||||
watcherHost.updateWatcher( watcher );
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if ( cluster.myLastLink != null )
|
||||
{
|
||||
addLink( (CraftingLink) cluster.myLastLink );
|
||||
this.addLink( (CraftingLink) cluster.myLastLink );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if ( cpuCluster != null )
|
||||
{
|
||||
return cpuCluster.submitJob( grid, job, src, requestingMachine );
|
||||
return cpuCluster.submitJob( this.grid, job, src, requestingMachine );
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -572,7 +572,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
public List<ICraftingMedium> getMediums(ICraftingPatternDetails key)
|
||||
{
|
||||
List<ICraftingMedium> mediums = craftingMethods.get( key );
|
||||
List<ICraftingMedium> mediums = this.craftingMethods.get( key );
|
||||
|
||||
if ( mediums == null )
|
||||
{
|
||||
|
||||
+114
-114
@@ -101,29 +101,29 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
private double buffer()
|
||||
{
|
||||
return providers.isEmpty() ? 1000.0 : 0.0;
|
||||
return this.providers.isEmpty() ? 1000.0 : 0.0;
|
||||
}
|
||||
|
||||
private IAEPowerStorage getFirstRequester()
|
||||
{
|
||||
if ( lastRequester == null )
|
||||
if ( this.lastRequester == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = requesters.iterator();
|
||||
lastRequester = i.hasNext() ? i.next() : null;
|
||||
Iterator<IAEPowerStorage> i = this.requesters.iterator();
|
||||
this.lastRequester = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
return lastRequester;
|
||||
return this.lastRequester;
|
||||
}
|
||||
|
||||
private IAEPowerStorage getFirstProvider()
|
||||
{
|
||||
if ( lastProvider == null )
|
||||
if ( this.lastProvider == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = providers.iterator();
|
||||
lastProvider = i.hasNext() ? i.next() : null;
|
||||
Iterator<IAEPowerStorage> i = this.providers.iterator();
|
||||
this.lastProvider = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
return lastProvider;
|
||||
return this.lastProvider;
|
||||
}
|
||||
|
||||
final Multiset<IEnergyGridProvider> energyGridProviders = HashMultiset.create();
|
||||
@@ -132,13 +132,13 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
PathGridCache pgc;
|
||||
|
||||
public EnergyGridCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void postInit(MENetworkPostCacheConstruction pcc)
|
||||
{
|
||||
pgc = myGrid.getCache( IPathingGrid.class );
|
||||
this.pgc = this.myGrid.getCache( IPathingGrid.class );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -152,7 +152,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
double diffDraw = newDraw - node.previousDraw;
|
||||
node.previousDraw = newDraw;
|
||||
|
||||
drainPerTick += diffDraw;
|
||||
this.drainPerTick += diffDraw;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -164,11 +164,11 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
case PROVIDE_POWER:
|
||||
if ( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
||||
providers.add( ev.storage );
|
||||
this.providers.add( ev.storage );
|
||||
break;
|
||||
case REQUEST_POWER:
|
||||
if ( ev.storage.getPowerFlow() != AccessRestriction.READ )
|
||||
requesters.add( ev.storage );
|
||||
this.requesters.add( ev.storage );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -181,8 +181,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double getEnergyDemand(double maxRequired)
|
||||
{
|
||||
localSeen.clear();
|
||||
return getEnergyDemand( maxRequired, localSeen );
|
||||
this.localSeen.clear();
|
||||
return this.getEnergyDemand( maxRequired, this.localSeen );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,9 +191,9 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
if ( !seen.add( this ) )
|
||||
return 0;
|
||||
|
||||
double required = buffer() - extra;
|
||||
double required = this.buffer() - this.extra;
|
||||
|
||||
Iterator<IAEPowerStorage> it = requesters.iterator();
|
||||
Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while (required < maxRequired && it.hasNext())
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
@@ -201,7 +201,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
required += Math.max( 0.0, node.getAEMaxPower() - node.getAECurrentPower() );
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> ix = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> ix = this.energyGridProviders.iterator();
|
||||
while (required < maxRequired && ix.hasNext())
|
||||
{
|
||||
IEnergyGridProvider node = ix.next();
|
||||
@@ -214,8 +214,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double injectPower(double amt, Actionable mode)
|
||||
{
|
||||
localSeen.clear();
|
||||
return injectAEPower( amt, mode, localSeen );
|
||||
this.localSeen.clear();
|
||||
return this.injectAEPower( amt, mode, this.localSeen );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,40 +224,40 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
if ( !seen.add( this ) )
|
||||
return 0;
|
||||
|
||||
double ignore = extra;
|
||||
amt += extra;
|
||||
double ignore = this.extra;
|
||||
amt += this.extra;
|
||||
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = requesters.iterator();
|
||||
Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while (amt > 0 && it.hasNext())
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
amt = node.injectAEPower( amt, Actionable.SIMULATE );
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while (amt > 0 && i.hasNext())
|
||||
amt = i.next().injectAEPower( amt, mode, seen );
|
||||
}
|
||||
else
|
||||
{
|
||||
tickInjectionPerTick += amt - ignore;
|
||||
this.tickInjectionPerTick += amt - ignore;
|
||||
// totalInjectionPastTicks[0] += i;
|
||||
|
||||
while (amt > 0 && !requesters.isEmpty())
|
||||
while (amt > 0 && !this.requesters.isEmpty())
|
||||
{
|
||||
IAEPowerStorage node = getFirstRequester();
|
||||
IAEPowerStorage node = this.getFirstRequester();
|
||||
|
||||
amt = node.injectAEPower( amt, Actionable.MODULATE );
|
||||
if ( amt > 0 )
|
||||
{
|
||||
requesters.remove( node );
|
||||
lastRequester = null;
|
||||
this.requesters.remove( node );
|
||||
this.lastRequester = null;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while (amt > 0 && i.hasNext())
|
||||
{
|
||||
IEnergyGridProvider what = i.next();
|
||||
@@ -270,30 +270,30 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
amt = cannotHold;
|
||||
}
|
||||
|
||||
extra = amt;
|
||||
this.extra = amt;
|
||||
}
|
||||
|
||||
return Math.max( 0.0, amt - buffer() );
|
||||
return Math.max( 0.0, amt - this.buffer() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
|
||||
{
|
||||
localSeen.clear();
|
||||
return pm.divide( extractAEPower( pm.multiply( amt ), mode, localSeen ) );
|
||||
this.localSeen.clear();
|
||||
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode, this.localSeen ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode(IGridNode node, IGridHost machine)
|
||||
{
|
||||
if ( machine instanceof IEnergyGridProvider )
|
||||
energyGridProviders.add( (IEnergyGridProvider) machine );
|
||||
this.energyGridProviders.add( (IEnergyGridProvider) machine );
|
||||
|
||||
// idle draw...
|
||||
GridNode gridNode = (GridNode) node;
|
||||
IGridBlock gb = gridNode.getGridBlock();
|
||||
gridNode.previousDraw = gb.getIdlePowerUsage();
|
||||
drainPerTick += gridNode.previousDraw;
|
||||
this.drainPerTick += gridNode.previousDraw;
|
||||
|
||||
// power storage
|
||||
if ( machine instanceof IAEPowerStorage )
|
||||
@@ -306,17 +306,17 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if ( ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
globalMaxPower += ps.getAEMaxPower();
|
||||
this.globalMaxPower += ps.getAEMaxPower();
|
||||
}
|
||||
|
||||
if ( current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
globalAvailablePower += current;
|
||||
providers.add( ps );
|
||||
this.globalAvailablePower += current;
|
||||
this.providers.add( ps );
|
||||
}
|
||||
|
||||
if ( current < max && ps.getPowerFlow() != AccessRestriction.READ )
|
||||
requesters.add( ps );
|
||||
this.requesters.add( ps );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,22 +324,22 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
IEnergyWatcherHost swh = (IEnergyWatcherHost) machine;
|
||||
EnergyWatcher iw = new EnergyWatcher( this, swh );
|
||||
watchers.put( node, iw );
|
||||
this.watchers.put( node, iw );
|
||||
swh.updateWatcher( iw );
|
||||
}
|
||||
|
||||
myGrid.postEventTo( node, new MENetworkPowerStatusChange() );
|
||||
this.myGrid.postEventTo( node, new MENetworkPowerStatusChange() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode(IGridNode node, IGridHost machine)
|
||||
{
|
||||
if ( machine instanceof IEnergyGridProvider )
|
||||
energyGridProviders.remove( machine );
|
||||
this.energyGridProviders.remove( machine );
|
||||
|
||||
// idle draw.
|
||||
GridNode gridNode = (GridNode) node;
|
||||
drainPerTick -= gridNode.previousDraw;
|
||||
this.drainPerTick -= gridNode.previousDraw;
|
||||
|
||||
// power storage.
|
||||
if ( machine instanceof IAEPowerStorage )
|
||||
@@ -349,28 +349,28 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
if ( ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
globalMaxPower -= ps.getAEMaxPower();
|
||||
globalAvailablePower -= ps.getAECurrentPower();
|
||||
this.globalMaxPower -= ps.getAEMaxPower();
|
||||
this.globalAvailablePower -= ps.getAECurrentPower();
|
||||
}
|
||||
|
||||
if ( lastProvider == machine )
|
||||
lastProvider = null;
|
||||
if ( this.lastProvider == machine )
|
||||
this.lastProvider = null;
|
||||
|
||||
if ( lastRequester == machine )
|
||||
lastRequester = null;
|
||||
if ( this.lastRequester == machine )
|
||||
this.lastRequester = null;
|
||||
|
||||
providers.remove( machine );
|
||||
requesters.remove( machine );
|
||||
this.providers.remove( machine );
|
||||
this.requesters.remove( machine );
|
||||
}
|
||||
}
|
||||
|
||||
if ( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IEnergyWatcher myWatcher = watchers.get( machine );
|
||||
IEnergyWatcher myWatcher = this.watchers.get( machine );
|
||||
if ( myWatcher != null )
|
||||
{
|
||||
myWatcher.clear();
|
||||
watchers.remove( machine );
|
||||
this.watchers.remove( machine );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,66 +381,66 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
if ( !interests.isEmpty() )
|
||||
if ( !this.interests.isEmpty() )
|
||||
{
|
||||
double oldPower = lastStoredPower;
|
||||
lastStoredPower = getStoredPower();
|
||||
double oldPower = this.lastStoredPower;
|
||||
this.lastStoredPower = this.getStoredPower();
|
||||
|
||||
EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, lastStoredPower ), null );
|
||||
EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, lastStoredPower ), null );
|
||||
for (EnergyThreshold th : interests.subSet( low, true, high, true ))
|
||||
EnergyThreshold low = new EnergyThreshold( Math.min( oldPower, this.lastStoredPower ), null );
|
||||
EnergyThreshold high = new EnergyThreshold( Math.max( oldPower, this.lastStoredPower ), null );
|
||||
for (EnergyThreshold th : this.interests.subSet( low, true, high, true ))
|
||||
{
|
||||
((EnergyWatcher) th.watcher).post( this );
|
||||
}
|
||||
}
|
||||
|
||||
avgDrainPerTick *= (AvgLength - 1) / AvgLength;
|
||||
avgInjectionPerTick *= (AvgLength - 1) / AvgLength;
|
||||
this.avgDrainPerTick *= (this.AvgLength - 1) / this.AvgLength;
|
||||
this.avgInjectionPerTick *= (this.AvgLength - 1) / this.AvgLength;
|
||||
|
||||
avgDrainPerTick += tickDrainPerTick / AvgLength;
|
||||
avgInjectionPerTick += tickInjectionPerTick / AvgLength;
|
||||
this.avgDrainPerTick += this.tickDrainPerTick / this.AvgLength;
|
||||
this.avgInjectionPerTick += this.tickInjectionPerTick / this.AvgLength;
|
||||
|
||||
tickDrainPerTick = 0;
|
||||
tickInjectionPerTick = 0;
|
||||
this.tickDrainPerTick = 0;
|
||||
this.tickInjectionPerTick = 0;
|
||||
|
||||
// power information.
|
||||
boolean currentlyHasPower = false;
|
||||
|
||||
if ( drainPerTick > 0.0001 )
|
||||
if ( this.drainPerTick > 0.0001 )
|
||||
{
|
||||
double drained = extractAEPower( getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
currentlyHasPower = drained >= drainPerTick - 0.001;
|
||||
double drained = this.extractAEPower( this.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
currentlyHasPower = drained >= this.drainPerTick - 0.001;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentlyHasPower = extractAEPower( 0.1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0;
|
||||
currentlyHasPower = this.extractAEPower( 0.1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0;
|
||||
}
|
||||
|
||||
// ticks since change..
|
||||
if ( currentlyHasPower == hasPower )
|
||||
ticksSinceHasPowerChange++;
|
||||
if ( currentlyHasPower == this.hasPower )
|
||||
this.ticksSinceHasPowerChange++;
|
||||
else
|
||||
ticksSinceHasPowerChange = 0;
|
||||
this.ticksSinceHasPowerChange = 0;
|
||||
|
||||
// update status..
|
||||
hasPower = currentlyHasPower;
|
||||
this.hasPower = currentlyHasPower;
|
||||
|
||||
// update public status, this buffers power ups for 30 ticks.
|
||||
if ( hasPower && ticksSinceHasPowerChange > 30 )
|
||||
publicPowerState( true, myGrid );
|
||||
else if ( !hasPower )
|
||||
publicPowerState( false, myGrid );
|
||||
if ( this.hasPower && this.ticksSinceHasPowerChange > 30 )
|
||||
this.publicPowerState( true, this.myGrid );
|
||||
else if ( !this.hasPower )
|
||||
this.publicPowerState( false, this.myGrid );
|
||||
|
||||
availableTicksSinceUpdate++;
|
||||
this.availableTicksSinceUpdate++;
|
||||
}
|
||||
|
||||
private void publicPowerState(boolean newState, IGrid grid)
|
||||
{
|
||||
if ( publicHasPower == newState )
|
||||
if ( this.publicHasPower == newState )
|
||||
return;
|
||||
|
||||
publicHasPower = newState;
|
||||
((Grid) myGrid).setImportantFlag( 0, publicHasPower );
|
||||
this.publicHasPower = newState;
|
||||
((Grid) this.myGrid).setImportantFlag( 0, this.publicHasPower );
|
||||
grid.postEvent( new MENetworkPowerStatusChange() );
|
||||
}
|
||||
|
||||
@@ -449,25 +449,25 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
*/
|
||||
public void refreshPower()
|
||||
{
|
||||
availableTicksSinceUpdate = 0;
|
||||
globalAvailablePower = 0;
|
||||
for (IAEPowerStorage p : providers)
|
||||
globalAvailablePower += p.getAECurrentPower();
|
||||
this.availableTicksSinceUpdate = 0;
|
||||
this.globalAvailablePower = 0;
|
||||
for (IAEPowerStorage p : this.providers)
|
||||
this.globalAvailablePower += p.getAECurrentPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStoredPower()
|
||||
{
|
||||
if ( availableTicksSinceUpdate > 90 )
|
||||
refreshPower();
|
||||
if ( this.availableTicksSinceUpdate > 90 )
|
||||
this.refreshPower();
|
||||
|
||||
return Math.max( 0.0, globalAvailablePower );
|
||||
return Math.max( 0.0, this.globalAvailablePower );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxStoredPower()
|
||||
{
|
||||
return globalMaxPower;
|
||||
return this.globalMaxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -476,15 +476,15 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
if ( !seen.add( this ) )
|
||||
return 0;
|
||||
|
||||
double extractedPower = extra;
|
||||
double extractedPower = this.extra;
|
||||
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
extractedPower += simulateExtract( extractedPower, amt );
|
||||
extractedPower += this.simulateExtract( extractedPower, amt );
|
||||
|
||||
if ( extractedPower < amt )
|
||||
{
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while (extractedPower < amt && i.hasNext())
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
}
|
||||
@@ -493,38 +493,38 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
extra = 0;
|
||||
extractedPower = doExtract( extractedPower, amt );
|
||||
this.extra = 0;
|
||||
extractedPower = this.doExtract( extractedPower, amt );
|
||||
}
|
||||
|
||||
// got more then we wanted?
|
||||
if ( extractedPower > amt )
|
||||
{
|
||||
extra = extractedPower - amt;
|
||||
globalAvailablePower -= amt;
|
||||
this.extra = extractedPower - amt;
|
||||
this.globalAvailablePower -= amt;
|
||||
|
||||
tickDrainPerTick += amt;
|
||||
this.tickDrainPerTick += amt;
|
||||
return amt;
|
||||
}
|
||||
|
||||
if ( extractedPower < amt )
|
||||
{
|
||||
Iterator<IEnergyGridProvider> i = energyGridProviders.iterator();
|
||||
Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while (extractedPower < amt && i.hasNext())
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
}
|
||||
|
||||
// go less or the correct amount?
|
||||
globalAvailablePower -= extractedPower;
|
||||
tickDrainPerTick += extractedPower;
|
||||
this.globalAvailablePower -= extractedPower;
|
||||
this.tickDrainPerTick += extractedPower;
|
||||
return extractedPower;
|
||||
}
|
||||
|
||||
private double doExtract(double extractedPower, double amt)
|
||||
{
|
||||
while (extractedPower < amt && !providers.isEmpty())
|
||||
while (extractedPower < amt && !this.providers.isEmpty())
|
||||
{
|
||||
IAEPowerStorage node = getFirstProvider();
|
||||
IAEPowerStorage node = this.getFirstProvider();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
@@ -532,8 +532,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if ( newPower < req )
|
||||
{
|
||||
providers.remove( node );
|
||||
lastProvider = null;
|
||||
this.providers.remove( node );
|
||||
this.lastProvider = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
private double simulateExtract(double extractedPower, double amt)
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = providers.iterator();
|
||||
Iterator<IAEPowerStorage> it = this.providers.iterator();
|
||||
|
||||
while (extractedPower < amt && it.hasNext())
|
||||
{
|
||||
@@ -560,38 +560,38 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public boolean isNetworkPowered()
|
||||
{
|
||||
return publicHasPower;
|
||||
return this.publicHasPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdlePowerUsage()
|
||||
{
|
||||
return drainPerTick + pgc.channelPowerUsage;
|
||||
return this.drainPerTick + this.pgc.channelPowerUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAvgPowerUsage()
|
||||
{
|
||||
return avgDrainPerTick;
|
||||
return this.avgDrainPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAvgPowerInjection()
|
||||
{
|
||||
return avgInjectionPerTick;
|
||||
return this.avgInjectionPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit(IGridStorage storageB)
|
||||
{
|
||||
extra /= 2;
|
||||
storageB.dataObject().setDouble( "extraEnergy", extra );
|
||||
this.extra /= 2;
|
||||
storageB.dataObject().setDouble( "extraEnergy", this.extra );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin(IGridStorage storageB)
|
||||
{
|
||||
extra += storageB.dataObject().getDouble( "extraEnergy" );
|
||||
this.extra += storageB.dataObject().getDouble( "extraEnergy" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+53
-53
@@ -57,7 +57,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
{
|
||||
|
||||
final private SetMultimap<IAEStack, ItemWatcher> interests = HashMultimap.create();
|
||||
final public GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<ItemWatcher>( interests );
|
||||
final public GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<ItemWatcher>( this.interests );
|
||||
|
||||
final HashSet<ICellProvider> activeCellProviders = new HashSet<ICellProvider>();
|
||||
final HashSet<ICellProvider> inactiveCellProviders = new HashSet<ICellProvider>();
|
||||
@@ -72,14 +72,14 @@ public class GridStorageCache implements IStorageGrid
|
||||
private final HashMap<IGridNode, IStackWatcher> watchers = new HashMap<IGridNode, IStackWatcher>();
|
||||
|
||||
public GridStorageCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
itemMonitor.onTick();
|
||||
fluidMonitor.onTick();
|
||||
this.itemMonitor.onTick();
|
||||
this.fluidMonitor.onTick();
|
||||
}
|
||||
|
||||
private class CellChangeTrackerRecord
|
||||
@@ -105,7 +105,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public void applyChanges()
|
||||
{
|
||||
postChangesToNetwork( channel, up_or_down, list, src );
|
||||
GridStorageCache.this.postChangesToNetwork( this.channel, this.up_or_down, this.list, this.src );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -117,12 +117,12 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public void postChanges(StorageChannel channel, int i, IMEInventoryHandler<? extends IAEStack> h, BaseActionSource actionSrc)
|
||||
{
|
||||
data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) );
|
||||
this.data.add( new CellChangeTrackerRecord( channel, i, h, actionSrc ) );
|
||||
}
|
||||
|
||||
public void applyChanges()
|
||||
{
|
||||
for (CellChangeTrackerRecord rec : data)
|
||||
for (CellChangeTrackerRecord rec : this.data)
|
||||
rec.applyChanges();
|
||||
}
|
||||
}
|
||||
@@ -130,23 +130,23 @@ public class GridStorageCache implements IStorageGrid
|
||||
@Override
|
||||
public void registerCellProvider(ICellProvider provider)
|
||||
{
|
||||
inactiveCellProviders.add( provider );
|
||||
addCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.add( provider );
|
||||
this.addCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterCellProvider(ICellProvider provider)
|
||||
{
|
||||
removeCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
inactiveCellProviders.remove( provider );
|
||||
this.removeCellProvider( provider, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.remove( provider );
|
||||
}
|
||||
|
||||
public CellChangeTracker addCellProvider(ICellProvider cc, CellChangeTracker tracker)
|
||||
{
|
||||
if ( inactiveCellProviders.contains( cc ) )
|
||||
if ( this.inactiveCellProviders.contains( cc ) )
|
||||
{
|
||||
inactiveCellProviders.remove( cc );
|
||||
activeCellProviders.add( cc );
|
||||
this.inactiveCellProviders.remove( cc );
|
||||
this.activeCellProviders.add( cc );
|
||||
|
||||
BaseActionSource actionSrc = new BaseActionSource();
|
||||
if ( cc instanceof IActionHost )
|
||||
@@ -168,10 +168,10 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public CellChangeTracker removeCellProvider(ICellProvider cc, CellChangeTracker tracker)
|
||||
{
|
||||
if ( activeCellProviders.contains( cc ) )
|
||||
if ( this.activeCellProviders.contains( cc ) )
|
||||
{
|
||||
inactiveCellProviders.add( cc );
|
||||
activeCellProviders.remove( cc );
|
||||
this.inactiveCellProviders.add( cc );
|
||||
this.activeCellProviders.remove( cc );
|
||||
|
||||
BaseActionSource actionSrc = new BaseActionSource();
|
||||
if ( cc instanceof IActionHost )
|
||||
@@ -194,12 +194,12 @@ public class GridStorageCache implements IStorageGrid
|
||||
@MENetworkEventSubscribe
|
||||
public void cellUpdate(MENetworkCellArrayUpdate ev)
|
||||
{
|
||||
myItemNetwork = null;
|
||||
myFluidNetwork = null;
|
||||
this.myItemNetwork = null;
|
||||
this.myFluidNetwork = null;
|
||||
|
||||
LinkedList<ICellProvider> ll = new LinkedList();
|
||||
ll.addAll( inactiveCellProviders );
|
||||
ll.addAll( activeCellProviders );
|
||||
ll.addAll( this.inactiveCellProviders );
|
||||
ll.addAll( this.activeCellProviders );
|
||||
|
||||
CellChangeTracker tracker = new CellChangeTracker();
|
||||
|
||||
@@ -217,13 +217,13 @@ public class GridStorageCache implements IStorageGrid
|
||||
}
|
||||
|
||||
if ( Active )
|
||||
addCellProvider( cc, tracker );
|
||||
this.addCellProvider( cc, tracker );
|
||||
else
|
||||
removeCellProvider( cc, tracker );
|
||||
this.removeCellProvider( cc, tracker );
|
||||
}
|
||||
|
||||
itemMonitor.forceUpdate();
|
||||
fluidMonitor.forceUpdate();
|
||||
this.itemMonitor.forceUpdate();
|
||||
this.fluidMonitor.forceUpdate();
|
||||
|
||||
tracker.applyChanges();
|
||||
}
|
||||
@@ -235,18 +235,18 @@ public class GridStorageCache implements IStorageGrid
|
||||
{
|
||||
ICellContainer cc = (ICellContainer) machine;
|
||||
|
||||
myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
removeCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
inactiveCellProviders.remove( cc );
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.removeCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
this.inactiveCellProviders.remove( cc );
|
||||
}
|
||||
|
||||
if ( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IStackWatcher myWatcher = watchers.get( machine );
|
||||
IStackWatcher myWatcher = this.watchers.get( machine );
|
||||
if ( myWatcher != null )
|
||||
{
|
||||
myWatcher.clear();
|
||||
watchers.remove( machine );
|
||||
this.watchers.remove( machine );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,42 +257,42 @@ public class GridStorageCache implements IStorageGrid
|
||||
if ( machine instanceof ICellContainer )
|
||||
{
|
||||
ICellContainer cc = (ICellContainer) machine;
|
||||
inactiveCellProviders.add( cc );
|
||||
this.inactiveCellProviders.add( cc );
|
||||
|
||||
myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.myGrid.postEvent( new MENetworkCellArrayUpdate() );
|
||||
if ( node.isActive() )
|
||||
addCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
this.addCellProvider( cc, new CellChangeTracker() ).applyChanges();
|
||||
}
|
||||
|
||||
if ( machine instanceof IStackWatcherHost )
|
||||
{
|
||||
IStackWatcherHost swh = (IStackWatcherHost) machine;
|
||||
ItemWatcher iw = new ItemWatcher( this, swh );
|
||||
watchers.put( node, iw );
|
||||
this.watchers.put( node, iw );
|
||||
swh.updateWatcher( iw );
|
||||
}
|
||||
}
|
||||
|
||||
private void buildNetworkStorage(StorageChannel chan)
|
||||
{
|
||||
SecurityCache security = myGrid.getCache( ISecurityGrid.class );
|
||||
SecurityCache security = this.myGrid.getCache( ISecurityGrid.class );
|
||||
|
||||
switch (chan)
|
||||
{
|
||||
case FLUIDS:
|
||||
myFluidNetwork = new NetworkInventoryHandler<IAEFluidStack>( StorageChannel.FLUIDS, security );
|
||||
for (ICellProvider cc : activeCellProviders)
|
||||
this.myFluidNetwork = new NetworkInventoryHandler<IAEFluidStack>( StorageChannel.FLUIDS, security );
|
||||
for (ICellProvider cc : this.activeCellProviders)
|
||||
{
|
||||
for (IMEInventoryHandler<IAEFluidStack> h : cc.getCellArray( chan ))
|
||||
myFluidNetwork.addNewStorage( h );
|
||||
this.myFluidNetwork.addNewStorage( h );
|
||||
}
|
||||
break;
|
||||
case ITEMS:
|
||||
myItemNetwork = new NetworkInventoryHandler<IAEItemStack>( StorageChannel.ITEMS, security );
|
||||
for (ICellProvider cc : activeCellProviders)
|
||||
this.myItemNetwork = new NetworkInventoryHandler<IAEItemStack>( StorageChannel.ITEMS, security );
|
||||
for (ICellProvider cc : this.activeCellProviders)
|
||||
{
|
||||
for (IMEInventoryHandler<IAEItemStack> h : cc.getCellArray( chan ))
|
||||
myItemNetwork.addNewStorage( h );
|
||||
this.myItemNetwork.addNewStorage( h );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -304,10 +304,10 @@ public class GridStorageCache implements IStorageGrid
|
||||
switch (chan)
|
||||
{
|
||||
case FLUIDS:
|
||||
fluidMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
this.fluidMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
break;
|
||||
case ITEMS:
|
||||
itemMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
this.itemMonitor.postChange( up_or_down > 0, availableItems, src );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@@ -315,37 +315,37 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public IMEInventoryHandler<IAEItemStack> getItemInventoryHandler()
|
||||
{
|
||||
if ( myItemNetwork == null )
|
||||
buildNetworkStorage( StorageChannel.ITEMS );
|
||||
return myItemNetwork;
|
||||
if ( this.myItemNetwork == null )
|
||||
this.buildNetworkStorage( StorageChannel.ITEMS );
|
||||
return this.myItemNetwork;
|
||||
}
|
||||
|
||||
public IMEInventoryHandler<IAEFluidStack> getFluidInventoryHandler()
|
||||
{
|
||||
if ( myFluidNetwork == null )
|
||||
buildNetworkStorage( StorageChannel.FLUIDS );
|
||||
return myFluidNetwork;
|
||||
if ( this.myFluidNetwork == null )
|
||||
this.buildNetworkStorage( StorageChannel.FLUIDS );
|
||||
return this.myFluidNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAlterationOfStoredItems(StorageChannel chan, Iterable<? extends IAEStack> input, BaseActionSource src)
|
||||
{
|
||||
if ( chan == StorageChannel.ITEMS )
|
||||
itemMonitor.postChange( true, (Iterable<IAEItemStack>) input, src );
|
||||
this.itemMonitor.postChange( true, (Iterable<IAEItemStack>) input, src );
|
||||
else if ( chan == StorageChannel.FLUIDS )
|
||||
fluidMonitor.postChange( true, (Iterable<IAEFluidStack>) input, src );
|
||||
this.fluidMonitor.postChange( true, (Iterable<IAEFluidStack>) input, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||
{
|
||||
return fluidMonitor;
|
||||
return this.fluidMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory()
|
||||
{
|
||||
return itemMonitor;
|
||||
return this.itemMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+19
-19
@@ -43,9 +43,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
public void forceUpdate()
|
||||
{
|
||||
hasChanged = true;
|
||||
this.hasChanged = true;
|
||||
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = getListeners();
|
||||
Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||
@@ -60,8 +60,8 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
public NetworkMonitor(GridStorageCache cache, StorageChannel chan) {
|
||||
super( null, chan );
|
||||
myGridCache = cache;
|
||||
myChannel = chan;
|
||||
this.myGridCache = cache;
|
||||
this.myChannel = chan;
|
||||
}
|
||||
|
||||
final static public LinkedList depth = new LinkedList();
|
||||
@@ -69,7 +69,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
@Override
|
||||
protected void postChangesToListeners(Iterable<T> changes, BaseActionSource src)
|
||||
{
|
||||
postChange( true, changes, src );
|
||||
this.postChange( true, changes, src );
|
||||
}
|
||||
|
||||
protected void postChange(boolean Add, Iterable<T> changes, BaseActionSource src)
|
||||
@@ -79,10 +79,10 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
depth.push( this );
|
||||
|
||||
sendEvent = true;
|
||||
notifyListenersOfChange( changes, src );
|
||||
this.sendEvent = true;
|
||||
this.notifyListenersOfChange( changes, src );
|
||||
|
||||
IItemList<T> myStorageList = getStorageList();
|
||||
IItemList<T> myStorageList = this.getStorageList();
|
||||
|
||||
for (T changedItem : changes)
|
||||
{
|
||||
@@ -91,9 +91,9 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
if ( !Add && changedItem != null )
|
||||
(difference = changedItem.copy()).setStackSize( -changedItem.getStackSize() );
|
||||
|
||||
if ( myGridCache.interestManager.containsKey( changedItem ) )
|
||||
if ( this.myGridCache.interestManager.containsKey( changedItem ) )
|
||||
{
|
||||
Collection<ItemWatcher> list = myGridCache.interestManager.get( changedItem );
|
||||
Collection<ItemWatcher> list = this.myGridCache.interestManager.get( changedItem );
|
||||
if ( !list.isEmpty() )
|
||||
{
|
||||
IAEStack fullStack = myStorageList.findPrecise( changedItem );
|
||||
@@ -103,12 +103,12 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
fullStack.setStackSize( 0 );
|
||||
}
|
||||
|
||||
myGridCache.interestManager.enableTransactions();
|
||||
this.myGridCache.interestManager.enableTransactions();
|
||||
|
||||
for (ItemWatcher iw : list)
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, difference, src, getChannel() );
|
||||
iw.getHost().onStackChange( myStorageList, fullStack, difference, src, this.getChannel() );
|
||||
|
||||
myGridCache.interestManager.disableTransactions();
|
||||
this.myGridCache.interestManager.disableTransactions();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,22 +120,22 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
public void onTick()
|
||||
{
|
||||
if ( sendEvent )
|
||||
if ( this.sendEvent )
|
||||
{
|
||||
sendEvent = false;
|
||||
myGridCache.myGrid.postEvent( new MENetworkStorageEvent( this, myChannel ) );
|
||||
this.sendEvent = false;
|
||||
this.myGridCache.myGrid.postEvent( new MENetworkStorageEvent( this, this.myChannel ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IMEInventoryHandler getHandler()
|
||||
{
|
||||
switch (myChannel)
|
||||
switch (this.myChannel)
|
||||
{
|
||||
case ITEMS:
|
||||
return myGridCache.getItemInventoryHandler();
|
||||
return this.myGridCache.getItemInventoryHandler();
|
||||
case FLUIDS:
|
||||
return myGridCache.getFluidInventoryHandler();
|
||||
return this.myGridCache.getFluidInventoryHandler();
|
||||
default:
|
||||
}
|
||||
return null;
|
||||
|
||||
+26
-26
@@ -47,14 +47,14 @@ public class P2PCache implements IGridCache
|
||||
final IGrid myGrid;
|
||||
|
||||
public P2PCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootComplete(MENetworkBootingStatusChange bootStatus)
|
||||
{
|
||||
ITickManager tm = myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : inputs.values())
|
||||
ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : this.inputs.values())
|
||||
{
|
||||
if ( me instanceof PartP2PTunnelME )
|
||||
tm.wakeDevice( me.getGridNode() );
|
||||
@@ -64,8 +64,8 @@ public class P2PCache implements IGridCache
|
||||
@MENetworkEventSubscribe
|
||||
public void bootComplete(MENetworkPowerStatusChange power)
|
||||
{
|
||||
ITickManager tm = myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : inputs.values())
|
||||
ITickManager tm = this.myGrid.getCache( ITickManager.class );
|
||||
for (PartP2PTunnel me : this.inputs.values())
|
||||
{
|
||||
if ( me instanceof PartP2PTunnelME )
|
||||
tm.wakeDevice( me.getGridNode() );
|
||||
@@ -80,23 +80,23 @@ public class P2PCache implements IGridCache
|
||||
|
||||
public void updateFreq(PartP2PTunnel t, long NewFreq)
|
||||
{
|
||||
if ( outputs.containsValue( t ) )
|
||||
outputs.remove( t.freq, t );
|
||||
if ( this.outputs.containsValue( t ) )
|
||||
this.outputs.remove( t.freq, t );
|
||||
|
||||
if ( inputs.containsValue( t ) )
|
||||
inputs.remove( t.freq );
|
||||
if ( this.inputs.containsValue( t ) )
|
||||
this.inputs.remove( t.freq );
|
||||
|
||||
t.freq = NewFreq;
|
||||
|
||||
if ( t.output )
|
||||
outputs.put( t.freq, t );
|
||||
this.outputs.put( t.freq, t );
|
||||
else
|
||||
inputs.put( t.freq, t );
|
||||
this.inputs.put( t.freq, t );
|
||||
|
||||
// AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
updateTunnel( t.freq, t.output, true );
|
||||
updateTunnel( t.freq, !t.output, true );
|
||||
this.updateTunnel( t.freq, t.output, true );
|
||||
this.updateTunnel( t.freq, !t.output, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,11 +115,11 @@ public class P2PCache implements IGridCache
|
||||
// );
|
||||
|
||||
if ( t.output )
|
||||
outputs.put( t.freq, t );
|
||||
this.outputs.put( t.freq, t );
|
||||
else
|
||||
inputs.put( t.freq, t );
|
||||
this.inputs.put( t.freq, t );
|
||||
|
||||
updateTunnel( t.freq, !t.output, false );
|
||||
this.updateTunnel( t.freq, !t.output, false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,24 +139,24 @@ public class P2PCache implements IGridCache
|
||||
// );
|
||||
|
||||
if ( t.output )
|
||||
outputs.remove( t.freq, t );
|
||||
this.outputs.remove( t.freq, t );
|
||||
else
|
||||
inputs.remove( t.freq );
|
||||
this.inputs.remove( t.freq );
|
||||
|
||||
updateTunnel( t.freq, !t.output, false );
|
||||
this.updateTunnel( t.freq, !t.output, false );
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTunnel(long freq, boolean updateOutputs, boolean configChange)
|
||||
{
|
||||
for (PartP2PTunnel p : outputs.get( freq ))
|
||||
for (PartP2PTunnel p : this.outputs.get( freq ))
|
||||
{
|
||||
if ( configChange )
|
||||
p.onTunnelConfigChange();
|
||||
p.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
PartP2PTunnel in = inputs.get( freq );
|
||||
PartP2PTunnel in = this.inputs.get( freq );
|
||||
if ( in != null )
|
||||
{
|
||||
if ( configChange )
|
||||
@@ -167,20 +167,20 @@ public class P2PCache implements IGridCache
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs(long freq, Class<? extends PartP2PTunnel> c)
|
||||
{
|
||||
PartP2PTunnel in = inputs.get( freq );
|
||||
PartP2PTunnel in = this.inputs.get( freq );
|
||||
if ( in == null )
|
||||
return NullColl;
|
||||
return this.NullColl;
|
||||
|
||||
TunnelCollection<PartP2PTunnel> out = inputs.get( freq ).getCollection( outputs.get( freq ), c );
|
||||
TunnelCollection<PartP2PTunnel> out = this.inputs.get( freq ).getCollection( this.outputs.get( freq ), c );
|
||||
if ( out == null )
|
||||
return NullColl;
|
||||
return this.NullColl;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public PartP2PTunnel getInput(long freq)
|
||||
{
|
||||
return inputs.get( freq );
|
||||
return this.inputs.get( freq );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+78
-78
@@ -83,69 +83,69 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
public PathGridCache(IGrid g)
|
||||
{
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
if ( recalculateControllerNextTick )
|
||||
if ( this.recalculateControllerNextTick )
|
||||
{
|
||||
recalcController();
|
||||
this.recalcController();
|
||||
}
|
||||
|
||||
if ( updateNetwork )
|
||||
if ( this.updateNetwork )
|
||||
{
|
||||
if ( !booting )
|
||||
myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
if ( !this.booting )
|
||||
this.myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
|
||||
booting = true;
|
||||
updateNetwork = false;
|
||||
instance++;
|
||||
channelsInUse = 0;
|
||||
this.booting = true;
|
||||
this.updateNetwork = false;
|
||||
this.instance++;
|
||||
this.channelsInUse = 0;
|
||||
|
||||
if ( !AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
int used = calculateRequiredChannels();
|
||||
int used = this.calculateRequiredChannels();
|
||||
|
||||
int nodes = myGrid.getNodes().size();
|
||||
ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
channelsByBlocks = nodes * used;
|
||||
channelPowerUsage = channelsByBlocks / 128.0;
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
this.channelsByBlocks = nodes * used;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
|
||||
myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
}
|
||||
else if ( controllerState == ControllerState.NO_CONTROLLER )
|
||||
else if ( this.controllerState == ControllerState.NO_CONTROLLER )
|
||||
{
|
||||
int requiredChannels = calculateRequiredChannels();
|
||||
int requiredChannels = this.calculateRequiredChannels();
|
||||
int used = requiredChannels;
|
||||
if ( requiredChannels > 8 )
|
||||
used = 0;
|
||||
|
||||
int nodes = myGrid.getNodes().size();
|
||||
channelsInUse = used;
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
this.channelsInUse = used;
|
||||
|
||||
ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
channelsByBlocks = nodes * used;
|
||||
channelPowerUsage = channelsByBlocks / 128.0;
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
this.channelsByBlocks = nodes * used;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
|
||||
myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( used ) );
|
||||
}
|
||||
else if ( controllerState == ControllerState.CONTROLLER_CONFLICT )
|
||||
else if ( this.controllerState == ControllerState.CONTROLLER_CONFLICT )
|
||||
{
|
||||
ticksUntilReady = 20;
|
||||
myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 ) );
|
||||
this.ticksUntilReady = 20;
|
||||
this.myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
int nodes = myGrid.getNodes().size();
|
||||
ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
int nodes = this.myGrid.getNodes().size();
|
||||
this.ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
|
||||
HashSet<IPathItem> closedList = new HashSet<IPathItem>();
|
||||
semiOpen = new HashSet<IPathItem>();
|
||||
this.semiOpen = new HashSet<IPathItem>();
|
||||
|
||||
// myGrid.getPivot().beginVisit( new AdHocChannelUpdater( 0 )
|
||||
// );
|
||||
for (IGridNode node : myGrid.getMachines( TileController.class ))
|
||||
for (IGridNode node : this.myGrid.getMachines( TileController.class ))
|
||||
{
|
||||
closedList.add( (IPathItem) node );
|
||||
for (IGridConnection gcc : node.getConnections())
|
||||
@@ -157,16 +157,16 @@ public class PathGridCache implements IPathingGrid
|
||||
closedList.add( gc );
|
||||
open.add( gc );
|
||||
gc.setControllerRoute( (GridNode) node, true );
|
||||
active.add( new PathSegment( this, open, semiOpen, closedList ) );
|
||||
this.active.add( new PathSegment( this, open, this.semiOpen, closedList ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !active.isEmpty() || ticksUntilReady > 0 )
|
||||
if ( !this.active.isEmpty() || this.ticksUntilReady > 0 )
|
||||
{
|
||||
Iterator<PathSegment> i = active.iterator();
|
||||
Iterator<PathSegment> i = this.active.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
PathSegment pat = i.next();
|
||||
@@ -177,11 +177,11 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
}
|
||||
|
||||
ticksUntilReady--;
|
||||
this.ticksUntilReady--;
|
||||
|
||||
if ( active.isEmpty() && ticksUntilReady <= 0 )
|
||||
if ( this.active.isEmpty() && this.ticksUntilReady <= 0 )
|
||||
{
|
||||
if ( controllerState == ControllerState.CONTROLLER_ONLINE )
|
||||
if ( this.controllerState == ControllerState.CONTROLLER_ONLINE )
|
||||
{
|
||||
final Iterator<TileController> controllerIterator = this.controllers.iterator();
|
||||
if (controllerIterator.hasNext())
|
||||
@@ -192,25 +192,25 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
|
||||
// check for achievements
|
||||
achievementPost();
|
||||
this.achievementPost();
|
||||
|
||||
booting = false;
|
||||
channelPowerUsage = channelsByBlocks / 128.0;
|
||||
myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
this.booting = false;
|
||||
this.channelPowerUsage = this.channelsByBlocks / 128.0;
|
||||
this.myGrid.postEvent( new MENetworkBootingStatusChange() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void achievementPost()
|
||||
{
|
||||
if ( lastChannels != channelsInUse && AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
if ( this.lastChannels != this.channelsInUse && AEConfig.instance.isFeatureEnabled( AEFeature.Channels ) )
|
||||
{
|
||||
Achievements currentBracket = getAchievementBracket( channelsInUse );
|
||||
Achievements lastBracket = getAchievementBracket( lastChannels );
|
||||
Achievements currentBracket = this.getAchievementBracket( this.channelsInUse );
|
||||
Achievements lastBracket = this.getAchievementBracket( this.lastChannels );
|
||||
if ( currentBracket != lastBracket && currentBracket != null )
|
||||
{
|
||||
Set<Integer> players = new HashSet<Integer>();
|
||||
for (IGridNode n : requireChannels)
|
||||
for (IGridNode n : this.requireChannels)
|
||||
players.add( n.getPlayerID() );
|
||||
|
||||
for (int id : players)
|
||||
@@ -219,7 +219,7 @@ public class PathGridCache implements IPathingGrid
|
||||
}
|
||||
}
|
||||
}
|
||||
lastChannels = channelsInUse;
|
||||
this.lastChannels = this.channelsInUse;
|
||||
}
|
||||
|
||||
private Achievements getAchievementBracket(int ch)
|
||||
@@ -239,16 +239,16 @@ public class PathGridCache implements IPathingGrid
|
||||
private int calculateRequiredChannels()
|
||||
{
|
||||
int depth = 0;
|
||||
semiOpen.clear();
|
||||
this.semiOpen.clear();
|
||||
|
||||
for (IGridNode nodes : requireChannels)
|
||||
for (IGridNode nodes : this.requireChannels)
|
||||
{
|
||||
if ( !semiOpen.contains( nodes ) )
|
||||
if ( !this.semiOpen.contains( nodes ) )
|
||||
{
|
||||
IGridBlock gb = nodes.getGridBlock();
|
||||
EnumSet<GridFlags> flags = gb.getFlags();
|
||||
|
||||
if ( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !blockDense.isEmpty() )
|
||||
if ( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !this.blockDense.isEmpty() )
|
||||
return 9;
|
||||
|
||||
depth++;
|
||||
@@ -258,7 +258,7 @@ public class PathGridCache implements IPathingGrid
|
||||
IGridMultiblock gmb = (IGridMultiblock) gb;
|
||||
Iterator<IGridNode> i = gmb.getMultiblockNodes();
|
||||
while (i.hasNext())
|
||||
semiOpen.add( (IPathItem) i.next() );
|
||||
this.semiOpen.add( (IPathItem) i.next() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,10 +270,10 @@ public class PathGridCache implements IPathingGrid
|
||||
public void repath()
|
||||
{
|
||||
// clean up...
|
||||
active.clear();
|
||||
this.active.clear();
|
||||
|
||||
channelsByBlocks = 0;
|
||||
updateNetwork = true;
|
||||
this.channelsByBlocks = 0;
|
||||
this.updateNetwork = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -281,19 +281,19 @@ public class PathGridCache implements IPathingGrid
|
||||
{
|
||||
if ( machine instanceof TileController )
|
||||
{
|
||||
controllers.remove( machine );
|
||||
recalculateControllerNextTick = true;
|
||||
this.controllers.remove( machine );
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
if ( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
requireChannels.remove( gridNode );
|
||||
this.requireChannels.remove( gridNode );
|
||||
|
||||
if ( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
|
||||
blockDense.remove( gridNode );
|
||||
this.blockDense.remove( gridNode );
|
||||
|
||||
repath();
|
||||
this.repath();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -301,19 +301,19 @@ public class PathGridCache implements IPathingGrid
|
||||
{
|
||||
if ( machine instanceof TileController )
|
||||
{
|
||||
controllers.add( (TileController) machine );
|
||||
recalculateControllerNextTick = true;
|
||||
this.controllers.add( (TileController) machine );
|
||||
this.recalculateControllerNextTick = true;
|
||||
}
|
||||
|
||||
EnumSet<GridFlags> flags = gridNode.getGridBlock().getFlags();
|
||||
|
||||
if ( flags.contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
requireChannels.add( gridNode );
|
||||
this.requireChannels.add( gridNode );
|
||||
|
||||
if ( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) )
|
||||
blockDense.add( gridNode );
|
||||
this.blockDense.add( gridNode );
|
||||
|
||||
repath();
|
||||
this.repath();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -322,28 +322,28 @@ public class PathGridCache implements IPathingGrid
|
||||
IGridNode gridNode = ev.node;
|
||||
|
||||
if ( gridNode.getGridBlock().getFlags().contains( GridFlags.REQUIRE_CHANNEL ) )
|
||||
requireChannels.add( gridNode );
|
||||
this.requireChannels.add( gridNode );
|
||||
else
|
||||
requireChannels.remove( gridNode );
|
||||
this.requireChannels.remove( gridNode );
|
||||
|
||||
repath();
|
||||
this.repath();
|
||||
}
|
||||
|
||||
private void recalcController()
|
||||
{
|
||||
recalculateControllerNextTick = false;
|
||||
ControllerState old = controllerState;
|
||||
this.recalculateControllerNextTick = false;
|
||||
ControllerState old = this.controllerState;
|
||||
|
||||
if ( controllers.isEmpty() )
|
||||
if ( this.controllers.isEmpty() )
|
||||
{
|
||||
controllerState = ControllerState.NO_CONTROLLER;
|
||||
this.controllerState = ControllerState.NO_CONTROLLER;
|
||||
}
|
||||
else
|
||||
{
|
||||
IGridNode startingNode = controllers.iterator().next().getGridNode( ForgeDirection.UNKNOWN );
|
||||
IGridNode startingNode = this.controllers.iterator().next().getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( startingNode == null )
|
||||
{
|
||||
controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
this.controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,15 +352,15 @@ public class PathGridCache implements IPathingGrid
|
||||
|
||||
startingNode.beginVisit( cv );
|
||||
|
||||
if ( cv.isValid && cv.found == controllers.size() )
|
||||
controllerState = ControllerState.CONTROLLER_ONLINE;
|
||||
if ( cv.isValid && cv.found == this.controllers.size() )
|
||||
this.controllerState = ControllerState.CONTROLLER_ONLINE;
|
||||
else
|
||||
controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
this.controllerState = ControllerState.CONTROLLER_CONFLICT;
|
||||
}
|
||||
|
||||
if ( old != controllerState )
|
||||
if ( old != this.controllerState )
|
||||
{
|
||||
myGrid.postEvent( new MENetworkControllerChange() );
|
||||
this.myGrid.postEvent( new MENetworkControllerChange() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -43,7 +43,7 @@ public class SecurityCache implements ISecurityGrid
|
||||
final private HashMap<Integer, EnumSet<SecurityPermissions>> playerPerms = new HashMap<Integer, EnumSet<SecurityPermissions>>();
|
||||
|
||||
public SecurityCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
private long securityKey = -1;
|
||||
@@ -52,43 +52,43 @@ public class SecurityCache implements ISecurityGrid
|
||||
@MENetworkEventSubscribe
|
||||
public void updatePermissions(MENetworkSecurityChange ev)
|
||||
{
|
||||
playerPerms.clear();
|
||||
if ( securityProvider.isEmpty() )
|
||||
this.playerPerms.clear();
|
||||
if ( this.securityProvider.isEmpty() )
|
||||
return;
|
||||
|
||||
securityProvider.get( 0 ).readPermissions( playerPerms );
|
||||
this.securityProvider.get( 0 ).readPermissions( this.playerPerms );
|
||||
}
|
||||
|
||||
public long getSecurityKey()
|
||||
{
|
||||
return securityKey;
|
||||
return this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return securityProvider.size() == 1 && securityProvider.get( 0 ).isSecurityEnabled();
|
||||
return this.securityProvider.size() == 1 && this.securityProvider.get( 0 ).isSecurityEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player, SecurityPermissions perm)
|
||||
{
|
||||
return hasPermission( player == null ? -1 : WorldSettings.getInstance().getPlayerID( player.getGameProfile() ), perm );
|
||||
return this.hasPermission( player == null ? -1 : WorldSettings.getInstance().getPlayerID( player.getGameProfile() ), perm );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(int playerID, SecurityPermissions perm)
|
||||
{
|
||||
if ( isAvailable() )
|
||||
if ( this.isAvailable() )
|
||||
{
|
||||
EnumSet<SecurityPermissions> perms = playerPerms.get( playerID );
|
||||
EnumSet<SecurityPermissions> perms = this.playerPerms.get( playerID );
|
||||
|
||||
if ( perms == null )
|
||||
{
|
||||
if ( playerID == -1 ) // no default?
|
||||
return false;
|
||||
else
|
||||
return hasPermission( -1, perm );
|
||||
return this.hasPermission( -1, perm );
|
||||
}
|
||||
|
||||
return perms.contains( perm );
|
||||
@@ -98,18 +98,18 @@ public class SecurityCache implements ISecurityGrid
|
||||
|
||||
private void updateSecurityKey()
|
||||
{
|
||||
long lastCode = securityKey;
|
||||
long lastCode = this.securityKey;
|
||||
|
||||
if ( securityProvider.size() == 1 )
|
||||
securityKey = securityProvider.get( 0 ).getSecurityKey();
|
||||
if ( this.securityProvider.size() == 1 )
|
||||
this.securityKey = this.securityProvider.get( 0 ).getSecurityKey();
|
||||
else
|
||||
securityKey = -1;
|
||||
this.securityKey = -1;
|
||||
|
||||
if ( lastCode != securityKey )
|
||||
if ( lastCode != this.securityKey )
|
||||
{
|
||||
myGrid.postEvent( new MENetworkSecurityChange() );
|
||||
for (IGridNode n : myGrid.getNodes())
|
||||
((GridNode) n).lastSecurityKey = securityKey;
|
||||
this.myGrid.postEvent( new MENetworkSecurityChange() );
|
||||
for (IGridNode n : this.myGrid.getNodes())
|
||||
((GridNode) n).lastSecurityKey = this.securityKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,8 +118,8 @@ public class SecurityCache implements ISecurityGrid
|
||||
{
|
||||
if ( machine instanceof ISecurityProvider )
|
||||
{
|
||||
securityProvider.remove( machine );
|
||||
updateSecurityKey();
|
||||
this.securityProvider.remove( machine );
|
||||
this.updateSecurityKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,11 +128,11 @@ public class SecurityCache implements ISecurityGrid
|
||||
{
|
||||
if ( machine instanceof ISecurityProvider )
|
||||
{
|
||||
securityProvider.add( (ISecurityProvider) machine );
|
||||
updateSecurityKey();
|
||||
this.securityProvider.add( (ISecurityProvider) machine );
|
||||
this.updateSecurityKey();
|
||||
}
|
||||
else
|
||||
((GridNode) gridNode).lastSecurityKey = securityKey;
|
||||
((GridNode) gridNode).lastSecurityKey = this.securityKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,8 +162,8 @@ public class SecurityCache implements ISecurityGrid
|
||||
@Override
|
||||
public int getOwner()
|
||||
{
|
||||
if ( isAvailable() )
|
||||
return securityProvider.get( 0 ).getOwner();
|
||||
if ( this.isAvailable() )
|
||||
return this.securityProvider.get( 0 ).getOwner();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+49
-49
@@ -54,37 +54,37 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
final IGrid myGrid;
|
||||
|
||||
public SpatialPylonCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long requiredPower()
|
||||
{
|
||||
return powerRequired;
|
||||
return this.powerRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRegion()
|
||||
{
|
||||
return captureMin != null;
|
||||
return this.captureMin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidRegion()
|
||||
{
|
||||
return hasRegion() && isValid;
|
||||
return this.hasRegion() && this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getMin()
|
||||
{
|
||||
return captureMin;
|
||||
return this.captureMin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getMax()
|
||||
{
|
||||
return captureMax;
|
||||
return this.captureMax;
|
||||
}
|
||||
|
||||
public void reset(IGrid grid)
|
||||
@@ -97,12 +97,12 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
double minPower = 0;
|
||||
double maxPower = 0;
|
||||
|
||||
clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
ioPorts = new LinkedList<TileSpatialIOPort>();
|
||||
this.clusters = new HashMap<SpatialPylonCluster, SpatialPylonCluster>();
|
||||
this.ioPorts = new LinkedList<TileSpatialIOPort>();
|
||||
|
||||
for (IGridNode gm : grid.getMachines( TileSpatialIOPort.class ))
|
||||
{
|
||||
ioPorts.add( (TileSpatialIOPort) gm.getMachine() );
|
||||
this.ioPorts.add( (TileSpatialIOPort) gm.getMachine() );
|
||||
}
|
||||
|
||||
IReadOnlyCollection<IGridNode> set = grid.getMachines( TileSpatialPylon.class );
|
||||
@@ -112,89 +112,89 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
{
|
||||
SpatialPylonCluster c = ((TileSpatialPylon) gm.getMachine()).getCluster();
|
||||
if ( c != null )
|
||||
clusters.put( c, c );
|
||||
this.clusters.put( c, c );
|
||||
}
|
||||
}
|
||||
|
||||
captureMax = null;
|
||||
captureMin = null;
|
||||
isValid = true;
|
||||
this.captureMax = null;
|
||||
this.captureMin = null;
|
||||
this.isValid = true;
|
||||
|
||||
int pylonBlocks = 0;
|
||||
for (SpatialPylonCluster cl : clusters.values())
|
||||
for (SpatialPylonCluster cl : this.clusters.values())
|
||||
{
|
||||
if ( captureMax == null )
|
||||
captureMax = cl.max.copy();
|
||||
if ( captureMin == null )
|
||||
captureMin = cl.min.copy();
|
||||
if ( this.captureMax == null )
|
||||
this.captureMax = cl.max.copy();
|
||||
if ( this.captureMin == null )
|
||||
this.captureMin = cl.min.copy();
|
||||
|
||||
pylonBlocks += cl.tileCount();
|
||||
|
||||
captureMin.x = Math.min( captureMin.x, cl.min.x );
|
||||
captureMin.y = Math.min( captureMin.y, cl.min.y );
|
||||
captureMin.z = Math.min( captureMin.z, cl.min.z );
|
||||
this.captureMin.x = Math.min( this.captureMin.x, cl.min.x );
|
||||
this.captureMin.y = Math.min( this.captureMin.y, cl.min.y );
|
||||
this.captureMin.z = Math.min( this.captureMin.z, cl.min.z );
|
||||
|
||||
captureMax.x = Math.max( captureMax.x, cl.max.x );
|
||||
captureMax.y = Math.max( captureMax.y, cl.max.y );
|
||||
captureMax.z = Math.max( captureMax.z, cl.max.z );
|
||||
this.captureMax.x = Math.max( this.captureMax.x, cl.max.x );
|
||||
this.captureMax.y = Math.max( this.captureMax.y, cl.max.y );
|
||||
this.captureMax.z = Math.max( this.captureMax.z, cl.max.z );
|
||||
}
|
||||
|
||||
if ( hasRegion() )
|
||||
if ( this.hasRegion() )
|
||||
{
|
||||
isValid = captureMax.x - captureMin.x > 1 && captureMax.y - captureMin.y > 1 && captureMax.z - captureMin.z > 1;
|
||||
this.isValid = this.captureMax.x - this.captureMin.x > 1 && this.captureMax.y - this.captureMin.y > 1 && this.captureMax.z - this.captureMin.z > 1;
|
||||
|
||||
for (SpatialPylonCluster cl : clusters.values())
|
||||
for (SpatialPylonCluster cl : this.clusters.values())
|
||||
{
|
||||
switch (cl.currentAxis)
|
||||
{
|
||||
case X:
|
||||
|
||||
isValid = isValid && ((captureMax.y == cl.min.y || captureMin.y == cl.max.y) || (captureMax.z == cl.min.z || captureMin.z == cl.max.z))
|
||||
&& ((captureMax.y == cl.max.y || captureMin.y == cl.min.y) || (captureMax.z == cl.max.z || captureMin.z == cl.min.z));
|
||||
this.isValid = this.isValid && ((this.captureMax.y == cl.min.y || this.captureMin.y == cl.max.y) || (this.captureMax.z == cl.min.z || this.captureMin.z == cl.max.z))
|
||||
&& ((this.captureMax.y == cl.max.y || this.captureMin.y == cl.min.y) || (this.captureMax.z == cl.max.z || this.captureMin.z == cl.min.z));
|
||||
|
||||
break;
|
||||
case Y:
|
||||
|
||||
isValid = isValid && ((captureMax.x == cl.min.x || captureMin.x == cl.max.x) || (captureMax.z == cl.min.z || captureMin.z == cl.max.z))
|
||||
&& ((captureMax.x == cl.max.x || captureMin.x == cl.min.x) || (captureMax.z == cl.max.z || captureMin.z == cl.min.z));
|
||||
this.isValid = this.isValid && ((this.captureMax.x == cl.min.x || this.captureMin.x == cl.max.x) || (this.captureMax.z == cl.min.z || this.captureMin.z == cl.max.z))
|
||||
&& ((this.captureMax.x == cl.max.x || this.captureMin.x == cl.min.x) || (this.captureMax.z == cl.max.z || this.captureMin.z == cl.min.z));
|
||||
|
||||
break;
|
||||
case Z:
|
||||
|
||||
isValid = isValid && ((captureMax.y == cl.min.y || captureMin.y == cl.max.y) || (captureMax.x == cl.min.x || captureMin.x == cl.max.x))
|
||||
&& ((captureMax.y == cl.max.y || captureMin.y == cl.min.y) || (captureMax.x == cl.max.x || captureMin.x == cl.min.x));
|
||||
this.isValid = this.isValid && ((this.captureMax.y == cl.min.y || this.captureMin.y == cl.max.y) || (this.captureMax.x == cl.min.x || this.captureMin.x == cl.max.x))
|
||||
&& ((this.captureMax.y == cl.max.y || this.captureMin.y == cl.min.y) || (this.captureMax.x == cl.max.x || this.captureMin.x == cl.min.x));
|
||||
|
||||
break;
|
||||
case UNFORMED:
|
||||
isValid = false;
|
||||
this.isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reqX = captureMax.x - captureMin.x;
|
||||
reqY = captureMax.y - captureMin.y;
|
||||
reqZ = captureMax.z - captureMin.z;
|
||||
reqX = this.captureMax.x - this.captureMin.x;
|
||||
reqY = this.captureMax.y - this.captureMin.y;
|
||||
reqZ = this.captureMax.z - this.captureMin.z;
|
||||
requirePylonBlocks = Math.max( 6, ((reqX * reqZ + reqX * reqY + reqY * reqZ) * 3) / 8 );
|
||||
|
||||
efficiency = (double) pylonBlocks / (double) requirePylonBlocks;
|
||||
this.efficiency = (double) pylonBlocks / (double) requirePylonBlocks;
|
||||
|
||||
if ( efficiency > 1.0 )
|
||||
efficiency = 1.0;
|
||||
if ( efficiency < 0.0 )
|
||||
efficiency = 0.0;
|
||||
if ( this.efficiency > 1.0 )
|
||||
this.efficiency = 1.0;
|
||||
if ( this.efficiency < 0.0 )
|
||||
this.efficiency = 0.0;
|
||||
|
||||
minPower = (double) reqX * (double) reqY * reqZ * AEConfig.instance.spatialPowerMultiplier;
|
||||
maxPower = Math.pow( minPower, AEConfig.instance.spatialPowerExponent );
|
||||
}
|
||||
|
||||
double affective_efficiency = Math.pow( efficiency, 0.25 );
|
||||
powerRequired = (long) (affective_efficiency * minPower + (1.0 - affective_efficiency) * maxPower);
|
||||
double affective_efficiency = Math.pow( this.efficiency, 0.25 );
|
||||
this.powerRequired = (long) (affective_efficiency * minPower + (1.0 - affective_efficiency) * maxPower);
|
||||
|
||||
for (SpatialPylonCluster cl : clusters.values())
|
||||
for (SpatialPylonCluster cl : this.clusters.values())
|
||||
{
|
||||
boolean myWasValid = cl.isValid;
|
||||
cl.isValid = isValid;
|
||||
if ( myWasValid != isValid )
|
||||
cl.isValid = this.isValid;
|
||||
if ( myWasValid != this.isValid )
|
||||
cl.updateStatus( false );
|
||||
}
|
||||
}
|
||||
@@ -202,13 +202,13 @@ public class SpatialPylonCache implements ISpatialCache
|
||||
@Override
|
||||
public float currentEfficiency()
|
||||
{
|
||||
return (float) efficiency * 100;
|
||||
return (float) this.efficiency * 100;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void bootingRender(MENetworkBootingStatusChange c)
|
||||
{
|
||||
reset( myGrid );
|
||||
this.reset( this.myGrid );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+36
-36
@@ -42,7 +42,7 @@ public class TickManagerCache implements ITickManager
|
||||
final IGrid myGrid;
|
||||
|
||||
public TickManagerCache(IGrid g) {
|
||||
myGrid = g;
|
||||
this.myGrid = g;
|
||||
}
|
||||
|
||||
final HashMap<IGridNode, TickTracker> alertable = new HashMap<IGridNode, TickTracker>();
|
||||
@@ -54,15 +54,15 @@ public class TickManagerCache implements ITickManager
|
||||
|
||||
public long getCurrentTick()
|
||||
{
|
||||
return currentTick;
|
||||
return this.currentTick;
|
||||
}
|
||||
|
||||
public long getAvgNanoTime(IGridNode node)
|
||||
{
|
||||
TickTracker tt = awake.get( node );
|
||||
TickTracker tt = this.awake.get( node );
|
||||
|
||||
if ( tt == null )
|
||||
tt = sleeping.get( node );
|
||||
tt = this.sleeping.get( node );
|
||||
|
||||
if ( tt == null )
|
||||
return -1;
|
||||
@@ -76,15 +76,15 @@ public class TickManagerCache implements ITickManager
|
||||
TickTracker tt = null;
|
||||
try
|
||||
{
|
||||
currentTick++;
|
||||
while (!upcomingTicks.isEmpty())
|
||||
this.currentTick++;
|
||||
while (!this.upcomingTicks.isEmpty())
|
||||
{
|
||||
tt = upcomingTicks.peek();
|
||||
int diff = (int) (currentTick - tt.lastTick);
|
||||
tt = this.upcomingTicks.peek();
|
||||
int diff = (int) (this.currentTick - tt.lastTick);
|
||||
if ( diff >= tt.current_rate )
|
||||
{
|
||||
// remove tt..
|
||||
upcomingTicks.poll();
|
||||
this.upcomingTicks.poll();
|
||||
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
|
||||
switch (mod)
|
||||
@@ -98,7 +98,7 @@ public class TickManagerCache implements ITickManager
|
||||
case SAME:
|
||||
break;
|
||||
case SLEEP:
|
||||
sleepDevice( tt.node );
|
||||
this.sleepDevice( tt.node );
|
||||
break;
|
||||
case SLOWER:
|
||||
tt.setRate( tt.current_rate + 1 );
|
||||
@@ -110,8 +110,8 @@ public class TickManagerCache implements ITickManager
|
||||
break;
|
||||
}
|
||||
|
||||
if ( awake.containsKey( tt.node ) )
|
||||
addToQueue( tt );
|
||||
if ( this.awake.containsKey( tt.node ) )
|
||||
this.addToQueue( tt );
|
||||
}
|
||||
else
|
||||
return; // done!
|
||||
@@ -128,30 +128,30 @@ public class TickManagerCache implements ITickManager
|
||||
|
||||
private void addToQueue(TickTracker tt)
|
||||
{
|
||||
tt.lastTick = currentTick;
|
||||
upcomingTicks.add( tt );
|
||||
tt.lastTick = this.currentTick;
|
||||
this.upcomingTicks.add( tt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alertDevice(IGridNode node)
|
||||
{
|
||||
TickTracker tt = alertable.get( node );
|
||||
TickTracker tt = this.alertable.get( node );
|
||||
if ( tt == null )
|
||||
return false;
|
||||
// throw new RuntimeException(
|
||||
// "Invalid alerted device, this node is not marked as alertable, or part of this grid." );
|
||||
|
||||
// set to awake, this is for sanity.
|
||||
sleeping.remove( node );
|
||||
awake.put( node, tt );
|
||||
this.sleeping.remove( node );
|
||||
this.awake.put( node, tt );
|
||||
|
||||
// configure sort.
|
||||
tt.lastTick = tt.lastTick - tt.request.maxTickRate;
|
||||
tt.current_rate = tt.request.minTickRate;
|
||||
|
||||
// prevent dupes and tick build up.
|
||||
upcomingTicks.remove( tt );
|
||||
upcomingTicks.add( tt );
|
||||
this.upcomingTicks.remove( tt );
|
||||
this.upcomingTicks.add( tt );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -159,11 +159,11 @@ public class TickManagerCache implements ITickManager
|
||||
@Override
|
||||
public boolean sleepDevice(IGridNode node)
|
||||
{
|
||||
if ( awake.containsKey( node ) )
|
||||
if ( this.awake.containsKey( node ) )
|
||||
{
|
||||
TickTracker gt = awake.get( node );
|
||||
awake.remove( node );
|
||||
sleeping.put( node, gt );
|
||||
TickTracker gt = this.awake.get( node );
|
||||
this.awake.remove( node );
|
||||
this.sleeping.put( node, gt );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -174,12 +174,12 @@ public class TickManagerCache implements ITickManager
|
||||
@Override
|
||||
public boolean wakeDevice(IGridNode node)
|
||||
{
|
||||
if ( sleeping.containsKey( node ) )
|
||||
if ( this.sleeping.containsKey( node ) )
|
||||
{
|
||||
TickTracker gt = sleeping.get( node );
|
||||
sleeping.remove( node );
|
||||
awake.put( node, gt );
|
||||
addToQueue( gt );
|
||||
TickTracker gt = this.sleeping.get( node );
|
||||
this.sleeping.remove( node );
|
||||
this.awake.put( node, gt );
|
||||
this.addToQueue( gt );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -192,9 +192,9 @@ public class TickManagerCache implements ITickManager
|
||||
{
|
||||
if ( machine instanceof IGridTickable )
|
||||
{
|
||||
alertable.remove( gridNode );
|
||||
sleeping.remove( gridNode );
|
||||
awake.remove( gridNode );
|
||||
this.alertable.remove( gridNode );
|
||||
this.sleeping.remove( gridNode );
|
||||
this.awake.remove( gridNode );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,17 +206,17 @@ public class TickManagerCache implements ITickManager
|
||||
TickingRequest tr = ((IGridTickable) machine).getTickingRequest( gridNode );
|
||||
if ( tr != null )
|
||||
{
|
||||
TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, currentTick, this );
|
||||
TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this );
|
||||
|
||||
if ( tr.canBeAlerted )
|
||||
alertable.put( gridNode, tt );
|
||||
this.alertable.put( gridNode, tt );
|
||||
|
||||
if ( tr.isSleeping )
|
||||
sleeping.put( gridNode, tt );
|
||||
this.sleeping.put( gridNode, tt );
|
||||
else
|
||||
{
|
||||
awake.put( gridNode, tt );
|
||||
addToQueue( tt );
|
||||
this.awake.put( gridNode, tt );
|
||||
this.addToQueue( tt );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ConnectionWrapper
|
||||
public IGridConnection connection;
|
||||
|
||||
public ConnectionWrapper(IGridConnection gc) {
|
||||
connection = gc;
|
||||
this.connection = gc;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-6
@@ -34,27 +34,27 @@ public class Connections implements Callable
|
||||
public boolean destroy = false;
|
||||
|
||||
public Connections(PartP2PTunnelME o) {
|
||||
me = o;
|
||||
this.me = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception
|
||||
{
|
||||
me.updateConnections( this );
|
||||
this.me.updateConnections( this );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void markDestroy()
|
||||
{
|
||||
create = false;
|
||||
destroy = true;
|
||||
this.create = false;
|
||||
this.destroy = true;
|
||||
}
|
||||
|
||||
public void markCreate()
|
||||
{
|
||||
create = true;
|
||||
destroy = false;
|
||||
this.create = true;
|
||||
this.destroy = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+21
-21
@@ -40,54 +40,54 @@ public class TickTracker implements Comparable<TickTracker>
|
||||
public int current_rate;
|
||||
|
||||
public TickTracker(TickingRequest req, IGridNode node, IGridTickable gt, long currentTick, TickManagerCache tickManagerCache) {
|
||||
request = req;
|
||||
this.request = req;
|
||||
this.gt = gt;
|
||||
this.node = node;
|
||||
current_rate = (req.minTickRate + req.maxTickRate) / 2;
|
||||
lastTick = currentTick;
|
||||
host = tickManagerCache;
|
||||
this.current_rate = (req.minTickRate + req.maxTickRate) / 2;
|
||||
this.lastTick = currentTick;
|
||||
this.host = tickManagerCache;
|
||||
}
|
||||
|
||||
public long getAvgNanos()
|
||||
{
|
||||
return (LastFiveTicksTime / 5);
|
||||
return (this.LastFiveTicksTime / 5);
|
||||
}
|
||||
|
||||
public void setRate(int rate)
|
||||
{
|
||||
current_rate = rate;
|
||||
this.current_rate = rate;
|
||||
|
||||
if ( current_rate < request.minTickRate )
|
||||
current_rate = request.minTickRate;
|
||||
if ( this.current_rate < this.request.minTickRate )
|
||||
this.current_rate = this.request.minTickRate;
|
||||
|
||||
if ( current_rate > request.maxTickRate )
|
||||
current_rate = request.maxTickRate;
|
||||
if ( this.current_rate > this.request.maxTickRate )
|
||||
this.current_rate = this.request.maxTickRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TickTracker t)
|
||||
{
|
||||
int nextTick = (int) ((lastTick - host.getCurrentTick()) + current_rate);
|
||||
int ts_nextTick = (int) ((t.lastTick - host.getCurrentTick()) + t.current_rate);
|
||||
int nextTick = (int) ((this.lastTick - this.host.getCurrentTick()) + this.current_rate);
|
||||
int ts_nextTick = (int) ((t.lastTick - this.host.getCurrentTick()) + t.current_rate);
|
||||
return nextTick - ts_nextTick;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||
{
|
||||
if ( gt instanceof AEBasePart )
|
||||
if ( this.gt instanceof AEBasePart )
|
||||
{
|
||||
AEBasePart part = (AEBasePart)gt;
|
||||
AEBasePart part = (AEBasePart)this.gt;
|
||||
part.addEntityCrashInfo( crashreportcategory );
|
||||
}
|
||||
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", current_rate );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", request.minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", request.maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", gt.getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", node.getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", node.getConnectedSides() );
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", this.current_rate );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", this.request.minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", this.request.maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", this.gt.getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", this.node.getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", this.node.getConnectedSides() );
|
||||
|
||||
DimensionalCoord dc = node.getGridBlock().getLocation();
|
||||
DimensionalCoord dc = this.node.getGridBlock().getLocation();
|
||||
if ( dc != null )
|
||||
crashreportcategory.addCrashSection( "Location", dc );
|
||||
}
|
||||
|
||||
@@ -31,35 +31,35 @@ public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
|
||||
Collection<T> tunnelSources;
|
||||
|
||||
public TunnelCollection(Collection<T> src, Class c) {
|
||||
tunnelSources = src;
|
||||
clz = c;
|
||||
this.tunnelSources = src;
|
||||
this.clz = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
if ( tunnelSources == null )
|
||||
if ( this.tunnelSources == null )
|
||||
return new NullIterator<T>();
|
||||
return new TunnelIterator<T>( tunnelSources, clz );
|
||||
return new TunnelIterator<T>( this.tunnelSources, this.clz );
|
||||
}
|
||||
|
||||
public void setSource(Collection<T> c)
|
||||
{
|
||||
tunnelSources = c;
|
||||
this.tunnelSources = c;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return !iterator().hasNext();
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
|
||||
public boolean matches(Class<? extends PartP2PTunnel> c)
|
||||
{
|
||||
return clz == c;
|
||||
return this.clz == c;
|
||||
}
|
||||
|
||||
public Class<? extends PartP2PTunnel> getClz()
|
||||
{
|
||||
return clz;
|
||||
return this.clz;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TunnelConnection
|
||||
final public IGridConnection c;
|
||||
|
||||
public TunnelConnection(PartP2PTunnelME t, IGridConnection con) {
|
||||
tunnel = t;
|
||||
c = con;
|
||||
this.tunnel = t;
|
||||
this.c = con;
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -32,32 +32,32 @@ public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
|
||||
|
||||
private void findNext()
|
||||
{
|
||||
while (Next == null && wrapped.hasNext())
|
||||
while (this.Next == null && this.wrapped.hasNext())
|
||||
{
|
||||
Next = wrapped.next();
|
||||
if ( !targetType.isInstance( Next ) )
|
||||
Next = null;
|
||||
this.Next = this.wrapped.next();
|
||||
if ( !this.targetType.isInstance( this.Next ) )
|
||||
this.Next = null;
|
||||
}
|
||||
}
|
||||
|
||||
public TunnelIterator(Collection<T> tunnelSources, Class clz) {
|
||||
wrapped = tunnelSources.iterator();
|
||||
targetType = clz;
|
||||
findNext();
|
||||
this.wrapped = tunnelSources.iterator();
|
||||
this.targetType = clz;
|
||||
this.findNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
findNext();
|
||||
return Next != null;
|
||||
this.findNext();
|
||||
return this.Next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
T tmp = Next;
|
||||
Next = null;
|
||||
T tmp = this.Next;
|
||||
this.Next = null;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user