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

Method execute

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

Source from the content-addressed store, hash-verified

381
382export class SampleArrayExecutor implements INodeExecutor {
383 execute(node: BlueprintNode, context: unknown): ExecutionResult {
384 const ctx = context as ProcGenContext;
385 const seed = ctx.evaluateInput(node.id, 'seed', 0) as number;
386 const array = ctx.evaluateInput(node.id, 'array', []) as unknown[];
387 const count = ctx.evaluateInput(node.id, 'count', 1) as number;
388
389 if (array.length === 0 || count <= 0) {
390 return { outputs: { result: [] } };
391 }
392
393 const rng = new SeededRandom(seed);
394 const actualCount = Math.min(count, array.length);
395 const result = sample(array, actualCount, rng);
396
397 return { outputs: { result } };
398 }
399}
400
401// =============================================================================

Callers

nothing calls this directly

Calls 3

sampleFunction · 0.90
evaluateInputMethod · 0.65
minMethod · 0.45

Tested by

no test coverage detected