@rbxts/covenant 3.0.2 → 3.1.1
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 -2
- package/src/covenant.luau +8 -6
package/package.json
CHANGED
package/src/covenant.d.ts
CHANGED
|
@@ -66,10 +66,11 @@ export declare class Covenant {
|
|
|
66
66
|
queriedComponents: Entity[][];
|
|
67
67
|
recipe: (entity: Entity, lastState: T | undefined, updateId: number, hooks: CovenantHooks) => T | undefined;
|
|
68
68
|
}): void;
|
|
69
|
-
defineIdentity<T extends defined>({ identityComponent, replicated, factory, }: {
|
|
69
|
+
defineIdentity<T extends defined>({ identityComponent, replicated, lifetime, factory, }: {
|
|
70
70
|
identityComponent: Entity<T>;
|
|
71
71
|
replicated: boolean;
|
|
72
|
-
|
|
72
|
+
lifetime: (entity: Entity, state: T, despawn: () => void) => (() => void) | undefined;
|
|
73
|
+
factory: (spawnEntity: (state: T) => void) => void;
|
|
73
74
|
}): void;
|
|
74
75
|
private worldEntity;
|
|
75
76
|
worldQuery<T extends Id[]>(...components: T): import("@rbxts/jecs").Query<T>;
|
package/src/covenant.luau
CHANGED
|
@@ -671,18 +671,20 @@ do
|
|
|
671
671
|
function Covenant:defineIdentity(_param)
|
|
672
672
|
local identityComponent = _param.identityComponent
|
|
673
673
|
local replicated = _param.replicated
|
|
674
|
+
local lifetime = _param.lifetime
|
|
674
675
|
local factory = _param.factory
|
|
675
676
|
self:checkComponentDefined(identityComponent)
|
|
676
677
|
self:defineComponentNetworkBehavior(identityComponent, replicated, false)
|
|
677
678
|
factory(function(state)
|
|
678
679
|
local entity = self:worldEntity()
|
|
679
680
|
self:worldSet(entity, identityComponent, state)
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
681
|
+
local cleanup = function() end
|
|
682
|
+
cleanup = lifetime(entity, state, function()
|
|
683
|
+
self:worldDelete(entity)
|
|
684
|
+
if cleanup ~= nil then
|
|
685
|
+
cleanup()
|
|
686
|
+
end
|
|
687
|
+
end)
|
|
686
688
|
end)
|
|
687
689
|
end
|
|
688
690
|
function Covenant:worldEntity()
|