Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard/ChatReplayListDialog.cs
gamer147 824309ec44 feat(battle-engine): close the AI-simulation subsystem (verbatim)
Copied the 89 uncopied AI*SimulationUtility/extension files defining the
AIVirtualCard/AIVirtualField extension methods; the compile loop then auto-closed
the revealed type deps (~3049 files total, drift-clean). 10.0k -> 62 errors.
2026-06-05 20:30:59 -04:00

91 lines
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Cute;
using UnityEngine;
namespace Wizard;
public class ChatReplayListDialog : MonoBehaviour
{
[SerializeField]
private SimpleScrollViewUI _replayListScrollView;
[SerializeField]
private UILabel _labelNoReplay;
private List<ReplayInfoItem> _listReplayInfoItem;
private Action<ReplayInfoItem> _onClickReplaySendBtn;
private List<string> _loadedResourceList = new List<string>();
public void Init(List<ReplayInfoItem> listReplayInfoItem, Action<ReplayInfoItem> onClickReplaySendBtn)
{
_listReplayInfoItem = listReplayInfoItem;
_onClickReplaySendBtn = onClickReplaySendBtn;
CreateReplayList();
}
private void CreateReplayList()
{
bool flag = _listReplayInfoItem.Count <= 0;
_replayListScrollView.SetVisiable(!flag);
_labelNoReplay.gameObject.SetActive(flag);
if (!flag)
{
LoadResources(delegate
{
_replayListScrollView.CreateScrollView(_listReplayInfoItem.Count, OnInitializeContent);
});
}
}
private void OnInitializeContent(int index, GameObject plate)
{
ReplayInfoItem replayInfo = _listReplayInfoItem[index];
plate.GetComponent<ChatReplayListDialogContent>().SetData(replayInfo, delegate
{
_onClickReplaySendBtn.Call(replayInfo);
});
}
private void LoadResources(Action callBack = null)
{
UIManager.GetInstance().createInSceneCenterLoading();
List<string> list = new List<string>();
foreach (ReplayInfoItem item in _listReplayInfoItem)
{
list.Add(Toolbox.ResourcesManager.GetAssetTypePath(item.OpponentEmblemId, ResourcesManager.AssetLoadPathType.Emblem_S));
if (!string.IsNullOrEmpty(item.OpponentCountryCode))
{
list.Add(Toolbox.ResourcesManager.GetAssetTypePath(item.OpponentCountryCode, ResourcesManager.AssetLoadPathType.Country_S));
}
}
List<string> loadPathList = list.Distinct().Except(_loadedResourceList).ToList();
if (loadPathList.Count > 0)
{
StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(loadPathList, delegate
{
_loadedResourceList.AddRange(loadPathList);
UIManager.GetInstance().closeInSceneCenterLoading();
callBack.Call();
}));
}
}
private void UnloadResources()
{
if (_loadedResourceList.Count > 0)
{
Toolbox.ResourcesManager.RemoveAssetGroup(_loadedResourceList);
_loadedResourceList.Clear();
}
}
private void OnDestroy()
{
UnloadResources();
}
}