Skip to content
Snippets Groups Projects
BiomeParameter.cs 984 B
Newer Older
using System.Collections;
using System;
Ryan Chang's avatar
Ryan Chang committed
using System.Linq;
using UnityEngine;
using System.Collections.Generic;

Ryan Chang's avatar
Ryan Chang committed
/// <summary>
/// Parameter used to control the generation of the biome.
/// </summary>
[Serializable]
Ryan Chang's avatar
Ryan Chang committed
public class BiomeParameter
Ryan Chang's avatar
Ryan Chang committed
    #region Variables
    [Header("User settings")]
    [Tooltip("Name of biome parameter, like temperature.")]
	public string name;
Ryan Chang's avatar
Ryan Chang committed

    [Tooltip("What is used to generate the biome.")]
    public List<Octave> map;
Ryan Chang's avatar
Ryan Chang committed

    [Tooltip("Color to use for debugging.")]
    public Color debugColor;
Ryan Chang's avatar
Ryan Chang committed
    #endregion
Ryan Chang's avatar
Ryan Chang committed

    public void DrawDebug(float x, float y)
    {
        Vector3 start = new(x, 0, y);
        Vector3 end = start + map.Sum(o => o.Calculate(new(x, y))) * Vector3.up;
        Debug.DrawLine(start, end, debugColor, 10);
    }

    /// <summary>
    /// Reseeds the map and shapeMap octaves by randomizing their
    /// offsets.
    /// </summary>
    public void ReseedOctaves()
    {
Ryan Chang's avatar
Ryan Chang committed
        map = map.ReseedOctaves();
Ryan Chang's avatar
Ryan Chang committed
    }