Beispiel #1
0
        public Character(Account account, long characterID, string name)
        {
            Account = account;
            ID = characterID;
            Name = name;

            Standings = new CharacterNPCStandings();

            m_charSheetRequest = new CharacterApiRequest<CharacterSheet>(characterID, Account.KeyID, Account.VCode);
            m_charSheetRequest.OnRequestUpdate += ApiRequestUpdate;

            m_charInfoRequest = new CharacterApiRequest<CharacterInfo>(characterID, Account.KeyID, Account.VCode);
            m_charInfoRequest.OnRequestUpdate += ApiRequestUpdate;

            m_skillQueueRequest = new CharacterApiRequest<SkillQueue>(characterID, Account.KeyID, Account.VCode);
            m_skillQueueRequest.OnRequestUpdate += ApiRequestUpdate;

            m_AssetListRequest = new CharacterApiRequest<AssetList>(characterID, Account.KeyID, Account.VCode);
            m_AssetListRequest.OnRequestUpdate += ApiRequestUpdate;

            m_StandingsRequest = new CharacterApiRequest<CharacterStandings>(characterID, Account.KeyID, Account.VCode);
            m_StandingsRequest.OnRequestUpdate += ApiRequestUpdate;

            API.EveApi.AddRequest(m_charInfoRequest);
            API.EveApi.AddRequest(m_charSheetRequest);
            API.EveApi.AddRequest(m_skillQueueRequest);
            API.EveApi.AddRequest(m_AssetListRequest);
            API.EveApi.AddRequest(m_StandingsRequest);
        }
Beispiel #2
0
        void ApiRequestUpdate(IApiRequest request)
        {
            if (request.LastResult != null && request.LastResult.Error == null)
            {
                if (request == m_charSheetRequest)
                {
                    ApiResult<CharacterSheet> charSheet = request.LastResult as ApiResult<CharacterSheet>;
                    UpdateCharacter(charSheet.Result);
                }
                else if (request == m_charInfoRequest)
                {
                    ApiResult<CharacterInfo> charInfo = request.LastResult as ApiResult<CharacterInfo>;
                    UpdateCharacter(charInfo.Result);
                }
                else if (request == m_skillQueueRequest)
                {
                    ApiResult<SkillQueue> queue = request.LastResult as ApiResult<SkillQueue>;
                    SkillQueue = queue.Result;
                }
                else if (request == m_AssetListRequest)
                {
                    ApiResult<AssetList> assets = request.LastResult as ApiResult<AssetList>;

                    // Create asset dictionary keyed on locationID
                    Dictionary<long, List<AssetListInfo>> newAssets = new Dictionary<long, List<AssetListInfo>>();

                    foreach (API.EVE.AssetListInfo info in assets.Result.Assets)
                    {
                        if (!newAssets.ContainsKey(info.LocationID))
                            newAssets.Add(info.LocationID, new List<AssetListInfo>());

                        newAssets[info.LocationID].Add(info);
                    }

                    //TODO: Better - as calling the dictionary itself doesn't trigger a save
                    Assets = newAssets;
                }
                else if (request == m_StandingsRequest)
                {
                    ApiResult<CharacterStandings> standingsResult = request.LastResult as ApiResult<CharacterStandings>;
                    Standings = standingsResult.Result.NPCStandings;
                }

                if (!IsUpdating && CharacterUpdated != null)
                {
                    CharacterUpdated(this, null);
                }
            }
        }