Class GravitasWorldContext
- Namespace
- Gravitas
- Assembly
- Gravitas.dll
Owns Gravitas runtime state for one explicit GridForge.Grids.GridWorld.
public sealed class GravitasWorldContext : IDisposable
- Inheritance
-
GravitasWorldContext
- Implements
- Inherited Members
Remarks
This is the context-first host API for multi-world Gravitas usage. Phase 1 owns world lifetime, deterministic clock state, and lifecycle hooks; later phases move physics registries, collision partitioning, query buffers, and coroutine state here.
Properties
AccumulatedTime
Gets this context's accumulated visualization time.
public Fixed64 AccumulatedTime { get; }
Property Value
- Fixed64
Collisions
Gets this context's world-local collision partitioning service.
public GravitasCollisionService Collisions { get; }
Property Value
Collisions2D
Gets this context's world-local pure 2D collision partitioning service.
public GravitasCollision2DService Collisions2D { get; }
Property Value
Constraints2D
Gets this context's world-local pure 2D constraint and ragdoll service.
public GravitasConstraint2DService Constraints2D { get; }
Property Value
Constraints3D
Gets this context's world-local 3D constraint and ragdoll service.
public GravitasConstraint3DService Constraints3D { get; }
Property Value
Coroutines
Gets this context's world-local lockstep coroutine service.
public GravitasCoroutineService Coroutines { get; }
Property Value
DeltaTime
Gets this context's fixed simulation time step.
public Fixed64 DeltaTime { get; }
Property Value
- Fixed64
Diagnostics
Gets this context's deterministic diagnostic sink.
public GravitasDiagnosticSink Diagnostics { get; }
Property Value
Environment
Gets this context's world-local physical environment values.
public PhysicsEnvironment Environment { get; }
Property Value
ExpectedAccumulation
Gets this context's visualization accumulation expressed in simulation frames.
public Fixed64 ExpectedAccumulation { get; }
Property Value
- Fixed64
FrameCount
Gets this context's simulated frame count.
public int FrameCount { get; }
Property Value
FrameRate
Gets this context's fixed simulation frame rate.
public int FrameRate { get; }
Property Value
InvDeltaTime
Gets the reciprocal of this context's fixed simulation time step.
public Fixed64 InvDeltaTime { get; }
Property Value
- Fixed64
IsDisposed
Gets whether this context has been disposed.
public bool IsDisposed { get; }
Property Value
Physics
Gets this context's world-local physics registration and pair service.
public GravitasPhysicsService Physics { get; }
Property Value
Physics2D
Gets this context's world-local pure 2D physics service.
public GravitasPhysics2DService Physics2D { get; }
Property Value
Query2D
Gets this context's world-local pure 2D query service.
public GravitasQuery2DService Query2D { get; }
Property Value
Query3D
Gets this context's world-local 3D query service.
public GravitasQuery3DService Query3D { get; }
Property Value
QueryMixed
Gets this context's explicit mixed 3D/2D query service.
public GravitasQueryMixedService QueryMixed { get; }
Property Value
ResetAccumulation
Gets whether this context's visualization accumulation will reset on the next visualize call.
public bool ResetAccumulation { get; }
Property Value
Settings
Gets this context's world-local physics settings.
public PhysicsSettings Settings { get; }
Property Value
TotalTime
Gets this context's total simulated time.
public Fixed64 TotalTime { get; }
Property Value
- Fixed64
VoxelSize
Gets a representative grid cell edge for this context's world.
public Fixed64 VoxelSize { get; }
Property Value
- Fixed64
World
Gets the explicit GridForge world owned or referenced by this context.
public GridWorld World { get; }
Property Value
- GridWorld
Methods
ApplySettings(PhysicsSettings)
Applies context-local settings and synchronizes frame-derived clock state.
public void ApplySettings(PhysicsSettings settings)
Parameters
settingsPhysicsSettingsThe settings instance to own.
Attach(GridWorld, bool)
Attaches a context to a host-owned GridForge.Grids.GridWorld.
public static GravitasWorldContext Attach(GridWorld world, bool takeOwnership = false)
Parameters
worldGridWorldThe active world to bind.
takeOwnershipboolTrue when disposing this context should dispose the supplied world.
Returns
- GravitasWorldContext
A context bound to
world.
ComputeReplayHash(GravitasReplayHashMode)
Computes a deterministic fixed-width hash of this context's replay-relevant physics state.
public ChronicleHash ComputeReplayHash(GravitasReplayHashMode mode = GravitasReplayHashMode.Authoritative)
Parameters
modeGravitasReplayHashModeSelects whether diagnostic solver/cache state is included in addition to authoritative state.
Returns
- ChronicleHash
A deterministic hash suitable for lockstep replay conformance checks.
Remarks
The hash includes context settings, environment values, body state, collider shape/filter state, retained pair/contact state, and continuation-affecting CCD handoff state. It excludes host object identity, delegates, diagnostics buffers, debug draw data, query scratch buffers, and visualization interpolation caches.
CreateOwned(int)
Creates a context with an owned GridForge.Grids.GridWorld.
public static GravitasWorldContext CreateOwned(int spatialGridCellSize = 50)
Parameters
spatialGridCellSizeintSpatial hash cell size for the created world.
Returns
- GravitasWorldContext
A context that owns its created world.
Dispose()
public void Dispose()
GetFrameFromTime(Fixed64)
Calculates the frame index containing the specified fixed-point timestamp.
public int GetFrameFromTime(Fixed64 timestamp)
Parameters
timestampFixed64The timestamp to resolve.
Returns
- int
The zero-based frame index for the timestamp.
LateSimulate()
Runs this context's late-simulation step.
public void LateSimulate()
LateVisualize()
Runs this context's host-owned late-visualization hook phase.
public void LateVisualize()
Reset()
Resets this context's deterministic clock and context-local lifecycle hooks.
public void Reset()
SetFrameRate(int)
Updates this context's fixed simulation frame rate.
public void SetFrameRate(int frameRate)
Parameters
frameRateintThe new frame rate. Must be within the supported physics settings range.
Simulate()
Advances this context's deterministic simulation clock and ordered simulate hooks.
public void Simulate()
Visualize()
Runs this context's visualization accumulation step.
public void Visualize()