using System.Collections;
|
using System.Collections.Generic;
|
using Unity.Collections;
|
using Unity.Jobs;
|
using Unity.Mathematics;
|
using UnityEngine;
|
|
public struct OreGnerationJob : IJobParallelFor
|
{
|
[ReadOnly] public int ChunkStartX;
|
[ReadOnly] public int ChunkStartY;
|
[ReadOnly] public int ChunkSize;
|
[ReadOnly] public int Weight;
|
[ReadOnly] public int ClusterWeight;
|
[ReadOnly] public float OffsetX;
|
[ReadOnly] public float OffsetY;
|
[ReadOnly] public int MaxWidth;
|
[ReadOnly] public int MaxDepth;
|
|
public NativeArray<bool> OreMap;
|
|
public void Execute(int index)
|
{
|
int x = ChunkStartX + (index % ChunkSize);
|
int y = ChunkStartY - (index / ChunkSize);
|
|
float xPerlin = ((float)x / MaxWidth) * ClusterWeight + OffsetX;
|
float yPerlin = ((float)Mathf.Abs(y) / MaxDepth) * ClusterWeight + OffsetY;
|
float perlinNoise = noise.snoise(new float2(xPerlin, yPerlin));
|
|
OreMap[index] = perlinNoise <= (1f / (float)Weight);
|
}
|
}
|