Files
kronic adf78570f8 Cleanup: remove legacy IMGUI ConnectionUI + crash-recovery scenes
Delete the NetConnectionUI GameObject from Game/DevSandbox/SampleScene + ConnectionUI.cs (the UITK frontend menu owns Host/Join+IP now); repoint 4 stale doc-comments (GameBootstrap done in commit C; DebugOverlay/ConnectionConfig/EditorAutoHostSystem here) to MainMenuController/WorldLauncher; remove the Assets/_Recovery crash-recovery scenes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 15:06:01 -07:00

36 lines
1.6 KiB
C#

#if UNITY_EDITOR
using Unity.Entities;
using Unity.NetCode;
namespace ProjectM.Simulation
{
/// <summary>
/// EDITOR-ONLY dev convenience for the M4 LAN flow. With auto-connect disabled in <c>GameBootstrap</c>,
/// this seeds a <see cref="ConnectionConfig"/> in each world on its first update so entering Play "just
/// works" multi-client: the server world hosts on loopback and every client / thin-client world joins
/// it — reproducing the old single-key playflow but for N players. Runs once per world then disables
/// itself, and skips seeding if a <see cref="ConnectionConfig"/> already exists (e.g. set by
/// the frontend menu's <c>WorldLauncher</c>). Does not exist in player builds.
/// </summary>
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation | WorldSystemFilterFlags.ClientSimulation | WorldSystemFilterFlags.ThinClientSimulation)]
public partial struct EditorAutoHostSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
state.Enabled = false; // run exactly once per world
if (SystemAPI.HasSingleton<ConnectionConfig>())
return;
const ushort port = 7979;
var cfg = state.WorldUnmanaged.IsServer()
? new ConnectionConfig { Mode = ConnectionMode.Host, Address = "127.0.0.1", Port = port, Requested = true }
: new ConnectionConfig { Mode = ConnectionMode.Join, Address = "127.0.0.1", Port = port, Requested = true };
var e = state.EntityManager.CreateEntity();
state.EntityManager.AddComponentData(e, cfg);
}
}
}
#endif