@rbxts/replecs 0.2.3 → 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/README.md +0 -2
- package/out/replecs/client.luau +625 -321
- package/out/replecs/common.luau +184 -59
- package/out/replecs/customid.luau +9 -8
- package/out/replecs/index.d.ts +257 -229
- package/out/replecs/init.luau +75 -66
- package/out/replecs/masking/init.luau +494 -429
- package/out/replecs/masking/mask_generator.luau +1 -1
- package/out/replecs/server.luau +1030 -465
- 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 +46 -44
package/out/replecs/init.luau
CHANGED
|
@@ -1,103 +1,94 @@
|
|
|
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
|
+
type Component<T = any> = common.Component<T>
|
|
17
|
+
|
|
12
18
|
export type HandleContext = customid.HandleContext
|
|
13
19
|
export type CustomId = customid.CustomId
|
|
14
|
-
export type HandshakeInfo =
|
|
15
|
-
|
|
16
|
-
type Entity = jecs.Entity
|
|
20
|
+
export type HandshakeInfo = types.HandshakeInfo
|
|
21
|
+
export type Serdes = types.Serdes
|
|
17
22
|
|
|
18
23
|
export type ReplecsLib = {
|
|
19
24
|
server: Server,
|
|
20
25
|
client: Client,
|
|
26
|
+
components: types.Components,
|
|
21
27
|
|
|
22
28
|
after_replication: (self: ReplecsLib, callback: () -> ()) -> (),
|
|
23
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) -> (),
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
type Replecs =
|
|
27
|
-
|
|
35
|
+
type Replecs = types.Components & {
|
|
36
|
+
__index: any,
|
|
37
|
+
VERSION: string,
|
|
38
|
+
create: (world: World?) -> ReplecsLib,
|
|
28
39
|
|
|
29
|
-
create_server: (world:
|
|
30
|
-
create_client: (world:
|
|
40
|
+
create_server: (world: World?) -> Server,
|
|
41
|
+
create_client: (world: World?) -> Client,
|
|
31
42
|
create_custom_id: (identifier: string, handler: (ctx: HandleContext) -> Entity?) -> CustomId,
|
|
32
43
|
}
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
local replecs = {}
|
|
46
|
+
replecs.VERSION = VERSION
|
|
47
|
+
replecs.__index = replecs
|
|
37
48
|
|
|
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
|
-
}
|
|
49
|
+
local PREREGISTRATION = common.preregistration
|
|
52
50
|
|
|
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)
|
|
51
|
+
if PREREGISTRATION then
|
|
52
|
+
local components = replecs :: Replecs
|
|
53
|
+
utils.create_components(common.preregister_tag, common.preregister_component, components)
|
|
54
|
+
utils.add_component_names(components, common.add_preregistered_name)
|
|
55
|
+
|
|
56
|
+
jecs.meta(components.custom, jecs.Exclusive)
|
|
57
|
+
jecs.meta(components.global, jecs.Exclusive)
|
|
81
58
|
end
|
|
82
59
|
|
|
83
|
-
|
|
84
|
-
|
|
60
|
+
local COMPONENTS = if PREREGISTRATION then replecs :: Replecs else nil
|
|
61
|
+
|
|
62
|
+
function replecs.create_server(world: World?): Server
|
|
63
|
+
return server.create(world, COMPONENTS)
|
|
85
64
|
end
|
|
86
65
|
|
|
87
|
-
function replecs.
|
|
88
|
-
|
|
66
|
+
function replecs.create_client(world: World?): Client
|
|
67
|
+
return client.create(world, COMPONENTS)
|
|
68
|
+
end
|
|
89
69
|
|
|
70
|
+
function replecs.create(world: World?): ReplecsLib
|
|
71
|
+
assert(game, "This is a Roblox specific function")
|
|
90
72
|
local RunService = game:GetService "RunService"
|
|
91
|
-
local
|
|
73
|
+
local self = {} :: ReplecsLib
|
|
74
|
+
|
|
75
|
+
if COMPONENTS then
|
|
76
|
+
self.components = COMPONENTS
|
|
77
|
+
elseif world then
|
|
78
|
+
self.components = utils.create_components(utils.tag_factory(world), utils.component_factory(world))
|
|
79
|
+
utils.add_component_names(self.components, function(component, name)
|
|
80
|
+
common.add_name(world, component, name)
|
|
81
|
+
end)
|
|
82
|
+
end
|
|
92
83
|
|
|
93
84
|
if RunService:IsServer() then
|
|
94
|
-
|
|
85
|
+
self.server = server.create(world, self.components)
|
|
95
86
|
end
|
|
96
87
|
if RunService:IsClient() then
|
|
97
|
-
|
|
88
|
+
self.client = client.create(world, self.components)
|
|
98
89
|
end
|
|
99
90
|
|
|
100
|
-
return setmetatable(
|
|
91
|
+
return setmetatable(self, replecs) :: any
|
|
101
92
|
end
|
|
102
93
|
|
|
103
94
|
function replecs.create_custom_id(identifier: string, handler: (ctx: HandleContext) -> Entity?)
|
|
@@ -122,4 +113,22 @@ function replecs.register_custom_id(lib: ReplecsLib, custom_id: CustomId)
|
|
|
122
113
|
end
|
|
123
114
|
end
|
|
124
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
|
+
|
|
125
134
|
return replecs :: Replecs
|