Skip to main content

World

A simulation world. Owns the actor pool, the snapshot store, and the projectile definitions registry. Built by Hindsight.createWorld.

A typical server uses one World; clients use one World per peer for visuals only. Server and client Worlds do not share state — both speak the same definitions module independently because each Actor requires the module in its own VM.

Properties

rollback

World.rollback: Rollback

The rollback store. See the Rollback class for the full method list.

Functions

cast

World:cast(optionsCastOptions) → ()

Fires a projectile. Resolves options.type against the definitions module, then dispatches to the least-loaded simulation actor in the pool.

On the server, timestamp should reflect the moment from the shooter's perspective — typically clientTimestamp - playerPing - interpolation. On the client, workspace:GetServerTimeNow() is fine — the client World has no rollback path.

hitscan

World:hitscan(optionsCastOptions) → ()

Resolves a single-frame ray. Server-side, queries the rollback store for lag-compensated character hits using options.timestamp; the projectile loop is bypassed entirely. Client-side, only world geometry is tested — the client World has no rollback path, so onIntersection will not fire.

Reuses the same ProjectileDefinition as cast. Hitscan-relevant fields: range, power, angle, loss, collaterals, raycastFilter, filter, onImpact, onIntersection. Projectile-only fields (velocity, gravity, lifetime) are ignored.

onDestroyed is not fired by the hitscan path — the terminal callback is the last onImpact or onIntersection. Out-of-range scans fire no callback at all.

Penetration and ricochet behave identically to the projectile path, bounded by MAX_ITERATIONS (16) to prevent runaway bounces.

destroy

World:destroy() → ()

Tears down the simulation actor pool. Disconnects every Output binding, destroys every Actor, and clears internal references. After destroy, the World is unusable — build a new one with Hindsight.createWorld.

Show raw api
{
    "functions": [
        {
            "name": "cast",
            "desc": "Fires a projectile. Resolves `options.type` against the definitions module,\nthen dispatches to the least-loaded simulation actor in the pool.\n\nOn the server, `timestamp` should reflect the moment from the shooter's\nperspective — typically `clientTimestamp - playerPing - interpolation`.\nOn the client, `workspace:GetServerTimeNow()` is fine — the client World\nhas no rollback path.",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "CastOptions"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 472,
                "path": "src/World.lua"
            }
        },
        {
            "name": "hitscan",
            "desc": "Resolves a single-frame ray. Server-side, queries the rollback store for\nlag-compensated character hits using `options.timestamp`; the projectile\nloop is bypassed entirely. Client-side, only world geometry is tested —\nthe client World has no rollback path, so `onIntersection` will not fire.\n\nReuses the same [`ProjectileDefinition`](Hindsight#ProjectileDefinition) as\n[`cast`](#cast). Hitscan-relevant fields: `range`, `power`, `angle`, `loss`,\n`collaterals`, `raycastFilter`, `filter`, `onImpact`, `onIntersection`.\nProjectile-only fields (`velocity`, `gravity`, `lifetime`) are ignored.\n\n`onDestroyed` is **not** fired by the hitscan path — the terminal callback\nis the last `onImpact` or `onIntersection`. Out-of-range scans fire no\ncallback at all.\n\nPenetration and ricochet behave identically to the projectile path,\nbounded by `MAX_ITERATIONS` (16) to prevent runaway bounces.",
            "params": [
                {
                    "name": "options",
                    "desc": "",
                    "lua_type": "CastOptions"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 498,
                "path": "src/World.lua"
            }
        },
        {
            "name": "destroy",
            "desc": "Tears down the simulation actor pool. Disconnects every Output binding,\ndestroys every Actor, and clears internal references. After `destroy`, the\nWorld is unusable — build a new one with [`Hindsight.createWorld`](Hindsight#createWorld).",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 516,
                "path": "src/World.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "rollback",
            "desc": "The rollback store. See the [`Rollback`](Rollback) class for the full\nmethod list.",
            "lua_type": "Rollback",
            "source": {
                "line": 63,
                "path": "src/World.lua"
            }
        }
    ],
    "types": [],
    "name": "World",
    "desc": "A simulation world. Owns the actor pool, the snapshot store, and the\nprojectile definitions registry. Built by [`Hindsight.createWorld`](Hindsight#createWorld).\n\nA typical server uses one World; clients use one World per peer for\nvisuals only. Server and client Worlds do not share state — both speak the\nsame definitions module independently because each Actor `require`s the\nmodule in its own VM.",
    "source": {
        "line": 35,
        "path": "src/World.lua"
    }
}