public override List <GameObject> Process(List <GameObject> input) { if (null == input || 0 == input.Count) { return(input); } var offset = new UniformRandomNumberGenerator(Randomizer.GenerateSeed()).Range(-1000, 1000); var model = NoiseUtility.Generate(width, height, zoom, lacunarity, persistence, seaLevel, mountainHeight, mountainPeakHeight, offset); var heightMap = model.heightMap; for (var w = 0; w < width; ++w) { for (var h = 0; h < height; ++h) { heightMap[w, h] = Mathf.Floor(heightMap[w, h] * this.elevation); } } var result = new List <GameObject> (); for (var w = 0; w < width; ++w) { for (var h = 0; h < height; ++h) { if (0 == input.Count) { break; } var go = input[0]; input.RemoveAt(0); go.name = "world_block_" + w + "_" + h; var mr = go.GetComponent <MeshRenderer> (); var extends = mr.bounds.size; go.transform.position = new Vector3(w * extends.x, heightMap[w, h], h * extends.z); var material = new Material(Shader.Find("Standard")); material.color = model.texture.GetPixel(w, h); mr.sharedMaterial = material; result.Add(go); } } return(result); }
protected override async Task ExecuteActionAsync(FabricTestContext testContext, GetClusterStateSnapshotAction action, CancellationToken cancellationToken) { Dictionary <string, int> ExceptionHistory = new Dictionary <string, int>(); int retries = 0; GetClusterStateSnapshotAction.ServiceCount = 0; GetClusterStateSnapshotAction.PartitionCount = 0; GetClusterStateSnapshotAction.ReplicaCount = 0; Stopwatch stopWatch = Stopwatch.StartNew(); ClusterStateSnapshot clusterSnapshot = null; do { ++retries; await Task.Delay(Constants.DefaultChaosSnapshotRecaptureBackoffInterval, cancellationToken).ConfigureAwait(false); try { clusterSnapshot = await this.CaptureClusterStateSnapshotAndPopulateEntitiesAsync( testContext, action, cancellationToken).ConfigureAwait(false); } catch (Exception exception) when(exception is FabricException || exception is ChaosInconsistentClusterSnapshotException) { string exceptionString = exception.Message; if (ExceptionHistory.ContainsKey(exceptionString)) { ExceptionHistory[exceptionString]++; } else { ExceptionHistory[exceptionString] = 1; } } string allExceptions = string.Join(ExceptionDelimeter, ExceptionHistory); if (retries >= action.MaximumNumberOfRetries) { TestabilityTrace.TraceSource.WriteWarning(TraceType, "While taking a consistent cluster snapshot, following exceptions occurred: {0}", allExceptions); } ChaosUtility.ThrowOrAssertIfTrue( ChaosConstants.GetClusterSnapshotAction_MaximumNumberOfRetriesAchieved_TelemetryId, retries >= action.MaximumNumberOfRetries, string.Format(StringResources.ChaosEngineError_GetClusterSnapshotAction_MaximumNumberOfRetriesAchieved, action.MaximumNumberOfRetries, allExceptions)); }while (clusterSnapshot == null); stopWatch.Stop(); var elapsedInGatherSnapshot = stopWatch.Elapsed; stopWatch = Stopwatch.StartNew(); clusterSnapshot.ApplyChaosTargetFilter(action.ChaosTargetFilter); clusterSnapshot.MarkAllUnsafeEntities(); stopWatch.Stop(); var elapsedInMarkAllUnsafe = stopWatch.Elapsed; if (UniformRandomNumberGenerator.NextDouble() < action.TelemetrySamplingProbability) { FabricEvents.Events.ChaosSnapshot( Guid.NewGuid().ToString(), clusterSnapshot.Nodes.Count, clusterSnapshot.Applications.Count, GetClusterStateSnapshotAction.ServiceCount, GetClusterStateSnapshotAction.PartitionCount, GetClusterStateSnapshotAction.ReplicaCount, elapsedInGatherSnapshot.TotalSeconds, elapsedInMarkAllUnsafe.TotalSeconds, retries); } TestabilityTrace.TraceSource.WriteInfo(TraceType, "For '{0}' nodes, '{1}' apps, '{2}' services, '{3}' partitions, '{4}' replicas, snapshot took '{5}', mark unsafe took '{6}', took '{7}' retries.", clusterSnapshot.Nodes.Count, clusterSnapshot.Applications.Count, GetClusterStateSnapshotAction.ServiceCount, GetClusterStateSnapshotAction.PartitionCount, GetClusterStateSnapshotAction.ReplicaCount, elapsedInGatherSnapshot, elapsedInMarkAllUnsafe, retries); action.Result = clusterSnapshot; ResultTraceString = "GetClusterStateSnapshotAction succeeded"; }