@rbxts/planck 0.1.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/Phase.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Phase } from "./types";
2
+
3
+ export = Phase;
package/out/Phase.luau ADDED
@@ -0,0 +1,89 @@
1
+ --- @class Phase
2
+ ---
3
+ --- Phases represent tags that tell the scheduler when to
4
+ --- schedule a set of systems.
5
+ local Phase = {}
6
+ Phase.__index = Phase
7
+
8
+ function Phase:__tostring()
9
+ return self._name
10
+ end
11
+
12
+ --- @within Phase
13
+ ---
14
+ --- Creates a new Phase, with an optional name to use for debugging.
15
+ --- When no name is provided, the script and line number will be used.
16
+ function Phase.new(name: string?)
17
+ name = name or debug.info(2, "sl")
18
+ return setmetatable({
19
+ _name = name,
20
+ _type = "phase",
21
+ }, Phase)
22
+ end
23
+
24
+ --- @prop PreStartup Phase
25
+ --- @within Phase
26
+ --- Runs before the `Startup` Phase.
27
+
28
+ --- @prop Startup Phase
29
+ --- @within Phase
30
+ --- This Phase will run once, the first time the Scheduler is ran,
31
+ --- before any other Phases are ran.
32
+
33
+ --- @prop PostStartup Phase
34
+ --- @within Phase
35
+ --- Runs after the `Startup` phase.
36
+
37
+ Phase.PreStartup = Phase.new("PreStartup")
38
+ Phase.Startup = Phase.new("Startup")
39
+ Phase.PostStartup = Phase.new("PostStartup")
40
+
41
+ --- @prop PreRender Phase
42
+ --- @within Phase
43
+ --- Runs on the `RunService.PreRender` Event.
44
+
45
+ --- @prop PreAnimation Phase
46
+ --- @within Phase
47
+ --- Runs on the `RunService.PreAnimation` Event.
48
+
49
+ --- @prop PreSimulation Phase
50
+ --- @within Phase
51
+ --- Runs on the `RunService.PreSimulation` Event.
52
+
53
+ --- @prop PostSimulation Phase
54
+ --- @within Phase
55
+ --- Runs on the `RunService.PostSimulation` Event.
56
+
57
+ Phase.PreRender = Phase.new("PreRender")
58
+ Phase.PreAnimation = Phase.new("PreAnimation")
59
+ Phase.PreSimulation = Phase.new("PreSimulation")
60
+ Phase.PostSimulation = Phase.new("PostSimulation")
61
+
62
+ --- @prop First Phase
63
+ --- @within Phase
64
+ --- Will always run first on the `RunService.Heartbeat` Event.
65
+
66
+ --- @prop PreUpdate Phase
67
+ --- @within Phase
68
+ --- Runs before the `Update` Phase.
69
+
70
+ --- @prop Update Phase
71
+ --- @within Phase
72
+ --- Runs on the `RunService.Heartbeat` Event.
73
+ --- This is the default Phase systems will run on.
74
+
75
+ --- @prop PostUpdate Phase
76
+ --- @within Phase
77
+ --- Runs after the `Update` Phase.
78
+
79
+ --- @prop Last Phase
80
+ --- @within Phase
81
+ --- Will always run last on the `RunService.Heartbeat` Event.
82
+
83
+ Phase.First = Phase.new("First")
84
+ Phase.PreUpdate = Phase.new("PreUpdate")
85
+ Phase.Update = Phase.new("Update")
86
+ Phase.PostUpdate = Phase.new("PostUpdate")
87
+ Phase.Last = Phase.new("Last")
88
+
89
+ return Phase
@@ -0,0 +1,4 @@
1
+ import { Pipeline } from "./types";
2
+
3
+
4
+ export = Pipeline;
@@ -0,0 +1,74 @@
1
+ local Phase = require(script.Parent:WaitForChild('Phase'))
2
+ --- @class Pipeline
3
+ ---
4
+ --- Pipelines represent a set of ordered Phases. Systems cannot be
5
+ --- assigned to Pipelines themselves, but rather to Phases within
6
+ --- those Pipelines.
7
+
8
+ local Pipeline = {}
9
+ Pipeline.__index = Pipeline
10
+
11
+ function Pipeline:__tostring()
12
+ return self._name
13
+ end
14
+
15
+ --- @method insert
16
+ --- @within Pipeline
17
+ --- @param phase Phase
18
+ --- @return Pipeline
19
+ ---
20
+ --- Adds a Phase to the Pipeline, ordering it implicitly.
21
+ function Pipeline:insert(phase)
22
+ table.insert(self._phases, phase)
23
+ return self
24
+ end
25
+
26
+ --- @method insert
27
+ --- @within Pipeline
28
+ --- @param phase Phase
29
+ --- @param after Phase
30
+ --- @return Pipeline
31
+ ---
32
+ --- Adds a Phase to the Pipeline after another Phase, ordering it explicitly.
33
+ function Pipeline:insertAfter(phase, otherPhase)
34
+ local i = table.find(self._phases, phase)
35
+ assert(i, "Phase not initialized in Pipeline")
36
+
37
+ table.insert(self._phases, i + 1, otherPhase)
38
+ return self
39
+ end
40
+
41
+ --- @within Pipeline
42
+ ---
43
+ --- Creates a new Pipeline, with an optional name to use for debugging.
44
+ --- When no name is provided, the script and line number will be used.
45
+ function Pipeline.new(name: string?)
46
+ name = name or debug.info(2, "sl")
47
+ return setmetatable({
48
+ _name = name,
49
+ _type = "pipeline",
50
+ _phases = {},
51
+ }, Pipeline)
52
+ end
53
+
54
+ --- @prop Startup Pipeline
55
+ --- @within Pipeline
56
+ ---
57
+ --- A Pipeline containing the `PreStartup`, `Startup`, and `PostStartup` phases.
58
+ Pipeline.Startup = Pipeline.new()
59
+ :insert(Phase.PreStartup)
60
+ :insert(Phase.Startup)
61
+ :insert(Phase.PostStartup)
62
+
63
+ --- @prop Main Pipeline
64
+ --- @within Pipeline
65
+ ---
66
+ --- A Pipeline containing the `First`, `PreUpdate`, `Update`, `PostUpdate`, and `Last` phases.
67
+ Pipeline.Main = Pipeline.new()
68
+ :insert(Phase.First)
69
+ :insert(Phase.PreUpdate)
70
+ :insert(Phase.Update)
71
+ :insert(Phase.PostUpdate)
72
+ :insert(Phase.Last)
73
+
74
+ return Pipeline
@@ -0,0 +1,3 @@
1
+ import { Scheduler } from "./types";
2
+
3
+ export = Scheduler;