jecs/lib/Types.luau
HowManySmall b3f8e2504e buh
2024-05-04 14:10:59 -06:00

73 lines
1.3 KiB
Text

--!native
--!optimize 2
--!strict
export type i53 = number
export type i24 = number
export type Ty = {i53}
export type ArchetypeId = number
export type Column = {any}
export type Archetype = {
id: number,
edges: {
[i24]: {
add: Archetype,
remove: Archetype,
},
},
types: Ty,
type: string | number,
entities: {number},
columns: {Column},
records: {},
}
export type Record = {
archetype: Archetype,
row: number,
}
export type EntityIndex = {[i24]: Record}
export type ComponentIndex = {[i24]: ArchetypeMap}
export type ArchetypeRecord = number
export type ArchetypeMap = {sparse: {[ArchetypeId]: ArchetypeRecord}, size: number}
export type Archetypes = {[ArchetypeId]: Archetype}
export type ArchetypeDiff = {
added: Ty,
removed: Ty,
}
export type Hook = {
ids: Ty,
archetype: Archetype,
otherArchetype: Archetype,
offset: number,
}
export type EventDescription = Hook & {
event: number,
}
export type World = {
archetypeIndex: {[number | string]: Archetype},
archetypes: {[number]: Archetype},
componentIndex: {[i24]: ArchetypeMap},
entityIndex: {[i53]: Record},
hooks: {[number]: {Hook}},
nextComponentId: number,
nextEntityId: number,
ROOT_ARCHETYPE: Archetype,
get: (self: World) -> (),
}
export type WorldStatic = {
new: () -> World,
}
return false