private static void GenerateBackgroundStructure(HexList4D <HexBackgroundComponent> background, int radius, BackroundTypes type, BackroundTypes badType, int count, float chance, float diffChance) { for (int i = 0; i < count; i++) { GenerateRecursiveB(background, type, badType, HexMath.RandomPosition(radius), chance, diffChance); } }
private static void GenerateRecursiveB(HexList4D <HexBackgroundComponent> background, BackroundTypes type, BackroundTypes badType, CubeCoords coords, float chance, float diffChange) { background.Add(coords, new HexBackgroundComponent() { BackgroundType = type, IsNew = false }); FastList <CubeCoords> neighbours = background.NeighboursOf(coords); for (int j = 0; j < neighbours.Count; j++) { HexBackgroundComponent hexComponent = background[neighbours[j].x, neighbours[j].y]; if (hexComponent.BackgroundType == badType && Random.Range(0f, 1f) < chance) { GenerateRecursiveB(background, type, badType, neighbours[j], chance - diffChange, diffChange); } } }