An Agnostic Scheduler, inspired by Bevy Schedules and Flecs Pipelines and Phases.
Important
The Planck Scheduler and it's plugins are currently in development! This means that they are not uploaded to Wally just yet.
v0.1.0 of this library will release when Roblox TypeScript typings are added as well as a Plugin to support the Matter Debugger.
You can install Planck with Wally
[dependencies]
Planck = "yetanotherclown/[email protected]"
A Phase is just a tag you can assign to your systems, it's a way to order systems as a group.
local myPhase = Phase.new("debugName")
scheduler
:insert(myPhase, RunService, "Heartbeat")
:addSystems(systemA, myPhase)
A Pipeline is a group of ordered phases. Each phase will run in the fixed order to which each Phase was passed to it.
local myPipeline = Pipeline.new()
:insert(phaseA)
:insert(phaseB)
:insert(phaseC)
scheduler
:insert(myPipeline, RunService, "Heartbeat")
Systems on these phases will run exactly once, before any other phase runs.
- PreStartup
- Startup
- PostStartup
local Planck = require("@packages/Planck")
local Phase = Planck.Phase
local PreStartup = Phase.PreStartup
local Startup = Phase.Startup
local PostStartup = Phase.PostStartup
These Phases are ran on Engine RunService Events, events are ran in the order listed.
Event | Phase |
---|---|
PreRender | PreRender |
PreAnimation | PreAnimation |
PreSimulation | PreSimulation |
PostSimulation | PostSimulation |
Heartbeat | Update |
local Planck = require("@packages/Planck")
local Phase = Planck.Phase
local PreRender = Phase.PreRender
local PreAnimation = Phase.PreAnimation
local PreSimulation = Phase.PreSimulation
local PostSimulation = Phase.PostSimulation
local Update = Phase.Update
The Main Pipeline will run phases on the RunService.Heartbeat
event.
- First
- PreUpdate
- Update
- PostUpdate
- Last
local Planck = require("@packages/Planck")
local Phase = Planck.Phase
local First = Phase.First
local PreUpdate = Phase.PreUpdate
local Update = Phase.Update
local PostUpdate = Phase.PostUpdate
local Last = Phase.Last
A system is just a function, or it could be a system table.
local systemA = {
phase = myPhase,
system = function()
-- ...
end,
}
local function systemB()
-- ...
end
scheduler
:addSystems(systemA)
:addSystems(systemB, myPhase)
The Scheduler is where you initialize all your Pipelines, Phases, and Systems.
local Planck = require("@packages/Planck")
local Phase = Planck.Phase
local Pipeline = Planck.Pipeline
local Scheduler = Planck.Scheduler
local PreUpdate = Phase.new()
local Update = Phase.new()
local PostUpdate = Phase.new()
local UpdatePipeline = Pipeline.new()
:insert(PreUpdate)
:insert(Update)
:insert(PostUpdate)
local Render = Phase.new()
local scheduler = scheduler.new(world)
:insert(UpdatePipeline, RunService, "Heartbeat")
:insertAfter(Render, UpdatePipeline)
:addSystems(systems, Update)
scheduler:removeSystem(systemA)
scheduler:replaceSystem(systemA, systemB)
scheduler:editSystem(systemA, newPhase)
scheduler:editSystem(systemA)
scheduler:setRunCondition(systemA, function(world)
return someCondition and true or false
end)
The Planck Scheduler is pluggable, providing plugins to add support for Jabby and the Matter Hooks runtime.
You can learn more in the Plugin Docs.