@quenty/animations 1.2.0 → 1.2.1-canary.402.40f9a1f.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 +10 -7
- package/src/Shared/AnimationSlotPlayer.lua +86 -0
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.2.1-canary.402.40f9a1f.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@1.2.0...@quenty/animations@1.2.1-canary.402.40f9a1f.0) (2023-08-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add AnimationSlotPlayer.new(animationTarget) ([86f1e99](https://github.com/Quenty/NevermoreEngine/commit/86f1e9989d4c52b136078a9c4c34c205e2e88549))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [1.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@1.1.0...@quenty/animations@1.2.0) (2023-07-28)
|
|
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.2.0",
|
|
3
|
+
"version": "1.2.1-canary.402.40f9a1f.0",
|
|
4
4
|
"description": "Utility methods for playing back animations on Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,14 +25,17 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/
|
|
29
|
-
"@quenty/
|
|
30
|
-
"@quenty/
|
|
31
|
-
"@quenty/
|
|
32
|
-
"@quenty/
|
|
28
|
+
"@quenty/baseobject": "6.2.2-canary.402.40f9a1f.0",
|
|
29
|
+
"@quenty/enumutils": "3.1.0",
|
|
30
|
+
"@quenty/humanoidanimatorutils": "2.2.0",
|
|
31
|
+
"@quenty/loader": "6.2.2-canary.402.40f9a1f.0",
|
|
32
|
+
"@quenty/maid": "2.5.0",
|
|
33
|
+
"@quenty/promisemaid": "1.2.1-canary.402.40f9a1f.0",
|
|
34
|
+
"@quenty/rbxasset": "1.1.1-canary.402.40f9a1f.0",
|
|
35
|
+
"@quenty/valueobject": "7.21.1-canary.402.40f9a1f.0"
|
|
33
36
|
},
|
|
34
37
|
"publishConfig": {
|
|
35
38
|
"access": "public"
|
|
36
39
|
},
|
|
37
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "40f9a1fad543e137f1e639cafc45a98cb439b0b6"
|
|
38
41
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
maid:GiveTask(function()
|
|
69
|
+
track:AdjustWeight(0, fadeTime or self._defaultFadeTime.Value)
|
|
70
|
+
end)
|
|
71
|
+
end))
|
|
72
|
+
|
|
73
|
+
self._maid._current = topMaid
|
|
74
|
+
|
|
75
|
+
return function()
|
|
76
|
+
if self._maid._current == topMaid then
|
|
77
|
+
self._maid._current = nil
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
function AnimationSlotPlayer:Stop()
|
|
83
|
+
self._maid._current = nil
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
return AnimationSlotPlayer
|