@quenty/immediateutils 1.1.0 → 1.2.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/package.json +5 -4
  4. package/src/Shared/core/ImmediateCoreUtils.lua +56 -149
  5. package/src/Shared/core/ImmediateInstall.lua +79 -11
  6. package/src/Shared/middleware/Defer/ImmediateDeferInstall.lua +49 -0
  7. package/src/Shared/scheduler/ImmediateScheduler.lua +20 -11
  8. package/src/Client/ImmediateServiceClient.lua +0 -30
  9. package/src/Server/ImmediateService.lua +0 -25
  10. package/src/Shared/core/ImmediateCoreComponents.lua +0 -43
  11. package/src/Shared/core/ImmediateJecsUtils.lua +0 -249
  12. package/src/Shared/core/ImmediateTypes.lua +0 -79
  13. package/src/Shared/middleware/ImmediateBuffers/ImmediateBufferUtils.lua +0 -65
  14. package/src/Shared/middleware/ImmediateBuffers/ImmediateBuffersInstall.lua +0 -35
  15. package/src/Shared/middleware/ImmediateHooks/ImmediateCommonHooks.lua +0 -86
  16. package/src/Shared/middleware/ImmediateHooks/ImmediateHookAverageUtils.lua +0 -26
  17. package/src/Shared/middleware/ImmediateHooks/ImmediateHookSpringUtils.lua +0 -31
  18. package/src/Shared/middleware/ImmediateHooks/ImmediateHookUtils.lua +0 -214
  19. package/src/Shared/middleware/ImmediateHooks/ImmediateHooksInstall.lua +0 -46
  20. package/src/Shared/middleware/ImmediateHooks/commonhooks/async.lua +0 -30
  21. package/src/Shared/middleware/ImmediateHooks/commonhooks/cache.lua +0 -34
  22. package/src/Shared/middleware/ImmediateHooks/commonhooks/changed.lua +0 -39
  23. package/src/Shared/middleware/ImmediateHooks/commonhooks/conditionSustained.lua +0 -31
  24. package/src/Shared/middleware/ImmediateHooks/commonhooks/counter.lua +0 -19
  25. package/src/Shared/middleware/ImmediateHooks/commonhooks/delayed.lua +0 -31
  26. package/src/Shared/middleware/ImmediateHooks/commonhooks/delta.lua +0 -41
  27. package/src/Shared/middleware/ImmediateHooks/commonhooks/deltatime.lua +0 -32
  28. package/src/Shared/middleware/ImmediateHooks/commonhooks/difference.lua +0 -31
  29. package/src/Shared/middleware/ImmediateHooks/commonhooks/draw.lua +0 -17
  30. package/src/Shared/middleware/ImmediateHooks/commonhooks/entity.lua +0 -21
  31. package/src/Shared/middleware/ImmediateHooks/commonhooks/filterDescendants.lua +0 -62
  32. package/src/Shared/middleware/ImmediateHooks/commonhooks/findChild.lua +0 -36
  33. package/src/Shared/middleware/ImmediateHooks/commonhooks/gate.lua +0 -23
  34. package/src/Shared/middleware/ImmediateHooks/commonhooks/gatecounter.lua +0 -37
  35. package/src/Shared/middleware/ImmediateHooks/commonhooks/hookEntity.lua +0 -29
  36. package/src/Shared/middleware/ImmediateHooks/commonhooks/linearWalk.lua +0 -143
  37. package/src/Shared/middleware/ImmediateHooks/commonhooks/maid.lua +0 -25
  38. package/src/Shared/middleware/ImmediateHooks/commonhooks/noise.lua +0 -54
  39. package/src/Shared/middleware/ImmediateHooks/commonhooks/random.lua +0 -20
  40. package/src/Shared/middleware/ImmediateHooks/commonhooks/randomChoice.lua +0 -52
  41. package/src/Shared/middleware/ImmediateHooks/commonhooks/rtbuffer.lua +0 -28
  42. package/src/Shared/middleware/ImmediateHooks/commonhooks/scheduledValues.lua +0 -143
  43. package/src/Shared/middleware/ImmediateHooks/commonhooks/scheduler.lua +0 -191
  44. package/src/Shared/middleware/ImmediateHooks/commonhooks/sin.lua +0 -38
  45. package/src/Shared/middleware/ImmediateHooks/commonhooks/slidingAvg.lua +0 -78
  46. package/src/Shared/middleware/ImmediateHooks/commonhooks/spring.lua +0 -118
  47. package/src/Shared/middleware/ImmediateHooks/commonhooks/state.lua +0 -23
  48. package/src/Shared/middleware/ImmediateHooks/commonhooks/subscribe.lua +0 -47
  49. package/src/Shared/middleware/ImmediateHooks/commonhooks/throttle.lua +0 -37
  50. package/src/Shared/middleware/ImmediateHooks/commonhooks/tween.lua +0 -14
  51. package/src/Shared/middleware/ImmediateHooks/commonhooks/useBinder.lua +0 -54
  52. package/src/Shared/middleware/ImmediateHooks/commonhooks/useTieInterface.lua +0 -34
@@ -1,249 +0,0 @@
1
- --!nonstrict
2
- local require = require(script.Parent.loader).load(script)
3
-
4
- local ImmediateTypes = require("ImmediateTypes")
5
- local Jecst = require("Jecst")
6
- local Maid = require("Maid")
7
- local Observable = require("Observable")
8
-
9
- local ImmediateJecsUtils = {}
10
-
11
- function ImmediateJecsUtils.childOf(r, et)
12
- return r.jecs.pair(r.jecs.ChildOf, et)
13
- end
14
-
15
- function ImmediateJecsUtils.countQuery(query: Jecst.Query<any>): number
16
- local count = 0
17
- for _ in query do
18
- count += 1
19
- end
20
- return count
21
- end
22
-
23
- function ImmediateJecsUtils.firstOfQuery(query: Jecst.Query<any>): Jecst.Entity?
24
- for entity in query do
25
- return entity
26
- end
27
- return nil
28
- end
29
-
30
- function ImmediateJecsUtils.getMaid(r: ImmediateTypes.ImmediateRuntime, entity: Jecst.Entity): Maid.Maid?
31
- return r.world:get(entity, r.comps.Maid)
32
- end
33
-
34
- function ImmediateJecsUtils.getAMaid(r: ImmediateTypes.ImmediateRuntime, entity: Jecst.Entity): Maid.Maid?
35
- local directMaid = r.world:get(entity, r.comps.Maid)
36
- if directMaid then
37
- return directMaid
38
- end
39
- while true do
40
- local parent = r.world:parent(entity)
41
- if not parent then
42
- break
43
- end
44
- entity = parent
45
- local parentMaid = r.world:get(parent, r.comps.Maid)
46
- if parentMaid then
47
- return parentMaid
48
- end
49
- end
50
- return r.maid
51
- end
52
-
53
- export type RxECSQueuedEmitIterator = ({ any }, number?) -> (number?, any?)
54
-
55
- function ImmediateJecsUtils.drainQueuedSnapshot(snapshot: { any }, index: number?): (number?, any?)
56
- local nextIndex = (index or 0) + 1
57
- local value = snapshot[nextIndex]
58
- if value == nil then
59
- return nil
60
- end
61
- return nextIndex, unpack(value)
62
- end
63
-
64
- export type RxECSObservableCollector = {
65
- Drain: () -> (RxECSQueuedEmitIterator, { any }, number),
66
- Last: () -> ...any,
67
- Destroy: () -> (),
68
- }
69
-
70
- function ImmediateJecsUtils.collectObservable(
71
- observable: Observable.Observable<any>,
72
- maid: Maid.Maid?
73
- ): RxECSObservableCollector
74
- local queueOfEmits = {}
75
- local lastEmit = nil
76
- local collectorMaid = Maid.new()
77
- collectorMaid:GiveTask(observable:Subscribe(function(...)
78
- table.insert(queueOfEmits, table.pack(...))
79
- lastEmit = table.pack(...)
80
- end))
81
- collectorMaid:GiveTask(function()
82
- table.clear(queueOfEmits)
83
- lastEmit = nil
84
- end)
85
- if maid then
86
- maid:GiveTask(collectorMaid)
87
- end
88
- return {
89
- Drain = function()
90
- local snapshot = queueOfEmits
91
- queueOfEmits = {}
92
- return ImmediateJecsUtils.drainQueuedSnapshot, snapshot, 0
93
- end,
94
- Last = function()
95
- if lastEmit == nil then
96
- return nil
97
- end
98
- return unpack(lastEmit)
99
- end,
100
- Destroy = function()
101
- collectorMaid:DoCleaning()
102
- end,
103
- }
104
- end
105
-
106
- -- loop for changed for a component, but use in a loop over many entities.
107
- -- use like:
108
- -- for entity, chrec in hooks.subscribe(observeComponentOnChanged(r, component)) do
109
- -- and this would loop over all entities who got the component.
110
- -- but only this component. use chrec.removed to see if it's actually removed or if the
111
- -- component was simply a tag without data.
112
- function ImmediateJecsUtils.observeComponentOnChanged(
113
- r: ImmediateTypes.ImmediateRuntime,
114
- component: Jecst.Id<any>
115
- ): Observable.Observable<
116
- Jecst.Entity,
117
- { curr: any?, removed: boolean }
118
- >
119
- assert(component, `Component not found`)
120
- return Observable.new(function(sub)
121
- local maid = Maid.new()
122
- maid:GiveTask(ImmediateJecsUtils.addAddCallback(r, component, function(_entity, _id, data)
123
- sub:Fire(_entity, { curr = data, removed = false })
124
- end))
125
- maid:GiveTask(ImmediateJecsUtils.addChangeCallback(r, component, function(_entity, _id, data)
126
- sub:Fire(_entity, { curr = data, removed = false })
127
- end))
128
- maid:GiveTask(ImmediateJecsUtils.addRemoveCallback(r, component, function(_entity, _id, _data)
129
- sub:Fire(_entity, { curr = nil, removed = true })
130
- end))
131
- for entity, data in r.world:query(component) do
132
- sub:Fire(entity, { curr = data, removed = false })
133
- end
134
- return maid
135
- end)
136
- end
137
-
138
- function ImmediateJecsUtils.observeComponentData(
139
- r: ImmediateTypes.ImmediateRuntime,
140
- entity: Jecst.Entity,
141
- component: Jecst.Id<any>
142
- ): Observable.Observable<any>
143
- assert(entity, `Entity not found for component: {component}`)
144
- assert(component, `Component not found for entity: {entity}`)
145
- return Observable.new(function(sub)
146
- local maid = Maid.new()
147
- maid:GiveTask(ImmediateJecsUtils.addAddCallback(r, component, function(_entity, _id, data)
148
- if _entity ~= entity then
149
- return
150
- end
151
- sub:Fire(data)
152
- end))
153
- maid:GiveTask(ImmediateJecsUtils.addChangeCallback(r, component, function(_entity, _id, data)
154
- if _entity ~= entity then
155
- return
156
- end
157
- sub:Fire(data)
158
- end))
159
- local data = r.world:get(entity, component)
160
- if data then
161
- sub:Fire(data)
162
- end
163
- return maid
164
- end)
165
- end
166
-
167
- function ImmediateJecsUtils.addChangeCallback(
168
- r: ImmediateTypes.ImmediateRuntime,
169
- component: Jecst.Id<any>,
170
- callback: (entity: Jecst.Entity, id: number, data: any) -> (),
171
- key: any?
172
- )
173
- local changeCallbacks = r.world:get(component, r.comps._ChangeCallbacks)
174
- assert(changeCallbacks, `Change callbacks not found for component: {component}`)
175
- assert(changeCallbacks.callbacks, `Change callbacks not found for component: {component}`)
176
- assert(changeCallbacks._counter, `Change callbacks counter not found for component: {component}`)
177
-
178
- if not key then
179
- key = changeCallbacks._counter
180
- changeCallbacks._counter += 1
181
- end
182
- changeCallbacks.callbacks[key] = callback
183
-
184
- return function()
185
- changeCallbacks.callbacks[key] = nil
186
- end
187
- end
188
-
189
- function ImmediateJecsUtils.addAddCallback(
190
- r: ImmediateTypes.ImmediateRuntime,
191
- component: Jecst.Id<any>,
192
- callback: (entity: Jecst.Entity, id: number, data: any) -> (),
193
- key: any?
194
- )
195
- local addCallbacks = r.world:get(component, r.comps._AddCallbacks)
196
- assert(addCallbacks, `Add callbacks not found for component: {component}`)
197
- assert(addCallbacks.callbacks, `Add callbacks not found for component: {component}`)
198
- assert(addCallbacks._counter ~= nil, `Add callbacks counter not found for component: {component}`)
199
-
200
- if not key then
201
- key = addCallbacks._counter
202
- addCallbacks._counter += 1
203
- end
204
- addCallbacks.callbacks[key] = callback
205
-
206
- return function()
207
- addCallbacks.callbacks[key] = nil
208
- end
209
- end
210
-
211
- function ImmediateJecsUtils.addRemoveCallback(
212
- r: ImmediateTypes.ImmediateRuntime,
213
- component: Jecst.Id<any>,
214
- callback: (entity: Jecst.Entity, id: number, delete: boolean?) -> (),
215
- key: any?
216
- )
217
- local removeCallbacks = r.world:get(component, r.comps._RemoveCallbacks)
218
- assert(removeCallbacks, `Remove callbacks not found for component: {component}`)
219
- assert(removeCallbacks.callbacks, `Remove callbacks not found for component: {component}`)
220
- assert(removeCallbacks._counter ~= nil, `Remove callbacks counter not found for component: {component}`)
221
-
222
- if not key then
223
- key = removeCallbacks._counter
224
- removeCallbacks._counter += 1
225
- end
226
- removeCallbacks.callbacks[key] = callback
227
-
228
- return function()
229
- removeCallbacks.callbacks[key] = nil
230
- end
231
- end
232
-
233
- function ImmediateJecsUtils.patch(
234
- rt: ImmediateTypes.ImmediateRuntime,
235
- et: Jecst.Entity,
236
- comp: Jecst.Id<any>,
237
- partialData: { any }
238
- )
239
- local data = rt.world:get(et, comp)
240
- if not data then
241
- return
242
- end
243
- for key, value in partialData do
244
- data[key] = value
245
- end
246
- rt.world:set(et, comp, data)
247
- end
248
-
249
- return ImmediateJecsUtils
@@ -1,79 +0,0 @@
1
- --!strict
2
- --[=[
3
- @class ImmediateSystem
4
- ]=]
5
- local require = require(script.Parent.loader).load(script)
6
-
7
- local ImmediateCoreComponents = require("ImmediateCoreComponents")
8
- local Jecst = require("Jecst")
9
- local Maid = require("Maid")
10
- local ServiceBag = require("ServiceBag")
11
-
12
- local ImmediateTypes = {}
13
-
14
- -- A component dictionary is a dictionary of component ids; however, their definition requires side effects to be applied to the world.
15
- -- The side effect is registering themselves to the world with their type.
16
- -- Because of their side effects, these are usually returned by the _applyAndReturnComponentDictionary function of a component info table.
17
- export type JecsComponentDictionary = { [string]: Jecst.Id<any> } & typeof(ImmediateCoreComponents({} :: Jecst.World))
18
-
19
- -- A component info table is a table (commonly returned by modules) containing a common function to apply and return a component dictionary.
20
- -- You would make your own modules that expose this as a function, like SomeProjectHere._applyAndReturnComponentDictionary
21
- -- Within it, you'd define what components (what data shapes) you'd like to use with jecs state.
22
- -- The components would be registered as valid Jecs components during runtime,
23
- -- but here we can also expose the returned components statically.
24
- export type JecsComponentDictionaryInjector = (world: Jecst.World) -> JecsComponentDictionary
25
-
26
- -- An ImmediateRuntime is centered around one Jecst world.
27
- -- It can be made synchronously/immediately.
28
- -- This is the core that *all* ImmediateRuntimes must have, and only that much.
29
- -- Your specific game or plugin can define its own "runtime-type", adding more fields onto this runtime
30
- -- table if necessary.
31
- export type ImmediateRuntime<CustomComponentDictionaries = {}, CustomBlackboardType = {}> = {
32
- -- A flag to enable debug mode, where you can run slower but correct checks.
33
- DEBUG: boolean,
34
-
35
- -- The backbone of any immediate runtime. (Thanks jecs!)
36
- jecs: Jecst.jecs,
37
- world: Jecst.World,
38
- comps: JecsComponentDictionary & CustomComponentDictionaries,
39
-
40
- -- A single maid that cleans up the entire runtime.
41
- maid: Maid.Maid,
42
-
43
- -- In case this is running inside a plugin.
44
- plugin: Plugin?,
45
-
46
- -- Nevermore/Raven portal.
47
- serviceBag: ServiceBag.ServiceBag,
48
-
49
- -- A raw require portal sometimes necessary for hooks that rely on the same require().
50
- -- (to escape complications with hot reloading)
51
- require: (path: string) -> any,
52
-
53
- -- The blackboard can be used to store any kind of state for all systems.
54
- -- Here, you won't have to worry about key-collision with the runtime table's root level.
55
- -- This is *only* CustomBlackboardType: `{ [any]: any } & B` makes Luau drop B's keys
56
- -- (every lookup is already `any`), so `localPlayer` would not show up.
57
- blackboard: CustomBlackboardType,
58
-
59
- errorlog: {
60
- lastErrorShout: number,
61
- },
62
-
63
- -- Scheduler cursors (set while a system/middleware runs; cleared after the frame).
64
- -- Gameplay-only neighbors (middleware skipped):
65
- previousSystem: any?,
66
- -- nextSystem: any?,
67
-
68
- -- Immediately adjacent invocations in the full schedule (includes middleware):
69
- previousRawSystem: any?,
70
- -- nextRawSystem: any?,
71
-
72
- -- clean up (maids can thus add this runtime table, and cleanup the entire runtime)
73
- Destroy: () -> (),
74
-
75
- -- allow new fields for hook addons to live in
76
- [any]: any,
77
- }
78
-
79
- return ImmediateTypes
@@ -1,65 +0,0 @@
1
- --!nonstrict
2
- --[=[
3
- @class ImmediateBufferUtils
4
-
5
- Optional runtime extension: deferred callback and entity-delete queues on
6
- `rt.buffers`. Install onto a bare ImmediateRuntime; drain after every
7
- gameplay system so a callback error cannot leave the live queues uncleared.
8
- ]=]
9
- local require = require(script.Parent.loader).load(script)
10
-
11
- local ImmediateTypes = require("ImmediateTypes")
12
- local Jecst = require("Jecst")
13
-
14
- export type Buffers = {
15
- callbacks: { () -> () },
16
- delete: { Jecst.Entity },
17
- }
18
-
19
- export type ImmediateBuffersAddon = {
20
- buffers: Buffers,
21
- }
22
-
23
- export type ImmediateRuntimeWithBuffers<C = {}, B = {}> = ImmediateTypes.ImmediateRuntime<C, B> & ImmediateBuffersAddon
24
-
25
- local ImmediateBufferUtils = {}
26
-
27
- function ImmediateBufferUtils.install<Rt>(rt: Rt): Rt & ImmediateBuffersAddon
28
- local runtime = rt :: Rt & ImmediateBuffersAddon
29
- if runtime.buffers == nil then
30
- runtime.buffers = {
31
- callbacks = {},
32
- delete = {},
33
- }
34
- end
35
- return runtime
36
- end
37
-
38
- function ImmediateBufferUtils.deferCallback(rt: ImmediateRuntimeWithBuffers, callback: () -> ())
39
- table.insert(rt.buffers.callbacks, callback)
40
- end
41
-
42
- function ImmediateBufferUtils.deferDelete(rt: ImmediateRuntimeWithBuffers, entity: Jecst.Entity)
43
- table.insert(rt.buffers.delete, entity)
44
- end
45
-
46
- function ImmediateBufferUtils.flush(rt: ImmediateRuntimeWithBuffers)
47
- -- Snapshot-and-clear first so a callback error cannot leave the live
48
- -- buffers uncleared and double-fire next postSystem.
49
- local callbacks = rt.buffers.callbacks
50
- local toDelete = rt.buffers.delete
51
- rt.buffers.callbacks = {}
52
- rt.buffers.delete = {}
53
-
54
- for _, callback in ipairs(callbacks) do
55
- callback()
56
- end
57
-
58
- for _, et in ipairs(toDelete) do
59
- if rt.world:contains(et) then
60
- rt.world:delete(et)
61
- end
62
- end
63
- end
64
-
65
- return ImmediateBufferUtils
@@ -1,35 +0,0 @@
1
- --!nonstrict
2
- --[=[
3
- @class ImmediateBuffersInstall
4
-
5
- Runtime decorator: adds rt.buffers, and optionally registers scheduler
6
- middleware to drain those queues after each gameplay system.
7
- ]=]
8
- local require = require(script.Parent.loader).load(script)
9
-
10
- local ImmediateBufferUtils = require("ImmediateBufferUtils")
11
- local ImmediateScheduler = require("ImmediateScheduler")
12
-
13
- local DEFAULT_PRIORITY = 100
14
-
15
- return function<Rt>(
16
- rt: Rt,
17
- scheduler: ImmediateScheduler.ImmediateScheduler?
18
- ): Rt & ImmediateBufferUtils.ImmediateBuffersAddon
19
- local runtime = ImmediateBufferUtils.install(rt)
20
-
21
- if scheduler then
22
- scheduler:RegisterSystem({
23
- name = "mw_immediate_buffers_flush",
24
- postSystem = true,
25
- priority = DEFAULT_PRIORITY,
26
- notProtected = false,
27
- system = function(r)
28
- ImmediateBufferUtils.flush(r)
29
- end,
30
- Destroy = function() end,
31
- })
32
- end
33
-
34
- return runtime
35
- end
@@ -1,86 +0,0 @@
1
- --!nonstrict
2
- --[=[
3
- @class ImmediateCommonHooks
4
-
5
- Assembles the built-in hook factories under middleware/ImmediateHooks/commonhooks.
6
- You should only have to call install() on your runtime.
7
- ]=]
8
-
9
- local rawrequire = require
10
- local require = require(script.Parent.loader).load(script)
11
-
12
- local ImmediateHookUtils = require("ImmediateHookUtils")
13
- local ImmediateTypes = require("ImmediateTypes")
14
-
15
- local ImmediateCommonHooks = {}
16
-
17
- --[[
18
-
19
- As of now, there's no way to magically gather the types of modules underneath a folder
20
- so we're just manually requiring them here.
21
- If a new hook is added to commonhooks, it'll need to be added here too.
22
- The pattern for any new custom hooks you'd use would to be to return a dictionary,
23
- with [hookName] = hookFunctionFactory(rt), which will give you a function that's aware of the
24
- runtime state.
25
-
26
- ]]
27
-
28
- function ImmediateCommonHooks._createHookCallbacks(rt: ImmediateTypes.ImmediateRuntime)
29
- local hooksFolder = script.Parent.commonhooks
30
- local hooks = {
31
- async = rawrequire(hooksFolder.async)(rt),
32
- cache = rawrequire(hooksFolder.cache)(rt),
33
- changed = rawrequire(hooksFolder.changed)(rt),
34
- conditionSustained = rawrequire(hooksFolder.conditionSustained)(rt),
35
- counter = rawrequire(hooksFolder.counter)(rt),
36
- delayed = rawrequire(hooksFolder.delayed)(rt),
37
- delta = rawrequire(hooksFolder.delta)(rt),
38
- deltatime = rawrequire(hooksFolder.deltatime)(rt),
39
- difference = rawrequire(hooksFolder.difference)(rt),
40
- draw = rawrequire(hooksFolder.draw)(rt),
41
- entity = rawrequire(hooksFolder.entity)(rt),
42
- filterDescendants = rawrequire(hooksFolder.filterDescendants)(rt),
43
- findChild = rawrequire(hooksFolder.findChild)(rt),
44
- gate = rawrequire(hooksFolder.gate)(rt),
45
- gatecounter = rawrequire(hooksFolder.gatecounter)(rt),
46
- hookEntity = rawrequire(hooksFolder.hookEntity)(rt),
47
- linearWalk = rawrequire(hooksFolder.linearWalk)(rt),
48
- maid = rawrequire(hooksFolder.maid)(rt),
49
- noise = rawrequire(hooksFolder.noise)(rt),
50
- random = rawrequire(hooksFolder.random)(rt),
51
- randomChoice = rawrequire(hooksFolder.randomChoice)(rt),
52
- rtbuffer = rawrequire(hooksFolder.rtbuffer)(rt),
53
- scheduledValues = rawrequire(hooksFolder.scheduledValues)(rt),
54
- scheduler = rawrequire(hooksFolder.scheduler)(rt),
55
- sin = rawrequire(hooksFolder.sin)(rt),
56
- slidingAvg = rawrequire(hooksFolder.slidingAvg)(rt),
57
- spring = rawrequire(hooksFolder.spring)(rt),
58
- state = rawrequire(hooksFolder.state)(rt),
59
- subscribe = rawrequire(hooksFolder.subscribe)(rt),
60
- throttle = rawrequire(hooksFolder.throttle)(rt),
61
- tween = rawrequire(hooksFolder.tween)(rt),
62
- useBinder = rawrequire(hooksFolder.useBinder)(rt),
63
- useTieInterface = rawrequire(hooksFolder.useTieInterface)(rt),
64
- }
65
- return hooks
66
- end
67
-
68
- export type ImmediateHookCallbacks = typeof(ImmediateCommonHooks._createHookCallbacks(
69
- {} :: ImmediateTypes.ImmediateRuntime
70
- ))
71
-
72
- export type ImmediateHooksAddon = ImmediateHookUtils.ImmediateHookBookAddon & {
73
- hooks: ImmediateHookCallbacks,
74
- }
75
-
76
- export type ImmediateRuntimeWithHooks<C = {}, B = {}> = ImmediateTypes.ImmediateRuntime<C, B> & ImmediateHooksAddon
77
-
78
- function ImmediateCommonHooks.install<Rt>(rt: Rt): Rt & ImmediateHooksAddon
79
- local runtime = ImmediateHookUtils.install(rt) :: Rt & ImmediateHooksAddon
80
- if runtime.hooks == nil then
81
- runtime.hooks = ImmediateCommonHooks._createHookCallbacks(runtime)
82
- end
83
- return runtime
84
- end
85
-
86
- return ImmediateCommonHooks
@@ -1,26 +0,0 @@
1
- --!strict
2
- --[=[
3
- @class ImmediateHookAverageUtils
4
- ]=]
5
- local ImmediateHookAverageUtils = {}
6
-
7
- export type AverageableValue = number | Vector3 | Vector2
8
-
9
- function ImmediateHookAverageUtils.zeroSum(sample: AverageableValue): AverageableValue
10
- local sampleType = typeof(sample)
11
- if sampleType == "Vector3" then
12
- return Vector3.zero
13
- elseif sampleType == "Vector2" then
14
- return Vector2.zero
15
- end
16
- return 0
17
- end
18
-
19
- function ImmediateHookAverageUtils.quotient(sum: AverageableValue, count: number): AverageableValue
20
- if count <= 0 then
21
- return sum
22
- end
23
- return (sum :: any) / count
24
- end
25
-
26
- return ImmediateHookAverageUtils
@@ -1,31 +0,0 @@
1
- --!strict
2
- --[=[
3
- @class ImmediateHookSpringUtils
4
- ]=]
5
- local ImmediateHookSpringUtils = {}
6
-
7
- function ImmediateHookSpringUtils.internalValue(value: any): any
8
- if typeof(value) == "Color3" then
9
- return Vector3.new(value.R, value.G, value.B)
10
- end
11
- return value
12
- end
13
-
14
- function ImmediateHookSpringUtils.externalValue(internal: any, asColor3: boolean): any
15
- if asColor3 and typeof(internal) == "Vector3" then
16
- return Color3.new(math.clamp(internal.X, 0, 1), math.clamp(internal.Y, 0, 1), math.clamp(internal.Z, 0, 1))
17
- end
18
- return internal
19
- end
20
-
21
- function ImmediateHookSpringUtils.usesColor3(goal: any?, value: any?): boolean
22
- if goal ~= nil then
23
- return typeof(goal) == "Color3"
24
- end
25
- if value ~= nil then
26
- return typeof(value) == "Color3"
27
- end
28
- return false
29
- end
30
-
31
- return ImmediateHookSpringUtils