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(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(FriendDataObjType.PlayerTable); } public static FriendRecommendTable GetFriendRecommendTable() { return ServerDataObjMgr.GetDataObj(FriendDataObjType.FriendRecommendTable); } public static FriendInfoCache GetFriendInfoCacheTable() { return ServerDataObjMgr.GetDataObj(FriendDataObjType.FriendInfoCache); } ///service public static PlayerTableOp GetPlayerTableOp() { return ServiceMgr.GetService(FriendServiceType.PlayerTableOp); } public static EventHandlerMgr GetEventHandlerMgr() { return ServiceMgr.GetService(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; } } }