Skip to content
Snippets Groups Projects
Commit ab661c18 authored by Ryan Chang's avatar Ryan Chang
Browse files

Start of biome data

parent 28e261b0
Branches legacy
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Contains the actual data that will be used to dictate the biome.
/// </summary>
public class BiomeData
{
[Tooltip("What is used to generate the terrain shape.")]
public List<Octave> shapeMap;
}
\ No newline at end of file
fileFormatVersion: 2
guid: 00d51d27fe26184a0a4b7861cb5bec85
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -7,8 +7,17 @@ using NaughtyAttributes;
public class BiomeMaster : MonoBehaviour
{
#region Variables
[Header("Biome Parameters")]
[InfoBox("Contains the parameters required for each biome.")]
public List<BiomeParameter> parameters;
[Header("Biome Data")]
[InfoBox("Contains the actual biomes. Each biome targets one or more biome " +
"parameters. Every point on the terrain will be assigned differing " +
"proportions of each biome, depending on how close the calculated " +
"parameters are to the target parameter of that biome.")]
public List<BiomeData> datas;
#region Debug
[Header("Debug")]
public int debugSize = 500;
......@@ -38,7 +47,7 @@ public class BiomeMaster : MonoBehaviour
}
}
[Button("Reseed Octaves")]
[Button("Reseed Parameters")]
private void ReseedParameters()
{
foreach (var param in parameters)
......
......@@ -31,24 +31,9 @@ public class BiomeParameter
/// </summary>
public void ReseedOctaves()
{
map = ReseedOctave(map);
shapeMap = ReseedOctave(shapeMap);
map = map.ReseedOctave();
shapeMap = shapeMap.ReseedOctave();
}
private List<Octave> ReseedOctave(List<Octave> octaves)
{
List<Octave> output = new(octaves.Count);
foreach (var o in octaves)
{
Octave newOctave = new(o, RandomOffset());
output.Add(newOctave);
}
return output;
}
private Vector2 RandomOffset() => RNG.GetRandomVector2(MAX_OCTAVE_OFFSET);
}
[Serializable]
......
......@@ -70,4 +70,24 @@ public struct Octave
type = copy.type;
this.offset = offset;
}
}
public static class OctaveExtensions
{
private static float MAX_OCTAVE_OFFSET = 256;
public static List<Octave> ReseedOctave(this List<Octave> octaves)
{
List<Octave> output = new(octaves.Count);
foreach (var o in octaves)
{
Octave newOctave = new(o, RandomOffset());
output.Add(newOctave);
}
return output;
}
private static Vector2 RandomOffset() => RNG.GetRandomVector2(MAX_OCTAVE_OFFSET);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment