jecs/demo/src/ReplicatedStorage/remotes.luau

43 lines
1 KiB
Text
Raw Normal View History

2025-06-05 20:48:13 +00:00
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local types = require("../ReplicatedStorage/types")
type Remote<T...> = {
2025-07-24 00:24:25 +00:00
FireClient: (Remote<T...>, Player, T...) -> (),
2025-06-05 20:48:13 +00:00
FireAllClients: (Remote<T...>, T...) -> (),
2025-07-24 00:24:25 +00:00
FireServer: (Remote<T...>, T...) -> (),
OnServerEvent: RBXScriptSignal<(Player, T...)>,
OnClientEvent: RBXScriptSignal<T...>
2025-06-05 20:48:13 +00:00
}
2025-07-24 00:24:25 +00:00
local function stream_ensure(name)
2025-06-05 20:48:13 +00:00
local remote = ReplicatedStorage:FindFirstChild(name)
if not remote then
remote = Instance.new("RemoteEvent")
remote.Name = name
remote.Parent = ReplicatedStorage
end
2025-07-24 00:24:25 +00:00
return remote
2025-06-05 20:48:13 +00:00
end
2025-07-24 00:24:25 +00:00
local function datagram_ensure(name)
2025-06-05 20:48:13 +00:00
local remote = ReplicatedStorage:FindFirstChild(name)
if not remote then
remote = Instance.new("UnreliableRemoteEvent")
remote.Name = name
remote.Parent = ReplicatedStorage
end
2025-07-24 00:24:25 +00:00
return remote
2025-06-05 20:48:13 +00:00
end
return {
input = datagram_ensure("input") :: Remote<string>,
replication = stream_ensure("replication") :: Remote<{
[string]: {
set: { types.Entity }?,
values: { any }?,
removed: { types.Entity }?
}
}>,
}