feat(gameplay): 更新单位属性和材质配置 - 调整多个单位的基础生命值和攻击力数值平衡 - 修改CoreBattleGround材质的纹理缩放比例 - 更新地砖材质颜色为白色 - 优化纹理资源设置,调整最大纹理尺寸并添加PlayableAds平台支持 - 修复弓箭手技能目标查找逻辑,改用统一的敌人检测方法 - 为水晶矿添加中立阵营设置和光球视觉效果同步 - 调整预制体中的全局缩放参数 - 为狼人和石巨人添加NavMeshAgent组件支持 - 优化水晶矿血条显示位置计算方式 ```
51 lines
2.1 KiB
C#
51 lines
2.1 KiB
C#
using System.Text.RegularExpressions;
|
|
using Codely.Microsoft.CodeAnalysis;
|
|
using Codely.Microsoft.CodeAnalysis.CSharp;
|
|
using Codely.Microsoft.CodeAnalysis.Text;
|
|
using SyntaxTree = Codely.Microsoft.CodeAnalysis.SyntaxTree;
|
|
|
|
namespace UnityTcp.Editor.Tools
|
|
{
|
|
internal class FixMissingBrace : ScriptFixProvider
|
|
{
|
|
// Jagged array rank: Type[][] or new Type[][]
|
|
static readonly Regex k_JaggedArrayPattern = new Regex(
|
|
@"\[\]\s*\[\]", RegexOptions.Compiled);
|
|
|
|
// Implicit array creation with named tuple: new[] { (name: ...)
|
|
static readonly Regex k_NamedTupleArrayPattern = new Regex(
|
|
@"new\s*\[\].*\(\s*\w+\s*:", RegexOptions.Compiled);
|
|
|
|
public override bool CanFix(Diagnostic diagnostic) => diagnostic.Id == "CS1513";
|
|
|
|
public override bool ApplyFix(ref SyntaxTree tree, Diagnostic diagnostic, ScriptFixContext context)
|
|
{
|
|
var source = tree.ToString();
|
|
var lineSpan = diagnostic.Location.GetLineSpan();
|
|
int diagLine = lineSpan.Span.Start.Line;
|
|
|
|
// Guard: skip CS1513 caused by script-incompatible syntax rather than
|
|
// actual missing braces. These patterns confuse the script parser and
|
|
// inserting } would make things worse.
|
|
var lines = source.Split('\n');
|
|
if (diagLine >= 0 && diagLine < lines.Length)
|
|
{
|
|
var lineText = lines[diagLine].Trim();
|
|
if (k_JaggedArrayPattern.IsMatch(lineText))
|
|
return false;
|
|
if (k_NamedTupleArrayPattern.IsMatch(lineText))
|
|
return false;
|
|
}
|
|
|
|
// Insert } at the diagnostic position
|
|
var sourceText = SourceText.From(source);
|
|
int insertPos = sourceText.Lines.GetPosition(lineSpan.Span.Start);
|
|
var newSource = source.Insert(insertPos, "}\n");
|
|
|
|
var updated = SyntaxFactory.ParseSyntaxTree(newSource);
|
|
if (ReferenceEquals(updated, tree)) return false;
|
|
tree = updated;
|
|
return true;
|
|
}
|
|
}
|
|
} |