@quenty/teamutils 10.17.0 → 10.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 +11 -0
- package/package.json +7 -7
- package/src/Shared/RxTeamUtils.lua +28 -28
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
|
+
## [10.17.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/teamutils@10.17.0...@quenty/teamutils@10.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
|
# [10.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/teamutils@10.16.2...@quenty/teamutils@10.17.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/teamutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/teamutils",
|
|
3
|
-
"version": "10.17.
|
|
3
|
+
"version": "10.17.1",
|
|
4
4
|
"description": "Team utility methods",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/brio": "^14.17.
|
|
32
|
-
"@quenty/instanceutils": "^13.17.
|
|
33
|
-
"@quenty/loader": "^10.8.
|
|
34
|
-
"@quenty/maid": "^3.4.
|
|
35
|
-
"@quenty/rx": "^13.17.
|
|
31
|
+
"@quenty/brio": "^14.17.1",
|
|
32
|
+
"@quenty/instanceutils": "^13.17.1",
|
|
33
|
+
"@quenty/loader": "^10.8.1",
|
|
34
|
+
"@quenty/maid": "^3.4.1",
|
|
35
|
+
"@quenty/rx": "^13.17.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
38
38
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Helper methods involving teams on Roblox.
|
|
3
4
|
@class RxTeamUtils
|
|
@@ -17,10 +18,10 @@ local Rx = require("Rx")
|
|
|
17
18
|
|
|
18
19
|
local RxTeamUtils = {}
|
|
19
20
|
|
|
20
|
-
function RxTeamUtils.observePlayerTeam(player)
|
|
21
|
+
function RxTeamUtils.observePlayerTeam(player: Player): Observable.Observable<Team?>
|
|
21
22
|
return Rx.combineLatest({
|
|
22
|
-
team = RxInstanceUtils.observeProperty(player, "Team")
|
|
23
|
-
neutral = RxInstanceUtils.observeProperty(player, "Neutral")
|
|
23
|
+
team = RxInstanceUtils.observeProperty(player, "Team"),
|
|
24
|
+
neutral = RxInstanceUtils.observeProperty(player, "Neutral"),
|
|
24
25
|
}):Pipe({
|
|
25
26
|
Rx.map(function(state)
|
|
26
27
|
if state.neutral then
|
|
@@ -28,20 +29,20 @@ function RxTeamUtils.observePlayerTeam(player)
|
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
return state.team
|
|
31
|
-
end)
|
|
32
|
-
})
|
|
32
|
+
end) :: any,
|
|
33
|
+
}) :: any
|
|
33
34
|
end
|
|
34
35
|
|
|
35
|
-
function RxTeamUtils.observePlayerTeamColor(player)
|
|
36
|
+
function RxTeamUtils.observePlayerTeamColor(player: Player): Observable.Observable<BrickColor?>
|
|
36
37
|
return RxTeamUtils.observePlayerTeam(player):Pipe({
|
|
37
|
-
Rx.switchMap(function(team)
|
|
38
|
+
Rx.switchMap(function(team: Team?): any
|
|
38
39
|
if team then
|
|
39
40
|
return RxInstanceUtils.observeProperty(team, "TeamColor")
|
|
40
41
|
else
|
|
41
42
|
return Rx.of(nil)
|
|
42
43
|
end
|
|
43
|
-
end)
|
|
44
|
-
})
|
|
44
|
+
end) :: any,
|
|
45
|
+
}) :: any
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
--[=[
|
|
@@ -50,13 +51,13 @@ end
|
|
|
50
51
|
@param team Team
|
|
51
52
|
@return Observable<Brio<Player>>
|
|
52
53
|
]=]
|
|
53
|
-
function RxTeamUtils.observePlayersForTeamBrio(team)
|
|
54
|
+
function RxTeamUtils.observePlayersForTeamBrio(team: Team): Observable.Observable<Brio.Brio<Player>>
|
|
54
55
|
assert(typeof(team) == "Instance" and team:IsA("Team"), "Bad team")
|
|
55
56
|
|
|
56
57
|
return Observable.new(function(sub)
|
|
57
58
|
local maid = Maid.new()
|
|
58
59
|
|
|
59
|
-
local function handlePlayer(player)
|
|
60
|
+
local function handlePlayer(player: Player)
|
|
60
61
|
local brio = Brio.new(player)
|
|
61
62
|
maid[player] = brio
|
|
62
63
|
|
|
@@ -68,12 +69,12 @@ function RxTeamUtils.observePlayersForTeamBrio(team)
|
|
|
68
69
|
maid[player] = nil
|
|
69
70
|
end))
|
|
70
71
|
|
|
71
|
-
for _, player in
|
|
72
|
+
for _, player in team:GetPlayers() do
|
|
72
73
|
handlePlayer(player)
|
|
73
74
|
end
|
|
74
75
|
|
|
75
76
|
return maid
|
|
76
|
-
end)
|
|
77
|
+
end) :: any
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
--[=[
|
|
@@ -82,13 +83,13 @@ end
|
|
|
82
83
|
@param teamColor BrickColor
|
|
83
84
|
@return Observable<Brio<Player>>
|
|
84
85
|
]=]
|
|
85
|
-
function RxTeamUtils.observeEnemyTeamColorPlayersBrio(teamColor)
|
|
86
|
+
function RxTeamUtils.observeEnemyTeamColorPlayersBrio(teamColor: BrickColor): Observable.Observable<Brio.Brio<Player>>
|
|
86
87
|
assert(typeof(teamColor) == "BrickColor", "Bad teamColor")
|
|
87
88
|
|
|
88
89
|
return Observable.new(function(sub)
|
|
89
90
|
local topMaid = Maid.new()
|
|
90
91
|
|
|
91
|
-
local function handlePlayerTeamChanged(playerMaid, player)
|
|
92
|
+
local function handlePlayerTeamChanged(playerMaid: Maid.Maid, player: Player)
|
|
92
93
|
if player.Team and player.Team.TeamColor.Number == teamColor.Number then
|
|
93
94
|
playerMaid[player] = nil
|
|
94
95
|
else
|
|
@@ -98,7 +99,7 @@ function RxTeamUtils.observeEnemyTeamColorPlayersBrio(teamColor)
|
|
|
98
99
|
end
|
|
99
100
|
end
|
|
100
101
|
|
|
101
|
-
local function handlePlayer(player)
|
|
102
|
+
local function handlePlayer(player: Player)
|
|
102
103
|
local maid = Maid.new()
|
|
103
104
|
|
|
104
105
|
handlePlayerTeamChanged(maid, player)
|
|
@@ -114,22 +115,21 @@ function RxTeamUtils.observeEnemyTeamColorPlayersBrio(teamColor)
|
|
|
114
115
|
topMaid[player] = nil
|
|
115
116
|
end))
|
|
116
117
|
|
|
117
|
-
for _, player in
|
|
118
|
+
for _, player in Players:GetPlayers() do
|
|
118
119
|
handlePlayer(player)
|
|
119
120
|
end
|
|
120
121
|
|
|
121
122
|
return topMaid
|
|
122
|
-
end)
|
|
123
|
+
end) :: any
|
|
123
124
|
end
|
|
124
125
|
|
|
125
|
-
|
|
126
126
|
--[=[
|
|
127
127
|
Observes all players for a team color (given they have a team)
|
|
128
128
|
|
|
129
129
|
@param teamColor BrickColor
|
|
130
130
|
@return Observable<Brio<Player>>
|
|
131
131
|
]=]
|
|
132
|
-
function RxTeamUtils.observePlayersForTeamColorBrio(teamColor)
|
|
132
|
+
function RxTeamUtils.observePlayersForTeamColorBrio(teamColor: BrickColor): Observable.Observable<Brio.Brio<Player>>
|
|
133
133
|
assert(typeof(teamColor) == "BrickColor", "Bad teamColor")
|
|
134
134
|
|
|
135
135
|
return RxTeamUtils.observeTeamsForColorBrio(teamColor):Pipe({
|
|
@@ -137,8 +137,8 @@ function RxTeamUtils.observePlayersForTeamColorBrio(teamColor)
|
|
|
137
137
|
-- with the same color so no great solution here.
|
|
138
138
|
RxBrioUtils.switchMapBrio(function(team)
|
|
139
139
|
return RxTeamUtils.observePlayersForTeamBrio(team)
|
|
140
|
-
end)
|
|
141
|
-
})
|
|
140
|
+
end),
|
|
141
|
+
}) :: any
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
--[=[
|
|
@@ -147,7 +147,7 @@ end
|
|
|
147
147
|
@param teamColor BrickColor
|
|
148
148
|
@return Observable<Brio<Team>>
|
|
149
149
|
]=]
|
|
150
|
-
function RxTeamUtils.observeTeamsForColorBrio(teamColor)
|
|
150
|
+
function RxTeamUtils.observeTeamsForColorBrio(teamColor: BrickColor): Observable.Observable<Brio.Brio<Team>>
|
|
151
151
|
assert(typeof(teamColor) == "BrickColor", "Bad teamColor")
|
|
152
152
|
|
|
153
153
|
return Observable.new(function(sub)
|
|
@@ -168,7 +168,7 @@ function RxTeamUtils.observeTeamsForColorBrio(teamColor)
|
|
|
168
168
|
|
|
169
169
|
sub:Fire(result)
|
|
170
170
|
else
|
|
171
|
-
maid._current = nil
|
|
171
|
+
maid._current = nil :: any
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
174
|
team:GetPropertyChangedSignal("TeamColor"):Connect(update)
|
|
@@ -176,7 +176,7 @@ function RxTeamUtils.observeTeamsForColorBrio(teamColor)
|
|
|
176
176
|
end))
|
|
177
177
|
|
|
178
178
|
return topMaid
|
|
179
|
-
end)
|
|
179
|
+
end) :: any
|
|
180
180
|
end
|
|
181
181
|
|
|
182
182
|
--[=[
|
|
@@ -184,7 +184,7 @@ end
|
|
|
184
184
|
|
|
185
185
|
@return Observable<Brio<Team>>
|
|
186
186
|
]=]
|
|
187
|
-
function RxTeamUtils.observeTeamsBrio()
|
|
187
|
+
function RxTeamUtils.observeTeamsBrio(): Observable.Observable<Brio.Brio<Team>>
|
|
188
188
|
return Observable.new(function(sub)
|
|
189
189
|
local maid = Maid.new()
|
|
190
190
|
|
|
@@ -202,12 +202,12 @@ function RxTeamUtils.observeTeamsBrio()
|
|
|
202
202
|
maid[inst] = nil
|
|
203
203
|
end))
|
|
204
204
|
|
|
205
|
-
for _, team in
|
|
205
|
+
for _, team in Teams:GetTeams() do
|
|
206
206
|
handleTeam(team)
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
return maid
|
|
210
|
-
end)
|
|
210
|
+
end) :: any
|
|
211
211
|
end
|
|
212
212
|
|
|
213
213
|
return RxTeamUtils
|