protected AbstractPipelineStage(AbstractPipelineEngine engine, T entity, IRule rule)
 {
     UniqueId = _nextFreeId++;
     Entity   = entity;
     State    = PipelineStates.Prepearing;
     Engine   = engine;
     Producer = rule;
     engine.AddCreatedStage(this);
 }
        /// <summary> Этот метод дёргать когда надо закончить стадию.  </summary>
        protected void FinishStage(params IGameStateEntity[] entity)
        {
            if (State == PipelineStates.Execution)
            {
                if (LogStages && Log != null)
                {
                    _logWatch.Stop();
                    var time = _logWatch.ElapsedMilliseconds;

                    if (!Engine.CountLog.ContainsKey(ToLogName()))
                    {
                        Engine.CountLog[ToLogName()] = 0;
                    }
                    Engine.CountLog[ToLogName()]++;

                    if (!Engine.TimeLog.ContainsKey(ToLogName()))
                    {
                        Engine.TimeLog[ToLogName()] = 0;
                    }
                    Engine.TimeLog[ToLogName()] += _logWatch.ElapsedTicks;

                    if (time > 0)
                    {
                        Log($"Finish Stage: {ToShortString()} whatch: {_logWatch.ElapsedMilliseconds} ms ({_logWatch.ElapsedTicks} ticks)");
                    }
                    _logWatch = null;
                }
                State = PipelineStates.Complete;
                CompleteEvent?.Invoke(this, entity);
                Engine = null;
            }
            else
            {
                Debug.LogError(ToShortString() + ".FinishStage() // Невыполнимо в данном состоянии.");
            }
        }
 public LambdaPipelineStage(AbstractPipelineEngine engine, Func <T, T> lambda, T entity,
                            IRule rule, string alias) : base(engine, entity, rule)
 {
     Lambda = lambda;
     Alias  = alias;
 }