mirror of
https://github.com/Ukendio/jecs.git
synced 2025-06-20 00:09:18 +00:00
Merge system files
This commit is contained in:
parent
8c28cab792
commit
411138e1f7
7 changed files with 51 additions and 143 deletions
|
@ -1,76 +0,0 @@
|
||||||
{
|
|
||||||
"name": "demo",
|
|
||||||
"tree": {
|
|
||||||
"$className": "DataModel",
|
|
||||||
"ReplicatedStorage": {
|
|
||||||
"$className": "ReplicatedStorage",
|
|
||||||
"$path": "demo/src/ReplicatedStorage",
|
|
||||||
"ecs": {
|
|
||||||
"$path": "src"
|
|
||||||
},
|
|
||||||
"net": {
|
|
||||||
"$path": "demo/net/client.luau"
|
|
||||||
},
|
|
||||||
"Packages": {
|
|
||||||
"$path": "demo/Packages"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ServerScriptService": {
|
|
||||||
"$className": "ServerScriptService",
|
|
||||||
"$path": "demo/src/ServerScriptService",
|
|
||||||
"net": {
|
|
||||||
"$path": "demo/net/server.luau"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Workspace": {
|
|
||||||
"$properties": {
|
|
||||||
"FilteringEnabled": true
|
|
||||||
},
|
|
||||||
"Baseplate": {
|
|
||||||
"$className": "Part",
|
|
||||||
"$properties": {
|
|
||||||
"Anchored": true,
|
|
||||||
"Color": [
|
|
||||||
0.38823,
|
|
||||||
0.37254,
|
|
||||||
0.38823
|
|
||||||
],
|
|
||||||
"Locked": true,
|
|
||||||
"Position": [
|
|
||||||
0,
|
|
||||||
-10,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"Size": [
|
|
||||||
512,
|
|
||||||
20,
|
|
||||||
512
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Lighting": {
|
|
||||||
"$properties": {
|
|
||||||
"Ambient": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"Brightness": 2,
|
|
||||||
"GlobalShadows": true,
|
|
||||||
"Outlines": false,
|
|
||||||
"Technology": "Voxel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"SoundService": {
|
|
||||||
"$properties": {
|
|
||||||
"RespectFilteringEnabled": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"StarterPlayer": {
|
|
||||||
"StarterPlayerScripts": {
|
|
||||||
"$path": "demo/src/StarterPlayer/StarterPlayerScripts"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,6 +8,9 @@ local jecs = require(ReplicatedStorage.ecs)
|
||||||
local __ = jecs.Wildcard
|
local __ = jecs.Wildcard
|
||||||
|
|
||||||
local std = require(ReplicatedStorage.std)
|
local std = require(ReplicatedStorage.std)
|
||||||
|
local ref = std.ref
|
||||||
|
local interval = std.interval
|
||||||
|
|
||||||
local world: std.World = std.world
|
local world: std.World = std.world
|
||||||
local cts = std.components
|
local cts = std.components
|
||||||
|
|
||||||
|
@ -48,7 +51,28 @@ local function mobsMove(dt: number)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return function(scheduler: std.Scheduler)
|
local throttle = interval(5)
|
||||||
return scheduler.systems.new(mobsMove,
|
|
||||||
scheduler.phases.Heartbeat)
|
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)
|
||||||
|
local phases = scheduler.phases
|
||||||
|
local system_new = scheduler.systems.new
|
||||||
|
system_new(mobsMove, phases.Heartbeat)
|
||||||
|
system_new(spawnMobs, phases.Heartbeat)
|
||||||
|
|
||||||
end
|
end
|
|
@ -40,6 +40,7 @@ local function players()
|
||||||
end
|
end
|
||||||
|
|
||||||
return function(scheduler: std.Scheduler)
|
return function(scheduler: std.Scheduler)
|
||||||
return scheduler.systems.new(players,
|
local phases = scheduler.phases
|
||||||
scheduler.phases.Heartbeat)
|
local system_new = scheduler.systems.new
|
||||||
|
system_new(players, phases.Heartbeat)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
local std = require(game:GetService("ReplicatedStorage").std)
|
|
||||||
local blink = require(game:GetService("ServerScriptService").net)
|
|
||||||
|
|
||||||
local ref = std.ref
|
|
||||||
local interval = std.interval
|
|
||||||
local cts = std.components
|
|
||||||
|
|
||||||
local Mob = cts.Mob
|
|
||||||
local Transform = cts.Transform
|
|
||||||
local Velocity = cts.Velocity
|
|
||||||
|
|
||||||
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(spawnMobs,
|
|
||||||
scheduler.phases.Heartbeat)
|
|
||||||
end
|
|
|
@ -1,7 +1,8 @@
|
||||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local blink = require(ReplicatedStorage.net)
|
||||||
local std = require(ReplicatedStorage.std)
|
local std = require(ReplicatedStorage.std)
|
||||||
local world = std.world
|
local world = std.world
|
||||||
|
local ref = std.ref
|
||||||
|
|
||||||
local cts = std.components
|
local cts = std.components
|
||||||
|
|
||||||
|
@ -19,7 +20,20 @@ local function move(dt: number)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return function(scheduler: std.Scheduler)
|
local function syncTransforms()
|
||||||
return scheduler.systems.new(move,
|
for _, id, cf in blink.UpdateTransform.Iter() do
|
||||||
scheduler.phases.RenderStepped)
|
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)
|
||||||
|
local phases = scheduler.phases
|
||||||
|
local system_new = scheduler.systems.new
|
||||||
|
system_new(move, phases.Heartbeat)
|
||||||
|
system_new(syncTransforms, phases.RenderStepped)
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,7 @@ local function syncMobs()
|
||||||
end
|
end
|
||||||
|
|
||||||
return function(scheduler: std.Scheduler)
|
return function(scheduler: std.Scheduler)
|
||||||
return scheduler.systems.new(syncMobs,
|
local phases = scheduler.phases
|
||||||
scheduler.phases.RenderStepped)
|
local system_new = scheduler.systems.new
|
||||||
|
system_new(syncMobs, phases.RenderStepped)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
||||||
local blink = require(ReplicatedStorage.net)
|
|
||||||
local std = require(ReplicatedStorage.std)
|
|
||||||
local ref = std.ref
|
|
||||||
local world = std.world
|
|
||||||
|
|
||||||
local cts = std.components
|
|
||||||
|
|
||||||
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(syncTransforms,
|
|
||||||
scheduler.phases.RenderStepped)
|
|
||||||
end
|
|
Loading…
Reference in a new issue