-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Persist autocrafting tasks
- Loading branch information
Showing
18 changed files
with
753 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...-api/src/main/java/com/refinedmods/refinedstorage/api/autocrafting/task/TaskSnapshot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.refinedmods.refinedstorage.api.autocrafting.task; | ||
|
||
import com.refinedmods.refinedstorage.api.autocrafting.Pattern; | ||
import com.refinedmods.refinedstorage.api.resource.ResourceKey; | ||
import com.refinedmods.refinedstorage.api.resource.list.MutableResourceList; | ||
import com.refinedmods.refinedstorage.api.resource.list.MutableResourceListImpl; | ||
import com.refinedmods.refinedstorage.api.resource.list.ResourceList; | ||
import com.refinedmods.refinedstorage.api.storage.Actor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import javax.annotation.Nullable; | ||
|
||
public record TaskSnapshot( | ||
TaskId id, | ||
ResourceKey resource, | ||
long amount, | ||
Actor actor, | ||
boolean notifyActor, | ||
long startTime, | ||
Map<Pattern, PatternSnapshot> patterns, | ||
List<PatternSnapshot> completedPatterns, | ||
ResourceList initialRequirements, | ||
ResourceList internalStorage, | ||
TaskState state, | ||
boolean cancelled | ||
) { | ||
MutableResourceList copyInitialRequirements() { | ||
final MutableResourceList copy = MutableResourceListImpl.create(); | ||
initialRequirements.getAll().forEach(key -> copy.add(key, initialRequirements.get(key))); | ||
return copy; | ||
} | ||
|
||
public MutableResourceList copyInternalStorage() { | ||
final MutableResourceList copy = MutableResourceListImpl.create(); | ||
internalStorage.getAll().forEach(key -> copy.add(key, internalStorage.get(key))); | ||
return copy; | ||
} | ||
|
||
public record PatternSnapshot( | ||
boolean root, | ||
Pattern pattern, | ||
Map<Integer, Map<ResourceKey, Long>> ingredients, | ||
@Nullable InternalPatternSnapshot internalPattern, | ||
@Nullable ExternalPatternSnapshot externalPattern | ||
) { | ||
AbstractTaskPattern toTaskPattern() { | ||
return internalPattern != null ? new InternalTaskPattern(this) : new ExternalTaskPattern(this); | ||
} | ||
} | ||
|
||
public record InternalPatternSnapshot(long originalIterationsRemaining, long iterationsRemaining) { | ||
} | ||
|
||
public record ExternalPatternSnapshot( | ||
ResourceList expectedOutputs, | ||
ResourceList simulatedIterationInputs, | ||
long originalIterationsToSendToSink, | ||
long iterationsToSendToSink, | ||
long iterationsReceived, | ||
boolean interceptedAnythingSinceLastStep, | ||
@Nullable | ||
ExternalPatternInputSink.Result lastSinkResult, | ||
@Nullable | ||
ExternalPatternInputSinkKey lastSinkResultKey | ||
) { | ||
MutableResourceList copyExpectedOutputs() { | ||
final MutableResourceList copy = MutableResourceListImpl.create(); | ||
expectedOutputs.getAll().forEach(key -> copy.add(key, expectedOutputs.get(key))); | ||
return copy; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.