예제 #1
0
        private void LogDamagePlayerEvent(IActor actor, IActor targetActor, ITacticalAct tacticalAct)
        {
            // Сервис логирование - необязательная зависимость.
            // Если он не задан, то не выполняем логирование.
            if (PlayerEventLogService is null)
            {
                return;
            }

            // Логируем только урон по персонажу игрока.
            if (targetActor.Person != PlayerEventLogService.Player.MainPerson)
            {
                return;
            }

            var damageEvent = new PlayerDamagedEvent(tacticalAct, actor);

            PlayerEventLogService.Log(damageEvent);
        }
예제 #2
0
        private async Task StartInternalAsync(IGlobe globe, IAutoplayContext context)
        {
            var iterationCounter = 1;

            while (await context.CheckNextIterationAsync() && iterationCounter <= ITERATION_LIMIT)
            {
                for (var updateCounter = 0; updateCounter < GlobeMetrics.OneIterationLength; updateCounter++)
                {
                    try
                    {
                        await globe.UpdateAsync(CancellationToken.None).ConfigureAwait(false);
                    }
                    catch (ActorTaskExecutionException exception)
                    {
                        CatchActorTaskExecutionException(exception);
                    }
                    catch (AggregateException exception)
                    {
                        CatchException(exception.InnerException);
                        throw;
                    }
                }

                iterationCounter++;
            }

            if (iterationCounter >= ITERATION_LIMIT)
            {
                if (PlayerEventLogService != null)
                {
                    var endOfLifeEvent = new EndOfLifeEvent();
                    PlayerEventLogService.Log(endOfLifeEvent);
                }
            }

            ProcessEnd();
        }