@rbxts/covenant 1.5.9 → 1.5.11
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/package.json +1 -1
- package/src/covenant.luau +103 -68
package/package.json
CHANGED
package/src/covenant.luau
CHANGED
|
@@ -16,6 +16,7 @@ local _helpers = TS.import(script, script.Parent, "helpers")
|
|
|
16
16
|
local compareMaps = _helpers.compareMaps
|
|
17
17
|
local turnSetWithIdentifierToMap = _helpers.turnSetWithIdentifierToMap
|
|
18
18
|
local EventMap = TS.import(script, script.Parent, "dataStructureWithEvents").EventMap
|
|
19
|
+
local BIG_PRIORITY = 10000000
|
|
19
20
|
for _k, _v in TS.import(script, TS.getModule(script, "@rbxts", "jecs").jecs) or {} do
|
|
20
21
|
exports[_k] = _v
|
|
21
22
|
end
|
|
@@ -88,7 +89,7 @@ do
|
|
|
88
89
|
local currentWorldChanges = self.worldChangesForPrediction
|
|
89
90
|
self.worldChangesForPrediction = {}
|
|
90
91
|
self.predictionSend(currentWorldChanges)
|
|
91
|
-
end,
|
|
92
|
+
end, BIG_PRIORITY + 1)
|
|
92
93
|
end
|
|
93
94
|
function Covenant:forEachComponentChanges(player, worldReconciliation, componentChanges, stringifiedComponent)
|
|
94
95
|
local component = tonumber(stringifiedComponent)
|
|
@@ -137,38 +138,56 @@ do
|
|
|
137
138
|
-- ▲ ReadonlyMap.forEach ▲
|
|
138
139
|
end
|
|
139
140
|
function Covenant:setupPredictionServer()
|
|
141
|
+
local changes = {}
|
|
140
142
|
self.predictionConnect(function(player, worldChanges)
|
|
141
|
-
local
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return nil
|
|
148
|
-
end
|
|
149
|
-
self:forEachComponentChanges(player, worldReconciliation, componentChanges, stringifiedComponent)
|
|
150
|
-
end
|
|
151
|
-
for _k, _v in worldChanges do
|
|
152
|
-
_callback(_v, _k, worldChanges)
|
|
143
|
+
local _arg0 = { player, worldChanges }
|
|
144
|
+
table.insert(changes, _arg0)
|
|
145
|
+
end)
|
|
146
|
+
self:schedule(RunService.Heartbeat, function()
|
|
147
|
+
if #changes == 0 then
|
|
148
|
+
return nil
|
|
153
149
|
end
|
|
154
|
-
--
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
local
|
|
158
|
-
local
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
151
|
+
local _callback = function(_param)
|
|
152
|
+
local player = _param[1]
|
|
153
|
+
local worldChanges = _param[2]
|
|
154
|
+
local worldReconciliation = {}
|
|
155
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
156
|
+
local _callback_1 = function(componentChanges, stringifiedComponent)
|
|
157
|
+
local _internalStringifiedComponents = self.internalStringifiedComponents
|
|
158
|
+
local _stringifiedComponent = stringifiedComponent
|
|
159
|
+
if not (_internalStringifiedComponents[_stringifiedComponent] ~= nil) then
|
|
160
|
+
return nil
|
|
161
|
+
end
|
|
162
|
+
self:forEachComponentChanges(player, worldReconciliation, componentChanges, stringifiedComponent)
|
|
163
|
+
end
|
|
164
|
+
for _k, _v in worldChanges do
|
|
165
|
+
_callback_1(_v, _k, worldChanges)
|
|
166
|
+
end
|
|
167
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
168
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
169
|
+
local _callback_2 = function(componentChanges, stringifiedComponent)
|
|
170
|
+
local _internalStringifiedComponents = self.internalStringifiedComponents
|
|
171
|
+
local _stringifiedComponent = stringifiedComponent
|
|
172
|
+
if _internalStringifiedComponents[_stringifiedComponent] ~= nil then
|
|
173
|
+
return nil
|
|
174
|
+
end
|
|
175
|
+
self:forEachComponentChanges(player, worldReconciliation, componentChanges, stringifiedComponent)
|
|
176
|
+
end
|
|
177
|
+
for _k, _v in worldChanges do
|
|
178
|
+
_callback_2(_v, _k, worldChanges)
|
|
179
|
+
end
|
|
180
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
181
|
+
if not (next(worldReconciliation) == nil) then
|
|
182
|
+
self.replicationSend(player, worldReconciliation)
|
|
161
183
|
end
|
|
162
|
-
self:forEachComponentChanges(player, worldReconciliation, componentChanges, stringifiedComponent)
|
|
163
|
-
end
|
|
164
|
-
for _k, _v in worldChanges do
|
|
165
|
-
_callback_1(_v, _k, worldChanges)
|
|
166
184
|
end
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
self.replicationSend(player, worldReconciliation)
|
|
185
|
+
for _k, _v in changes do
|
|
186
|
+
_callback(_v, _k - 1, changes)
|
|
170
187
|
end
|
|
171
|
-
|
|
188
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
189
|
+
table.clear(changes)
|
|
190
|
+
end, BIG_PRIORITY)
|
|
172
191
|
end
|
|
173
192
|
function Covenant:setupPrediction()
|
|
174
193
|
if RunService:IsClient() then
|
|
@@ -198,7 +217,7 @@ do
|
|
|
198
217
|
end
|
|
199
218
|
-- ▲ ReadonlyArray.forEach ▲
|
|
200
219
|
end
|
|
201
|
-
end,
|
|
220
|
+
end, BIG_PRIORITY + 1)
|
|
202
221
|
end
|
|
203
222
|
function Covenant:setupReplicationPayload()
|
|
204
223
|
self.requestPayloadConnect(function(player)
|
|
@@ -236,56 +255,72 @@ do
|
|
|
236
255
|
end)
|
|
237
256
|
end
|
|
238
257
|
function Covenant:setupReplicationClient()
|
|
258
|
+
local changes = {}
|
|
239
259
|
self.replicationConnect(function(worldChanges)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
260
|
+
local _worldChanges = worldChanges
|
|
261
|
+
table.insert(changes, _worldChanges)
|
|
262
|
+
end)
|
|
263
|
+
self:schedule(RunService.Heartbeat, function()
|
|
264
|
+
if #changes == 0 then
|
|
265
|
+
return nil
|
|
266
|
+
end
|
|
267
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
268
|
+
local _callback = function(worldChanges)
|
|
247
269
|
-- ▼ ReadonlyMap.forEach ▼
|
|
248
|
-
local _callback_1 = function(
|
|
249
|
-
local
|
|
250
|
-
|
|
251
|
-
|
|
270
|
+
local _callback_1 = function(entityData, stringifiedEntity)
|
|
271
|
+
local entity = tonumber(stringifiedEntity)
|
|
272
|
+
if entityData == Delete then
|
|
273
|
+
self:worldDelete(entity)
|
|
252
274
|
return nil
|
|
253
275
|
end
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
276
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
277
|
+
local _callback_2 = function(state, stringifiedComponent)
|
|
278
|
+
local _internalStringifiedComponents = self.internalStringifiedComponents
|
|
279
|
+
local _stringifiedComponent = stringifiedComponent
|
|
280
|
+
if not (_internalStringifiedComponents[_stringifiedComponent] ~= nil) then
|
|
281
|
+
return nil
|
|
282
|
+
end
|
|
283
|
+
local component = tonumber(stringifiedComponent)
|
|
284
|
+
if state == Remove then
|
|
285
|
+
self:worldSet(entity, component, nil, true)
|
|
286
|
+
else
|
|
287
|
+
self:worldSet(entity, component, state, true)
|
|
288
|
+
end
|
|
259
289
|
end
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
_callback_1(_v, _k, entityData)
|
|
263
|
-
end
|
|
264
|
-
-- ▲ ReadonlyMap.forEach ▲
|
|
265
|
-
-- ▼ ReadonlyMap.forEach ▼
|
|
266
|
-
local _callback_2 = function(state, stringifiedComponent)
|
|
267
|
-
local _internalStringifiedComponents = self.internalStringifiedComponents
|
|
268
|
-
local _stringifiedComponent = stringifiedComponent
|
|
269
|
-
if _internalStringifiedComponents[_stringifiedComponent] ~= nil then
|
|
270
|
-
return nil
|
|
290
|
+
for _k, _v in entityData do
|
|
291
|
+
_callback_2(_v, _k, entityData)
|
|
271
292
|
end
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
293
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
294
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
295
|
+
local _callback_3 = function(state, stringifiedComponent)
|
|
296
|
+
local _internalStringifiedComponents = self.internalStringifiedComponents
|
|
297
|
+
local _stringifiedComponent = stringifiedComponent
|
|
298
|
+
if _internalStringifiedComponents[_stringifiedComponent] ~= nil then
|
|
299
|
+
return nil
|
|
300
|
+
end
|
|
301
|
+
local component = tonumber(stringifiedComponent)
|
|
302
|
+
if state == Remove then
|
|
303
|
+
self:worldSet(entity, component, nil, true)
|
|
304
|
+
else
|
|
305
|
+
self:worldSet(entity, component, state, true)
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
for _k, _v in entityData do
|
|
309
|
+
_callback_3(_v, _k, entityData)
|
|
277
310
|
end
|
|
311
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
278
312
|
end
|
|
279
|
-
for _k, _v in
|
|
280
|
-
|
|
313
|
+
for _k, _v in worldChanges do
|
|
314
|
+
_callback_1(_v, _k, worldChanges)
|
|
281
315
|
end
|
|
282
316
|
-- ▲ ReadonlyMap.forEach ▲
|
|
283
317
|
end
|
|
284
|
-
for _k, _v in
|
|
285
|
-
_callback(_v, _k,
|
|
318
|
+
for _k, _v in changes do
|
|
319
|
+
_callback(_v, _k - 1, changes)
|
|
286
320
|
end
|
|
287
|
-
-- ▲
|
|
288
|
-
|
|
321
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
322
|
+
table.clear(changes)
|
|
323
|
+
end, BIG_PRIORITY)
|
|
289
324
|
end
|
|
290
325
|
function Covenant:setupReplication()
|
|
291
326
|
if RunService:IsServer() then
|
|
@@ -502,7 +537,7 @@ do
|
|
|
502
537
|
local _arg0 = tostring(c)
|
|
503
538
|
_undefinedStringifiedComponents[_arg0] = true
|
|
504
539
|
if RunService:IsStudio() and self.logging then
|
|
505
|
-
print(`{(debug.info(
|
|
540
|
+
print(`{(debug.info(2, "sl"))}:{c}`)
|
|
506
541
|
end
|
|
507
542
|
return c
|
|
508
543
|
end
|