Ticketer¶
Namespace Nfty.Ticket in assembly Nfty.Ticket.
The roll: decides a whole asset and touches no pixels.
Remarks¶
This is the only roll of an asset in the product. Generator calls it and keeps only the render, and StackRoll.ForRecipe (the recipe preview) calls it too, so there is exactly one definition of the order in which an asset's layers consume the RNG. Two copies is how "the same seed produces the same collection" stops being true, and the difference would be invisible until a server and a client disagreed about what had been dropped.
Methods¶
Prepare(MenuBook)¶
Resolves a book's draw order and totals, once.
Parameters
book(MenuBook) - The Menu to prepare.
Returns. The prepared form, to hand Ticketer.TryRoll() repeatedly.
TryRoll(PreparedMenu, IRng)¶
Rolls one asset.
Parameters
menu(PreparedMenu) - The prepared Menu.rng(IRng) - The run's RNG.
Returns. The ticket, or null when the recipe's rules reject the selection — which is the caller's signal to reroll, exactly as Generator's loop does.
Exceptions
ArgumentNullException-menuorrngis null.
Example
Roll with a bounded retry, as the generator does. One generator is one stream, so give each worker its own.
var menu = Ticketer.Prepare(book);
var rng = new SplitMix64Rng(SeedHash.ToUlong("my-seed"));
AssetTicket? ticket = null;
for (int attempt = 0; attempt < 10_000 && ticket is null; attempt++)
ticket = Ticketer.TryRoll(menu, rng);
See also