Sector Generation

Fixed Laser cancelling bug
Fixed Turrets not activating
Added ability to bind player perspective to orbital entities
Added Markov Chain name generator + Australian place name dataset
Modified old "galaxy" shader to serve as sector background
Implemented Cem Yuksel's Weighted Sample Elimination for Poisson Disk Sample Sets
Created sector generator which places sectors using WSE
This commit is contained in:
Reinier Vens 2021-03-10 09:18:07 +00:00
commit 3f9af29843
108 changed files with 139298 additions and 13543 deletions

View file

@ -0,0 +1,58 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
using Random = UnityEngine.Random;
public class SectorMap : MonoBehaviour
{
public MeshRenderer SectorRenderer;
public SectorGenerationSettings Settings;
public Prototype ZonePrototype;
[Header("Name Generation")]
public TextAsset NameFile;
public int NameFileMinWordLength = 4;
public int NameGeneratorMinLength = 5;
public int NameGeneratorMaxLength = 10;
public int NameGeneratorOrder = 4;
// Start is called before the first frame update
void Start()
{
var names = new HashSet<string>();
var lines = NameFile.text.Split('\n');
foreach (var line in lines)
{
foreach(var word in line.ToUpperInvariant().Split(' ', ',', '.', '"'))
if (word.Length >= NameGeneratorMinLength && !names.Contains(word))
names.Add(word);
}
var random = new Unity.Mathematics.Random(1337);
for (int i = 0; i < 4096; i++) random.NextFloat();
var nameGenerator = new MarkovNameGenerator(ref random, names, NameGeneratorOrder, NameGeneratorMinLength, NameGeneratorMaxLength);
Settings.NoisePosition = Random.value * 100;
var sector = SectorGenerator.GenerateSector(ref random, Settings, nameGenerator);
foreach (var zone in sector.Zones)
{
var zoneInstance = ZonePrototype.Instantiate<Transform>();
zoneInstance.position = new Vector3(zone.Position.x - .5f, zone.Position.y - .5f);
}
}
// Update is called once per frame
void Update()
{
SectorRenderer.material.SetFloat("CloudAmplitude", Settings.CloudAmplitude);
SectorRenderer.material.SetFloat("CloudExponent", Settings.CloudExponent);
SectorRenderer.material.SetFloat("NoisePosition", Settings.NoisePosition);
SectorRenderer.material.SetFloat("NoiseAmplitude", Settings.NoiseAmplitude);
SectorRenderer.material.SetFloat("NoiseOffset", Settings.NoiseOffset);
SectorRenderer.material.SetFloat("NoiseGain", Settings.NoiseGain);
SectorRenderer.material.SetFloat("NoiseLacunarity", Settings.NoiseLacunarity);
SectorRenderer.material.SetFloat("NoiseFrequency", Settings.NoiseFrequency);
}
}