This commit is contained in:
PrototypeTrousers
2021-12-09 23:08:26 -03:00
parent b51af43dba
commit 94d73aec7c
9 changed files with 1164 additions and 1358 deletions
+4 -9
View File
@@ -170,15 +170,14 @@ public class GridStorageCache implements IStorageGrid
private CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
{
if( this.inactiveCellProviders.contains( cc ) && !this.activeCellProviders.contains( cc ))
if( this.inactiveCellProviders.contains( cc ) )
{
this.inactiveCellProviders.remove( cc );
this.activeCellProviders.add( cc );
final IActionSource actionSrc = cc instanceof IActionHost ? new MachineSource( (IActionHost) cc ) : new BaseActionSource();
this.storageMonitors.forEach( ( channel, monitor ) ->
{
this.storageMonitors.forEach( ( channel, monitor ) -> {
for( final IMEInventoryHandler<?> h : cc.getCellArray( channel ) )
{
tracker.postChanges( channel, 1, h, actionSrc );
@@ -223,7 +222,7 @@ public class GridStorageCache implements IStorageGrid
for( final ICellProvider cc : ll )
{
boolean active = true;
boolean active = false;
if( cc instanceof IActionHost )
{
@@ -232,10 +231,6 @@ public class GridStorageCache implements IStorageGrid
{
active = true;
}
else
{
active = false;
}
}
if( active )
@@ -249,7 +244,7 @@ public class GridStorageCache implements IStorageGrid
}
tracker.applyChanges();
this.storageMonitors.forEach( ( channel, monitor ) -> monitor.forceUpdate() );
this.storageMonitors.forEach( ( channel, monitor ) -> monitor.setForceUpdate( true ) );
}
private <T extends IAEStack<T>, C extends IStorageChannel<T>> void postChangesToNetwork( final C chan, final int upOrDown, final IItemList<T> availableItems, final IActionSource src )
+12 -2
View File
@@ -63,6 +63,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
private boolean sendEvent = false;
private long gridItemCount;
private long gridFluidCount;
public boolean forceUpdate;
public NetworkMonitor( final GridStorageCache cache, final IStorageChannel<T> chan )
{
@@ -232,7 +233,6 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
return;
}
src2MonitorsMap.get( src ).add( this );
isNested = false;
this.sendEvent = true;
@@ -285,7 +285,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
if( networkMonitor.isNested != networkMonitor.wasNested )
{
networkMonitor.wasNested = networkMonitor.isNested;
networkMonitor.forceUpdate();
networkMonitor.setForceUpdate( true );
}
} );
src2MonitorsMap.remove( src );
@@ -293,8 +293,14 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
}
}
public void setForceUpdate( boolean forceUpdate )
{
this.forceUpdate = forceUpdate;
}
void forceUpdate()
{
forceUpdate = false;
this.cachedList.resetStatus();
this.getAvailableItems( this.cachedList );
@@ -357,6 +363,10 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
void onTick()
{
if( forceUpdate )
{
forceUpdate();
}
if( this.sendEvent )
{
this.sendEvent = false;