@quenty/deathreport 10.21.0 → 10.21.1-canary.545.2374fb2.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 +11 -0
- package/package.json +15 -15
- package/src/Client/DeathReportServiceClient.lua +2 -1
- package/src/Client/Stats/PlayerDeathTrackerClient.lua +2 -1
- package/src/Client/Stats/PlayerKillTrackerClient.lua +2 -1
- package/src/Server/DeathReportService.lua +54 -15
- package/src/Server/DeathTrackedHumanoid.lua +1 -1
- package/src/Server/Stats/PlayerDeathTracker.lua +2 -1
- package/src/Server/Stats/PlayerKillTracker.lua +10 -7
- package/src/Server/Stats/PlayerKillTrackerAssigner.lua +5 -4
- package/src/Shared/DeathReportProcessor.lua +48 -27
- package/src/Shared/DeathReportUtils.lua +26 -11
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.21.1-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/deathreport@10.21.0...@quenty/deathreport@10.21.1-canary.545.2374fb2.0) (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.21.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/deathreport@10.20.2...@quenty/deathreport@10.21.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/deathreport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/deathreport",
|
|
3
|
-
"version": "10.21.0",
|
|
3
|
+
"version": "10.21.1-canary.545.2374fb2.0",
|
|
4
4
|
"description": "Death report service which will track the deaths of players",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@quenty/baseobject": "
|
|
33
|
-
"@quenty/binder": "
|
|
34
|
-
"@quenty/characterutils": "
|
|
35
|
-
"@quenty/humanoidkillerutils": "
|
|
36
|
-
"@quenty/loader": "
|
|
37
|
-
"@quenty/maid": "
|
|
38
|
-
"@quenty/playerhumanoidbinder": "
|
|
39
|
-
"@quenty/remoting": "
|
|
40
|
-
"@quenty/rx": "
|
|
41
|
-
"@quenty/rxbinderutils": "
|
|
42
|
-
"@quenty/servicebag": "
|
|
43
|
-
"@quenty/signal": "
|
|
44
|
-
"@quenty/table": "
|
|
32
|
+
"@quenty/baseobject": "10.8.1-canary.545.2374fb2.0",
|
|
33
|
+
"@quenty/binder": "14.19.1-canary.545.2374fb2.0",
|
|
34
|
+
"@quenty/characterutils": "12.18.1-canary.545.2374fb2.0",
|
|
35
|
+
"@quenty/humanoidkillerutils": "2.3.2-canary.545.2374fb2.0",
|
|
36
|
+
"@quenty/loader": "10.8.1-canary.545.2374fb2.0",
|
|
37
|
+
"@quenty/maid": "3.4.1-canary.545.2374fb2.0",
|
|
38
|
+
"@quenty/playerhumanoidbinder": "14.19.1-canary.545.2374fb2.0",
|
|
39
|
+
"@quenty/remoting": "12.18.1-canary.545.2374fb2.0",
|
|
40
|
+
"@quenty/rx": "13.17.1-canary.545.2374fb2.0",
|
|
41
|
+
"@quenty/rxbinderutils": "14.19.1-canary.545.2374fb2.0",
|
|
42
|
+
"@quenty/servicebag": "11.11.2-canary.545.2374fb2.0",
|
|
43
|
+
"@quenty/signal": "7.10.1-canary.545.2374fb2.0",
|
|
44
|
+
"@quenty/table": "3.7.2-canary.545.2374fb2.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
|
|
47
47
|
}
|
|
@@ -14,6 +14,7 @@ local DeathReportServiceConstants = require("DeathReportServiceConstants")
|
|
|
14
14
|
local PromiseGetRemoteEvent = require("PromiseGetRemoteEvent")
|
|
15
15
|
local DeathReportProcessor = require("DeathReportProcessor")
|
|
16
16
|
local DeathReportUtils = require("DeathReportUtils")
|
|
17
|
+
local _ServiceBag = require("ServiceBag")
|
|
17
18
|
|
|
18
19
|
-- Note: don't make this too big without upgrading the way we handle the queue
|
|
19
20
|
local MAX_DEATH_REPORTS = 5
|
|
@@ -27,7 +28,7 @@ DeathReportServiceClient.ServiceName = "DeathReportServiceClient"
|
|
|
27
28
|
|
|
28
29
|
@param serviceBag ServiceBag
|
|
29
30
|
]=]
|
|
30
|
-
function DeathReportServiceClient:Init(serviceBag)
|
|
31
|
+
function DeathReportServiceClient:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
31
32
|
assert(not self._serviceBag, "Already initialized")
|
|
32
33
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
33
34
|
self._maid = Maid.new()
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
local require = require(script.Parent.loader).load(script)
|
|
6
6
|
|
|
7
7
|
local BaseObject = require("BaseObject")
|
|
8
|
+
local _ServiceBag = require("ServiceBag")
|
|
8
9
|
|
|
9
10
|
local PlayerDeathTrackerClient = setmetatable({}, BaseObject)
|
|
10
11
|
PlayerDeathTrackerClient.ClassName = "PlayerDeathTrackerClient"
|
|
11
12
|
PlayerDeathTrackerClient.__index = PlayerDeathTrackerClient
|
|
12
13
|
|
|
13
|
-
function PlayerDeathTrackerClient.new(tracker, serviceBag)
|
|
14
|
+
function PlayerDeathTrackerClient.new(tracker, serviceBag: _ServiceBag.ServiceBag)
|
|
14
15
|
local self = setmetatable(BaseObject.new(tracker), PlayerDeathTrackerClient)
|
|
15
16
|
|
|
16
17
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
local require = require(script.Parent.loader).load(script)
|
|
6
6
|
|
|
7
7
|
local BaseObject = require("BaseObject")
|
|
8
|
+
local _ServiceBag = require("ServiceBag")
|
|
8
9
|
|
|
9
10
|
local PlayerKillTrackerClient = setmetatable({}, BaseObject)
|
|
10
11
|
PlayerKillTrackerClient.ClassName = "PlayerKillTrackerClient"
|
|
11
12
|
PlayerKillTrackerClient.__index = PlayerKillTrackerClient
|
|
12
13
|
|
|
13
|
-
function PlayerKillTrackerClient.new(tracker, serviceBag)
|
|
14
|
+
function PlayerKillTrackerClient.new(tracker, serviceBag: _ServiceBag.ServiceBag)
|
|
14
15
|
local self = setmetatable(BaseObject.new(tracker), PlayerKillTrackerClient)
|
|
15
16
|
|
|
16
17
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Centralized death reporting service which can be used to track
|
|
3
4
|
deaths.
|
|
@@ -14,25 +15,41 @@ local DeathReportServiceConstants = require("DeathReportServiceConstants")
|
|
|
14
15
|
local DeathReportUtils = require("DeathReportUtils")
|
|
15
16
|
local Maid = require("Maid")
|
|
16
17
|
local DeathReportProcessor = require("DeathReportProcessor")
|
|
18
|
+
local _ServiceBag = require("ServiceBag")
|
|
19
|
+
local _Observable = require("Observable")
|
|
17
20
|
|
|
18
21
|
local DeathReportService = {}
|
|
19
22
|
DeathReportService.ServiceName = "DeathReportService"
|
|
20
23
|
|
|
24
|
+
export type DeathReportService = typeof(setmetatable(
|
|
25
|
+
{} :: {
|
|
26
|
+
_serviceBag: any,
|
|
27
|
+
_maid: Maid.Maid,
|
|
28
|
+
NewDeathReport: Signal.Signal<DeathReportUtils.DeathReport>,
|
|
29
|
+
_remoteEvent: RemoteEvent,
|
|
30
|
+
_reportProcessor: DeathReportProcessor.DeathReportProcessor,
|
|
31
|
+
_weaponDataRetrievers: { GetWeaponData },
|
|
32
|
+
},
|
|
33
|
+
{ __index = DeathReportService }
|
|
34
|
+
))
|
|
35
|
+
|
|
36
|
+
export type GetWeaponData = (humanoid: Humanoid) -> DeathReportUtils.WeaponData?
|
|
37
|
+
|
|
21
38
|
--[=[
|
|
22
39
|
Initializes the DeathReportService. Should be done via [ServiceBag].
|
|
23
40
|
|
|
24
41
|
@param serviceBag ServiceBag
|
|
25
42
|
]=]
|
|
26
|
-
function DeathReportService
|
|
43
|
+
function DeathReportService.Init(self: DeathReportService, serviceBag: _ServiceBag.ServiceBag)
|
|
27
44
|
assert(not self._serviceBag, "Already initialized")
|
|
28
45
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
29
46
|
self._maid = Maid.new()
|
|
30
47
|
|
|
31
48
|
-- Internal
|
|
32
|
-
self._serviceBag:GetService(require("DeathReportBindersServer"))
|
|
49
|
+
self._serviceBag:GetService((require :: any)("DeathReportBindersServer"))
|
|
33
50
|
|
|
34
51
|
-- Export
|
|
35
|
-
self.NewDeathReport = self._maid:Add(Signal.new())
|
|
52
|
+
self.NewDeathReport = self._maid:Add(Signal.new()) :: any
|
|
36
53
|
|
|
37
54
|
-- State
|
|
38
55
|
self._remoteEvent = GetRemoteEvent(DeathReportServiceConstants.REMOTE_EVENT_NAME)
|
|
@@ -41,7 +58,7 @@ function DeathReportService:Init(serviceBag)
|
|
|
41
58
|
self._weaponDataRetrievers = {}
|
|
42
59
|
end
|
|
43
60
|
|
|
44
|
-
function DeathReportService
|
|
61
|
+
function DeathReportService.AddWeaponDataRetriever(self: DeathReportService, getWeaponData: GetWeaponData)
|
|
45
62
|
table.insert(self._weaponDataRetrievers, getWeaponData)
|
|
46
63
|
|
|
47
64
|
return function()
|
|
@@ -52,10 +69,10 @@ function DeathReportService:AddWeaponDataRetriever(getWeaponData)
|
|
|
52
69
|
end
|
|
53
70
|
end
|
|
54
71
|
|
|
55
|
-
function DeathReportService
|
|
72
|
+
function DeathReportService.FindWeaponData(self: DeathReportService, humanoid: Humanoid): DeathReportUtils.WeaponData?
|
|
56
73
|
assert(typeof(humanoid) == "Instance", "Bad humanoid")
|
|
57
74
|
|
|
58
|
-
for _, item in
|
|
75
|
+
for _, item in self._weaponDataRetrievers do
|
|
59
76
|
local result = item(humanoid)
|
|
60
77
|
if result then
|
|
61
78
|
assert(DeathReportUtils.isWeaponData(result), "Failed to return valid weaponData")
|
|
@@ -73,7 +90,10 @@ end
|
|
|
73
90
|
@param player Player
|
|
74
91
|
@return Observable<DeathReport>
|
|
75
92
|
]=]
|
|
76
|
-
function DeathReportService
|
|
93
|
+
function DeathReportService.ObservePlayerKillerReports(
|
|
94
|
+
self: DeathReportService,
|
|
95
|
+
player: Player
|
|
96
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
77
97
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
78
98
|
|
|
79
99
|
return self._reportProcessor:ObservePlayerKillerReports(player)
|
|
@@ -85,7 +105,10 @@ end
|
|
|
85
105
|
@param player Player
|
|
86
106
|
@return Observable<DeathReport>
|
|
87
107
|
]=]
|
|
88
|
-
function DeathReportService
|
|
108
|
+
function DeathReportService.ObservePlayerDeathReports(
|
|
109
|
+
self: DeathReportService,
|
|
110
|
+
player: Player
|
|
111
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
89
112
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
90
113
|
|
|
91
114
|
return self._reportProcessor:ObservePlayerDeathReports(player)
|
|
@@ -97,7 +120,10 @@ end
|
|
|
97
120
|
@param humanoid Humanoid
|
|
98
121
|
@return Observable<DeathReport>
|
|
99
122
|
]=]
|
|
100
|
-
function DeathReportService
|
|
123
|
+
function DeathReportService.ObserveHumanoidKillerReports(
|
|
124
|
+
self: DeathReportService,
|
|
125
|
+
humanoid: Humanoid
|
|
126
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
101
127
|
assert(typeof(humanoid) == "Instance" and humanoid:IsA("Humanoid"), "Bad humanoid")
|
|
102
128
|
|
|
103
129
|
return self._reportProcessor:ObserveHumanoidKillerReports(humanoid)
|
|
@@ -109,7 +135,10 @@ end
|
|
|
109
135
|
@param humanoid Humanoid
|
|
110
136
|
@return Observable<DeathReport>
|
|
111
137
|
]=]
|
|
112
|
-
function DeathReportService
|
|
138
|
+
function DeathReportService.ObserveHumanoidDeathReports(
|
|
139
|
+
self: DeathReportService,
|
|
140
|
+
humanoid: Humanoid
|
|
141
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
113
142
|
assert(typeof(humanoid) == "Instance" and humanoid:IsA("Humanoid"), "Bad humanoid")
|
|
114
143
|
|
|
115
144
|
return self._reportProcessor:ObserveHumanoidDeathReports(humanoid)
|
|
@@ -121,7 +150,10 @@ end
|
|
|
121
150
|
@param character Model
|
|
122
151
|
@return Observable<DeathReport>
|
|
123
152
|
]=]
|
|
124
|
-
function DeathReportService
|
|
153
|
+
function DeathReportService.ObserveCharacterKillerReports(
|
|
154
|
+
self: DeathReportService,
|
|
155
|
+
character: Model
|
|
156
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
125
157
|
assert(typeof(character) == "Instance" and character:IsA("Model"), "Bad character")
|
|
126
158
|
|
|
127
159
|
return self._reportProcessor:ObserveCharacterKillerReports(character)
|
|
@@ -133,7 +165,10 @@ end
|
|
|
133
165
|
@param character Model
|
|
134
166
|
@return Observable<DeathReport>
|
|
135
167
|
]=]
|
|
136
|
-
function DeathReportService
|
|
168
|
+
function DeathReportService.ObserveCharacterDeathReports(
|
|
169
|
+
self: DeathReportService,
|
|
170
|
+
character: Model
|
|
171
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
137
172
|
assert(typeof(character) == "Instance" and character:IsA("Model"), "Bad character")
|
|
138
173
|
|
|
139
174
|
return self._reportProcessor:ObserveCharacterDeathReports(character)
|
|
@@ -146,7 +181,11 @@ end
|
|
|
146
181
|
@param humanoid Humanoid -- Humanoid that died
|
|
147
182
|
@param weaponData WeaponData? -- Weapon data to report
|
|
148
183
|
]=]
|
|
149
|
-
function DeathReportService
|
|
184
|
+
function DeathReportService.ReportHumanoidDeath(
|
|
185
|
+
self: DeathReportService,
|
|
186
|
+
humanoid: Humanoid,
|
|
187
|
+
weaponData: DeathReportUtils.WeaponData?
|
|
188
|
+
)
|
|
150
189
|
assert(typeof(humanoid) == "Instance", "Bad humanoid")
|
|
151
190
|
|
|
152
191
|
local report = DeathReportUtils.fromDeceasedHumanoid(humanoid, weaponData or self:FindWeaponData(humanoid))
|
|
@@ -154,7 +193,7 @@ function DeathReportService:ReportHumanoidDeath(humanoid, weaponData)
|
|
|
154
193
|
self:ReportDeathReport(report)
|
|
155
194
|
end
|
|
156
195
|
|
|
157
|
-
function DeathReportService
|
|
196
|
+
function DeathReportService.ReportDeathReport(self: DeathReportService, deathReport: DeathReportUtils.DeathReport)
|
|
158
197
|
assert(DeathReportUtils.isDeathReport(deathReport), "Bad deathReport")
|
|
159
198
|
|
|
160
199
|
-- Notify services
|
|
@@ -166,7 +205,7 @@ function DeathReportService:ReportDeathReport(deathReport)
|
|
|
166
205
|
self._remoteEvent:FireAllClients(deathReport)
|
|
167
206
|
end
|
|
168
207
|
|
|
169
|
-
function DeathReportService
|
|
208
|
+
function DeathReportService.Destroy(self: DeathReportService)
|
|
170
209
|
self._maid:DoCleaning()
|
|
171
210
|
end
|
|
172
211
|
|
|
@@ -11,7 +11,7 @@ local DeathTrackedHumanoid = setmetatable({}, BaseObject)
|
|
|
11
11
|
DeathTrackedHumanoid.ClassName = "DeathTrackedHumanoid"
|
|
12
12
|
DeathTrackedHumanoid.__index = DeathTrackedHumanoid
|
|
13
13
|
|
|
14
|
-
function DeathTrackedHumanoid.new(humanoid, serviceBag)
|
|
14
|
+
function DeathTrackedHumanoid.new(humanoid: Humanoid, serviceBag)
|
|
15
15
|
local self = setmetatable(BaseObject.new(humanoid), DeathTrackedHumanoid)
|
|
16
16
|
|
|
17
17
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
@@ -6,12 +6,13 @@ local require = require(script.Parent.loader).load(script)
|
|
|
6
6
|
|
|
7
7
|
local BaseObject = require("BaseObject")
|
|
8
8
|
local DeathReportService = require("DeathReportService")
|
|
9
|
+
local _ServiceBag = require("ServiceBag")
|
|
9
10
|
|
|
10
11
|
local PlayerDeathTracker = setmetatable({}, BaseObject)
|
|
11
12
|
PlayerDeathTracker.ClassName = "PlayerDeathTracker"
|
|
12
13
|
PlayerDeathTracker.__index = PlayerDeathTracker
|
|
13
14
|
|
|
14
|
-
function PlayerDeathTracker.new(scoreObject, serviceBag)
|
|
15
|
+
function PlayerDeathTracker.new(scoreObject, serviceBag: _ServiceBag.ServiceBag)
|
|
15
16
|
local self = setmetatable(BaseObject.new(scoreObject), PlayerDeathTracker)
|
|
16
17
|
|
|
17
18
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
@@ -6,12 +6,13 @@ local require = require(script.Parent.loader).load(script)
|
|
|
6
6
|
|
|
7
7
|
local BaseObject = require("BaseObject")
|
|
8
8
|
local DeathReportService = require("DeathReportService")
|
|
9
|
+
local _ServiceBag = require("ServiceBag")
|
|
9
10
|
|
|
10
11
|
local PlayerKillTracker = setmetatable({}, BaseObject)
|
|
11
12
|
PlayerKillTracker.ClassName = "PlayerKillTracker"
|
|
12
13
|
PlayerKillTracker.__index = PlayerKillTracker
|
|
13
14
|
|
|
14
|
-
function PlayerKillTracker.new(scoreObject, serviceBag)
|
|
15
|
+
function PlayerKillTracker.new(scoreObject, serviceBag: _ServiceBag.ServiceBag)
|
|
15
16
|
local self = setmetatable(BaseObject.new(scoreObject), PlayerKillTracker)
|
|
16
17
|
|
|
17
18
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
@@ -20,10 +21,12 @@ function PlayerKillTracker.new(scoreObject, serviceBag)
|
|
|
20
21
|
self._player = self._obj.Parent
|
|
21
22
|
assert(self._player and self._player:IsA("Player"), "Bad player")
|
|
22
23
|
|
|
23
|
-
self._maid:GiveTask(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
self._maid:GiveTask(
|
|
25
|
+
self._deathReportService:ObservePlayerKillerReports(self._player):Subscribe(function(deathReport)
|
|
26
|
+
assert(deathReport.killerPlayer == self._player, "Bad player")
|
|
27
|
+
self._obj.Value = self._obj.Value + 1
|
|
28
|
+
end)
|
|
29
|
+
)
|
|
27
30
|
|
|
28
31
|
return self
|
|
29
32
|
end
|
|
@@ -32,11 +35,11 @@ function PlayerKillTracker:GetKillValue()
|
|
|
32
35
|
return self._obj
|
|
33
36
|
end
|
|
34
37
|
|
|
35
|
-
function PlayerKillTracker:GetPlayer()
|
|
38
|
+
function PlayerKillTracker:GetPlayer(): Player
|
|
36
39
|
return self._obj.Parent
|
|
37
40
|
end
|
|
38
41
|
|
|
39
|
-
function PlayerKillTracker:GetKills()
|
|
42
|
+
function PlayerKillTracker:GetKills(): number
|
|
40
43
|
return self._obj.Value
|
|
41
44
|
end
|
|
42
45
|
|
|
@@ -10,12 +10,13 @@ local BaseObject = require("BaseObject")
|
|
|
10
10
|
local Maid = require("Maid")
|
|
11
11
|
local PlayerKillTrackerUtils = require("PlayerKillTrackerUtils")
|
|
12
12
|
local DeathReportBindersServer = require("DeathReportBindersServer")
|
|
13
|
+
local _ServiceBag = require("ServiceBag")
|
|
13
14
|
|
|
14
15
|
local PlayerKillTrackerAssigner = setmetatable({}, BaseObject)
|
|
15
16
|
PlayerKillTrackerAssigner.ClassName = "PlayerKillTrackerAssigner"
|
|
16
17
|
PlayerKillTrackerAssigner.__index = PlayerKillTrackerAssigner
|
|
17
18
|
|
|
18
|
-
function PlayerKillTrackerAssigner.new(serviceBag)
|
|
19
|
+
function PlayerKillTrackerAssigner.new(serviceBag: _ServiceBag.ServiceBag)
|
|
19
20
|
local self = setmetatable(BaseObject.new(), PlayerKillTrackerAssigner)
|
|
20
21
|
|
|
21
22
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
@@ -30,14 +31,14 @@ function PlayerKillTrackerAssigner.new(serviceBag)
|
|
|
30
31
|
self:_handlePlayerRemoving(player)
|
|
31
32
|
end))
|
|
32
33
|
|
|
33
|
-
for _, player in
|
|
34
|
+
for _, player in Players:GetPlayers() do
|
|
34
35
|
self:_handlePlayerAdded(player)
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
return self
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
function PlayerKillTrackerAssigner:GetPlayerKills(player)
|
|
41
|
+
function PlayerKillTrackerAssigner:GetPlayerKills(player: Player)
|
|
41
42
|
local tracker = self:GetPlayerKillTracker(player)
|
|
42
43
|
if tracker then
|
|
43
44
|
return tracker:GetKills()
|
|
@@ -46,7 +47,7 @@ function PlayerKillTrackerAssigner:GetPlayerKills(player)
|
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
49
|
|
|
49
|
-
function PlayerKillTrackerAssigner:GetPlayerKillTracker(player)
|
|
50
|
+
function PlayerKillTrackerAssigner:GetPlayerKillTracker(player: Player)
|
|
50
51
|
local trackerInstance = self._killTrackers[player]
|
|
51
52
|
if trackerInstance then
|
|
52
53
|
return self._deathReportBindersServer.PlayerKillTracker:Get(trackerInstance)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Handles shared observable subscription tables for the client and server
|
|
3
4
|
|
|
@@ -11,31 +12,33 @@ local Players = game:GetService("Players")
|
|
|
11
12
|
local BaseObject = require("BaseObject")
|
|
12
13
|
local ObservableSubscriptionTable = require("ObservableSubscriptionTable")
|
|
13
14
|
local DeathReportUtils = require("DeathReportUtils")
|
|
15
|
+
local _Observable = require("Observable")
|
|
14
16
|
|
|
15
17
|
local DeathReportProcessor = setmetatable({}, BaseObject)
|
|
16
18
|
DeathReportProcessor.ClassName = "DeathReportProcessor"
|
|
17
19
|
DeathReportProcessor.__index = DeathReportProcessor
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
self.
|
|
33
|
-
|
|
34
|
-
self.
|
|
35
|
-
self._maid:
|
|
36
|
-
|
|
37
|
-
self.
|
|
38
|
-
self._maid:
|
|
21
|
+
export type DeathReportProcessor = typeof(setmetatable(
|
|
22
|
+
{} :: {
|
|
23
|
+
_playerKillerSubTable: ObservableSubscriptionTable.ObservableSubscriptionTable<DeathReportUtils.DeathReport>,
|
|
24
|
+
_playerDeathSubTable: ObservableSubscriptionTable.ObservableSubscriptionTable<DeathReportUtils.DeathReport>,
|
|
25
|
+
_humanoidKillerSubTable: ObservableSubscriptionTable.ObservableSubscriptionTable<DeathReportUtils.DeathReport>,
|
|
26
|
+
_humanoidDeathSubTable: ObservableSubscriptionTable.ObservableSubscriptionTable<DeathReportUtils.DeathReport>,
|
|
27
|
+
_characterKillerSubTable: ObservableSubscriptionTable.ObservableSubscriptionTable<DeathReportUtils.DeathReport>,
|
|
28
|
+
_characterDeathSubTable: ObservableSubscriptionTable.ObservableSubscriptionTable<DeathReportUtils.DeathReport>,
|
|
29
|
+
},
|
|
30
|
+
{ __index = DeathReportProcessor }
|
|
31
|
+
))
|
|
32
|
+
|
|
33
|
+
function DeathReportProcessor.new(): DeathReportProcessor
|
|
34
|
+
local self = setmetatable(BaseObject.new() :: any, DeathReportProcessor)
|
|
35
|
+
|
|
36
|
+
self._playerKillerSubTable = self._maid:Add(ObservableSubscriptionTable.new())
|
|
37
|
+
self._playerDeathSubTable = self._maid:Add(ObservableSubscriptionTable.new())
|
|
38
|
+
self._humanoidKillerSubTable = self._maid:Add(ObservableSubscriptionTable.new())
|
|
39
|
+
self._humanoidDeathSubTable = self._maid:Add(ObservableSubscriptionTable.new())
|
|
40
|
+
self._characterKillerSubTable = self._maid:Add(ObservableSubscriptionTable.new())
|
|
41
|
+
self._characterDeathSubTable = self._maid:Add(ObservableSubscriptionTable.new())
|
|
39
42
|
|
|
40
43
|
self._maid:GiveTask(Players.PlayerRemoving:Connect(function(player)
|
|
41
44
|
self._playerKillerSubTable:Complete(player)
|
|
@@ -51,7 +54,10 @@ end
|
|
|
51
54
|
@param player Player
|
|
52
55
|
@return Observable<DeathReport>
|
|
53
56
|
]=]
|
|
54
|
-
function DeathReportProcessor
|
|
57
|
+
function DeathReportProcessor.ObservePlayerKillerReports(
|
|
58
|
+
self: DeathReportProcessor,
|
|
59
|
+
player: Player
|
|
60
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
55
61
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
56
62
|
|
|
57
63
|
return self._playerKillerSubTable:Observe(player)
|
|
@@ -63,7 +69,10 @@ end
|
|
|
63
69
|
@param player Player
|
|
64
70
|
@return Observable<DeathReport>
|
|
65
71
|
]=]
|
|
66
|
-
function DeathReportProcessor
|
|
72
|
+
function DeathReportProcessor.ObservePlayerDeathReports(
|
|
73
|
+
self: DeathReportProcessor,
|
|
74
|
+
player: Player
|
|
75
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
67
76
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
68
77
|
|
|
69
78
|
return self._playerDeathSubTable:Observe(player)
|
|
@@ -75,7 +84,10 @@ end
|
|
|
75
84
|
@param humanoid Humanoid
|
|
76
85
|
@return Observable<DeathReport>
|
|
77
86
|
]=]
|
|
78
|
-
function DeathReportProcessor
|
|
87
|
+
function DeathReportProcessor.ObserveHumanoidDeathReports(
|
|
88
|
+
self: DeathReportProcessor,
|
|
89
|
+
humanoid: Humanoid
|
|
90
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
79
91
|
assert(typeof(humanoid) == "Instance" and humanoid:IsA("Humanoid"), "Bad humanoid")
|
|
80
92
|
|
|
81
93
|
return self._humanoidDeathSubTable:Observe(humanoid)
|
|
@@ -87,7 +99,10 @@ end
|
|
|
87
99
|
@param humanoid Humanoid
|
|
88
100
|
@return Observable<DeathReport>
|
|
89
101
|
]=]
|
|
90
|
-
function DeathReportProcessor
|
|
102
|
+
function DeathReportProcessor.ObserveHumanoidKillerReports(
|
|
103
|
+
self: DeathReportProcessor,
|
|
104
|
+
humanoid: Humanoid
|
|
105
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
91
106
|
assert(typeof(humanoid) == "Instance" and humanoid:IsA("Humanoid"), "Bad humanoid")
|
|
92
107
|
|
|
93
108
|
return self._humanoidKillerSubTable:Observe(humanoid)
|
|
@@ -99,7 +114,10 @@ end
|
|
|
99
114
|
@param character Model
|
|
100
115
|
@return Observable<DeathReport>
|
|
101
116
|
]=]
|
|
102
|
-
function DeathReportProcessor
|
|
117
|
+
function DeathReportProcessor.ObserveCharacterKillerReports(
|
|
118
|
+
self: DeathReportProcessor,
|
|
119
|
+
character: Model
|
|
120
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
103
121
|
assert(typeof(character) == "Instance" and character:IsA("Model"), "Bad character")
|
|
104
122
|
|
|
105
123
|
return self._characterKillerSubTable:Observe(character)
|
|
@@ -111,7 +129,10 @@ end
|
|
|
111
129
|
@param character Model
|
|
112
130
|
@return Observable<DeathReport>
|
|
113
131
|
]=]
|
|
114
|
-
function DeathReportProcessor
|
|
132
|
+
function DeathReportProcessor.ObserveCharacterDeathReports(
|
|
133
|
+
self: DeathReportProcessor,
|
|
134
|
+
character: Model
|
|
135
|
+
): _Observable.Observable<DeathReportUtils.DeathReport>
|
|
115
136
|
assert(typeof(character) == "Instance" and character:IsA("Model"), "Bad character")
|
|
116
137
|
|
|
117
138
|
return self._characterDeathSubTable:Observe(character)
|
|
@@ -123,7 +144,7 @@ end
|
|
|
123
144
|
|
|
124
145
|
@param deathReport DeathReport
|
|
125
146
|
]=]
|
|
126
|
-
function DeathReportProcessor
|
|
147
|
+
function DeathReportProcessor.HandleDeathReport(self: DeathReportProcessor,deathReport: DeathReportUtils.DeathReport)
|
|
127
148
|
assert(DeathReportUtils.isDeathReport(deathReport), "Bad deathreport")
|
|
128
149
|
|
|
129
150
|
if deathReport.killerPlayer then
|
|
@@ -18,14 +18,29 @@ local DeathReportUtils = {}
|
|
|
18
18
|
@param weaponData WeaponData
|
|
19
19
|
@return DeathReport
|
|
20
20
|
]=]
|
|
21
|
-
function DeathReportUtils.fromDeceasedHumanoid(humanoid: Humanoid, weaponData)
|
|
21
|
+
function DeathReportUtils.fromDeceasedHumanoid(humanoid: Humanoid, weaponData: WeaponData?)
|
|
22
22
|
assert(DeathReportUtils.isWeaponData(weaponData) or weaponData == nil, "Bad weaponData")
|
|
23
23
|
|
|
24
24
|
local killerHumanoid = HumanoidKillerUtils.getKillerHumanoidOfHumanoid(humanoid)
|
|
25
|
-
|
|
25
|
+
local character = humanoid.Parent
|
|
26
|
+
return DeathReportUtils.create(character, killerHumanoid, weaponData)
|
|
26
27
|
end
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
export type WeaponData = {
|
|
30
|
+
weaponInstance: Instance?,
|
|
31
|
+
}
|
|
32
|
+
export type DeathReport = {
|
|
33
|
+
type: "deathReport",
|
|
34
|
+
adornee: Instance,
|
|
35
|
+
humanoid: Humanoid?,
|
|
36
|
+
player: Player?,
|
|
37
|
+
killerAdornee: Instance?,
|
|
38
|
+
killerHumanoid: Humanoid?,
|
|
39
|
+
killerPlayer: Player?,
|
|
40
|
+
weaponData: WeaponData,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function DeathReportUtils.create(adornee: Instance, killerAdornee: Instance?, weaponData: WeaponData?): DeathReport
|
|
29
44
|
assert(typeof(adornee) == "Instance", "Bad adornee")
|
|
30
45
|
|
|
31
46
|
local humanoid
|
|
@@ -53,7 +68,7 @@ end
|
|
|
53
68
|
@param deathReport any
|
|
54
69
|
@return boolean
|
|
55
70
|
]=]
|
|
56
|
-
function DeathReportUtils.isDeathReport(deathReport)
|
|
71
|
+
function DeathReportUtils.isDeathReport(deathReport: any): boolean
|
|
57
72
|
return type(deathReport) == "table" and deathReport.type == "deathReport"
|
|
58
73
|
end
|
|
59
74
|
|
|
@@ -74,7 +89,7 @@ end
|
|
|
74
89
|
@param weaponInstance Instance?
|
|
75
90
|
@return WeaponData
|
|
76
91
|
]=]
|
|
77
|
-
function DeathReportUtils.createWeaponData(weaponInstance)
|
|
92
|
+
function DeathReportUtils.createWeaponData(weaponInstance: Instance?): WeaponData
|
|
78
93
|
assert(typeof(weaponInstance) == "Instance" or weaponInstance == nil, "Bad weaponInstance")
|
|
79
94
|
|
|
80
95
|
return {
|
|
@@ -88,7 +103,7 @@ end
|
|
|
88
103
|
@param deathReport DeathReport
|
|
89
104
|
@return string
|
|
90
105
|
]=]
|
|
91
|
-
function DeathReportUtils.getDeadDisplayName(deathReport)
|
|
106
|
+
function DeathReportUtils.getDeadDisplayName(deathReport: DeathReport): string?
|
|
92
107
|
if deathReport.player then
|
|
93
108
|
return deathReport.player.DisplayName
|
|
94
109
|
elseif deathReport.humanoid then
|
|
@@ -113,7 +128,7 @@ end
|
|
|
113
128
|
@param player Player
|
|
114
129
|
@return string
|
|
115
130
|
]=]
|
|
116
|
-
function DeathReportUtils.involvesPlayer(deathReport, player)
|
|
131
|
+
function DeathReportUtils.involvesPlayer(deathReport: DeathReport, player: Player): boolean
|
|
117
132
|
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
118
133
|
|
|
119
134
|
return (deathReport.player == player) or (deathReport.killerPlayer == player)
|
|
@@ -125,7 +140,7 @@ end
|
|
|
125
140
|
@param deathReport DeathReport
|
|
126
141
|
@return string?
|
|
127
142
|
]=]
|
|
128
|
-
function DeathReportUtils.getKillerDisplayName(deathReport)
|
|
143
|
+
function DeathReportUtils.getKillerDisplayName(deathReport: DeathReport): string?
|
|
129
144
|
if deathReport.killerPlayer then
|
|
130
145
|
assert(deathReport.killerPlayer:IsA("Player"), "Bad player")
|
|
131
146
|
return deathReport.killerPlayer.DisplayName
|
|
@@ -148,7 +163,7 @@ end
|
|
|
148
163
|
@param deathReport DeathReport
|
|
149
164
|
@return Color3?
|
|
150
165
|
]=]
|
|
151
|
-
function DeathReportUtils.getDeadColor(deathReport)
|
|
166
|
+
function DeathReportUtils.getDeadColor(deathReport: DeathReport): Color3?
|
|
152
167
|
if deathReport.player then
|
|
153
168
|
local team = deathReport.player.Team
|
|
154
169
|
if team then
|
|
@@ -165,7 +180,7 @@ end
|
|
|
165
180
|
@param deathReport DeathReport
|
|
166
181
|
@return Color3?
|
|
167
182
|
]=]
|
|
168
|
-
function DeathReportUtils.getKillerColor(deathReport)
|
|
183
|
+
function DeathReportUtils.getKillerColor(deathReport: DeathReport): Color3?
|
|
169
184
|
if deathReport.killerPlayer then
|
|
170
185
|
local team = deathReport.killerPlayer.Team
|
|
171
186
|
if team then
|
|
@@ -180,7 +195,7 @@ end
|
|
|
180
195
|
Gets the default color of a death report to use.
|
|
181
196
|
@return Color3
|
|
182
197
|
]=]
|
|
183
|
-
function DeathReportUtils.getDefaultColor()
|
|
198
|
+
function DeathReportUtils.getDefaultColor(): Color3
|
|
184
199
|
return DEFAULT_COLOR
|
|
185
200
|
end
|
|
186
201
|
|