private void AddEvolution(DecodedTaf decodedTaf, Evolution evolution, Dictionary <string, object> result, string entityName) { // clone the evolution entity var newEvolution = evolution.Clone() as Evolution; // add the new entity to it newEvolution.Entity = result[entityName]; if (entityName == VisibilityChunkDecoder.VisibilityParameterName && _withCavok) { newEvolution.Cavok = true; } // get the original entity from the decoded taf or a new one decoded taf doesn't contain it yet var decodedEntity = typeof(DecodedTaf).GetProperty(entityName).GetValue(decodedTaf) as AbstractEntity; if (decodedEntity == null || entityName == CloudChunkDecoder.CloudsParameterName || entityName == WeatherChunkDecoder.WeatherPhenomenonParameterName) { // that entity is not in the decoded_taf yet, or it's a cloud layer which is a special case decodedEntity = InstantiateEntity(entityName); } // add the new evolution to that entity decodedEntity.Evolutions.Add(newEvolution); // update the decoded taf's entity or add the new one to it switch (entityName) { case CloudChunkDecoder.CloudsParameterName: decodedTaf.Clouds.Add(decodedEntity as CloudLayer); break; case WeatherChunkDecoder.WeatherPhenomenonParameterName: decodedTaf.WeatherPhenomenons.Add(decodedEntity as WeatherPhenomenon); break; case VisibilityChunkDecoder.VisibilityParameterName: decodedTaf.Visibility = decodedEntity as Visibility; break; case SurfaceWindChunkDecoder.SurfaceWindParameterName: decodedTaf.SurfaceWind = decodedEntity as SurfaceWind; break; case TemperatureChunkDecoder.MaximumTemperatureParameterName: decodedTaf.MaximumTemperature = decodedEntity as Temperature; break; case TemperatureChunkDecoder.MinimumTemperatureParameterName: decodedTaf.MinimumTemperature = decodedEntity as Temperature; break; default: throw new TafChunkDecoderException(TafChunkDecoderException.Messages.UnknownEntity + decodedEntity.ToString()); } }
void work() { //evolution = new Evolution(new Random(), new StencilSpeciesArrCreator(new Random(), 10, 10, new double[] { 0.25, 0.25, 0.25, 0.25 }), 7, 25) { }; //evolution = new Evolution(new Random(), new StencilSpeciesArrCreator(new Random(), 50, 50, new double[] { 0.25, 0.25, 0.25, 0.25 }), 1, 5) { }; evolution = new Evolution(new Random(), new StencilSpeciesArrCreator(new Random(), 10, 10, 4), 7, 25) { }; evolutionForView = (Evolution)evolution.Clone(); while (running) { evolution.Feed(42); evolutionForView = (Evolution)evolution.Clone(); //Thread.Sleep(1000); if (leapNow) { evolution.Leap(); leapNow = false; } } }