Asteroids & Refactoring
We have proper belts that hug the Grid, reactive properties for planet instance data, and more!
This commit is contained in:
parent
a981a46170
commit
1f90d3639a
42 changed files with 614 additions and 597 deletions
|
|
@ -48,6 +48,7 @@ public class DatabaseListView : EditorWindow
|
|||
private Dictionary<Guid, HashSet<Guid>> _itemBlueprints = new Dictionary<Guid, HashSet<Guid>>();
|
||||
private HashSet<Guid> _itemBlueprintFoldouts = new HashSet<Guid>();
|
||||
private HashSet<string> _itemGroupFoldouts = new HashSet<string>();
|
||||
private DirectoryInfo _filePath;
|
||||
|
||||
public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black;
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ public class DatabaseListView : EditorWindow
|
|||
|
||||
void OnEnable()
|
||||
{
|
||||
_filePath = new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
// Create database cache
|
||||
_databaseCache = new DatabaseCache();
|
||||
|
||||
|
|
@ -169,12 +171,12 @@ public class DatabaseListView : EditorWindow
|
|||
|
||||
if (GUILayout.Button("Save"))
|
||||
{
|
||||
_databaseCache.Save(new DirectoryInfo(Application.dataPath).Parent.FullName);
|
||||
_databaseCache.Save(_filePath.FullName);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Load"))
|
||||
{
|
||||
_databaseCache.Load(new DirectoryInfo(Application.dataPath).Parent.FullName);
|
||||
_databaseCache.Load(_filePath.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ public class GalaxyEditor : Editor
|
|||
}
|
||||
|
||||
GUILayout.Label("Preview", EditorStyles.boldLabel);
|
||||
_galaxyMat.SetFloat("Arms", galaxy.MapData.GlobalData.Arms);
|
||||
_galaxyMat.SetFloat("Twist", galaxy.MapData.GlobalData.Twist);
|
||||
_galaxyMat.SetFloat("TwistPower", galaxy.MapData.GlobalData.TwistPower);
|
||||
_galaxyMat.SetFloat("Arms", galaxy.MapData.ShapeSettings.Arms);
|
||||
_galaxyMat.SetFloat("Twist", galaxy.MapData.ShapeSettings.Twist);
|
||||
_galaxyMat.SetFloat("TwistPower", galaxy.MapData.ShapeSettings.TwistExponent);
|
||||
_galaxyMat.SetFloat("SpokeOffset", _currentLayer.SpokeOffset);
|
||||
_galaxyMat.SetFloat("SpokeScale", _currentLayer.SpokeScale);
|
||||
_galaxyMat.SetFloat("CoreBoost", _currentLayer.CoreBoost);
|
||||
|
|
@ -168,7 +168,7 @@ public class GalaxyEditor : Editor
|
|||
var accum = 0f;
|
||||
foreach (var hp in points.Select(p=>p+Random.insideUnitCircle * ((points[0]-points[1]).magnitude/2)))
|
||||
{
|
||||
var den = galaxy.MapData.StarDensity.Evaluate(hp, galaxy.MapData.GlobalData);
|
||||
var den = galaxy.MapData.StarDensity.Evaluate(hp, galaxy.MapData.ShapeSettings);
|
||||
if(!float.IsNaN(den))
|
||||
accum += saturate(den) * Random.value;
|
||||
// else
|
||||
|
|
@ -292,7 +292,7 @@ public class GalaxyEditor : Editor
|
|||
R.Db("Aetheria").Table("Galaxy").Insert(data).Run(_connection);
|
||||
}
|
||||
|
||||
R.Db("Aetheria").Table("Galaxy").Insert(galaxy.MapData.GlobalData).Run(_connection);
|
||||
R.Db("Aetheria").Table("Galaxy").Insert(galaxy.MapData.ShapeSettings).Run(_connection);
|
||||
}
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MessagePack;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class ZoneEditor : EditorWindow
|
||||
{
|
||||
// Singleton to avoid multiple instances of window.
|
||||
private static ZoneEditor _instance;
|
||||
public static ZoneEditor Instance => _instance ?? GetWindow<ZoneEditor>();
|
||||
[MenuItem("Window/Aetheria/Zone Editor")]
|
||||
static void Init() => Instance.Show();
|
||||
|
||||
private SectorRenderer _sectorRenderer;
|
||||
private DirectoryInfo _filePath;
|
||||
private GameContext _context;
|
||||
private DatabaseCache _cache;
|
||||
private Zone _zone;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_instance = this;
|
||||
_filePath = new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
|
||||
// Create Game Context
|
||||
_cache = new DatabaseCache();
|
||||
_cache.Load(_filePath.FullName);
|
||||
_context = new GameContext(_cache, Debug.Log);
|
||||
|
||||
// Find Sector Renderer and apply context
|
||||
_sectorRenderer = FindObjectOfType<SectorRenderer>();
|
||||
_sectorRenderer.Context = _context;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (GUILayout.Button("Load Zone"))
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
foreach(var file in _filePath.EnumerateFiles("*.zone"))
|
||||
menu.AddItem(new GUIContent(file.Name), false, () => LoadZone(file));
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Clear Zone"))
|
||||
_sectorRenderer.ClearZone();
|
||||
|
||||
if (GUILayout.Button("Save Zone"))
|
||||
SaveZone();
|
||||
|
||||
if (GUILayout.Button("Update Orbits"))
|
||||
{
|
||||
_zone.Update(.01f);
|
||||
//_sectorRenderer.LateUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// Does the rendering of the map editor in the scene view.
|
||||
private void OnSceneGUI(SceneView sceneView) { }
|
||||
|
||||
void OnFocus()
|
||||
{
|
||||
SceneView.onSceneGUIDelegate -= this.OnSceneGUI; // Just in case
|
||||
SceneView.onSceneGUIDelegate += this.OnSceneGUI;
|
||||
}
|
||||
|
||||
private void LoadZone(FileInfo zoneFile)
|
||||
{
|
||||
var zonePack = MessagePackSerializer.Deserialize<ZonePack>(File.ReadAllBytes(zoneFile.FullName));
|
||||
_zone = new Zone(_context, zonePack);
|
||||
_sectorRenderer.LoadZone(_zone);
|
||||
}
|
||||
|
||||
public void SaveZone()
|
||||
{
|
||||
var dir = Path.Combine(_filePath.FullName, $"{_zone.Data.Name}.zone");
|
||||
File.WriteAllBytes(dir,MessagePackSerializer.Serialize(_zone.Pack()));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d675657ad7e1e7246b133b7abadaee2f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue