@quenty/animations 8.17.0 → 8.17.1

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.17.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@8.17.0...@quenty/animations@8.17.1) (2025-04-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
12
+
13
+
14
+
15
+
16
+
6
17
  # [8.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@8.16.2...@quenty/animations@8.17.0) (2025-04-02)
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": "8.17.0",
3
+ "version": "8.17.1",
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.8.0",
29
- "@quenty/enumutils": "^3.4.0",
30
- "@quenty/humanoidanimatorutils": "^3.1.0",
31
- "@quenty/loader": "^10.8.0",
32
- "@quenty/maid": "^3.4.0",
33
- "@quenty/promise": "^10.10.1",
34
- "@quenty/promisemaid": "^5.10.1",
35
- "@quenty/rbxasset": "^5.8.0",
36
- "@quenty/rx": "^13.17.0",
37
- "@quenty/signal": "^7.10.0",
38
- "@quenty/valueobject": "^13.17.0"
28
+ "@quenty/baseobject": "^10.8.1",
29
+ "@quenty/enumutils": "^3.4.1",
30
+ "@quenty/humanoidanimatorutils": "^3.1.1",
31
+ "@quenty/loader": "^10.8.1",
32
+ "@quenty/maid": "^3.4.1",
33
+ "@quenty/promise": "^10.10.2",
34
+ "@quenty/promisemaid": "^5.10.2",
35
+ "@quenty/rbxasset": "^5.8.1",
36
+ "@quenty/rx": "^13.17.1",
37
+ "@quenty/signal": "^7.10.1",
38
+ "@quenty/valueobject": "^13.17.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "e8ea56930e65322fcffc05a1556d5df988068f0b"
43
+ "gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
44
44
  }
@@ -15,10 +15,13 @@ local AnimationPromiseUtils = {}
15
15
  Promises that the track is finished
16
16
 
17
17
  @param animationTrack AnimationTrack
18
- @param endMarkerName string | nil
18
+ @param endMarkerName string?
19
19
  @return Promise
20
20
  ]=]
21
- function AnimationPromiseUtils.promiseFinished(animationTrack, endMarkerName)
21
+ function AnimationPromiseUtils.promiseFinished(
22
+ animationTrack: AnimationTrack,
23
+ endMarkerName: string?
24
+ ): Promise.Promise<()>
22
25
  assert(typeof(animationTrack) == "Instance", "Bad animationTrack")
23
26
  assert(type(endMarkerName) == "string" or endMarkerName == nil, "Bad endMarkerName")
24
27
  local promise = Promise.new()
@@ -52,7 +55,7 @@ end
52
55
  @param animationTrack AnimationTrack
53
56
  @return Promise
54
57
  ]=]
55
- function AnimationPromiseUtils.promiseLoaded(animationTrack)
58
+ function AnimationPromiseUtils.promiseLoaded(animationTrack: AnimationTrack): Promise.Promise<()>
56
59
  assert(typeof(animationTrack) == "Instance", "Bad animationTrack")
57
60
 
58
61
  if animationTrack.Length > 0 then
@@ -97,7 +100,7 @@ end
97
100
  @param keyframeName string
98
101
  @return Promise
99
102
  ]=]
100
- function AnimationPromiseUtils.promiseKeyframeReached(animationTrack, keyframeName)
103
+ function AnimationPromiseUtils.promiseKeyframeReached(animationTrack: AnimationTrack, keyframeName: string): Promise.Promise<()>
101
104
  assert(typeof(animationTrack) == "Instance", "Bad animationTrack")
102
105
  assert(type(keyframeName) == "string", "Bad endMarkerName")
103
106
 
@@ -45,7 +45,7 @@ end
45
45
 
46
46
  @param defaultFadeTime number
47
47
  ]=]
48
- function AnimationSlotPlayer:SetDefaultFadeTime(defaultFadeTime)
48
+ function AnimationSlotPlayer:SetDefaultFadeTime(defaultFadeTime: number)
49
49
  self._defaultFadeTime.Value = defaultFadeTime
50
50
  end
51
51
 
@@ -76,7 +76,7 @@ end
76
76
  @param speed number
77
77
  @return () -> () -- Callback to clean things up
78
78
  ]=]
79
- function AnimationSlotPlayer:AdjustSpeed(id, speed)
79
+ function AnimationSlotPlayer:AdjustSpeed(id: string | number, speed: number)
80
80
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
81
81
  assert(type(speed) == "number", "Bad speed")
82
82
 
@@ -84,26 +84,28 @@ function AnimationSlotPlayer:AdjustSpeed(id, speed)
84
84
 
85
85
  local topMaid = Maid.new()
86
86
 
87
- topMaid:GiveTask(self._currentAnimationTrackData:ObserveBrio(function(data)
88
- return data and data.animationId == animationId
89
- end):Subscribe(function(brio)
90
- if brio:IsDead() then
91
- return
92
- end
87
+ topMaid:GiveTask(self._currentAnimationTrackData
88
+ :ObserveBrio(function(data)
89
+ return data and data.animationId == animationId
90
+ end)
91
+ :Subscribe(function(brio)
92
+ if brio:IsDead() then
93
+ return
94
+ end
93
95
 
94
- local data = brio:GetValue()
95
- local maid = brio:ToMaid()
96
+ local data = brio:GetValue()
97
+ local maid = brio:ToMaid()
96
98
 
97
- data.track:AdjustSpeed(speed)
99
+ data.track:AdjustSpeed(speed)
98
100
 
99
- -- TODO: Use stack here?
100
- -- TODO: Probably need rogue property mechanisms
101
- maid:GiveTask(function()
102
- if math.abs(data.track.Speed - speed) <= 1e-3 then
103
- data.track:AdjustSpeed(data.originalSpeed)
104
- end
105
- end)
106
- end))
101
+ -- TODO: Use stack here?
102
+ -- TODO: Probably need rogue property mechanisms
103
+ maid:GiveTask(function()
104
+ if math.abs(data.track.Speed - speed) <= 1e-3 then
105
+ data.track:AdjustSpeed(data.originalSpeed)
106
+ end
107
+ end)
108
+ end))
107
109
 
108
110
  -- TODO: Probably per-a-track instead of global like this
109
111
  self._maid._currentSpeedAdjustment = topMaid
@@ -120,10 +122,10 @@ end
120
122
 
121
123
  @param id string | number
122
124
  @param weight number
123
- @param fadeTime number
125
+ @param fadeTime number?
124
126
  @return () -> () -- Callback to clean things up
125
127
  ]=]
126
- function AnimationSlotPlayer:AdjustWeight(id, weight, fadeTime)
128
+ function AnimationSlotPlayer:AdjustWeight(id: string, weight: number, fadeTime: number?)
127
129
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
128
130
  assert(type(weight) == "number", "Bad weight")
129
131
  assert(type(fadeTime) == "number" or fadeTime == nil, "Bad fadeTime")
@@ -132,26 +134,28 @@ function AnimationSlotPlayer:AdjustWeight(id, weight, fadeTime)
132
134
 
133
135
  local topMaid = Maid.new()
134
136
 
135
- topMaid:GiveTask(self._currentAnimationTrackData:ObserveBrio(function(data)
136
- return data and data.animationId == animationId
137
- end):Subscribe(function(brio)
138
- if brio:IsDead() then
139
- return
140
- end
137
+ topMaid:GiveTask(self._currentAnimationTrackData
138
+ :ObserveBrio(function(data)
139
+ return data and data.animationId == animationId
140
+ end)
141
+ :Subscribe(function(brio)
142
+ if brio:IsDead() then
143
+ return
144
+ end
141
145
 
142
- local data = brio:GetValue()
143
- local maid = brio:ToMaid()
146
+ local data = brio:GetValue()
147
+ local maid = brio:ToMaid()
144
148
 
145
- data.track:AdjustWeight(weight, fadeTime)
149
+ data.track:AdjustWeight(weight, fadeTime)
146
150
 
147
- -- TODO: Use stack here?
148
- -- TODO: Probably need rogue property mechanisms
149
- maid:GiveTask(function()
150
- if math.abs(data.track.Speed - weight) <= 1e-3 then
151
- data.track:AdjustWeight(data.originalWeight, fadeTime)
152
- end
153
- end)
154
- end))
151
+ -- TODO: Use stack here?
152
+ -- TODO: Probably need rogue property mechanisms
153
+ maid:GiveTask(function()
154
+ if math.abs(data.track.Speed - weight) <= 1e-3 then
155
+ data.track:AdjustWeight(data.originalWeight, fadeTime)
156
+ end
157
+ end)
158
+ end))
155
159
 
156
160
  -- TODO: Probably per-a-track instead of global like this
157
161
  self._maid._currentWeightAdjustment = topMaid
@@ -170,10 +174,10 @@ end
170
174
  @param fadeTime number?
171
175
  @param weight number?
172
176
  @param speed number?
173
- @param priority number?
177
+ @param priority Enum.AnimationPriority?
174
178
  @return () -> () -- Callback to clean things up
175
179
  ]=]
176
- function AnimationSlotPlayer:Play(id, fadeTime, weight, speed, priority)
180
+ function AnimationSlotPlayer:Play(id: string | number, fadeTime: number?, weight: number?, speed: number?, priority: Enum.AnimationPriority?): () -> ()
177
181
  fadeTime = fadeTime or self._defaultFadeTime.Value
178
182
  priority = priority or self._defaultAnimationPriority.Value
179
183
  weight = weight or 1 -- We need to explicitly adjust the weight here
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Plays a single track, allowing for the animation to be controlled easier.
3
4
 
@@ -21,11 +22,11 @@ AnimationTrackPlayer.__index = AnimationTrackPlayer
21
22
  all data is found.
22
23
 
23
24
  @param animationTarget Instance | Observable<Instance>
24
- @param animationId string | number | nil
25
+ @param animationId string | number?
25
26
  @return AnimationTrackPlayer
26
27
  ]=]
27
28
  function AnimationTrackPlayer.new(animationTarget, animationId)
28
- local self = setmetatable(BaseObject.new(), AnimationTrackPlayer)
29
+ local self = setmetatable(BaseObject.new() :: any, AnimationTrackPlayer)
29
30
 
30
31
  self._animationTarget = self._maid:Add(ValueObject.new(nil))
31
32
  self._trackId = self._maid:Add(ValueObject.new(nil))
@@ -111,7 +112,7 @@ end
111
112
  @param weight number
112
113
  @param fadeTime number
113
114
  ]=]
114
- function AnimationTrackPlayer:SetWeightTargetIfNotSet(weight, fadeTime)
115
+ function AnimationTrackPlayer:SetWeightTargetIfNotSet(weight: number, fadeTime: number)
115
116
  self._maid._adjustWeight = self:_onEachTrack(function(_maid, track)
116
117
  if track.WeightTarget ~= weight then
117
118
  track:AdjustWeight(weight, fadeTime)
@@ -126,7 +127,7 @@ end
126
127
  @param weight number
127
128
  @param speed number
128
129
  ]=]
129
- function AnimationTrackPlayer:Play(fadeTime, weight, speed)
130
+ function AnimationTrackPlayer:Play(fadeTime: number, weight: number, speed: number)
130
131
  if weight then
131
132
  self._maid._adjustWeight = nil
132
133
  end
@@ -146,7 +147,7 @@ end
146
147
 
147
148
  @param fadeTime number
148
149
  ]=]
149
- function AnimationTrackPlayer:Stop(fadeTime)
150
+ function AnimationTrackPlayer:Stop(fadeTime: number)
150
151
  self._maid._play = nil
151
152
  self._maid._stop = self:_onEachTrack(function(_maid, track)
152
153
  track:Stop(fadeTime)
@@ -159,7 +160,7 @@ end
159
160
  @param weight number
160
161
  @param fadeTime number
161
162
  ]=]
162
- function AnimationTrackPlayer:AdjustWeight(weight, fadeTime)
163
+ function AnimationTrackPlayer:AdjustWeight(weight: number, fadeTime: number)
163
164
  self._maid._adjustWeight = self:_onEachTrack(function(_maid, track)
164
165
  track:AdjustWeight(weight, fadeTime)
165
166
  end)
@@ -171,7 +172,7 @@ end
171
172
  @param speed number
172
173
  @param fadeTime number
173
174
  ]=]
174
- function AnimationTrackPlayer:AdjustSpeed(speed, fadeTime)
175
+ function AnimationTrackPlayer:AdjustSpeed(speed: number, fadeTime: number)
175
176
  self._maid._adjustSpeed = self:_onEachTrack(function(_maid, track)
176
177
  track:AdjustSpeed(speed, fadeTime)
177
178
  end)
@@ -182,7 +183,7 @@ end
182
183
 
183
184
  @return boolean
184
185
  ]=]
185
- function AnimationTrackPlayer:IsPlaying()
186
+ function AnimationTrackPlayer:IsPlaying(): boolean
186
187
  local track = self._currentTrack.Value
187
188
  if track then
188
189
  return track.IsPlaying
@@ -21,13 +21,14 @@ function AnimationUtils.playAnimation(
21
21
  fadeTime: number?,
22
22
  weight: number?,
23
23
  speed: number?,
24
- priority: AnimationPriority?): AnimationTrack?
24
+ priority: Enum.AnimationPriority?
25
+ ): AnimationTrack?
25
26
  assert(typeof(target) == "Instance", "Bad target")
26
27
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
27
28
  assert(type(fadeTime) == "number" or fadeTime == nil, "Bad fadeTime")
28
29
  assert(type(weight) == "number" or weight == nil, "Bad weight")
29
30
  assert(type(speed) == "number" or speed == nil, "Bad speed")
30
- assert(EnumUtils.isOfType(Enum.AnimationPriority, priority) or priority == nil, "Bad priority")
31
+ assert(priority == nil or EnumUtils.isOfType(Enum.AnimationPriority, priority), "Bad priority")
31
32
 
32
33
  local animationTrack = AnimationUtils.getOrCreateAnimationTrack(target, id, priority)
33
34
 
@@ -47,7 +48,11 @@ end
47
48
  --[=[
48
49
  Stops the animation on the target instance.
49
50
  ]=]
50
- function AnimationUtils.stopAnimation(target: Animator | Player | Model | AnimationController, id: string | number, fadeTime: number?): AnimationTrack?
51
+ function AnimationUtils.stopAnimation(
52
+ target: Animator | Player | Model | AnimationController,
53
+ id: string | number,
54
+ fadeTime: number?
55
+ ): AnimationTrack?
51
56
  assert(typeof(target) == "Instance", "Bad target")
52
57
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
53
58
  assert(type(fadeTime) == "number" or fadeTime == nil, "Bad fadeTime")
@@ -67,10 +72,11 @@ end
67
72
  function AnimationUtils.getOrCreateAnimationTrack(
68
73
  target: Animator | Player | Model | AnimationController,
69
74
  id: string | number,
70
- priority: AnimationPriority?): AnimationTrack?
75
+ priority: Enum.AnimationPriority?
76
+ ): AnimationTrack?
71
77
  assert(typeof(target) == "Instance", "Bad target")
72
78
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
73
- assert(EnumUtils.isOfType(Enum.AnimationPriority, priority) or priority == nil, "Bad priority")
79
+ assert(priority == nil or EnumUtils.isOfType(Enum.AnimationPriority, priority), "Bad priority")
74
80
 
75
81
  local animator = AnimationUtils.getOrCreateAnimator(target)
76
82
  if not animator then
@@ -91,7 +97,13 @@ function AnimationUtils.getOrCreateAnimationTrack(
91
97
  animationTrack = animator:LoadAnimation(animation)
92
98
  end)
93
99
  if not ok then
94
- warn(string.format("[AnimationUtils] - Failed to load animation with id %q due to %q", tostring(id), tostring(err)))
100
+ warn(
101
+ string.format(
102
+ "[AnimationUtils] - Failed to load animation with id %q due to %q",
103
+ tostring(id),
104
+ tostring(err)
105
+ )
106
+ )
95
107
  return nil
96
108
  end
97
109
 
@@ -101,12 +113,12 @@ end
101
113
  --[=[
102
114
  Gets or creates an animation from the id in the animator
103
115
  ]=]
104
- function AnimationUtils.getOrCreateAnimationFromIdInAnimator(animator: Animator, id: string | number): Animation?
116
+ function AnimationUtils.getOrCreateAnimationFromIdInAnimator(animator: Animator, id: string | number): Animation
105
117
  assert(typeof(animator) == "Instance" and animator:IsA("Animator"), "Bad animator")
106
118
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
107
119
 
108
120
  local animationId = RbxAssetUtils.toRbxAssetId(id)
109
- for _, animation in pairs(animator:GetChildren()) do
121
+ for _, animation in animator:GetChildren() do
110
122
  if animation:IsA("Animation") then
111
123
  if animation.AnimationId == animationId then
112
124
  return animation
@@ -125,7 +137,8 @@ end
125
137
  ]=]
126
138
  function AnimationUtils.findAnimationTrack(
127
139
  target: Animator | Player | Model | AnimationController,
128
- id: string | number): AnimationTrack?
140
+ id: string | number
141
+ ): AnimationTrack?
129
142
  assert(typeof(target) == "Instance", "Bad target")
130
143
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
131
144
 
@@ -146,7 +159,7 @@ function AnimationUtils.findAnimationTrackInAnimator(animator: Animator, id: str
146
159
 
147
160
  local animationId = RbxAssetUtils.toRbxAssetId(id)
148
161
 
149
- for _, animationTrack in pairs(animator:GetPlayingAnimationTracks()) do
162
+ for _, animationTrack in animator:GetPlayingAnimationTracks() do
150
163
  local animation = animationTrack.Animation
151
164
  if animation and animation.AnimationId == animationId then
152
165
  return animationTrack
@@ -221,4 +234,4 @@ function AnimationUtils.createAnimationFromId(id: string | number): Animation
221
234
  return animation
222
235
  end
223
236
 
224
- return AnimationUtils
237
+ return AnimationUtils
@@ -26,7 +26,7 @@ StudioRigAnimator.__index = StudioRigAnimator
26
26
  @param animatorOrHumanoid Animator | Humanoid
27
27
  @return StudioRigAnimator
28
28
  ]=]
29
- function StudioRigAnimator.new(animatorOrHumanoid)
29
+ function StudioRigAnimator.new(animatorOrHumanoid: Animator | Humanoid)
30
30
  local self = setmetatable(BaseObject.new(animatorOrHumanoid), StudioRigAnimator)
31
31
 
32
32
  if RunService:IsStudio() and not RunService:IsRunning() then
@@ -38,6 +38,10 @@ end
38
38
 
39
39
  function StudioRigAnimator:_setupStudio()
40
40
  self._animator = AnimationUtils.getOrCreateAnimator(self._obj)
41
+ if not self._animator then
42
+ return
43
+ end
44
+
41
45
  self._lastTime = os.clock()
42
46
 
43
47
  self._maid:GiveTask(RunService.RenderStepped:Connect(function()
@@ -49,4 +53,4 @@ function StudioRigAnimator:_setupStudio()
49
53
  end))
50
54
  end
51
55
 
52
- return StudioRigAnimator
56
+ return StudioRigAnimator
@@ -10,6 +10,13 @@ local AnimationUtils = require("AnimationUtils")
10
10
 
11
11
  game.UserInputService.InputBegan:Connect(function(inputObject)
12
12
  if inputObject.KeyCode == Enum.KeyCode.Q then
13
- AnimationUtils.playAnimation(Players.LocalPlayer, "rbxassetid://14012074834", nil, nil, 1, Enum.AnimationPriority.Action3)
13
+ AnimationUtils.playAnimation(
14
+ Players.LocalPlayer,
15
+ "rbxassetid://14012074834",
16
+ nil,
17
+ nil,
18
+ 1,
19
+ Enum.AnimationPriority.Action3
20
+ )
14
21
  end
15
- end)
22
+ end)
@@ -5,4 +5,3 @@ local ServerScriptService = game:GetService("ServerScriptService")
5
5
 
6
6
  local loader = ServerScriptService:FindFirstChild("LoaderUtils", true).Parent
7
7
  require(loader).bootstrapGame(ServerScriptService.animations)
8
-