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

@ -59,11 +59,11 @@ public class InventoryMenu : MonoBehaviour
{
_destroyItem = false;
});
var cargo = GameManager.DockingBay ?? GameManager.CurrentShip.CargoBays.FirstOrDefault();
var cargo = GameManager.DockingBay ?? GameManager.CurrentEntity.CargoBays.FirstOrDefault();
if (cargo!=null)
InventoryPanels[0].Display(cargo);
if(GameManager.CurrentShip != null)
InventoryPanels[1].Display(GameManager.CurrentShip);
if(GameManager.CurrentEntity != null)
InventoryPanels[1].Display(GameManager.CurrentEntity);
else InventoryPanels[1].Clear();
}

View file

@ -103,11 +103,11 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
{
Current.onClick.AddListener(() =>
{
if (_displayedEntity != GameManager.CurrentShip)
if (_displayedEntity != GameManager.CurrentEntity)
{
if(_displayedEntity is Ship ship)
{
GameManager.CurrentShip = ship;
GameManager.CurrentEntity = ship;
GameManager.DockingBay.DockedShip = ship;
Current.targetGraphic.color = ToggleEnabledColor;
}
@ -159,7 +159,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
ship.SetParent(GameManager.DockedEntity);
GameManager.PlayerEntities.Add(ship);
GameManager.Credits -= pack.Price(GameManager.ItemManager);
GameManager.CurrentShip = ship;
GameManager.CurrentEntity = ship;
GameManager.DockingBay.DockedShip = ship;
Display(ship);
}, pack.Price(GameManager.ItemManager) < GameManager.Credits
@ -282,7 +282,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
if (Current)
{
Current.gameObject.SetActive(true);
Current.targetGraphic.color = entity == GameManager.CurrentShip ? ToggleEnabledColor : ToggleDisabledColor;
Current.targetGraphic.color = entity == GameManager.CurrentEntity ? ToggleEnabledColor : ToggleDisabledColor;
}
if (Thermal)
{

View file

@ -47,7 +47,7 @@ public class MenuPanel : MonoBehaviour
{
foreach (var tabButton in _tabs.Values)
{
tabButton.gameObject.SetActive(!tabButton.RequireParent || GameManager.CurrentShip.Parent != null);
tabButton.gameObject.SetActive(!tabButton.RequireParent || GameManager.CurrentEntity.Parent != null);
}
}

View file

@ -242,10 +242,13 @@ public class SchematicDisplay : MonoBehaviour
$"{((int)(_cargoBays.Min(r => r.Temperature) - 273.15f)).ToString()}-" +
$"{((int)(_cargoBays.Max(r => r.Temperature) - 273.15f)).ToString()}°C";
CockpitTemperatureLabel.text = $"{((int)(_cockpit.Item.Temperature - 273.15f)).ToString()}°C";
if(_cockpit != null)
{
CockpitTemperatureLabel.text = $"{((int) (_cockpit.Item.Temperature - 273.15f)).ToString()}°C";
HeatstrokeMeterFill.anchorMax = new Vector2(_entity.Heatstroke, 1);
HeatstrokeLimitFill.anchorMax = new Vector2(_cockpit.Item.Temperature / Settings.GameplaySettings.HeatstrokeTemperature, 1);
HeatstrokeMeterFill.anchorMax = new Vector2(_entity.Heatstroke, 1);
HeatstrokeLimitFill.anchorMax = new Vector2(_cockpit.Item.Temperature / Settings.GameplaySettings.HeatstrokeTemperature, 1);
}
if (_capacitors.Length == 0)
{

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);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5369ea8554e422a45a9f949bdd3bee3f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -448,7 +448,7 @@ public class TradeMenu : MonoBehaviour
_targetCargo = GameManager.DockingBay;
TargetCargoLabel.text = "Docking Bay";
});
foreach (var ship in GameManager.CurrentShip.Parent.Children.Where(GameManager.PlayerEntities.Contains))
foreach (var ship in GameManager.CurrentEntity.Parent.Children.Where(GameManager.PlayerEntities.Contains))
{
foreach (var bay in ship.CargoBays.Select((bay, index) => (bay, index)))
ContextMenu.AddOption($"{ship.Name} Bay {bay.index}",