feat(gameplay): 更新单位属性和材质配置 - 调整多个单位的基础生命值和攻击力数值平衡 - 修改CoreBattleGround材质的纹理缩放比例 - 更新地砖材质颜色为白色 - 优化纹理资源设置,调整最大纹理尺寸并添加PlayableAds平台支持 - 修复弓箭手技能目标查找逻辑,改用统一的敌人检测方法 - 为水晶矿添加中立阵营设置和光球视觉效果同步 - 调整预制体中的全局缩放参数 - 为狼人和石巨人添加NavMeshAgent组件支持 - 优化水晶矿血条显示位置计算方式 ```
86 lines
3.2 KiB
C#
86 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace UnityTcp.Editor.Helpers
|
|
{
|
|
/// <summary>
|
|
/// Provides static methods for creating standardized success and error response objects.
|
|
/// Ensures consistent JSON structure for communication back to the Codely client.
|
|
///
|
|
/// Response format: { success, message, data? }
|
|
///
|
|
/// There is no pending/op_id/poll_interval variant: a tool call returns only when its work is
|
|
/// finished, so there is nothing for a client to poll or correlate.
|
|
///
|
|
/// Responses carry only the tool's own result. Editor state is an explicit
|
|
/// read via manage_editor.get_state, not an ambient field on every
|
|
/// response.
|
|
/// </summary>
|
|
public static class Response
|
|
{
|
|
/// <summary>
|
|
/// Creates a standardized success response object.
|
|
/// </summary>
|
|
/// <param name="message">A message describing the successful operation.</param>
|
|
/// <param name="data">Optional additional data to include in the response.</param>
|
|
/// <returns>An object representing the success response.</returns>
|
|
public static object Success(string message, object data = null)
|
|
{
|
|
var response = new Dictionary<string, object>
|
|
{
|
|
{ "success", true },
|
|
{ "message", message }
|
|
};
|
|
|
|
if (data != null)
|
|
{
|
|
response["data"] = data;
|
|
}
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a standardized error response object.
|
|
/// </summary>
|
|
/// <param name="errorCodeOrMessage">A message describing the error.</param>
|
|
/// <param name="data">Optional additional data (e.g., error details) to include.</param>
|
|
/// <returns>An object representing the error response.</returns>
|
|
public static object Error(string errorCodeOrMessage, object data = null)
|
|
{
|
|
var response = new Dictionary<string, object>
|
|
{
|
|
{ "success", false },
|
|
{ "message", errorCodeOrMessage },
|
|
{ "code", errorCodeOrMessage },
|
|
{ "error", errorCodeOrMessage }
|
|
};
|
|
|
|
if (data != null)
|
|
{
|
|
response["data"] = data;
|
|
}
|
|
|
|
return response;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates an error response whose <c>code</c> is a stable token clients can branch on,
|
|
/// separate from the human-readable message. <see cref="Error"/> copies its single argument
|
|
/// into all three of <c>code</c>, <c>message</c> and <c>error</c>, which is fine for a bare
|
|
/// message but destroys the token as soon as the message says anything more.
|
|
///
|
|
/// Carries no <c>data</c>: an asynchronous response is rendered as a success by the client
|
|
/// whenever it has a payload, so a failure must be message-only.
|
|
/// </summary>
|
|
public static object ErrorWithCode(string code, string message)
|
|
=> new Dictionary<string, object>
|
|
{
|
|
{ "success", false },
|
|
{ "message", message },
|
|
{ "code", code },
|
|
{ "error", code },
|
|
};
|
|
}
|
|
}
|