@rbxts/covenant 1.2.0 → 1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/covenant",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "main": "src/init.luau",
5
5
  "scripts": {
6
6
  "build": "rbxtsc",
package/src/covenant.d.ts CHANGED
@@ -42,6 +42,7 @@ export declare class Covenant {
42
42
  subscribeComponent<T>(component: Entity<T>, subscriber: (entity: Entity, state: T | undefined, previousState: T | undefined) => void): () => void;
43
43
  private worldDelete;
44
44
  worldComponent<T extends defined>(): Entity<T>;
45
+ worldTag(): Entity<undefined>;
45
46
  private worldInternalComponent;
46
47
  private checkComponentDefined;
47
48
  private defineComponentNetworkBehavior;
@@ -60,13 +61,10 @@ export declare class Covenant {
60
61
  queriedComponents: Entity[][];
61
62
  recipe: (entity: Entity, lastChildrenStates: ReadonlyArray<T>, updateId: number, hooks: CovenantHooks) => ReadonlyArray<T>;
62
63
  }): void;
63
- defineEntitySource<T extends defined>({ identityComponent, recipe, replicated, }: {
64
+ defineStaticEntity<T extends defined>({ identityComponent, recipe, replicated, }: {
64
65
  replicated: boolean;
65
66
  identityComponent: Entity<T>;
66
- recipe: (updateId: number, hooks: CovenantHooks) => {
67
- statesToCreate?: ReadonlyArray<T>;
68
- entitiesToDelete?: ReadonlyArray<Entity>;
69
- };
67
+ recipe: (updateId: number, hooks: CovenantHooks) => T[];
70
68
  }): void;
71
69
  private worldEntity;
72
70
  worldQuery<T extends Id[]>(...components: T): import("@rbxts/jecs").Query<import("@rbxts/jecs").InferComponents<T>>;
package/src/covenant.luau CHANGED
@@ -428,6 +428,14 @@ do
428
428
  _undefinedStringifiedComponents[_arg0] = true
429
429
  return c
430
430
  end
431
+ function Covenant:worldTag()
432
+ self:preventPostStartCall()
433
+ local c = self._world:component()
434
+ local _undefinedStringifiedComponents = self.undefinedStringifiedComponents
435
+ local _arg0 = tostring(c)
436
+ _undefinedStringifiedComponents[_arg0] = true
437
+ return c
438
+ end
431
439
  function Covenant:worldInternalComponent()
432
440
  self:preventPostStartCall()
433
441
  return self._world:component()
@@ -762,7 +770,7 @@ do
762
770
  updater()
763
771
  end)
764
772
  end
765
- function Covenant:defineEntitySource(_param)
773
+ function Covenant:defineStaticEntity(_param)
766
774
  local identityComponent = _param.identityComponent
767
775
  local recipe = _param.recipe
768
776
  local replicated = _param.replicated
@@ -781,35 +789,16 @@ do
781
789
  local lastUpdateId = 0
782
790
  local updater = function()
783
791
  lastUpdateId += 1
784
- local _binding = recipe(lastUpdateId, hooks)
785
- local statesToCreate = _binding.statesToCreate
786
- local entitiesToDelete = _binding.entitiesToDelete
787
- local _result = statesToCreate
788
- if _result ~= nil then
789
- -- ▼ ReadonlyArray.forEach ▼
790
- local _callback = function(state)
791
- local entity = self:worldEntity()
792
- self:worldSet(entity, identityComponent, state)
793
- end
794
- for _k, _v in _result do
795
- _callback(_v, _k - 1, _result)
796
- end
797
- -- ▲ ReadonlyArray.forEach ▲
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)
798
797
  end
799
- local _result_1 = entitiesToDelete
800
- if _result_1 ~= nil then
801
- -- ▼ ReadonlyArray.forEach ▼
802
- local _callback = function(entity)
803
- if not self:worldHas(entity, identityComponent) then
804
- return nil
805
- end
806
- self:worldDelete(entity)
807
- end
808
- for _k, _v in _result_1 do
809
- _callback(_v, _k - 1, _result_1)
810
- end
811
- -- ▲ ReadonlyArray.forEach ▲
798
+ for _k, _v in states do
799
+ _callback(_v, _k - 1, states)
812
800
  end
801
+ -- ▲ ReadonlyArray.forEach ▲
813
802
  end
814
803
  self:schedule(RunService.Heartbeat, function()
815
804
  if not willUpdate then