using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using ProtoCSStruct; using Sog; namespace Friend { public class PlayerTable : IServerDataObj { // uid public Dictionary m_playerTable; public List m_playerListForUpdate; public PlayerTable() { m_playerTable = new Dictionary(); m_playerListForUpdate = new List(); } public override int GetDataType() { return FriendDataObjType.PlayerTable; } } public class FixedList { private T[] array; private int count; private int length; public FixedList(int num) { array = new T[num]; count = 0; length = num; } public int Count => count; public int Lenght => length; public ref T this[int index] { get { if (index < 0 || index >= count) { throw new ArgumentOutOfRangeException(); } return ref array[index]; } } public void Add(ref T item) { if (count >= length) { throw new ArgumentOutOfRangeException(); } array[count] = item; count++; } public bool IsFull() { return count >= length; } public void Clear() { count = 0; } } public class FriendRecommendInfo { public static int MaxLevel = 10; public static int ArrayNum = MaxLevel / 10 + 1; public static int NumPerLevel = 500; // 每10级一个推荐组, uidHash方便查询是否在组中, uidList记录所有在组里的数据, 方便随机推荐 public int logicWorldId; public HashSet[] uidHash = new HashSet[ArrayNum]; public FixedList[] uidList = new FixedList[ArrayNum]; public FriendRecommendInfo(int logicWorldId) { this.logicWorldId = logicWorldId; for (int i = 0; i < ArrayNum; i++) { uidHash[i] = new HashSet(); uidList[i] = new FixedList(NumPerLevel); } } } public class FriendRecommendTable : IServerDataObj { public Dictionary m_recommendInfoTable; public long nextTickSec; public FriendRecommendTable() { m_recommendInfoTable = new Dictionary(); } public override int GetDataType() { return FriendDataObjType.FriendRecommendTable; } } }