@rbxts/replecs 0.2.3 → 0.2.4
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/README.md +0 -2
- package/out/replecs/client.luau +620 -320
- package/out/replecs/common.luau +184 -59
- package/out/replecs/customid.luau +9 -8
- package/out/replecs/index.d.ts +229 -229
- package/out/replecs/init.luau +53 -66
- package/out/replecs/masking/init.luau +521 -384
- package/out/replecs/masking/mask_generator.luau +1 -1
- package/out/replecs/server.luau +953 -440
- package/out/replecs/types.luau +67 -0
- package/out/replecs/utils.luau +257 -198
- package/out/replecs/ver.luau +1 -2
- package/out/tsconfig.tsbuildinfo +1 -0
- package/package.json +47 -45
package/out/replecs/index.d.ts
CHANGED
|
@@ -1,229 +1,229 @@
|
|
|
1
|
-
import type { Entity, Id, Pair, Tag, World } from "@rbxts/jecs";
|
|
2
|
-
|
|
3
|
-
declare namespace Replecs {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
declare const Replecs: Replecs.Replecs;
|
|
228
|
-
|
|
229
|
-
export = Replecs;
|
|
1
|
+
import type { Entity, Id, Pair, Tag, World } from "@rbxts/jecs";
|
|
2
|
+
|
|
3
|
+
declare namespace Replecs {
|
|
4
|
+
export type SerdesTable =
|
|
5
|
+
| {
|
|
6
|
+
bytespan?: number;
|
|
7
|
+
includes_variants?: false;
|
|
8
|
+
serialize: (value: any) => buffer;
|
|
9
|
+
deserialize: (buffer: buffer) => any;
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
bytespan?: number;
|
|
13
|
+
includes_variants: true;
|
|
14
|
+
serialize: (value: any) => LuaTuple<[buffer, defined[] | undefined]>;
|
|
15
|
+
deserialize: (buffer: buffer, blobs: defined[] | undefined) => any;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type MemberFilterMap = Map<Player, boolean>;
|
|
19
|
+
type MemberFilter = Player | MemberFilterMap | undefined;
|
|
20
|
+
type Member = unknown;
|
|
21
|
+
|
|
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>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface Components {
|
|
60
|
+
shared: Tag;
|
|
61
|
+
networked: Entity<MemberFilter>;
|
|
62
|
+
reliable: Entity<MemberFilter>;
|
|
63
|
+
unreliable: Entity<MemberFilter>;
|
|
64
|
+
relation: Entity<MemberFilter>;
|
|
65
|
+
|
|
66
|
+
serdes: Entity<SerdesTable>;
|
|
67
|
+
custom: Entity;
|
|
68
|
+
custom_handler: Entity<(value: any) => Entity>;
|
|
69
|
+
global: Entity<number>;
|
|
70
|
+
|
|
71
|
+
Shared: Tag;
|
|
72
|
+
Networked: Entity<MemberFilter>;
|
|
73
|
+
Reliable: Entity<MemberFilter>;
|
|
74
|
+
Unreliable: Entity<MemberFilter>;
|
|
75
|
+
Relation: Entity<MemberFilter>;
|
|
76
|
+
|
|
77
|
+
Serdes: Entity<SerdesTable>;
|
|
78
|
+
Custom: Entity;
|
|
79
|
+
CustomHandler: Entity<(value: any) => Entity>;
|
|
80
|
+
Global: Entity<number>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface Client {
|
|
84
|
+
world: World;
|
|
85
|
+
inited?: boolean;
|
|
86
|
+
|
|
87
|
+
is_relicating: boolean;
|
|
88
|
+
after_relication_callbacks: [() => void];
|
|
89
|
+
|
|
90
|
+
components: Components;
|
|
91
|
+
|
|
92
|
+
init(world?: World): void;
|
|
93
|
+
destroy(): void;
|
|
94
|
+
|
|
95
|
+
handle_global(handler: (id: number) => Entity): void;
|
|
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
|
+
|
|
103
|
+
after_replication(callback: () => void): void;
|
|
104
|
+
added(callback: (entity: Entity) => void): () => void;
|
|
105
|
+
|
|
106
|
+
hook<T>(
|
|
107
|
+
action: "changed",
|
|
108
|
+
relation: Pair<MemberFilter, T>,
|
|
109
|
+
callback: (entity: Entity, id: Id<T>, value: T) => void,
|
|
110
|
+
): () => void;
|
|
111
|
+
hook<T>(
|
|
112
|
+
action: "removed",
|
|
113
|
+
relation: Pair<MemberFilter, T>,
|
|
114
|
+
callback: (entity: Entity, id: Id<T>) => void,
|
|
115
|
+
): () => void;
|
|
116
|
+
hook(
|
|
117
|
+
action: "deleted",
|
|
118
|
+
entity: Entity,
|
|
119
|
+
callback: (entity: Entity) => void,
|
|
120
|
+
): () => void;
|
|
121
|
+
|
|
122
|
+
override<T>(
|
|
123
|
+
action: "changed",
|
|
124
|
+
relation: Pair<MemberFilter, T>,
|
|
125
|
+
callback: (entity: Entity, id: Id<T>, value: any) => void,
|
|
126
|
+
): () => void;
|
|
127
|
+
override<T>(
|
|
128
|
+
action: "removed",
|
|
129
|
+
relation: Pair<MemberFilter, T>,
|
|
130
|
+
callback: (entity: Entity, id: Id<T>) => void,
|
|
131
|
+
): () => void;
|
|
132
|
+
override(
|
|
133
|
+
action: "deleted",
|
|
134
|
+
entity: Entity,
|
|
135
|
+
callback: (entity: Entity) => void,
|
|
136
|
+
): () => void;
|
|
137
|
+
|
|
138
|
+
encode_component(component: Entity): number;
|
|
139
|
+
decode_component(encoded: number): Entity;
|
|
140
|
+
register_custom_id(custom_id: CustomId): void;
|
|
141
|
+
|
|
142
|
+
apply_updates(buf: buffer, all_variants?: defined[][]): void;
|
|
143
|
+
apply_unreliable(buf: buffer, all_variants?: defined[][]): void;
|
|
144
|
+
apply_full(buf: buffer, all_variants?: defined[][]): void;
|
|
145
|
+
|
|
146
|
+
generate_handshake(): HandshakeInfo;
|
|
147
|
+
verify_handshake(
|
|
148
|
+
handshake: HandshakeInfo,
|
|
149
|
+
): LuaTuple<[true]> | LuaTuple<[false, string]>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface ServerImp {
|
|
153
|
+
set_networked(entity: Entity, filter?: MemberFilter): void;
|
|
154
|
+
set_reliable(
|
|
155
|
+
entity: Entity,
|
|
156
|
+
component: Entity,
|
|
157
|
+
filter?: MemberFilter,
|
|
158
|
+
): void;
|
|
159
|
+
set_unreliable(
|
|
160
|
+
entity: Entity,
|
|
161
|
+
component: Entity,
|
|
162
|
+
filter?: MemberFilter,
|
|
163
|
+
): void;
|
|
164
|
+
set_relation(entity: Entity, relation: Entity, filter?: MemberFilter): void;
|
|
165
|
+
|
|
166
|
+
stop_networked(entity: Entity, keep?: boolean): void;
|
|
167
|
+
stop_reliable(entity: Entity, component: Entity, keep?: boolean): void;
|
|
168
|
+
stop_unreliable(entity: Entity, component: Entity, keep?: boolean): void;
|
|
169
|
+
stop_relation(entity: Entity, relation: Entity, keep?: boolean): void;
|
|
170
|
+
|
|
171
|
+
set_custom(entity: Entity, handler: Entity | CustomId): void;
|
|
172
|
+
remove_custom(entity: Entity): void;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface Server extends ServerImp {
|
|
176
|
+
world: World;
|
|
177
|
+
inited?: boolean;
|
|
178
|
+
|
|
179
|
+
init(world?: World): void;
|
|
180
|
+
destroy(): void;
|
|
181
|
+
|
|
182
|
+
encode_component(component: Entity): number;
|
|
183
|
+
decode_component(encoded: number): Entity;
|
|
184
|
+
register_custom_id(custom_id: CustomId): void;
|
|
185
|
+
|
|
186
|
+
get_full(player: Player): LuaTuple<[buffer, defined[][]?]>;
|
|
187
|
+
collect_updates(): IterableFunction<
|
|
188
|
+
LuaTuple<[Player, buffer, defined[][]?]>
|
|
189
|
+
>;
|
|
190
|
+
collect_unreliable(): IterableFunction<
|
|
191
|
+
LuaTuple<[Player, buffer, defined[][]?]>
|
|
192
|
+
>;
|
|
193
|
+
|
|
194
|
+
mark_player_ready(player: Player): void;
|
|
195
|
+
is_player_ready(player: Player): boolean;
|
|
196
|
+
|
|
197
|
+
add_player_alias(client: Player, alias: defined): void;
|
|
198
|
+
remove_player_alias(alias: defined): void;
|
|
199
|
+
|
|
200
|
+
generate_handshake(): HandshakeInfo;
|
|
201
|
+
verify_handshake(
|
|
202
|
+
handshake: HandshakeInfo,
|
|
203
|
+
): LuaTuple<[true]> | LuaTuple<[false, string]>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface ReplecsLib {
|
|
207
|
+
client: Client;
|
|
208
|
+
server: Server;
|
|
209
|
+
|
|
210
|
+
after_replication(callback: () => void): void;
|
|
211
|
+
register_custom_id(custom_id: CustomId): void;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface Replecs extends Components {
|
|
215
|
+
VERSION: string;
|
|
216
|
+
|
|
217
|
+
create: (world?: World) => ReplecsLib;
|
|
218
|
+
create_server: (world?: World) => Server;
|
|
219
|
+
create_client: (world?: World) => Client;
|
|
220
|
+
create_custom_id: (
|
|
221
|
+
identifier: string,
|
|
222
|
+
handler?: (ctx: HandleContext) => Entity,
|
|
223
|
+
) => CustomId;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare const Replecs: Replecs.Replecs;
|
|
228
|
+
|
|
229
|
+
export = Replecs;
|
package/out/replecs/init.luau
CHANGED
|
@@ -1,103 +1,90 @@
|
|
|
1
|
-
local jecs = require
|
|
2
|
-
local common = require
|
|
1
|
+
local jecs = require (script.Parent:WaitForChild('jecs'))
|
|
2
|
+
local common = require (script:WaitForChild('common'))
|
|
3
|
+
local types = require (script:WaitForChild('types'))
|
|
4
|
+
local utils = require (script:WaitForChild('utils'))
|
|
3
5
|
|
|
4
|
-
local client = require
|
|
5
|
-
local server = require
|
|
6
|
-
local customid = require
|
|
7
|
-
local VERSION = require
|
|
6
|
+
local client = require (script:WaitForChild('client'))
|
|
7
|
+
local server = require (script:WaitForChild('server'))
|
|
8
|
+
local customid = require (script:WaitForChild('customid'))
|
|
9
|
+
local VERSION = require (script:WaitForChild('ver'))
|
|
8
10
|
|
|
9
11
|
export type Server = server.Server
|
|
10
12
|
export type Client = client.Client
|
|
11
13
|
|
|
14
|
+
type Entity = common.Entity
|
|
15
|
+
type World = common.World
|
|
16
|
+
|
|
12
17
|
export type HandleContext = customid.HandleContext
|
|
13
18
|
export type CustomId = customid.CustomId
|
|
14
|
-
export type HandshakeInfo =
|
|
15
|
-
|
|
16
|
-
type Entity = jecs.Entity
|
|
19
|
+
export type HandshakeInfo = types.HandshakeInfo
|
|
20
|
+
export type Serdes = types.Serdes
|
|
17
21
|
|
|
18
22
|
export type ReplecsLib = {
|
|
19
23
|
server: Server,
|
|
20
24
|
client: Client,
|
|
25
|
+
components: types.Components,
|
|
21
26
|
|
|
22
27
|
after_replication: (self: ReplecsLib, callback: () -> ()) -> (),
|
|
23
28
|
register_custom_id: (self: ReplecsLib, custom_id: CustomId) -> (),
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
type Replecs =
|
|
27
|
-
|
|
31
|
+
type Replecs = types.Components & {
|
|
32
|
+
__index: any,
|
|
33
|
+
VERSION: string,
|
|
34
|
+
create: (world: World?) -> ReplecsLib,
|
|
28
35
|
|
|
29
|
-
create_server: (world:
|
|
30
|
-
create_client: (world:
|
|
36
|
+
create_server: (world: World?) -> Server,
|
|
37
|
+
create_client: (world: World?) -> Client,
|
|
31
38
|
create_custom_id: (identifier: string, handler: (ctx: HandleContext) -> Entity?) -> CustomId,
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
local replecs = {}
|
|
42
|
+
replecs.VERSION = VERSION
|
|
43
|
+
replecs.__index = replecs
|
|
37
44
|
|
|
38
|
-
local
|
|
39
|
-
VERSION = VERSION,
|
|
40
|
-
shared = jecs.tag(),
|
|
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(),
|
|
50
|
-
__alive_tracking__ = jecs.tag(),
|
|
51
|
-
}
|
|
45
|
+
local PREREGISTRATION = common.preregistration
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
replecs.Pair = replecs.pair
|
|
61
|
-
replecs.Shared = replecs.shared
|
|
62
|
-
replecs.Global = replecs.global
|
|
63
|
-
|
|
64
|
-
jecs.meta(replecs.serdes, jecs.Name, "replecs.serdes")
|
|
65
|
-
jecs.meta(replecs.custom, jecs.Name, "replecs.custom")
|
|
66
|
-
jecs.meta(replecs.custom_handler, jecs.Name, "replecs.custom_handler")
|
|
67
|
-
jecs.meta(replecs.networked, jecs.Name, "replecs.networked")
|
|
68
|
-
jecs.meta(replecs.reliable, jecs.Name, "replecs.reliable")
|
|
69
|
-
jecs.meta(replecs.unreliable, jecs.Name, "replecs.unreliable")
|
|
70
|
-
jecs.meta(replecs.pair, jecs.Name, "replecs.pair")
|
|
71
|
-
jecs.meta(replecs.shared, jecs.Name, "replecs.shared")
|
|
72
|
-
jecs.meta(replecs.global, jecs.Name, "replecs.global")
|
|
73
|
-
|
|
74
|
-
jecs.meta(replecs.__alive_tracking__, jecs.Name, "replecs.__alive_tracking__")
|
|
75
|
-
|
|
76
|
-
jecs.meta(replecs.custom, jecs.Exclusive)
|
|
77
|
-
jecs.meta(replecs.global, jecs.Exclusive)
|
|
78
|
-
|
|
79
|
-
function replecs.create_server(world: jecs.World?): Server
|
|
80
|
-
return server.create(world, replecs :: Replecs)
|
|
47
|
+
if PREREGISTRATION then
|
|
48
|
+
local components = replecs :: Replecs
|
|
49
|
+
utils.create_components(common.preregister_tag, common.preregister_component, components)
|
|
50
|
+
utils.add_component_names(components, common.add_preregistered_name)
|
|
51
|
+
|
|
52
|
+
jecs.meta(components.custom, jecs.Exclusive)
|
|
53
|
+
jecs.meta(components.global, jecs.Exclusive)
|
|
81
54
|
end
|
|
82
55
|
|
|
83
|
-
|
|
84
|
-
|
|
56
|
+
local COMPONENTS = if PREREGISTRATION then replecs :: Replecs else nil
|
|
57
|
+
|
|
58
|
+
function replecs.create_server(world: World?): Server
|
|
59
|
+
return server.create(world, COMPONENTS)
|
|
85
60
|
end
|
|
86
61
|
|
|
87
|
-
function replecs.
|
|
88
|
-
|
|
62
|
+
function replecs.create_client(world: World?): Client
|
|
63
|
+
return client.create(world, COMPONENTS)
|
|
64
|
+
end
|
|
89
65
|
|
|
66
|
+
function replecs.create(world: World?): ReplecsLib
|
|
67
|
+
assert(game, "This is a Roblox specific function")
|
|
90
68
|
local RunService = game:GetService "RunService"
|
|
91
|
-
local
|
|
69
|
+
local self = {} :: ReplecsLib
|
|
70
|
+
|
|
71
|
+
if COMPONENTS then
|
|
72
|
+
self.components = COMPONENTS
|
|
73
|
+
elseif world then
|
|
74
|
+
self.components = utils.create_components(utils.tag_factory(world), utils.component_factory(world))
|
|
75
|
+
utils.add_component_names(self.components, function(component, name)
|
|
76
|
+
common.add_name(world, component, name)
|
|
77
|
+
end)
|
|
78
|
+
end
|
|
92
79
|
|
|
93
80
|
if RunService:IsServer() then
|
|
94
|
-
|
|
81
|
+
self.server = server.create(world, self.components)
|
|
95
82
|
end
|
|
96
83
|
if RunService:IsClient() then
|
|
97
|
-
|
|
84
|
+
self.client = client.create(world, self.components)
|
|
98
85
|
end
|
|
99
86
|
|
|
100
|
-
return setmetatable(
|
|
87
|
+
return setmetatable(self, replecs) :: any
|
|
101
88
|
end
|
|
102
89
|
|
|
103
90
|
function replecs.create_custom_id(identifier: string, handler: (ctx: HandleContext) -> Entity?)
|