Add MainHUD gameplay UI, net handshake updates, and server maintenance mode.

Introduce UiManager/MainHUD prefab flow, strengthen GameNet/WsClient, and add AIServer maintenance endpoint support.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
udx
2026-09-21 17:34:42 +08:00
co-authored by Cursor
parent 10d9b98637
commit c94b8fefeb
32 changed files with 1907 additions and 74 deletions
+6 -47
View File
@@ -1,7 +1,7 @@
using AOT.Boot;
using HotUpdate.Gameplay;
using HotUpdate.Net;
using UnityEngine;
using UnityEngine.UI;
namespace HotUpdate
{
@@ -23,8 +23,6 @@ namespace HotUpdate
public sealed class HotUpdateBootstrap : MonoBehaviour
{
BootContext _ctx;
GameNet _net;
Text _hud;
public void Bind(BootContext ctx)
{
@@ -34,53 +32,14 @@ namespace HotUpdate
void Start()
{
Debug.Log($"[HotUpdate] Bootstrap ready. CDN={_ctx?.CdnRoot}");
EnsureHud();
// M3:示例角色(与网络并行,不依赖 WS)
var spawner = gameObject.AddComponent<CharacterSpawner>();
spawner.Bind(_ctx);
spawner.Spawn();
var net = gameObject.AddComponent<GameNet>();
net.Bind(_ctx);
_net = gameObject.AddComponent<GameNet>();
_net.Bind(_ctx);
_net.OnStatus += s =>
{
if (_hud != null) _hud.text = s;
};
_net.OnWsReady += () =>
{
if (_hud != null)
_hud.text = $"WS OK pid={_net.Session?.Pid} | MaleExplorer";
Debug.Log($"[HotUpdate] M2 WS ready pid={_net.Session?.Pid}");
};
_net.StartGuestSession();
}
var gameplay = gameObject.AddComponent<GameplayBootstrap>();
gameplay.Bind(_ctx, net);
void EnsureHud()
{
var canvasGo = new GameObject("NetHud");
canvasGo.transform.SetParent(transform, false);
var canvas = canvasGo.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
canvas.sortingOrder = 200;
var scaler = canvasGo.AddComponent<CanvasScaler>();
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
scaler.referenceResolution = new Vector2(1080, 1920);
canvasGo.AddComponent<GraphicRaycaster>();
var textGo = new GameObject("Status");
textGo.transform.SetParent(canvasGo.transform, false);
_hud = textGo.AddComponent<Text>();
_hud.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
_hud.fontSize = 28;
_hud.color = Color.white;
_hud.alignment = TextAnchor.LowerCenter;
var rt = textGo.GetComponent<RectTransform>();
rt.anchorMin = new Vector2(0.05f, 0.08f);
rt.anchorMax = new Vector2(0.95f, 0.16f);
rt.offsetMin = Vector2.zero;
rt.offsetMax = Vector2.zero;
_hud.text = "net…";
net.StartGuestSession();
}
}
}