Exemple #1
0
        static async Task Main(string[] args)
        {
            VRChatApi.VRChatApi api = new VRChatApi.VRChatApi("avail", "");

            // remote config
            ConfigResponse config = await api.RemoteConfig.Get();

            // user api
            UserResponse user = await api.UserApi.Login();

            //UserResponse userNew = await api.UserApi.Register("someName", "somePassword", "*****@*****.**");
            //UserResponse userUpdated = await api.UserApi.UpdateInfo(user.id, null, null, null, new List<string>() { "admin_moderator", "admin_scripting_access", "system_avatar_access", "system_world_access" });

            // friends
            //List<UserBriefResponse> friends = await api.FriendsApi.Get(0, 20, true);
            //NotificationResponse friendRequestResponse = await api.FriendsApi.SendRequest("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685", api.UserApi.Username);
            //string friendDeletionResponse = await api.FriendsApi.DeleteFriend("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685");
            //await api.FriendsApi.AcceptFriend("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685");

            // world api
            WorldResponse world = await api.WorldApi.Get("wrld_b2d24c29-1ded-4990-a90d-dd6dcc440300");

            //List<WorldBriefResponse> starWorlds = await api.WorldApi.Search(WorldGroups.Favorite, count: 4);
            //List<WorldBriefResponse> scaryWorlds = await api.WorldApi.Search(keyword: "Scary", sort: SortOptions.Popularity);
            //List<WorldBriefResponse> featuredWorlds = await api.WorldApi.Search(featured: true);
            //WorldMetadataResponse metadata = await api.WorldApi.GetMetadata("wrld_b2d24c29-1ded-4990-a90d-dd6dcc440300");

            /*if (world.instances.Count > 0)
             * {
             *  WorldInstanceResponse worldInst = await api.WorldApi.GetInstance(world.id, world.instances[0].id);
             * }*/
        }
Exemple #2
0
        public async Task <WorldResponse> Get(string id)
        {
            Console.WriteLine($"Getting world info with ID: {id}");

            HttpResponseMessage response = await Global.HttpClient.GetAsync($"worlds/{id}?apiKey={Global.ApiKey}");

            WorldResponse res = null;

            if (response.IsSuccessStatusCode)
            {
                string json = await response.Content.ReadAsStringAsync();

                Console.WriteLine($"JSON received: {json}");
                res = JsonConvert.DeserializeObject <WorldResponse>(json);

                // Parse instances.
                res.instances = res._instances.Select(data => new WorldInstance()
                {
                    id        = (string)data[0],
                    occupants = (int)data[1]
                }).ToList();
            }

            return(res);
        }
Exemple #3
0
        public void Update(CommandFactory commandFactory, Core.Visualization.IVisualizer visualizer)
        {
            var describeWorld = commandFactory.ExecuteCommand <DescribeWorldResponse>(string.Empty);

            if (_worldName != describeWorld.Name)
            {
                _worldResponse = commandFactory.ExecuteCommand <WorldResponse>(describeWorld.Name);
                _homeResponse  = commandFactory.ExecuteCommand <HomeResponse>(string.Empty);
                _graph         = new MapGraph(_worldResponse);
                _cars          = new List <Car>();

                _worldName = describeWorld.Name;
            }

            UpdateCarState(commandFactory);
            foreach (var car in _cars.Where(c => c.CanMove))
            {
                if (!car.Route.Any())
                {
                    car.Route = _graph.FindBestRoute(car) ?? new List <Road>();
                }

                car.MoveToNextCity(commandFactory);
            }

            Thread.Sleep(100);
        }
        static async Task Main(string[] args)
        {
            using (WebClient wc = new WebClient())
            {
                var online_users = wc.DownloadString("https://api.vrchat.cloud/api/1/visits");
                Console.WriteLine("Initializing API... ({0} users online)", online_users);
            }
            api = new VRChatApi.VRChatApi("", "");
            if (args.Length < 1)
            {
                worldId = SearchWorld();
                if (string.IsNullOrWhiteSpace(worldId))
                {
                    throw new Exception("Missing world ID!");
                }
            }
            else
            {
                worldId = args[0];    // wrld_b805006c-bec7-4179-958a-5a9351e48d5c
            }
            Console.WriteLine("Getting world \"{0}\"...", worldId);
            WorldResponse world = await api.WorldApi.Get(worldId);

            Console.WriteLine("Name: {0}", world.name);
            Console.WriteLine("Players: {0} / {1}", world.occupants, world.capacity);
            if (world.occupants < 1)
            {
                await CreateNew("No one seems to be online, sorry!"); return;
            }
            Console.WriteLine("Instances:");
            string instance_pattern = @"^(\d+)~hidden";
            //string instance_pattern_private = instance_pattern + @"\((usr_[\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12})\)~nonce\(([0-9A-Z]{64})\)$";
            string fullest       = "";
            int    fullest_count = 0;

            foreach (var instance in world.instances)
            {
                if (!Regex.Match(instance.id, instance_pattern).Success)
                {
                    Console.WriteLine("{0}: {1}", instance.id, instance.occupants);
                    if (instance.occupants > fullest_count)
                    {
                        fullest = instance.id;
                    }
                    fullest_count = instance.occupants;
                } /* else {
                   * var parsed = Regex.Split(instance.id, instance_pattern_private);
                   * var parsed_id = parsed[1];var parsed_usr_id = parsed[2]; var parsed_nonce = parsed[3];
                   * UserBriefResponse creator = await api.UserApi.GetById(parsed_usr_id);
                   * Console.WriteLine("{0} (private) by {1}: {2}", parsed_id, creator.displayName, instance.occupants);
                   * } */
            }
            if (fullest_count < 1)
            {
                await CreateNew("No public instances found, sorry!"); return;
            }
            await StartGame(worldId, fullest);
        }
Exemple #5
0
 private void FillWorld(WorldResponse world)
 {
     txt_world_id.Text          = world.id;
     txt_world_id.Tag           = world;
     txt_world_name.Text        = world.name;
     txt_world_version.Text     = world.version.ToString();
     txt_world_author.Text      = $"{world.authorName} ({world.authorId})";
     txt_world_asset.Text       = world.assetUrl;
     txt_world_description.Text = world.description;
 }
Exemple #6
0
        public static void Get(int id, Action <World> callback, Action <Exception> error)
        {
            Request <WorldRequest> request = new Request <WorldRequest>(GetMethod, new WorldRequest(id));

            request.Then(json =>
            {
                WorldResponse response = JsonUtility.FromJson <WorldResponse>(json);
                World world            = World.CreateFromDTO(response);
                callback.Invoke(world);
            }).Catch(error.Invoke);
        }
        public MapGraph(WorldResponse worldResponse)
        {
            Cities = worldResponse.VisitingBonuses.Select((vb, i) => new City(i + 1, vb, worldResponse.BaseLocations.Contains(i + 1))).ToList();

            foreach (var road in worldResponse.Roads)
            {
                var fromCity = GetCityById(road.FromCityId);
                var toCity   = GetCityById(road.ToCityId);

                fromCity.Roads.Add(new Road(fromCity, toCity, road.BaseCost));
                toCity.Roads.Add(new Road(toCity, fromCity, road.BaseCost));
            }
        }
Exemple #8
0
 public static World CreateFromDTO(WorldResponse response)
 {
     return(new World()
     {
         Id = response.id,
         Name = response.name,
         CreatedAt = response.created_at,
         Seed = response.seed,
         TotalSystems = response.systems_total,
         MaxPlayers = response.max_players,
         CurrentPlayers = response.current_players
     });
 }
Exemple #9
0
        static async Task Main(string[] args)
        {
            VRChatApi.VRChatApi api = new VRChatApi.VRChatApi("username", "password");
            VRChatApi.Logging.LogProvider.SetCurrentLogProvider(new ColoredConsoleLogProvider());

            // remote config
            ConfigResponse config = await api.RemoteConfig.Get();

            // user api
            //UserResponse userNew = await api.UserApi.Register("someName", "somePassword", "*****@*****.**");
            UserResponse user = await api.UserApi.Login();

            //UserResponse userUpdated = await api.UserApi.UpdateInfo(user.id, null, null, null, new List<string>() { "admin_moderator", "admin_scripting_access", "system_avatar_access", "system_world_access" });

            // friends
            //List<UserBriefResponse> friends = await api.FriendsApi.Get(0, 20, true);
            //NotificationResponse friendRequestResponse = await api.FriendsApi.SendRequest("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685", api.UserApi.Username);
            //string friendDeletionResponse = await api.FriendsApi.DeleteFriend("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685");
            //await api.FriendsApi.AcceptFriend("usr_f8220fc0-e6f9-45ab-8d9f-ae00e8491685");

            // world api
            var           worldId = "wrld_b2d24c29-1ded-4990-a90d-dd6dcc440300"; // The great Pug
            WorldResponse world   = await api.WorldApi.Get(worldId);

            //List<WorldBriefResponse> starWorlds = await api.WorldApi.Search(WorldGroups.Favorite, count: 4);
            List <WorldBriefResponse> scaryWorlds = await api.WorldApi.Search(keyword : "Scary", sort : SortOptions.Popularity);

            List <WorldBriefResponse> featuredWorlds = await api.WorldApi.Search(featured : true);

            WorldMetadataResponse metadata = await api.WorldApi.GetMetadata(worldId);

            var instances = new List <WorldInstanceResponse>();

            if (world.instances.Count > 0)
            {
                foreach (WorldInstance instance in world.instances)
                {
                    WorldInstanceResponse worldInst = await api.WorldApi.GetInstance(world.id, instance.id);

                    instances.Add(worldInst);
                }
            }

            // avatar api
            AvatarResponse avatar = await api.AvatarApi.GetById("avtr_17036f54-f706-46bf-8a43-0c60564123ff");
        }
Exemple #10
0
        public async Task <WorldResponse> Get(string id)
        {
            HttpResponseMessage response = await Global.HttpClient.GetAsync($"worlds/{id}?apiKey={Global.ApiKey}");

            WorldResponse res = null;

            if (response.IsSuccessStatusCode)
            {
                res = await response.Content.ReadAsAsync <WorldResponse>();

                // Parse instances.
                res.instances = res._instances.Select(data => new WorldInstance()
                {
                    id        = (string)data[0],
                    occupants = (int)data[1]
                }).ToList();
            }

            return(res);
        }
Exemple #11
0
        async public void userlists(bool nightmodeset)
        {
            try
            {
                int useNu2 = 0;
                // UserResponse users = await api.UserApi.Login();


                List <UserBriefResponse> friends = await api.FriendsApi.Get(0, 99, false);

                List <UserBriefResponse> dump;


                int i = 99;

                while (i < 500)
                {
                    if (i == friends.Count)
                    {
                        dump = await api.FriendsApi.Get(i, 99, false);

                        friends.AddRange(dump);

                        i += 99;
                    }
                    else
                    {
                        break;
                    }
                }

                List <UserBriefResponse> SortedList = friends.OrderBy(x => x.location).ToList();
                SortedList.Reverse();



                string worddump = "";

                foreach (var friend in SortedList)
                {
                    useNu2++;

                    string a = friend.location;

                    string idcut   = ":";
                    string instcut = "~";

                    string wordid;
                    string wordinst;

                    int    aleg    = a.Length;
                    string instcol = "#000000";
                    string TrustLevel;
                    string Trustcol = "Green";

                    string framecolor = "#FFFFFF";
                    if (nightmodeset == true)

                    {
                        framecolor = "#000000";
                    }

                    List <int> grdpoint = new List <int>();
                    grdpoint.Add(1);


                    foreach (var Trustser in friend.tags)
                    {
                        if (Trustser == "admin_moderator")
                        {
                            grdpoint.Add(8); //영자
                        }
                        else if (Trustser == "system_legend")
                        {
                            grdpoint.Add(7); //검딱
                        }
                        else if (Trustser == "system_trust_legend")
                        {
                            grdpoint.Add(6); //노딱
                        }
                        else if (Trustser == "system_trust_veteran")
                        {
                            grdpoint.Add(5); //보딱
                        }
                        else if (Trustser == "system_trust_trusted")
                        {
                            grdpoint.Add(4); //주딱
                        }
                        else if (Trustser == "system_trust_known")
                        {
                            grdpoint.Add(3); //초딱
                        }
                        else if (Trustser == "system_trust_basic")
                        {
                            grdpoint.Add(2); //파딱
                        }
                        else
                        {
                            grdpoint.Add(1); //흰딱
                        }
                    }


                    int point = grdpoint.Max();


                    if (point == 8)
                    {
                        TrustLevel = "moderator"; //영자
                        Trustcol   = "#FF0000";
                    }
                    else if (point == 7)
                    {
                        TrustLevel = "legend"; //검딱
                        Trustcol   = "#FA5882";
                    }
                    else if (point == 6)
                    {
                        TrustLevel = "veteran"; //노딱
                        Trustcol   = "#FFE400";
                    }
                    else if (point == 5)
                    {
                        TrustLevel = "trusted";//보딱
                        Trustcol   = "#7112FF";
                    }
                    else if (point == 4)
                    {
                        TrustLevel = "known"; //주딱
                        Trustcol   = "#FF5E00";
                    }
                    else if (point == 3)
                    {
                        TrustLevel = "user"; //초딱
                        Trustcol   = "#7DFE74";
                    }
                    else if (point == 2)
                    {
                        TrustLevel = "basic"; //파딱
                        Trustcol   = "#489CFF";
                    }
                    else
                    {
                        TrustLevel = "Visitor";//흰딱
                        Trustcol   = "#E1E1E1";
                    }


                    if ("active" == friend.status)
                    {
                        friend.status = "online";
                        instcol       = "#1DDB16";
                    }
                    else if ("ask me" == friend.status)
                    {
                        instcol = "#FF7012";
                    }
                    else if ("busy" == friend.status)
                    {
                        instcol = "#FF0000";
                    }
                    else if ("join me" == friend.status)
                    {
                        instcol = "#2478FF";
                    }


                    if (1 <= a.IndexOf(idcut))
                    {
                        wordid = a.Substring(0, a.IndexOf(idcut));

                        if (1 <= a.IndexOf("hidden"))
                        {
                            wordinst = ("#" + a.Substring(a.IndexOf(idcut) + 1, (a.IndexOf(instcut) - 1) - a.IndexOf(idcut)) + " friends+");
                        }
                        else if (1 <= a.IndexOf("friends"))
                        {
                            wordinst = ("#" + a.Substring(a.IndexOf(idcut) + 1, (a.IndexOf(instcut) - 1) - a.IndexOf(idcut)) + " friends");
                        }


                        else
                        {
                            wordinst = ("#" + a.Substring(a.IndexOf(idcut) + 1, (a.Length - 1) - a.IndexOf(idcut)) + " public");
                        }
                        WorldResponse wodrs = await api.WorldApi.Get(wordid);



                        if (worddump != friend.location)
                        {
                            worddump = friend.location;

                            userlist.Add(new user
                            {
                                //world


                                notworld = false,
                                map2     = 0,
                                map      = "#C0C0C0",
                                Name     = wodrs.name,
                                mapuri   = wodrs.assetUrl,
                                Location = wordinst,


                                ImageUrl = wodrs.imageUrl,
                                location = friend.location,
                                statu    = wodrs.authorName,
                            });
                        }



                        userlist.Add(new user
                        {
                            notworld = true,
                            map2     = 20,
                            usid     = friend.id,

                            map         = framecolor,
                            Location    = friend.statusDescription,
                            mapinst     = friend.status,
                            Locationimg = wodrs.imageUrl,
                            mapuri      = wodrs.assetUrl,
                            authorName  = wodrs.authorName,
                            Name        = friend.displayName,
                            location    = friend.location,
                            statu       = friend.status,


                            usNa     = friend.username,
                            ImageUrl = friend.currentAvatarImageUrl,
                            ustags   = friend.tags,
                            Trustcol = Trustcol,
                            instcol  = instcol,

                            TrustLevel        = TrustLevel,
                            bio               = friend.bio,
                            statusDescription = friend.statusDescription,
                        });
                    }
                    else
                    {
                        userlist.Add(new user
                        {
                            notworld = true,
                            map2     = 20,
                            usid     = friend.id,
                            Location = friend.location,

                            map  = framecolor,
                            Name = friend.displayName,

                            ImageUrl = friend.currentAvatarImageUrl,
                            statu    = friend.status,
                            mapinst  = friend.status,

                            usNa   = friend.username,
                            ustags = friend.tags,

                            Trustcol = Trustcol,
                            instcol  = instcol,

                            TrustLevel        = TrustLevel,
                            bio               = friend.bio,
                            statusDescription = friend.statusDescription
                        });
                    }
                }



                onlineNum = useNu2;



                listpro.ItemsSource = null;
                BindingContext      = this;
                listpro.ItemsSource = userlist;

                listpro.EndRefresh();
            }

            catch
            {
                var answer = DisplayAlert("login error", "Your session has expired. Please re-login", "ok");
            }
        }