MCPcopy Create free account
hub / github.com/esengine/esengine / execute

Method execute

packages/procgen/src/nodes/ProcGenNodes.ts:342–356  ·  view source on GitHub ↗
(node: BlueprintNode, context: unknown)

Source from the content-addressed store, hash-verified

340
341export 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// =============================================================================

Callers

nothing calls this directly

Calls 2

pickOneFunction · 0.90
evaluateInputMethod · 0.65

Tested by

no test coverage detected