@quenty/characterutils 12.17.0 → 12.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,14 @@
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
+ ## [12.17.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/characterutils@12.17.0...@quenty/characterutils@12.17.1) (2025-03-21)
7
+
8
+ **Note:** Version bump only for package @quenty/characterutils
9
+
10
+
11
+
12
+
13
+
6
14
  # [12.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/characterutils@12.16.0...@quenty/characterutils@12.17.0) (2025-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @quenty/characterutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/characterutils",
3
- "version": "12.17.0",
3
+ "version": "12.17.1",
4
4
  "description": "CharacterUtils",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,16 +25,16 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/brio": "^14.16.0",
28
+ "@quenty/brio": "^14.16.1",
29
29
  "@quenty/deferred": "^2.2.0",
30
- "@quenty/instanceutils": "^13.16.0",
30
+ "@quenty/instanceutils": "^13.16.1",
31
31
  "@quenty/loader": "^10.8.0",
32
32
  "@quenty/maid": "^3.4.0",
33
- "@quenty/promise": "^10.10.0",
34
- "@quenty/rx": "^13.16.0"
33
+ "@quenty/promise": "^10.10.1",
34
+ "@quenty/rx": "^13.16.1"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "184a407d8d7366c39009444c3c9a7023cb176471"
39
+ "gitHead": "6b7c3e15e60cdb185986207b574e2b5591261e7a"
40
40
  }
@@ -12,7 +12,7 @@ local CharacterUtils = {}
12
12
  @param player Player
13
13
  @return Humanoid? -- Nil if not found
14
14
  ]=]
15
- function CharacterUtils.getPlayerHumanoid(player)
15
+ function CharacterUtils.getPlayerHumanoid(player: Player): Humanoid?
16
16
  local character = player.Character
17
17
  if not character then
18
18
  return nil
@@ -26,7 +26,7 @@ end
26
26
  @param player Player
27
27
  @return Humanoid? -- Nil if not found
28
28
  ]=]
29
- function CharacterUtils.getAlivePlayerHumanoid(player)
29
+ function CharacterUtils.getAlivePlayerHumanoid(player: Player): Humanoid?
30
30
  local humanoid = CharacterUtils.getPlayerHumanoid(player)
31
31
  if not humanoid or humanoid.Health <= 0 then
32
32
  return nil
@@ -41,7 +41,7 @@ end
41
41
  @param player Player
42
42
  @return BasePart? -- Nil if not found
43
43
  ]=]
44
- function CharacterUtils.getAlivePlayerRootPart(player)
44
+ function CharacterUtils.getAlivePlayerRootPart(player: Player): BasePart?
45
45
  local humanoid = CharacterUtils.getPlayerHumanoid(player)
46
46
  if not humanoid or humanoid.Health <= 0 then
47
47
  return nil
@@ -55,7 +55,7 @@ end
55
55
  @param player Player
56
56
  @return BasePart? -- Nil if not found
57
57
  ]=]
58
- function CharacterUtils.getPlayerRootPart(player)
58
+ function CharacterUtils.getPlayerRootPart(player: Player): BasePart?
59
59
  local humanoid = CharacterUtils.getPlayerHumanoid(player)
60
60
  if not humanoid then
61
61
  return nil
@@ -78,7 +78,7 @@ end
78
78
 
79
79
  @param player Player
80
80
  ]=]
81
- function CharacterUtils.unequipTools(player)
81
+ function CharacterUtils.unequipTools(player: Player)
82
82
  local humanoid = CharacterUtils.getPlayerHumanoid(player)
83
83
  if humanoid then
84
84
  humanoid:UnequipTools()
@@ -106,7 +106,7 @@ end
106
106
  @param descendant Instance -- A child of the potential character.
107
107
  @return Player? -- Nil if not found
108
108
  ]=]
109
- function CharacterUtils.getPlayerFromCharacter(descendant)
109
+ function CharacterUtils.getPlayerFromCharacter(descendant: Instance): Player?
110
110
  local character = descendant
111
111
  local player = Players:GetPlayerFromCharacter(character)
112
112
 
@@ -122,4 +122,4 @@ function CharacterUtils.getPlayerFromCharacter(descendant)
122
122
  return player
123
123
  end
124
124
 
125
- return CharacterUtils
125
+ return CharacterUtils
@@ -24,7 +24,7 @@ local MAX_YIELD_TIME = 60
24
24
  @param humanoid Humanoid
25
25
  @return Promise<BasePart>
26
26
  ]=]
27
- function RootPartUtils.promiseRootPart(humanoid)
27
+ function RootPartUtils.promiseRootPart(humanoid: Humanoid)
28
28
  if humanoid.RootPart then
29
29
  return Promise.resolved(humanoid.RootPart)
30
30
  end
@@ -69,4 +69,4 @@ function RootPartUtils.promiseRootPart(humanoid)
69
69
  return promise
70
70
  end
71
71
 
72
- return RootPartUtils
72
+ return RootPartUtils
@@ -36,17 +36,29 @@ end
36
36
  @param player Player
37
37
  @return Observable<Model>
38
38
  ]=]
39
- function RxCharacterUtils.observeCharacter(player)
39
+ function RxCharacterUtils.observeCharacter(player: Player)
40
40
  return RxInstanceUtils.observeProperty(player, "Character")
41
41
  end
42
42
 
43
- function RxCharacterUtils.observeCharacterBrio(player)
43
+ --[=[
44
+ Observes a player's character property as a brio
45
+
46
+ @param player Player
47
+ @return Observable<Brio<Model>>
48
+ ]=]
49
+ function RxCharacterUtils.observeCharacterBrio(player: Player)
44
50
  return RxInstanceUtils.observePropertyBrio(player, "Character", function(character)
45
51
  return character ~= nil
46
52
  end)
47
53
  end
48
54
 
49
- function RxCharacterUtils.observeIsOfLocalCharacter(instance)
55
+ --[=[
56
+ Observes whether the instance is part of the local player's character
57
+
58
+ @param instance Instance
59
+ @return Observable<boolean>
60
+ ]=]
61
+ function RxCharacterUtils.observeIsOfLocalCharacter(instance: Instance)
50
62
  assert(typeof(instance) == "Instance", "Bad instance")
51
63
 
52
64
  local localPlayer = Players.LocalPlayer
@@ -56,8 +68,8 @@ function RxCharacterUtils.observeIsOfLocalCharacter(instance)
56
68
  end
57
69
 
58
70
  return Rx.combineLatest({
59
- character = RxCharacterUtils.observeLocalPlayerCharacter();
60
- _ancestry = RxInstanceUtils.observeAncestry(instance)
71
+ character = RxCharacterUtils.observeLocalPlayerCharacter(),
72
+ _ancestry = RxInstanceUtils.observeAncestry(instance),
61
73
  }):Pipe({
62
74
  Rx.map(function(state)
63
75
  if state.character then
@@ -65,19 +77,30 @@ function RxCharacterUtils.observeIsOfLocalCharacter(instance)
65
77
  else
66
78
  return false
67
79
  end
68
- end);
69
- Rx.distinct();
80
+ end),
81
+ Rx.distinct(),
70
82
  })
71
83
  end
72
84
 
73
- function RxCharacterUtils.observeIsOfLocalCharacterBrio(instance)
85
+ --[=[
86
+ Observes whether the instance is part of the local player's character as a brio
87
+
88
+ @param instance Instance
89
+ @return Observable<Brio<boolean>>
90
+ ]=]
91
+ function RxCharacterUtils.observeIsOfLocalCharacterBrio(instance: Instance)
74
92
  return RxCharacterUtils.observeIsOfLocalCharacter(instance):Pipe({
75
93
  RxBrioUtils.switchToBrio(function(value)
76
94
  return value
77
- end)
95
+ end),
78
96
  })
79
97
  end
80
98
 
99
+ --[=[
100
+ Observes the local player's character
101
+
102
+ @return Observable<Model>
103
+ ]=]
81
104
  function RxCharacterUtils.observeLocalPlayerCharacter()
82
105
  return RxInstanceUtils.observeProperty(Players, "LocalPlayer"):Pipe({
83
106
  Rx.switchMap(function(player)
@@ -86,8 +109,8 @@ function RxCharacterUtils.observeLocalPlayerCharacter()
86
109
  else
87
110
  return Rx.of(nil)
88
111
  end
89
- end);
90
- Rx.distinct();
112
+ end),
113
+ Rx.distinct(),
91
114
  })
92
115
  end
93
116
 
@@ -100,7 +123,7 @@ function RxCharacterUtils.observeLastHumanoidBrio(player: Player)
100
123
  return RxCharacterUtils.observeLastCharacterBrio(player):Pipe({
101
124
  RxBrioUtils.switchMapBrio(function(character)
102
125
  return RxInstanceUtils.observeLastNamedChildBrio(character, "Humanoid", "Humanoid")
103
- end);
126
+ end),
104
127
  })
105
128
  end
106
129
 
@@ -129,6 +152,7 @@ local function observeHumanoidLifetimeAsBrio(humanoid: Humanoid)
129
152
  return maid
130
153
  else
131
154
  onDeath()
155
+ return nil
132
156
  end
133
157
  end)
134
158
  end
@@ -161,7 +185,7 @@ function RxCharacterUtils.observeLastAliveHumanoidBrio(player: Player)
161
185
  return RxCharacterUtils.observeLastHumanoidBrio(player):Pipe({
162
186
  RxBrioUtils.switchMapBrio(function(humanoid)
163
187
  return observeHumanoidLifetimeAsBrio(humanoid)
164
- end);
188
+ end),
165
189
  })
166
190
  end
167
191
 
@@ -15,7 +15,7 @@ local RxRootPartUtils = {}
15
15
  @param character Model
16
16
  @return Brio<BasePart>
17
17
  ]=]
18
- function RxRootPartUtils.observeHumanoidRootPartBrio(character)
18
+ function RxRootPartUtils.observeHumanoidRootPartBrio(character: Model)
19
19
  -- let's make a reasonable assumption here about name not changing
20
20
  return RxInstanceUtils.observeChildrenBrio(character, function(part)
21
21
  return part:IsA("BasePart") and part.Name == "HumanoidRootPart"
@@ -28,12 +28,12 @@ end
28
28
  @param humanoid Humanoid
29
29
  @return Brio<BasePart>
30
30
  ]=]
31
- function RxRootPartUtils.observeHumanoidRootPartBrioFromHumanoid(humanoid)
31
+ function RxRootPartUtils.observeHumanoidRootPartBrioFromHumanoid(humanoid: Humanoid)
32
32
  return RxInstanceUtils.observeParentBrio(humanoid):Pipe({
33
33
  RxBrioUtils.switchMapBrio(function(character)
34
34
  return RxRootPartUtils.observeHumanoidRootPartBrio(character)
35
- end)
35
+ end),
36
36
  })
37
37
  end
38
38
 
39
- return RxRootPartUtils
39
+ return RxRootPartUtils