---@meta tiny-ecs

---@class World
World = {}

function World:add(...) end

---@generic T : Entity
---@param entity T
---@return T
function World:addEntity(entity) end

---@generic T : System
---@param system T
---@return T
function World:addSystem(system) end

function World:remove(...) end

function World:removeEntity(entity) end

function World:removeSystem(system) end

--- Manages Entities and Systems marked for deletion or addition. Call this
--- before modifying Systems and Entities outside of a call to `tiny.update`.
--- Do not call this within a call to `tiny.update`.
function World:refresh() end

---@param dt number
---@param systemFilter nil | fun(world: World, system: System): boolean
function World:update(dt, systemFilter) end

--- Removes all Entities from the World.
function World:clearEntities() end

--- Removes all Systems from the World.
function World:clearSystems() end

--- Gets number of Entities in the World.
function World:getEntityCount() end

--- Gets number of Systems in World.
function World:getSystemCount() end

--- Sets the index of a System in the World, and returns the old index. Changes
--- the order in which they Systems processed, because lower indexed Systems are
--- processed first. Returns the old system.index.
function World:setSystemIndex(world, system, index) end

---@generic T
---@param shape T | fun()
---@param process fun(entity: T, dt: number, system: System) | nil
---@param compare nil | fun(system: System, entityA: T, entityB: T): boolean
---@return System | { entities: T[] }
function World:filteredSystem(name, shape, process, compare) end