Пример #1
0
    // Token: 0x06005943 RID: 22851 RVA: 0x001EFAF0 File Offset: 0x001EDEF0
    private ApiWorld.WorldInstance ConfigurePortal(ApiWorld world)
    {
        this.portalTrigger = base.gameObject.GetOrAddComponent <PortalTrigger>();
        this.portalTrigger.effectPrefabName = "PortalExitEffect";
        this.isValidWorld = true;
        string name = (!(this.portalMarker != null) || string.IsNullOrEmpty(this.portalMarker.customPortalName)) ? world.name : this.portalMarker.customPortalName;

        this.DownloadWorldImage(world.imageUrl);
        BoxCollider orAddComponent = base.gameObject.GetOrAddComponent <BoxCollider>();

        orAddComponent.center    = new Vector3(0f, 1f, 0f);
        orAddComponent.size      = new Vector3(1f, 2f, 1f);
        orAddComponent.isTrigger = true;
        ApiWorld.WorldInstance worldInstance = (!this.Dynamic) ? world.GetBestInstance(null, ModerationManager.Instance.IsBannedFromPublicOnly(APIUser.CurrentUser.id)) : new ApiWorld.WorldInstance(this.worldInstanceId, 0);
        this.worldInstanceId = worldInstance.idWithTags;
        VRC.Player player = null;
        if (this.Dynamic)
        {
            player = VRC.Network.GetPlayerByInstigatorID(this.CreatorId);
            if (player != null)
            {
                Vector3 position = player.transform.position;
                position.y = 0f;
                Vector3 position2 = base.transform.position;
                position2.y = 0f;
                Vector3 a = position2 - position;
                base.transform.rotation = Quaternion.LookRotation(-a, Vector3.up);
            }
            if (base.transform.Find("Timer") != null)
            {
                base.transform.Find("Timer").gameObject.SetActive(true);
            }
            if (base.transform.Find("Timer/TextMesh") != null)
            {
                this.timerText = base.transform.Find("Timer/TextMesh").GetComponent <TextMeshPro>();
            }
            if (base.transform.Find("PlayerCount") != null)
            {
                this.playerCountObj = base.transform.Find("PlayerCount").gameObject;
                this.playerCountObj.SetActive(true);
            }
            if (base.transform.Find("PlayerCount/TextMesh"))
            {
                this.playerCountText = base.transform.Find("PlayerCount/TextMesh").GetComponent <TextMeshPro>();
            }
            RoomManager.PortalCreated(this);
        }
        this.SetupPortalName(name, worldInstance, world, (!(player == null)) ? player.name : string.Empty);
        this.apiWorld = world;
        return(worldInstance);
    }
Пример #2
0
 // Token: 0x0600549D RID: 21661 RVA: 0x001D3148 File Offset: 0x001D1548
 public static bool EnterWorld(ApiWorld world, string instanceId = "")
 {
     Debug.Log("Entering Room: " + world.name);
     if (VRCFlowNetworkManager.Instance == null || !VRCFlowNetworkManager.Instance.isConnected || !RoomManager.enterRoomReady)
     {
         string message = "Cannot join room. Connection not ready for join operations";
         UserMessage.SetMessage(message);
         Debug.LogError(message);
         return(false);
     }
     try
     {
         RoomManager.LockdownOverride = false;
         Analytics.Send(ApiAnalyticEvent.EventType.joinsWorld, world.id, null, null);
         ExitGames.Client.Photon.Hashtable hashtable = new ExitGames.Client.Photon.Hashtable();
         hashtable["scene"]     = "Custom";
         hashtable["url"]       = world.assetUrl;
         hashtable["name"]      = world.name;
         hashtable["blueprint"] = world;
         string[] customRoomPropertiesForLobby = new string[]
         {
             "scene",
             "url",
             "name"
         };
         RoomOptions roomOptions = new RoomOptions();
         roomOptions.IsOpen                       = true;
         roomOptions.IsVisible                    = true;
         roomOptions.MaxPlayers                   = (byte)((world.capacity * 2 >= 255) ? 255 : (world.capacity * 2));
         roomOptions.CustomRoomProperties         = hashtable;
         roomOptions.CustomRoomPropertiesForLobby = customRoomPropertiesForLobby;
         List <string> list = (from m in ModerationManager.Instance.GetModerationsOfType(ApiModeration.ModerationType.Kick)
                               where m.worldId == world.id
                               select m.instanceId).ToList <string>();
         if (world.capacity == 1)
         {
             instanceId = User.CurrentUser.id + ((!ModerationManager.Instance.IsBannedFromPublicOnly(APIUser.CurrentUser.id)) ? string.Empty : ApiWorld.WorldInstance.BuildAccessTags(ApiWorld.WorldInstance.AccessType.FriendsOnly, APIUser.CurrentUser.id));
         }
         else if (string.IsNullOrEmpty(instanceId) || list.Contains(instanceId))
         {
             instanceId = world.GetBestInstance(list, ModerationManager.Instance.IsBannedFromPublicOnly(APIUser.CurrentUser.id)).idWithTags;
         }
         string text = world.id + ":" + instanceId;
         Debug.Log("Joining " + text);
         Debug.Log("Joining or Creating Room: " + world.name);
         bool flag = PhotonNetwork.JoinOrCreateRoom(text, roomOptions, TypedLobby.Default);
         if (!flag)
         {
             RoomManager.currentRoom = null;
             RoomManager.ClearMetadata();
             throw new Exception("JoinOrCreateRoom failed!");
         }
         RoomManager.currentRoom = world;
         RoomManager.currentRoom.currentInstanceIdWithTags = instanceId;
         ApiWorld.WorldInstance worldInstance = new ApiWorld.WorldInstance(instanceId, 0);
         RoomManager.currentRoom.currentInstanceIdOnly = worldInstance.idOnly;
         RoomManager.currentRoom.currentInstanceAccess = worldInstance.GetAccessType();
         Debug.Log("Successfully joined room");
         RoomManager.lastMetadataFetchMinute = -1;
     }
     catch (Exception ex)
     {
         Debug.LogError("Something went entering room:\n" + ex.ToString() + "\n" + ex.StackTrace);
         return(false);
     }
     return(true);
 }
Пример #3
0
        // Token: 0x06006074 RID: 24692 RVA: 0x0021F7B8 File Offset: 0x0021DBB8
        public void SetupWorldInfo(ApiWorld world, ApiWorld.WorldInstance instance = null, bool newInstance = false, bool isPortal = false)
        {
            if (instance == null)
            {
                instance = world.GetBestInstance(null, false);
            }
            this.mWorld           = world;
            this.worldInstance    = instance;
            this.openedFromPortal = isPortal;
            ApiWorld.WorldInstance.AccessType   accessType   = this.worldInstance.GetAccessType();
            ApiWorld.WorldInstance.AccessDetail accessDetail = ApiWorld.WorldInstance.GetAccessDetail(accessType);
            string str = string.Empty;

            this.roomName.text = world.name;
            string instanceCreator = this.worldInstance.GetInstanceCreator();

            str = accessDetail.shortName;
            this.instanceStatus.text = accessDetail.fullName;
            if (accessType == ApiWorld.WorldInstance.AccessType.Public)
            {
                this.roomAuthor.text = world.authorName;
                this.roomOwner.text  = world.authorName;
            }
            else if (accessType == ApiWorld.WorldInstance.AccessType.InviteOnly || accessType == ApiWorld.WorldInstance.AccessType.FriendsOnly || accessType == ApiWorld.WorldInstance.AccessType.FriendsOfGuests)
            {
                this.roomAuthor.text = world.authorName;
                this.roomOwner.text  = "(loading...)";
                APIUser.Fetch(instanceCreator, delegate(APIUser user)
                {
                    this.roomOwner.text = user.displayName;
                }, null);
            }
            this.playerCount.text     = this.worldInstance.count.ToString();
            this.maxPlayers.text      = world.capacity.ToString();
            this.worldInstanceId.text = "#" + this.worldInstance.idOnly + " " + str;
            Downloader.DownloadImage(world.imageUrl, delegate(string downloadedUrl, Texture2D obj)
            {
                this.roomImage.texture = obj;
            }, string.Empty);
            this.isPortalMenu = isPortal;
            this.ConfigureJoinButton(instance.count >= world.capacity, instance.isPublic);
            this.ConfigurePortalButton(accessType, instanceCreator == APIUser.CurrentUser.id, instance.count >= world.capacity, instance.isPublic);
            if (isPortal)
            {
                this.backButton.GetComponentInChildren <Text>().text = "Exit";
                this.backButton.onClick.AddListener(new UnityAction(this.Respawn));
                VRCUiManager.Instance.ShowScreen("UserInterface/MenuContent/Backdrop/Backdrop");
                VRCUiManager.Instance.HideScreen("HEADER");
                QuickMenu.Instance.CanExitWithButton = false;
            }
            else
            {
                this.backButton.onClick.AddListener(new UnityAction(this.BackToWorlds));
                this.backButton.GetComponentInChildren <Text>().text = "Back";
            }
            if (this.il != null)
            {
                this.il.world = world;
                this.il.Refresh();
            }
            if (world.releaseStatus == "public" || world.authorId == APIUser.CurrentUser.id)
            {
                this.newInstanceButton.interactable = true;
            }
            if (instance.count >= world.capacity)
            {
                this.playerCount.text = "Full";
            }
            this.SetCurrentInstanceMessage(string.Empty, false);
            if (RoomManager.inRoom)
            {
                ApiWorld currentRoom = RoomManager.currentRoom;
                if (currentRoom.id == world.id && currentRoom.currentInstanceIdWithTags == this.worldInstance.idWithTags)
                {
                    this.SetCurrentInstanceMessage("You are here", true);
                }
            }
            if (newInstance)
            {
                this.SetCurrentInstanceMessage("NEW INSTANCE", true);
            }
        }