// 座標チャンネルへの入室処理をカスタマイズしたいときは、 // シーンファイルの入室パターンを「custom」に設定した上で、 // このファイルのFirstJoinCustomとFailedJoinCustomを実装する component ChSJoinProcess { ChSBridge m_ChSBridge; ChSModel m_Model; fVoidCallback m_CheckAuthorityJwtCallback; public ChSJoinProcess() { m_ChSBridge = system.Layer_GetComponentByName("vcc_icon_only_base"); m_Model = system.Layer_GetComponentByName("vcc_icon_only_base"); } public void FirstJoinCustom(JsVal val) { // カスタムの初回入室処理を実装 } public void FailedJoinCustom(JsVal val) { // カスタムの入室失敗時の処理を実装 } public void JoinFromURLRoomID(JsVal val) { m_Model.EnterPositionChannel(hel_skyway_get_roomid()); } JsVal BuildJoinPositionChannelArgs() { JsVal args = makeJsObj(); args.AddPropertyByVal("spatiumCode", makeJsStrFrom(hsNetGetSpatiumCode())); args.AddPropertyByVal("worldCode", makeJsStrFrom(hsGetCurrentWorldId())); return args; } public void JoinPositionChannelByLobbying(JsVal val) { hel_net_join_position_channel_by_lobbying( _CheckAuthorizationJwtAndTicketJwt, BuildJoinPositionChannelArgs() ); } void _CheckAuthorizationJwtAndTicketJwt(JsVal returnValues) { JsVal authorizationJwt = returnValues.GetProperty("authorizationJwt"); g_authorityJwt = !authorizationJwt.IsNull() ? authorizationJwt.GetStr() : ""; JsVal ticketJwt = returnValues.GetProperty("ticketJwt"); g_ticketJwt = !ticketJwt.IsNull() ? ticketJwt.GetStr() : ""; } public void JoinRandomPositionChannel(JsVal val) { JsVal args = BuildJoinPositionChannelArgs(); args.AddPropertyByVal("excludeEmptyChannel", makeJsBoolFrom(hsNetExcludeEmptyChannel())); args.AddPropertyByVal("allowMultiVoiceChannel", makeJsBoolFrom(m_ChSBridge.IsAllowMultiVoiceChannel())); hel_net_join_random_position_channel(_JoinRandomPositionChannelCallback, args); } void _JoinRandomPositionChannelCallback(JsVal returnValues) { _CheckAuthorizationJwtAndTicketJwt(returnValues); JsVal errorCode = returnValues.GetProperty("errorCode"); if (errorCode.IsNull()) { return; } m_ChSBridge.HandlePositionChannelCreationError(errorCode.GetStr()); } public void JoinSelectedAnyRoom(JsVal val) { // チャンネルリストのUIを開く LayerBundle layer = hsLayerGet("vcc_icon_only_base"); if (layer !== null) { if (m_ChSBridge.IsAllowMultiVoiceChannel()) { layer.CallComponentMethod("VCCViewModel", "OpenSpaceList", ""); } else { layer.CallComponentMethod("VCCViewModel", "OpenChannelList", ""); } } } public void JoinNewRoom(JsVal val) { m_Model.CreateNewPositionChannel( (m_ChSBridge.IsAllowMultiVoiceChannel() ? "FreeSpace" : "FreeTalk") + "_%d" % hsMathRandom(999999), "public" ); } public void RedirectToOutGame(JsVal val) { // 後ほどHeliScript組み込み関数を実装 hel_transitionToPage(hsNetGetPosChannelRedirectURL("playerexceed")); } public bool CheckUserCount(JsVal val) { // チャンネル情報の解析 if (val === null || (val.GetType() != 1 && val.GetType() != 2)) return false; VCCPositionChannel Channel = new VCCPositionChannel(); if (!Channel.Analyse(val, false)) return false; if (Channel.Data.ChannelId.IsEmpty()) return false; // 指定ルームが満員かどうかチェック if (Channel.Data.JoinUsersData.Count + 1 > (m_ChSBridge.IsAllowMultiVoiceChannel() // 1対NタイプのRTCの場合はMaxPosPlayerCountを見る ? Channel.Data.MaxPosPlayerCount // 1対1タイプのRTCの場合はMaxVoicePlayerCountを見る // 音声が20人より多いとスマホ端末で落ちやすくなってしまう : Channel.Data.MaxVoicePlayerCount)) return false; // ルームが空いている return true; } }