@rbxts/replecs 0.1.0-alpha9-test5 → 0.2.0-cdtest.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/out/replecs/client.luau +816 -345
- package/out/replecs/common.luau +40 -23
- package/out/replecs/customid.luau +39 -0
- package/out/replecs/index.d.ts +116 -26
- package/out/replecs/init.luau +45 -17
- package/out/replecs/masking/init.luau +40 -35
- package/out/replecs/masking/mask_generator.luau +1 -1
- package/out/replecs/server.luau +547 -280
- package/out/replecs/utils.luau +188 -31
- package/out/replecs/ver.luau +2 -0
- package/package.json +1 -1
- package/out/replecs/masking/filter_group.luau +0 -1
package/out/replecs/common.luau
CHANGED
|
@@ -1,52 +1,69 @@
|
|
|
1
1
|
local jecs = require "../jecs"
|
|
2
|
+
local customid = require "./customid"
|
|
3
|
+
|
|
4
|
+
export type FunctionFilter = (player: Player) -> boolean
|
|
5
|
+
export type AnyFilter = PlayerFilter | Player
|
|
6
|
+
type Entity<T = any> = jecs.Entity<T>
|
|
2
7
|
|
|
3
8
|
export type PlayerFilter = {
|
|
4
9
|
[Player]: boolean,
|
|
5
10
|
}
|
|
6
11
|
|
|
12
|
+
export type SharedInfo<T> = {
|
|
13
|
+
lookup: { [string]: T },
|
|
14
|
+
keys: { string },
|
|
15
|
+
indexes: { [number]: T },
|
|
16
|
+
members: { [T]: number },
|
|
17
|
+
}
|
|
18
|
+
export type HandshakeInfo = {
|
|
19
|
+
components: { [string]: boolean },
|
|
20
|
+
custom_ids: { [string]: boolean },
|
|
21
|
+
serdes: { [string]: {
|
|
22
|
+
includes_variants: boolean?,
|
|
23
|
+
bytespan: number?,
|
|
24
|
+
} },
|
|
25
|
+
}
|
|
26
|
+
|
|
7
27
|
export type Serdes = {
|
|
8
28
|
includes_variants: boolean?,
|
|
29
|
+
bytespan: number?,
|
|
9
30
|
serialize: (value: any) -> (buffer, { any }?),
|
|
10
31
|
deserialize: (buffer, { any }?) -> any,
|
|
11
32
|
}
|
|
12
33
|
|
|
13
34
|
export type Components = {
|
|
14
|
-
shared:
|
|
15
|
-
networked:
|
|
16
|
-
reliable:
|
|
17
|
-
unreliable:
|
|
18
|
-
pair:
|
|
19
|
-
|
|
20
|
-
serdes:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
__alive_tracking__: jecs.Entity,
|
|
35
|
+
shared: Entity,
|
|
36
|
+
networked: Entity<AnyFilter?>,
|
|
37
|
+
reliable: Entity<AnyFilter?>,
|
|
38
|
+
unreliable: Entity<AnyFilter?>,
|
|
39
|
+
pair: Entity<AnyFilter?>,
|
|
40
|
+
|
|
41
|
+
serdes: Entity<Serdes>,
|
|
42
|
+
custom: Entity,
|
|
43
|
+
custom_handler: Entity<(val: any) -> Entity?>,
|
|
44
|
+
global: Entity<number>,
|
|
45
|
+
__alive_tracking__: Entity,
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
export type Shared = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
components: { [number]: jecs.Entity },
|
|
32
|
-
ids: { [jecs.Entity]: number },
|
|
49
|
+
components: SharedInfo<Entity>,
|
|
50
|
+
custom_ids: SharedInfo<customid.CustomId>,
|
|
33
51
|
|
|
34
|
-
|
|
35
|
-
serdes: { [jecs.Entity]: Serdes },
|
|
52
|
+
serdes: { [Entity]: Serdes },
|
|
36
53
|
}
|
|
37
54
|
|
|
38
55
|
export type WorldHooks = {
|
|
39
56
|
added: (
|
|
40
57
|
world: jecs.World,
|
|
41
|
-
component:
|
|
42
|
-
fn: (entity:
|
|
58
|
+
component: Entity,
|
|
59
|
+
fn: (entity: Entity, id: jecs.Id, value: any) -> ()
|
|
43
60
|
) -> () -> (),
|
|
44
61
|
changed: (
|
|
45
62
|
world: jecs.World,
|
|
46
|
-
component:
|
|
47
|
-
fn: (entity:
|
|
63
|
+
component: Entity,
|
|
64
|
+
fn: (entity: Entity, id: jecs.Id, value: any) -> ()
|
|
48
65
|
) -> () -> (),
|
|
49
|
-
removed: (world: jecs.World, component:
|
|
66
|
+
removed: (world: jecs.World, component: Entity, fn: (entity: Entity, id: jecs.Id) -> ()) -> () -> (),
|
|
50
67
|
}
|
|
51
68
|
|
|
52
69
|
return nil
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
local jecs = require "../jecs"
|
|
2
|
+
|
|
3
|
+
type Entity<T = any> = jecs.Entity<T>
|
|
4
|
+
type Id<T = any> = jecs.Id<T>
|
|
5
|
+
type World = jecs.World
|
|
6
|
+
|
|
7
|
+
export type HandleContext = {
|
|
8
|
+
entity_id: number,
|
|
9
|
+
component: <T>(component: Entity<T>) -> T,
|
|
10
|
+
target: (relation: jecs.Id, index: number?) -> Entity?,
|
|
11
|
+
pair_value: <T>(relation: jecs.Id<T>, target: Entity) -> T?,
|
|
12
|
+
has_pair: (relation: jecs.Id, target: Entity) -> boolean,
|
|
13
|
+
|
|
14
|
+
entity: (server_entity: number) -> Entity,
|
|
15
|
+
has: (tag: Entity) -> boolean,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type CustomId = {
|
|
19
|
+
identifier: string,
|
|
20
|
+
handle_callback: ((ctx: HandleContext) -> Entity?)?,
|
|
21
|
+
|
|
22
|
+
handle: (self: CustomId, handler: (ctx: HandleContext) -> Entity?) -> (),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
local custom_id = {}
|
|
26
|
+
|
|
27
|
+
function custom_id.handle(custom: CustomId, callback: (ctx: HandleContext) -> Entity?)
|
|
28
|
+
custom.handle_callback = callback
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
function create(identifier: string, callback: ((ctx: HandleContext) -> Entity?)?): CustomId
|
|
32
|
+
local handler = {} :: CustomId
|
|
33
|
+
handler.identifier = identifier
|
|
34
|
+
handler.handle_callback = callback
|
|
35
|
+
|
|
36
|
+
return setmetatable(handler, custom_id) :: any
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
return { create = create }
|
package/out/replecs/index.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { Entity, Pair, Tag, World } from "@rbxts/jecs";
|
|
1
|
+
import type { Entity, Id, Pair, Tag, World } from "@rbxts/jecs";
|
|
2
2
|
|
|
3
3
|
declare namespace Replecs {
|
|
4
4
|
export type SerdesTable =
|
|
5
5
|
| {
|
|
6
|
+
bytespan?: number;
|
|
6
7
|
includes_variants?: false;
|
|
7
8
|
serialize: (value: any) => buffer;
|
|
8
9
|
deserialize: (buffer: buffer) => any;
|
|
9
10
|
}
|
|
10
11
|
| {
|
|
12
|
+
bytespan?: number;
|
|
11
13
|
includes_variants: true;
|
|
12
14
|
serialize: (value: any) => LuaTuple<[buffer, defined[] | undefined]>;
|
|
13
15
|
deserialize: (buffer: buffer, blobs: defined[] | undefined) => any;
|
|
@@ -17,11 +19,41 @@ declare namespace Replecs {
|
|
|
17
19
|
type MemberFilter = Player | MemberFilterMap | undefined;
|
|
18
20
|
type Member = unknown;
|
|
19
21
|
|
|
20
|
-
interface
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export interface SharedInfo<T> {
|
|
23
|
+
lookup: Record<string, T>;
|
|
24
|
+
keys: string[];
|
|
25
|
+
indexes: [T];
|
|
26
|
+
members: Map<T, number>;
|
|
27
|
+
}
|
|
28
|
+
export interface HandleContext {
|
|
29
|
+
entity_id: number;
|
|
30
|
+
component: <T>(component: Entity<T>) => T;
|
|
31
|
+
target: (relation: Id, index?: number) => Entity | undefined;
|
|
32
|
+
pair_value: <T>(relation: Id<T>, target: Entity) => T | undefined;
|
|
33
|
+
has_pair: (relation: Id, target: Entity) => boolean;
|
|
34
|
+
|
|
35
|
+
entity: (server_entity: number) => Entity | undefined;
|
|
36
|
+
has: (tag: Entity) => boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface CustomId {
|
|
39
|
+
identifier: string;
|
|
40
|
+
handle_callback: (ctx: HandleContext) => Entity;
|
|
41
|
+
handle(handler: (ctx: HandleContext) => Entity): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Shared {
|
|
45
|
+
components: SharedInfo<Entity>;
|
|
46
|
+
custom_ids: SharedInfo<CustomId>;
|
|
47
|
+
}
|
|
48
|
+
interface HandshakeSerdesInfo {
|
|
49
|
+
includes_variants?: boolean;
|
|
50
|
+
bytespan?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface HandshakeInfo {
|
|
54
|
+
components: Record<string, boolean>;
|
|
55
|
+
custom_ids: Record<string, boolean>;
|
|
56
|
+
serdes: Record<string, HandshakeSerdesInfo>;
|
|
25
57
|
}
|
|
26
58
|
|
|
27
59
|
export interface Components {
|
|
@@ -32,7 +64,6 @@ declare namespace Replecs {
|
|
|
32
64
|
pair: Entity<MemberFilter>;
|
|
33
65
|
|
|
34
66
|
serdes: Entity<SerdesTable>;
|
|
35
|
-
bytespan: Entity<number>;
|
|
36
67
|
custom: Entity;
|
|
37
68
|
custom_handler: Entity<(value: any) => Entity>;
|
|
38
69
|
global: Entity<number>;
|
|
@@ -44,7 +75,6 @@ declare namespace Replecs {
|
|
|
44
75
|
Pair: Entity<MemberFilter>;
|
|
45
76
|
|
|
46
77
|
Serdes: Entity<SerdesTable>;
|
|
47
|
-
Bytespan: Entity<number>;
|
|
48
78
|
Custom: Entity;
|
|
49
79
|
CustomHandler: Entity<(value: any) => Entity>;
|
|
50
80
|
Global: Entity<number>;
|
|
@@ -54,67 +84,120 @@ declare namespace Replecs {
|
|
|
54
84
|
world: World;
|
|
55
85
|
inited?: boolean;
|
|
56
86
|
|
|
87
|
+
is_relicating: boolean;
|
|
88
|
+
after_relication_callbacks: [() => void];
|
|
89
|
+
|
|
90
|
+
components: Components;
|
|
91
|
+
|
|
57
92
|
init(world?: World): void;
|
|
58
93
|
destroy(): void;
|
|
59
94
|
|
|
60
95
|
handle_global(handler: (id: number) => Entity): void;
|
|
61
96
|
|
|
97
|
+
get_server_entity(client_entity: Entity): number | undefined;
|
|
98
|
+
get_client_entity(server_entity: number): Entity | undefined;
|
|
99
|
+
|
|
100
|
+
register_entity(entity: Entity, server_entity: number): void;
|
|
101
|
+
unregister_entity(entity: Entity): void;
|
|
102
|
+
|
|
62
103
|
after_replication(callback: () => void): void;
|
|
63
104
|
added(callback: (entity: Entity) => void): () => void;
|
|
105
|
+
|
|
64
106
|
hook<T>(
|
|
65
|
-
entity: Entity,
|
|
66
107
|
action: "changed",
|
|
67
108
|
relation: Pair<MemberFilter, T>,
|
|
68
|
-
callback: (entity: Entity, id:
|
|
109
|
+
callback: (entity: Entity, id: Id<T>, value: T) => void
|
|
69
110
|
): () => void;
|
|
70
111
|
hook<T>(
|
|
71
|
-
entity: Entity,
|
|
72
112
|
action: "removed",
|
|
73
113
|
relation: Pair<MemberFilter, T>,
|
|
74
|
-
callback: (entity: Entity, id:
|
|
114
|
+
callback: (entity: Entity, id: Id<T>) => void
|
|
75
115
|
): () => void;
|
|
76
116
|
hook(
|
|
77
|
-
entity: Entity,
|
|
78
117
|
action: "deleted",
|
|
118
|
+
entity: Entity,
|
|
79
119
|
callback: (entity: Entity) => void
|
|
80
120
|
): () => void;
|
|
81
121
|
|
|
82
122
|
override<T>(
|
|
83
|
-
entity: Entity,
|
|
84
123
|
action: "changed",
|
|
85
124
|
relation: Pair<MemberFilter, T>,
|
|
86
|
-
callback: (entity: Entity, id:
|
|
125
|
+
callback: (entity: Entity, id: Id<T>, value: any) => void
|
|
87
126
|
): () => void;
|
|
88
127
|
override<T>(
|
|
89
|
-
entity: Entity,
|
|
90
128
|
action: "removed",
|
|
91
129
|
relation: Pair<MemberFilter, T>,
|
|
92
|
-
callback: (entity: Entity, id:
|
|
130
|
+
callback: (entity: Entity, id: Id<T>) => void
|
|
93
131
|
): () => void;
|
|
94
132
|
override(
|
|
95
|
-
entity: Entity,
|
|
96
133
|
action: "deleted",
|
|
134
|
+
entity: Entity,
|
|
97
135
|
callback: (entity: Entity) => void
|
|
98
136
|
): () => void;
|
|
99
137
|
|
|
100
138
|
encode_component(component: Entity): number;
|
|
101
139
|
decode_component(encoded: number): Entity;
|
|
102
|
-
|
|
103
|
-
get_server_entity(client_entity: Entity): number | undefined;
|
|
104
|
-
get_client_entity(server_entity: number): Entity | undefined;
|
|
140
|
+
register_custom_id(custom_id: CustomId): void;
|
|
105
141
|
|
|
106
142
|
apply_updates(buf: buffer, all_variants?: unknown[][]): void;
|
|
107
143
|
apply_unreliable(buf: buffer, all_variants?: unknown[][]): void;
|
|
108
144
|
apply_full(buf: buffer, all_variants?: unknown[][]): void;
|
|
145
|
+
|
|
146
|
+
generate_handshake(): HandshakeInfo;
|
|
147
|
+
verify_handshake(
|
|
148
|
+
handshake: HandshakeInfo
|
|
149
|
+
): LuaTuple<[true]> | LuaTuple<[false, string]>;
|
|
109
150
|
}
|
|
110
151
|
|
|
111
|
-
export interface
|
|
152
|
+
export interface ServerImp {
|
|
153
|
+
set_networked(
|
|
154
|
+
server: Server,
|
|
155
|
+
entity: Entity,
|
|
156
|
+
filter?: MemberFilter
|
|
157
|
+
): void;
|
|
158
|
+
stop_networked(server: Server, entity: Entity): void;
|
|
159
|
+
|
|
160
|
+
set_reliable(
|
|
161
|
+
server: Server,
|
|
162
|
+
entity: Entity,
|
|
163
|
+
component: Entity,
|
|
164
|
+
filter?: MemberFilter
|
|
165
|
+
): void;
|
|
166
|
+
set_unreliable(
|
|
167
|
+
server: Server,
|
|
168
|
+
entity: Entity,
|
|
169
|
+
component: Entity,
|
|
170
|
+
filter?: MemberFilter
|
|
171
|
+
): void;
|
|
172
|
+
set_pair(
|
|
173
|
+
server: Server,
|
|
174
|
+
entity: Entity,
|
|
175
|
+
relation: Entity,
|
|
176
|
+
filter?: MemberFilter
|
|
177
|
+
): void;
|
|
178
|
+
set_custom(
|
|
179
|
+
server: Server,
|
|
180
|
+
entity: Entity,
|
|
181
|
+
handler: Entity | CustomId
|
|
182
|
+
): void;
|
|
183
|
+
|
|
184
|
+
stop_reliable(server: Server, entity: Entity, component: Entity): void;
|
|
185
|
+
stop_unreliable(server: Server, entity: Entity, component: Entity): void;
|
|
186
|
+
stop_pair(server: Server, entity: Entity, relation: Entity): void;
|
|
187
|
+
remove_custom(server: Server, entity: Entity): void;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface Server extends ServerImp {
|
|
112
191
|
world: World;
|
|
113
192
|
inited?: boolean;
|
|
114
193
|
|
|
115
194
|
init(world?: World): void;
|
|
116
195
|
destroy(): void;
|
|
117
196
|
|
|
197
|
+
encode_component(component: Entity): number;
|
|
198
|
+
decode_component(encoded: number): Entity;
|
|
199
|
+
register_custom_id(custom_id: CustomId): void;
|
|
200
|
+
|
|
118
201
|
get_full(player: Player): LuaTuple<[buffer, unknown[][]]>;
|
|
119
202
|
collect_updates(): IterableFunction<
|
|
120
203
|
LuaTuple<[Player, buffer, unknown[][]]>
|
|
@@ -123,16 +206,16 @@ declare namespace Replecs {
|
|
|
123
206
|
LuaTuple<[Player, buffer, unknown[][]]>
|
|
124
207
|
>;
|
|
125
208
|
|
|
126
|
-
encode_component(component: Entity): number;
|
|
127
|
-
decode_component(encoded: number): Entity;
|
|
128
|
-
|
|
129
209
|
mark_player_ready(player: Player): void;
|
|
130
210
|
is_player_ready(player: Player): boolean;
|
|
131
211
|
|
|
132
212
|
add_player_alias(client: Player, alias: defined): void;
|
|
133
213
|
remove_player_alias(alias: defined): void;
|
|
134
214
|
|
|
135
|
-
|
|
215
|
+
generate_handshake(): HandshakeInfo;
|
|
216
|
+
verify_handshake(
|
|
217
|
+
handshake: HandshakeInfo
|
|
218
|
+
): LuaTuple<[true]> | LuaTuple<[false, string]>;
|
|
136
219
|
}
|
|
137
220
|
|
|
138
221
|
export interface ReplecsLib {
|
|
@@ -140,12 +223,19 @@ declare namespace Replecs {
|
|
|
140
223
|
server: Server;
|
|
141
224
|
|
|
142
225
|
after_replication(callback: () => void): void;
|
|
226
|
+
register_custom_id(custom_id: CustomId): void;
|
|
143
227
|
}
|
|
144
228
|
|
|
145
229
|
export interface Replecs extends Components {
|
|
230
|
+
VERSION: string;
|
|
231
|
+
|
|
146
232
|
create: (world?: World) => ReplecsLib;
|
|
147
233
|
create_server: (world?: World) => Server;
|
|
148
234
|
create_client: (world?: World) => Client;
|
|
235
|
+
create_custom_id: (
|
|
236
|
+
identifier: string,
|
|
237
|
+
handler?: (ctx: HandleContext) => Entity
|
|
238
|
+
) => CustomId;
|
|
149
239
|
}
|
|
150
240
|
}
|
|
151
241
|
|
package/out/replecs/init.luau
CHANGED
|
@@ -3,15 +3,32 @@ local common = require "@self/common"
|
|
|
3
3
|
|
|
4
4
|
local client = require "@self/client"
|
|
5
5
|
local server = require "@self/server"
|
|
6
|
+
local customid = require "@self/customid"
|
|
7
|
+
local VERSION = require "@self/ver"
|
|
6
8
|
|
|
7
9
|
export type Server = server.Server
|
|
8
10
|
export type Client = client.Client
|
|
9
11
|
|
|
12
|
+
export type HandleContext = customid.HandleContext
|
|
13
|
+
export type CustomId = customid.CustomId
|
|
14
|
+
export type HandshakeInfo = common.HandshakeInfo
|
|
15
|
+
|
|
16
|
+
type Entity = jecs.Entity
|
|
17
|
+
|
|
10
18
|
export type ReplecsLib = {
|
|
11
19
|
server: Server,
|
|
12
20
|
client: Client,
|
|
13
21
|
|
|
14
22
|
after_replication: (self: ReplecsLib, callback: () -> ()) -> (),
|
|
23
|
+
register_custom_id: (self: ReplecsLib, custom_id: CustomId) -> (),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type Replecs = common.Components & {
|
|
27
|
+
create: (world: jecs.World?) -> ReplecsLib,
|
|
28
|
+
|
|
29
|
+
create_server: (world: jecs.World?) -> Server,
|
|
30
|
+
create_client: (world: jecs.World?) -> Client,
|
|
31
|
+
create_custom_id: (identifier: string, handler: (ctx: HandleContext) -> Entity?) -> CustomId,
|
|
15
32
|
}
|
|
16
33
|
|
|
17
34
|
type MemberFilter = {
|
|
@@ -19,23 +36,22 @@ type MemberFilter = {
|
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
local replecs = {
|
|
39
|
+
VERSION = VERSION,
|
|
22
40
|
shared = jecs.tag(),
|
|
23
|
-
networked = jecs.component()
|
|
24
|
-
reliable = jecs.component()
|
|
25
|
-
unreliable = jecs.component()
|
|
26
|
-
pair = jecs.component()
|
|
27
|
-
|
|
28
|
-
serdes = jecs.component()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
global = jecs.component() :: jecs.Entity<number>,
|
|
41
|
+
networked = jecs.component(),
|
|
42
|
+
reliable = jecs.component(),
|
|
43
|
+
unreliable = jecs.component(),
|
|
44
|
+
pair = jecs.component(),
|
|
45
|
+
|
|
46
|
+
serdes = jecs.component(),
|
|
47
|
+
custom = jecs.tag(),
|
|
48
|
+
custom_handler = jecs.component(),
|
|
49
|
+
global = jecs.component(),
|
|
33
50
|
__alive_tracking__ = jecs.tag(),
|
|
34
51
|
}
|
|
35
52
|
|
|
36
53
|
replecs.__index = replecs
|
|
37
54
|
replecs.Serdes = replecs.serdes
|
|
38
|
-
replecs.Bytespan = replecs.bytespan
|
|
39
55
|
replecs.Custom = replecs.custom
|
|
40
56
|
replecs.CustomHandler = replecs.custom_handler
|
|
41
57
|
replecs.Networked = replecs.networked
|
|
@@ -46,7 +62,6 @@ replecs.Shared = replecs.shared
|
|
|
46
62
|
replecs.Global = replecs.global
|
|
47
63
|
|
|
48
64
|
jecs.meta(replecs.serdes, jecs.Name, "replecs.serdes")
|
|
49
|
-
jecs.meta(replecs.bytespan, jecs.Name, "replecs.bytespan")
|
|
50
65
|
jecs.meta(replecs.custom, jecs.Name, "replecs.custom")
|
|
51
66
|
jecs.meta(replecs.custom_handler, jecs.Name, "replecs.custom_handler")
|
|
52
67
|
jecs.meta(replecs.networked, jecs.Name, "replecs.networked")
|
|
@@ -62,11 +77,11 @@ jecs.meta(replecs.custom, jecs.Exclusive)
|
|
|
62
77
|
jecs.meta(replecs.global, jecs.Exclusive)
|
|
63
78
|
|
|
64
79
|
function replecs.create_server(world: jecs.World?): Server
|
|
65
|
-
return server.create(world, replecs)
|
|
80
|
+
return server.create(world, replecs :: Replecs)
|
|
66
81
|
end
|
|
67
82
|
|
|
68
83
|
function replecs.create_client(world: jecs.World?): Client
|
|
69
|
-
return client.create(world, replecs)
|
|
84
|
+
return client.create(world, replecs :: Replecs)
|
|
70
85
|
end
|
|
71
86
|
|
|
72
87
|
function replecs.create(world: jecs.World?): ReplecsLib
|
|
@@ -76,15 +91,19 @@ function replecs.create(world: jecs.World?): ReplecsLib
|
|
|
76
91
|
local lib = {} :: ReplecsLib
|
|
77
92
|
|
|
78
93
|
if RunService:IsServer() then
|
|
79
|
-
lib.server = server.create(world, replecs)
|
|
94
|
+
lib.server = server.create(world, replecs :: Replecs)
|
|
80
95
|
end
|
|
81
96
|
if RunService:IsClient() then
|
|
82
|
-
lib.client = client.create(world, replecs)
|
|
97
|
+
lib.client = client.create(world, replecs :: Replecs)
|
|
83
98
|
end
|
|
84
99
|
|
|
85
100
|
return setmetatable(lib, replecs) :: any
|
|
86
101
|
end
|
|
87
102
|
|
|
103
|
+
function replecs.create_custom_id(identifier: string, handler: (ctx: HandleContext) -> Entity?)
|
|
104
|
+
return customid.create(identifier, handler)
|
|
105
|
+
end
|
|
106
|
+
|
|
88
107
|
function replecs.after_replication(lib: ReplecsLib, callback: () -> ())
|
|
89
108
|
local lib_client = lib.client
|
|
90
109
|
if lib_client then
|
|
@@ -94,4 +113,13 @@ function replecs.after_replication(lib: ReplecsLib, callback: () -> ())
|
|
|
94
113
|
end
|
|
95
114
|
end
|
|
96
115
|
|
|
97
|
-
|
|
116
|
+
function replecs.register_custom_id(lib: ReplecsLib, custom_id: CustomId)
|
|
117
|
+
if lib.server then
|
|
118
|
+
lib.server:register_custom_id(custom_id)
|
|
119
|
+
end
|
|
120
|
+
if lib.client then
|
|
121
|
+
lib.client:register_custom_id(custom_id)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
return replecs :: Replecs
|