推动Config新增
This commit is contained in:
@@ -3,6 +3,8 @@ using Convention.WindowsUI.Variant;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
@@ -16,8 +18,56 @@ namespace Demo.Game
|
||||
|
||||
[Content] public GameController RootGameController;
|
||||
|
||||
public string SourcePath;
|
||||
public HashSet<string> LoadedScriptSet = new();
|
||||
[Setting]public string SourcePath;
|
||||
[Header("GlobalConfig")]
|
||||
public readonly HashSet<string> LoadedScriptSet = new();
|
||||
public readonly Dictionary<int, ScriptableObject> LoadedScriptIndex = new();
|
||||
public readonly Dictionary<ScriptableObject, int> LoadedScriptRIndex = new();
|
||||
private int LoadedScriptCnt = 0;
|
||||
/// <summary>
|
||||
/// 被用于自动生成
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public int PushLoadedScriptObject(ScriptableObject obj)
|
||||
{
|
||||
while (LoadedScriptIndex.TryAdd(LoadedScriptCnt, obj) == false)
|
||||
LoadedScriptCnt++;
|
||||
LoadedScriptRIndex.Add(obj, LoadedScriptCnt);
|
||||
return LoadedScriptCnt++;
|
||||
}
|
||||
/// <summary>
|
||||
/// 被用于从缓存中生成
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public int PushLoadedScriptObject(ScriptableObject obj, int index)
|
||||
{
|
||||
LoadedScriptIndex.Add(index, obj);
|
||||
LoadedScriptRIndex.Add(obj, index);
|
||||
return index;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过序列号获得物体
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public ScriptableObject FindWithIndex(int index)
|
||||
{
|
||||
if(index<0)
|
||||
return null;
|
||||
return LoadedScriptIndex[index];
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过物体获得序列号
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns>若无法找到将返回-1</returns>
|
||||
public int FindIndex(ScriptableObject obj)
|
||||
{
|
||||
return LoadedScriptRIndex.TryGetValue(obj, out var index) ? index : -1;
|
||||
}
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user