コード例 #1
0
 public void Update(DBEntity ent, object sender)
 {
     _collection.Update(ent);
     Senders.Add(sender);
     EntityUpdated?.Invoke(this, ent);
     Senders.Clear();
 }
コード例 #2
0
 private void OnEntityUpdated(T entity)
 {
     if (EntityUpdated == null)
     {
         return;
     }
     EntityUpdated.Invoke(this, entity);
 }
コード例 #3
0
        /// <summary>
        ///     Updates the current beatmap by its id. If it's not being tracked, throws an exception.
        /// </summary>
        /// <param name="userId">Id of the beatmap</param>
        /// <param name="token">Cancellation Token to cancel the current requests.</param>
        /// <returns></returns>
        public override async Task <Beatmap> UpdateEntityAsync(long beatmapId, CancellationToken token = default)
        {
            if (!Entities.TryGetValue(beatmapId, out var beatmap))
            {
                throw new InvalidOperationException($"The beatmap with key {beatmapId} is not being tracked yet.");
            }

            var newBeatmap = await _client.GetBeatmapByIdAsync(beatmapId, token).ConfigureAwait(false);

            var equality = beatmap.ApproachRate == newBeatmap.ApproachRate &&
                           beatmap.ApprovedDate == newBeatmap.ApprovedDate &&
                           beatmap.Artist == newBeatmap.Artist &&
                           beatmap.Author == newBeatmap.Author &&
                           beatmap.Bpm == newBeatmap.Bpm &&
                           beatmap.CircleSize == newBeatmap.CircleSize &&
                           beatmap.Difficulty == newBeatmap.Difficulty &&
                           beatmap.StarRating == newBeatmap.StarRating &&
                           beatmap.FailCount == newBeatmap.FailCount &&
                           beatmap.FavoriteCount == newBeatmap.FavoriteCount &&
                           beatmap.GameMode == newBeatmap.GameMode &&
                           beatmap.Genre == newBeatmap.Genre &&
                           beatmap.HitLength == newBeatmap.HitLength &&
                           beatmap.HpDrain == newBeatmap.HpDrain &&
                           beatmap.Language == newBeatmap.Language &&
                           beatmap.MaxCombo == newBeatmap.MaxCombo &&
                           beatmap.OverallDifficulty == newBeatmap.OverallDifficulty &&
                           beatmap.PassCount == newBeatmap.PassCount &&
                           beatmap.PlayCount == newBeatmap.PlayCount &&
                           beatmap.Source == newBeatmap.Source &&
                           beatmap.State == newBeatmap.State &&
                           string.Join("||", beatmap.Tags) == string.Join("||", newBeatmap.Tags) &&
                           beatmap.Title == newBeatmap.Title &&
                           beatmap.TotalLength == newBeatmap.TotalLength;

            _entities[beatmapId] = newBeatmap;

            if (!equality)
            {
                EntityUpdated?.Invoke(new EntityUpdateEventArgs <Beatmap>(_client, beatmap, newBeatmap));
            }

            return(newBeatmap);
        }
コード例 #4
0
ファイル: UserAnalyzer.cs プロジェクト: Z3RYX/OsuSharp
        /// <summary>
        ///     Updates the current user by its id. If it's not being tracked, throws an exception because this method lacks of the GameMode.
        /// </summary>
        /// <param name="userId">Id of the user</param>
        /// <param name="token">Cancellation Token to cancel the current requests.</param>
        /// <returns></returns>
        public override async Task <User> UpdateEntityAsync(long userId, CancellationToken token = default)
        {
            if (!Entities.TryGetValue(userId, out var user))
            {
                throw new InvalidOperationException($"The user with key {userId} is not being tracked yet.");
            }

            var newUser = await _client.GetUserByUserIdAsync(userId, user.GameMode).ConfigureAwait(false);

            var equality = user.UserId == newUser.UserId &&
                           user.Username == newUser.Username &&
                           user.Count50 == newUser.Count50 &&
                           user.Count100 == newUser.Count100 &&
                           user.Count300 == newUser.Count300 &&
                           user.PlayCount == newUser.PlayCount &&
                           user.RankedScore == newUser.RankedScore &&
                           user.Score == newUser.Score &&
                           user.Rank == newUser.Rank &&
                           user.Level == newUser.Level &&
                           user.PerformancePoints == newUser.PerformancePoints &&
                           user.Accuracy == newUser.Accuracy &&
                           user.CountSS == newUser.CountSS &&
                           user.CountSSH == newUser.CountSSH &&
                           user.CountS == newUser.CountS &&
                           user.CountSH == newUser.CountSH &&
                           user.CountA == newUser.CountA &&
                           user.CountryRank == newUser.CountryRank &&
                           user.GameMode == newUser.GameMode;

            _entities[userId] = newUser;

            if (!equality)
            {
                EntityUpdated?.Invoke(new EntityUpdateEventArgs <User>(_client, user, newUser));
            }

            return(newUser);
        }
コード例 #5
0
        private void ReceivedEntityStatePDU(EntityStatePDU entityState)
        {
            if (IsOwnEntity(entityState))
            {
                return;
            }

            DISReflectedEntity reflectedEntity;

            if (!_reflectedEntities.TryGetValue(entityState.EntityId, out reflectedEntity))
            {
                reflectedEntity = new DISReflectedEntity();
                _reflectedEntities[entityState.EntityId] = reflectedEntity;

                reflectedEntity.UpdateState(entityState);
                DISEntityJoined?.Invoke(reflectedEntity);
            }
            else
            {
                reflectedEntity.UpdateState(entityState);
                EntityUpdated?.Invoke(reflectedEntity);
            }
        }
コード例 #6
0
 internal void OnEntityUpdated(object sender, T entity)
 {
     EntityUpdated?.Invoke(sender, new EntityChangedEventArgs <T>(entity));
 }
コード例 #7
0
 private void OnEntityUpdated()
 {
     EntityUpdated?.Invoke();
 }
コード例 #8
0
ファイル: EntityTracker.cs プロジェクト: SoliaRdi/TeraCompass
 private void OnEntityUpdated(IEntity entity)
 {
     EntityUpdated?.Invoke(entity);
 }