cluaupp 1.5.0 → 1.5.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/CHANGELOG.md +47 -0
- package/README.md +10 -5
- package/api/CHANGELOG.md +3 -0
- package/api/chat.js +74 -0
- package/api/fixtures/roblox/README.md +6 -0
- package/api/fixtures/roblox/aux/sample.d.luau +6 -0
- package/api/fixtures/roblox/mini/Mini-API-Dump.json +72 -0
- package/api/generated/bench-latest.json +39 -0
- package/api/generated/capability-profile.json +76 -0
- package/api/generated/lsp-index.json +1 -0
- package/api/generated/luau/classes.d.luau +11221 -0
- package/api/generated/luau/datatypes.d.luau +327 -0
- package/api/generated/luau/enums.d.luau +4918 -0
- package/api/generated/luau/globals.d.luau +12 -0
- package/api/manifests/roblox-target.manifest.json +22 -0
- package/api/normalized/roblox-target.profile.json +237461 -0
- package/api/overrides/classes.json +8 -0
- package/api/overrides/compatibility.json +9 -0
- package/api/overrides/datatypes.json +1579 -0
- package/api/overrides/enums.json +8 -0
- package/api/overrides/globals.json +8 -0
- package/api/overrides/type-mappings.json +9 -0
- package/api/roblox-api.lock.json +9 -0
- package/data/Mini-API-Dump.json +1 -0
- package/editors/vscode/README.md +12 -10
- package/editors/vscode/extension.js +82 -0
- package/editors/vscode/icons/axiom.svg +4 -0
- package/editors/vscode/icons/bloom.svg +5 -0
- package/editors/vscode/icons/helm.svg +4 -0
- package/editors/vscode/icons/hive.svg +5 -0
- package/editors/vscode/icons/mint.svg +4 -0
- package/editors/vscode/icons/shift.svg +6 -0
- package/editors/vscode/language-configuration-schema.json +24 -0
- package/editors/vscode/package.json +172 -12
- package/editors/vscode/snippets/axiom.json +12 -0
- package/editors/vscode/snippets/bloom.json +12 -0
- package/editors/vscode/snippets/helm.json +12 -0
- package/editors/vscode/snippets/hive.json +12 -0
- package/editors/vscode/snippets/mint.json +12 -0
- package/editors/vscode/snippets/shift.json +17 -0
- package/editors/vscode/syntaxes/axiom.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/bloom.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/helm.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/hive.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/mint.tmLanguage.json +5 -0
- package/editors/vscode/syntaxes/schema.tmLanguage.json +89 -0
- package/editors/vscode/syntaxes/shift.tmLanguage.json +5 -0
- package/examples/game/.cluaupp/compile-cache/ReplicatedStorage__Shared__Constants__Datas__TemplateData.clh.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Boot__DataBoot.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Configuration__ServerConfig.clp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__Guard.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__PlayerHandler.server.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterCharacterScripts__Character__CharacterReady.client.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterPlayerScripts__Controllers__DataController.client.clpp.json +1 -0
- package/examples/game/.cluaupp/compile-cache/index.json +12 -0
- package/examples/game/.cluaupp/datamodel-profile.json +94 -0
- package/examples/game/.vscode/settings.json +12 -1
- package/examples/game/include/clpp/datatypes.clh +337 -373
- package/examples/game/include/clpp/generated/datamodel.clh +25 -0
- package/examples/game/include/clpp/generated/enums.clh +1 -1
- package/examples/game/include/clpp/generated/instances.clh +41135 -41064
- package/examples/game/include/clpp/libs/axiom.clh +1 -1
- package/examples/game/include/clpp/libs/math.clh +14 -0
- package/examples/game/include/clpp/libs/spring.clh +17 -0
- package/examples/game/include/clpp/libs/ward.clh +1 -0
- package/examples/game/include/clpp/roblox.clh +3 -4
- package/examples/game/libs/ArrayIndexer/init.luau +209 -0
- package/examples/game/libs/Axiom/init.luau +608 -0
- package/examples/game/libs/Bloom/init.luau +433 -0
- package/examples/game/libs/Coil/init.luau +215 -0
- package/examples/game/libs/Crest/init.luau +426 -0
- package/examples/game/libs/Echo/init.luau +417 -0
- package/examples/game/libs/Ember/init.luau +365 -0
- package/examples/game/libs/Flare/init.luau +717 -0
- package/examples/game/libs/Gleam/init.luau +729 -0
- package/examples/game/libs/Guide/init.luau +215 -0
- package/examples/game/libs/Helm/init.luau +377 -0
- package/examples/game/libs/Hive/init.luau +241 -0
- package/examples/game/libs/Keep/Client.luau +114 -0
- package/examples/game/libs/Keep/Data.luau +883 -0
- package/examples/game/libs/Keep/Engine.luau +211 -0
- package/examples/game/libs/Keep/Enum.luau +6 -0
- package/examples/game/libs/Keep/Enums.luau +10 -0
- package/examples/game/libs/Keep/Path.luau +236 -0
- package/examples/game/libs/Keep/Replicator.luau +298 -0
- package/examples/game/libs/Keep/Server.luau +251 -0
- package/examples/game/libs/Keep/Store.luau +652 -0
- package/examples/game/libs/Keep/Trade.luau +455 -0
- package/examples/game/libs/Keep/init.luau +205 -0
- package/examples/game/libs/Lens/init.luau +609 -0
- package/examples/game/libs/Mint/init.luau +279 -0
- package/examples/game/libs/Net/init.luau +156 -0
- package/examples/game/libs/Net/src/codec.luau +224 -0
- package/examples/game/libs/Occlude/init.luau +117 -0
- package/examples/game/libs/Pin/init.luau +309 -0
- package/examples/game/libs/Promise/LICENSE +21 -0
- package/examples/game/libs/Promise/_impl/LICENSE +21 -0
- package/examples/game/libs/Promise/_impl/init.lua +1991 -0
- package/examples/game/libs/Promise/init.lua +1990 -0
- package/examples/game/libs/Promise/init.luau +13 -0
- package/examples/game/libs/Promise/types.luau +46 -0
- package/examples/game/libs/Roster/init.luau +686 -0
- package/examples/game/libs/SOURCES.md +31 -0
- package/examples/game/libs/Shift/init.luau +238 -0
- package/examples/game/libs/Spark/init.luau +487 -0
- package/examples/game/libs/Stage/init.luau +178 -0
- package/examples/game/libs/Sweep/init.luau +259 -0
- package/examples/game/libs/Trace/init.luau +213 -0
- package/examples/game/libs/Ward/init.luau +211 -0
- package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau +29 -0
- package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau.map.json +13 -0
- package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau +83 -0
- package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau +18 -0
- package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau +14 -0
- package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau +15 -0
- package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau.map.json +13 -0
- package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau +50 -0
- package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau.map.json +13 -0
- package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau +12 -0
- package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau.map.json +13 -0
- package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau +16 -0
- package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau.map.json +13 -0
- package/examples/game/src/ReplicatedStorage/Shared/Net/Net.clh +26 -0
- package/examples/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
- package/examples/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
- package/examples/game/stylua.toml +9 -0
- package/generated/api/build-profile.js +115 -0
- package/generated/api/cache.js +44 -0
- package/generated/api/coverage.js +32 -0
- package/generated/api/diff.js +125 -0
- package/generated/api/generators/clpp-headers.js +353 -0
- package/generated/api/generators/docs-reference.js +7 -0
- package/generated/api/generators/lsp-index.js +81 -0
- package/generated/api/generators/luau-defs.js +94 -0
- package/generated/api/ide.js +76 -0
- package/generated/api/identifier.js +47 -0
- package/generated/api/index.js +324 -0
- package/generated/api/loader.js +57 -0
- package/generated/api/merge.js +88 -0
- package/generated/api/model.js +5 -0
- package/generated/api/normalize.js +231 -0
- package/generated/api/overrides-validate.js +58 -0
- package/generated/api/perf.js +12 -0
- package/generated/api/registry.js +136 -0
- package/generated/api/release.js +44 -0
- package/generated/api/resolver.js +250 -0
- package/generated/api/sources/aux-types-diff.js +75 -0
- package/generated/api/sources/client-tracker.js +11 -0
- package/generated/api/sources/creator-docs.js +42 -0
- package/generated/api/sources/luau-types.js +34 -0
- package/generated/api/sources/mini-dump.js +17 -0
- package/generated/api/sources/studio-api.js +8 -0
- package/generated/api/sources/studio-apiv2.js +11 -0
- package/generated/api/sources/studio-full-api.js +8 -0
- package/generated/api/studio-smoke.js +80 -0
- package/generated/api/type-parse.js +49 -0
- package/generated/api/understander.js +51 -0
- package/generated/api/validate.js +135 -0
- package/generated/api-cli.js +421 -0
- package/generated/cli.js +16 -5
- package/generated/clpp/contract.js +3 -3
- package/generated/clpp/format-luau.js +236 -0
- package/generated/clpp/index.js +13 -1
- package/generated/clpp/modules.js +227 -0
- package/generated/clpp/postprocess.js +86 -5
- package/generated/clpp/rewrite-janitor.js +145 -0
- package/generated/clpp/runner.js +14 -2
- package/generated/compile.js +82 -0
- package/generated/flare/parse.js +12 -1
- package/generated/intellisense.js +57 -1
- package/generated/native/index.js +217 -16
- package/generated/target/authority-check.js +136 -0
- package/generated/target/authority-graph.js +74 -0
- package/generated/target/build-cache.js +112 -0
- package/generated/target/capabilities.js +89 -0
- package/generated/target/capability-profile.js +30 -0
- package/generated/target/component-contracts.js +60 -0
- package/generated/target/context-check.js +160 -0
- package/generated/target/datamodel-check.js +170 -0
- package/generated/target/datamodel-generate.js +74 -0
- package/generated/target/datamodel.js +233 -0
- package/generated/target/diagnostics.js +63 -0
- package/generated/target/doctor.js +152 -0
- package/generated/target/flare-version.js +58 -0
- package/generated/target/get-service.js +69 -0
- package/generated/target/lifetime-check.js +47 -0
- package/generated/target/luau-stamp.js +39 -0
- package/generated/target/optimizer-advise.js +88 -0
- package/generated/target/optimizer-apply.js +44 -0
- package/generated/target/optimizer-soa.js +254 -0
- package/generated/target/parallel-check.js +136 -0
- package/generated/target/pgo.js +148 -0
- package/generated/target/project-docs.js +69 -0
- package/generated/target/project-graph.js +71 -0
- package/generated/target/roblox.js +63 -0
- package/generated/target/security-check.js +41 -0
- package/generated/target/source-map.js +25 -0
- package/generated/target/studio-bridge.js +112 -0
- package/generated/utils/project.js +178 -8
- package/generated/utils/rojo-mapper.js +11 -3
- package/include/clpp/datatypes.clh +337 -373
- package/include/clpp/generated/enums.clh +1 -1
- package/include/clpp/generated/instances.clh +41135 -41064
- package/include/clpp/libs/axiom.clh +1 -1
- package/include/clpp/libs/hive.clh +1 -0
- package/include/clpp/libs/keep.clh +2 -0
- package/include/clpp/libs/math.clh +14 -0
- package/include/clpp/libs/spring.clh +17 -0
- package/include/clpp/libs/ward.clh +1 -0
- package/include/clpp/roblox.clh +3 -4
- package/package.json +10 -3
- package/plugins/CluauppNav/Plugin.luau +207 -0
- package/plugins/CluauppNav/ProfileLogger.luau +27 -0
- package/plugins/CluauppNav/README.md +24 -0
- package/runtime/Axiom/init.luau +10 -7
- package/runtime/Coil/init.luau +8 -2
- package/runtime/Crest/init.luau +1 -0
- package/runtime/Flare/init.luau +2 -1
- package/runtime/Gleam/init.luau +15 -4
- package/runtime/Hive/init.luau +36 -14
- package/runtime/Pin/init.luau +5 -2
- package/runtime/Roster/init.luau +2 -0
- package/runtime/Spark/init.luau +3 -0
- package/runtime/Sweep/init.luau +2 -0
- package/runtime/Trace/init.luau +3 -0
- package/runtime/Ward/init.luau +38 -5
- package/scripts/postinstall-editor.js +17 -0
- package/skills/README.md +13 -0
- package/skills/clpp-hive-flare/SKILL.md +79 -0
- package/skills/clpp-language/SKILL.md +123 -0
- package/skills/clpp-language/compiler.md +89 -0
- package/skills/clpp-style/SKILL.md +95 -0
- package/src/api/build-profile.ts +138 -0
- package/src/api/cache.ts +45 -0
- package/src/api/coverage.ts +46 -0
- package/src/api/diff.ts +143 -0
- package/src/api/generators/clpp-headers.ts +377 -0
- package/src/api/generators/docs-reference.ts +11 -0
- package/src/api/generators/lsp-index.ts +106 -0
- package/src/api/generators/luau-defs.ts +98 -0
- package/src/api/ide.ts +87 -0
- package/src/api/identifier.ts +47 -0
- package/src/api/index.ts +269 -0
- package/src/api/loader.ts +60 -0
- package/src/api/merge.ts +126 -0
- package/src/api/model.ts +283 -0
- package/src/api/normalize.ts +257 -0
- package/src/api/overrides-validate.ts +58 -0
- package/src/api/perf.ts +15 -0
- package/src/api/registry.ts +162 -0
- package/src/api/release.ts +47 -0
- package/src/api/resolver.ts +255 -0
- package/src/api/sources/aux-types-diff.ts +81 -0
- package/src/api/sources/client-tracker.ts +10 -0
- package/src/api/sources/creator-docs.ts +37 -0
- package/src/api/sources/luau-types.ts +30 -0
- package/src/api/sources/mini-dump.ts +50 -0
- package/src/api/sources/studio-api.ts +7 -0
- package/src/api/sources/studio-apiv2.ts +10 -0
- package/src/api/sources/studio-full-api.ts +7 -0
- package/src/api/studio-smoke.ts +82 -0
- package/src/api/type-parse.ts +48 -0
- package/src/api/understander.ts +72 -0
- package/src/api/validate.ts +160 -0
- package/src/api-cli.ts +493 -0
- package/src/api.generated.js +37 -22
- package/src/cli.ts +21 -6
- package/src/clpp/contract.ts +34 -3
- package/src/clpp/format-luau.ts +262 -0
- package/src/clpp/index.ts +13 -2
- package/src/clpp/modules.ts +252 -0
- package/src/clpp/postprocess.ts +100 -5
- package/src/clpp/rewrite-janitor.ts +156 -0
- package/src/clpp/runner.ts +14 -2
- package/src/compile.ts +87 -0
- package/src/flare/parse.ts +14 -1
- package/src/flare/types.ts +2 -0
- package/src/intellisense.ts +58 -1
- package/src/native/index.ts +225 -16
- package/src/target/authority-check.ts +162 -0
- package/src/target/authority-graph.ts +80 -0
- package/src/target/build-cache.ts +129 -0
- package/src/target/capabilities.ts +115 -0
- package/src/target/capability-profile.ts +25 -0
- package/src/target/component-contracts.ts +64 -0
- package/src/target/context-check.ts +177 -0
- package/src/target/datamodel-check.ts +188 -0
- package/src/target/datamodel-generate.ts +78 -0
- package/src/target/datamodel.ts +261 -0
- package/src/target/diagnostics.ts +67 -0
- package/src/target/doctor.ts +171 -0
- package/src/target/flare-version.ts +61 -0
- package/src/target/get-service.ts +85 -0
- package/src/target/lifetime-check.ts +45 -0
- package/src/target/luau-stamp.ts +33 -0
- package/src/target/optimizer-advise.ts +93 -0
- package/src/target/optimizer-apply.ts +63 -0
- package/src/target/optimizer-soa.ts +270 -0
- package/src/target/parallel-check.ts +135 -0
- package/src/target/pgo.ts +157 -0
- package/src/target/project-docs.ts +68 -0
- package/src/target/project-graph.ts +75 -0
- package/src/target/roblox.ts +78 -0
- package/src/target/security-check.ts +40 -0
- package/src/target/source-map.ts +36 -0
- package/src/target/studio-bridge.ts +140 -0
- package/src/types.ts +14 -0
- package/src/utils/project.ts +183 -9
- package/src/utils/rojo-mapper.ts +12 -3
- package/stylua.toml +9 -0
- package/templates/game/.vscode/settings.json +7 -1
- package/templates/game/include/clpp/datatypes.clh +337 -373
- package/templates/game/include/clpp/generated/enums.clh +1 -1
- package/templates/game/include/clpp/generated/instances.clh +41135 -41064
- package/templates/game/include/clpp/libs/axiom.clh +1 -1
- package/templates/game/include/clpp/libs/ward.clh +1 -0
- package/templates/game/include/clpp/roblox.clh +3 -4
- package/templates/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
- package/templates/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
- package/templates/game/stylua.toml +9 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
--!native
|
|
2
|
+
--!optimize 2
|
|
3
|
+
--!strict
|
|
4
|
+
-- Echo — character snapshot replication. CFrame packed as f32s.
|
|
5
|
+
|
|
6
|
+
local RunService = game:GetService("RunService")
|
|
7
|
+
local Players = game:GetService("Players")
|
|
8
|
+
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
9
|
+
|
|
10
|
+
local Echo = {}
|
|
11
|
+
Echo.__index = Echo
|
|
12
|
+
|
|
13
|
+
local HEADER_SIZE = 6
|
|
14
|
+
local RECORD_SIZE = 52
|
|
15
|
+
local CFRAME_SIZE = 48
|
|
16
|
+
local MAX_UNRELIABLE = 900
|
|
17
|
+
local FOLDER_NAME = "EchoRemotes"
|
|
18
|
+
local SNAPSHOT_NAME = "Snapshot"
|
|
19
|
+
|
|
20
|
+
local remotes: Folder? = nil
|
|
21
|
+
local started = false
|
|
22
|
+
|
|
23
|
+
local config = {
|
|
24
|
+
Rate = 20,
|
|
25
|
+
Interpolate = 16,
|
|
26
|
+
MaxDistance = 0,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
local stats = {
|
|
30
|
+
Packets = 0,
|
|
31
|
+
PacketsSent = 0,
|
|
32
|
+
PacketsReceived = 0,
|
|
33
|
+
BytesSent = 0,
|
|
34
|
+
BytesReceived = 0,
|
|
35
|
+
Snapshots = 0,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
local rules = {
|
|
39
|
+
SkipLocal = true,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type Track = {
|
|
43
|
+
target: CFrame,
|
|
44
|
+
current: CFrame?,
|
|
45
|
+
clock: number,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type EchoEntity = {
|
|
49
|
+
Player: Player,
|
|
50
|
+
CFrame: CFrame,
|
|
51
|
+
Clock: number,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
local entities: { [Player]: EchoEntity } = {}
|
|
55
|
+
local tracks: { [Player]: Track } = {}
|
|
56
|
+
local lastSnapshots: { [Player]: { CFrame: CFrame, Clock: number } } = {}
|
|
57
|
+
|
|
58
|
+
local function writeCFrameAt(buf: buffer, offset: number, cf: CFrame)
|
|
59
|
+
local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = cf:GetComponents()
|
|
60
|
+
buffer.writef32(buf, offset, x)
|
|
61
|
+
buffer.writef32(buf, offset + 4, y)
|
|
62
|
+
buffer.writef32(buf, offset + 8, z)
|
|
63
|
+
buffer.writef32(buf, offset + 12, r00)
|
|
64
|
+
buffer.writef32(buf, offset + 16, r01)
|
|
65
|
+
buffer.writef32(buf, offset + 20, r02)
|
|
66
|
+
buffer.writef32(buf, offset + 24, r10)
|
|
67
|
+
buffer.writef32(buf, offset + 28, r11)
|
|
68
|
+
buffer.writef32(buf, offset + 32, r12)
|
|
69
|
+
buffer.writef32(buf, offset + 36, r20)
|
|
70
|
+
buffer.writef32(buf, offset + 40, r21)
|
|
71
|
+
buffer.writef32(buf, offset + 44, r22)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
local function readCFrameAt(buf: buffer, offset: number): CFrame
|
|
75
|
+
return CFrame.new(
|
|
76
|
+
buffer.readf32(buf, offset),
|
|
77
|
+
buffer.readf32(buf, offset + 4),
|
|
78
|
+
buffer.readf32(buf, offset + 8),
|
|
79
|
+
buffer.readf32(buf, offset + 12),
|
|
80
|
+
buffer.readf32(buf, offset + 16),
|
|
81
|
+
buffer.readf32(buf, offset + 20),
|
|
82
|
+
buffer.readf32(buf, offset + 24),
|
|
83
|
+
buffer.readf32(buf, offset + 28),
|
|
84
|
+
buffer.readf32(buf, offset + 32),
|
|
85
|
+
buffer.readf32(buf, offset + 36),
|
|
86
|
+
buffer.readf32(buf, offset + 40),
|
|
87
|
+
buffer.readf32(buf, offset + 44)
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
local function rootPart(player: Player): BasePart?
|
|
92
|
+
local character = player.Character
|
|
93
|
+
local root = character and character:FindFirstChild("HumanoidRootPart")
|
|
94
|
+
if root and root:IsA("BasePart") then
|
|
95
|
+
return root
|
|
96
|
+
end
|
|
97
|
+
return nil
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
local function ensureEntity(player: Player): EchoEntity
|
|
101
|
+
local entity = entities[player]
|
|
102
|
+
if entity then
|
|
103
|
+
return entity
|
|
104
|
+
end
|
|
105
|
+
entity = {
|
|
106
|
+
Player = player,
|
|
107
|
+
CFrame = CFrame.identity,
|
|
108
|
+
Clock = 0,
|
|
109
|
+
}
|
|
110
|
+
entities[player] = entity
|
|
111
|
+
return entity
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
local function folder(): Folder
|
|
115
|
+
if remotes and remotes.Parent then
|
|
116
|
+
return remotes
|
|
117
|
+
end
|
|
118
|
+
if RunService:IsClient() then
|
|
119
|
+
local existing = ReplicatedStorage:WaitForChild(FOLDER_NAME)
|
|
120
|
+
assert(existing:IsA("Folder"), "EchoRemotes must be a Folder")
|
|
121
|
+
remotes = existing
|
|
122
|
+
return existing
|
|
123
|
+
end
|
|
124
|
+
local existing = ReplicatedStorage:FindFirstChild(FOLDER_NAME)
|
|
125
|
+
if existing and existing:IsA("Folder") then
|
|
126
|
+
remotes = existing
|
|
127
|
+
return existing
|
|
128
|
+
end
|
|
129
|
+
local created = Instance.new("Folder")
|
|
130
|
+
created.Name = FOLDER_NAME
|
|
131
|
+
created.Parent = ReplicatedStorage
|
|
132
|
+
remotes = created
|
|
133
|
+
return created
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
local function snapshotRemote(): UnreliableRemoteEvent
|
|
137
|
+
local parent = folder()
|
|
138
|
+
if RunService:IsClient() then
|
|
139
|
+
local existing = parent:WaitForChild(SNAPSHOT_NAME)
|
|
140
|
+
assert(existing:IsA("UnreliableRemoteEvent"), "Echo Snapshot must be UnreliableRemoteEvent")
|
|
141
|
+
return existing
|
|
142
|
+
end
|
|
143
|
+
local existing = parent:FindFirstChild(SNAPSHOT_NAME)
|
|
144
|
+
if existing and existing:IsA("UnreliableRemoteEvent") then
|
|
145
|
+
return existing
|
|
146
|
+
end
|
|
147
|
+
if existing then
|
|
148
|
+
existing:Destroy()
|
|
149
|
+
end
|
|
150
|
+
local created = Instance.new("UnreliableRemoteEvent")
|
|
151
|
+
created.Name = SNAPSHOT_NAME
|
|
152
|
+
created.Parent = parent
|
|
153
|
+
return created
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
function Echo.WriteCFrame(cf: CFrame): buffer
|
|
157
|
+
local buf = buffer.create(CFRAME_SIZE)
|
|
158
|
+
writeCFrameAt(buf, 0, cf)
|
|
159
|
+
return buf
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
function Echo.ReadCFrame(buf: buffer): CFrame
|
|
163
|
+
return readCFrameAt(buf, 0)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
local function publish(remote: UnreliableRemoteEvent)
|
|
167
|
+
local list = {}
|
|
168
|
+
for _, player in Players:GetPlayers() do
|
|
169
|
+
local root = rootPart(player)
|
|
170
|
+
if root then
|
|
171
|
+
table.insert(list, player)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
if #list == 0 then
|
|
175
|
+
return
|
|
176
|
+
end
|
|
177
|
+
local clock = workspace:GetServerTimeNow()
|
|
178
|
+
local maxRecords = math.max(1, math.floor((MAX_UNRELIABLE - HEADER_SIZE) / RECORD_SIZE))
|
|
179
|
+
local index = 1
|
|
180
|
+
while index <= #list do
|
|
181
|
+
local count = math.min(#list - index + 1, maxRecords)
|
|
182
|
+
local buf = buffer.create(HEADER_SIZE + count * RECORD_SIZE)
|
|
183
|
+
buffer.writef32(buf, 0, clock)
|
|
184
|
+
buffer.writeu16(buf, 4, count)
|
|
185
|
+
local offset = HEADER_SIZE
|
|
186
|
+
for slot = 0, count - 1 do
|
|
187
|
+
local player = list[index + slot]
|
|
188
|
+
local root = rootPart(player)
|
|
189
|
+
if root then
|
|
190
|
+
buffer.writeu32(buf, offset, player.UserId)
|
|
191
|
+
writeCFrameAt(buf, offset + 4, root.CFrame)
|
|
192
|
+
local entity = ensureEntity(player)
|
|
193
|
+
entity.CFrame = root.CFrame
|
|
194
|
+
entity.Clock = clock
|
|
195
|
+
lastSnapshots[player] = { CFrame = root.CFrame, Clock = clock }
|
|
196
|
+
else
|
|
197
|
+
buffer.writeu32(buf, offset, player.UserId)
|
|
198
|
+
writeCFrameAt(buf, offset + 4, CFrame.identity)
|
|
199
|
+
end
|
|
200
|
+
offset += RECORD_SIZE
|
|
201
|
+
end
|
|
202
|
+
remote:FireAllClients(buf)
|
|
203
|
+
stats.Packets += 1
|
|
204
|
+
stats.PacketsSent += 1
|
|
205
|
+
stats.BytesSent += buffer.len(buf)
|
|
206
|
+
stats.Snapshots += count
|
|
207
|
+
index += count
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
local function applyPacked(packed: buffer)
|
|
212
|
+
if buffer.len(packed) < HEADER_SIZE then
|
|
213
|
+
return
|
|
214
|
+
end
|
|
215
|
+
stats.Packets += 1
|
|
216
|
+
stats.PacketsReceived += 1
|
|
217
|
+
stats.BytesReceived += buffer.len(packed)
|
|
218
|
+
local clock = buffer.readf32(packed, 0)
|
|
219
|
+
local count = buffer.readu16(packed, 4)
|
|
220
|
+
local localPlayer = Players.LocalPlayer
|
|
221
|
+
local localId = if localPlayer then localPlayer.UserId else 0
|
|
222
|
+
local origin: Vector3? = nil
|
|
223
|
+
if config.MaxDistance > 0 and localPlayer then
|
|
224
|
+
local localRoot = rootPart(localPlayer)
|
|
225
|
+
if localRoot then
|
|
226
|
+
origin = localRoot.Position
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
local offset = HEADER_SIZE
|
|
230
|
+
for _ = 1, count do
|
|
231
|
+
if offset + RECORD_SIZE > buffer.len(packed) then
|
|
232
|
+
break
|
|
233
|
+
end
|
|
234
|
+
local userId = buffer.readu32(packed, offset)
|
|
235
|
+
local cf = readCFrameAt(packed, offset + 4)
|
|
236
|
+
offset += RECORD_SIZE
|
|
237
|
+
if rules.SkipLocal and userId == localId then
|
|
238
|
+
continue
|
|
239
|
+
end
|
|
240
|
+
local player = Players:GetPlayerByUserId(userId)
|
|
241
|
+
if not player then
|
|
242
|
+
continue
|
|
243
|
+
end
|
|
244
|
+
if rules.SkipLocal and player == localPlayer then
|
|
245
|
+
continue
|
|
246
|
+
end
|
|
247
|
+
if origin and (cf.Position - origin).Magnitude > config.MaxDistance then
|
|
248
|
+
continue
|
|
249
|
+
end
|
|
250
|
+
local entity = ensureEntity(player)
|
|
251
|
+
entity.CFrame = cf
|
|
252
|
+
entity.Clock = clock
|
|
253
|
+
lastSnapshots[player] = { CFrame = cf, Clock = clock }
|
|
254
|
+
local track = tracks[player]
|
|
255
|
+
if track then
|
|
256
|
+
track.target = cf
|
|
257
|
+
track.clock = clock
|
|
258
|
+
else
|
|
259
|
+
tracks[player] = {
|
|
260
|
+
target = cf,
|
|
261
|
+
current = nil,
|
|
262
|
+
clock = clock,
|
|
263
|
+
}
|
|
264
|
+
end
|
|
265
|
+
stats.Snapshots += 1
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
local function interpolate(dt: number)
|
|
270
|
+
local localPlayer = Players.LocalPlayer
|
|
271
|
+
local rate = math.max(config.Interpolate, 0)
|
|
272
|
+
local alpha = if rate <= 0 then 1 else 1 - math.exp(-rate * dt)
|
|
273
|
+
for player, track in tracks do
|
|
274
|
+
if rules.SkipLocal and player == localPlayer then
|
|
275
|
+
continue
|
|
276
|
+
end
|
|
277
|
+
if not player.Parent then
|
|
278
|
+
tracks[player] = nil
|
|
279
|
+
continue
|
|
280
|
+
end
|
|
281
|
+
local root = rootPart(player)
|
|
282
|
+
if not root then
|
|
283
|
+
continue
|
|
284
|
+
end
|
|
285
|
+
local current = track.current or root.CFrame
|
|
286
|
+
local target = track.target
|
|
287
|
+
if (current.Position - target.Position).Magnitude > 40 then
|
|
288
|
+
current = target
|
|
289
|
+
else
|
|
290
|
+
current = current:Lerp(target, alpha)
|
|
291
|
+
end
|
|
292
|
+
track.current = current
|
|
293
|
+
root.CFrame = current
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
function Echo.Start()
|
|
298
|
+
if started then
|
|
299
|
+
return
|
|
300
|
+
end
|
|
301
|
+
started = true
|
|
302
|
+
local remote = snapshotRemote()
|
|
303
|
+
if RunService:IsServer() then
|
|
304
|
+
local elapsed = 0
|
|
305
|
+
RunService.Heartbeat:Connect(function(dt)
|
|
306
|
+
elapsed += dt
|
|
307
|
+
local interval = 1 / math.max(config.Rate, 1)
|
|
308
|
+
if elapsed < interval then
|
|
309
|
+
return
|
|
310
|
+
end
|
|
311
|
+
elapsed = 0
|
|
312
|
+
publish(remote)
|
|
313
|
+
end)
|
|
314
|
+
Players.PlayerRemoving:Connect(function(player)
|
|
315
|
+
entities[player] = nil
|
|
316
|
+
lastSnapshots[player] = nil
|
|
317
|
+
end)
|
|
318
|
+
else
|
|
319
|
+
remote.OnClientEvent:Connect(function(packed: buffer)
|
|
320
|
+
applyPacked(packed)
|
|
321
|
+
end)
|
|
322
|
+
RunService.Heartbeat:Connect(function(dt)
|
|
323
|
+
interpolate(dt)
|
|
324
|
+
end)
|
|
325
|
+
Players.PlayerRemoving:Connect(function(player)
|
|
326
|
+
tracks[player] = nil
|
|
327
|
+
entities[player] = nil
|
|
328
|
+
lastSnapshots[player] = nil
|
|
329
|
+
end)
|
|
330
|
+
Players.PlayerAdded:Connect(function(player)
|
|
331
|
+
player.CharacterAdded:Connect(function()
|
|
332
|
+
local track = tracks[player]
|
|
333
|
+
if track then
|
|
334
|
+
track.current = nil
|
|
335
|
+
end
|
|
336
|
+
end)
|
|
337
|
+
end)
|
|
338
|
+
for _, player in Players:GetPlayers() do
|
|
339
|
+
player.CharacterAdded:Connect(function()
|
|
340
|
+
local track = tracks[player]
|
|
341
|
+
if track then
|
|
342
|
+
track.current = nil
|
|
343
|
+
end
|
|
344
|
+
end)
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
local Holder = {}
|
|
350
|
+
|
|
351
|
+
function Holder.Get(player: Player): EchoEntity?
|
|
352
|
+
return entities[player]
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
function Holder.All(): { [Player]: EchoEntity }
|
|
356
|
+
return entities
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
function Echo.Holder()
|
|
360
|
+
return Holder
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
local Entity = {}
|
|
364
|
+
|
|
365
|
+
function Entity.new(player: Player): EchoEntity
|
|
366
|
+
return ensureEntity(player)
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
function Echo.Entity()
|
|
370
|
+
return Entity
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
function Echo.Stats()
|
|
374
|
+
return stats
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
function Echo.Config(patch: any?): typeof(config)
|
|
378
|
+
if typeof(patch) == "table" then
|
|
379
|
+
if typeof(patch.Rate) == "number" then
|
|
380
|
+
config.Rate = patch.Rate
|
|
381
|
+
end
|
|
382
|
+
if typeof(patch.Interpolate) == "number" then
|
|
383
|
+
config.Interpolate = patch.Interpolate
|
|
384
|
+
end
|
|
385
|
+
if typeof(patch.MaxDistance) == "number" then
|
|
386
|
+
config.MaxDistance = patch.MaxDistance
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
return config
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
function Echo.ReplicationRules(patch: any?): typeof(rules)
|
|
393
|
+
if typeof(patch) == "table" then
|
|
394
|
+
if patch.SkipLocal ~= nil then
|
|
395
|
+
rules.SkipLocal = patch.SkipLocal == true
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
return rules
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
function Echo.Events()
|
|
402
|
+
return folder()
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
function Echo.Snapshots()
|
|
406
|
+
return lastSnapshots
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
function Echo.ServerClock()
|
|
410
|
+
return workspace:GetServerTimeNow()
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
function Echo.Player()
|
|
414
|
+
return Players.LocalPlayer
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
return Echo
|