static VehicleCache()
        {
            Console.WriteLine("Vehicle cache loading...");
            // get all vehicles' info and save them to dictionary
            string     allVehiclesRequest = $@"https://census.daybreakgames.com/s:{PS2APIConstants.ServiceId}/get/ps2/vehicle/?c:limit=100&c:show=vehicle_id,type_id,name";
            JsonObject json     = PS2APIUtils.RestAPIRequest(allVehiclesRequest).GetAwaiter().GetResult();
            var        vehicles = json?["vehicle_list"] as JsonArray;

            if (vehicles == null)
            {
                return;
            }
            for (int i = 0; i < vehicles.Length; i++)
            {
                JsonString vehicleId = vehicles[i]?["vehicle_id"] as JsonString;
                JsonString name      = vehicles[i]?["name"]?["en"] as JsonString;
                JsonString typeId    = vehicles[i]?["type_id"] as JsonString;
                if (vehicleId == null || name == null)
                {
                    continue;
                }
                VehicleIdToName.Add(vehicleId, new VehicleRecord()
                {
                    Name = name?.InnerString, Id = vehicleId, Type = typeId
                });
            }
            Console.WriteLine("Vehicle cache loaded!");
        }
Esempio n. 2
0
        static LoadoutCache()
        {
            Console.WriteLine("Loadout cache loading...");
            // get all loadout names and save it to dictionary
            string     allLoadoutsRequest = $@"http://census.daybreakgames.com/s:{PS2APIConstants.ServiceId}/get/ps2/loadout/?c:limit=100&c:show=loadout_id,profile_id&c:join=profile^on:profile_id^show:name^inject_at:profile";
            JsonObject json     = PS2APIUtils.RestAPIRequest(allLoadoutsRequest).GetAwaiter().GetResult();
            var        loadouts = json?["loadout_list"] as JsonArray;

            if (loadouts == null)
            {
                return;
            }
            for (int i = 0; i < loadouts.Length; i++)
            {
                JsonString loadoutId = loadouts[i]?["loadout_id"] as JsonString;
                JsonString name      = loadouts[i]?["profile"]?["name"]?["en"] as JsonString;
                if (loadoutId == null || name == null)
                {
                    continue;
                }
                LoadoutIdToName.Add(loadoutId, name);
            }
            Console.WriteLine("Loadout cache loaded!");
        }
Esempio n. 3
0
        static WeaponsCache()
        {
            Console.WriteLine("Weapons cache loading...");
            // get all weapons' names and save them to dictionary
            string     allWeaponsRequest = @"https://census.daybreakgames.com/s:georgik/get/ps2/item_to_weapon/?c:limit=2000&c:join=item^show:name^inject_at:item";
            JsonObject json    = PS2APIUtils.RestAPIRequest(allWeaponsRequest).GetAwaiter().GetResult();
            var        weapons = json?["item_to_weapon_list"] as JsonArray;

            if (weapons == null)
            {
                return;
            }
            for (int i = 0; i < weapons.Length; i++)
            {
                JsonString itemId = weapons[i]?["item_id"] as JsonString;
                JsonString name   = weapons[i]?["item"]?["name"]?["en"] as JsonString;
                if (itemId == null || name == null)
                {
                    continue;
                }
                ItemIdToWeaponName.Add(itemId, name);
            }
            Console.WriteLine("Weapons cache loaded!");
        }