forked from Necrobot-Private/PokemonGo.RocketAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.cs
91 lines (72 loc) · 3.39 KB
/
Map.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#region using directives
using System;
using System.Threading.Tasks;
using Google.Protobuf;
using PokemonGo.RocketAPI.Helpers;
using POGOProtos.Networking.Requests;
using POGOProtos.Networking.Requests.Messages;
using POGOProtos.Networking.Responses;
#endregion
namespace PokemonGo.RocketAPI.Rpc
{
public class Map : BaseRpc
{
public Map(Client client) : base(client)
{
}
public async
Task
<
Tuple
<GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse,
DownloadSettingsResponse, GetBuddyWalkedResponse>> GetMapObjects()
{
#region Messages
var getMapObjectsMessage = new GetMapObjectsMessage
{
CellId = {S2Helper.GetNearbyCellIds(Client.CurrentLongitude, Client.CurrentLatitude)},
SinceTimestampMs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
Latitude = Client.CurrentLatitude,
Longitude = Client.CurrentLongitude
};
var getHatchedEggsMessage = new GetHatchedEggsMessage();
var getInventoryMessage = new GetInventoryMessage
{
LastTimestampMs = Client.InventoryLastUpdateTimestamp
};
var checkAwardedBadgesMessage = new CheckAwardedBadgesMessage();
var downloadSettingsMessage = new DownloadSettingsMessage
{
Hash = Client.SettingsHash
};
#endregion
var getMapObjectsRequest = new Request
{
RequestType = RequestType.GetMapObjects,
RequestMessage = getMapObjectsMessage.ToByteString()
};
var request = GetRequestBuilder().GetRequestEnvelope(CommonRequest.FillRequest(getMapObjectsRequest, Client));
Tuple<GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse> response =
await
PostProtoPayload
<Request, GetMapObjectsResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetInventoryResponse,
CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse>(request);
GetInventoryResponse getInventoryResponse = response.Item4;
CommonRequest.ProcessGetInventoryResponse(Client, getInventoryResponse);
DownloadSettingsResponse downloadSettingsResponse = response.Item6;
CommonRequest.ProcessDownloadSettingsResponse(Client, downloadSettingsResponse);
CheckChallengeResponse checkChallengeResponse = response.Item2;
CommonRequest.ProcessCheckChallengeResponse(Client, checkChallengeResponse);
return response;
}
public async Task<GetIncensePokemonResponse> GetIncensePokemons()
{
var message = new GetIncensePokemonMessage
{
PlayerLatitude = Client.CurrentLatitude,
PlayerLongitude = Client.CurrentLongitude
};
return await PostProtoPayload<Request, GetIncensePokemonResponse>(RequestType.GetIncensePokemon, message);
}
}
}