Skip to content

Instantly share code, notes, and snippets.

@lparkermg
Last active October 18, 2020 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lparkermg/1bfa8f4020e76dab2aaecf6e55429588 to your computer and use it in GitHub Desktop.
Save lparkermg/1bfa8f4020e76dab2aaecf6e55429588 to your computer and use it in GitHub Desktop.
Interface for the building functionality in Project 2.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Helpers
{
/// <summary>
/// Interface to handle building.
/// </summary>
/// <typeparam name="T">Type of object that's being built.</typeparam>
public interface IBuilder<T>
{
/// <summary>
/// Gets the <see cref="Texture2D"/> assigned in the AddTexture function.
/// </summary>
Texture2D Texture { get; }
/// <summary>
/// Assigns the <see cref="Texture2D"/> used in building.
/// </summary>
/// <param name="texture">The <see cref="Texture2D"/> used for building.</param>
/// <returns>The current <see cref="IBuilder{T}"/>.</returns>
IBuilder<T> AddTexture(Texture2D texture);
/// <summary>
/// Adds the types of biomes used when building.
/// </summary>
/// <param name="min">The min range of the biome type.</param>
/// <param name="max">The max range of the biome type.</param>
/// <param name="type">The type of biome.</param>
/// <returns>The current <see cref="IBuilder{T}"/>.</returns>
IBuilder<T> AddBiomeTypeRange(float min, float max, BiomeType type);
/// <summary>
/// Adds the <see cref="IList{Tuple{TileType,float,float}}"/> used for building the world.
/// </summary>
/// <param name="typeRanges">The <see cref="TileType"/> and the ranges it appears at.</param>
/// <returns>The current <see cref="IBuilder{T}"/>.</returns>
IBuilder<T> AddTileTypeRanges(IList<Tuple<TileType, float, float>> typeRanges);
/// <summary>
/// Sets the range of what gets built.
/// </summary>
/// <param name="min">Minimum build range.</param>
/// <param name="max">Maximum build range.</param>
/// <returns>The current <see cref="IBuilder{T}"/>.</returns>
IBuilder<T> AddCutOffRange(float min = 0f, float max = 1f);
/// <summary>
/// Sets any of the builder related options.
/// </summary>
/// <param name="generateStartAndEnd">Determines if the builder should set the start and end tiles.</param>
/// <returns>The current <see cref="IBuilder{T}"/>.</returns>
IBuilder<T> SetBuildOptions(bool generateStartAndEnd);
/// <summary>
/// Builds the <see cref="T"/> with the provided details.
/// </summary>
/// <returns>A populated <see cref="T"/>.</returns>
T Build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment