@rbxts/covenant 1.3.0 → 1.3.3
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 +1 -1
- package/src/covenant.luau +8 -29
- package/src/helpers.d.ts +12 -2
- package/src/helpers.luau +2 -2
package/package.json
CHANGED
package/src/covenant.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export declare class Covenant {
|
|
|
64
64
|
defineStaticEntity<T extends defined>({ identityComponent, recipe, replicated, }: {
|
|
65
65
|
replicated: boolean;
|
|
66
66
|
identityComponent: Entity<T>;
|
|
67
|
-
recipe: (
|
|
67
|
+
recipe: () => T[];
|
|
68
68
|
}): void;
|
|
69
69
|
private worldEntity;
|
|
70
70
|
worldQuery<T extends Id[]>(...components: T): import("@rbxts/jecs").Query<import("@rbxts/jecs").InferComponents<T>>;
|
package/src/covenant.luau
CHANGED
|
@@ -776,37 +776,16 @@ do
|
|
|
776
776
|
local replicated = _param.replicated
|
|
777
777
|
self:checkComponentDefined(identityComponent)
|
|
778
778
|
self:defineComponentNetworkBehavior(identityComponent, replicated, false)
|
|
779
|
-
local
|
|
780
|
-
|
|
781
|
-
|
|
779
|
+
local states = recipe()
|
|
780
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
781
|
+
local _callback = function(state)
|
|
782
|
+
local entity = self:worldEntity()
|
|
783
|
+
self:worldSet(entity, identityComponent, state)
|
|
782
784
|
end
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
subscribeComponent = function(component, subscriber)
|
|
786
|
-
self:subscribeComponent(component, subscriber)
|
|
787
|
-
end,
|
|
788
|
-
})
|
|
789
|
-
local lastUpdateId = 0
|
|
790
|
-
local updater = function()
|
|
791
|
-
lastUpdateId += 1
|
|
792
|
-
local states = recipe(lastUpdateId, hooks)
|
|
793
|
-
-- ▼ ReadonlyArray.forEach ▼
|
|
794
|
-
local _callback = function(state)
|
|
795
|
-
local entity = self:worldEntity()
|
|
796
|
-
self:worldSet(entity, identityComponent, state)
|
|
797
|
-
end
|
|
798
|
-
for _k, _v in states do
|
|
799
|
-
_callback(_v, _k - 1, states)
|
|
800
|
-
end
|
|
801
|
-
-- ▲ ReadonlyArray.forEach ▲
|
|
785
|
+
for _k, _v in states do
|
|
786
|
+
_callback(_v, _k - 1, states)
|
|
802
787
|
end
|
|
803
|
-
|
|
804
|
-
if not willUpdate then
|
|
805
|
-
return nil
|
|
806
|
-
end
|
|
807
|
-
willUpdate = false
|
|
808
|
-
updater()
|
|
809
|
-
end)
|
|
788
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
810
789
|
end
|
|
811
790
|
function Covenant:worldEntity()
|
|
812
791
|
return self._world:entity()
|
package/src/helpers.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Discriminator } from "./hooks";
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
|
|
3
|
+
export declare function turnArrayWithIdentifierToMap<T extends defined>(
|
|
4
|
+
array: ReadonlyArray<T>,
|
|
5
|
+
getIdentifier: (state: T) => Discriminator,
|
|
6
|
+
): Map<defined, T>;
|
|
7
|
+
export declare function compareMaps<
|
|
8
|
+
TKey extends Discriminator,
|
|
9
|
+
TValue extends defined,
|
|
10
|
+
>(
|
|
11
|
+
previousMap: ReadonlyMap<TKey, TValue>,
|
|
12
|
+
newMap: ReadonlyMap<TKey, TValue>,
|
|
13
|
+
): {
|
|
4
14
|
entriesAdded: {
|
|
5
15
|
key: TKey;
|
|
6
16
|
value: TValue;
|
package/src/helpers.luau
CHANGED
|
@@ -7,8 +7,8 @@ local function turnArrayWithIdentifierToMap(array, getIdentifier)
|
|
|
7
7
|
local _value = value
|
|
8
8
|
newMap[identifier] = _value
|
|
9
9
|
end
|
|
10
|
-
for _k, _v in array do
|
|
11
|
-
_callback(_v
|
|
10
|
+
for _k, _v in pairs(array) do
|
|
11
|
+
_callback(_v)
|
|
12
12
|
end
|
|
13
13
|
-- ▲ ReadonlyArray.forEach ▲
|
|
14
14
|
return newMap
|