@quenty/animations 8.20.1 → 8.20.2-canary.63ba0e0.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,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
+ ## [8.20.2-canary.63ba0e0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@8.20.1...@quenty/animations@8.20.2-canary.63ba0e0.0) (2025-09-26)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Handle priority properly ([1f48083](https://github.com/Quenty/NevermoreEngine/commit/1f48083435c8d14aa0fe21a237fe92f3df4e7a17))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [8.20.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@8.20.0...@quenty/animations@8.20.1) (2025-09-16)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/animations",
3
- "version": "8.20.1",
3
+ "version": "8.20.2-canary.63ba0e0.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": "^10.9.0",
29
- "@quenty/enumutils": "^3.4.2",
30
- "@quenty/humanoidanimatorutils": "^3.2.0",
31
- "@quenty/loader": "^10.9.0",
32
- "@quenty/maid": "^3.5.0",
33
- "@quenty/promise": "^10.12.0",
34
- "@quenty/promisemaid": "^5.12.0",
35
- "@quenty/rbxasset": "^5.9.0",
36
- "@quenty/rx": "^13.19.0",
37
- "@quenty/signal": "^7.11.1",
38
- "@quenty/valueobject": "^13.19.0"
28
+ "@quenty/baseobject": "10.9.0",
29
+ "@quenty/enumutils": "3.4.2",
30
+ "@quenty/humanoidanimatorutils": "3.2.0",
31
+ "@quenty/loader": "10.9.0",
32
+ "@quenty/maid": "3.5.0",
33
+ "@quenty/promise": "10.12.0",
34
+ "@quenty/promisemaid": "5.12.0",
35
+ "@quenty/rbxasset": "5.9.1-canary.63ba0e0.0",
36
+ "@quenty/rx": "13.19.1-canary.63ba0e0.0",
37
+ "@quenty/signal": "7.11.1",
38
+ "@quenty/valueobject": "13.19.1-canary.63ba0e0.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "dfcf334600d0c7b4961050e5a7df255b9fef858f"
43
+ "gitHead": "63ba0e0c4b5c8bdaeb452f0b3d742b7b8bc8a7ab"
44
44
  }
@@ -14,6 +14,12 @@ local AnimationUtils = {}
14
14
  --[=[
15
15
  Plays the animation on the target instance.
16
16
 
17
+ :::tip
18
+ If you play an animation at 1 priority, and then request another animation track at
19
+ a different priority, it will give you 2 separate animation tracks. Otherwise it tries to reuse the
20
+ same animation track.
21
+ :::
22
+
17
23
  @return AnimationTrack?
18
24
  ]=]
19
25
  function AnimationUtils.playAnimation(
@@ -86,12 +92,12 @@ function AnimationUtils.getOrCreateAnimationTrack(
86
92
 
87
93
  assert(typeof(animator) == "Instance" and animator:IsA("Animator"), "Bad animator")
88
94
 
89
- local foundAnimationTrack = AnimationUtils.findAnimationTrackInAnimator(animator, id)
95
+ local foundAnimationTrack = AnimationUtils.findAnimationTrackInAnimator(animator, id, priority)
90
96
  if foundAnimationTrack then
91
97
  return foundAnimationTrack
92
98
  end
93
99
 
94
- local animation = AnimationUtils.getOrCreateAnimationFromIdInAnimator(animator, id)
100
+ local animation = AnimationUtils.getOrCreateAnimationFromIdInAnimator(animator, id, priority)
95
101
 
96
102
  local animationTrack
97
103
  local ok, err = pcall(function()
@@ -108,15 +114,24 @@ function AnimationUtils.getOrCreateAnimationTrack(
108
114
  return nil
109
115
  end
110
116
 
117
+ if priority then
118
+ animationTrack.Priority = priority
119
+ end
120
+
111
121
  return animationTrack
112
122
  end
113
123
 
114
124
  --[=[
115
125
  Gets or creates an animation from the id in the animator
116
126
  ]=]
117
- function AnimationUtils.getOrCreateAnimationFromIdInAnimator(animator: Animator, id: string | number): Animation
127
+ function AnimationUtils.getOrCreateAnimationFromIdInAnimator(
128
+ animator: Animator,
129
+ id: string | number,
130
+ priority: Enum.AnimationPriority?
131
+ ): Animation
118
132
  assert(typeof(animator) == "Instance" and animator:IsA("Animator"), "Bad animator")
119
133
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
134
+ assert(priority == nil or EnumUtils.isOfType(Enum.AnimationPriority, priority), "Bad priority")
120
135
 
121
136
  local animationId = RbxAssetUtils.toRbxAssetId(id)
122
137
  for _, animation in animator:GetChildren() do
@@ -138,31 +153,65 @@ end
138
153
  ]=]
139
154
  function AnimationUtils.findAnimationTrack(
140
155
  target: Animator | Player | Model | AnimationController,
141
- id: string | number
156
+ id: string | number,
157
+ priority: Enum.AnimationPriority?
142
158
  ): AnimationTrack?
143
159
  assert(typeof(target) == "Instance", "Bad target")
144
160
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
161
+ assert(priority == nil or EnumUtils.isOfType(Enum.AnimationPriority, priority), "Bad priority")
145
162
 
146
163
  local animator = AnimationUtils.getOrCreateAnimator(target)
147
164
  if not animator then
148
165
  return nil
149
166
  end
150
167
 
151
- return AnimationUtils.findAnimationTrackInAnimator(animator, id)
168
+ return AnimationUtils.findAnimationTrackInAnimator(animator, id, priority)
169
+ end
170
+
171
+ --[=[
172
+ Computes whether a given animation track matches the id and priority
173
+ ]=]
174
+ function AnimationUtils.isMatchingAnimationTrack(
175
+ animationTrack: AnimationTrack,
176
+ id: string | number,
177
+ priority: Enum.AnimationPriority?
178
+ ): boolean
179
+ assert(typeof(animationTrack) == "Instance" and animationTrack:IsA("AnimationTrack"), "Bad animationTrack")
180
+ assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
181
+ assert(priority == nil or EnumUtils.isOfType(Enum.AnimationPriority, priority), "Bad priority")
182
+
183
+ local animation = animationTrack.Animation
184
+ if not animation then
185
+ return false
186
+ end
187
+
188
+ local animationId = RbxAssetUtils.toRbxAssetId(id)
189
+ if animation.AnimationId ~= animationId then
190
+ return false
191
+ end
192
+
193
+ if priority and animationTrack.Priority ~= priority then
194
+ return false
195
+ end
196
+
197
+ return true
152
198
  end
153
199
 
154
200
  --[=[
155
201
  Finds an animation track in an animator
156
202
  ]=]
157
- function AnimationUtils.findAnimationTrackInAnimator(animator: Animator, id: string | number): AnimationTrack?
203
+ function AnimationUtils.findAnimationTrackInAnimator(
204
+ animator: Animator,
205
+ id: string | number,
206
+ priority: Enum.AnimationPriority?
207
+ ): AnimationTrack?
158
208
  assert(typeof(animator) == "Instance" and animator:IsA("Animator"), "Bad animator")
159
209
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
160
210
 
161
211
  local animationId = RbxAssetUtils.toRbxAssetId(id)
162
212
 
163
213
  for _, animationTrack in animator:GetPlayingAnimationTracks() do
164
- local animation = animationTrack.Animation
165
- if animation and animation.AnimationId == animationId then
214
+ if AnimationUtils.isMatchingAnimationTrack(animationTrack, animationId, priority) then
166
215
  return animationTrack
167
216
  end
168
217
  end