private void HandleSprinkleOfElement(WorldGenSettings settings, Tag targetTag, Chunk world, SetValuesFunction SetValues, float temperatureMin, float temperatureRange, SeededRandom rnd) { FeatureSettings feature = settings.GetFeature(targetTag.Name); string element = feature.GetOneWeightedSimHash("SprinkleOfElementChoices", rnd).element; Element element2 = ElementLoader.FindElementByName(element); ProcGen.Room value = null; SettingsCache.rooms.TryGetValue(targetTag.Name, out value); SampleDescriber sampleDescriber = value; Sim.PhysicsData defaultValues = element2.defaultValues; Sim.DiseaseCell invalid = Sim.DiseaseCell.Invalid; for (int i = 0; i < terrainPositions.Count; i++) { if (!(terrainPositions[i].Value != targetTag)) { float radius = rnd.RandomRange(sampleDescriber.blobSize.min, sampleDescriber.blobSize.max); Vector2 center = Grid.CellToPos2D(terrainPositions[i].Key); List <Vector2I> filledCircle = ProcGen.Util.GetFilledCircle(center, radius); for (int j = 0; j < filledCircle.Count; j++) { Vector2I vector2I = filledCircle[j]; int x = vector2I.x; Vector2I vector2I2 = filledCircle[j]; int num = Grid.XYToCell(x, vector2I2.y); if (Grid.IsValidCell(num)) { defaultValues.mass = GetDensityMassForCell(world, num, element2.defaultValues.mass); defaultValues.temperature = temperatureMin + world.heatOffset[num] * temperatureRange; SetValues(num, element2, defaultValues, invalid); } } } } }
private void GenerateActionCells(WorldGenSettings settings, Tag tag, HashSet <Vector2I> possiblePoints, SeededRandom rnd) { ProcGen.Room value = null; SettingsCache.rooms.TryGetValue(tag.Name, out value); SampleDescriber sampleDescriber = value; if (sampleDescriber == null && settings.HasMob(tag.Name)) { sampleDescriber = settings.GetMob(tag.Name); } if (sampleDescriber != null) { HashSet <Vector2I> hashSet = new HashSet <Vector2I>(); float randomValueWithinRange = sampleDescriber.density.GetRandomValueWithinRange(rnd); List <Vector2> list; switch (sampleDescriber.selectMethod) { case SampleDescriber.PointSelectionMethod.RandomPoints: list = PointGenerator.GetRandomPoints(poly, randomValueWithinRange, 0f, null, sampleDescriber.sampleBehaviour, true, rnd, true, true); break; default: list = new List <Vector2>(); list.Add(node.position); break; } foreach (Vector2 item2 in list) { Vector2 current = item2; Vector2I item = new Vector2I((int)current.x, (int)current.y); if (possiblePoints.Contains(item)) { hashSet.Add(item); } } if (value != null && value.mobselection == ProcGen.Room.Selection.None) { if (terrainPositions == null) { terrainPositions = new List <KeyValuePair <int, Tag> >(); } foreach (Vector2I item3 in hashSet) { Vector2I current2 = item3; int num = Grid.XYToCell(current2.x, current2.y); if (Grid.IsValidCell(num)) { terrainPositions.Add(new KeyValuePair <int, Tag>(num, tag)); } } } } }