@quenty/animations 1.2.1-canary.402.5852ffd.0 → 1.2.1-canary.402.a911cda.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
CHANGED
|
@@ -3,9 +3,21 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [1.2.1-canary.402.
|
|
6
|
+
## [1.2.1-canary.402.a911cda.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@1.2.0...@quenty/animations@1.2.1-canary.402.a911cda.0) (2023-08-23)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add missing dependency ([42ac596](https://github.com/Quenty/NevermoreEngine/commit/42ac5964e2154311070278732bf61b2b6b6982ce))
|
|
12
|
+
* Rename HoarcekatRigAnimator ([87ff244](https://github.com/Quenty/NevermoreEngine/commit/87ff244c1ef964a496fd71c08e9a4f3fb195a2b7))
|
|
13
|
+
* Track weight will only adjust if we get a track ([e885fce](https://github.com/Quenty/NevermoreEngine/commit/e885fced59555520dce0ed0a21f95157ba45f14d))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* Add AnimationSlotPlayer.new(animationTarget) ([86f1e99](https://github.com/Quenty/NevermoreEngine/commit/86f1e9989d4c52b136078a9c4c34c205e2e88549))
|
|
19
|
+
* Add AnimationTrackPlayer.new(animationTarget, animationId) ([7b254c2](https://github.com/Quenty/NevermoreEngine/commit/7b254c2870b8ed930c33081df84944925702d10a))
|
|
20
|
+
* Add studio rig animator ([9a6578b](https://github.com/Quenty/NevermoreEngine/commit/9a6578bfd712728b179ce40096f1ee7c581c112f))
|
|
9
21
|
|
|
10
22
|
|
|
11
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/animations",
|
|
3
|
-
"version": "1.2.1-canary.402.
|
|
3
|
+
"version": "1.2.1-canary.402.a911cda.0",
|
|
4
4
|
"description": "Utility methods for playing back animations on Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,14 +25,19 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@quenty/baseobject": "6.2.2-canary.402.a911cda.0",
|
|
28
29
|
"@quenty/enumutils": "3.1.0",
|
|
29
30
|
"@quenty/humanoidanimatorutils": "2.2.0",
|
|
30
|
-
"@quenty/loader": "6.2.2-canary.402.
|
|
31
|
-
"@quenty/
|
|
32
|
-
"@quenty/
|
|
31
|
+
"@quenty/loader": "6.2.2-canary.402.a911cda.0",
|
|
32
|
+
"@quenty/maid": "2.5.1-canary.402.a911cda.0",
|
|
33
|
+
"@quenty/promisemaid": "1.2.1-canary.402.a911cda.0",
|
|
34
|
+
"@quenty/rbxasset": "1.1.1-canary.402.a911cda.0",
|
|
35
|
+
"@quenty/rx": "7.14.1-canary.402.a911cda.0",
|
|
36
|
+
"@quenty/signal": "2.4.0",
|
|
37
|
+
"@quenty/valueobject": "7.21.1-canary.402.a911cda.0"
|
|
33
38
|
},
|
|
34
39
|
"publishConfig": {
|
|
35
40
|
"access": "public"
|
|
36
41
|
},
|
|
37
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "a911cdaf4f1039b599528cec17b027f4660e4fd8"
|
|
38
43
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class AnimationSlotPlayer
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local BaseObject = require("BaseObject")
|
|
8
|
+
local AnimationUtils = require("AnimationUtils")
|
|
9
|
+
local ValueObject = require("ValueObject")
|
|
10
|
+
local Maid = require("Maid")
|
|
11
|
+
local EnumUtils = require("EnumUtils")
|
|
12
|
+
|
|
13
|
+
local AnimationSlotPlayer = setmetatable({}, BaseObject)
|
|
14
|
+
AnimationSlotPlayer.ClassName = "AnimationSlotPlayer"
|
|
15
|
+
AnimationSlotPlayer.__index = AnimationSlotPlayer
|
|
16
|
+
|
|
17
|
+
function AnimationSlotPlayer.new(animationTarget)
|
|
18
|
+
local self = setmetatable(BaseObject.new(), AnimationSlotPlayer)
|
|
19
|
+
|
|
20
|
+
self._animationTarget = ValueObject.new(nil)
|
|
21
|
+
self._maid:GiveTask(self._animationTarget)
|
|
22
|
+
|
|
23
|
+
self._defaultFadeTime = ValueObject.new(0.1, "number")
|
|
24
|
+
self._maid:GiveTask(self._defaultFadeTime)
|
|
25
|
+
|
|
26
|
+
self._defaultAnimationPriority = ValueObject.new(nil)
|
|
27
|
+
self._maid:GiveTask(self._defaultAnimationPriority)
|
|
28
|
+
|
|
29
|
+
if animationTarget then
|
|
30
|
+
self:SetAnimationTarget(animationTarget)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
return self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
function AnimationSlotPlayer:SetDefaultFadeTime(defaultFadeTime)
|
|
37
|
+
self._defaultFadeTime.Value = defaultFadeTime
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
function AnimationSlotPlayer:SetDefaultAnimationPriority(defaultAnimationPriority)
|
|
41
|
+
assert(EnumUtils.isOfType(Enum.AnimationPriority, defaultAnimationPriority) or defaultAnimationPriority == nil, "Bad defaultAnimationPriority")
|
|
42
|
+
|
|
43
|
+
self._defaultAnimationPriority.Value = defaultAnimationPriority
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
function AnimationSlotPlayer:SetAnimationTarget(animationTarget)
|
|
47
|
+
self._animationTarget:Mount(animationTarget)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
function AnimationSlotPlayer:Play(id, fadeTime, weight, speed, priority)
|
|
51
|
+
fadeTime = fadeTime or self._defaultFadeTime.Value
|
|
52
|
+
priority = priority or self._defaultAnimationPriority.Value
|
|
53
|
+
weight = weight or 1 -- We need to explicitly adjust the weight here
|
|
54
|
+
|
|
55
|
+
local topMaid = Maid.new()
|
|
56
|
+
|
|
57
|
+
topMaid:GiveTask(self._animationTarget:ObserveBrio(function(target)
|
|
58
|
+
return target ~= nil
|
|
59
|
+
end):Subscribe(function(brio)
|
|
60
|
+
if brio:IsDead() then
|
|
61
|
+
return
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
local animationTarget = brio:GetValue()
|
|
65
|
+
local maid = brio:ToMaid()
|
|
66
|
+
|
|
67
|
+
local track = AnimationUtils.playAnimation(animationTarget, id, fadeTime, weight, speed, priority)
|
|
68
|
+
if track then
|
|
69
|
+
maid:GiveTask(function()
|
|
70
|
+
track:AdjustWeight(0, fadeTime or self._defaultFadeTime.Value)
|
|
71
|
+
end)
|
|
72
|
+
else
|
|
73
|
+
warn("[AnimationSlotPlayer] - Failed to get animation to play")
|
|
74
|
+
end
|
|
75
|
+
end))
|
|
76
|
+
|
|
77
|
+
self._maid._current = topMaid
|
|
78
|
+
|
|
79
|
+
return function()
|
|
80
|
+
if self._maid._current == topMaid then
|
|
81
|
+
self._maid._current = nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
function AnimationSlotPlayer:Stop()
|
|
87
|
+
self._maid._current = nil
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
return AnimationSlotPlayer
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class AnimationTrackPlayer
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local BaseObject = require("BaseObject")
|
|
8
|
+
local ValueObject = require("ValueObject")
|
|
9
|
+
local Rx = require("Rx")
|
|
10
|
+
local AnimationUtils = require("AnimationUtils")
|
|
11
|
+
local Signal = require("Signal")
|
|
12
|
+
|
|
13
|
+
local AnimationTrackPlayer = setmetatable({}, BaseObject)
|
|
14
|
+
AnimationTrackPlayer.ClassName = "AnimationTrackPlayer"
|
|
15
|
+
AnimationTrackPlayer.__index = AnimationTrackPlayer
|
|
16
|
+
|
|
17
|
+
function AnimationTrackPlayer.new(animationTarget, animationId)
|
|
18
|
+
local self = setmetatable(BaseObject.new(), AnimationTrackPlayer)
|
|
19
|
+
|
|
20
|
+
self._animationTarget = ValueObject.new(nil)
|
|
21
|
+
self._maid:GiveTask(self._animationTarget)
|
|
22
|
+
|
|
23
|
+
self._trackId = ValueObject.new(nil)
|
|
24
|
+
self._maid:GiveTask(self._trackId)
|
|
25
|
+
|
|
26
|
+
self._currentTrack = ValueObject.new(nil)
|
|
27
|
+
self._maid:GiveTask(self._currentTrack)
|
|
28
|
+
|
|
29
|
+
self.KeyframeReached = Signal.new()
|
|
30
|
+
self._maid:GiveTask(self.KeyframeReached)
|
|
31
|
+
|
|
32
|
+
self._animationPriority = ValueObject.new(nil)
|
|
33
|
+
self._maid:GiveTask(self._animationPriority)
|
|
34
|
+
|
|
35
|
+
if animationTarget then
|
|
36
|
+
self:SetAnimationTarget(animationTarget)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if animationId then
|
|
40
|
+
self:SetAnimationId(animationId)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
self:_setupState()
|
|
44
|
+
|
|
45
|
+
return self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
function AnimationTrackPlayer:_setupState()
|
|
49
|
+
self._maid:GiveTask(Rx.combineLatest({
|
|
50
|
+
animationTarget = self._animationTarget:Observe();
|
|
51
|
+
trackId = self._trackId:Observe();
|
|
52
|
+
animationPriority = self._animationPriority:Observe();
|
|
53
|
+
}):Pipe({
|
|
54
|
+
Rx.throttleDefer();
|
|
55
|
+
}):Subscribe(function(state)
|
|
56
|
+
if state.animationTarget and state.trackId then
|
|
57
|
+
self._currentTrack.Value = AnimationUtils.getOrCreateAnimationTrack(state.animationTarget, state.trackId, state.animationPriority)
|
|
58
|
+
else
|
|
59
|
+
self._currentTrack.Value = nil
|
|
60
|
+
end
|
|
61
|
+
end))
|
|
62
|
+
|
|
63
|
+
self._maid:GiveTask(self._currentTrack:ObserveBrio(function(track)
|
|
64
|
+
return track ~= nil
|
|
65
|
+
end):Subscribe(function(brio)
|
|
66
|
+
if brio:IsDead() then
|
|
67
|
+
return
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
local maid = brio:ToMaid()
|
|
71
|
+
local track = brio:GetValue()
|
|
72
|
+
|
|
73
|
+
maid:GiveTask(track.KeyframeReached:Connect(function(...)
|
|
74
|
+
self.KeyframeReached:Fire(...)
|
|
75
|
+
end))
|
|
76
|
+
end))
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
function AnimationTrackPlayer:SetAnimationId(animationId)
|
|
80
|
+
return self._trackId:Mount(animationId)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
function AnimationTrackPlayer:GetAnimationId()
|
|
84
|
+
return self._trackId.Value
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
function AnimationTrackPlayer:SetAnimationTarget(animationTarget)
|
|
88
|
+
return self._animationTarget:Mount(animationTarget)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
function AnimationTrackPlayer:SetWeightTargetIfNotSet(weight, fadeTime)
|
|
92
|
+
self._maid._adjustWeight = self:_onEachTrack(function(_maid, track)
|
|
93
|
+
if track.WeightTarget ~= weight then
|
|
94
|
+
track:AdjustWeight(weight, fadeTime)
|
|
95
|
+
end
|
|
96
|
+
end)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
function AnimationTrackPlayer:Play(fadeTime, weight, speed)
|
|
100
|
+
if weight then
|
|
101
|
+
self._maid._adjustWeight = nil
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
if speed then
|
|
105
|
+
self._maid._adjustSpeed = nil
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
self._maid._stop = nil
|
|
109
|
+
self._maid._play = self:_onEachTrack(function(_maid, track)
|
|
110
|
+
track:Play(fadeTime, weight, speed)
|
|
111
|
+
end)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
function AnimationTrackPlayer:Stop(fadeTime)
|
|
115
|
+
self._maid._play = nil
|
|
116
|
+
self._maid._stop = self:_onEachTrack(function(_maid, track)
|
|
117
|
+
track:Stop(fadeTime)
|
|
118
|
+
end)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
function AnimationTrackPlayer:AdjustWeight(weight, fadeTime)
|
|
122
|
+
self._maid._adjustWeight = self:_onEachTrack(function(_maid, track)
|
|
123
|
+
track:AdjustWeight(weight, fadeTime)
|
|
124
|
+
end)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
function AnimationTrackPlayer:AdjustSpeed(speed, fadeTime)
|
|
128
|
+
self._maid._adjustSpeed = self:_onEachTrack(function(_maid, track)
|
|
129
|
+
track:AdjustSpeed(speed, fadeTime)
|
|
130
|
+
end)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
function AnimationTrackPlayer:IsPlaying()
|
|
134
|
+
local track = self._currentTrack.Value
|
|
135
|
+
if track then
|
|
136
|
+
return track.IsPlaying
|
|
137
|
+
else
|
|
138
|
+
return false
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
function AnimationTrackPlayer:_onEachTrack(callback)
|
|
143
|
+
return self._currentTrack:ObserveBrio(function(track)
|
|
144
|
+
return track ~= nil
|
|
145
|
+
end):Subscribe(function(brio)
|
|
146
|
+
if brio:IsDead() then
|
|
147
|
+
return
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
local track = brio:GetValue()
|
|
151
|
+
callback(brio:ToMaid(), track)
|
|
152
|
+
end)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
return AnimationTrackPlayer
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
Ship to run animations in hoarcekat
|
|
3
|
+
|
|
4
|
+
@class StudioRigAnimator
|
|
5
|
+
]=]
|
|
6
|
+
|
|
7
|
+
local require = require(script.Parent.loader).load(script)
|
|
8
|
+
|
|
9
|
+
local RunService = game:GetService("RunService")
|
|
10
|
+
|
|
11
|
+
local BaseObject = require("BaseObject")
|
|
12
|
+
local AnimationUtils = require("AnimationUtils")
|
|
13
|
+
|
|
14
|
+
local StudioRigAnimator = setmetatable({}, BaseObject)
|
|
15
|
+
StudioRigAnimator.ClassName = "StudioRigAnimator"
|
|
16
|
+
StudioRigAnimator.__index = StudioRigAnimator
|
|
17
|
+
|
|
18
|
+
function StudioRigAnimator.new(animatorOrHumanoid)
|
|
19
|
+
local self = setmetatable(BaseObject.new(animatorOrHumanoid), StudioRigAnimator)
|
|
20
|
+
|
|
21
|
+
if RunService:IsStudio() and not RunService:IsRunning() then
|
|
22
|
+
self:_setupStudio()
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
return self
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
function StudioRigAnimator:_setupStudio()
|
|
29
|
+
self._animator = AnimationUtils.getOrCreateAnimator(self._obj)
|
|
30
|
+
self._lastTime = os.clock()
|
|
31
|
+
|
|
32
|
+
self._maid:GiveTask(RunService.RenderStepped:Connect(function()
|
|
33
|
+
local now = os.clock()
|
|
34
|
+
local delta = now - self._lastTime
|
|
35
|
+
self._lastTime = now
|
|
36
|
+
|
|
37
|
+
self._animator:StepAnimations(delta)
|
|
38
|
+
end))
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
return StudioRigAnimator
|