整合SLSUtilities

This commit is contained in:
SoulliesOfficial
2026-01-17 11:35:49 -05:00
parent d94241f36c
commit 7ee2894a63
1338 changed files with 3051541 additions and 507034 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Sirenix.OdinInspector;
using SoftCircuits.Collections;
using UnityEngine;
namespace Cielonos.MainGame.Inventory
@@ -11,28 +12,32 @@ namespace Cielonos.MainGame.Inventory
/// 这是你的“蓝图”资产。
/// </summary>
[CreateAssetMenu(fileName = "ComboData", menuName = "Cielonos/Items/ComboData")]
public class ComboData : ScriptableObject
public class ComboData : SerializedScriptableObject
{
public float defaultDisappearTime;
//[InlineProperty] public ComboTreeData tree;
[InlineProperty] [HideLabel] public ComboTreeData tree;
[InlineProperty]
[Title("连招树编辑器", "可视化编辑连招树的节点和分支")]
public Dictionary<string, ComboTreeData> comboTrees;
public ComboTreeData mainTree => comboTrees["Main"];
[OnInspectorInit]
private void OnEnable()
{
defaultDisappearTime = 0.25f;
tree ??= new ComboTreeData();
// 确保总有一个 RootNode
if (tree.nodes == null || tree.nodes.Count == 0)
if (comboTrees == null)
{
tree.nodes = new List<ComboNodeData>();
// 添加不可删除的 RootNode
tree.nodes.Add(new ComboNodeData() { referenceName = "Root" });
}
comboTrees = new Dictionary<string, ComboTreeData>();
ComboTreeData tree = new ComboTreeData();
if (tree.nodes == null || tree.nodes.Count == 0)
{
tree.nodes = new List<ComboNodeData>();
tree.nodes.Add(new ComboNodeData() { referenceName = "Root" });
}
// 关键一步:将树实例传递给所有子节点,以便它们能填充下拉列表
tree.InitializeNodeReferences();
tree.InitializeNodeReferences();
comboTrees["Main"] = tree;
}
}
}
@@ -42,17 +47,17 @@ namespace Cielonos.MainGame.Inventory
[Serializable]
public class ComboTreeData
{
// --- 修改点 ---
// 将标题移到这里,使其在内联属性的顶部显示
[Title("连招树编辑器", "可视化编辑连招树的节点和分支")]
// --- 修改结束 ---
public float resetTime = 0.2f;
[ListDrawerSettings(
DraggableItems = true, // 现在可以安全地拖动排序了!
NumberOfItemsPerPage = 20,
CustomAddFunction = "AddNode",
CustomRemoveElementFunction = "RemoveNode")]
CustomRemoveElementFunction = "RemoveNode",
ListElementLabelName = "GetComboNodeLabel")]
[HideReferenceObjectPicker]
public List<ComboNodeData> nodes;
/// <summary>
/// Odin Inspector 自定义添加按钮的实现
/// </summary>
@@ -107,9 +112,9 @@ namespace Cielonos.MainGame.Inventory
return nodes.Select(n => n.referenceName).Where(n => !string.IsNullOrEmpty(n));
}
public ComboSubmodule.ComboTree ToRuntime()
public ComboSubmodule.ComboTree ToRuntime(ComboSubmodule owner)
{
var runtimeTree = new ComboSubmodule.ComboTree();
var runtimeTree = new ComboSubmodule.ComboTree(owner, resetTime);
runtimeTree.nodes = new List<ComboSubmodule.ComboTree.Node>();
// 创建运行时节点
@@ -129,6 +134,7 @@ namespace Cielonos.MainGame.Inventory
return runtimeTree;
}
}
/// <summary>
@@ -141,7 +147,8 @@ namespace Cielonos.MainGame.Inventory
[InfoBox("这是 Root 节点,是所有连招的起点。", InfoMessageType.Info, "IsRootNode")]
public string referenceName;
[ListDrawerSettings(NumberOfItemsPerPage = 5)]
[ListDrawerSettings(NumberOfItemsPerPage = 10, CustomAddFunction = "AddBranch")]
[HideReferenceObjectPicker]
public List<ComboBranchData> branches = new List<ComboBranchData>();
private bool IsRootNode() => referenceName == "Root";
@@ -156,6 +163,31 @@ namespace Cielonos.MainGame.Inventory
return true;
}
private void AddBranch()
{
branches.Add(new ComboBranchData());
}
private string GetComboNodeLabel()
{
// 1. 获取当前节点名称
string name = string.IsNullOrEmpty(referenceName) ? "[未命名]" : referenceName;
// 2. 如果没有分支,直接返回节点名
if (branches == null || branches.Count == 0)
{
return name;
}
// 3. 拼接子节点名称
// 这里使用 Linq 提取所有分支的目标节点名
// 格式示例: "Root - (1, 2, 3)"
List<string> targetNodes = branches
.Select(b => b == null || string.IsNullOrEmpty(b.nextNodeRefName) ? "?" : $"{b.operation}->{b.nextNodeRefName}").ToList();
return $"{name} - ({string.Join(", ", targetNodes)})";
}
}
/// <summary>
@@ -171,7 +203,5 @@ namespace Cielonos.MainGame.Inventory
[HorizontalGroup("Branch")]
[LabelText("下一个节点")]
public string nextNodeRefName; // <-- 使用名称引用,而不是索引
// --- Odin 辅助字段和方法 ---
}
}