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.
115 lines
3.0 KiB
115 lines
3.0 KiB
1 month ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
using Sog;
|
||
|
using ProtoCSStruct;
|
||
|
|
||
|
namespace Friend
|
||
|
{
|
||
|
public static class FriendServerUtils
|
||
|
{
|
||
|
public static FriendServerData GetFriendServerData()
|
||
|
{
|
||
|
return ServerDataObjMgr.GetDataObj<FriendServerData>(FriendDataObjType.FriendServerData);
|
||
|
}
|
||
|
|
||
|
public static ProtoCSStructPacker GetProtoPacker()
|
||
|
{
|
||
|
return ProtoPackerFactory.Instance.GetProtoCSStructPacker();
|
||
|
}
|
||
|
|
||
|
public static StructPacketSender GetPacketSender()
|
||
|
{
|
||
|
return GetFriendServerData().m_packetSender;
|
||
|
}
|
||
|
|
||
|
|
||
|
public static PlayerTable GetPlayerTable()
|
||
|
{
|
||
|
return ServerDataObjMgr.GetDataObj<PlayerTable>(FriendDataObjType.PlayerTable);
|
||
|
}
|
||
|
|
||
|
public static FriendRecommendTable GetFriendRecommendTable()
|
||
|
{
|
||
|
return ServerDataObjMgr.GetDataObj<FriendRecommendTable>(FriendDataObjType.FriendRecommendTable);
|
||
|
}
|
||
|
|
||
|
|
||
|
public static FriendInfoCache GetFriendInfoCacheTable()
|
||
|
{
|
||
|
return ServerDataObjMgr.GetDataObj<FriendInfoCache>(FriendDataObjType.FriendInfoCache);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
///service
|
||
|
public static PlayerTableOp GetPlayerTableOp()
|
||
|
{
|
||
|
return ServiceMgr.GetService<PlayerTableOp>(FriendServiceType.PlayerTableOp);
|
||
|
}
|
||
|
|
||
|
public static EventHandlerMgr GetEventHandlerMgr()
|
||
|
{
|
||
|
return ServiceMgr.GetService<EventHandlerMgr>(FriendServiceType.EventHandlerMgr);
|
||
|
}
|
||
|
|
||
|
public static long GetTimeMs()
|
||
|
{
|
||
|
return GetFriendServerData().m_app.Time.GetTime();
|
||
|
}
|
||
|
|
||
|
public static long GetTimeSecond()
|
||
|
{
|
||
|
return GetFriendServerData().m_app.Time.GetTimeSecond();
|
||
|
}
|
||
|
|
||
|
public static DateTime GetDateTime()
|
||
|
{
|
||
|
return GetFriendServerData().m_app.Time.GetDateTime();
|
||
|
}
|
||
|
|
||
|
public static ServerApp GetApp()
|
||
|
{
|
||
|
return GetFriendServerData().m_app;
|
||
|
}
|
||
|
|
||
|
public static uint GetAppID()
|
||
|
{
|
||
|
return GetFriendServerData().m_app.ServerID;
|
||
|
}
|
||
|
|
||
|
public static int GetLogicWorldId(int realmId)
|
||
|
{
|
||
|
RealmBriefInfo briefInfo = GetRealmBriefInfo(realmId);
|
||
|
if (briefInfo != null)
|
||
|
{
|
||
|
return briefInfo.logicWorldId;
|
||
|
}
|
||
|
|
||
|
TraceLog.Error("FriendServerUtils.GetLogicWorldId fail {0}", realmId);
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public static RealmBriefInfo GetRealmBriefInfo(int realmId)
|
||
|
{
|
||
|
GetFriendServerData().m_realmInfosMap.TryGetValue(realmId, out var briefInfo);
|
||
|
return briefInfo;
|
||
|
|
||
|
}
|
||
|
|
||
|
public static bool CheckIsSameLogicWorld(int realm1, int realm2)
|
||
|
{
|
||
|
if (realm1 == realm2)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
int logicWorld1 = GetLogicWorldId(realm1);
|
||
|
int logicWorld2 = GetLogicWorldId(realm2);
|
||
|
return logicWorld1 == logicWorld2;
|
||
|
}
|
||
|
}
|
||
|
}
|