Skip to content

Commit

Permalink
Merge system files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Sep 9, 2024
1 parent 8c28cab commit 411138e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 141 deletions.
76 changes: 0 additions & 76 deletions demo.project.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ local jecs = require(ReplicatedStorage.ecs)
local __ = jecs.Wildcard

local std = require(ReplicatedStorage.std)
local ref = std.ref
local interval = std.interval

local world: std.World = std.world
local cts = std.components

Expand Down Expand Up @@ -48,7 +51,28 @@ local function mobsMove(dt: number)
end
end

local throttle = interval(5)

local function spawnMobs()
if throttle() then
local p = Vector3.new(0, 5, 0)
local cf = CFrame.new(p)
local v = 5

local id = ref()
:set(Velocity, v)
:set(Transform, { new = cf })
:add(Mob)
.id()

blink.SpawnMob.FireAll(id, cf, v)
end
end

return function(scheduler: std.Scheduler)
return scheduler.systems.new(mobsMove,
scheduler.phases.Heartbeat)
local phases = scheduler.phases
local system_new = scheduler.systems.new
system_new(mobsMove, phases.Heartbeat)
system_new(spawnMobs, phases.Heartbeat)

end
5 changes: 3 additions & 2 deletions demo/src/ServerScriptService/systems/players.luau
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ local function players()
end

return function(scheduler: std.Scheduler)
return scheduler.systems.new(players,
scheduler.phases.Heartbeat)
local phases = scheduler.phases
local system_new = scheduler.systems.new
system_new(players, phases.Heartbeat)
end
33 changes: 0 additions & 33 deletions demo/src/ServerScriptService/systems/spawnMobs.luau

This file was deleted.

20 changes: 17 additions & 3 deletions demo/src/StarterPlayer/StarterPlayerScripts/systems/move.luau
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local blink = require(ReplicatedStorage.net)
local std = require(ReplicatedStorage.std)
local world = std.world
local ref = std.ref

local cts = std.components

Expand All @@ -19,7 +20,20 @@ local function move(dt: number)
end
end

local function syncTransforms()
for _, id, cf in blink.UpdateTransform.Iter() do
local e = ref("server-"..id)
local transform = e:get(cts.Transform)
if not transform then
continue
end
transform.new = cf
end
end

return function(scheduler: std.Scheduler)
return scheduler.systems.new(move,
scheduler.phases.RenderStepped)
local phases = scheduler.phases
local system_new = scheduler.systems.new
system_new(move, phases.Heartbeat)
system_new(syncTransforms, phases.RenderStepped)
end
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local function syncMobs()
end

return function(scheduler: std.Scheduler)
return scheduler.systems.new(syncMobs,
scheduler.phases.RenderStepped)
local phases = scheduler.phases
local system_new = scheduler.systems.new
system_new(syncMobs, phases.RenderStepped)
end

This file was deleted.

0 comments on commit 411138e

Please sign in to comment.