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
Owns world lifetime, deterministic timing, physics registries, collision partitioning, queries, coroutines, and lifecycle hooks for one simulation.
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
ElapsedTime
Gets elapsed simulation time, preserving the history of step-size changes.
public ChronicleTimestamp ElapsedTime { get; }
Property Value
- ChronicleTimestamp
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 long 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
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
spatialGridCellSizeintOrdinary-grid spatial lookup cell size for the created world.
Returns
- GravitasWorldContext
A context that owns its created world.
Dispose()
public void Dispose()
GetFrameCountForDuration(Fixed64)
Counts complete steps in a duration using the current fixed step size.
public long GetFrameCountForDuration(Fixed64 duration)
Parameters
durationFixed64A nonnegative duration in seconds.
Returns
- long
The complete-step count, rounded down using exact raw-unit division.
Remarks
This is not a historical timestamp-to-frame lookup.
LateSimulate()
Runs this context's late-simulation step.
public void LateSimulate()
Exceptions
- InvalidOperationException
The independent late-simulation phase counter is exhausted. Rejection occurs before this call changes world state.
- OverflowException
A body position cannot be represented. Earlier step work may already have advanced; stop and restore a known state before continuing.
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()
Remarks
Timing exhaustion rejects before this call changes world state.
Exceptions
- InvalidOperationException
The frame counter or required late-simulation phase counter is exhausted.
- OverflowException
The next elapsed timestamp is unrepresentable.
Visualize()
Runs this context's visualization accumulation step.
public void Visualize()