Skip to Content

Scaling

Per-scale numeric definitions keyed by scaleId under Ephemeral.scalings.<scaleId>. Supports create/configure/delete/list and ComputeTarget for a step index.

State (Ephemeral)

PathPurpose
scalings (object)One object per scaleId — tuning fields (steps, linearStep, multiplier, exponent, min/max, rounding, targetType, …)

How it looks in ephemeral.json

Under Ephemeral.scalings, each key is a scale id. Example from the Gnosis Engine’s default template (objectiveTarget drives round targets with ComputeTarget):

ephemeral.json
{ "Ephemeral": { "scalings": { "objectiveTarget": { "base": 50, "steps": "multiplier", "linearStep": 0, "multiplier": 1.2468991, "exponent": 1, "min": 1, "max": 0, "rounding": "round", "targetType": "int" } } } }

You may start with scalings empty and fill it at runtime via CreateScaling, or ship prefilled definitions in JSON as in the template.

Events

String ids are in GnosisScalingEvents (Runtime/GnosisEngine/Source/Services/Ephemeral/Services/ScalingService/). REQUEST_* are interceptable; matching FACT_* fire after a successful mutation.

Event idKind
REQUEST_SCALING_CREATERequest
FACT_SCALING_CREATEDFact
REQUEST_SCALING_CONFIGURERequest
FACT_SCALING_CONFIGUREDFact
REQUEST_SCALING_DELETERequest
FACT_SCALING_DELETEDFact

Payload key strings (e.g. scaleId, stepIndex, target, allowed, reason) are the PAYLOAD_* constants on the same class.

Functions

FunctionParameters (summary)
CreateScalingscaleId, optional base, steps (comma list: linear/exponent/multiplier), numeric tuning fields
ConfigureScalingscaleId + any tunable fields
DeleteScalingscaleId
GetScalingscaleId
ListScalings
ComputeTargetscaleId, stepIndex → includes target, targetKind

Usage example — ComputeTarget from scalings

Use ComputeTarget with a scaleId and stepIndex (e.g. current round, wave, or difficulty step) to read a value from Ephemeral.scalings. Example (payload keys are the string values from GnosisScalingEvents in the package — e.g. "scaleId", "stepIndex", "target"):

ScalingService.Example1.cs
private int ComputeRoundObjectiveTargetFromScaling(int stepIndex) { if (Context?.Store == null || Context.CallService == null) return fallbackIfMissing; var parameters = GnosisNode.CreateObject(Context.Store); parameters.Set("scaleId", "objectiveTarget"); // sample game id; matches default template `Ephemeral.scalings` parameters.Set("stepIndex", stepIndex); var result = CallService("Scaling", "ComputeTarget", parameters); if (!result.Success || !result.Data.IsValid || result.Data.Type != GnosisValueType.Object) return fallbackIfMissing; var targetNode = result.Data["target"]; if (!targetNode.IsValid) return fallbackIfMissing; if (targetNode.Type == GnosisValueType.Int) return Mathf.Max(0, (int)targetNode); if (targetNode.Type == GnosisValueType.Long) return Mathf.Max(0, (int)(long)targetNode); if (targetNode.Type == GnosisValueType.Float) return Mathf.Max(0, Mathf.RoundToInt((float)targetNode)); return fallbackIfMissing; }

(Typical host-side pattern; your game chooses scale ids and fallback handling.)

In the engine’s default template data, the objectiveTarget entry under Ephemeral.scalings matches the scaleId used in that sample; your game can use any ids you define.

Statistics

None.

Last updated on