@rbxts/covenant 1.0.17 → 1.1.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.luau +57 -55
- package/src/hooks.luau +1 -0
package/package.json
CHANGED
package/src/covenant.luau
CHANGED
|
@@ -648,6 +648,63 @@ do
|
|
|
648
648
|
end
|
|
649
649
|
-- ▲ ReadonlyArray.forEach ▲
|
|
650
650
|
local lastUpdateId = 0
|
|
651
|
+
self:subscribeComponent(parentComponent, function(entity, newState, lastState)
|
|
652
|
+
local lastStateMap = turnArrayWithIdentifierToMap(lastState or {}, getIdentifier)
|
|
653
|
+
local newStateMap = turnArrayWithIdentifierToMap(newState or {}, getIdentifier)
|
|
654
|
+
local entityTracker = self:worldGet(entity, parentEntityTrackerComponent)
|
|
655
|
+
if entityTracker == nil then
|
|
656
|
+
entityTracker = {}
|
|
657
|
+
self:worldSet(entity, parentEntityTrackerComponent, entityTracker)
|
|
658
|
+
end
|
|
659
|
+
local _binding = compareMaps(lastStateMap, newStateMap)
|
|
660
|
+
local entriesChanged = _binding.entriesChanged
|
|
661
|
+
local entriesAdded = _binding.entriesAdded
|
|
662
|
+
local keysRemoved = _binding.keysRemoved
|
|
663
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
664
|
+
local _callback_4 = function(_param_1)
|
|
665
|
+
local key = _param_1.key
|
|
666
|
+
local value = _param_1.value
|
|
667
|
+
local childEntity = self:worldEntity()
|
|
668
|
+
entityTracker[key] = childEntity
|
|
669
|
+
self:worldSet(childEntity, childIdentityComponent, value)
|
|
670
|
+
self._world:add(childEntity, pair(ChildOf, entity))
|
|
671
|
+
end
|
|
672
|
+
for _k, _v in entriesAdded do
|
|
673
|
+
_callback_4(_v, _k - 1, entriesAdded)
|
|
674
|
+
end
|
|
675
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
676
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
677
|
+
local _callback_5 = function(_param_1)
|
|
678
|
+
local key = _param_1.key
|
|
679
|
+
local value = _param_1.value
|
|
680
|
+
local childEntity = entityTracker[key]
|
|
681
|
+
assert(childEntity ~= 0 and childEntity == childEntity and childEntity)
|
|
682
|
+
local _arg0 = self:worldContains(childEntity)
|
|
683
|
+
assert(_arg0)
|
|
684
|
+
self:worldSet(childEntity, childIdentityComponent, value)
|
|
685
|
+
end
|
|
686
|
+
for _k, _v in entriesChanged do
|
|
687
|
+
_callback_5(_v, _k - 1, entriesChanged)
|
|
688
|
+
end
|
|
689
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
690
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
691
|
+
local _callback_6 = function(key)
|
|
692
|
+
local _entityTracker = entityTracker
|
|
693
|
+
local _key = key
|
|
694
|
+
local childEntity = _entityTracker[_key]
|
|
695
|
+
assert(childEntity ~= 0 and childEntity == childEntity and childEntity)
|
|
696
|
+
local _arg0 = self:worldContains(childEntity)
|
|
697
|
+
assert(_arg0)
|
|
698
|
+
self:worldDelete(childEntity)
|
|
699
|
+
local _entityTracker_1 = entityTracker
|
|
700
|
+
local _key_1 = key
|
|
701
|
+
_entityTracker_1[_key_1] = nil
|
|
702
|
+
end
|
|
703
|
+
for _k, _v in keysRemoved do
|
|
704
|
+
_callback_6(_v, _k - 1, keysRemoved)
|
|
705
|
+
end
|
|
706
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
707
|
+
end)
|
|
651
708
|
local updater = function()
|
|
652
709
|
lastUpdateId += 1
|
|
653
710
|
local updateId = lastUpdateId
|
|
@@ -666,64 +723,9 @@ do
|
|
|
666
723
|
end
|
|
667
724
|
handledStringifiedEntities[stringifiedEntity] = true
|
|
668
725
|
unhandledStringifiedEntities[stringifiedEntity] = nil
|
|
669
|
-
local entityTracker = self:worldGet(entity, parentEntityTrackerComponent)
|
|
670
|
-
if entityTracker == nil then
|
|
671
|
-
entityTracker = {}
|
|
672
|
-
self:worldSet(entity, parentEntityTrackerComponent, entityTracker)
|
|
673
|
-
end
|
|
674
726
|
local lastState = self:worldGet(entity, parentComponent) or {}
|
|
675
727
|
local newState = recipe(entity, lastState, updateId, hooks)
|
|
676
728
|
self:worldSet(entity, parentComponent, newState)
|
|
677
|
-
local lastStateMap = turnArrayWithIdentifierToMap(lastState, getIdentifier)
|
|
678
|
-
local newStateMap = turnArrayWithIdentifierToMap(newState, getIdentifier)
|
|
679
|
-
local _binding = compareMaps(lastStateMap, newStateMap)
|
|
680
|
-
local entriesChanged = _binding.entriesChanged
|
|
681
|
-
local entriesAdded = _binding.entriesAdded
|
|
682
|
-
local keysRemoved = _binding.keysRemoved
|
|
683
|
-
-- ▼ ReadonlyArray.forEach ▼
|
|
684
|
-
local _callback_5 = function(_param_1)
|
|
685
|
-
local key = _param_1.key
|
|
686
|
-
local value = _param_1.value
|
|
687
|
-
local childEntity = self:worldEntity()
|
|
688
|
-
entityTracker[key] = childEntity
|
|
689
|
-
self:worldSet(childEntity, childIdentityComponent, value)
|
|
690
|
-
self._world:add(childEntity, pair(ChildOf, entity))
|
|
691
|
-
end
|
|
692
|
-
for _k, _v in entriesAdded do
|
|
693
|
-
_callback_5(_v, _k - 1, entriesAdded)
|
|
694
|
-
end
|
|
695
|
-
-- ▲ ReadonlyArray.forEach ▲
|
|
696
|
-
-- ▼ ReadonlyArray.forEach ▼
|
|
697
|
-
local _callback_6 = function(_param_1)
|
|
698
|
-
local key = _param_1.key
|
|
699
|
-
local value = _param_1.value
|
|
700
|
-
local childEntity = entityTracker[key]
|
|
701
|
-
assert(childEntity ~= 0 and childEntity == childEntity and childEntity)
|
|
702
|
-
local _arg0 = self:worldContains(childEntity)
|
|
703
|
-
assert(_arg0)
|
|
704
|
-
self:worldSet(childEntity, childIdentityComponent, value)
|
|
705
|
-
end
|
|
706
|
-
for _k, _v in entriesChanged do
|
|
707
|
-
_callback_6(_v, _k - 1, entriesChanged)
|
|
708
|
-
end
|
|
709
|
-
-- ▲ ReadonlyArray.forEach ▲
|
|
710
|
-
-- ▼ ReadonlyArray.forEach ▼
|
|
711
|
-
local _callback_7 = function(key)
|
|
712
|
-
local _entityTracker = entityTracker
|
|
713
|
-
local _key = key
|
|
714
|
-
local childEntity = _entityTracker[_key]
|
|
715
|
-
assert(childEntity ~= 0 and childEntity == childEntity and childEntity)
|
|
716
|
-
local _arg0 = self:worldContains(childEntity)
|
|
717
|
-
assert(_arg0)
|
|
718
|
-
self:worldDelete(childEntity)
|
|
719
|
-
local _entityTracker_1 = entityTracker
|
|
720
|
-
local _key_1 = key
|
|
721
|
-
_entityTracker_1[_key_1] = nil
|
|
722
|
-
end
|
|
723
|
-
for _k, _v in keysRemoved do
|
|
724
|
-
_callback_7(_v, _k - 1, keysRemoved)
|
|
725
|
-
end
|
|
726
|
-
-- ▲ ReadonlyArray.forEach ▲
|
|
727
729
|
end
|
|
728
730
|
end
|
|
729
731
|
for _k, _v in queries do
|
package/src/hooks.luau
CHANGED
|
@@ -3,6 +3,7 @@ local TS = _G[script]
|
|
|
3
3
|
local _dataStructureWithEvents = TS.import(script, script.Parent, "dataStructureWithEvents")
|
|
4
4
|
local EventMap = _dataStructureWithEvents.EventMap
|
|
5
5
|
local EventSet = _dataStructureWithEvents.EventSet
|
|
6
|
+
-- TODO: make events available for dynamic instances
|
|
6
7
|
local function createUseEvent(_param)
|
|
7
8
|
local indicateUpdate = _param.indicateUpdate
|
|
8
9
|
local queues = EventMap.new()
|