(client) feat:完成实体生成函数,修复行为树加载错误,改进Define打印缩进

This commit is contained in:
m0_75251201
2025-07-22 14:40:24 +08:00
parent 506d0a68a8
commit a6dfbd7c68
26 changed files with 835 additions and 527 deletions

View File

@ -17,6 +17,7 @@ namespace Data
drawingOrder_right;
public BehaviorTreeDef behaviorTree;
public AffiliationDef affiliation;
public DrawingOrderDef GetDrawingOrder(Orientation orientation)
@ -60,29 +61,38 @@ namespace Data
public class BehaviorTreeDef : Define
{
public BehaviorTreeDef[] childTree;
public string className;
public string className="Selector";
public string condition;
public override bool Init(XElement xmlDef)
{
base.Init(xmlDef);
// 从当前节点获取className和condition属性
className = xmlDef.Attribute("className")?.Value ?? className;
condition = xmlDef.Attribute("condition")?.Value;
var nodes = xmlDef.Elements("Node");
var xElements = nodes as XElement[] ?? nodes.ToArray();
if (!xElements.Any())
return false;
if (!nodes.Any())
return true; // 没有子节点也是有效的
className = xmlDef.Attribute("className")?.Value;
List<BehaviorTreeDef> children = new();
foreach (var node in xElements)
foreach (var node in nodes)
{
var childNode = new BehaviorTreeDef();
childNode.Init(node);
if (!childNode.Init(node))
return false;
children.Add(childNode);
}
childTree = children.ToArray();
return true;
}
}
public class AffiliationDef : Define
{
}
}