@rbxts/replecs 0.2.4 → 0.3.0-test1
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/out/replecs/client.luau +7 -3
- package/out/replecs/index.d.ts +40 -12
- package/out/replecs/init.luau +22 -0
- package/out/replecs/masking/init.luau +237 -309
- package/out/replecs/server.luau +172 -120
- package/out/replecs/ver.luau +1 -1
- package/out/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/out/replecs/client.luau
CHANGED
|
@@ -70,8 +70,8 @@ type DeletedHookEntry = {
|
|
|
70
70
|
type CustomIdMap = { [Entity]: CustomId | Entity }
|
|
71
71
|
|
|
72
72
|
export type ClientImp = {
|
|
73
|
-
set_serdes: <T>(
|
|
74
|
-
remove_serdes: (
|
|
73
|
+
set_serdes: <T>(self: Client, id: Component<T>, serdes: types.Serdes<T>) -> (),
|
|
74
|
+
remove_serdes: (self: Client, id: Component) -> (),
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export type Client = ClientImp & {
|
|
@@ -158,6 +158,7 @@ local WORLD_ADD = common.world_add
|
|
|
158
158
|
local WORLD_SET = common.world_set
|
|
159
159
|
local WORLD_REMOVE = common.world_remove
|
|
160
160
|
local WORLD_GET = common.world_get
|
|
161
|
+
local WORLD_HAS = common.world_has
|
|
161
162
|
local WORLD_DELETE = common.world_delete
|
|
162
163
|
|
|
163
164
|
local HOOK_ADDED = common.hook_added
|
|
@@ -269,7 +270,9 @@ function client_replicator.entity_set_unreliable(
|
|
|
269
270
|
local command_buffer = get_or_create_command_buffer(client, entity)
|
|
270
271
|
command_buffer.unreliable_components[id] = { value = value }
|
|
271
272
|
else
|
|
272
|
-
|
|
273
|
+
if WORLD_HAS(client.world, entity, id) then
|
|
274
|
+
client_replicator.entity_set(client, entity, id, value, changed_hooks)
|
|
275
|
+
end
|
|
273
276
|
end
|
|
274
277
|
end
|
|
275
278
|
|
|
@@ -1371,6 +1374,7 @@ function client_replicator.apply_unreliable(client: Client, buf: buffer, all_var
|
|
|
1371
1374
|
for _ = 1, total_unreliable do
|
|
1372
1375
|
local component = client_replicator.read_component_id(client, c)
|
|
1373
1376
|
local value = client_replicator.read_component_value(client, component, c, variants)
|
|
1377
|
+
|
|
1374
1378
|
local unreliable_hooks = changed_hooks[PAIR(components.unreliable, component)]
|
|
1375
1379
|
client_replicator.entity_set_unreliable(client, entity, component, value, unreliable_hooks)
|
|
1376
1380
|
end
|
package/out/replecs/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { Entity, Id, Pair, Tag, World } from "@rbxts/jecs";
|
|
1
|
+
import type { Entity, Id, InferComponent, Pair, Tag, World } from "@rbxts/jecs";
|
|
2
2
|
|
|
3
3
|
declare namespace Replecs {
|
|
4
|
-
export type SerdesTable =
|
|
4
|
+
export type SerdesTable<T = any> =
|
|
5
5
|
| {
|
|
6
6
|
bytespan?: number;
|
|
7
7
|
includes_variants?: false;
|
|
8
|
-
serialize: (value:
|
|
9
|
-
deserialize: (buffer: buffer) =>
|
|
8
|
+
serialize: (value: T) => buffer;
|
|
9
|
+
deserialize: (buffer: buffer) => T;
|
|
10
10
|
}
|
|
11
11
|
| {
|
|
12
12
|
bytespan?: number;
|
|
13
13
|
includes_variants: true;
|
|
14
|
-
serialize: (value:
|
|
15
|
-
deserialize: (buffer: buffer, blobs: defined[] | undefined) =>
|
|
14
|
+
serialize: (value: T) => LuaTuple<[buffer, defined[] | undefined]>;
|
|
15
|
+
deserialize: (buffer: buffer, blobs: defined[] | undefined) => T;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
type MemberFilterMap = Map<Player, boolean>;
|
|
@@ -80,6 +80,14 @@ declare namespace Replecs {
|
|
|
80
80
|
Global: Entity<number>;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
export interface ClientImp {
|
|
84
|
+
set_serdes<T extends Id>(
|
|
85
|
+
component: InferComponent<T>,
|
|
86
|
+
serdes: SerdesTable<T>,
|
|
87
|
+
): void;
|
|
88
|
+
remove_serdes(component: Id): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
83
91
|
export interface Client {
|
|
84
92
|
world: World;
|
|
85
93
|
inited?: boolean;
|
|
@@ -91,9 +99,7 @@ declare namespace Replecs {
|
|
|
91
99
|
|
|
92
100
|
init(world?: World): void;
|
|
93
101
|
destroy(): void;
|
|
94
|
-
|
|
95
102
|
handle_global(handler: (id: number) => Entity): void;
|
|
96
|
-
|
|
97
103
|
get_server_entity(client_entity: Entity): number | undefined;
|
|
98
104
|
get_client_entity(server_entity: number): Entity | undefined;
|
|
99
105
|
|
|
@@ -137,11 +143,14 @@ declare namespace Replecs {
|
|
|
137
143
|
|
|
138
144
|
encode_component(component: Entity): number;
|
|
139
145
|
decode_component(encoded: number): Entity;
|
|
146
|
+
get_shared_count(): number;
|
|
147
|
+
|
|
140
148
|
register_custom_id(custom_id: CustomId): void;
|
|
141
149
|
|
|
142
150
|
apply_updates(buf: buffer, all_variants?: defined[][]): void;
|
|
143
151
|
apply_unreliable(buf: buffer, all_variants?: defined[][]): void;
|
|
144
152
|
apply_full(buf: buffer, all_variants?: defined[][]): void;
|
|
153
|
+
apply_entity(buf: buffer, all_variants?: defined[][]): void;
|
|
145
154
|
|
|
146
155
|
generate_handshake(): HandshakeInfo;
|
|
147
156
|
verify_handshake(
|
|
@@ -161,15 +170,23 @@ declare namespace Replecs {
|
|
|
161
170
|
component: Entity,
|
|
162
171
|
filter?: MemberFilter,
|
|
163
172
|
): void;
|
|
173
|
+
set_pair(entity: Entity, id: Pair, filter?: MemberFilter): void;
|
|
164
174
|
set_relation(entity: Entity, relation: Entity, filter?: MemberFilter): void;
|
|
165
175
|
|
|
166
176
|
stop_networked(entity: Entity, keep?: boolean): void;
|
|
167
177
|
stop_reliable(entity: Entity, component: Entity, keep?: boolean): void;
|
|
168
178
|
stop_unreliable(entity: Entity, component: Entity, keep?: boolean): void;
|
|
179
|
+
stop_pair(entity: Entity, id: Pair): void;
|
|
169
180
|
stop_relation(entity: Entity, relation: Entity, keep?: boolean): void;
|
|
170
181
|
|
|
171
182
|
set_custom(entity: Entity, handler: Entity | CustomId): void;
|
|
172
183
|
remove_custom(entity: Entity): void;
|
|
184
|
+
|
|
185
|
+
set_serdes<T extends Id>(
|
|
186
|
+
component: InferComponent<T>,
|
|
187
|
+
serdes: SerdesTable<T>,
|
|
188
|
+
): void;
|
|
189
|
+
remove_serdes(component: Id): void;
|
|
173
190
|
}
|
|
174
191
|
|
|
175
192
|
export interface Server extends ServerImp {
|
|
@@ -180,15 +197,20 @@ declare namespace Replecs {
|
|
|
180
197
|
destroy(): void;
|
|
181
198
|
|
|
182
199
|
encode_component(component: Entity): number;
|
|
183
|
-
decode_component(encoded: number): Entity;
|
|
200
|
+
decode_component(encoded: number): Entity | undefined;
|
|
201
|
+
get_shared_count(): number;
|
|
202
|
+
|
|
184
203
|
register_custom_id(custom_id: CustomId): void;
|
|
185
204
|
|
|
186
|
-
get_full(player: Player): LuaTuple<[buffer, defined[][]
|
|
205
|
+
get_full(player: Player): LuaTuple<[buffer, defined[][] | undefined]>;
|
|
206
|
+
collect_entity(
|
|
207
|
+
entity: Entity,
|
|
208
|
+
): IterableFunction<LuaTuple<[Player, buffer, defined[][] | undefined]>>;
|
|
187
209
|
collect_updates(): IterableFunction<
|
|
188
|
-
LuaTuple<[Player, buffer, defined[][]
|
|
210
|
+
LuaTuple<[Player, buffer, defined[][] | undefined]>
|
|
189
211
|
>;
|
|
190
212
|
collect_unreliable(): IterableFunction<
|
|
191
|
-
LuaTuple<[Player, buffer, defined[][]
|
|
213
|
+
LuaTuple<[Player, buffer, defined[][] | undefined]>
|
|
192
214
|
>;
|
|
193
215
|
|
|
194
216
|
mark_player_ready(player: Player): void;
|
|
@@ -209,6 +231,12 @@ declare namespace Replecs {
|
|
|
209
231
|
|
|
210
232
|
after_replication(callback: () => void): void;
|
|
211
233
|
register_custom_id(custom_id: CustomId): void;
|
|
234
|
+
|
|
235
|
+
set_serdes<T extends Id>(
|
|
236
|
+
component: InferComponent<T>,
|
|
237
|
+
serdes: SerdesTable<T>,
|
|
238
|
+
): void;
|
|
239
|
+
remove_serdes(component: Id): void;
|
|
212
240
|
}
|
|
213
241
|
|
|
214
242
|
export interface Replecs extends Components {
|
package/out/replecs/init.luau
CHANGED
|
@@ -13,6 +13,7 @@ export type Client = client.Client
|
|
|
13
13
|
|
|
14
14
|
type Entity = common.Entity
|
|
15
15
|
type World = common.World
|
|
16
|
+
type Component<T = any> = common.Component<T>
|
|
16
17
|
|
|
17
18
|
export type HandleContext = customid.HandleContext
|
|
18
19
|
export type CustomId = customid.CustomId
|
|
@@ -26,6 +27,9 @@ export type ReplecsLib = {
|
|
|
26
27
|
|
|
27
28
|
after_replication: (self: ReplecsLib, callback: () -> ()) -> (),
|
|
28
29
|
register_custom_id: (self: ReplecsLib, custom_id: CustomId) -> (),
|
|
30
|
+
|
|
31
|
+
set_serdes: <T>(self: ReplecsLib, id: Component<T>, serdes: types.Serdes<T>) -> (),
|
|
32
|
+
remove_serdes: (self: ReplecsLib, id: Component) -> (),
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
type Replecs = types.Components & {
|
|
@@ -109,4 +113,22 @@ function replecs.register_custom_id(lib: ReplecsLib, custom_id: CustomId)
|
|
|
109
113
|
end
|
|
110
114
|
end
|
|
111
115
|
|
|
116
|
+
function replecs.set_serdes(lib: ReplecsLib, id: Component, serdes: Serdes)
|
|
117
|
+
if lib.server then
|
|
118
|
+
lib.server:set_serdes(id, serdes)
|
|
119
|
+
end
|
|
120
|
+
if lib.client then
|
|
121
|
+
lib.client:set_serdes(id, serdes)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
function replecs.remove_serdes(lib: ReplecsLib, id: Component)
|
|
126
|
+
if lib.server then
|
|
127
|
+
lib.server:remove_serdes(id)
|
|
128
|
+
end
|
|
129
|
+
if lib.client then
|
|
130
|
+
lib.client:remove_serdes(id)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
112
134
|
return replecs :: Replecs
|