To start, create a new MonoBehaviour script that derives from the ChunkReuseJudge base abstract class.
You should place your class inside of the DeepSpaceLabs.SAM namespace, which will make the ChunkReuseJudge class available and also help avoid naming conflicts with 3rd party assets or your own code.
--Special Note--
An easy way to start with your custom class is to hover over your custom class name and choose the option Show potential fixes -> Implement abstract class. This will provide default overrides for all abstract class members.
In addition, we recommend adding the following attribute above your class, which will ensure the custom chunk reuse judge is shown with other Chunk Reuse Judges in menus:
[AddComponentMenu(GlobalValues.COMPONENT_ROOT_PATH + "Chunk Reuse Judges/Custom Judge Name")]
This is the one and only method you need to override for Chunk Reuse Judges. Your implementation should return a JudgementDelegate object, which is simply a Function that takes in a Cell that has Asset Chunks and a Cell that needs Asset Chunks, and returns a bool indicating whether the Asset Chunks can be transferred from the cellThatHasChunks to the cellThatNeedsChunks.
We utilize a delegate and Cell based arguments in order to allow the reuse logic to work inside of Jobs. The input Cells are actually the Streamable Grid Cell Indexes of the World Cell that no longer needs its Asset Chunks and the World Cell needing Asset Chunks.
It's a good idea to assign the delegate to a field on your custom class in Awake, since GetJudgementLogic is called repeatedly and only a single delegate object is needed. If you do not follow this advice, garbage will be generated each time GetJudgementLogic is called!
Some examples of reuse logic that you might wish to employ include:
1) Allowing reuse if the two Cells have the same Row, Column, Layer, or some combination of Row/Column, Column/Layer, or Row/Layer.
2) Allowing Reuse if the Cells are within some distance of each other.
3) Assigning Cells to specific groups based on the indexes, computing those groups within the delegate, and allowing reuse only if the two Cells fall within the same group.