@quenty/animations 2.1.1 → 2.2.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
+ # [2.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@2.1.1...@quenty/animations@2.2.0) (2023-12-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add AnimationSlotPlayer:AdjustWeight() API call ([6e8f586](https://github.com/Quenty/NevermoreEngine/commit/6e8f586afb65303920a78b762d9bc519b30c0ffd))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.1.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/animations@2.1.0...@quenty/animations@2.1.1) (2023-10-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": "2.1.1",
3
+ "version": "2.2.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": "^7.0.0",
28
+ "@quenty/baseobject": "^7.1.0",
29
29
  "@quenty/enumutils": "^3.1.0",
30
30
  "@quenty/humanoidanimatorutils": "^3.0.0",
31
- "@quenty/loader": "^7.0.0",
31
+ "@quenty/loader": "^7.1.0",
32
32
  "@quenty/maid": "^2.6.0",
33
- "@quenty/promise": "^7.0.0",
34
- "@quenty/promisemaid": "^2.0.0",
35
- "@quenty/rbxasset": "^2.0.0",
36
- "@quenty/rx": "^8.1.1",
37
- "@quenty/signal": "^3.0.0",
38
- "@quenty/valueobject": "^8.1.1"
33
+ "@quenty/promise": "^7.1.0",
34
+ "@quenty/promisemaid": "^2.1.0",
35
+ "@quenty/rbxasset": "^2.1.0",
36
+ "@quenty/rx": "^8.2.0",
37
+ "@quenty/signal": "^3.1.0",
38
+ "@quenty/valueobject": "^8.2.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "440aca7ce2b50b74317ee05fdc0b8d1e58001af3"
43
+ "gitHead": "2c2dbbc0cb2fbb46b4f3270c559c63890fe18b26"
44
44
  }
@@ -22,6 +22,7 @@ function AnimationSlotPlayer.new(animationTarget)
22
22
  self._defaultFadeTime = self._maid:Add(ValueObject.new(0.1, "number"))
23
23
  self._defaultAnimationPriority = self._maid:Add(ValueObject.new(nil))
24
24
  self._currentAnimationTrackData = self._maid:Add(ValueObject.new(nil))
25
+ self._currentAnimationId = self._maid:Add(ValueObject.new(nil))
25
26
 
26
27
  if animationTarget then
27
28
  self:SetAnimationTarget(animationTarget)
@@ -46,7 +47,7 @@ end
46
47
 
47
48
  function AnimationSlotPlayer:AdjustSpeed(id, speed)
48
49
  assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
49
- assert(type(speed) == "number", "Bad number")
50
+ assert(type(speed) == "number", "Bad speed")
50
51
 
51
52
  local animationId = RbxAssetUtils.toRbxAssetId(id)
52
53
 
@@ -83,6 +84,46 @@ function AnimationSlotPlayer:AdjustSpeed(id, speed)
83
84
  end
84
85
  end
85
86
 
87
+ function AnimationSlotPlayer:AdjustWeight(id, weight, fadeTime)
88
+ assert(RbxAssetUtils.isConvertableToRbxAsset(id), "Bad id")
89
+ assert(type(weight) == "number", "Bad weight")
90
+ assert(type(fadeTime) == "number" or fadeTime == nil, "Bad fadeTime")
91
+
92
+ local animationId = RbxAssetUtils.toRbxAssetId(id)
93
+
94
+ local topMaid = Maid.new()
95
+
96
+ topMaid:GiveTask(self._currentAnimationTrackData:ObserveBrio(function(data)
97
+ return data and data.animationId == animationId
98
+ end):Subscribe(function(brio)
99
+ if brio:IsDead() then
100
+ return
101
+ end
102
+
103
+ local data = brio:GetValue()
104
+ local maid = brio:ToMaid()
105
+
106
+ data.track:AdjustWeight(weight, fadeTime)
107
+
108
+ -- TODO: Use stack here?
109
+ -- TODO: Probably need rogue property mechanisms
110
+ maid:GiveTask(function()
111
+ if math.abs(data.track.Speed - weight) <= 1e-3 then
112
+ data.track:AdjustWeight(data.originalWeight, fadeTime)
113
+ end
114
+ end)
115
+ end))
116
+
117
+ -- TODO: Probably per-a-track instead of global like this
118
+ self._maid._currentWeightAdjustment = topMaid
119
+
120
+ return function()
121
+ if self._maid._currentWeightAdjustment == topMaid then
122
+ self._maid._currentWeightAdjustment = nil
123
+ end
124
+ end
125
+ end
126
+
86
127
  function AnimationSlotPlayer:Play(id, fadeTime, weight, speed, priority)
87
128
  fadeTime = fadeTime or self._defaultFadeTime.Value
88
129
  priority = priority or self._defaultAnimationPriority.Value