@quenty/immediateutils 1.1.0 → 1.3.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.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/package.json +14 -13
- package/src/Shared/core/ImmediateCoreUtils.lua +56 -149
- package/src/Shared/core/ImmediateInstall.lua +79 -11
- package/src/Shared/middleware/Defer/ImmediateDeferInstall.lua +49 -0
- package/src/Shared/scheduler/ImmediateScheduler.lua +20 -11
- package/src/Client/ImmediateServiceClient.lua +0 -30
- package/src/Server/ImmediateService.lua +0 -25
- package/src/Shared/core/ImmediateCoreComponents.lua +0 -43
- package/src/Shared/core/ImmediateJecsUtils.lua +0 -249
- package/src/Shared/core/ImmediateTypes.lua +0 -79
- package/src/Shared/middleware/ImmediateBuffers/ImmediateBufferUtils.lua +0 -65
- package/src/Shared/middleware/ImmediateBuffers/ImmediateBuffersInstall.lua +0 -35
- package/src/Shared/middleware/ImmediateHooks/ImmediateCommonHooks.lua +0 -86
- package/src/Shared/middleware/ImmediateHooks/ImmediateHookAverageUtils.lua +0 -26
- package/src/Shared/middleware/ImmediateHooks/ImmediateHookSpringUtils.lua +0 -31
- package/src/Shared/middleware/ImmediateHooks/ImmediateHookUtils.lua +0 -214
- package/src/Shared/middleware/ImmediateHooks/ImmediateHooksInstall.lua +0 -46
- package/src/Shared/middleware/ImmediateHooks/commonhooks/async.lua +0 -30
- package/src/Shared/middleware/ImmediateHooks/commonhooks/cache.lua +0 -34
- package/src/Shared/middleware/ImmediateHooks/commonhooks/changed.lua +0 -39
- package/src/Shared/middleware/ImmediateHooks/commonhooks/conditionSustained.lua +0 -31
- package/src/Shared/middleware/ImmediateHooks/commonhooks/counter.lua +0 -19
- package/src/Shared/middleware/ImmediateHooks/commonhooks/delayed.lua +0 -31
- package/src/Shared/middleware/ImmediateHooks/commonhooks/delta.lua +0 -41
- package/src/Shared/middleware/ImmediateHooks/commonhooks/deltatime.lua +0 -32
- package/src/Shared/middleware/ImmediateHooks/commonhooks/difference.lua +0 -31
- package/src/Shared/middleware/ImmediateHooks/commonhooks/draw.lua +0 -17
- package/src/Shared/middleware/ImmediateHooks/commonhooks/entity.lua +0 -21
- package/src/Shared/middleware/ImmediateHooks/commonhooks/filterDescendants.lua +0 -62
- package/src/Shared/middleware/ImmediateHooks/commonhooks/findChild.lua +0 -36
- package/src/Shared/middleware/ImmediateHooks/commonhooks/gate.lua +0 -23
- package/src/Shared/middleware/ImmediateHooks/commonhooks/gatecounter.lua +0 -37
- package/src/Shared/middleware/ImmediateHooks/commonhooks/hookEntity.lua +0 -29
- package/src/Shared/middleware/ImmediateHooks/commonhooks/linearWalk.lua +0 -143
- package/src/Shared/middleware/ImmediateHooks/commonhooks/maid.lua +0 -25
- package/src/Shared/middleware/ImmediateHooks/commonhooks/noise.lua +0 -54
- package/src/Shared/middleware/ImmediateHooks/commonhooks/random.lua +0 -20
- package/src/Shared/middleware/ImmediateHooks/commonhooks/randomChoice.lua +0 -52
- package/src/Shared/middleware/ImmediateHooks/commonhooks/rtbuffer.lua +0 -28
- package/src/Shared/middleware/ImmediateHooks/commonhooks/scheduledValues.lua +0 -143
- package/src/Shared/middleware/ImmediateHooks/commonhooks/scheduler.lua +0 -191
- package/src/Shared/middleware/ImmediateHooks/commonhooks/sin.lua +0 -38
- package/src/Shared/middleware/ImmediateHooks/commonhooks/slidingAvg.lua +0 -78
- package/src/Shared/middleware/ImmediateHooks/commonhooks/spring.lua +0 -118
- package/src/Shared/middleware/ImmediateHooks/commonhooks/state.lua +0 -23
- package/src/Shared/middleware/ImmediateHooks/commonhooks/subscribe.lua +0 -47
- package/src/Shared/middleware/ImmediateHooks/commonhooks/throttle.lua +0 -37
- package/src/Shared/middleware/ImmediateHooks/commonhooks/tween.lua +0 -14
- package/src/Shared/middleware/ImmediateHooks/commonhooks/useBinder.lua +0 -54
- package/src/Shared/middleware/ImmediateHooks/commonhooks/useTieInterface.lua +0 -34
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class scheduler
|
|
4
|
-
|
|
5
|
-
When called, will progress a timeline.
|
|
6
|
-
Will call provided callbacks based on defined timestamps every time this is called
|
|
7
|
-
(meant to be a per-tick basis).
|
|
8
|
-
Callbacks the one that is last timestamp before it.
|
|
9
|
-
Each callback is called with the current overall time elapsed since init,
|
|
10
|
-
and time elapsed in current stage.
|
|
11
|
-
Returns current overall time.
|
|
12
|
-
|
|
13
|
-
Set stage.hold = true from a callback to hold (pin) that stage. The scheduler
|
|
14
|
-
keeps invoking it every tick and will not advance until a tick where hold is
|
|
15
|
-
not requested. Returning false also holds at runtime, but stage.hold avoids
|
|
16
|
-
Luau unifying mixed callback return types in a numeric table literal.
|
|
17
|
-
The clock keeps running while held; absolute key times may drift. Prefer
|
|
18
|
-
forceInOrder when holds may overrun later keys so unvisited stages catch up.
|
|
19
|
-
|
|
20
|
-
phases: {
|
|
21
|
-
[0] = init()
|
|
22
|
-
[0.1] = something()
|
|
23
|
-
[1.0] = something()
|
|
24
|
-
[2.0] = cleanupfunc()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
Returns scheduler state.
|
|
28
|
-
]=]
|
|
29
|
-
|
|
30
|
-
local require = require(script.Parent.loader).load(script)
|
|
31
|
-
|
|
32
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
33
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
34
|
-
|
|
35
|
-
export type SchedulerState = {
|
|
36
|
-
lastCalledAt: number,
|
|
37
|
-
currentOverallTime: number,
|
|
38
|
-
currentStageTime: number,
|
|
39
|
-
currentStageDuration: number?,
|
|
40
|
-
currentStageAlpha: number,
|
|
41
|
-
currentCallback: (() -> ...any) | nil,
|
|
42
|
-
currentTimeKey: number | nil,
|
|
43
|
-
isHeld: boolean,
|
|
44
|
-
hold: boolean,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
48
|
-
return function(
|
|
49
|
-
phases: {
|
|
50
|
-
[number]: ((SchedulerState) -> ...any) | nil,
|
|
51
|
-
},
|
|
52
|
-
dis: any?,
|
|
53
|
-
-- forceInOrder: if true, will force the scheduler
|
|
54
|
-
-- to call callbacks in order of time keys even if
|
|
55
|
-
-- current time already elapsed (will call in a sequence at least once.)
|
|
56
|
-
forceInOrder: boolean?
|
|
57
|
-
): {
|
|
58
|
-
lastCalledAt: number,
|
|
59
|
-
currentOverallTime: number,
|
|
60
|
-
currentStageTime: number,
|
|
61
|
-
currentStageDuration: number?,
|
|
62
|
-
currentStageAlpha: number,
|
|
63
|
-
currentCallback: (() -> ...any) | nil,
|
|
64
|
-
currentTimeKey: number | nil,
|
|
65
|
-
isHeld: boolean,
|
|
66
|
-
}
|
|
67
|
-
local _hookState, _hookMaid = getOrCreateHookState(rt, dis)
|
|
68
|
-
local currClock = os.clock()
|
|
69
|
-
|
|
70
|
-
if not _hookState._init then
|
|
71
|
-
_hookState._init = true
|
|
72
|
-
_hookState._sortedTimeKeys = {}
|
|
73
|
-
_hookState._timeKeysVisited = {}
|
|
74
|
-
_hookState._heldTimeKey = nil
|
|
75
|
-
_hookState.lastCalledAt = currClock
|
|
76
|
-
_hookState.currentOverallTime = 0
|
|
77
|
-
_hookState.currentStageTime = 0
|
|
78
|
-
_hookState.currentStageDuration = nil
|
|
79
|
-
_hookState.currentStageAlpha = 0
|
|
80
|
-
_hookState.currentCallback = nil
|
|
81
|
-
_hookState.currentTimeKey = nil
|
|
82
|
-
_hookState.hold = false
|
|
83
|
-
|
|
84
|
-
for timestamp, _callback in phases do
|
|
85
|
-
table.insert(_hookState._sortedTimeKeys, timestamp)
|
|
86
|
-
_hookState._timeKeysVisited[timestamp] = false
|
|
87
|
-
end
|
|
88
|
-
table.sort(_hookState._sortedTimeKeys)
|
|
89
|
-
|
|
90
|
-
_hookMaid:GiveTask(function()
|
|
91
|
-
table.clear(_hookState)
|
|
92
|
-
end)
|
|
93
|
-
_hookState.evaluateCurrentTimeKey = function()
|
|
94
|
-
if _hookState._heldTimeKey ~= nil then
|
|
95
|
-
return _hookState._heldTimeKey
|
|
96
|
-
end
|
|
97
|
-
-- From earliest to latest
|
|
98
|
-
for i, timeKey in _hookState._sortedTimeKeys do
|
|
99
|
-
if _hookState._forceInOrder then
|
|
100
|
-
local weArePastIt = _hookState.currentOverallTime >= timeKey
|
|
101
|
-
local weHaventExecutedBefore = not _hookState._timeKeysVisited[timeKey]
|
|
102
|
-
if weArePastIt and weHaventExecutedBefore then
|
|
103
|
-
return timeKey
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
if _hookState.currentOverallTime < timeKey then
|
|
107
|
-
local prevTimeKey = _hookState._sortedTimeKeys[i - 1]
|
|
108
|
-
if prevTimeKey then
|
|
109
|
-
return prevTimeKey
|
|
110
|
-
else
|
|
111
|
-
return nil
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
-- If we've gone through all the time keys and didn't find one,
|
|
116
|
-
-- return the last time key since we're past all of them.
|
|
117
|
-
return _hookState._sortedTimeKeys[#_hookState._sortedTimeKeys]
|
|
118
|
-
end
|
|
119
|
-
_hookState.evaluateCurrentStageDuration = function()
|
|
120
|
-
local currentTimeKey = _hookState.currentTimeKey
|
|
121
|
-
if currentTimeKey == nil then
|
|
122
|
-
return nil
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
local sortedTimeKeys = _hookState._sortedTimeKeys
|
|
126
|
-
local currentIndex = table.find(sortedTimeKeys, currentTimeKey)
|
|
127
|
-
local nextTimeKey = currentIndex and sortedTimeKeys[currentIndex + 1]
|
|
128
|
-
if nextTimeKey == nil then
|
|
129
|
-
return nil
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
local duration = nextTimeKey - currentTimeKey
|
|
133
|
-
if duration <= 0 then
|
|
134
|
-
return nil
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
return duration
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
_hookState._forceInOrder = forceInOrder == true
|
|
142
|
-
|
|
143
|
-
local timeSinceLastCall = currClock - _hookState.lastCalledAt
|
|
144
|
-
_hookState.currentOverallTime += timeSinceLastCall
|
|
145
|
-
_hookState.currentStageTime += timeSinceLastCall
|
|
146
|
-
_hookState.lastCalledAt = currClock
|
|
147
|
-
local timeKey = _hookState.evaluateCurrentTimeKey()
|
|
148
|
-
if timeKey then
|
|
149
|
-
if _hookState.currentTimeKey ~= timeKey then
|
|
150
|
-
_hookState.currentStageTime = 0
|
|
151
|
-
end
|
|
152
|
-
_hookState.currentTimeKey = timeKey
|
|
153
|
-
_hookState.currentStageDuration = _hookState.evaluateCurrentStageDuration()
|
|
154
|
-
if _hookState.currentStageDuration then
|
|
155
|
-
_hookState.currentStageAlpha =
|
|
156
|
-
math.clamp(_hookState.currentStageTime / _hookState.currentStageDuration, 0, 1)
|
|
157
|
-
else
|
|
158
|
-
_hookState.currentStageAlpha = 1
|
|
159
|
-
end
|
|
160
|
-
local callback = phases[timeKey]
|
|
161
|
-
_hookState.currentCallback = callback
|
|
162
|
-
_hookState._timeKeysVisited[timeKey] = true
|
|
163
|
-
if callback then
|
|
164
|
-
_hookState.hold = false
|
|
165
|
-
local result: any = callback(_hookState)
|
|
166
|
-
if result == false or _hookState.hold then
|
|
167
|
-
_hookState._heldTimeKey = timeKey
|
|
168
|
-
else
|
|
169
|
-
_hookState._heldTimeKey = nil
|
|
170
|
-
end
|
|
171
|
-
else
|
|
172
|
-
_hookState._heldTimeKey = nil
|
|
173
|
-
end
|
|
174
|
-
else
|
|
175
|
-
_hookState.currentStageDuration = nil
|
|
176
|
-
_hookState.currentStageAlpha = 0
|
|
177
|
-
_hookState._heldTimeKey = nil
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
lastCalledAt = _hookState.lastCalledAt,
|
|
182
|
-
currentOverallTime = _hookState.currentOverallTime,
|
|
183
|
-
currentStageTime = _hookState.currentStageTime,
|
|
184
|
-
currentStageDuration = _hookState.currentStageDuration,
|
|
185
|
-
currentStageAlpha = _hookState.currentStageAlpha,
|
|
186
|
-
currentCallback = _hookState.currentCallback,
|
|
187
|
-
currentTimeKey = _hookState.currentTimeKey,
|
|
188
|
-
isHeld = _hookState._heldTimeKey ~= nil,
|
|
189
|
-
}
|
|
190
|
-
end
|
|
191
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class sin
|
|
4
|
-
|
|
5
|
-
Oscillating sine in [min, max] (default 0..1).
|
|
6
|
-
frequency = cycles per second (default 1).
|
|
7
|
-
Same signature as noise; phase is integrated so mid-flight freq changes stay continuous.
|
|
8
|
-
]=]
|
|
9
|
-
|
|
10
|
-
local require = require(script.Parent.loader).load(script)
|
|
11
|
-
|
|
12
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
13
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
14
|
-
|
|
15
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
16
|
-
return function(dis: any?, min: number?, max: number?, frequency: number?, startPhase: number?): number
|
|
17
|
-
local hookState, _hookMaid = getOrCreateHookState(rt, dis)
|
|
18
|
-
|
|
19
|
-
local lo = if min ~= nil then min else 0
|
|
20
|
-
local hi = if max ~= nil then max else 1
|
|
21
|
-
local freq = if frequency ~= nil then frequency else 1
|
|
22
|
-
|
|
23
|
-
local now = os.clock() + (startPhase or 0)
|
|
24
|
-
if not hookState.sinInit then
|
|
25
|
-
hookState.sinInit = true
|
|
26
|
-
-- Random phase so sibling sins don't all sync.
|
|
27
|
-
hookState.sinPhase = Random.new():NextNumber(0, 1)
|
|
28
|
-
hookState.sinLastClock = now
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
local dt = now - hookState.sinLastClock
|
|
32
|
-
hookState.sinLastClock = now
|
|
33
|
-
hookState.sinPhase += math.max(dt, 0) * freq
|
|
34
|
-
|
|
35
|
-
local u = (math.sin(hookState.sinPhase * math.pi * 2) + 1) * 0.5
|
|
36
|
-
return lo + (hi - lo) * u
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class slidingAvg
|
|
4
|
-
|
|
5
|
-
If you call this hook with a constantly updating number or vector,
|
|
6
|
-
it will return the average of the last windowSize values.
|
|
7
|
-
Optionally, pass in a boolean/condition flag to determine if you actually
|
|
8
|
-
want to add it to the sliding average.
|
|
9
|
-
(You can put a throttle hook in that flag argument.)
|
|
10
|
-
|
|
11
|
-
This also returns callbacks to add values outside of calling
|
|
12
|
-
this hook, like manually populating the values queue or clearing it.
|
|
13
|
-
|
|
14
|
-
Pass fillBufferWithFirstValue to seed the window with the first sample (warm start).
|
|
15
|
-
]=]
|
|
16
|
-
|
|
17
|
-
local require = require(script.Parent.loader).load(script)
|
|
18
|
-
|
|
19
|
-
local ImmediateHookAverageUtils = require("ImmediateHookAverageUtils")
|
|
20
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
21
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
22
|
-
|
|
23
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
24
|
-
return function(
|
|
25
|
-
dis: any?,
|
|
26
|
-
value: ImmediateHookAverageUtils.AverageableValue,
|
|
27
|
-
windowSize: number,
|
|
28
|
-
conditionToInclude: boolean?,
|
|
29
|
-
fillBufferWithFirstValue: boolean?
|
|
30
|
-
)
|
|
31
|
-
assert(windowSize >= 1, "slidingAvg windowSize must be >= 1")
|
|
32
|
-
|
|
33
|
-
local hookState, _hookMaid = getOrCreateHookState(rt, dis)
|
|
34
|
-
if not hookState.init then
|
|
35
|
-
hookState.init = true
|
|
36
|
-
hookState.windowSize = windowSize
|
|
37
|
-
hookState.buffer = table.create(windowSize)
|
|
38
|
-
hookState.head = 1
|
|
39
|
-
hookState.count = 0
|
|
40
|
-
hookState.sum = ImmediateHookAverageUtils.zeroSum(value)
|
|
41
|
-
hookState.zeroSum = hookState.sum
|
|
42
|
-
hookState.push = function(pushValue: ImmediateHookAverageUtils.AverageableValue)
|
|
43
|
-
local capacity = hookState.windowSize
|
|
44
|
-
local i = hookState.head
|
|
45
|
-
local old = hookState.buffer[i]
|
|
46
|
-
hookState.buffer[i] = pushValue
|
|
47
|
-
hookState.head = (i % capacity) + 1
|
|
48
|
-
if hookState.count < capacity then
|
|
49
|
-
hookState.count += 1
|
|
50
|
-
hookState.sum += pushValue
|
|
51
|
-
else
|
|
52
|
-
hookState.sum += pushValue - old
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
hookState.clear = function()
|
|
56
|
-
table.clear(hookState.buffer)
|
|
57
|
-
hookState.head = 1
|
|
58
|
-
hookState.count = 0
|
|
59
|
-
hookState.sum = hookState.zeroSum
|
|
60
|
-
end
|
|
61
|
-
if fillBufferWithFirstValue then
|
|
62
|
-
for _ = 1, windowSize do
|
|
63
|
-
hookState.push(value)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
if conditionToInclude ~= nil then
|
|
69
|
-
if conditionToInclude == true then
|
|
70
|
-
hookState.push(value)
|
|
71
|
-
end
|
|
72
|
-
else
|
|
73
|
-
hookState.push(value)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
return ImmediateHookAverageUtils.quotient(hookState.sum, hookState.count), hookState.push, hookState.clear
|
|
77
|
-
end
|
|
78
|
-
end
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class spring
|
|
4
|
-
|
|
5
|
-
Springs a number / Vector2 / Vector3 / Color3, or a CFrame.
|
|
6
|
-
|
|
7
|
-
CFrame uses three Vector3 springs (position, look, up) and returns
|
|
8
|
-
`(CFrame, nil)` — there is no single Spring object for that path.
|
|
9
|
-
]=]
|
|
10
|
-
|
|
11
|
-
local require = require(script.Parent.loader).load(script)
|
|
12
|
-
|
|
13
|
-
local ImmediateHookSpringUtils = require("ImmediateHookSpringUtils")
|
|
14
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
15
|
-
local Spring = require("Spring")
|
|
16
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
17
|
-
|
|
18
|
-
local function usesCFrame(goal: any?, value: any?): boolean
|
|
19
|
-
if goal ~= nil then
|
|
20
|
-
return typeof(goal) == "CFrame"
|
|
21
|
-
end
|
|
22
|
-
if value ~= nil then
|
|
23
|
-
return typeof(value) == "CFrame"
|
|
24
|
-
end
|
|
25
|
-
return false
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
29
|
-
return function(dis: any?, goal: any?, value: any?, speed: number?, damping: number?): (any, Spring.Spring<any>?)
|
|
30
|
-
local hookState, _hookMaid = getOrCreateHookState(rt, dis)
|
|
31
|
-
|
|
32
|
-
if hookState.springIsCFrame == nil then
|
|
33
|
-
hookState.springIsCFrame = usesCFrame(goal, value)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
if hookState.springIsCFrame then
|
|
37
|
-
if not hookState.springPos then
|
|
38
|
-
local finalStartCF = value
|
|
39
|
-
if not finalStartCF then
|
|
40
|
-
finalStartCF = goal
|
|
41
|
-
end
|
|
42
|
-
if not finalStartCF then
|
|
43
|
-
finalStartCF = CFrame.new()
|
|
44
|
-
end
|
|
45
|
-
hookState.springPos = Spring.new(finalStartCF.Position)
|
|
46
|
-
hookState.springPos.Position = finalStartCF.Position
|
|
47
|
-
hookState.springPos.Speed = speed or 10
|
|
48
|
-
hookState.springPos.Damper = damping or 1
|
|
49
|
-
hookState.springLookAlong = Spring.new(finalStartCF.LookVector)
|
|
50
|
-
hookState.springLookAlong.Position = finalStartCF.LookVector
|
|
51
|
-
hookState.springLookAlong.Speed = speed or 10
|
|
52
|
-
hookState.springLookAlong.Damper = damping or 1
|
|
53
|
-
hookState.springUpVector = Spring.new(finalStartCF.UpVector)
|
|
54
|
-
hookState.springUpVector.Position = finalStartCF.UpVector
|
|
55
|
-
hookState.springUpVector.Speed = speed or 10
|
|
56
|
-
hookState.springUpVector.Damper = damping or 1
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
if speed then
|
|
60
|
-
hookState.springPos.Speed = speed
|
|
61
|
-
hookState.springLookAlong.Speed = speed
|
|
62
|
-
hookState.springUpVector.Speed = speed
|
|
63
|
-
end
|
|
64
|
-
if damping then
|
|
65
|
-
hookState.springPos.Damper = damping
|
|
66
|
-
hookState.springLookAlong.Damper = damping
|
|
67
|
-
hookState.springUpVector.Damper = damping
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
if goal ~= nil then
|
|
71
|
-
hookState.springPos.Target = goal.Position
|
|
72
|
-
hookState.springLookAlong.Target = goal.LookVector
|
|
73
|
-
hookState.springUpVector.Target = goal.UpVector
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
hookState.finalCFrame = CFrame.lookAlong(
|
|
77
|
-
hookState.springPos.Position,
|
|
78
|
-
hookState.springLookAlong.Position,
|
|
79
|
-
hookState.springUpVector.Position
|
|
80
|
-
)
|
|
81
|
-
return hookState.finalCFrame, nil
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
if hookState.springIsColor3 == nil then
|
|
85
|
-
hookState.springIsColor3 = ImmediateHookSpringUtils.usesColor3(goal, value)
|
|
86
|
-
end
|
|
87
|
-
local isColor3 = hookState.springIsColor3
|
|
88
|
-
|
|
89
|
-
if not hookState.spring then
|
|
90
|
-
local initialSource = value
|
|
91
|
-
if initialSource == nil then
|
|
92
|
-
initialSource = goal
|
|
93
|
-
end
|
|
94
|
-
if initialSource == nil then
|
|
95
|
-
initialSource = if isColor3 then Vector3.zero else 0
|
|
96
|
-
end
|
|
97
|
-
local initial = ImmediateHookSpringUtils.internalValue(initialSource)
|
|
98
|
-
hookState.spring = Spring.new(initial)
|
|
99
|
-
hookState.spring.Speed = speed or 10
|
|
100
|
-
hookState.spring.Damper = damping or 1
|
|
101
|
-
hookState.spring.Position = initial
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
if speed then
|
|
105
|
-
hookState.spring.Speed = speed
|
|
106
|
-
end
|
|
107
|
-
if damping then
|
|
108
|
-
hookState.spring.Damper = damping
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
if goal ~= nil then
|
|
112
|
-
hookState.spring.Target = ImmediateHookSpringUtils.internalValue(goal)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
local position = ImmediateHookSpringUtils.externalValue(hookState.spring.Position, isColor3)
|
|
116
|
-
return position, hookState.spring
|
|
117
|
-
end
|
|
118
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class state
|
|
4
|
-
]=]
|
|
5
|
-
|
|
6
|
-
local require = require(script.Parent.loader).load(script)
|
|
7
|
-
|
|
8
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
9
|
-
local Maid = require("Maid")
|
|
10
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
11
|
-
|
|
12
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
13
|
-
return function(dis: any?, initFunction: ({ any? }, Maid.Maid) -> ...any?)
|
|
14
|
-
local hookState, hookMaid = getOrCreateHookState(rt, dis)
|
|
15
|
-
if hookState._init == nil then
|
|
16
|
-
hookState._init = true
|
|
17
|
-
if initFunction then
|
|
18
|
-
initFunction(hookState, hookMaid)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
return hookState, hookMaid
|
|
22
|
-
end
|
|
23
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class subscribe
|
|
4
|
-
]=]
|
|
5
|
-
|
|
6
|
-
local require = require(script.Parent.loader).load(script)
|
|
7
|
-
|
|
8
|
-
local ImmediateJecsUtils = require("ImmediateJecsUtils")
|
|
9
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
10
|
-
local Observable = require("Observable")
|
|
11
|
-
local Rx = require("Rx")
|
|
12
|
-
local Signal = require("Signal")
|
|
13
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
14
|
-
|
|
15
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
16
|
-
return function(
|
|
17
|
-
subscribable: Observable.Observable<any> | Signal.Signal<any>,
|
|
18
|
-
dis: any?,
|
|
19
|
-
returnLastEmittedOnly: boolean?
|
|
20
|
-
)
|
|
21
|
-
local function toObservable(source: Observable.Observable<any> | Signal.Signal<any>): Observable.Observable<any>
|
|
22
|
-
if typeof(source) == "RBXScriptSignal" or Signal.isSignal(source) then
|
|
23
|
-
return Rx.fromSignal(source :: Signal.Signal<any>)
|
|
24
|
-
end
|
|
25
|
-
if Observable.isObservable(source) then
|
|
26
|
-
return source :: Observable.Observable<any>
|
|
27
|
-
end
|
|
28
|
-
-- RemotingMember and other Connect()-able tables
|
|
29
|
-
return Rx.fromSignal(source :: Signal.Signal<any>)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
local hookState, hookMaid = getOrCreateHookState(rt, dis)
|
|
33
|
-
|
|
34
|
-
if hookState.collector == nil then
|
|
35
|
-
hookState.collector =
|
|
36
|
-
hookMaid:Add(ImmediateJecsUtils.collectObservable(toObservable(subscribable), hookMaid))
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
local collector = hookState.collector
|
|
40
|
-
assert(collector, "subscribe hook collector missing")
|
|
41
|
-
|
|
42
|
-
if returnLastEmittedOnly then
|
|
43
|
-
return collector.Last()
|
|
44
|
-
end
|
|
45
|
-
return collector.Drain()
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class throttle
|
|
4
|
-
|
|
5
|
-
Returns true if the last call was more than `seconds` ago.
|
|
6
|
-
]=]
|
|
7
|
-
|
|
8
|
-
local require = require(script.Parent.loader).load(script)
|
|
9
|
-
|
|
10
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
11
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
12
|
-
|
|
13
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
14
|
-
return function(seconds: number, dis: any?, delayOnFirstCall: boolean?)
|
|
15
|
-
local hookState, _hookMaid = getOrCreateHookState(rt, dis, function(_state)
|
|
16
|
-
-- only allow cleanup once the throttle window has already expired,
|
|
17
|
-
-- so a recreated state firing immediately matches what the old state would do
|
|
18
|
-
return _state.lastRanAtClock == nil or (os.clock() - _state.lastRanAtClock) >= (_state.seconds or 0)
|
|
19
|
-
end)
|
|
20
|
-
hookState.seconds = seconds
|
|
21
|
-
|
|
22
|
-
local now = os.clock()
|
|
23
|
-
local lastRanAtClock = hookState.lastRanAtClock
|
|
24
|
-
|
|
25
|
-
if lastRanAtClock == nil then
|
|
26
|
-
hookState.lastRanAtClock = now
|
|
27
|
-
return not delayOnFirstCall
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
if now - lastRanAtClock >= seconds then
|
|
31
|
-
hookState.lastRanAtClock = now
|
|
32
|
-
return true
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
return false
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
--!strict
|
|
2
|
-
--[=[
|
|
3
|
-
@class tween
|
|
4
|
-
|
|
5
|
-
Advances by last time called by default.
|
|
6
|
-
]=]
|
|
7
|
-
|
|
8
|
-
local require = require(script.Parent.loader).load(script)
|
|
9
|
-
|
|
10
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
11
|
-
|
|
12
|
-
return function(_rt: ImmediateTypes.ImmediateRuntime)
|
|
13
|
-
return function(_dis: any?, _start: any?, _goal: any?, _duration: number?) end
|
|
14
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class useBinder
|
|
4
|
-
]=]
|
|
5
|
-
|
|
6
|
-
local require = require(script.Parent.loader).load(script)
|
|
7
|
-
|
|
8
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
9
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
10
|
-
|
|
11
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
12
|
-
return function(dis, instance: Instance, binderTag: string, debug: boolean?)
|
|
13
|
-
local hookState, hookMaid = getOrCreateHookState(rt, dis)
|
|
14
|
-
|
|
15
|
-
if hookState.boundObject ~= nil then
|
|
16
|
-
return hookState.boundObject
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
if hookState.pendingPromise ~= nil then
|
|
20
|
-
if debug then
|
|
21
|
-
warn(`Pending promise for {binderTag} exists...`)
|
|
22
|
-
end
|
|
23
|
-
return nil
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
local binder = rt.serviceBag:GetService(rt.require(binderTag))
|
|
27
|
-
if not binder then
|
|
28
|
-
warn(`No binder found for tag {binderTag}`)
|
|
29
|
-
return nil
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
if not hookState.startedBinderPromise then
|
|
33
|
-
if debug then
|
|
34
|
-
warn(`Starting promise for {binderTag}`)
|
|
35
|
-
end
|
|
36
|
-
hookState.startedBinderPromise = true
|
|
37
|
-
hookMaid:GivePromise(binder
|
|
38
|
-
:Promise(instance)
|
|
39
|
-
:Then(function(boundObject)
|
|
40
|
-
if debug then
|
|
41
|
-
warn(`Bound object for {binderTag}!`)
|
|
42
|
-
end
|
|
43
|
-
hookState.boundObject = boundObject
|
|
44
|
-
end)
|
|
45
|
-
:Catch(function(err)
|
|
46
|
-
warn(`Failed to start binder promise for {binderTag}`, err)
|
|
47
|
-
hookState.boundObject = nil
|
|
48
|
-
end))
|
|
49
|
-
return binder:Get(instance)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
return nil
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
--!nonstrict
|
|
2
|
-
--[=[
|
|
3
|
-
@class useTieInterface
|
|
4
|
-
|
|
5
|
-
Returns the latest tie interface. Uses brio to cleanup itself.
|
|
6
|
-
]=]
|
|
7
|
-
|
|
8
|
-
local require = require(script.Parent.loader).load(script)
|
|
9
|
-
|
|
10
|
-
local ImmediateTypes = require("ImmediateTypes")
|
|
11
|
-
local TieRealms = require("TieRealms")
|
|
12
|
-
local getOrCreateHookState = require("ImmediateHookUtils").getOrCreateHookState
|
|
13
|
-
|
|
14
|
-
return function(rt: ImmediateTypes.ImmediateRuntime)
|
|
15
|
-
return function(dis, instance: Instance, tieInterfaceName: string, realm: TieRealms.TieRealm?)
|
|
16
|
-
local hookState, hookMaid = getOrCreateHookState(rt, dis)
|
|
17
|
-
if hookState.observingBrio == nil then
|
|
18
|
-
-- listens and always updates the current interface
|
|
19
|
-
local tieInterface = rt.require(tieInterfaceName)
|
|
20
|
-
if realm then
|
|
21
|
-
tieInterface = tieInterface[realm]
|
|
22
|
-
end
|
|
23
|
-
hookState.observingBrio = hookMaid:GiveTask(tieInterface:ObserveBrio(instance):Subscribe(function(brio)
|
|
24
|
-
if brio:IsDead() then
|
|
25
|
-
hookState.currentInterface = nil
|
|
26
|
-
return
|
|
27
|
-
end
|
|
28
|
-
local _maid, interface = brio:ToMaidAndValue()
|
|
29
|
-
hookState.currentInterface = interface
|
|
30
|
-
end))
|
|
31
|
-
end
|
|
32
|
-
return hookState.currentInterface
|
|
33
|
-
end
|
|
34
|
-
end
|