Documentation
¶
Overview ¶
Package world defines the bounded compiled sector format shared by level compilers and Karty hosts. It contains data contracts and validation only.
Index ¶
Constants ¶
const ( LegacyVersion = uint16(1) ActorVersion = uint16(2) Version = uint16(3) EntryName = "@world/main" Feature = cartridge.FeatureWorldSectorsV1 MaxEncodedSize = 8 * 1024 * 1024 MaxSectors = 256 MaxWalls = 8192 MaxWallsPerSector = 256 MaxContents = 4096 MaxIdentifierBytes = 128 MaxKindBytes = 128 MaxTags = 8 MaxTagBytes = 64 MaxCoordinate = 1_000_000.0 MinEdgeLength = 1e-6 MinClearance = 1e-6 )
Variables ¶
var ( ErrSize = errors.New("world payload size is invalid") ErrSyntax = errors.New("world payload syntax is invalid") ErrVersion = errors.New("world payload version is unsupported") ErrBounds = errors.New("world payload exceeds a declared bound") ErrIdentity = errors.New("world identity is invalid") ErrGeometry = errors.New("world geometry is invalid") ErrPortal = errors.New("world portal is invalid") ErrContent = errors.New("world content is invalid") ErrCanonical = errors.New("world payload is not canonical") )
Functions ¶
Types ¶
type Actor ¶ added in v0.0.6
type Actor struct {
Yaw float64 `json:"yaw"`
Pitch float64 `json:"pitch"`
Roll float64 `json:"roll"`
Scale Vec3 `json:"scale"`
Sprite *Sprite `json:"sprite,omitempty"`
Tags []string `json:"tags,omitempty"`
}
Actor is the optional typed ECS payload introduced by compiled-world v2. Position remains on Content so actor and non-rendered gameplay contents share the same stable identity and sector assignment.
type Content ¶
type Content struct {
ID string `json:"id"`
SourceID string `json:"source_id"`
Instance string `json:"instance"`
Kind string `json:"kind"`
Sector uint32 `json:"sector"`
Position Vec3 `json:"position"`
Actor *Actor `json:"actor,omitempty"`
}
Content retains both its compiled identity and authored/prefab provenance. The component payload is deliberately deferred to its own versioned format.
type Document ¶
type Document struct {
Version uint16 `json:"version"`
Sectors []Sector `json:"sectors"`
Contents []Content `json:"contents"`
}
Document is one completely compiled world. Sector order is stable because portal references use sector indexes.
type Sector ¶
type Sector struct {
ID string `json:"id"`
SourceRoom string `json:"source_room"`
Instance string `json:"instance"`
Walls []Wall `json:"walls"`
Floor Plane `json:"floor"`
Ceiling Plane `json:"ceiling"`
FloorMaterial uint32 `json:"floor_material"`
CeilingMaterial uint32 `json:"ceiling_material"`
}
Sector is a strictly convex CCW cell. SourceRoom and Instance retain the authoring identity after prefab expansion and decomposition.
type Sprite ¶ added in v0.0.6
type Sprite struct {
AssetID uint32 `json:"asset_id"`
Facing SpriteFacing `json:"facing"`
Alpha SpriteAlpha `json:"alpha"`
Width float64 `json:"width"`
Height float64 `json:"height"`
OriginX float64 `json:"origin_x"`
OriginY float64 `json:"origin_y"`
}
type SpriteAlpha ¶ added in v0.0.6
type SpriteAlpha string
const ( SpriteCutout SpriteAlpha = "cutout" SpriteBlend SpriteAlpha = "blend" )
type SpriteFacing ¶ added in v0.0.6
type SpriteFacing string
const ( SpriteCameraFacing SpriteFacing = "camera-facing" SpriteUpright SpriteFacing = "upright" SpriteCross SpriteFacing = "cross" SpriteFixed SpriteFacing = "fixed" )
type Wall ¶
type Wall struct {
Start Vec2 `json:"start"`
End Vec2 `json:"end"`
Portal int32 `json:"portal"`
PortalWall uint16 `json:"portal_wall,omitempty"`
Material uint32 `json:"material"`
SourceEdge string `json:"source_edge"`
}
Wall is one directed sector boundary. Portal is the adjacent sector index, or -1 for an opaque wall. PortalWall is one plus the reciprocal wall index in compiled-world v3; zero is reserved for v1/v2 coincident portals and opaque walls. The paired directed edges define a rigid destination-to-source portal transform. SourceEdge is empty only for compiler-generated internal decomposition edges.