@rbxts/covenant 3.1.0 → 3.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/package.json +1 -1
- package/src/covenant.d.ts +2 -1
- package/src/covenant.luau +20 -31
package/package.json
CHANGED
package/src/covenant.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare class Covenant {
|
|
|
20
20
|
private systems;
|
|
21
21
|
private worldChangesForReplication;
|
|
22
22
|
private worldChangesForPrediction;
|
|
23
|
+
private components;
|
|
23
24
|
private undefinedStringifiedComponents;
|
|
24
25
|
private replicatedStringifiedComponents;
|
|
25
26
|
private predictedStringifiedComponents;
|
|
@@ -69,7 +70,7 @@ export declare class Covenant {
|
|
|
69
70
|
defineIdentity<T extends defined>({ identityComponent, replicated, lifetime, factory, }: {
|
|
70
71
|
identityComponent: Entity<T>;
|
|
71
72
|
replicated: boolean;
|
|
72
|
-
lifetime: (entity: Entity, state: T, despawn: () => void) => (() => void);
|
|
73
|
+
lifetime: (entity: Entity, state: T, despawn: () => void) => (() => void) | undefined;
|
|
73
74
|
factory: (spawnEntity: (state: T) => void) => void;
|
|
74
75
|
}): void;
|
|
75
76
|
private worldEntity;
|
package/src/covenant.luau
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local exports = {}
|
|
4
|
-
local
|
|
5
|
-
local ChildOf = _jecs.ChildOf
|
|
6
|
-
local pair = _jecs.pair
|
|
7
|
-
local world = _jecs.world
|
|
4
|
+
local world = TS.import(script, TS.getModule(script, "@rbxts", "jecs").jecs).world
|
|
8
5
|
local _services = TS.import(script, TS.getModule(script, "@rbxts", "services"))
|
|
9
6
|
local Players = _services.Players
|
|
10
7
|
local RunService = _services.RunService
|
|
@@ -44,6 +41,7 @@ do
|
|
|
44
41
|
self.systems = EventMap.new()
|
|
45
42
|
self.worldChangesForReplication = {}
|
|
46
43
|
self.worldChangesForPrediction = {}
|
|
44
|
+
self.components = {}
|
|
47
45
|
self.undefinedStringifiedComponents = {}
|
|
48
46
|
self.replicatedStringifiedComponents = {}
|
|
49
47
|
self.predictedStringifiedComponents = {}
|
|
@@ -476,36 +474,23 @@ do
|
|
|
476
474
|
if not self:worldContains(entity) then
|
|
477
475
|
return nil
|
|
478
476
|
end
|
|
479
|
-
local
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
local _result = toDelete[_length]
|
|
485
|
-
toDelete[_length] = nil
|
|
486
|
-
-- ▲ Array.pop ▲
|
|
487
|
-
local currentEntity = _result
|
|
488
|
-
if processed[currentEntity] ~= nil or not self:worldContains(currentEntity) then
|
|
489
|
-
continue
|
|
490
|
-
end
|
|
491
|
-
processed[currentEntity] = true
|
|
492
|
-
for childEntity in self:worldQuery(pair(ChildOf, currentEntity)) do
|
|
493
|
-
table.insert(toDelete, childEntity)
|
|
477
|
+
local _exp = self.components
|
|
478
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
479
|
+
local _callback = function(c)
|
|
480
|
+
if self:worldHas(c) then
|
|
481
|
+
self:worldSet(entity, c, nil)
|
|
494
482
|
end
|
|
495
483
|
end
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
self._world:delete(entityToDelete)
|
|
499
|
-
if RunService:IsServer() then
|
|
500
|
-
local _worldChangesForReplication = self.worldChangesForReplication
|
|
501
|
-
local _arg0 = tostring(entityToDelete)
|
|
502
|
-
_worldChangesForReplication[_arg0] = Delete
|
|
503
|
-
end
|
|
484
|
+
for _k, _v in _exp do
|
|
485
|
+
_callback(_v, _k - 1, _exp)
|
|
504
486
|
end
|
|
505
|
-
|
|
506
|
-
|
|
487
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
488
|
+
self._world:delete(entity)
|
|
489
|
+
if RunService:IsServer() then
|
|
490
|
+
local _worldChangesForReplication = self.worldChangesForReplication
|
|
491
|
+
local _arg0 = tostring(entity)
|
|
492
|
+
_worldChangesForReplication[_arg0] = Delete
|
|
507
493
|
end
|
|
508
|
-
-- ▲ ReadonlySet.forEach ▲
|
|
509
494
|
end
|
|
510
495
|
function Covenant:worldComponent()
|
|
511
496
|
self:preventPostStartCall()
|
|
@@ -513,6 +498,8 @@ do
|
|
|
513
498
|
local _undefinedStringifiedComponents = self.undefinedStringifiedComponents
|
|
514
499
|
local _arg0 = tostring(c)
|
|
515
500
|
_undefinedStringifiedComponents[_arg0] = true
|
|
501
|
+
local _exp = self.components
|
|
502
|
+
table.insert(_exp, c)
|
|
516
503
|
if RunService:IsStudio() and self.logging then
|
|
517
504
|
print(`{(debug.info(2, "sl"))}:{c}`)
|
|
518
505
|
end
|
|
@@ -681,7 +668,9 @@ do
|
|
|
681
668
|
local cleanup = function() end
|
|
682
669
|
cleanup = lifetime(entity, state, function()
|
|
683
670
|
self:worldDelete(entity)
|
|
684
|
-
cleanup
|
|
671
|
+
if cleanup ~= nil then
|
|
672
|
+
cleanup()
|
|
673
|
+
end
|
|
685
674
|
end)
|
|
686
675
|
end)
|
|
687
676
|
end
|