@quenty/animations 1.5.0 → 1.5.1-canary.417.052e8ba.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 +11 -0
- package/package.json +13 -13
- package/src/Shared/AnimationSlotPlayer.lua +62 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.5.1-canary.417.052e8ba.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@1.5.0...@quenty/animations@1.5.1-canary.417.052e8ba.0) (2023-10-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add AnimationSlotPlayer:AdjustSpeed(id, speed) ([bd59858](https://github.com/Quenty/NevermoreEngine/commit/bd598582df448591a71996b6198ac3ba40f03404))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [1.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@1.4.0...@quenty/animations@1.5.0) (2023-09-21)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/animations
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/animations",
|
|
3
|
-
"version": "1.5.0",
|
|
3
|
+
"version": "1.5.1-canary.417.052e8ba.0",
|
|
4
4
|
"description": "Utility methods for playing back animations on Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/baseobject": "
|
|
29
|
-
"@quenty/enumutils": "
|
|
30
|
-
"@quenty/humanoidanimatorutils": "
|
|
31
|
-
"@quenty/loader": "
|
|
32
|
-
"@quenty/maid": "
|
|
33
|
-
"@quenty/promise": "
|
|
34
|
-
"@quenty/promisemaid": "
|
|
35
|
-
"@quenty/rbxasset": "
|
|
36
|
-
"@quenty/rx": "
|
|
37
|
-
"@quenty/signal": "
|
|
38
|
-
"@quenty/valueobject": "
|
|
28
|
+
"@quenty/baseobject": "6.3.1-canary.417.052e8ba.0",
|
|
29
|
+
"@quenty/enumutils": "3.1.0",
|
|
30
|
+
"@quenty/humanoidanimatorutils": "2.2.1-canary.417.052e8ba.0",
|
|
31
|
+
"@quenty/loader": "6.3.1-canary.417.052e8ba.0",
|
|
32
|
+
"@quenty/maid": "2.6.0",
|
|
33
|
+
"@quenty/promise": "6.8.1-canary.417.052e8ba.0",
|
|
34
|
+
"@quenty/promisemaid": "1.3.1-canary.417.052e8ba.0",
|
|
35
|
+
"@quenty/rbxasset": "1.2.1-canary.417.052e8ba.0",
|
|
36
|
+
"@quenty/rx": "7.16.1-canary.417.052e8ba.0",
|
|
37
|
+
"@quenty/signal": "2.4.1-canary.417.052e8ba.0",
|
|
38
|
+
"@quenty/valueobject": "7.24.1-canary.417.052e8ba.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "052e8ba33437f71398c4c08c8dbcbf076022d388"
|
|
44
44
|
}
|
|
@@ -9,6 +9,7 @@ local AnimationUtils = require("AnimationUtils")
|
|
|
9
9
|
local ValueObject = require("ValueObject")
|
|
10
10
|
local Maid = require("Maid")
|
|
11
11
|
local EnumUtils = require("EnumUtils")
|
|
12
|
+
local RbxAssetUtils = require("RbxAssetUtils")
|
|
12
13
|
|
|
13
14
|
local AnimationSlotPlayer = setmetatable({}, BaseObject)
|
|
14
15
|
AnimationSlotPlayer.ClassName = "AnimationSlotPlayer"
|
|
@@ -17,14 +18,10 @@ AnimationSlotPlayer.__index = AnimationSlotPlayer
|
|
|
17
18
|
function AnimationSlotPlayer.new(animationTarget)
|
|
18
19
|
local self = setmetatable(BaseObject.new(), AnimationSlotPlayer)
|
|
19
20
|
|
|
20
|
-
self._animationTarget = ValueObject.new(nil)
|
|
21
|
-
self._maid:
|
|
22
|
-
|
|
23
|
-
self.
|
|
24
|
-
self._maid:GiveTask(self._defaultFadeTime)
|
|
25
|
-
|
|
26
|
-
self._defaultAnimationPriority = ValueObject.new(nil)
|
|
27
|
-
self._maid:GiveTask(self._defaultAnimationPriority)
|
|
21
|
+
self._animationTarget = self._maid:Add(ValueObject.new(nil))
|
|
22
|
+
self._defaultFadeTime = self._maid:Add(ValueObject.new(0.1, "number"))
|
|
23
|
+
self._defaultAnimationPriority = self._maid:Add(ValueObject.new(nil))
|
|
24
|
+
self._currentAnimationTrackData = self._maid:Add(ValueObject.new(nil))
|
|
28
25
|
|
|
29
26
|
if animationTarget then
|
|
30
27
|
self:SetAnimationTarget(animationTarget)
|
|
@@ -47,6 +44,45 @@ function AnimationSlotPlayer:SetAnimationTarget(animationTarget)
|
|
|
47
44
|
self._animationTarget:Mount(animationTarget)
|
|
48
45
|
end
|
|
49
46
|
|
|
47
|
+
function AnimationSlotPlayer:AdjustSpeed(id, speed)
|
|
48
|
+
assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
|
|
49
|
+
assert(type(speed) == "number", "Bad number")
|
|
50
|
+
|
|
51
|
+
local animationId = RbxAssetUtils.toRbxAssetId(id)
|
|
52
|
+
|
|
53
|
+
local topMaid = Maid.new()
|
|
54
|
+
|
|
55
|
+
topMaid:GiveTask(self._currentAnimationTrackData:ObserveBrio(function(data)
|
|
56
|
+
return data and data.animationId == animationId
|
|
57
|
+
end):Subscribe(function(brio)
|
|
58
|
+
if brio:IsDead() then
|
|
59
|
+
return
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
local data = brio:GetValue()
|
|
63
|
+
local maid = brio:ToMaid()
|
|
64
|
+
|
|
65
|
+
data.track:AdjustSpeed(speed)
|
|
66
|
+
|
|
67
|
+
-- TODO: Use stack here?
|
|
68
|
+
-- TODO: Probably need rogue property mechanisms
|
|
69
|
+
maid:GiveTask(function()
|
|
70
|
+
if math.abs(data.track.Speed - speed) <= 1e-3 then
|
|
71
|
+
data.track:AdjustSpeed(data.originalSpeed)
|
|
72
|
+
end
|
|
73
|
+
end)
|
|
74
|
+
end))
|
|
75
|
+
|
|
76
|
+
-- TODO: Probably per-a-track instead of global like this
|
|
77
|
+
self._maid._currentSpeedAdjustment = topMaid
|
|
78
|
+
|
|
79
|
+
return function()
|
|
80
|
+
if self._maid._currentSpeedAdjustment == topMaid then
|
|
81
|
+
self._maid._currentSpeedAdjustment = nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
50
86
|
function AnimationSlotPlayer:Play(id, fadeTime, weight, speed, priority)
|
|
51
87
|
fadeTime = fadeTime or self._defaultFadeTime.Value
|
|
52
88
|
priority = priority or self._defaultAnimationPriority.Value
|
|
@@ -54,6 +90,8 @@ function AnimationSlotPlayer:Play(id, fadeTime, weight, speed, priority)
|
|
|
54
90
|
|
|
55
91
|
local topMaid = Maid.new()
|
|
56
92
|
|
|
93
|
+
local animationId = RbxAssetUtils.toRbxAssetId(id)
|
|
94
|
+
|
|
57
95
|
topMaid:GiveTask(self._animationTarget:ObserveBrio(function(target)
|
|
58
96
|
return target ~= nil
|
|
59
97
|
end):Subscribe(function(brio)
|
|
@@ -64,8 +102,23 @@ function AnimationSlotPlayer:Play(id, fadeTime, weight, speed, priority)
|
|
|
64
102
|
local animationTarget = brio:GetValue()
|
|
65
103
|
local maid = brio:ToMaid()
|
|
66
104
|
|
|
67
|
-
local track = AnimationUtils.playAnimation(animationTarget,
|
|
105
|
+
local track = AnimationUtils.playAnimation(animationTarget, animationId, fadeTime, weight, speed, priority)
|
|
68
106
|
if track then
|
|
107
|
+
local data = {
|
|
108
|
+
animationId = animationId;
|
|
109
|
+
track = track;
|
|
110
|
+
originalSpeed = speed;
|
|
111
|
+
originalWeight = weight;
|
|
112
|
+
originalPriority = priority;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
self._currentAnimationTrackData.Value = data
|
|
116
|
+
maid:GiveTask(function()
|
|
117
|
+
if self._currentAnimationTrackData.Value == data then
|
|
118
|
+
self._currentAnimationTrackData.Value = nil
|
|
119
|
+
end
|
|
120
|
+
end)
|
|
121
|
+
|
|
69
122
|
maid:GiveTask(function()
|
|
70
123
|
track:AdjustWeight(0, fadeTime or self._defaultFadeTime.Value)
|
|
71
124
|
end)
|