调整部分数据表配置,优化 SpriteCache 功能
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SepCore.Event;
|
||||
using SepCore.Definition;
|
||||
@@ -48,8 +49,8 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
private float _spawnRateScaleInput = 1f;
|
||||
private float _extendDurationSeconds = 30f;
|
||||
|
||||
private PropConfig[] _allProps = Array.Empty<PropConfig>();
|
||||
private PropConfig[] _filteredProps = Array.Empty<PropConfig>();
|
||||
private IReadOnlyList<PropConfig> _allProps;
|
||||
private IReadOnlyList<PropConfig> _filteredProps;
|
||||
private string[] _displayNames = Array.Empty<string>();
|
||||
|
||||
private int _cornerTapCount;
|
||||
@@ -212,7 +213,7 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
PropConfig selectedProp = GetSelectedProp();
|
||||
if (selectedProp == null) return;
|
||||
|
||||
GUILayout.Label($"Selected: {selectedProp.Title} ({selectedProp.Rarity})");
|
||||
GUILayout.Label($"Selected: {selectedProp.Name} ({selectedProp.Rarity})");
|
||||
GUILayout.Label(ItemDescUtility.CreatePropDescription(selectedProp.Modifiers), GUILayout.Height(40f));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
@@ -397,27 +398,24 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
|
||||
private void EnsurePropList(bool force = false)
|
||||
{
|
||||
if (!force && _allProps != null && _allProps.Length > 0) return;
|
||||
if (!force && _allProps != null && _allProps.Count > 0) return;
|
||||
|
||||
if (GameEntry.Luban == null)
|
||||
{
|
||||
_allProps = Array.Empty<PropConfig>();
|
||||
_filteredProps = Array.Empty<PropConfig>();
|
||||
_displayNames = Array.Empty<string>();
|
||||
return;
|
||||
}
|
||||
|
||||
var table = GameEntry.Luban.GetTable<PropConfig>();
|
||||
_allProps = table != null ? table.ToArray() : Array.Empty<PropConfig>();
|
||||
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, Mathf.Max(0, _allProps.Length - 1));
|
||||
|
||||
_allProps = GameEntry.Luban.GetTable<PropConfig>();
|
||||
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, Mathf.Max(0, _allProps.Count - 1));
|
||||
ApplyFilter(_searchText);
|
||||
}
|
||||
|
||||
private void ApplyFilter(string keyword)
|
||||
{
|
||||
if (_allProps == null || _allProps.Length == 0)
|
||||
if (_allProps == null || _allProps.Count == 0)
|
||||
{
|
||||
_filteredProps = Array.Empty<PropConfig>();
|
||||
_displayNames = Array.Empty<string>();
|
||||
return;
|
||||
}
|
||||
@@ -431,19 +429,19 @@ public class RuntimeDebugPanelComponent : MonoBehaviour
|
||||
string search = keyword.Trim();
|
||||
_filteredProps = _allProps.Where(p =>
|
||||
p != null &&
|
||||
(p.Title?.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||||
(p.Name?.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||||
p.Id.ToString().Contains(search))).ToArray();
|
||||
}
|
||||
|
||||
_displayNames = _filteredProps.Select(p => $"[{p.Id}] {p.Title} ({p.Rarity})").ToArray();
|
||||
_displayNames = _filteredProps.Select(p => $"[{p.Id}] {p.Name} ({p.Rarity})").ToArray();
|
||||
if (_displayNames.Length == 0) _selectedIndex = 0;
|
||||
else _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1);
|
||||
}
|
||||
|
||||
private PropConfig GetSelectedProp()
|
||||
{
|
||||
if (_filteredProps == null || _filteredProps.Length == 0) return null;
|
||||
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, _filteredProps.Length - 1);
|
||||
if (_filteredProps == null || _filteredProps.Count == 0) return null;
|
||||
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, _filteredProps.Count - 1);
|
||||
return _filteredProps[_selectedIndex];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user