Entities
Overview
In OpenCore, Entities are runtime representations of game objects (players, vehicles, NPCs, channels). Unlike raw handles, entities are rich objects that provide:
- State Management via
BaseEntitystate flags and metadata. - API Abstraction through adapter-backed methods instead of direct native calls.
- Lifecycle Safety using framework registries and cleanup flows.
Core Entities
Base Entity Contracts
Shared contracts used by runtime entities:
BaseEntityfor identity, state, metadata, and snapshots.Spatialfor position/heading operations.NativeHandlefor low-level handle interoperability.
Player
Represents a connected client with:
- Session identity (
clientID,accountID, identifiers). - Player communication (
emit,send). - Position/routing bucket, state flags, and metadata.
Vehicle
Represents a server-managed spawned vehicle with:
- Stable
networkIdand nativehandle. - Ownership/mod/metadata synchronization.
- Routing bucket and lifecycle helpers.
NPC
Represents a server-side ped wrapper with:
- Stable logical ID plus native handle/netId.
- Spatial and combat controls.
- Synced state bag helpers and serialization.
Architecture
Entities follow the Adapters Pattern. They avoid direct native calls and delegate to injected contracts (IEntityServer, IPedServer, IVehicleServer, etc.). This improves testability and keeps behavior consistent across runtime modes.