You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.7 KiB
74 lines
1.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using ProtoCSStruct;
|
|
using Sog;
|
|
|
|
namespace Friend
|
|
{
|
|
public class PlayerTableOp : BaseReloadableService
|
|
{
|
|
private PlayerTable m_table;
|
|
|
|
public override int GetServiceType()
|
|
{
|
|
return FriendServiceType.PlayerTableOp;
|
|
}
|
|
|
|
//销毁的时候置空
|
|
public override void Dispose()
|
|
{
|
|
m_table = null;
|
|
}
|
|
|
|
|
|
public PlayerTableOp(PlayerTable playerTable)
|
|
{
|
|
m_table = playerTable;
|
|
}
|
|
|
|
|
|
public PlayerInfoFriend GetPlayerInfo(long uid)
|
|
{
|
|
//是否存在
|
|
if(m_table.m_playerTable.ContainsKey(uid))
|
|
{
|
|
return m_table.m_playerTable[uid];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
|
|
public bool AddPlayerInfo(PlayerInfoFriend playerInfo)
|
|
{
|
|
if (m_table.m_playerTable.ContainsKey(playerInfo.UserID) == false)
|
|
{
|
|
m_table.m_playerTable.Add(playerInfo.UserID, playerInfo);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
// 如果要删除player,必须要player offline再删除,否则好友数据可能要下次上线才能更新
|
|
//
|
|
public bool RemovePlayerInfo(long uid)
|
|
{
|
|
if (m_table.m_playerTable.ContainsKey(uid) == false)
|
|
{
|
|
TraceLog.Error("PlayerTableOp.RemovePlayerInfo uid {0} not in table", uid);
|
|
return false;
|
|
}
|
|
|
|
return m_table.m_playerTable.Remove(uid);
|
|
}
|
|
|
|
public int GetObjCount()
|
|
{
|
|
return m_table.m_playerTable.Count;
|
|
}
|
|
}
|
|
}
|
|
|