(node: BlueprintNode, context: unknown)
| 340 | |
| 341 | export class PickRandomExecutor implements INodeExecutor { |
| 342 | execute(node: BlueprintNode, context: unknown): ExecutionResult { |
| 343 | const ctx = context as ProcGenContext; |
| 344 | const seed = ctx.evaluateInput(node.id, 'seed', 0) as number; |
| 345 | const index = ctx.evaluateInput(node.id, 'index', 0) as number; |
| 346 | const array = ctx.evaluateInput(node.id, 'array', []) as unknown[]; |
| 347 | |
| 348 | if (array.length === 0) { |
| 349 | return { outputs: { value: null } }; |
| 350 | } |
| 351 | |
| 352 | const rng = new SeededRandom(seed + index * 12345); |
| 353 | const value = pickOne(array, rng); |
| 354 | |
| 355 | return { outputs: { value } }; |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | // ============================================================================= |
nothing calls this directly
no test coverage detected