Exemplo n.º 1
0
        public void Execute()
        {
            lock (lockObj)
            {
                if (entityIds == null)
                {
                    return;
                }

                if (entityIds.Count == 0)
                {
                    return;
                }

                log.Info("Обработка новых игроков " + entityIds.Count);
                var currentEntityIds = new Dictionary <int, ushort>(entityIds);
                foreach (var pair in currentEntityIds)
                {
                    int    accountId = pair.Key;
                    ushort entityId  = pair.Value;
                    // log.Debug($"accountId={accountId} entityId={entityId}");
                    ServerGameEntity entity = gameContext.GetEntityWithId(entityId);

                    //todo обновление id сущности игрока
                    int currentPlayerAccountId = PlayerIdStorage.AccountId;
                    if (accountId == currentPlayerAccountId)
                    {
                        log.Info($"Установка PlayerEntityId={entityId} accountId={accountId}");
                        PlayerIdStorage.PlayerEntityId = entityId;
                    }

                    if (entity != null)
                    {
                        entity.ReplaceNickname(playerInfos[accountId].Nickname);
                        entityIds.Remove(accountId);
                    }
                    else
                    {
                        log.Debug($"Нет сущности с таким id entityId = {entityId}");
                    }
                }
            }
        }