void RPC_S2C_StartLogin(uLink.BitStream stream, uLink.NetworkMessageInfo info) { _pos = transform.position = stream.Read <Vector3>(); int recordTeamId = stream.Read <int>(); bool hasRecord = stream.Read <bool>(); _networkState = stream.Read <ENetworkState>(); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.ChangePlayerStateByNet(Id, (int)NetworkState); } _useNewPos = UseNewPosition(hasRecord, recordTeamId); ChunkManager.Clear(); if (null != PeSceneCtrl.Instance) { PeSceneCtrl.Instance.GotoGameSence(); } if (Pathea.PeGameMgr.IsCustom) { int descId = -1 == DescId ? Id : DescId; curPlayerDesc = ForceSetting.AddPlayer(descId, TeamId, EPlayerType.Human, RoleName); } }
public static void RPC_S2C_ResponseUGC(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int count = stream.Read <int>(); if (count <= 0) { if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.Instance.ActiveStartBtn(); } } else { RegisteredISO[] isos = stream.Read <RegisteredISO[]>(); foreach (RegisteredISO iso in isos) { if (_SteamItems.ContainsKey(iso._hashCode)) { _SteamItems[iso._hashCode] = iso._isoName; } } RoomGui_N.SetDownLoadInfo(isos.Length); _DownloadList.Clear(); _CurDownloadList.Clear(); _DownloadList.AddRange(isos); //foreach(var iter in _DownloadList) //{ // _CurDownloadList.Add(iter.UGCHandle); //} } }
void RPC_Ping(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int ping = stream.Read <int>(); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.ChangePlayerDelayByNet(Id, ping); } }
IEnumerator DownLoadCoroutine() { int lastDownloadBytes = 0; while (true) { if (_DownloadList.Count >= 1 && NetworkInterface.IsClient) { string isoName = _DownloadList[0]._isoName; if (0 == _CurDownload) { _CurDownload = _DownloadList[0].UGCHandle; DownloadUGC(); lastDownloadBytes = 0; } else { int downloadedBytes = 0; int totalBytes = 0; if (SteamRemoteStorage.GetUGCDownloadProgress(new UGCHandle_t(_CurDownload), out downloadedBytes, out totalBytes)) { if (0 != totalBytes && downloadedBytes != lastDownloadBytes) { int speed = downloadedBytes - lastDownloadBytes; lastDownloadBytes = downloadedBytes; speed /= 1024; RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, speed); RoomGui_N.SetMapInfo("Downloading " + isoName + "...[" + downloadedBytes * 100 / totalBytes + "%]"); } } else { // string skey = ""; foreach (KeyValuePair <string, FileSender> iter in _FileSenderMgr) { if (iter.Value.m_FileHandle == _CurDownload && iter.Value.m_FileSize > 0) { int speed = iter.Value.m_Sended - lastDownloadBytes; lastDownloadBytes = iter.Value.m_Sended; speed /= 1024; totalBytes = iter.Value.m_FileSize; RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, speed); RoomGui_N.SetMapInfo("Downloading " + isoName + "...[" + downloadedBytes * 100 / totalBytes + "%]"); break; } } } } } yield return(new WaitForSeconds(0.02f)); } }
void Awake() { m_Instance = this; //this.m_RoomPlayerList = new List<RoomPlayerInfo>(); this.m_IsoDownloadInfo = new IsoDownLoadInfo(); this.m_ForceDic = new Dictionary <int, Dictionary <int, int> >(); this.m_ForceItemList = new List <ForceItem_N>(); this.m_RoomInfoComp = this.ForceInfoGo.GetComponent <RoomInfo_N>(); this.m_RoomChatComp = this.ForceChatGo.GetComponent <RoomChat_N>(); this.m_Repositioning = false; this.m_InitAllForce = false; }
public static void RPC_S2C_SendFile(uLink.BitStream stream, uLink.NetworkMessageInfo info) { byte [] data = stream.Read <byte[]> (); int count = stream.Read <int> (); string skey = stream.Read <string> (); if (data != null && count != 0) { if (_FileSenderMgr.ContainsKey(skey) && _FileSenderMgr[skey] != null) { bool bFinish = false; _FileSenderMgr[skey].WriteData(data, count, ref bFinish); if (bFinish) { RegisteredISO iso = _DownloadList.Find(iter => iter.UGCHandle == _FileSenderMgr[skey].m_FileHandle); if (iso != null) { string fielName = VCConfig.s_CreationNetCachePath + _FileSenderMgr[skey].m_FileName + VCConfig.s_CreationNetCacheFileExt; using (FileStream fs = new FileStream(fielName, FileMode.Create, FileAccess.Write, FileShare.Read)) { fs.Write(_FileSenderMgr[skey].m_Data, 0, (int)_FileSenderMgr[skey].m_FileSize); } _DownloadList.RemoveAll(iter => iter.UGCHandle == _FileSenderMgr[skey].m_FileHandle); Debug.Log(_DownloadList.Count().ToString() + "===========" + _FileSenderMgr[skey].m_FileName); _SteamItems[iso._hashCode] = _FileSenderMgr[skey].m_FileName; } NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, _FileSenderMgr[skey].m_FileHandle); _CurDownload = 0; _FileSenderMgr.Remove(skey); if (_DownloadList.Count <= 0) { RoomGui_N.SetMapInfo("Download complete"); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.Instance.ActiveStartBtn(); } } else { RoomGui_N.SetMapInfo("Downloading " + _FileSenderMgr[skey].m_FileName + "...[100%]"); } RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0); } else { NetworkManager.SyncServer(EPacketType.PT_Common_UGCUpload, skey, count, true); } } } }
internal static void DownloadUGC() { try { RegisteredISO iso = _DownloadList.Find(iter => iter.UGCHandle == _CurDownload); if (null == iso) { _DownloadList.RemoveAll(iter => iter.UGCHandle == _CurDownload); _CurDownload = 0; return; } if (!_SteamItems.ContainsKey(iso._hashCode)) { //if (_CurDownloadList.Contains(_CurDownload)) // return; UGCHandle_t handler; handler.m_UGCHandle = _CurDownload; SteamAPICall_t caller = SteamRemoteStorage.UGCDownload(handler, 0); //new CallResult<RemoteStorageDownloadUGCResult_t>(OnSteamUGCDownloadResult, caller); RemoteStorageDownloadPreUGCResult = CallResult <RemoteStorageDownloadUGCResult_t> .Create(OnSteamUGCDownloadResult); RemoteStorageDownloadPreUGCResult.Set(caller); RoomGui_N.SetMapInfo("Downloading " + iso._isoName + "...[0%]"); } else { _DownloadList.RemoveAll(iter => iter.UGCHandle == _CurDownload); NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, _CurDownload); _CurDownload = 0; if (_DownloadList.Count <= 0) { RoomGui_N.SetMapInfo("Download complete"); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.Instance.ActiveStartBtn(); } } else { RoomGui_N.SetMapInfo("Downloading " + iso._isoName + "...[100%]"); } } RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0); } catch (Exception e) { LogManager.Warning(e.Message); } }
void RPC_S2C_RoomStatusChanged(uLink.BitStream stream, uLink.NetworkMessageInfo info) { _networkState = stream.Read <ENetworkState>(); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.ChangePlayerStateByNet(Id, (int)NetworkState); } if (IsOwner) { delGrassPos.Clear(); delTreePos.Clear(); } }
public static void RPC_S2C_FileDontExists(uLink.BitStream stream, uLink.NetworkMessageInfo info) { ulong fileHandle = stream.Read <ulong> (); _DownloadList.RemoveAll(iter => iter.UGCHandle == fileHandle); _CurDownload = 0; if (_DownloadList.Count <= 0) { RoomGui_N.SetMapInfo("Download complete"); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.Instance.ActiveStartBtn(); } } RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0); }
void RPC_S2C_TeamChange(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int index = stream.Read <int>(); int descId = stream.Read <int>(); if (!Pathea.PeGameMgr.IsMultiCustom) { if (TeamId == index) { return; } } _teamId = index; _descId = descId; RoomPlayerInfo rpi; if (!RolesInRoom.ContainsKey(Id)) { rpi = new RoomPlayerInfo(); rpi.mId = Id; rpi.mPlayerInfo.mName = Role.name; rpi.mPlayerInfo.mSex = Role.sex; RolesInRoom[Id] = rpi; } else { rpi = RolesInRoom[Id]; } rpi.mPlayerInfo.mLevel = Role.level; rpi.mPlayerInfo.mWinnRate = Role.winrate; rpi.mFocreID = Pathea.PeGameMgr.IsSurvive && !Pathea.PeGameMgr.IsCustom ? -1 : TeamId; rpi.mRoleID = _descId; rpi.mState = (int)NetworkState; _steamID = SteamMgr.steamId; if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.ChangeRoomPlayerByNet(rpi); } }
void RPC_S2C_InitData(uLink.BitStream stream, uLink.NetworkMessageInfo info) { _networkState = stream.Read <ENetworkState>(); _teamId = stream.Read <int>(); _colorIndex = stream.Read <int>(); _descId = stream.Read <int>(); RoomPlayerInfo rpi = new RoomPlayerInfo(); rpi.mId = Id; rpi.mPlayerInfo.mName = Role.name; rpi.mPlayerInfo.mSex = Role.sex; rpi.mPlayerInfo.mLevel = Role.level; rpi.mPlayerInfo.mWinnRate = Role.winrate; rpi.mFocreID = Pathea.PeGameMgr.IsSurvive && !Pathea.PeGameMgr.IsCustom ? -1 : TeamId; rpi.mRoleID = _descId; rpi.mState = (int)NetworkState; RoomGui_N.InitRoomPlayerByNet(rpi); }
protected override void OnPEDestroy() { DelBaseNetwork(); if (ReferenceEquals(this, MainPlayer)) { if (Pathea.PeGameMgr.IsMultiCustom || Pathea.PeGameMgr.IsMultiStory) { LSubTerrSL.OnLSubTerrSLInitEvent -= CacheDelTree; } else { RSubTerrSL.OnRSubTerrSLInitEvent -= CacheDelTree; } GrassDataSL.OnGrassDataInitEvent -= CacheDelGrass; } if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.RemoveRoomPlayerByNet(Id); } }
void RPC_S2C_KickPlayer(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int playerInstanceId = stream.Read <int>(); RoomGui_N.KickPlayerByNet(playerInstanceId); }
void RPC_Message(uLink.BitStream stream, uLink.NetworkMessageInfo info) { string msg = stream.Read <string>(); RoomGui_N.GetNewMsgByNet(RoleName, msg); }
public static void RPC_S2C_DownTimeOut(uLink.BitStream stream, uLink.NetworkMessageInfo info) { /*ulong fileHandle = */ stream.Read <ulong> (); RoomGui_N.SetMapInfo("Download failed"); MessageBox_N.ShowYNBox(PELocalization.GetString(8000116), OnYesEvent, OnNoEvent); }
static void OnSteamUGCDownloadResult(RemoteStorageDownloadUGCResult_t pCallback, bool bIOFailure) { Debug.Log("[SteamUGCDownloadResult] -- " + pCallback.m_eResult + " -- Name:" + pCallback.m_pchFileName + " -- Size:" + pCallback.m_nSizeInBytes); if (pCallback.m_eResult == EResult.k_EResultOK) { RegisteredISO iso = _DownloadList.Find(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle); if (iso != null) { string fielName = VCConfig.s_CreationNetCachePath + iso._hashCode.ToString("X").PadLeft(16, '0') + VCConfig.s_CreationNetCacheFileExt; byte[] fileData = new byte[pCallback.m_nSizeInBytes]; int length = SteamRemoteStorage.UGCRead(pCallback.m_hFile, fileData, pCallback.m_nSizeInBytes, 0, EUGCReadAction.k_EUGCRead_Close); using (FileStream fs = new FileStream(fielName, FileMode.Create, FileAccess.Write, FileShare.Read)) { fs.Write(fileData, 0, length); } _DownloadList.RemoveAll(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle); _SteamItems[iso._hashCode] = pCallback.m_pchFileName; } if (BaseNetwork.MainPlayer.NetworkState == ENetworkState.Null) { NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, pCallback.m_hFile.m_UGCHandle); } else { for (int i = 0; i < _CurDownloadList.Count; i++) { if (_CurDownloadList[i] == pCallback.m_hFile.m_UGCHandle) { NetworkManager.SyncServer(EPacketType.PT_Common_UGCDownloaded, pCallback.m_hFile.m_UGCHandle); _CurDownloadList[i] = 0; } } } _CurDownload = 0; if (_DownloadList.Count <= 0) { RoomGui_N.SetMapInfo("Download complete"); if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) { RoomGui_N.Instance.ActiveStartBtn(); } } else { RoomGui_N.SetMapInfo("Downloading " + pCallback.m_pchFileName + "...[100%]"); } RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0); } else if (pCallback.m_eResult == EResult.k_EResultFileNotFound) { Debug.LogWarning(pCallback.m_hFile.m_UGCHandle + " does not exits."); //_DownloadList.RemoveAll(iter => iter.UGCHandle == pCallback.m_hFile.m_UGCHandle); //_CurDownload = 0; //if (_DownloadList.Count <= 0) //{ // RoomGui_N.SetMapInfo("Download complete"); // if (null != RoomGui_N.Instance && RoomGui_N.Instance.isShow) // RoomGui_N.Instance.ActiveStartBtn(); //} //RoomGui_N.UpdateDownLoadInfo(_DownloadList.Count, 0); NetworkManager.SyncServer(EPacketType.PT_Common_InvalidUGC, _DownloadList[0]._hashCode, pCallback.m_hFile.m_UGCHandle); } else if (pCallback.m_eResult == EResult.k_EResultTimeout) { NetworkManager.SyncServer(EPacketType.PT_Common_DownTimeOut, _DownloadList[0]._hashCode, pCallback.m_hFile.m_UGCHandle); } else { RoomGui_N.SetMapInfo("Download failed"); MessageBox_N.ShowYNBox(PELocalization.GetString(8000116), OnYesEvent, OnNoEvent); } }