RoR2-ChensHelpers

Contains simple and useful helpers for RoR2 mod creators to use. Mainly caters to Chen's mods.

View on GitHub

ChensHelpers

Chen.Helpers.UnityHelpers

QueueProcessor<T> Class

A generic component for implementing a Queue Processor.
The Queue Processor attempts to process N items per frame, allowing items to be processed over time and not instantaneously.

public abstract class QueueProcessor<T>

Type parameters

T

Inheritance UnityEngine.MonoBehaviour 🡒 QueueProcessor<T>

Fields  
processQueue The data structure where all items are queued in for processing.
Properties  
itemsPerFrame Number of items to process per frame.
processInterval The time gap in seconds in between processes.
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 queue.
Returning true will dispose of the item. Returning false will put the item back at the end of the queue.