mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Use generalized iteration
This commit is contained in:
parent
76aef4f1b1
commit
edb73ca49a
3 changed files with 4 additions and 4 deletions
|
@ -34,11 +34,11 @@ local moving_mobs = world
|
||||||
local function mobsMove(dt: number)
|
local function mobsMove(dt: number)
|
||||||
local targets = {}
|
local targets = {}
|
||||||
|
|
||||||
for _, character in characters:iter() do
|
for _, character in characters do
|
||||||
table.insert(targets, (character.PrimaryPart :: Part).Position)
|
table.insert(targets, (character.PrimaryPart :: Part).Position)
|
||||||
end
|
end
|
||||||
|
|
||||||
for mob, transform, v in moving_mobs:iter() do
|
for mob, transform, v in moving_mobs do
|
||||||
local cf = transform.new
|
local cf = transform.new
|
||||||
local p = cf.Position
|
local p = cf.Position
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ local Transform = cts.Transform
|
||||||
|
|
||||||
local moving_models = world:query(Transform, Model):cached()
|
local moving_models = world:query(Transform, Model):cached()
|
||||||
local function move(dt: number)
|
local function move(dt: number)
|
||||||
for _, transform, model in moving_models:iter() do
|
for _, transform, model in moving_models do
|
||||||
local cf = transform.new
|
local cf = transform.new
|
||||||
if cf ~= transform.old then
|
if cf ~= transform.old then
|
||||||
local part = model.PrimaryPart :: BasePart
|
local part = model.PrimaryPart :: BasePart
|
||||||
|
|
|
@ -34,7 +34,7 @@ end
|
||||||
|
|
||||||
local q = world:query(A, B, C, D):cached()
|
local q = world:query(A, B, C, D):cached()
|
||||||
local function cached()
|
local function cached()
|
||||||
for _ in q:iter() do
|
for _ in q do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue