Initial commit: Client Doc docs Server Tools
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using XWorld.Framework;
|
||||
// Alias to resolve ambiguity between XWorld.Framework.ILogger and UnityEngine.ILogger
|
||||
using IFwkLogger = XWorld.Framework.ILogger;
|
||||
|
||||
namespace XGame.MiniGame
|
||||
{
|
||||
// 注入给 IGameClient 的上下文:资源/日志/发送/退出
|
||||
public sealed class GameClientCtx : IGameClientCtx
|
||||
{
|
||||
public IAssetLoader Assets { get; }
|
||||
public IFwkLogger Logger { get; }
|
||||
|
||||
private readonly Action<NetMessage> _send;
|
||||
private readonly Action _exit;
|
||||
|
||||
public GameClientCtx(IAssetLoader assets, IFwkLogger logger, Action<NetMessage> send, Action exit)
|
||||
{
|
||||
Assets = assets; Logger = logger; _send = send; _exit = exit;
|
||||
}
|
||||
|
||||
public void Send(NetMessage message) => _send(message);
|
||||
public void Exit() => _exit();
|
||||
}
|
||||
|
||||
// 简单 Unity 日志器(实现框架 ILogger)
|
||||
public sealed class UnityLogger : IFwkLogger
|
||||
{
|
||||
private readonly string _prefix;
|
||||
public UnityLogger(string prefix = "[minigame]") { _prefix = prefix; }
|
||||
public void Info(string m) => Debug.Log($"{_prefix} {m}");
|
||||
public void Warn(string m) => Debug.LogWarning($"{_prefix} {m}");
|
||||
public void Error(string m) => Debug.LogError($"{_prefix} {m}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user