Asteroid Belts
Sector renderer is now also rendering asteroid belts. All gravity calculations have been moved out of monobehaviors.
This commit is contained in:
parent
d12d7c5c45
commit
a981a46170
76 changed files with 25027 additions and 2016 deletions
|
|
@ -17,8 +17,9 @@ public class DatabaseInspector : EditorWindow
|
|||
public static DatabaseCache DatabaseCache;
|
||||
public DatabaseEntry entry;
|
||||
|
||||
// Singleton to avoid multiple instances of window.
|
||||
// Singleton to avoid multiple instances of window.
|
||||
private static DatabaseInspector _instance;
|
||||
public static DatabaseInspector Instance => _instance ?? GetWindow<DatabaseInspector>();
|
||||
|
||||
private DatabaseListView _list;
|
||||
private GUIStyle _labelStyle;
|
||||
|
|
@ -36,32 +37,12 @@ public class DatabaseInspector : EditorWindow
|
|||
|
||||
public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black;
|
||||
|
||||
// Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...).
|
||||
public DatabaseInspector()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
public static DatabaseInspector ShowWindow()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
// "Get existing open window or if none, make a new one:" says documentation.
|
||||
// But if called after script reloads a second instance will be opened! => Custom singleton required.
|
||||
DatabaseInspector window = GetWindow<DatabaseInspector>();
|
||||
window.titleContent = new GUIContent("DB Inspector");
|
||||
_instance = window;
|
||||
window.Show();
|
||||
}
|
||||
else
|
||||
_instance.Focus();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_list = DatabaseListView.ShowWindow();
|
||||
_instance = this;
|
||||
_list = DatabaseListView.Instance;
|
||||
_list.Show();
|
||||
DatabaseCache.OnDataUpdateLocal += _ => Repaint();
|
||||
DatabaseCache.OnDataUpdateRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
wantsMouseMove = true;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,14 @@ public class DatabaseListView : EditorWindow
|
|||
{
|
||||
// Singleton to avoid multiple instances of window.
|
||||
private static DatabaseListView _instance;
|
||||
public static DatabaseListView Instance => _instance ?? (DatabaseListView)GetWindow<DatabaseListView>();
|
||||
[MenuItem("Window/Aetheria Database Tools")]
|
||||
static void Init() => Instance.Show();
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
public Guid SelectedItem;
|
||||
public GUIStyle SelectedStyle;
|
||||
|
||||
|
|
@ -43,39 +51,9 @@ public class DatabaseListView : EditorWindow
|
|||
|
||||
public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black;
|
||||
|
||||
// Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...).
|
||||
public DatabaseListView()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
public static DatabaseListView ShowWindow()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
// "Get existing open window or if none, make a new one:" says documentation.
|
||||
// But if called after script reloads a second instance will be opened! => Custom singleton required.
|
||||
DatabaseListView window = GetWindow<DatabaseListView>();
|
||||
window.titleContent = new GUIContent("DB List");
|
||||
_instance = window;
|
||||
_instance.InitStyles();
|
||||
window.Show();
|
||||
}
|
||||
else
|
||||
_instance.Focus();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public GUIStyle ListItemStyle =>
|
||||
(_listItemStyle = !_listItemStyle) ? _listStyleEven : _listStyleOdd;
|
||||
|
||||
[MenuItem("Window/Aetheria Database Tools")]
|
||||
static void Init()
|
||||
{
|
||||
ShowWindow();
|
||||
}
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
// Create database cache
|
||||
|
|
@ -114,7 +92,8 @@ public class DatabaseListView : EditorWindow
|
|||
_databaseCache.OnDataDeleteRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
|
||||
DatabaseInspector.DatabaseCache = _databaseCache;
|
||||
_inspector = DatabaseInspector.ShowWindow();
|
||||
_inspector = DatabaseInspector.Instance;
|
||||
_inspector.Show();
|
||||
|
||||
_itemTypes = typeof(ItemData).GetAllChildClasses()
|
||||
.Where(t => t.GetCustomAttribute<InspectableAttribute>() != null).ToArray();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using MessagePack.Formatters;
|
||||
using MessagePack.Resolvers;
|
||||
|
|
@ -32,7 +33,11 @@ public class SerializerTestWindow : EditorWindow
|
|||
public void OnGUI()
|
||||
{
|
||||
//var obj = new ShieldData() {ID = Guid.NewGuid(), Name = "Bar" , HeatPerformanceCurve = new []{float4(0,0,0,0), float4(1,1,1,1)}} as DatabaseEntry;
|
||||
var obj = new GalaxyRequestMessage() as Message;
|
||||
//var obj = new GalaxyRequestMessage() as Message;
|
||||
var obj = new Gradient();
|
||||
var times = Enumerable.Range(0, 5).Select(i => (float) i / 4).ToArray();
|
||||
obj.alphaKeys = times.Select(f => new GradientAlphaKey(1, f)).ToArray();
|
||||
obj.colorKeys = times.Select(f => new GradientColorKey(UnityEngine.Random.ColorHSV(), f)).ToArray();
|
||||
// JsonSerializer serializer = new JsonSerializer();
|
||||
// serializer.Converters.Add(new MathJsonConverter());
|
||||
// serializer.Converters.Add(Converter.DateTimeConverter);
|
||||
|
|
|
|||
84
Assets/Scripts/Editor/ZoneEditor.cs
Normal file
84
Assets/Scripts/Editor/ZoneEditor.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
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()));
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Editor/ZoneEditor.cs.meta
Normal file
11
Assets/Scripts/Editor/ZoneEditor.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d675657ad7e1e7246b133b7abadaee2f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue