ChensHelpers
Chen.Helpers.UnityHelpers
ListProcessor<T> Class
A generic component for implementing a List Processor.
The List Processor will attempt to process all the items in the data structure in a single frame.
public abstract class ListProcessor<T>
Type parameters
Inheritance UnityEngine.MonoBehaviour 🡒 ListProcessor<T>
Fields | |
---|---|
processList | The data structure where all items are stored for processing. |
Properties | |
---|---|
processInterval | The time gap in seconds in between processes. |
repeatUntilSuccess | Determines whether the data structure should save failed items back and repeat the process in the same frame. |
Methods | |
---|---|
Add(T) | Adds an item into the data structure for processing. No need to override this, but one may do so for complex implementations. |
FixedUpdate() | A method powered by Unity’s MonoBehaviour. This contains the logic processing the queue and its items. There is no need to override this, however if complex code is required, one may do so. |
OnFailure(T) | A post-processing method to perform when the operation process failed. Always invoke base.OnFailure. |
OnSuccess(T) | A post-processing method to perform when the operation process is successful. Always invoke base.OnSuccess. |
Process(T) | A method the contains the main processing logic. It is required to be implemented by the child class. This method returns a boolean that determines the outcome of the item from the list. Returning true will dispose of the item. Returning false will put the item back at the end of the queue. |