diff --git a/Project.toml b/Project.toml index 476a8a6..f4c142d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Overseer" uuid = "1ada24be-c16d-4464-9f61-27c2e0f16645" authors = ["louisponet "] -version = "0.2.7" +version = "0.2.8" [deps] MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" diff --git a/src/entity.jl b/src/entity.jl index 8622050..0ee0f3a 100644 --- a/src/entity.jl +++ b/src/entity.jl @@ -28,10 +28,6 @@ function Entity(m::AbstractLedger, datas...) return e end -function entity(c::AbstractComponent, i::Integer) - return Entity(c.indices.packed[i]) -end - function Entity(m::AbstractLedger, parent::Entity, datas...) e = Entity(m) for d in datas @@ -186,3 +182,8 @@ end return @inbounds i.components[state][i.e], state + 1 end @inline Base.@propagate_inbounds Base.getindex(e::EntityState, i::Int) = e.components[i][e.e] + +function entity(c::AbstractComponent, i::Integer) + return EntityState(Entity(c.indices.packed[i]), c) +end + diff --git a/src/ledger.jl b/src/ledger.jl index 476c752..51ec0d8 100644 --- a/src/ledger.jl +++ b/src/ledger.jl @@ -54,7 +54,7 @@ stage(m::AbstractLedger, name) = stage(ledger(m), name) valid_entities(m::AbstractLedger) = filter(x -> x.id != 0, entities(m)) stages(m::AbstractLedger) = ledger(m).stages groups(m::AbstractLedger) = ledger(m).groups -singleton(m::AbstractLedger, ::Type{T}) where {T} = EntityState(entity(m[T], 1), m[T]) +singleton(m::AbstractLedger, ::Type{T}) where {T} = EntityState(Entity(entity(m[T], 1)), m[T]) ##### BASE Extensions #### function Base.show(io::IO, ::MIME"text/plain", l::AbstractLedger)