@quenty/animationgroup 10.2.0 → 10.3.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,22 @@
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
+ # [10.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animationgroup@10.2.0...@quenty/animationgroup@10.3.0) (2024-05-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Fix .package-lock.json replicating in packages ([75d0efe](https://github.com/Quenty/NevermoreEngine/commit/75d0efeef239f221d93352af71a5b3e930ec23c5))
12
+
13
+
14
+ ### Features
15
+
16
+ * Allow tracks to be set in the AnimationGroup ([b51619a](https://github.com/Quenty/NevermoreEngine/commit/b51619add82097b5bc7449a21a9fd202374cd7bb))
17
+
18
+
19
+
20
+
21
+
6
22
  # [10.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animationgroup@10.1.0...@quenty/animationgroup@10.2.0) (2024-04-27)
7
23
 
8
24
  **Note:** Version bump only for package @quenty/animationgroup
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "animationgroup",
3
+ "globIgnorePaths": [ "**/.package-lock.json" ],
3
4
  "tree": {
4
5
  "$path": "src"
5
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/animationgroup",
3
- "version": "10.2.0",
3
+ "version": "10.3.0",
4
4
  "description": "A group of weighted tracks that can be played back with weighted probability. The closest example to this is the idle animation that looks around at a 1:10 ratio when you're standing still in default Roblox animation script.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,13 +26,13 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/animationtrackutils": "^2.1.1",
30
- "@quenty/baseobject": "^10.2.0",
31
- "@quenty/loader": "^10.2.0",
32
- "@quenty/maid": "^3.1.0"
29
+ "@quenty/animationtrackutils": "^2.2.0",
30
+ "@quenty/baseobject": "^10.3.0",
31
+ "@quenty/loader": "^10.3.0",
32
+ "@quenty/maid": "^3.2.0"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "5c9eab1eac73f0d54953cca5017b7be968182f72"
37
+ "gitHead": "3fd5cdca3128bf34c8d9dfae1e92d62533b6e6f5"
38
38
  }
@@ -23,10 +23,10 @@ AnimationGroup.__index = AnimationGroup
23
23
  function AnimationGroup.new(weightedTracks)
24
24
  local self = setmetatable(BaseObject.new(), AnimationGroup)
25
25
 
26
- self._weightedTracks = weightedTracks or error("No tracksWithWeight")
27
- for _, animation in pairs(self._weightedTracks) do
28
- assert(animation.track, "Bad animation.track")
29
- assert(animation.weight, "Bad animation.weight")
26
+ self._weightedTracks = {}
27
+
28
+ if weightedTracks then
29
+ self:SetWeightedTracks(weightedTracks)
30
30
  end
31
31
 
32
32
  self._maid:GiveTask(function()
@@ -41,17 +41,41 @@ end
41
41
  @param transitionTime number
42
42
  ]=]
43
43
  function AnimationGroup:Play(transitionTime)
44
+ assert(type(transitionTime) == "number" or transitionTime == nil, "Bad transitionTime")
45
+
44
46
  if self._currentTrack and self._currentTrack.IsPlaying then
45
47
  return
46
48
  end
47
49
 
48
50
  self:_playNewTrack(transitionTime)
49
51
  end
52
+
53
+ --[=[
54
+ @param weightedTracks { WeightedTrack }
55
+ @param transitionTime number | nil
56
+ ]=]
57
+ function AnimationGroup:SetWeightedTracks(weightedTracks, transitionTime)
58
+ assert(type(weightedTracks) == "table", "Bad weightedTracks")
59
+ assert(type(transitionTime) == "number" or transitionTime == nil, "Bad transitionTime")
60
+
61
+ for _, animation in pairs(weightedTracks) do
62
+ assert(animation.track, "Bad animation.track")
63
+ assert(animation.weight, "Bad animation.weight")
64
+ end
65
+
66
+ self._weightedTracks = weightedTracks
67
+
68
+ self:Stop(transitionTime)
69
+ self:Play(transitionTime)
70
+ end
71
+
50
72
  --[=[
51
73
  Stops the animations
52
74
  @param transitionTime number
53
75
  ]=]
54
76
  function AnimationGroup:Stop(transitionTime)
77
+ assert(type(transitionTime) == "number" or transitionTime == nil, "Bad transitionTime")
78
+
55
79
  if self._currentTrack then
56
80
  self._currentTrack:Stop(transitionTime)
57
81
  self._currentTrack = nil
@@ -59,7 +83,13 @@ function AnimationGroup:Stop(transitionTime)
59
83
  end
60
84
 
61
85
  function AnimationGroup:_playNewTrack(transitionTime)
86
+ assert(type(transitionTime) == "number" or transitionTime == nil, "Bad transitionTime")
87
+
62
88
  local trackData = AnimationGroupUtils.selectFromWeightedTracks(self._weightedTracks)
89
+ if not trackData then
90
+ return
91
+ end
92
+
63
93
  local track = trackData.track or error("No track")
64
94
 
65
95
  if self._currentTrack == track and self._currentTrack.IsPlaying then
@@ -36,6 +36,7 @@ function AnimationGroupUtils.createdWeightedTracks(animatorOrHumanoid, weightedA
36
36
  assert(weightedAnimationList, "Bad weightedAnimationList")
37
37
 
38
38
  local tracks = {}
39
+
39
40
  for _, weightedAnimation in pairs(weightedAnimationList) do
40
41
  assert(weightedAnimation.animationId, "Bad weightedAnimation.animationId")
41
42
  assert(weightedAnimation.weight, "Bad weightedAnimation.weight")
@@ -44,6 +45,7 @@ function AnimationGroupUtils.createdWeightedTracks(animatorOrHumanoid, weightedA
44
45
  AnimationTrackUtils.loadAnimationFromId(animatorOrHumanoid, weightedAnimation.animationId),
45
46
  weightedAnimation.weight))
46
47
  end
48
+
47
49
  return tracks
48
50
  end
49
51