@rbxts/covenant 3.2.4 → 3.3.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 +3 -1
- package/src/covenant.luau +22 -25
package/package.json
CHANGED
package/src/covenant.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class Covenant {
|
|
|
24
24
|
private undefinedStringifiedComponents;
|
|
25
25
|
private replicatedStringifiedComponents;
|
|
26
26
|
private predictedStringifiedComponents;
|
|
27
|
+
private stringfiedComponentsToNameMap;
|
|
27
28
|
private started;
|
|
28
29
|
private stringifiedComponentSubscribers;
|
|
29
30
|
private stringifiedComponentValidators;
|
|
@@ -56,7 +57,8 @@ export declare class Covenant {
|
|
|
56
57
|
private worldSet;
|
|
57
58
|
subscribeComponent<T>(component: Entity<T>, subscriber: (entity: Entity, state: T | undefined, previousState: T | undefined) => void): () => void;
|
|
58
59
|
private worldDelete;
|
|
59
|
-
worldComponent<T extends defined>(): Entity<T>;
|
|
60
|
+
worldComponent<T extends defined>(name: string): Entity<T>;
|
|
61
|
+
getComponentName(component: Entity): string;
|
|
60
62
|
worldTag(): Entity<undefined>;
|
|
61
63
|
private checkComponentDefined;
|
|
62
64
|
private defineComponentNetworkBehavior;
|
package/src/covenant.luau
CHANGED
|
@@ -45,6 +45,7 @@ do
|
|
|
45
45
|
self.undefinedStringifiedComponents = {}
|
|
46
46
|
self.replicatedStringifiedComponents = {}
|
|
47
47
|
self.predictedStringifiedComponents = {}
|
|
48
|
+
self.stringfiedComponentsToNameMap = {}
|
|
48
49
|
self.started = false
|
|
49
50
|
self.stringifiedComponentSubscribers = {}
|
|
50
51
|
self.stringifiedComponentValidators = {}
|
|
@@ -120,12 +121,9 @@ do
|
|
|
120
121
|
_worldReconciliation_1[_stringifiedEntity_1] = _entityReconciliations
|
|
121
122
|
end
|
|
122
123
|
local _entityReconciliations = entityReconciliations
|
|
123
|
-
local
|
|
124
|
-
local
|
|
125
|
-
|
|
126
|
-
_condition = Remove
|
|
127
|
-
end
|
|
128
|
-
_entityReconciliations[_exp] = _condition
|
|
124
|
+
local _stringifiedComponent_1 = stringifiedComponent
|
|
125
|
+
local _arg1 = if self:worldHas(entity, component) then self:worldGet(entity, component) else Remove
|
|
126
|
+
_entityReconciliations[_stringifiedComponent_1] = _arg1
|
|
129
127
|
end
|
|
130
128
|
end
|
|
131
129
|
for _k, _v in componentChanges do
|
|
@@ -415,12 +413,9 @@ do
|
|
|
415
413
|
end
|
|
416
414
|
if entityChanges ~= Delete then
|
|
417
415
|
local _entityChanges = entityChanges
|
|
418
|
-
local
|
|
419
|
-
local
|
|
420
|
-
|
|
421
|
-
_condition_1 = Remove
|
|
422
|
-
end
|
|
423
|
-
_entityChanges[_exp] = _condition_1
|
|
416
|
+
local _arg0_2 = tostring(component)
|
|
417
|
+
local _arg1 = if newState ~= nil then newState else Remove
|
|
418
|
+
_entityChanges[_arg0_2] = _arg1
|
|
424
419
|
end
|
|
425
420
|
end
|
|
426
421
|
local _condition_1 = RunService:IsClient()
|
|
@@ -445,12 +440,9 @@ do
|
|
|
445
440
|
local serverEntity = _clientToServerEntityMap[_arg0_2]
|
|
446
441
|
assert(serverEntity ~= 0 and serverEntity == serverEntity and serverEntity, "This entity should exist.")
|
|
447
442
|
local _componentChanges = componentChanges
|
|
448
|
-
local
|
|
449
|
-
local
|
|
450
|
-
|
|
451
|
-
_condition_2 = Remove
|
|
452
|
-
end
|
|
453
|
-
_componentChanges[_exp] = _condition_2
|
|
443
|
+
local _arg0_3 = tostring(serverEntity)
|
|
444
|
+
local _arg1 = if newState ~= nil then newState else Remove
|
|
445
|
+
_componentChanges[_arg0_3] = _arg1
|
|
454
446
|
end
|
|
455
447
|
end
|
|
456
448
|
function Covenant:subscribeComponent(component, subscriber)
|
|
@@ -506,20 +498,25 @@ do
|
|
|
506
498
|
_worldChangesForReplication[_arg0] = Delete
|
|
507
499
|
end
|
|
508
500
|
end
|
|
509
|
-
function Covenant:worldComponent()
|
|
501
|
+
function Covenant:worldComponent(name)
|
|
510
502
|
self:preventPostStartCall()
|
|
511
503
|
local c = self._world:component()
|
|
512
|
-
local
|
|
513
|
-
local
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
504
|
+
local cStr = tostring(c)
|
|
505
|
+
local _stringfiedComponentsToNameMap = self.stringfiedComponentsToNameMap
|
|
506
|
+
local _name = name
|
|
507
|
+
_stringfiedComponentsToNameMap[cStr] = _name
|
|
508
|
+
self.undefinedStringifiedComponents[cStr] = true
|
|
509
|
+
self.stringfiedComponents[cStr] = true
|
|
518
510
|
if RunService:IsStudio() and self.logging then
|
|
519
511
|
print(`{(debug.info(2, "sl"))}:{c}`)
|
|
520
512
|
end
|
|
521
513
|
return c
|
|
522
514
|
end
|
|
515
|
+
function Covenant:getComponentName(component)
|
|
516
|
+
local _stringfiedComponentsToNameMap = self.stringfiedComponentsToNameMap
|
|
517
|
+
local _arg0 = tostring(component)
|
|
518
|
+
return _stringfiedComponentsToNameMap[_arg0]
|
|
519
|
+
end
|
|
523
520
|
function Covenant:worldTag()
|
|
524
521
|
self:preventPostStartCall()
|
|
525
522
|
local c = self._world:component()
|