using System; using System.Collections.Generic; using UnityEngine; namespace YooAsset.Editor { internal class RemotePlayerSession { private readonly List _reportList = new List(); /// /// 用户ID /// public int PlayerId { private set; get; } /// /// 保存的报告最大数量 /// public int MaxReportCount { private set; get; } public int MinRangeValue { get { return 0; } } public int MaxRangeValue { get { int index = _reportList.Count - 1; if (index < 0) index = 0; return index; } } public RemotePlayerSession(int playerId, int maxReportCount = 1000) { PlayerId = playerId; MaxReportCount = maxReportCount; } /// /// 清理缓存数据 /// public void ClearDebugReport() { _reportList.Clear(); } /// /// 添加一个调试报告 /// public void AddDebugReport(DebugReport report) { if (report == null) Debug.LogWarning("Invalid debug report data !"); if (_reportList.Count >= MaxReportCount) _reportList.RemoveAt(0); _reportList.Add(report); } /// /// 获取调试报告 /// public DebugReport GetDebugReport(int rangeIndex) { if (_reportList.Count == 0) return null; if (rangeIndex < 0 || rangeIndex >= _reportList.Count) return null; return _reportList[rangeIndex]; } /// /// 规范索引值 /// public int ClampRangeIndex(int rangeIndex) { if (rangeIndex < 0) return 0; if (rangeIndex > MaxRangeValue) return MaxRangeValue; return rangeIndex; } } }