@lagless/create 0.0.50 → 0.0.51
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/package.json
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"@lagless/net-wire": "^<%= laglessVersion %>",
|
|
18
18
|
"@lagless/react": "^<%= laglessVersion %>",
|
|
19
19
|
"@lagless/pixi-react": "^<%= laglessVersion %>",
|
|
20
|
+
"@lagless/desync-diagnostics": "^<%= laglessVersion %>",
|
|
21
|
+
"@lagless/binary": "^<%= laglessVersion %>",
|
|
20
22
|
<% if (simulationType === 'physics2d') { -%>
|
|
21
23
|
"@lagless/physics2d": "^<%= laglessVersion %>",
|
|
22
24
|
"@lagless/physics-shared": "^<%= laglessVersion %>",
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
PlayerJoined,
|
|
7
7
|
<%= projectName %>Arena,
|
|
8
8
|
} from '<%= packageName %>-simulation';
|
|
9
|
-
import { createContext, FC, ReactNode, useContext, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { createContext, FC, ReactNode, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
10
|
import { useTick } from '@pixi/react';
|
|
11
11
|
import { useNavigate } from 'react-router-dom';
|
|
12
12
|
import { ProviderStore } from '../hooks/use-start-match';
|
|
@@ -15,6 +15,10 @@ import { RelayInputProvider, RelayConnection } from '@lagless/relay-client';
|
|
|
15
15
|
import { getMatchInfo } from '../hooks/use-start-multiplayer-match';
|
|
16
16
|
import { UUID } from '@lagless/misc';
|
|
17
17
|
import { useDevBridge, useDiagnosticsControl } from '@lagless/react';
|
|
18
|
+
import { useDesyncDiagnostics } from '@lagless/desync-diagnostics';
|
|
19
|
+
<% if (simulationType !== 'raw') { -%>
|
|
20
|
+
import { getFastHash } from '@lagless/binary';
|
|
21
|
+
<% } -%>
|
|
18
22
|
<% if (simulationType === 'physics2d') { -%>
|
|
19
23
|
import { PhysicsWorldManager2d, type RapierModule2d } from '@lagless/physics2d';
|
|
20
24
|
<% } else if (simulationType === 'physics3d') { -%>
|
|
@@ -218,6 +222,36 @@ export const RunnerProvider: FC<RunnerProviderProps> = ({ children }) => {
|
|
|
218
222
|
|
|
219
223
|
useDevBridge(runner, { hashTrackingInterval: <%= projectName %>Arena.hashReportInterval, diagnosticsEnabled });
|
|
220
224
|
|
|
225
|
+
<% if (simulationType === 'physics2d') { -%>
|
|
226
|
+
const diagnosticsOptions = useMemo(() => {
|
|
227
|
+
if (!runner) return undefined;
|
|
228
|
+
const wm = runner.PhysicsWorldManager;
|
|
229
|
+
return {
|
|
230
|
+
physicsHashFn: () => {
|
|
231
|
+
const snap = wm.takeSnapshot();
|
|
232
|
+
return getFastHash(snap.buffer);
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
}, [runner]);
|
|
236
|
+
|
|
237
|
+
useDesyncDiagnostics(runner, { ...diagnosticsOptions, enabled: diagnosticsEnabled });
|
|
238
|
+
<% } else if (simulationType === 'physics3d') { -%>
|
|
239
|
+
const diagnosticsOptions = useMemo(() => {
|
|
240
|
+
if (!runner) return undefined;
|
|
241
|
+
const wm = runner.PhysicsWorldManager;
|
|
242
|
+
return {
|
|
243
|
+
physicsHashFn: () => {
|
|
244
|
+
const snap = wm.takeSnapshot();
|
|
245
|
+
return getFastHash(snap.buffer);
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
}, [runner]);
|
|
249
|
+
|
|
250
|
+
useDesyncDiagnostics(runner, { ...diagnosticsOptions, enabled: diagnosticsEnabled });
|
|
251
|
+
<% } else { -%>
|
|
252
|
+
useDesyncDiagnostics(runner, { enabled: diagnosticsEnabled });
|
|
253
|
+
<% } -%>
|
|
254
|
+
|
|
221
255
|
return !runner ? null : <RunnerContext.Provider value={runner}>{children}</RunnerContext.Provider>;
|
|
222
256
|
};
|
|
223
257
|
|