Esempio n. 1
0
    private void OnRealmConnectionFailed(JumpInPayload failedRealm)
    {
        bool isArchipelagoRealm = string.IsNullOrEmpty(failedRealm.realm.layer);

        if (failedRealm.gridPosition != lastJumpInTried.gridPosition ||
            failedRealm.realm.serverName != lastJumpInTried.realm.serverName ||
            (!isArchipelagoRealm && failedRealm.realm.layer != lastJumpInTried.realm.layer))
        {
            return;
        }

        if (nextMostPopulatedRealms.Count > 0)
        {
            WebInterface.NotifyStatusThroughChat("Trying to connect to the next more populated realm...");
            HotScenesController.HotSceneInfo.Realm nextRealmToTry = nextMostPopulatedRealms.Dequeue();
            SetLastJumpInTried(hotSceneInfo.baseCoords, nextRealmToTry.serverName, nextRealmToTry.layer);
            OnJumpIn?.Invoke(hotSceneInfo.baseCoords, nextRealmToTry.serverName, nextRealmToTry.layer);
        }
        else
        {
            WebInterface.NotifyStatusThroughChat("You'll stay in your current realm.");
            RealmsInfoBridge.OnRealmConnectionSuccess -= OnRealmConnectionSuccess;
            RealmsInfoBridge.OnRealmConnectionFailed  -= OnRealmConnectionFailed;
            OnJumpIn?.Invoke(hotSceneInfo.baseCoords, null, null);
        }
    }
Esempio n. 2
0
    public void JumpInPressed()
    {
        HotScenesController.HotSceneInfo.Realm realm = new HotScenesController.HotSceneInfo.Realm()
        {
            layer = null, serverName = null
        };
        hotSceneInfo.realms = hotSceneInfo.realms.OrderByDescending(x => x.usersCount).ToArray();
        nextMostPopulatedRealms.Clear();
        for (int i = 0; i < hotSceneInfo.realms.Length; i++)
        {
            bool isArchipelagoRealm = string.IsNullOrEmpty(hotSceneInfo.realms[i].layer);

            if (isArchipelagoRealm || hotSceneInfo.realms[i].usersCount < hotSceneInfo.realms[i].maxUsers)
            {
                realm = hotSceneInfo.realms[i];
                if (i < hotSceneInfo.realms.Length - 1)
                {
                    nextMostPopulatedRealms = new Queue <HotScenesController.HotSceneInfo.Realm>(hotSceneInfo.realms.ToList().GetRange(i + 1, hotSceneInfo.realms.Length - i - 1));
                }
                break;
            }
        }

        if (!string.IsNullOrEmpty(realm.serverName))
        {
            RealmsInfoBridge.OnRealmConnectionSuccess -= OnRealmConnectionSuccess;
            RealmsInfoBridge.OnRealmConnectionSuccess += OnRealmConnectionSuccess;
            RealmsInfoBridge.OnRealmConnectionFailed  -= OnRealmConnectionFailed;
            RealmsInfoBridge.OnRealmConnectionFailed  += OnRealmConnectionFailed;
        }

        SetLastJumpInTried(hotSceneInfo.baseCoords, realm.serverName, realm.layer);
        OnJumpIn?.Invoke(hotSceneInfo.baseCoords, realm.serverName, realm.layer);
    }
    public void JumpInPressed()
    {
        HotScenesController.HotSceneInfo.Realm realm = new HotScenesController.HotSceneInfo.Realm()
        {
            layer = null, serverName = null
        };
        for (int i = 0; i < hotSceneInfo.realms.Length; i++)
        {
            if (hotSceneInfo.realms[i].usersCount < hotSceneInfo.realms[i].usersMax)
            {
                realm = hotSceneInfo.realms[i];
                break;
            }
        }

        OnJumpIn?.Invoke(hotSceneInfo.baseCoords, realm.serverName, realm.layer);
    }