Slice 2: menu class picker (Warrior / Ranger)

MainMenuController gains a 2-class picker that sets WorldLauncher.SelectedClass;
WorldLauncher seeds a ClassSelection singleton into the client world at session start,
which GoInGameClientSystem carries on the spawn RPC. Default Warrior. Completes the
Slice 2 loop: pick a class in the menu -> spawn with its kit. Editor-default boot stays
Warrior (the menu path drives the choice). 348/348.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-18 00:39:38 -07:00
parent 0a3a39e3d2
commit 431a7e2ed9
2 changed files with 33 additions and 0 deletions
@@ -28,6 +28,9 @@ namespace ProjectM.Client
public static bool Busy { get; private set; }
/// <summary>Slice 2: the class chosen in the menu (a CharacterId byte), seeded into the client world at session start.</summary>
public static byte SelectedClass = (byte)CharacterId.Warrior;
public static void StartSession(SessionMode mode, string joinIp, bool loadSave)
{
if (Busy) return;
@@ -51,6 +54,7 @@ namespace ProjectM.Client
World server = null;
World client = ClientServerBootstrap.CreateClientWorld("ClientWorld");
SeedClass(client, SelectedClass); // Slice 2: stage the chosen class for GoInGameClientSystem -> spawn
if (mode == SessionMode.Join)
{
@@ -101,6 +105,15 @@ namespace ProjectM.Client
});
}
static void SeedClass(World world, byte classId)
{
if (world is not { IsCreated: true }) return;
var em = world.EntityManager;
using var q = em.CreateEntityQuery(ComponentType.ReadWrite<ClassSelection>());
Entity e = q.IsEmptyIgnoreFilter ? em.CreateEntity(typeof(ClassSelection)) : q.GetSingletonEntity();
em.SetComponentData(e, new ClassSelection { ClassId = classId });
}
static void StagePendingSave(World server)
{
var data = SaveService.Load();