```
feat(gameplay): 更新单位属性和材质配置 - 调整多个单位的基础生命值和攻击力数值平衡 - 修改CoreBattleGround材质的纹理缩放比例 - 更新地砖材质颜色为白色 - 优化纹理资源设置,调整最大纹理尺寸并添加PlayableAds平台支持 - 修复弓箭手技能目标查找逻辑,改用统一的敌人检测方法 - 为水晶矿添加中立阵营设置和光球视觉效果同步 - 调整预制体中的全局缩放参数 - 为狼人和石巨人添加NavMeshAgent组件支持 - 优化水晶矿血条显示位置计算方式 ```
This commit is contained in:
1 parent
0e7de5f885
commit
53d95802e5
448 files changed
+133333
-472
No files matched your search
+86
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Codely.Newtonsoft.Json.Linq;
|
||||
|
||||
namespace UnityTcp.Editor.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Shared action dispatch for Unity tool handlers: read/normalize <c>action</c>,
|
||||
/// optional alias remap, unknown-action error, and try/catch around the handler.
|
||||
/// </summary>
|
||||
public static class ActionRouter
|
||||
{
|
||||
public static bool TryResolve(
|
||||
JObject @params,
|
||||
IEnumerable<string> validActions,
|
||||
out string action,
|
||||
out object error,
|
||||
IReadOnlyDictionary<string, string> aliases = null,
|
||||
string defaultAction = null)
|
||||
{
|
||||
action = @params?["action"]?.ToString()?.ToLower();
|
||||
if (string.IsNullOrEmpty(action))
|
||||
{
|
||||
action = defaultAction;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(action))
|
||||
{
|
||||
error = Response.Error("Action parameter is required.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aliases != null && aliases.TryGetValue(action, out var canonical))
|
||||
{
|
||||
action = canonical;
|
||||
}
|
||||
|
||||
if (validActions != null)
|
||||
{
|
||||
bool known = false;
|
||||
foreach (var valid in validActions)
|
||||
{
|
||||
if (valid == action)
|
||||
{
|
||||
known = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!known)
|
||||
{
|
||||
error = Response.Error(
|
||||
$"Unknown action: '{action}'. Valid actions are: {string.Join(", ", validActions)}"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
error = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static object Route(
|
||||
JObject @params,
|
||||
IReadOnlyDictionary<string, Func<JObject, object>> handlers,
|
||||
IReadOnlyDictionary<string, string> aliases = null,
|
||||
string defaultAction = null)
|
||||
{
|
||||
if (!TryResolve(@params, handlers.Keys, out var action, out var error, aliases, defaultAction))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return handlers[action](@params);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Response.Error(
|
||||
$"Internal error processing action '{action}': {e.Message}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user