Exemplo n.º 1
0
        internal void Update(long dt)
        {
            if (!Alive)
            {
                return;
            }
            Age         += dt;
            this.Energy -= EnergyWast;
            this.Stimulate(this.TimeUpdateStimulus, Age);
            foreach (var cell in World[X, Y])
            {
                if (cell == this)
                {
                    continue;
                }
                var amount = cell is SubstanceCell ? (cell as SubstanceCell).Amount : 0;
                var target = cell is Life ? (cell as Life) : null;
                this.Stimulate(this.EnvironmentStimulus, cell, amount, target);
            }
            var count = this.PendingStimulus.Count;

            for (var i = 0; i < count; i++)
            {
                if (!Alive)
                {
                    return;
                }
                var pending = PendingStimulus.Dequeue();
                pending.Stimulus.Handle(pending.Args);
            }
        }
Exemplo n.º 2
0
 internal void Update(long dt)
 {
     if (!Alive)
     {
         return;
     }
     Age += dt;
     while (this.PendingStimulus.Count > 0)
     {
         if (!Alive)
         {
             return;
         }
         var pending = PendingStimulus.Dequeue();
         pending.Stimulus.Handle(pending.Args);
     }
 }