mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 01:20:04 +00:00
Fix indentations
This commit is contained in:
parent
4f65be279b
commit
a974132e29
1 changed files with 773 additions and 783 deletions
|
@ -272,7 +272,8 @@ local function hash(arr: { number }): string
|
|||
return table.concat(arr, "_")
|
||||
end
|
||||
|
||||
local world_get: (world: World, entityId: i53, a: i53, b: i53?, c: i53?, d: i53?, e: i53?) -> (...any)
|
||||
local world_get: (world: World, entityId: i53,
|
||||
a: i53, b: i53?, c: i53?, d: i53?, e: i53?) -> ...any
|
||||
do
|
||||
-- Keeping the function as small as possible to enable inlining
|
||||
local records
|
||||
|
@ -289,7 +290,9 @@ do
|
|||
return columns[tr.column][row]
|
||||
end
|
||||
|
||||
function world_get(world: World, entity: i53, a: i53, b: i53?, c: i53?, d: i53?, e: i53?): ...any
|
||||
function world_get(world: World, entity: i53,
|
||||
a: i53, b: i53?, c: i53?, d: i53?, e: i53?): ...any
|
||||
|
||||
local record = world.entityIndex.sparse[entity]
|
||||
if not record then
|
||||
return nil
|
||||
|
@ -401,7 +404,9 @@ end
|
|||
-- TODO:
|
||||
-- should have an additional `nth` parameter which selects the nth target
|
||||
-- this is important when an entity can have multiple relationships with the same target
|
||||
local function world_target(world: World, entity: i53, relation: i24--[[, nth: number]]): i24?
|
||||
local function world_target(world: World, entity: i53,
|
||||
relation: i24--[[, nth: number]]): i24?
|
||||
|
||||
local record = world.entityIndex.sparse[entity]
|
||||
local archetype = record.archetype
|
||||
if not archetype then
|
||||
|
@ -421,10 +426,7 @@ local function world_target(world: World, entity: i53, relation: i24--[[, nth: n
|
|||
return ecs_pair_second(world, archetype.types[tr.column])
|
||||
end
|
||||
|
||||
local function id_record_ensure(
|
||||
world: World,
|
||||
id: number
|
||||
): ArchetypeMap
|
||||
local function id_record_ensure(world: World, id: number): ArchetypeMap
|
||||
local componentIndex = world.componentIndex
|
||||
local idr = componentIndex[id]
|
||||
|
||||
|
@ -433,16 +435,13 @@ local function id_record_ensure(
|
|||
local relation = ECS_ENTITY_T_HI(id)
|
||||
|
||||
local cleanup_policy = world_target(world, relation, EcsOnDelete)
|
||||
local cleanup_policy_target = world_target(world, relation,
|
||||
EcsOnDeleteTarget)
|
||||
local cleanup_policy_target = world_target(world, relation, EcsOnDeleteTarget)
|
||||
|
||||
if cleanup_policy == EcsDelete or cleanup_policy_target == EcsDelete then
|
||||
flags = bit32.bor(flags, ECS_ID_DELETE)
|
||||
end
|
||||
|
||||
if world_has_any(world, relation,
|
||||
EcsOnAdd, EcsOnSet, EcsOnRemove)
|
||||
then
|
||||
if world_has_any(world, relation, EcsOnAdd, EcsOnSet, EcsOnRemove) then
|
||||
flags = bit32.bor(flags, ECS_ID_HAS_HOOKS)
|
||||
end
|
||||
|
||||
|
@ -457,7 +456,7 @@ local function id_record_ensure(
|
|||
idr = {
|
||||
size = 0,
|
||||
cache = {},
|
||||
flags = flags
|
||||
flags = flags,
|
||||
} :: ArchetypeMap
|
||||
componentIndex[id] = idr
|
||||
end
|
||||
|
@ -754,16 +753,16 @@ local function world_clear(world: World, entity: i53)
|
|||
entity_move(world.entityIndex, entity, record, ROOT_ARCHETYPE)
|
||||
end
|
||||
|
||||
local function archetype_fast_delete_last(columns, column_count,
|
||||
types, entity)
|
||||
local function archetype_fast_delete_last(columns: { Column },
|
||||
column_count: number, types: { i53 }, entity: i53)
|
||||
|
||||
for i, column in columns do
|
||||
column[column_count] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function archetype_fast_delete(columns, column_count,
|
||||
row, types, entity)
|
||||
local function archetype_fast_delete(columns: { Column },
|
||||
column_count: number, row, types, entity)
|
||||
|
||||
for i, column in columns do
|
||||
column[row] = column[column_count]
|
||||
|
@ -771,8 +770,6 @@ local function archetype_fast_delete(columns, column_count,
|
|||
end
|
||||
end
|
||||
|
||||
local ERROR_DELETE_PANIC = "Tried to delete entity that has (OnDelete, Panic)"
|
||||
|
||||
local function archetype_delete(world: World,
|
||||
archetype: Archetype, row: number)
|
||||
|
||||
|
@ -802,14 +799,11 @@ local function archetype_delete(world: World,
|
|||
end
|
||||
|
||||
if row == last then
|
||||
archetype_fast_delete_last(columns,
|
||||
column_count, types, delete)
|
||||
archetype_fast_delete_last(columns, column_count, types, delete)
|
||||
else
|
||||
archetype_fast_delete(columns, column_count,
|
||||
row, types, delete)
|
||||
archetype_fast_delete(columns, column_count, row, types, delete)
|
||||
end
|
||||
|
||||
|
||||
local component_index = world.componentIndex
|
||||
local archetypes = world.archetypes
|
||||
|
||||
|
@ -933,8 +927,7 @@ end
|
|||
|
||||
type CompatibleArchetype = { archetype: Archetype, indices: { number } }
|
||||
|
||||
local function noop()
|
||||
end
|
||||
local function noop() end
|
||||
|
||||
local function Arm(query, ...)
|
||||
return query
|
||||
|
@ -1322,7 +1315,7 @@ do
|
|||
return query
|
||||
end
|
||||
|
||||
local function world_query_replace(query, fn: (...any) -> (...any))
|
||||
local function world_query_replace(query, fn: (...any) -> ...any)
|
||||
query_init(query)
|
||||
|
||||
for i, archetype in compatible_archetypes do
|
||||
|
@ -1351,15 +1344,13 @@ do
|
|||
local vc = columns[records[C].column]
|
||||
local vd = columns[records[D].column]
|
||||
|
||||
va[row], vb[row], vc[row], vd[row] = fn(
|
||||
va[row], vb[row], vc[row], vd[row])
|
||||
va[row], vb[row], vc[row], vd[row] = fn(va[row], vb[row], vc[row], vd[row])
|
||||
else
|
||||
for j, id in ids do
|
||||
local tr = records[id]
|
||||
queryOutput[j] = columns[tr.column][row]
|
||||
end
|
||||
world_query_replace_values(row, columns,
|
||||
fn(unpack(queryOutput)))
|
||||
world_query_replace_values(row, columns, fn(unpack(queryOutput)))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1430,7 +1421,7 @@ do
|
|||
with = world_query_with,
|
||||
without = world_query_without,
|
||||
replace = world_query_replace,
|
||||
archetypes = world_query_archetypes
|
||||
archetypes = world_query_archetypes,
|
||||
} :: any
|
||||
|
||||
setmetatable(it, it)
|
||||
|
@ -1478,8 +1469,7 @@ function World.new()
|
|||
entity_index_new_id(self.entityIndex, i)
|
||||
end
|
||||
|
||||
world_add(self, EcsChildOf,
|
||||
ECS_PAIR(EcsOnDeleteTarget, EcsDelete))
|
||||
world_add(self, EcsChildOf, ECS_PAIR(EcsOnDeleteTarget, EcsDelete))
|
||||
|
||||
return self
|
||||
end
|
||||
|
@ -1495,14 +1485,14 @@ export type Entity<T = nil> = number & {__T: T }
|
|||
type Iter<T...> = (query: Query<T...>) -> () -> (Entity, T...)
|
||||
|
||||
type Query<T...> = typeof(setmetatable({}, {
|
||||
__iter = (nil :: any) :: Iter<T...>
|
||||
__iter = (nil :: any) :: Iter<T...>,
|
||||
})) & {
|
||||
iter: Iter<T...>,
|
||||
next: Item<T...>,
|
||||
drain: (self: Query<T...>) -> Query<T...>,
|
||||
with: (self: Query<T...>, ...i53) -> Query<T...>,
|
||||
without: (self: Query<T...>, ...i53) -> Query<T...>,
|
||||
replace: (self: Query<T...>, <U...>(T...) -> (U...)) -> (),
|
||||
replace: (self: Query<T...>, <U...>(T...) -> U...) -> (),
|
||||
archetypes: () -> { Archetype },
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue