From aa5addf040dc1acbf7cda2e13debe25684fe1169 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 13 Jun 2026 05:33:34 +0100 Subject: [PATCH] Delete legacy CultCache editor writers --- Aetheria.State/README.md | 5 + .../CultCache/Editor/AetheriaDatabaseView.cs | 46 --- .../Editor/AetheriaDatabaseView.cs.meta | 3 - .../Scripts/CultCache/Editor/BaseInspector.cs | 31 -- .../CultCache/Editor/BaseInspector.cs.meta | 3 - .../CultCache/Editor/DatabaseInspector.cs | 292 ---------------- .../Editor/DatabaseInspector.cs.meta | 11 - .../Scripts/CultCache/Editor/DatabaseView.cs | 325 ------------------ .../CultCache/Editor/DatabaseView.cs.meta | 11 - .../CultCache/Editor/EditorDispatch.cs | 81 ----- .../CultCache/Editor/EditorDispatch.cs.meta | 11 - .../Scripts/CultCache/Editor/Inspectors.meta | 8 - .../Editor/Inspectors/AetheriaInspectors.cs | 234 ------------- .../Inspectors/AetheriaInspectors.cs.meta | 3 - .../Inspectors/AnimationCurveInspector.cs | 58 ---- .../AnimationCurveInspector.cs.meta | 3 - .../Inspectors/DatabaseLinkInspector.cs | 169 --------- .../Inspectors/DatabaseLinkInspector.cs.meta | 3 - .../Editor/Inspectors/DictionaryInspector.cs | 211 ------------ .../Inspectors/DictionaryInspector.cs.meta | 3 - .../Editor/Inspectors/EnumValuesInspector.cs | 59 ---- .../Inspectors/EnumValuesInspector.cs.meta | 3 - .../Editor/Inspectors/FloatInspector.cs | 54 --- .../Editor/Inspectors/FloatInspector.cs.meta | 3 - .../Editor/Inspectors/IntInspector.cs | 40 --- .../Editor/Inspectors/IntInspector.cs.meta | 3 - .../Editor/Inspectors/ListInspector.cs | 132 ------- .../Editor/Inspectors/ListInspector.cs.meta | 3 - .../Editor/Inspectors/MathematicsInspector.cs | 144 -------- .../Inspectors/MathematicsInspector.cs.meta | 11 - .../Editor/Inspectors/PrimitiveInspector.cs | 40 --- .../Inspectors/PrimitiveInspector.cs.meta | 3 - .../Editor/Inspectors/TypeInspector.cs | 23 -- .../Editor/Inspectors/TypeInspector.cs.meta | 3 - .../Editor/Inspectors/UnityObjectInspector.cs | 47 --- .../Inspectors/UnityObjectInspector.cs.meta | 3 - Assets/Scripts/Editor/NameTools.cs | 15 +- docs/aetheria-perfect-machine-map.md | 83 +++-- 38 files changed, 53 insertions(+), 2127 deletions(-) delete mode 100644 Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs delete mode 100644 Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/BaseInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/BaseInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/DatabaseInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/DatabaseInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/DatabaseView.cs delete mode 100644 Assets/Scripts/CultCache/Editor/DatabaseView.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/EditorDispatch.cs delete mode 100644 Assets/Scripts/CultCache/Editor/EditorDispatch.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs.meta delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs delete mode 100644 Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs.meta diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 60b4eee41..a63fe2979 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -25,6 +25,11 @@ Keyboard layout rendering now reads the checked-in Unity text asset directly. The old generated `GameData/KeyboardLayouts/*.msgpack` cache was deleted; layout edits are runtime-only until Verse owns a typed layout/settings document. +The old IMGUI CultCache database editor has been deleted, and `NameTools` no +longer exports `NameFile/*.msgpack`. `AetherDB.msgpack` and existing name files +remain legacy catalog inputs only; typed catalog migration is the next owner +move. + Current rebuild notes: - `MessagePack` 3.1.4 is pulled transitively through CultLib and is currently diff --git a/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs b/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs deleted file mode 100644 index e18d815f6..000000000 --- a/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.IO; -using UnityEditor; -using UnityEngine; - -public class AetheriaDatabaseView : DatabaseListView -{ - // Singleton to avoid multiple instances of window. - private static DatabaseListView _instance; - private string tableName; - public static DatabaseListView Instance => _instance ? _instance : GetWindow(); - [MenuItem("Window/Aetheria/Database Tools")] - static void Init() => Instance.Show(); - private void Awake() - { - _instance = this; - } - - protected override string DatabaseName => "Aetheria"; - - protected override string FilePath => new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData").FullName; - - protected override DatabaseEntryGroup[] Groupers => new DatabaseEntryGroup[] - { - new DatabaseEntryGroup( - data => data.Category, - category => Enum.GetName(typeof(SimpleCommodityCategory), category), - (data, category) => data.Category = category ), - new DatabaseEntryGroup( - data => data.Category, - category => Enum.GetName(typeof(CompoundCommodityCategory), category), - (data, category) => data.Category = category ), - new DatabaseEntryGroup( - data => data.HardpointType, - type => Enum.GetName(typeof(HardpointType), type), - (data, type) => data.Hardpoint = type), - new DatabaseEntryGroup( - data => data.Manufacturer, - factionID => factionID == Guid.Empty ? "Default" : cultCache.Get(factionID).ShortName, - (data, faction) => data.Manufacturer = faction), - new DatabaseEntryGroup( - data => data.HullType, - type => Enum.GetName(typeof(HullType), type), - (data, type) => data.HullType = type) - }; -} diff --git a/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs.meta b/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs.meta deleted file mode 100644 index 073e80c80..000000000 --- a/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4016d25951e246a184441b2aae75eba0 -timeCreated: 1617151686 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/BaseInspector.cs b/Assets/Scripts/CultCache/Editor/BaseInspector.cs deleted file mode 100644 index 2c07b7e6e..000000000 --- a/Assets/Scripts/CultCache/Editor/BaseInspector.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -public abstract class BaseInspector -{ - protected const int width = 150; - protected const int labelWidth = 20; - protected const int toggleWidth = 18; - protected const int arrowWidth = 22; - - public abstract T Inspect(string label, T value, object parent, DatabaseInspector inspectorWindow); -} - -public abstract class BaseInspector where A : Attribute -{ - protected const int width = 150; - protected const int labelWidth = 20; - protected const int toggleWidth = 18; - protected const int arrowWidth = 22; - - public abstract T Inspect(string label, T value, object parent, DatabaseInspector inspectorWindow, A attribute); -} - -public abstract class BaseInspector where A : Attribute where B : Attribute -{ - protected const int width = 150; - protected const int labelWidth = 20; - protected const int toggleWidth = 18; - protected const int arrowWidth = 22; - - public abstract T Inspect(string label, T value, object parent, DatabaseInspector inspectorWindow, A attributeA, B attributeB); -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/BaseInspector.cs.meta b/Assets/Scripts/CultCache/Editor/BaseInspector.cs.meta deleted file mode 100644 index b7330b2c5..000000000 --- a/Assets/Scripts/CultCache/Editor/BaseInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f3cde78766994141a3da6ab88d09118f -timeCreated: 1617052142 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs b/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs deleted file mode 100644 index 0c896850c..000000000 --- a/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs +++ /dev/null @@ -1,292 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using MessagePack; -using Unity.Mathematics; -using UnityEditor; -using UnityEngine; -using static Unity.Mathematics.math; -using static UnityEditor.EditorGUILayout; -using int2 = Unity.Mathematics.int2; -using Object = UnityEngine.Object; - -public class DatabaseInspector : EditorWindow -{ - public static CultCache CultCache; - public DatabaseEntry entry; - - // Singleton to avoid multiple instances of window. - private static DatabaseInspector _instance; - public static DatabaseInspector Instance => _instance ? _instance : GetWindow(); - private static bool _listItemStyle; - public static GUIStyle ListItemStyle => (_listItemStyle = !_listItemStyle) ? DatabaseListView.ListStyleEven : DatabaseListView.ListStyleOdd; - - public const int Width = 150; - - private Vector2 _view; - private GUIStyle _warning; - private List<(Type targetType, HashSet attributes, Type inspectorType, object instance)> _inspectors = - new List<(Type targetType, HashSet attributes, Type inspectorType, object instance)>(); - - private List<(Type targetType, HashSet attributes, Type inspectorType, Dictionary instances)> _genericInspectors = - new List<(Type targetType, HashSet attributes, Type inspectorType, Dictionary instances)>(); - private HashSet _foldouts = new HashSet(); - - public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black; - - void OnEnable() - { - _instance = this; - CultCache.OnUpdate += (_,__) => EditorDispatcher.Dispatch(Repaint); - wantsMouseMove = true; - _warning = new GUIStyle(EditorStyles.boldLabel); - _warning.normal.textColor = Color.red; - - var inspectorTypes = typeof(BaseInspector<>).GetAllGenericChildClasses() - .Concat(typeof(BaseInspector<,>).GetAllGenericChildClasses()) - .Concat(typeof(BaseInspector<,,>).GetAllGenericChildClasses()); - foreach (var type in inspectorTypes) - { - var genericArguments = type.BaseType.GetGenericArguments(); - if(genericArguments.Any()) - { - if (genericArguments[0].ContainsGenericParameters) - { - _genericInspectors.Add(( - genericArguments[0].GetGenericTypeDefinition(), - new HashSet(genericArguments.Skip(1)), - type, - new Dictionary() - )); - } - else - { - _inspectors.Add(( - genericArguments[0], - new HashSet(genericArguments.Skip(1)), - type, - Activator.CreateInstance(type) - )); - } - } - } - } - - public void Inspect(object obj, object parent = null) - { - foreach (var field in obj.GetType().GetFields().OrderBy(f=>f.GetCustomAttribute()?.IntKey ?? 0)) - { - Inspect(obj, field, parent); - } - } - - public void Inspect(object obj, FieldInfo field, object parent = null) - { - var inspectable = field.GetCustomAttribute(); - if (inspectable == null) return; - - var attributes = field.GetCustomAttributes(false); - - var type = field.FieldType; - var value = field.GetValue(obj); - - field.SetValue(obj, InspectMember(field.Name.SplitCamelCase(), value, parent ?? obj, type, false, attributes)); - } - - public object InspectMember(string label, object value, object parent, Type type, bool suppressContainer = false, params object[] attributes) - { - var style = _listItemStyle; - object GetAttribute(Type attributeType) - { - return attributes.FirstOrDefault(attributeType.IsInstanceOfType); - } - - if (value == null && type != typeof(string) && !(type.IsInterface || type.IsAbstract)) value = Activator.CreateInstance(type); - - var potentialInspectors = _inspectors - .Where(pi => - pi.targetType == type && - pi.attributes.All(attributeType => GetAttribute(attributeType) != null)); - if (potentialInspectors.Any()) - { - var preferredInspector = potentialInspectors.MaxBy(i => i.attributes.Count); - var parameters = new[] {label, value, parent, this} - .Concat(preferredInspector.attributes.Select(GetAttribute)) - .ToArray(); - value = preferredInspector.inspectorType.GetMethod("Inspect").Invoke(preferredInspector.instance, parameters); - _listItemStyle = style; - return value; - } - - if (type.IsEnum) - { - var isflags = type.GetCustomAttributes().Any(); - var names = Enum.GetNames(type); - value = InspectEnum(label, (int) value, isflags ? names.Skip(1).ToArray() : names, isflags); - _listItemStyle = style; - return value; - } - - if (type.GetCustomAttribute() != null) - { - if(!suppressContainer) - GUILayout.BeginVertical(GUI.skin.box); - using (new HorizontalScope()) - { - if(!suppressContainer) - { - if (Foldout(_foldouts.Contains(value), label, true, EditorStyles.boldLabel)) - _foldouts.Add(value); - else _foldouts.Remove(value); - } - if (type.IsInterface || type.IsAbstract) - { - var subTypes = type.GetAllChildClasses().Where(t=>!(t.IsInterface || t.IsAbstract)).ToArray(); - var selected = value != null ? Array.IndexOf(subTypes, value.GetType()) + 1 : 0; - var newSelection = Popup(selected, - subTypes.Select(t => t.Name.SplitCamelCase()).Prepend("None").ToArray()); - if (newSelection != selected) - value = newSelection == 0 ? null : Activator.CreateInstance(subTypes[newSelection - 1]); - } - else if (value == null) value = Activator.CreateInstance(type); - } - - if (value != null && (_foldouts.Contains(value) || suppressContainer)) Inspect(value, parent); - if(!suppressContainer) - GUILayout.EndVertical(); - _listItemStyle = style; - return value; - } - - if (type.IsGenericType) - { - var genericTypeDefinition = type.GetGenericTypeDefinition(); - var potentialGenericInspectors = _genericInspectors - .Where(pi => - pi.targetType == genericTypeDefinition && - pi.attributes.All(attributeType => GetAttribute(attributeType) != null)); - if (potentialGenericInspectors.Any()) - { - var genericTypeArguments = type.GenericTypeArguments; - var preferredInspector = potentialGenericInspectors.MaxBy(i => i.attributes.Count); - var genericInspectorType = preferredInspector.inspectorType.MakeGenericType(genericTypeArguments); - if (!preferredInspector.instances.ContainsKey(genericInspectorType)) - preferredInspector.instances[genericInspectorType] = - Activator.CreateInstance(genericInspectorType); - var parameters = new[] {label, value, parent, this}; - value = genericInspectorType.GetMethod("Inspect").Invoke(preferredInspector.instances[genericInspectorType], parameters); - _listItemStyle = style; - return value; - } - } - - Debug.Log($"Field \"{label}\" has unknown type {type.Name}. No inspector was generated."); - - _listItemStyle = style; - return value; - } - - public int InspectEnum(string label, int value, string[] enumOptions, bool flags) - { - if (flags) - { - Space(); - LabelField(label, EditorStyles.boldLabel); - using (new VerticalScope(GUI.skin.box)) - { - for (var i = 0; i < enumOptions.Length; i++) - { - using (var h = new HorizontalScope()) - { - GUILayout.Label(enumOptions[i], GUILayout.Width(Width)); - var set = Toggle(1 << i == (1 << i & value)); - if (set) - value |= 1 << i; - else value &= ~(1 << i); - } - } - } - - return value; - } - - using (var h = new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(Width)); - return Popup(value, enumOptions); - } - } - - public void OnGUI() - { - if (entry==null) - { - LabelField("No Entry Selected!"); - return; - } - - if(entry is INamedEntry namedEntry) - GUILayout.Label(namedEntry.EntryName, EditorStyles.boldLabel); - - _view = BeginScrollView( - _view, - false, - false, - GUIStyle.none, - GUI.skin.verticalScrollbar, - GUI.skin.scrollView, - GUILayout.Width(EditorGUIUtility.currentViewWidth), - GUILayout.ExpandHeight(true)); - - // Serialize inspected object so we can check whether it has actually changed - RegisterResolver.Register(); - var previousBytes = MessagePackSerializer.Serialize(entry); - var previousHash = previousBytes.GetHashSHA1(); - - EditorGUI.BeginChangeCheck(); - - var dataEntry = entry; - - using (new HorizontalScope()) - { - // if(GUILayout.Button("Print JSON")) - // Debug.Log(entry.ToJson()); - if (GUILayout.Button("Delete Entry")) - { - CultCache.Remove(entry); - entry = null; - return; - } - - if (GUILayout.Button("Clone Entry")) - { - var copy = MessagePackSerializer.Deserialize(previousBytes); - copy.ID = Guid.NewGuid(); - CultCache.Add(copy); - } - } - - using (var h = new HorizontalScope()) - { - GUILayout.Label("ID"); - LabelField(dataEntry.ID.ToString()); - } - - _listItemStyle = false; - Inspect(entry); - - if (EditorGUI.EndChangeCheck()) - { - if(previousHash != MessagePackSerializer.Serialize(entry).GetHashSHA1()) - CultCache.Add(entry); - } - - EndScrollView(); - } -} diff --git a/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs.meta b/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs.meta deleted file mode 100644 index c3cf8a9bd..000000000 --- a/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30b612dc279f724418b8a7a5426287c2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/CultCache/Editor/DatabaseView.cs b/Assets/Scripts/CultCache/Editor/DatabaseView.cs deleted file mode 100644 index 1fe885bf9..000000000 --- a/Assets/Scripts/CultCache/Editor/DatabaseView.cs +++ /dev/null @@ -1,325 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public abstract class DatabaseListView : EditorWindow -{ - public static GUIStyle ListStyleOdd; - public static GUIStyle ListStyleEven; - - public Guid SelectedItem; - public GUIStyle SelectedStyle; - - protected CultCache cultCache; - private static DatabaseInspector _inspector; - private Dictionary _tables; - //private Type[] _entryTypes; - private Type[] _globalTypes; - private Vector2 _view; - - private HashSet _groupFoldouts = new HashSet(); - - protected abstract string DatabaseName { get; } - protected abstract string FilePath { get; } - protected virtual DatabaseEntryGroup[] Groupers => new DatabaseEntryGroup[] { }; - - protected class DatabaseEntryGroup : DatabaseEntryGroup where T : DatabaseEntry - { - public Func GroupSelector { get; } - public Func GroupLabel { get; } - public Action Activator { get; } - - public DatabaseEntryGroup(Func groupSelector, Func groupLabel, Action activator) - { - GroupSelector = groupSelector; - GroupLabel = groupLabel; - Activator = activator; - } - - public override bool CanGroup(Type type) - { - return typeof(T) == type; - } - - public override object SelectGroup(DatabaseEntry o) - { - if (o is T t) return GroupSelector(t); - return null; - } - - public override string GetGroupName(object o) - { - if (o is K k) return GroupLabel(k); - return "ERROR"; - } - - public override int HashGroup(object o) - { - return o.GetHashCode(); - if (o is K k) return k.GetHashCode(); - return 0; - } - - public override void Activate(DatabaseEntry o, object g) - { - if(o is T t && g is K k) Activator(t, k); - throw new ArgumentException( - $"Entry group activation failed! Expected: object type {typeof(T)}, group type {typeof(K)}; received: object type {o.GetType()}, group type {g.GetType()}"); - } - } - - protected abstract class DatabaseEntryGroup - { - public abstract bool CanGroup(Type type); - public abstract object SelectGroup(DatabaseEntry o); - public abstract string GetGroupName(object o); - public abstract int HashGroup(object o); - public abstract void Activate(DatabaseEntry o, object g); - } - - public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black; - - private bool _listItemStyle; - private SingleFileMessagePackBackingStore _msgPackStore; - public GUIStyle ListItemStyle => (_listItemStyle = !_listItemStyle) ? ListStyleEven : ListStyleOdd; - - void OnEnable() - { - ListStyleOdd = new GUIStyle - { - normal = {background = EditorGUIUtility.isProSkin ? XKCDColors.DarkGrey.ToTexture() : XKCDColors.LightGrey.ToTexture()}, - margin = new RectOffset(0, 0, 0, 0) - }; - ListStyleEven = new GUIStyle - { - normal = {background = EditorGUIUtility.isProSkin ? Color.Lerp(XKCDColors.DarkGrey,Color.black,.5f).ToTexture() : Color.Lerp(XKCDColors.LightGrey,Color.white,.5f).ToTexture()}, - margin = new RectOffset(0, 0, 0, 0) - }; - - _msgPackStore = new SingleFileMessagePackBackingStore(Path.Combine(FilePath, "AetherDB.msgpack")); - cultCache = new CultCache(); - cultCache.AddBackingStore(_msgPackStore); - cultCache.AddBackingStore(new MultiFileMessagePackBackingStore(FilePath), typeof(NameFile)); - cultCache.PullAllBackingStores(); - - cultCache.OnUpdate += (_,__) => EditorDispatcher.Dispatch(Repaint); - DatabaseInspector.CultCache = cultCache; - _inspector = DatabaseInspector.Instance; - _inspector.Show(); - - _globalTypes = typeof(DatabaseEntry).GetAllChildClasses() - .Where(t => t.GetCustomAttribute() != null && t.GetCustomAttribute() != null).ToArray(); - _tables = typeof(DatabaseEntry).GetAllChildClasses() - .Where(t => t.GetCustomAttribute() != null && t.GetCustomAttribute() == null) - .GroupBy(t=>t.GetCustomAttribute()?.TableName ?? "Default") - .ToDictionary(group=>group.Key, group=> (false, group.Select(t=>(t, false)).ToArray())); - InitStyles(); - } - - private void InitStyles() - { - SelectedStyle = new GUIStyle - { - normal = {background = EditorGUIUtility.isProSkin ? XKCDColors.DarkGreyBlue.ToTexture() : XKCDColors.Greyblue.ToTexture()}, - margin = new RectOffset(0, 0, 0, 0) - }; - } - - public void OnGUI() - { - Event currentEvent = Event.current; - EventType currentEventType = currentEvent.type; - - if (currentEventType == EventType.DragUpdated) - // Indicate that we don't accept drags ourselves - DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; - - using (new HorizontalScope()) - { - GUILayout.Label("Export"); - if (GUILayout.Button("MsgPack")) - { - _msgPackStore.PushAll(); - Debug.Log("Exported DB to MessagePack!"); - } - } - - GUILayout.Space(5); - - _view = BeginScrollView( - _view, - false, - false, - GUIStyle.none, - GUI.skin.verticalScrollbar, - GUI.skin.scrollView, - GUILayout.Width(EditorGUIUtility.currentViewWidth), - GUILayout.ExpandHeight(true)); - - foreach (var globalType in _globalTypes) - { - var globalEntry = cultCache.GetGlobal(globalType); - var style = ListItemStyle; - var selected = SelectedItem == globalEntry.ID; - using (new HorizontalScope(selected?SelectedStyle:style)) - { - using (var h = new HorizontalScope()) - { - if (h.rect.Contains(currentEvent.mousePosition)) - { - if (currentEventType == EventType.MouseUp) - Select(globalEntry); - } - - GUILayout.Label(globalType.Name.SplitCamelCase(), selected ? EditorStyles.whiteLabel : GUI.skin.label); - } - } - } - - void DisplayGroup(Type entryType, IEnumerable entries, IEnumerable nestedGroups, int indent = 2, Action activatePreviousGroups = null, string previousGroupNames = "") - { - var grouper = nestedGroups.FirstOrDefault(); - if (grouper != null) - { - var groups = entries.GroupBy(o => grouper.SelectGroup(o)); - foreach (var group in groups) - { - //var groupHash = grouper.HashGroup(group.Key); - var groupName = grouper.GetGroupName(group.Key); - var groupHash = groupName.GetHashCode(); - using (new HorizontalScope(ListItemStyle)) - { - GUILayout.Space(indent*10); - if (Foldout(_groupFoldouts.Contains(groupHash), FormatTypeName(groupName), true)) - _groupFoldouts.Add(groupHash); - else _groupFoldouts.Remove(groupHash); - } - - if (_groupFoldouts.Contains(groupHash)) - { - Action activate = entry => - { - activatePreviousGroups?.Invoke(entry); - grouper.Activate(entry, group.Key); - }; - - DisplayGroup(entryType, group, nestedGroups.Skip(1), indent + 1, activate, $"{groupName} {previousGroupNames}"); - - using (var h = new HorizontalScope(ListItemStyle)) - { - if (GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) - CreateItem(entryType, activate); - GUILayout.Space((indent+1)*10); - GUILayout.Label($"Create {groupName} {previousGroupNames}"); - } - } - } - } - else - { - int index = 0; - foreach (var entry in entries) - { - index++; - var style = ListItemStyle; - var selected = SelectedItem == entry.ID; - using (var h = new HorizontalScope(selected ? SelectedStyle : style)) - { - if (h.rect.Contains(currentEvent.mousePosition)) - { - if (currentEventType == EventType.MouseDrag) - { - DragAndDrop.PrepareStartDrag(); - DragAndDrop.SetGenericData("Item", entry.ID); - DragAndDrop.StartDrag("Database Item"); - } - else if (currentEventType == EventType.MouseUp) - Select(entry); - } - - GUILayout.Space(indent*10); - GUILayout.Label((entry as INamedEntry)?.EntryName ?? index.ToString(), - selected ? EditorStyles.whiteLabel : GUI.skin.label); - } - } - } - } - - foreach (var table in _tables.Keys.ToArray()) - { - var (tableFoldout, _) = _tables[table]; - using (new HorizontalScope(ListItemStyle)) - { - _tables[table] = (Foldout(tableFoldout = _tables[table].foldout, table, true), _tables[table].types); - } - - if (tableFoldout) - { - for (var i = 0; i < _tables[table].types.Length; i++) - { - var (entryType, typeFoldout) = _tables[table].types[i]; - using (new HorizontalScope(ListItemStyle)) - { - GUILayout.Space(10); - _tables[table].types[i] = (entryType, typeFoldout = Foldout(typeFoldout, - ((NameAttribute) entryType.GetCustomAttribute(typeof(NameAttribute)))?.Name ?? FormatTypeName(entryType.Name), - true)); - } - - if (typeFoldout) - { - var entries = cultCache.GetAll(entryType) - .OrderBy(entry => entry is INamedEntry namedEntry ? namedEntry.EntryName : entry.ID.ToString()); - var groupers = Groupers.Where(g => g.CanGroup(entryType)); - DisplayGroup(entryType, entries, groupers); - - using (var h = new HorizontalScope(ListItemStyle)) - { - if (GUI.Button(h.rect, GUIContent.none, GUIStyle.none)) - CreateItem(entryType); - GUILayout.Space(20); - GUILayout.Label($"Create {FormatTypeName(entryType.Name)}"); - } - } - } - } - } - - EndScrollView(); - } - - public static string FormatTypeName(string typeName) - { - return (typeName.EndsWith("Data") - ? typeName.Substring(0, typeName.Length - 4) - : typeName).SplitCamelCase(); - } - - void Select(DatabaseEntry item) - { - SelectedItem = item.ID; - Repaint(); - _inspector.entry = cultCache.Get(SelectedItem); - _inspector.Repaint(); - } - - private DatabaseEntry CreateItem(Type type, Action onCreate = null) - { - var newEntry = (DatabaseEntry) Activator.CreateInstance(type); - if(newEntry is INamedEntry entry) - entry.EntryName = $"New {FormatTypeName(type.Name)}"; - onCreate?.Invoke(newEntry); - cultCache.Add(newEntry); - Select(newEntry); - return newEntry; - } -} diff --git a/Assets/Scripts/CultCache/Editor/DatabaseView.cs.meta b/Assets/Scripts/CultCache/Editor/DatabaseView.cs.meta deleted file mode 100644 index 17ec8bd15..000000000 --- a/Assets/Scripts/CultCache/Editor/DatabaseView.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b514fcab25f3b914b89824efbe244591 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/CultCache/Editor/EditorDispatch.cs b/Assets/Scripts/CultCache/Editor/EditorDispatch.cs deleted file mode 100644 index 90d63faa9..000000000 --- a/Assets/Scripts/CultCache/Editor/EditorDispatch.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using UnityEditor; -using UnityEngine; - -public static class EditorDispatcher -{ - private static readonly Queue dispatchQueue = new Queue(); - private static double timeSliceLimit = 10.0; // in miliseconds - private static Stopwatch timer; - - static EditorDispatcher() - { - EditorApplication.update += Update; - timer = new Stopwatch(); - } - - private static void Update () - { - lock (dispatchQueue) - { - int dispatchCount = 0; - - timer.Reset(); - timer.Start(); - - while (dispatchQueue.Count > 0 && (timer.Elapsed.TotalMilliseconds <= timeSliceLimit)) - { - dispatchQueue.Dequeue().Invoke(); - - dispatchCount++; - } - - timer.Stop(); - -// if (dispatchCount > 0) -// UnityEngine.Debug.Log(string.Format("[EditorDispatcher] Dispatched {0} calls in {1}ms", dispatchCount, timer.Elapsed.TotalMilliseconds)); - - // todo some logic for disconnecting update when the queue is empty - } - } - - /// - /// Send an Action Delegate to be run on the main thread. See EditorDispatchActions for some common usecases. - /// - /// An action delegate to run on the main thread - /// An AsyncDispatch that can be used to track if the dispatch has completed. - public static AsyncDispatch Dispatch(Action task) - { - lock (dispatchQueue) - { - AsyncDispatch dispatch = new AsyncDispatch(); - - // enqueue a new task that runs the supplied task and completes the dispatcher - dispatchQueue.Enqueue(() => { task(); dispatch.FinishedDispatch(); }); - - return dispatch; - } - } -} - -/// -/// Represents the progress of the dispatched action. Can be yielded to in a coroutine. -/// If not using coroutines, look at the IsDone property to find out when its okay to proceed. -/// -public class AsyncDispatch : CustomYieldInstruction -{ - public bool IsDone { get; private set; } - public override bool keepWaiting { get { return !IsDone; } } - - - /// - /// Flags this dispatch as completed. - /// - internal void FinishedDispatch() - { - IsDone = true; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/EditorDispatch.cs.meta b/Assets/Scripts/CultCache/Editor/EditorDispatch.cs.meta deleted file mode 100644 index b772d8892..000000000 --- a/Assets/Scripts/CultCache/Editor/EditorDispatch.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b7269ba738c469a4ea5b50811ef07f11 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/CultCache/Editor/Inspectors.meta b/Assets/Scripts/CultCache/Editor/Inspectors.meta deleted file mode 100644 index cd59277e6..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b62c0242f5704a96829889e1d4c44900 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs b/Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs deleted file mode 100644 index d60574934..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using Unity.Mathematics; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; -using static Unity.Mathematics.math; - -public class StatReferenceInspector : BaseInspector -{ - public override StatReference Inspect(string label, StatReference value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - - using (new VerticalScope()) - { - var targetObjects = typeof(BehaviorData).GetAllChildClasses() - .Concat(typeof(EquippableItemData).GetAllChildClasses()).ToArray(); - var objectNames = targetObjects.Select(b => b.Name).ToArray(); - var selectedIndex = Array.IndexOf(objectNames, value.Target); - if (selectedIndex == -1) - { - selectedIndex = 0; - GUI.changed = true; - } - using (new HorizontalScope()) - { - GUILayout.Label("Target", GUILayout.Width(width)); - var newSelection = Popup(selectedIndex, objectNames); - if (newSelection != selectedIndex) - GUI.changed = true; - value.Target = objectNames[newSelection]; - } - - using (new HorizontalScope()) - { - GUILayout.Label("Stat", GUILayout.Width(width)); - var stats = targetObjects[selectedIndex].GetFields() - .Where(f => f.FieldType == typeof(PerformanceStat)).ToArray(); - if(stats.Length==0) - GUILayout.Label("No Stats!"); - else - { - var statNames = stats.Select(s => s.Name).ToArray(); - var selectedStatIndex = Array.IndexOf(statNames, value.Stat); - if (selectedStatIndex == -1) - { - selectedStatIndex = 0; - GUI.changed = true; - } - var newSelection = Popup(selectedStatIndex, statNames); - if (newSelection != selectedStatIndex) - GUI.changed = true; - value.Stat = statNames[newSelection]; - } - } - } - } - - return value; - } -} - -public class PerformanceStatInspector : BaseInspector -{ - public override PerformanceStat Inspect(string label, PerformanceStat value, object parent, DatabaseInspector inspectorWindow) - { - if(value == null) - value = new PerformanceStat(); - using (new VerticalScope()) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("Min", EditorStyles.miniLabel, GUILayout.Width(labelWidth)); - value.Min = DelayedFloatField(value.Min); - GUILayout.Label("Max", EditorStyles.miniLabel, GUILayout.Width(labelWidth + 5)); - value.Max = DelayedFloatField(value.Max); - } - - // Only display heat, durability and quality effects if the stat actually varies - if (Math.Abs(value.Min - value.Max) > .0001f) - { - using (new HorizontalScope()) - { - GUILayout.Label("", GUILayout.Width(width)); - GUILayout.Label("H", EditorStyles.miniLabel, GUILayout.Width(labelWidth)); - value.HeatExponentMultiplier = DelayedFloatField(value.HeatExponentMultiplier); - - GUILayout.Label("D", EditorStyles.miniLabel, GUILayout.Width(labelWidth)); - value.DurabilityExponentMultiplier = DelayedFloatField(value.DurabilityExponentMultiplier); - - GUILayout.Label("Q", EditorStyles.miniLabel, GUILayout.Width(labelWidth)); - value.QualityExponent = DelayedFloatField(value.QualityExponent); - } - } - - Space(); - } - - return value; - } -} - -public class ShapeInspector : BaseInspector -{ - private Material _schematicMat = new Material(Shader.Find("Legacy Shaders/Particles/Additive")); - - public override Shape Inspect(string label, Shape value, object parent, DatabaseInspector inspectorWindow) - { - if(value == null) - { - value = new Shape(1, 1); - value[int2(0)] = true; - } - using (new VerticalScope()) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("Size", GUILayout.ExpandWidth(false)); - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.Width = DelayedIntField(value.Width); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.Height = DelayedIntField(value.Height); - } - - using (new HorizontalScope()) - { - GUILayout.Label("", GUILayout.Width(width)); - using (new VerticalScope()) - { - for (var y = value.Height - 1; y >= 0; y--) - { - using (new HorizontalScope()) - { - for (var x = 0; x < value.Width; x++) - { - var oldColor = GUI.backgroundColor; - value[int2(x, y)] = Toggle(value[int2(x, y)], GUILayout.Width(toggleWidth)); - GUI.backgroundColor = oldColor; - } - } - } - } - GUILayout.FlexibleSpace(); - } - } - - return value; - } -} - -public class ShapeSchematicInspector : BaseInspector -{ - private Material _schematicMat = new Material(Shader.Find("Legacy Shaders/Particles/Additive")); - - public override Shape Inspect(string label, Shape value, object parent, DatabaseInspector inspectorWindow, InspectableSchematicShapeAttribute attribute) - { - var item = parent as EquippableItemData; - if(value == null) - { - value = new Shape(1, 1); - value[int2(0)] = true; - } - using (new VerticalScope()) - { - Texture2D schematic = null; - if(item != null && !string.IsNullOrEmpty(item.Schematic)) - schematic = AssetDatabase.LoadAssetAtPath(item.Schematic); - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("Size", GUILayout.ExpandWidth(false)); - if(schematic == null) - { - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.Width = DelayedIntField(value.Width); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.Height = DelayedIntField(value.Height); - } - else - { - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.Width = DelayedIntField(value.Width); - value.Height = Mathf.RoundToInt(value.Width * ((float)schematic.height / schematic.width)); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - LabelField($"{value.Height}"); - } - } - - using (new HorizontalScope()) - { - GUILayout.Label("", GUILayout.Width(width)); - using (var a = new VerticalScope()) - { - if(schematic != null) - { - EditorGUI.DrawPreviewTexture(a.rect, schematic, _schematicMat); - } - for (var y = value.Height - 1; y >= 0; y--) - { - using (new HorizontalScope()) - { - for (var x = 0; x < value.Width; x++) - { - var oldColor = GUI.backgroundColor; - if(item is HullData hull) - { - var hardpoint = hull.Hardpoints - .FirstOrDefault(hp => - hp.Shape.Coordinates - .Select(v => v + hp.Position) - .Any(v => v.x == x && v.y == y)); - if (hardpoint != null) - GUI.backgroundColor = hardpoint.TintColor.ToColor(); - } - value[int2(x, y)] = Toggle(value[int2(x, y)], GUILayout.Width(toggleWidth)); - GUI.backgroundColor = oldColor; - } - } - } - } - GUILayout.FlexibleSpace(); - } - } - - return value; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs.meta deleted file mode 100644 index d04e230b0..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 57d0bc090768458b9428efd7a8a33741 -timeCreated: 1617069994 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs deleted file mode 100644 index 6f586824b..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Linq; -using Unity.Mathematics; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; -using static Unity.Mathematics.math; - -public class AnimationCurveFloat4Inspector : BaseInspector -{ - public override float4[] Inspect(string label, float4[] value, object parent, DatabaseInspector inspectorWindow) - { - var val = value != null && value.Length > 0 - ? value.ToCurve() - : new AnimationCurve(); - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - val = CurveField(val, Color.yellow, new Rect(0, 0, 1, 1)); - } - - return val.keys.Select(k => float4(k.time, k.value, k.inTangent, k.outTangent)).ToArray(); - } -} - -public class BezierCurveInspector : BaseInspector -{ - public override BezierCurve Inspect(string label, BezierCurve value, object parent, DatabaseInspector inspectorWindow) - { - var val = value != null && value.Keys != null && value.Keys.Length > 0 - ? value.ToCurve() - : new AnimationCurve(); - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - val = CurveField(val, Color.yellow, new Rect(0, 0, 1, 1)); - } - - value.Keys = val.keys.Select(k => float4(k.time, k.value, k.inTangent, k.outTangent)).ToArray(); - - return value; - } -} - -public class AnimationCurveInspect : BaseInspector -{ - public override AnimationCurve Inspect(string label, AnimationCurve value, object parent, DatabaseInspector inspectorWindow) - { - using (var h = new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - if (value == null) - value = new AnimationCurve(); - value = CurveField(value, Color.yellow, new Rect(0, 0, 1, 1)); - } - - return value; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs.meta deleted file mode 100644 index fffa738ed..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/AnimationCurveInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c89e0e7eb9f243cbbce28df59f6fb1c9 -timeCreated: 1617066399 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs deleted file mode 100644 index 6cfac4907..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class DatabaseLinkInspector : BaseInspector -{ - public override Guid Inspect(string label, Guid value, object parent, DatabaseInspector inspectorWindow, InspectableDatabaseLinkAttribute link) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - var valueEntry = DatabaseInspector.CultCache.Get(value); - using (var h = new HorizontalScope(GUI.skin.box)) - { - GUILayout.Label((valueEntry as INamedEntry)?.EntryName ?? valueEntry?.ID.ToString() ?? $"Drag and drop: {DatabaseListView.FormatTypeName(link.EntryType.Name)}"); - - if (h.rect.Contains(Event.current.mousePosition) && (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)) - { - var guid = (Guid) DragAndDrop.GetGenericData("Item"); - var dragEntry = DatabaseInspector.CultCache.Get(guid); - var dragValid = dragEntry != null && link.EntryType.IsInstanceOfType(dragEntry) && dragEntry != valueEntry; - if(Event.current.type == EventType.DragUpdated) - DragAndDrop.visualMode = dragValid ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; - else if(Event.current.type == EventType.DragPerform) - { - if (dragValid) - { - DragAndDrop.AcceptDrag(); - GUI.changed = true; - return guid; - } - } - } - if (GUILayout.Button("-", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3))) - { - return Guid.Empty; - } - } - } - - return value; - } -} - -public class DatabaseLinkObjectInspector : BaseInspector> where T : DatabaseEntry -{ - public override DatabaseLink Inspect(string label, DatabaseLink value, object parent, DatabaseInspector inspectorWindow) - { - if (value == null) - value = new DatabaseLink(); - - if(!string.IsNullOrEmpty(label)) - { - GUILayout.BeginHorizontal(); - GUILayout.Label(label, GUILayout.Width(width)); - } - - var valueEntry = value.Value; - using (var h = string.IsNullOrEmpty(label) ? new HorizontalScope() : new HorizontalScope(GUI.skin.box)) - { - GUILayout.Label((valueEntry as INamedEntry)?.EntryName ?? valueEntry?.ID.ToString() ?? $"Drag and drop: {DatabaseListView.FormatTypeName(typeof(T).Name)}"); - - if (h.rect.Contains(Event.current.mousePosition) && (Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragPerform)) - { - var guid = (Guid) DragAndDrop.GetGenericData("Item"); - var dragEntry = DatabaseInspector.CultCache.Get(guid); - var dragValid = dragEntry is T && dragEntry != valueEntry; - if(Event.current.type == EventType.DragUpdated) - DragAndDrop.visualMode = dragValid ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; - else if(Event.current.type == EventType.DragPerform) - { - if (dragValid) - { - DragAndDrop.AcceptDrag(); - value.LinkID = guid; - return value; - } - } - } - if(value.LinkID != Guid.Empty) - { - if (GUILayout.Button("-", - GUILayout.Width((EditorGUIUtility.singleLineHeight - 3) * 2), - GUILayout.Height(EditorGUIUtility.singleLineHeight - 3))) - { - value.LinkID = Guid.Empty; - } - } - } - - if(!string.IsNullOrEmpty(label)) - { - GUILayout.EndHorizontal(); - } - - return value; - } -} - -public class DatabaseLinkListInspector : BaseInspector, InspectableDatabaseLinkAttribute> -{ - private bool _listItemStyle; - public GUIStyle ListItemStyle => - (_listItemStyle = !_listItemStyle) ? DatabaseListView.ListStyleEven : DatabaseListView.ListStyleOdd; - - public override List Inspect(string label, - List value, - object parent, - DatabaseInspector inspectorWindow, - InspectableDatabaseLinkAttribute link) - { - using (var v = new VerticalScope(GUI.skin.box)) - { - GUILayout.Label(label, EditorStyles.boldLabel); - if (value.Count == 0) - { - using (new HorizontalScope(ListItemStyle)) - { - GUILayout.Label($"Drag from list to add {link.EntryType.Name}"); - } - } - foreach (var guid in value.ToArray()) - { - using (new HorizontalScope(ListItemStyle)) - { - var entry = DatabaseInspector.CultCache.Get(guid); - if (entry == null) - { - value.Remove(guid); - GUI.changed = true; - } - else - { - GUILayout.Label((entry as INamedEntry)?.EntryName ?? entry.ID.ToString()); - - // var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); - // GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0); - if (GUILayout.Button("-", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3))) - { - value.Remove(guid); - } - } - } - } - - if (v.rect.Contains(Event.current.mousePosition)) - { - var guid = DragAndDrop.GetGenericData("Item"); - var dragObj = DragAndDrop.GetGenericData("Item") is Guid ? DatabaseInspector.CultCache.Get((Guid) guid) : null; - var dragValid = dragObj != null && link.EntryType.IsInstanceOfType(dragObj) && !value.Contains(dragObj.ID); - if(Event.current.type == EventType.DragUpdated) - DragAndDrop.visualMode = dragValid ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; - else if(Event.current.type == EventType.DragPerform) - { - if (dragValid) - { - DragAndDrop.AcceptDrag(); - value.Add((Guid) guid); - GUI.changed = true; - } - } - } - } - - return value; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs.meta deleted file mode 100644 index 42978a734..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/DatabaseLinkInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 5e08712ea4854536b130f82ad61db7a8 -timeCreated: 1617069551 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs deleted file mode 100644 index 7d2128b5e..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs +++ /dev/null @@ -1,211 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class FloatDictionaryInspector : BaseInspector, InspectableDatabaseLinkAttribute> -{ - public override Dictionary Inspect(string label, - Dictionary value, - object parent, - DatabaseInspector inspectorWindow, - InspectableDatabaseLinkAttribute attribute) - { - Space(); - LabelField(label, EditorStyles.boldLabel); - - using (var v = new VerticalScope(GUI.skin.box)) - { - if (value.Count == 0) - { - using (new HorizontalScope(DatabaseInspector.ListItemStyle)) - { - GUILayout.Label("Drag from list to add item"); - } - } - foreach (var ingredient in value.ToArray()) - { - using (new HorizontalScope(DatabaseInspector.ListItemStyle)) - { - var entry = DatabaseInspector.CultCache.Get(ingredient.Key); - if (entry == null) - { - value.Remove(ingredient.Key); - GUI.changed = true; - return value; - } - - if(entry is INamedEntry named) - GUILayout.Label(named.EntryName); - else GUILayout.Label(entry.ID.ToString()); - value[ingredient.Key] = DelayedFloatField(value[ingredient.Key], GUILayout.Width(50)); - - // var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); - // GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0); - if (GUILayout.Button("-", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3))) - value.Remove(ingredient.Key); - } - } - - if (v.rect.Contains(Event.current.mousePosition)) - { - var dragData = DragAndDrop.GetGenericData("Item"); - var isId = dragData is Guid; - var dragEntry = isId ? DatabaseInspector.CultCache.Get((Guid)dragData) : null; - var correctType = attribute.EntryType.IsInstanceOfType(dragEntry); - if(Event.current.type == EventType.DragUpdated) - DragAndDrop.visualMode = correctType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; - else if(Event.current.type == EventType.DragPerform) - { - if (isId && correctType) - { - DragAndDrop.AcceptDrag(); - value[(Guid)dragData] = 1; - GUI.changed = true; - } - } - } - } - - return value; - } -} - -public class RangedFloatDictionaryInspector : BaseInspector, InspectableDatabaseLinkAttribute, RangedFloatAttribute> -{ - public override Dictionary Inspect(string label, - Dictionary value, - object parent, - DatabaseInspector inspectorWindow, - InspectableDatabaseLinkAttribute link, - RangedFloatAttribute range) - { - Space(); - LabelField(label, EditorStyles.boldLabel); - - using (var v = new VerticalScope(GUI.skin.box)) - { - if (value.Count == 0) - { - using (new HorizontalScope(DatabaseInspector.ListItemStyle)) - { - GUILayout.Label("Drag from list to add item"); - } - } - foreach (var ingredient in value.ToArray()) - { - using (new HorizontalScope(DatabaseInspector.ListItemStyle)) - { - var entry = DatabaseInspector.CultCache.Get(ingredient.Key); - if (entry == null) - { - value.Remove(ingredient.Key); - GUI.changed = true; - return value; - } - - if(entry is INamedEntry named) - GUILayout.Label(named.EntryName); - else GUILayout.Label(entry.ID.ToString()); - value[ingredient.Key] = Slider(value[ingredient.Key], range.Min, range.Max); - - // var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); - // GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0); - if (GUILayout.Button("-", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3))) - value.Remove(ingredient.Key); - } - } - - if (v.rect.Contains(Event.current.mousePosition)) - { - var dragData = DragAndDrop.GetGenericData("Item"); - var isId = dragData is Guid; - var dragEntry = isId ? DatabaseInspector.CultCache.Get((Guid)dragData) : null; - var correctType = link.EntryType.IsInstanceOfType(dragEntry); - if(Event.current.type == EventType.DragUpdated) - DragAndDrop.visualMode = correctType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; - else if(Event.current.type == EventType.DragPerform) - { - if (isId && correctType) - { - DragAndDrop.AcceptDrag(); - value[(Guid)dragData] = range.Max; - GUI.changed = true; - } - } - } - } - - return value; - } -} - -public class IntDictionaryInspector : BaseInspector, InspectableDatabaseLinkAttribute> -{ - public override Dictionary Inspect(string label, - Dictionary value, - object parent, - DatabaseInspector inspectorWindow, - InspectableDatabaseLinkAttribute attribute) - { - Space(); - LabelField(label, EditorStyles.boldLabel); - - using (var v = new VerticalScope(GUI.skin.box)) - { - if (value.Count == 0) - { - using (var h = new HorizontalScope(DatabaseInspector.ListItemStyle)) - { - GUILayout.Label("Drag from list to add item"); - } - } - foreach (var ingredient in value.ToArray()) - { - using (var h = new HorizontalScope(DatabaseInspector.ListItemStyle)) - { - var entry = DatabaseInspector.CultCache.Get(ingredient.Key); - if (entry == null) - { - value.Remove(ingredient.Key); - GUI.changed = true; - return value; - } - if(entry is INamedEntry named) - GUILayout.Label(named.EntryName); - else GUILayout.Label(entry.ID.ToString()); - - value[ingredient.Key] = DelayedIntField(value[ingredient.Key], GUILayout.Width(50)); - - // var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); - // GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0); - if (GUILayout.Button("-", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3)) || value[ingredient.Key]==0) - value.Remove(ingredient.Key); - } - } - - if (v.rect.Contains(Event.current.mousePosition)) - { - var dragData = DragAndDrop.GetGenericData("Item"); - var isId = dragData is Guid; - var dragEntry = isId ? DatabaseInspector.CultCache.Get((Guid)dragData) : null; - var correctType = attribute.EntryType.IsInstanceOfType(dragEntry); - if(Event.current.type == EventType.DragUpdated) - DragAndDrop.visualMode = correctType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected; - else if(Event.current.type == EventType.DragPerform) - { - if (isId && correctType) - { - DragAndDrop.AcceptDrag(); - value[(Guid)dragData] = 1; - GUI.changed = true; - } - } - } - } - - return value; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs.meta deleted file mode 100644 index 08a3ac73a..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/DictionaryInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a42620fd406045889578e2ad8d5fd8de -timeCreated: 1617067689 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs deleted file mode 100644 index 4f4d48590..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using static Unity.Mathematics.math; -using static UnityEditor.EditorGUILayout; - -public class EnumInspector : BaseInspector, InspectableEnumValuesAttribute> -{ - public override List Inspect(string label, List list, object parent, DatabaseInspector inspectorWindow, InspectableEnumValuesAttribute attribute) - { - var names = Enum.GetNames(attribute.EnumType); - list ??= new List(); - - while(list.Count < names.Length) list.Add(Activator.CreateInstance()); - while(list.Count > names.Length) list.RemoveAt(list.Count-1); - - for (var i = 0; i < names.Length; i++) - inspectorWindow.InspectMember(names[i], list[i], parent, typeof(T)); - - return list; - } -} - -public class EnumDictionaryInspector : BaseInspector> where E : Enum -{ - private static HashSet _foldouts = new HashSet(); - - public override EnumDictionary Inspect(string label, EnumDictionary dict, object parent, DatabaseInspector inspectorWindow) - { - var names = Enum.GetNames(typeof(E)); - if (dict == null || dict.Values.Length != names.Length) - { - var newValue = new T[names.Length]; - if(dict != null && dict.Values.Length > 0) - Array.Copy(dict.Values, newValue, min(dict.Values.Length, newValue.Length)); - dict.Values = newValue; - } - - using (new VerticalScope(GUI.skin.box)) - { - if (Foldout(_foldouts.Contains(dict), label, true, EditorStyles.boldLabel)) - _foldouts.Add(dict); - else _foldouts.Remove(dict); - if(_foldouts.Contains(dict)) - { - for (var i = 0; i < names.Length; i++) - { - using (new VerticalScope(DatabaseInspector.ListItemStyle)) - { - dict.Values[i] = (T) inspectorWindow.InspectMember(names[i], dict.Values[i], parent, typeof(T)); - } - } - } - } - - return dict; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs.meta deleted file mode 100644 index f7f4ea7c5..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/EnumValuesInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: da1b15e5564747958639c8f959226c74 -timeCreated: 1617335525 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs deleted file mode 100644 index 27847e30e..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs +++ /dev/null @@ -1,54 +0,0 @@ -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class FloatInspector : BaseInspector -{ - public override float Inspect(string label, float value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return DelayedFloatField(value); - } - } -} - -public class RangedFloatInspector : BaseInspector -{ - public override float Inspect(string label, - float value, - object parent, - DatabaseInspector inspectorWindow, - InspectableRangedFloatAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return Slider(value, attribute.Min, attribute.Max); - } - } -} - -public class TemperatureFloatInspector : BaseInspector -{ - public override float Inspect(string label, - float value, - object parent, - DatabaseInspector inspectorWindow, - InspectableTemperatureAttribute attribute) - { - using (var h = new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("°K", EditorStyles.miniLabel, GUILayout.Width(labelWidth)); - value = DelayedFloatField(value); - GUILayout.Label("°C", EditorStyles.miniLabel, GUILayout.Width(labelWidth)); - value = DelayedFloatField(value - 273.15f) + 273.15f; - GUILayout.Label("°F", EditorStyles.miniLabel, GUILayout.Width(labelWidth)); - value = (DelayedFloatField((value - 273.15f) * 1.8f + 32) - 32) / 1.8f + 273.15f; - - return value; - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs.meta deleted file mode 100644 index 17a7c71fc..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 47b8e5bc90714055881eb31baf2ab879 -timeCreated: 1617065074 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs deleted file mode 100644 index 51e990342..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs +++ /dev/null @@ -1,40 +0,0 @@ -using static Unity.Mathematics.math; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class IntInspector : BaseInspector -{ - public override int Inspect(string label, int value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return DelayedIntField(value); - } - } -} - -public class UintInspector : BaseInspector -{ - public override uint Inspect(string label, uint value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return (uint) max(DelayedIntField((int)value), 0); - } - } -} - -public class RangedIntInspector : BaseInspector -{ - public override int Inspect(string label, int value, object parent, DatabaseInspector inspectorWindow, InspectableRangedIntAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return IntSlider(value, attribute.Min, attribute.Max); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs.meta deleted file mode 100644 index 969165fd1..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ac7d3b8651964ce1a732a002447d6f69 -timeCreated: 1617065365 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs deleted file mode 100644 index fbd330812..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class ListInspector : BaseInspector> -{ - private static HashSet _foldouts = new HashSet(); - - public override List Inspect(string label, List list, object parent, DatabaseInspector inspectorWindow) - { - var listType = typeof(T); - var inspectable = listType.GetCustomAttribute(); - // if (listType.GetCustomAttribute() != null) - // { - //Space(); - using (new VerticalScope(GUI.skin.box)) - { - if (list == null) - { - list = new List(); - } - else - { - var sorted = true; - var order = int.MinValue; - foreach(var element in list) - { - if (element == null) - { - list.Remove(element); - return list; - } - var elementType = element.GetType(); - var elementOrder = elementType.GetCustomAttribute()?.Order ?? 0; - if (elementOrder < order) - sorted = false; - order = elementOrder; - } - - if (!sorted) - { - list.Sort((x, y) => (x.GetType().GetCustomAttribute()?.Order ?? 0).CompareTo(y.GetType().GetCustomAttribute()?.Order ?? 0)); - } - } - if (Foldout(_foldouts.Contains(list), label, true, EditorStyles.boldLabel)) - _foldouts.Add(list); - else _foldouts.Remove(list); - if (_foldouts.Contains(list)) - { - foreach (var o in list) - { - if (o == null) - { - list.Remove(o); - break; - } - bool _tinted = false; - var originalColor = GUI.backgroundColor; - if (o is ITintInspector tint) - { - _tinted = true; - GUI.backgroundColor = tint.TintColor.ToColor(); - } - - using (new VerticalScope(DatabaseInspector.ListItemStyle)) - { - using (new HorizontalScope()) - { - if (inspectable != null) - { - if (Foldout(_foldouts.Contains(o), o.ToString(), true, EditorStyles.boldLabel)) - _foldouts.Add(o); - else - _foldouts.Remove(o); - } - else inspectorWindow.InspectMember("", o, parent, listType, true); - - if (GUILayout.Button("-", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3))) - { - list.Remove(o); - break; - } - } - if(inspectable != null && _foldouts.Contains(o)) - inspectorWindow.InspectMember("", o, parent, o.GetType(), true); - } - - if(_tinted) - GUI.backgroundColor = originalColor; - } - using (new HorizontalScope(DatabaseInspector.ListItemStyle)) - { - GUILayout.Label($"Add new {listType.GetFullName()}", GUILayout.ExpandWidth(true)); - // var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight)); - // GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0); - if (GUILayout.Button("+", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3))) - { - if (listType.IsAbstract || listType.IsInterface) - { - var menu = new GenericMenu(); - foreach (var childType in listType.GetAllChildClasses().Where(t=>!t.IsAbstract && !t.IsInterface)) - { - menu.AddItem(new GUIContent(childType.Name), false, () => - { - var o = (T) Activator.CreateInstance(childType); - _foldouts.Add(o); - list.Add(o); - }); - } - menu.ShowAsContext(); - } - else - { - var o = Activator.CreateInstance(); - _foldouts.Add(o); - list.Add(o); - } - } - } - } - } - // } - // else Debug.Log($"Field \"{label}\" is a list of non-Inspectable type {listType.Name}. No inspector was generated."); - - return list; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs.meta deleted file mode 100644 index c9e68d5d1..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 551335721057411d942b3317ae028546 -timeCreated: 1617145746 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs deleted file mode 100644 index 6232f6e99..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs +++ /dev/null @@ -1,144 +0,0 @@ -using Unity.Mathematics; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class Float2Inspector : BaseInspector -{ - public override float2 Inspect(string label, float2 value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.x = DelayedFloatField(value.x); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.y = DelayedFloatField(value.y); - return value; - } - } -} - -public class Float3Inspector : BaseInspector -{ - public override float3 Inspect(string label, float3 value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.x = DelayedFloatField(value.x); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.y = DelayedFloatField(value.y); - GUILayout.Label("Z", GUILayout.Width(labelWidth)); - value.z = DelayedFloatField(value.z); - return value; - } - } -} - -public class Float3ColorInspector : BaseInspector -{ - public override float3 Inspect(string label, float3 value, object parent, DatabaseInspector inspectorWindow, InspectableColorAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return ColorField(value.ToColor()).ToFloat3(); - } - } -} - -public class Float4Inspector : BaseInspector -{ - public override float4 Inspect(string label, float4 value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.x = DelayedFloatField(value.x); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.y = DelayedFloatField(value.y); - GUILayout.Label("Z", GUILayout.Width(labelWidth)); - value.z = DelayedFloatField(value.z); - GUILayout.Label("W", GUILayout.Width(labelWidth)); - value.w = DelayedFloatField(value.w); - return value; - } - } -} - -public class Float4ColorInspector : BaseInspector -{ - public override float4 Inspect(string label, float4 value, object parent, DatabaseInspector inspectorWindow, InspectableColorAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return ColorField(value.ToColor()).ToFloat4(); - } - } -} - -public class Int2Inspector : BaseInspector -{ - public override int2 Inspect(string label, int2 value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.x = DelayedIntField(value.x); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.y = DelayedIntField(value.y); - if (GUILayout.Button("\u2190", GUILayout.Width(arrowWidth))) - value.x--; - if (GUILayout.Button("\u2192", GUILayout.Width(arrowWidth))) - value.x++; - if (GUILayout.Button("\u2191", GUILayout.Width(arrowWidth))) - value.y++; - if (GUILayout.Button("\u2193", GUILayout.Width(arrowWidth))) - value.y--; - return value; - } - } -} - -public class Int3Inspector : BaseInspector -{ - public override int3 Inspect(string label, int3 value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.x = DelayedIntField(value.x); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.y = DelayedIntField(value.y); - GUILayout.Label("Z", GUILayout.Width(labelWidth)); - value.z = DelayedIntField(value.z); - return value; - } - } -} - -public class Int4Inspector : BaseInspector -{ - public override int4 Inspect(string label, int4 value, object parent, DatabaseInspector inspectorWindow) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - GUILayout.Label("X", GUILayout.Width(labelWidth)); - value.x = DelayedIntField(value.x); - GUILayout.Label("Y", GUILayout.Width(labelWidth)); - value.y = DelayedIntField(value.y); - GUILayout.Label("Z", GUILayout.Width(labelWidth)); - value.z = DelayedIntField(value.z); - GUILayout.Label("W", GUILayout.Width(labelWidth)); - value.w = DelayedIntField(value.w); - return value; - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs.meta deleted file mode 100644 index a77ad74c8..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/MathematicsInspector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae5bba94d1f1a7144944aebf833497b3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs deleted file mode 100644 index b2c4b99ac..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class BoolInspector : BaseInspector -{ - public override bool Inspect(string label, bool value, object parent, DatabaseInspector inspectorWindow) - { - using (var h = new EditorGUILayout.HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return Toggle(value); - } - } -} - -public class StringInspector : BaseInspector -{ - public override string Inspect(string label, string value, object parent, DatabaseInspector inspectorWindow) - { - using (var h = new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return DelayedTextField(value); - } - } -} - -public class StringAreaInspector : BaseInspector -{ - public override string Inspect(string label, string value, object parent, DatabaseInspector inspectorWindow, InspectableTextAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - EditorStyles.textArea.wordWrap = true; - return DelayedTextField(value, EditorStyles.textArea, GUILayout.Height(100)); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs.meta deleted file mode 100644 index fc3143b8b..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/PrimitiveInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 91dcbfa1679e4be1944d6856ca63bf13 -timeCreated: 1617065181 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs deleted file mode 100644 index 19a4138b0..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Linq; -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class TypeInspector : BaseInspector -{ - public override Type Inspect(string label, Type value, object parent, DatabaseInspector inspectorWindow, InspectableTypeAttribute attribute) - { - var types = attribute.Type.GetAllChildClasses(); - var enumOptions = new[] {"None"}.Concat(types.Select(t => t.Name)).ToArray(); - var index = Array.IndexOf(types, value) + 1; - - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - index = Popup(index, enumOptions); - } - - return index == 0 ? null : types[index - 1]; - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs.meta deleted file mode 100644 index 005fcd819..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4762384a61dc4d08a1ba4e7564a20081 -timeCreated: 1617066802 \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs b/Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs deleted file mode 100644 index cf0c872ae..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs +++ /dev/null @@ -1,47 +0,0 @@ -using UnityEditor; -using UnityEngine; -using static UnityEditor.EditorGUILayout; - -public class TextureInspector : BaseInspector -{ - public override string Inspect(string label, - string value, - object parent, - DatabaseInspector inspectorWindow, - InspectableTextureAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return AssetDatabase.GetAssetPath(ObjectField(AssetDatabase.LoadAssetAtPath(value), typeof(Texture2D), false)); - } - } -} - -public class GameObjectInspector : BaseInspector -{ - public override string Inspect(string label, string value, object parent, DatabaseInspector inspectorWindow, InspectablePrefabAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return AssetDatabase.GetAssetPath(ObjectField(AssetDatabase.LoadAssetAtPath(value), typeof(GameObject), false)); - } - } -} - -public class TextAssetInspector : BaseInspector -{ - public override string Inspect(string label, - string value, - object parent, - DatabaseInspector inspectorWindow, - InspectableTextAssetAttribute attribute) - { - using (new HorizontalScope()) - { - GUILayout.Label(label, GUILayout.Width(width)); - return AssetDatabase.GetAssetPath(ObjectField(AssetDatabase.LoadAssetAtPath(value), typeof(TextAsset), false)); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs.meta b/Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs.meta deleted file mode 100644 index 1990fc264..000000000 --- a/Assets/Scripts/CultCache/Editor/Inspectors/UnityObjectInspector.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 8519fa7d4f06468bb9be151f053d1fcb -timeCreated: 1617067005 \ No newline at end of file diff --git a/Assets/Scripts/Editor/NameTools.cs b/Assets/Scripts/Editor/NameTools.cs index 1482e4022..9e31c5597 100644 --- a/Assets/Scripts/Editor/NameTools.cs +++ b/Assets/Scripts/Editor/NameTools.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; -using MessagePack; using Unity.Mathematics; using UnityEngine; using UnityEditor; @@ -46,17 +45,7 @@ public class NameTools : EditorWindow if (GUILayout.Button("Save Name Files")) { - RegisterResolver.Register(); - var nameFilesDirectory = ActionGameManager.GameDataDirectory.CreateSubdirectory("NameFile"); - foreach (var nameFile in NameFiles) - { - var entry = new NameFile - { - Name = nameFile.name, - Names = nameFile.text.Split('\n') - }; - File.WriteAllBytes(Path.Combine(nameFilesDirectory.FullName, $"{entry.ID.ToString()}.msgpack"), MessagePackSerializer.Serialize((DatabaseEntry) entry)); - } + Debug.LogWarning("Name file persistence belongs to the Verse state spine. Legacy NameFile .msgpack export is disabled."); } nameFile = (TextAsset) EditorGUILayout.ObjectField("Name File", nameFile, typeof(TextAsset), false); @@ -112,4 +101,4 @@ public class NameTools : EditorWindow } } } -} \ No newline at end of file +} diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 5fccaed20..8686f4444 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1,6 +1,6 @@ # Aetheria Perfect Machine Map -Date: 2026-06-12 +Date: 2026-06-13 This is the Proprioception and Imagination pass for turning Aetheria from a Unity project with ancestral cache/network/UI machinery into a coherent @@ -17,22 +17,23 @@ local CultCache, and legacy UI paths should be migration-only or deleted. ## Current Mechanism -- Unity client/runtime lives under `Assets/`, with gameplay scripts reading and - mutating old `CultCache` data, especially through `ActionGameManager`. -- Shared domain state is built around `DatabaseEntry`, GUID identity, MessagePack - attributes, Newtonsoft attributes, JsonKnownTypes polymorphism, and static - cache references. -- Local persistence is mostly old MessagePack files in `GameData/`, but JSON - backing stores, JSON converters, JsonKnownTypes, and Newtonsoft attributes are - still welded into the model. -- `Economy.Server` uses LiteNetLib and MessagePack messages, while its database - path still directly connects to RethinkDB and depends on the old shared cache - model. -- A vendored RethinkDB driver lives under - `Assets/Scripts/ServerShared/NIH/RethinkDb/` and pins old Newtonsoft. -- The old Unity DB inspector is an IMGUI editor window under - `Assets/Scripts/CultCache/Editor/`, tied to Rethink tables and the old - cache model. +- Unity client/runtime lives under `Assets/`. Gameplay still reads the legacy + item/name catalog through `ActionGameManager.LegacyCultCache`, but local run + saves, loadouts, player settings files, zone files, and generated keyboard + layout caches no longer write bespoke durable files. +- Shared domain state is still partly built around `DatabaseEntry`, GUID + identity, MessagePack attributes, and static cache references. Newtonsoft, + JsonKnownTypes, RethinkDB, LiteNetLib client transport, and the broken + `Economy.Shared` wrapper have been removed from live source. +- Local legacy catalog data remains in `GameData/AetherDB.msgpack` and + `GameData/NameFile/*.msgpack` as migration/catalog inputs. The old + `PlayerSettings.msgpack`, `.loadout`, `.zone`, and + `GameData/KeyboardLayouts/*.msgpack` authority paths are disabled or deleted. +- `Economy.Server` now starts the modern `Aetheria.State` CultMesh node and no + longer owns RethinkDB/LiteNetLib state. +- The old IMGUI DB inspector under `Assets/Scripts/CultCache/Editor/` has been + deleted. `NameTools` can still clean/generate names, but legacy NameFile + `.msgpack` export is disabled. - Runtime UI is old Unity UI/uGUI prefabs plus `MonoBehaviour` scripts under `Assets/Scripts/UI/` and `Assets/Prefabs/UI/`. - Aetheria already has Unity UIElements support available through @@ -55,20 +56,25 @@ local CultCache, and legacy UI paths should be migration-only or deleted. ## Current Authority Map -- Owner: `DatabaseEntry` plus old `CultCache` act as the practical state owner. -- Inputs: Unity gameplay code, editor DB inspector actions, legacy data files, - RethinkDB changefeeds, and server messages. -- Outputs: in-memory domain objects, old MessagePack files, optional JSON files, - RethinkDB table writes, and UI/editor projections. -- Derived state: UI panels, editor rows, Rethink table names, and serialized - payloads pretend to be projections but can still influence write paths. -- Forbidden writers: Rethink changefeed handlers, old JSON backing stores, - JsonKnownTypes converters, editor table exports, static cache globals, and - server-side `DatabaseCache` paths. +- Owner: `Aetheria.State` owns the new typed state spine for durable state. + `DatabaseEntry` plus old `CultCache` still own legacy catalog reads inside the + Unity runtime until catalog migration lands. +- Inputs: Unity gameplay code, legacy catalog files, typed state documents, and + CultMesh server state. +- Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy + catalog reads emit in-memory domain objects only; the old local save and + editor catalog write paths have been cut. +- Derived state: UI panels, generated keyboard layouts, editor rows, and + serialized legacy payloads are projections or migration inputs, not durable + authority. +- Forbidden writers: old JSON backing stores, JsonKnownTypes converters, + Rethink/LiteNet paths, IMGUI database editor exports, local save-file writes, + generated keyboard layout caches, and server-side `DatabaseCache` paths. - Shared paths: manual gameplay edits, editor edits, server updates, file load, file save, and migration all need to converge on one typed commit primitive. - Deletion line: no new behavior should be added to the old `DatabaseEntry`, - RethinkDB, JsonKnownTypes, or IMGUI DB inspector paths. + legacy `CultCache`, or MessagePack catalog paths except bounded migration + readers that emit typed `Aetheria.State` documents. ## Target Authority Map @@ -84,9 +90,9 @@ local CultCache, and legacy UI paths should be migration-only or deleted. `DatabaseEntry.ID`, global cache statics, and any compatibility reader. - Shared paths: gameplay input, editor edits, import/deep-load, replication, simulation ticks, and tests all call the same typed state service. -- Deletion line: after migration smokes pass, delete vendored RethinkDB, - Newtonsoft/JsonKnownTypes dependencies, old JSON backing stores, and the old - cache editor window. +- Deletion line: after catalog migration smokes pass, delete or quarantine the + remaining legacy `CultCache`/`DatabaseEntry` runtime catalog dependency and + remove old MessagePack backing store classes from live Unity source. ## Intended Change @@ -173,12 +179,15 @@ First Aetheria surfaces to publish: - Then replace runtime HUD/menu/inventory/map screens. 7. Purge - - Delete vendored RethinkDB. - - Delete JsonKnownTypes. - - Delete Newtonsoft dependencies and attributes from live code. - - Delete old JSON backing stores. - - Delete or quarantine old cache abstractions that no longer protect an - invariant. + - Done: delete vendored RethinkDB. + - Done: delete JsonKnownTypes. + - Done: delete Newtonsoft dependencies and attributes from live code. + - Done: delete old JSON backing stores. + - Done: delete the broken `Economy.Shared` wrapper and tracked build output. + - Done: disable legacy local save, loadout, zone, player-settings, keyboard + layout, DB inspector, and NameFile export writers. + - Remaining: delete or quarantine old cache abstractions that no longer + protect an invariant once catalog migration has a typed reader. ## Verification