Browser multiplayer client: promote the KNI spike to src/LittleSim.Web
LittleSim.Web (Blazor WASM + KNI/WebGL) is a real network client now: it connects to the dedicated server over WebSocket (ClientWebSocket maps to the browser socket), applies MrGameEng.Net delta snapshots into its EntityStore and draws pawns through SpriteBatch — fatigue dims them just like on desktop. The server address comes from ?server=ws://host:port in the page URL, defaulting to the page's host on port 9050. The net contract is mirrored in NetContract.cs (KNI and DesktopGL assemblies can't mix until the graphics libraries build per platform) with loud keep-in-sync comments on both sides. Both clients now smooth replicated positions between 10 Hz snapshots: NetLerp + NetSmoothingSystem lerp the visual position toward the latest server position every frame (exponential, ~0.25 s to converge). Verified against a live LittleSim.Server --listen: the browser client connects (server log), draws ~3.3k lit pixels of pawns whose layout changes between samples, and survives 400+ ticks without errors. Found along the way: requestAnimationFrame freezes in hidden windows — the game loop only runs while the tab is visible. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
e8273f9ffa
commit
580cb6ccc9
@@ -0,0 +1,63 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
|
||||
<PropertyGroup>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<RootNamespace>LittleSim.Web</RootNamespace>
|
||||
<AssemblyName>LittleSim.Web</AssemblyName>
|
||||
<DefineConstants>$(DefineConstants);BLAZORGL</DefineConstants>
|
||||
<KniPlatform>BlazorGL</KniPlatform>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Pages\Index.razor.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="LittleSimWebGame.cs" />
|
||||
<Compile Include="NetContract.cs" />
|
||||
<Compile Include="WorldViewScene.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!--
|
||||
Веб-клиент собирается против KNI (форк MonoGame с платформой Blazor/WebGL), поэтому
|
||||
ссылается только на платформо-независимые библиотеки движка: Core и Net.
|
||||
Графические библиотеки движка (DesktopGL) сюда подключать нельзя — у KNI свои
|
||||
сборки с теми же неймспейсами.
|
||||
-->
|
||||
<ProjectReference Include="..\..\engine\src\MrGameEng.Core\MrGameEng.Core.csproj" />
|
||||
<ProjectReference Include="..\..\engine\src\MrGameEng.Net\MrGameEng.Net.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="nkast.Xna.Framework" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Content" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Graphics" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Audio" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Media" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Input" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Game" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Devices" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Storage" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Xna.Framework.XR" Version="4.2.9001" />
|
||||
<PackageReference Include="nkast.Kni.Platform.Blazor.GL" Version="4.2.9001.2" />
|
||||
<PackageReference Include="nkast.Xna.Framework.Content.Pipeline.Builder" Version="4.2.9001" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.17" />
|
||||
<PackageReference
|
||||
Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer"
|
||||
Version="8.0.17"
|
||||
PrivateAssets="all"
|
||||
/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<KniContentReference Include="Content\LittleSimWebContent.mgcb" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user