Modular Database Tools
Extracted all inspector code for database inspector into a single class per supported field type and wrote reflection code to invoke them automatically Removed all Aetheria-specific code from database tools Database View editor is now abstract and supports arbitrary grouping of entry types; specific users must implement their own database view
This commit is contained in:
parent
48759380c5
commit
526a737a4d
72 changed files with 1674 additions and 1624 deletions
|
|
@ -170,7 +170,7 @@
|
|||
<Compile Include="Assets\Scripts\ServerShared\NIH\LinqFaster\Aggregate.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\NIH\MIConvexHull\ConvexHull\ConvexFace.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\NIH\LiteNetLib\NatPunchModule.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\CultCache\DatabaseCache.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\CultCache\CultCache.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Agents\Tasks\AgentTask.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ColorMath.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Radiator.cs" />
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ Material:
|
|||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Scale: 3.0991225
|
||||
- _Scale: 2.049001
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
|
|
|
|||
46
Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs
Normal file
46
Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
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<AetheriaDatabaseView>();
|
||||
[MenuItem("Window/Aetheria/Database Tools")]
|
||||
static void Init() => Instance.Show();
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
protected override string DatabaseName => "Aetheria";
|
||||
|
||||
protected override string FilePath => Path.Combine(new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData").FullName, "AetherDB.msgpack");
|
||||
|
||||
protected override DatabaseEntryGroup[] Groupers => new DatabaseEntryGroup[]
|
||||
{
|
||||
new DatabaseEntryGroup<SimpleCommodityData,SimpleCommodityCategory>(
|
||||
data => data.Category,
|
||||
category => Enum.GetName(typeof(SimpleCommodityCategory), category),
|
||||
(data, category) => data.Category = category ),
|
||||
new DatabaseEntryGroup<CompoundCommodityData, CompoundCommodityCategory>(
|
||||
data => data.Category,
|
||||
category => Enum.GetName(typeof(CompoundCommodityCategory), category),
|
||||
(data, category) => data.Category = category ),
|
||||
new DatabaseEntryGroup<GearData, HardpointType>(
|
||||
data => data.HardpointType,
|
||||
type => Enum.GetName(typeof(HardpointType), type),
|
||||
(data, type) => data.Hardpoint = type),
|
||||
// new DatabaseEntryGroup<GearData, Guid>(
|
||||
// data => data.Manufacturer,
|
||||
// factionID => cultCache.Get<Faction>(factionID).ShortName,
|
||||
// (data, faction) => data.Manufacturer = faction),
|
||||
new DatabaseEntryGroup<HullData, HullType>(
|
||||
data => data.HullType,
|
||||
type => Enum.GetName(typeof(HullType), type),
|
||||
(data, type) => data.HullType = type)
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4016d25951e246a184441b2aae75eba0
|
||||
timeCreated: 1617151686
|
||||
31
Assets/Scripts/CultCache/Editor/BaseInspector.cs
Normal file
31
Assets/Scripts/CultCache/Editor/BaseInspector.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
public abstract class BaseInspector<T>
|
||||
{
|
||||
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<T, A> 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<T, A, B> 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);
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -14,89 +14,119 @@ using UnityEditor;
|
|||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class DatabaseListView : EditorWindow
|
||||
public abstract class DatabaseListView : EditorWindow
|
||||
{
|
||||
// Singleton to avoid multiple instances of window.
|
||||
private static DatabaseListView _instance;
|
||||
public static DatabaseListView Instance => _instance ? _instance : GetWindow<DatabaseListView>();
|
||||
[MenuItem("Window/GameCult/Database Tools")]
|
||||
static void Init() => Instance.Show();
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
public static GUIStyle ListStyleOdd;
|
||||
public static GUIStyle ListStyleEven;
|
||||
|
||||
public Guid SelectedItem;
|
||||
public GUIStyle SelectedStyle;
|
||||
|
||||
public static RethinkDB R = RethinkDB.R;
|
||||
|
||||
private DatabaseCache _databaseCache;
|
||||
private bool[] _itemTypeFoldouts;
|
||||
private bool _itemsFoldout;
|
||||
private bool _compoundFoldout;
|
||||
private bool _simpleFoldout;
|
||||
private bool _commoditiesFoldout;
|
||||
//private bool _consumablesFoldout;
|
||||
private Type[] _itemTypes;
|
||||
private bool _listItemStyle;
|
||||
private GUIStyle _listStyleOdd;
|
||||
private GUIStyle _listStyleEven;
|
||||
protected CultCache cultCache;
|
||||
private static DatabaseInspector _inspector;
|
||||
private Type[] _entryTypes;
|
||||
private bool[] _entryFoldouts;
|
||||
private bool[] _typeFoldouts;
|
||||
private string _connectionString;
|
||||
private const float LineHeight = 20;
|
||||
private Vector2 _view;
|
||||
private RethinkQueryStatus _queryStatus;
|
||||
private HashSet<string> _itemGroupFoldouts = new HashSet<string>();
|
||||
private HashSet<Guid> _itemManufacturerFoldouts = new HashSet<Guid>();
|
||||
private HashSet<(Guid, HardpointType)> _itemManufacturerTypeFoldouts = new HashSet<(Guid, HardpointType)>();
|
||||
private string _filePath => Path.Combine(new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData").FullName, _fileName);
|
||||
private string _fileName = "AetherDB.msgpack";
|
||||
|
||||
private HashSet<int> _groupFoldouts = new HashSet<int>();
|
||||
|
||||
protected abstract string DatabaseName { get; }
|
||||
protected abstract string FilePath { get; }
|
||||
protected virtual DatabaseEntryGroup[] Groupers => new DatabaseEntryGroup[] { };
|
||||
|
||||
protected class DatabaseEntryGroup<T, K> : DatabaseEntryGroup where T : DatabaseEntry
|
||||
{
|
||||
public Func<T,K> GroupSelector { get; }
|
||||
public Func<K,string> GroupLabel { get; }
|
||||
public Action<T, K> Activator { get; }
|
||||
|
||||
public DatabaseEntryGroup(Func<T, K> groupSelector, Func<K, string> groupLabel, Action<T, K> 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)
|
||||
{
|
||||
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;
|
||||
public GUIStyle ListItemStyle =>
|
||||
(_listItemStyle = !_listItemStyle) ? _listStyleEven : _listStyleOdd;
|
||||
(_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)
|
||||
};
|
||||
|
||||
//_filePath = ;
|
||||
// Create database cache
|
||||
_databaseCache = new DatabaseCache(_filePath);
|
||||
cultCache = new CultCache(FilePath);
|
||||
|
||||
// var onInsert = new Action<DatabaseEntry>(entry =>
|
||||
// {
|
||||
// });
|
||||
// _databaseCache.OnDataInsertLocal += onInsert;
|
||||
// _databaseCache.OnDataInsertRemote += onInsert;
|
||||
cultCache.OnDataUpdateLocal += _ => Repaint();
|
||||
cultCache.OnDataInsertLocal += _ => Repaint();
|
||||
cultCache.OnDataDeleteLocal += _ => Repaint();
|
||||
cultCache.OnDataUpdateRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
cultCache.OnDataInsertRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
cultCache.OnDataDeleteRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
|
||||
// var onDelete = new Action<DatabaseEntry>(entry =>
|
||||
// {
|
||||
// });
|
||||
// _databaseCache.OnDataDeleteLocal += onDelete;
|
||||
// _databaseCache.OnDataDeleteRemote += onDelete;
|
||||
|
||||
_databaseCache.OnDataUpdateLocal += _ => Repaint();
|
||||
_databaseCache.OnDataInsertLocal += _ => Repaint();
|
||||
_databaseCache.OnDataDeleteLocal += _ => Repaint();
|
||||
_databaseCache.OnDataUpdateRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
_databaseCache.OnDataInsertRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
_databaseCache.OnDataDeleteRemote += _ => EditorDispatcher.Dispatch(Repaint);
|
||||
|
||||
DatabaseInspector.DatabaseCache = _databaseCache;
|
||||
DatabaseInspector.CultCache = cultCache;
|
||||
_inspector = DatabaseInspector.Instance;
|
||||
_inspector.Show();
|
||||
|
||||
_itemTypes = typeof(ItemData).GetAllChildClasses()
|
||||
.Where(t => t.GetCustomAttribute<InspectableAttribute>() != null).ToArray();
|
||||
_entryTypes = typeof(DatabaseEntry).GetAllChildClasses()
|
||||
.Where(t => t.GetCustomAttribute<InspectableAttribute>() != null && !typeof(ItemData).IsAssignableFrom(t)).ToArray();
|
||||
.Where(t => t.GetCustomAttribute<InspectableAttribute>() != null).ToArray();
|
||||
|
||||
_itemTypeFoldouts = new bool[_itemTypes.Length];
|
||||
_entryFoldouts = new bool[_entryTypes.Length];
|
||||
_typeFoldouts = new bool[_entryTypes.Length];
|
||||
|
||||
if (EditorPrefs.HasKey("RethinkDB.URL"))
|
||||
_connectionString = EditorPrefs.GetString("RethinkDB.URL");
|
||||
|
|
@ -108,20 +138,9 @@ public class DatabaseListView : EditorWindow
|
|||
|
||||
private void InitStyles()
|
||||
{
|
||||
var isDark = EditorGUIUtility.isProSkin;
|
||||
_listStyleOdd = new GUIStyle
|
||||
{
|
||||
normal = {background = isDark ? XKCDColors.DarkGrey.ToTexture() : XKCDColors.LightGrey.ToTexture()},
|
||||
margin = new RectOffset(0, 0, 0, 0)
|
||||
};
|
||||
_listStyleEven = new GUIStyle
|
||||
{
|
||||
normal = {background = isDark ? Color.Lerp(XKCDColors.DarkGrey,Color.black,.5f).ToTexture() : Color.Lerp(XKCDColors.LightGrey,Color.white,.5f).ToTexture()},
|
||||
margin = new RectOffset(0, 0, 0, 0)
|
||||
};
|
||||
SelectedStyle = new GUIStyle
|
||||
{
|
||||
normal = {background = isDark ? XKCDColors.DarkGreyBlue.ToTexture() : XKCDColors.Greyblue.ToTexture()},
|
||||
normal = {background = EditorGUIUtility.isProSkin ? XKCDColors.DarkGreyBlue.ToTexture() : XKCDColors.Greyblue.ToTexture()},
|
||||
margin = new RectOffset(0, 0, 0, 0)
|
||||
};
|
||||
}
|
||||
|
|
@ -142,7 +161,7 @@ public class DatabaseListView : EditorWindow
|
|||
{
|
||||
EditorPrefs.SetString("RethinkDB.URL", _connectionString);
|
||||
JsonKnownTypesSettingsManager.RegisterTypeAssembly<ItemData>();
|
||||
_queryStatus = RethinkConnection.RethinkConnect(_databaseCache, _connectionString);
|
||||
_queryStatus = RethinkConnection.RethinkConnect(cultCache, _connectionString, DatabaseName);
|
||||
}
|
||||
// if (GUILayout.Button("Connect All"))
|
||||
// {
|
||||
|
|
@ -155,21 +174,21 @@ public class DatabaseListView : EditorWindow
|
|||
//_fileName = TextField(_fileName);
|
||||
if (GUILayout.Button("Save"))
|
||||
{
|
||||
_databaseCache.Save();
|
||||
cultCache.Save();
|
||||
Debug.Log("Local DB Cache Saved!");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Load"))
|
||||
{
|
||||
_databaseCache.Load();
|
||||
cultCache.Load();
|
||||
Debug.Log("Loaded DB From Local Cache!");
|
||||
}
|
||||
}
|
||||
|
||||
if (_queryStatus != null && _queryStatus.RetrievedItems < _queryStatus.GalaxyEntries + _queryStatus.ItemsEntries)
|
||||
if (_queryStatus != null && _queryStatus.RetrievedEntries < _queryStatus.TotalEntries)
|
||||
{
|
||||
var progressRect = GetControlRect(false, 20);
|
||||
EditorGUI.ProgressBar(progressRect, (float)_queryStatus.RetrievedItems/(_queryStatus.GalaxyEntries + _queryStatus.ItemsEntries), "Sync Progress");
|
||||
EditorGUI.ProgressBar(progressRect, (float)_queryStatus.RetrievedEntries/_queryStatus.TotalEntries, "Sync Progress");
|
||||
}
|
||||
GUILayout.Space(5);
|
||||
|
||||
|
|
@ -183,228 +202,100 @@ public class DatabaseListView : EditorWindow
|
|||
GUILayout.Width(EditorGUIUtility.currentViewWidth),
|
||||
GUILayout.ExpandHeight(true));
|
||||
|
||||
// if(GUILayout.Button("Log Cache Count"))
|
||||
// Debug.Log($"Cache contains {_databaseCache.AllEntries.Count()} elements");
|
||||
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
_itemsFoldout = Foldout(_itemsFoldout, "Items", true);
|
||||
}
|
||||
if (_itemsFoldout)
|
||||
{
|
||||
var items = _databaseCache.AllEntries.Where(item => item is ItemData).Cast<ItemData>().ToArray();
|
||||
for (var i = 0; i < _itemTypes.Length; i++)
|
||||
{
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
_itemTypeFoldouts[i] = Foldout(_itemTypeFoldouts[i],
|
||||
((NameAttribute) _itemTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? FormatTypeName(_itemTypes[i].Name),
|
||||
true);
|
||||
}
|
||||
if (_itemTypeFoldouts[i])
|
||||
{
|
||||
if (_itemTypes[i] == typeof(SimpleCommodityData) ||
|
||||
_itemTypes[i] == typeof(CompoundCommodityData) ||
|
||||
_itemTypes[i] == typeof(HullData))
|
||||
{
|
||||
var typedItems = items
|
||||
.Where(e => e.GetType() == _itemTypes[i])
|
||||
.OrderBy(item => item.Name);
|
||||
IEnumerable<IGrouping<string, ItemData>> itemGroups = new List<IGrouping<string, ItemData>>();
|
||||
if(_itemTypes[i] == typeof(SimpleCommodityData))
|
||||
itemGroups = typedItems.GroupBy(item => Enum.GetName(typeof(SimpleCommodityCategory), (item as SimpleCommodityData).Category));
|
||||
else if(_itemTypes[i] == typeof(CompoundCommodityData))
|
||||
itemGroups = typedItems.GroupBy(item => Enum.GetName(typeof(CompoundCommodityCategory), (item as CompoundCommodityData).Category));
|
||||
else if (_itemTypes[i] == typeof(HullData))
|
||||
itemGroups = typedItems.GroupBy(item => Enum.GetName(typeof(HullType), (item as HullData).HullType));
|
||||
else itemGroups = typedItems.GroupBy(item => "All");
|
||||
|
||||
foreach (var itemGroup in itemGroups)
|
||||
{
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
GUILayout.Space(20);
|
||||
if (Foldout(_itemGroupFoldouts.Contains(itemGroup.Key), FormatTypeName(itemGroup.Key), true))
|
||||
_itemGroupFoldouts.Add(itemGroup.Key);
|
||||
else _itemGroupFoldouts.Remove(itemGroup.Key);
|
||||
}
|
||||
|
||||
if (_itemGroupFoldouts.Contains(itemGroup.Key))
|
||||
{
|
||||
foreach (var item in itemGroup)
|
||||
{
|
||||
var style = ListItemStyle;
|
||||
var selected = SelectedItem == item.ID;
|
||||
using (new HorizontalScope(selected?SelectedStyle:style))
|
||||
{
|
||||
using (var h = new HorizontalScope())
|
||||
{
|
||||
if (h.rect.Contains(currentEvent.mousePosition))
|
||||
{
|
||||
if (currentEventType == EventType.MouseDrag)
|
||||
{
|
||||
DragAndDrop.PrepareStartDrag();
|
||||
DragAndDrop.SetGenericData("Item", item.ID);
|
||||
DragAndDrop.StartDrag("Database Item");
|
||||
}
|
||||
else if (currentEventType == EventType.MouseUp)
|
||||
Select(item);
|
||||
}
|
||||
|
||||
GUILayout.Space(30);
|
||||
GUILayout.Label(item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!typeof(EquippableItemData).IsAssignableFrom(_itemTypes[i]))
|
||||
throw new InvalidCastException($"Type {_itemTypes[i].Name} is invalid! Expected equippable item.");
|
||||
var typedItems = items
|
||||
.Where(e => e.GetType() == _itemTypes[i])
|
||||
.Cast<EquippableItemData>()
|
||||
.OrderBy(item => item.Name);
|
||||
var manufacturerGroups = typedItems.GroupBy(item => item.Manufacturer);
|
||||
foreach (var manufacturerGroup in manufacturerGroups)
|
||||
{
|
||||
var manufacturer = _databaseCache.Get<Faction>(manufacturerGroup.Key);
|
||||
var manufacturerName = manufacturer?.Name ?? "None";
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
GUILayout.Space(20);
|
||||
if (Foldout(_itemManufacturerFoldouts.Contains(manufacturerGroup.Key), manufacturerName, true))
|
||||
_itemManufacturerFoldouts.Add(manufacturerGroup.Key);
|
||||
else _itemManufacturerFoldouts.Remove(manufacturerGroup.Key);
|
||||
}
|
||||
|
||||
if (_itemManufacturerFoldouts.Contains(manufacturerGroup.Key))
|
||||
{
|
||||
if (_itemTypes[i] == typeof(GearData) || _itemTypes[i] == typeof(WeaponItemData))
|
||||
{
|
||||
var itemGroups = manufacturerGroup.GroupBy(item => item.HardpointType);
|
||||
|
||||
foreach (var itemGroup in itemGroups)
|
||||
{
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
GUILayout.Space(30);
|
||||
if (Foldout(_itemManufacturerTypeFoldouts.Contains((manufacturerGroup.Key, itemGroup.Key)), Enum.GetName(typeof(HardpointType), itemGroup.Key), true))
|
||||
_itemManufacturerTypeFoldouts.Add((manufacturerGroup.Key, itemGroup.Key));
|
||||
else _itemManufacturerTypeFoldouts.Remove((manufacturerGroup.Key, itemGroup.Key));
|
||||
}
|
||||
|
||||
if (_itemManufacturerTypeFoldouts.Contains((manufacturerGroup.Key, itemGroup.Key)))
|
||||
{
|
||||
foreach (var item in itemGroup)
|
||||
{
|
||||
var style = ListItemStyle;
|
||||
var selected = SelectedItem == item.ID;
|
||||
using (new HorizontalScope(selected?SelectedStyle:style))
|
||||
{
|
||||
using (var h = new HorizontalScope())
|
||||
{
|
||||
if (h.rect.Contains(currentEvent.mousePosition))
|
||||
{
|
||||
if (currentEventType == EventType.MouseDrag)
|
||||
{
|
||||
DragAndDrop.PrepareStartDrag();
|
||||
DragAndDrop.SetGenericData("Item", item.ID);
|
||||
DragAndDrop.StartDrag("Database Item");
|
||||
}
|
||||
else if (currentEventType == EventType.MouseUp)
|
||||
Select(item);
|
||||
}
|
||||
|
||||
GUILayout.Space(40);
|
||||
GUILayout.Label(item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in manufacturerGroup)
|
||||
{
|
||||
var style = ListItemStyle;
|
||||
var selected = SelectedItem == item.ID;
|
||||
using (new HorizontalScope(selected?SelectedStyle:style))
|
||||
{
|
||||
using (var h = new HorizontalScope())
|
||||
{
|
||||
if (h.rect.Contains(currentEvent.mousePosition))
|
||||
{
|
||||
if (currentEventType == EventType.MouseDrag)
|
||||
{
|
||||
DragAndDrop.PrepareStartDrag();
|
||||
DragAndDrop.SetGenericData("Item", item.ID);
|
||||
DragAndDrop.StartDrag("Database Item");
|
||||
}
|
||||
else if (currentEventType == EventType.MouseUp)
|
||||
Select(item);
|
||||
}
|
||||
|
||||
GUILayout.Space(30);
|
||||
GUILayout.Label(item.Name, selected ? EditorStyles.whiteLabel : GUI.skin.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
|
||||
CreateItem(_itemTypes[i]);
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label("New " + FormatTypeName(_itemTypes[i].Name));
|
||||
// var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
|
||||
// GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//var entries = _databaseCache.AllEntries.Where(item => !(item is ItemData)).ToArray();
|
||||
for (var i = 0; i < _entryTypes.Length; i++)
|
||||
{
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
_entryFoldouts[i] = Foldout(_entryFoldouts[i],
|
||||
_typeFoldouts[i] = Foldout(_typeFoldouts[i],
|
||||
((NameAttribute) _entryTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? FormatTypeName(_entryTypes[i].Name),
|
||||
true);
|
||||
}
|
||||
|
||||
if (_entryFoldouts[i])
|
||||
if (_typeFoldouts[i])
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var entry in _databaseCache.GetAll(_entryTypes[i]).OrderBy(entry=>entry is INamedEntry namedEntry ? namedEntry.EntryName : entry.ID.ToString()))
|
||||
// TODO: NESTED GROUPS!
|
||||
var entries = cultCache.GetAll(_entryTypes[i])
|
||||
.OrderBy(entry => entry is INamedEntry namedEntry ? namedEntry.EntryName : entry.ID.ToString());
|
||||
var grouper = Groupers.FirstOrDefault(g => g.CanGroup(_entryTypes[i]));
|
||||
if (grouper != null)
|
||||
{
|
||||
index++;
|
||||
var style = ListItemStyle;
|
||||
var selected = SelectedItem == entry.ID;
|
||||
using (var h = new HorizontalScope(selected?SelectedStyle:style))
|
||||
var groups = entries.GroupBy(o => grouper.SelectGroup(o));
|
||||
foreach (var group in groups)
|
||||
{
|
||||
if (h.rect.Contains(currentEvent.mousePosition))
|
||||
var groupHash = grouper.HashGroup(group.Key);
|
||||
var groupName = grouper.GetGroupName(group.Key);
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
if (currentEventType == EventType.MouseDrag)
|
||||
{
|
||||
DragAndDrop.PrepareStartDrag();
|
||||
DragAndDrop.SetGenericData("Item", entry.ID);
|
||||
DragAndDrop.StartDrag("Database Item");
|
||||
}
|
||||
else if (currentEventType == EventType.MouseUp)
|
||||
Select(entry);
|
||||
GUILayout.Space(10);
|
||||
if (Foldout(_groupFoldouts.Contains(groupHash), FormatTypeName(groupName), true))
|
||||
_groupFoldouts.Add(groupHash);
|
||||
else _groupFoldouts.Remove(groupHash);
|
||||
}
|
||||
|
||||
if (_groupFoldouts.Contains(groupHash))
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var entry in group)
|
||||
{
|
||||
index++;
|
||||
var style = ListItemStyle;
|
||||
var selected = SelectedItem == entry.ID;
|
||||
using (new HorizontalScope(selected?SelectedStyle:style))
|
||||
{
|
||||
using (var h = new HorizontalScope())
|
||||
{
|
||||
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(20);
|
||||
GUILayout.Label((entry as INamedEntry)?.EntryName ?? index.ToString(), selected ? EditorStyles.whiteLabel : GUI.skin.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
|
||||
CreateItem(_entryTypes[i], entry => grouper.Activate(entry, group.Key));
|
||||
GUILayout.Space(20);
|
||||
GUILayout.Label($"New {groupName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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(10);
|
||||
GUILayout.Label((entry as INamedEntry)?.EntryName ?? index.ToString(), selected ? EditorStyles.whiteLabel : GUI.skin.label);
|
||||
}
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label((entry as INamedEntry)?.EntryName ?? index.ToString(), selected ? EditorStyles.whiteLabel : GUI.skin.label);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -413,9 +304,7 @@ public class DatabaseListView : EditorWindow
|
|||
if(GUI.Button(h.rect, GUIContent.none, GUIStyle.none))
|
||||
CreateItem(_entryTypes[i]);
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("New " + _entryTypes[i].Name);
|
||||
// var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
|
||||
// GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
|
||||
GUILayout.Label($"New {_entryTypes[i].Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -434,7 +323,7 @@ public class DatabaseListView : EditorWindow
|
|||
{
|
||||
SelectedItem = item.ID;
|
||||
Repaint();
|
||||
_inspector.entry = _databaseCache.Get(SelectedItem);
|
||||
_inspector.entry = cultCache.Get(SelectedItem);
|
||||
_inspector.Repaint();
|
||||
}
|
||||
|
||||
|
|
@ -444,7 +333,7 @@ public class DatabaseListView : EditorWindow
|
|||
if(newEntry is INamedEntry entry)
|
||||
entry.EntryName = $"New {FormatTypeName(type.Name)}";
|
||||
onCreate?.Invoke(newEntry);
|
||||
_databaseCache.Add(newEntry);
|
||||
cultCache.Add(newEntry);
|
||||
Select(newEntry);
|
||||
return newEntry;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
public abstract class InspectorBase<T>
|
||||
{
|
||||
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);
|
||||
}
|
||||
183
Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs
Normal file
183
Assets/Scripts/CultCache/Editor/Inspectors/AetheriaInspectors.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class StatReferenceInspector : BaseInspector<StatReference>
|
||||
{
|
||||
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<PerformanceStat>
|
||||
{
|
||||
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<Shape>
|
||||
{
|
||||
private Material _schematicMat = new Material(Shader.Find("Legacy Shaders/Particles/Additive"));
|
||||
|
||||
public override Shape Inspect(string label, Shape value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
var hull = parent as HullData;
|
||||
if(value == null)
|
||||
{
|
||||
value = new Shape(1, 1);
|
||||
value[int2(0)] = true;
|
||||
}
|
||||
using (new VerticalScope())
|
||||
{
|
||||
Texture2D schematic = null;
|
||||
if(hull != null && !string.IsNullOrEmpty(hull.Schematic))
|
||||
schematic = AssetDatabase.LoadAssetAtPath<Texture2D>(hull.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(hull != null)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57d0bc090768458b9428efd7a8a33741
|
||||
timeCreated: 1617069994
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class AnimationCurveFloat4Inspector : BaseInspector<float4[]>
|
||||
{
|
||||
public override float4[] Inspect(string label, float4[] value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
var val = value != null && value.Length > 0
|
||||
? value.ToCurve()
|
||||
: new AnimationCurve();
|
||||
using (var h = new EditorGUILayout.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 AnimationCurveInspect : BaseInspector<AnimationCurve>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c89e0e7eb9f243cbbce28df59f6fb1c9
|
||||
timeCreated: 1617066399
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class DatabaseLinkInspector : BaseInspector<Guid, InspectableDatabaseLinkAttribute>
|
||||
{
|
||||
public override Guid Inspect(string label, Guid value, object parent, DatabaseInspector inspectorWindow, InspectableDatabaseLinkAttribute link)
|
||||
{
|
||||
LabelField(label, EditorStyles.boldLabel);
|
||||
var valueEntry = DatabaseInspector.CultCache.Get(value);
|
||||
using (var h = new HorizontalScope(GUI.skin.box))
|
||||
{
|
||||
GUILayout.Label((valueEntry as INamedEntry)?.EntryName ?? valueEntry?.ID.ToString() ?? $"Assign a {link.EntryType.Name} by dragging from the list panel.");
|
||||
|
||||
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<T> : BaseInspector<DatabaseLink<T>> where T : DatabaseEntry
|
||||
{
|
||||
public override DatabaseLink<T> Inspect(string label, DatabaseLink<T> value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
if (value == null)
|
||||
value = new DatabaseLink<T>{Cache = DatabaseInspector.CultCache};
|
||||
LabelField(label, EditorStyles.boldLabel);
|
||||
var valueEntry = value.Value;
|
||||
using (var h = new HorizontalScope(GUI.skin.box))
|
||||
{
|
||||
GUILayout.Label((valueEntry as INamedEntry)?.EntryName ?? valueEntry?.ID.ToString() ?? $"Assign a {typeof(T).Name} by dragging from the list panel.");
|
||||
|
||||
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 (GUILayout.Button("-", GUILayout.Width((EditorGUIUtility.singleLineHeight - 3)*2), GUILayout.Height(EditorGUIUtility.singleLineHeight-3)))
|
||||
{
|
||||
value.LinkID = Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public class DatabaseLinkListInspector : BaseInspector<List<Guid>, InspectableDatabaseLinkAttribute>
|
||||
{
|
||||
private bool _listItemStyle;
|
||||
public GUIStyle ListItemStyle =>
|
||||
(_listItemStyle = !_listItemStyle) ? DatabaseListView.ListStyleEven : DatabaseListView.ListStyleOdd;
|
||||
|
||||
public override List<Guid> Inspect(string label,
|
||||
List<Guid> value,
|
||||
object parent,
|
||||
DatabaseInspector inspectorWindow,
|
||||
InspectableDatabaseLinkAttribute link)
|
||||
{
|
||||
Space();
|
||||
LabelField(label, EditorStyles.boldLabel);
|
||||
|
||||
using (var v = new VerticalScope(GUI.skin.box))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5e08712ea4854536b130f82ad61db7a8
|
||||
timeCreated: 1617069551
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class FloatDictionaryInspector : BaseInspector<Dictionary<Guid, float>, InspectableDatabaseLinkAttribute>
|
||||
{
|
||||
private bool _listItemStyle;
|
||||
public GUIStyle ListItemStyle =>
|
||||
(_listItemStyle = !_listItemStyle) ? DatabaseListView.ListStyleEven : DatabaseListView.ListStyleOdd;
|
||||
|
||||
public override Dictionary<Guid, float> Inspect(string label,
|
||||
Dictionary<Guid, float> 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(ListItemStyle))
|
||||
{
|
||||
GUILayout.Label("Drag from list to add item");
|
||||
}
|
||||
}
|
||||
foreach (var ingredient in value.ToArray())
|
||||
{
|
||||
using (new HorizontalScope(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 guid;
|
||||
var dragEntry = isId ? DatabaseInspector.CultCache.Get(guid) : 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] = 1;
|
||||
GUI.changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public class RangedFloatDictionaryInspector : BaseInspector<Dictionary<Guid, float>, InspectableDatabaseLinkAttribute, RangedFloatAttribute>
|
||||
{
|
||||
private bool _listItemStyle;
|
||||
public GUIStyle ListItemStyle =>
|
||||
(_listItemStyle = !_listItemStyle) ? DatabaseListView.ListStyleEven : DatabaseListView.ListStyleOdd;
|
||||
|
||||
public override Dictionary<Guid, float> Inspect(string label,
|
||||
Dictionary<Guid, float> 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(ListItemStyle))
|
||||
{
|
||||
GUILayout.Label("Drag from list to add item");
|
||||
}
|
||||
}
|
||||
foreach (var ingredient in value.ToArray())
|
||||
{
|
||||
using (new HorizontalScope(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 guid;
|
||||
var dragEntry = isId ? DatabaseInspector.CultCache.Get(guid) : 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] = range.Max;
|
||||
GUI.changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public class IntDictionaryInspector : BaseInspector<Dictionary<Guid, int>, InspectableDatabaseLinkAttribute>
|
||||
{
|
||||
private bool _listItemStyle;
|
||||
public GUIStyle ListItemStyle =>
|
||||
(_listItemStyle = !_listItemStyle) ? DatabaseListView.ListStyleEven : DatabaseListView.ListStyleOdd;
|
||||
|
||||
public override Dictionary<Guid, int> Inspect(string label,
|
||||
Dictionary<Guid, int> 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(ListItemStyle))
|
||||
{
|
||||
GUILayout.Label("Drag from list to add item");
|
||||
}
|
||||
}
|
||||
foreach (var ingredient in value.ToArray())
|
||||
{
|
||||
using (var h = new HorizontalScope(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 guid;
|
||||
var dragEntry = isId ? DatabaseInspector.CultCache.Get(guid) : 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] = 1;
|
||||
GUI.changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a42620fd406045889578e2ad8d5fd8de
|
||||
timeCreated: 1617067689
|
||||
54
Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs
Normal file
54
Assets/Scripts/CultCache/Editor/Inspectors/FloatInspector.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class FloatInspector : BaseInspector<float>
|
||||
{
|
||||
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<float, RangedFloatInspectableAttribute>
|
||||
{
|
||||
public override float Inspect(string label,
|
||||
float value,
|
||||
object parent,
|
||||
DatabaseInspector inspectorWindow,
|
||||
RangedFloatInspectableAttribute attribute)
|
||||
{
|
||||
using (new HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(label, GUILayout.Width(width));
|
||||
return Slider(value, attribute.Min, attribute.Max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TemperatureFloatInspector : BaseInspector<float, InspectableTemperatureAttribute>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 47b8e5bc90714055881eb31baf2ab879
|
||||
timeCreated: 1617065074
|
||||
27
Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs
Normal file
27
Assets/Scripts/CultCache/Editor/Inspectors/IntInspector.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class IntInspector : BaseInspector<int>
|
||||
{
|
||||
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 RangedIntInspector : BaseInspector<int, RangedIntInspectableAttribute>
|
||||
{
|
||||
public override int Inspect(string label, int value, object parent, DatabaseInspector inspectorWindow, RangedIntInspectableAttribute attribute)
|
||||
{
|
||||
using (new HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(label, GUILayout.Width(width));
|
||||
return IntSlider(value, attribute.Min, attribute.Max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ac7d3b8651964ce1a732a002447d6f69
|
||||
timeCreated: 1617065365
|
||||
142
Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs
Normal file
142
Assets/Scripts/CultCache/Editor/Inspectors/ListInspector.cs
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
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<T> : BaseInspector<List<T>>
|
||||
{
|
||||
private bool _listItemStyle;
|
||||
private static HashSet<int> _listItemFoldouts = new HashSet<int>();
|
||||
public GUIStyle ListItemStyle =>
|
||||
(_listItemStyle = !_listItemStyle) ? DatabaseListView.ListStyleEven : DatabaseListView.ListStyleOdd;
|
||||
|
||||
public override List<T> Inspect(string label, List<T> list, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
var listType = typeof(T);
|
||||
if (listType.GetCustomAttribute<InspectableAttribute>() != null)
|
||||
{
|
||||
Space();
|
||||
using (new VerticalScope(GUI.skin.box))
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = new List<T>();
|
||||
}
|
||||
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<OrderAttribute>()?.Order ?? 0;
|
||||
if (elementOrder < order)
|
||||
sorted = false;
|
||||
order = elementOrder;
|
||||
}
|
||||
|
||||
if (!sorted)
|
||||
{
|
||||
list.Sort((x, y) => (x.GetType().GetCustomAttribute<OrderAttribute>()?.Order ?? 0).CompareTo(y.GetType().GetCustomAttribute<OrderAttribute>()?.Order ?? 0));
|
||||
}
|
||||
}
|
||||
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(ListItemStyle))
|
||||
{
|
||||
using (new HorizontalScope())
|
||||
{
|
||||
//if (listType.IsInterface)
|
||||
if(Foldout(_listItemFoldouts.Contains(o.GetHashCode()), o.ToString(), true))
|
||||
_listItemFoldouts.Add(o.GetHashCode());
|
||||
else
|
||||
_listItemFoldouts.Remove(o.GetHashCode());
|
||||
|
||||
|
||||
// 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)))
|
||||
{
|
||||
list.Remove(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(_listItemFoldouts.Contains(o.GetHashCode()))
|
||||
{
|
||||
Space();
|
||||
|
||||
inspectorWindow.Inspect(o, true);
|
||||
}
|
||||
}
|
||||
|
||||
if(_tinted)
|
||||
GUI.backgroundColor = originalColor;
|
||||
}
|
||||
using (new HorizontalScope(ListItemStyle))
|
||||
{
|
||||
GUILayout.Label($"Add new {listType.Name}", 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.IsInterface)
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
foreach (var childType in listType.GetAllInterfaceClasses())
|
||||
{
|
||||
menu.AddItem(new GUIContent(childType.Name), false, () =>
|
||||
{
|
||||
list.Add((T)Activator.CreateInstance(childType));
|
||||
});
|
||||
}
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
else if (listType.IsAbstract)
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
foreach (var childType in listType.GetAllChildClasses().Where(t=>!t.IsAbstract))
|
||||
{
|
||||
menu.AddItem(new GUIContent(childType.Name), false, () =>
|
||||
{
|
||||
list.Add((T)Activator.CreateInstance(childType));
|
||||
});
|
||||
}
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(Activator.CreateInstance<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else Debug.Log($"Field \"{label}\" is a list of non-Inspectable type {listType.Name}. No inspector was generated.");
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 551335721057411d942b3317ae028546
|
||||
timeCreated: 1617145746
|
||||
|
|
@ -3,11 +3,12 @@ using UnityEditor;
|
|||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class Float2Inspector : InspectorBase<float2>
|
||||
|
||||
public class Float2Inspector : BaseInspector<float2>
|
||||
{
|
||||
public override float2 Inspect(string label, float2 value)
|
||||
public override float2 Inspect(string label, float2 value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
using (var h = new EditorGUILayout.HorizontalScope())
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(label, GUILayout.Width(width));
|
||||
GUILayout.Label("X", GUILayout.Width(labelWidth));
|
||||
|
|
@ -19,27 +20,49 @@ public class Float2Inspector : InspectorBase<float2>
|
|||
}
|
||||
}
|
||||
|
||||
public class Float3Inspector : InspectorBase<float3>
|
||||
public class Float3Inspector : BaseInspector<float3>
|
||||
{
|
||||
public override float3 Inspect(string label, float3 value)
|
||||
public override float3 Inspect(string label, float3 value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
using (var h = new EditorGUILayout.HorizontalScope())
|
||||
using (new EditorGUILayout.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 Int2Inspector : InspectorBase<int2>
|
||||
public class Float4Inspector : BaseInspector<float4>
|
||||
{
|
||||
public override int2 Inspect(string label, int2 value)
|
||||
public override float4 Inspect(string label, float4 value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
using (var h = new EditorGUILayout.HorizontalScope())
|
||||
using (new EditorGUILayout.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 Int2Inspector : BaseInspector<int2>
|
||||
{
|
||||
public override int2 Inspect(string label, int2 value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
GUILayout.Label(label, GUILayout.Width(width));
|
||||
GUILayout.Label("X", GUILayout.Width(labelWidth));
|
||||
|
|
@ -57,4 +80,42 @@ public class Int2Inspector : InspectorBase<int2>
|
|||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Int3Inspector : BaseInspector<int3>
|
||||
{
|
||||
public override int3 Inspect(string label, int3 value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
using (new EditorGUILayout.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<int4>
|
||||
{
|
||||
public override int4 Inspect(string label, int4 value, object parent, DatabaseInspector inspectorWindow)
|
||||
{
|
||||
using (new EditorGUILayout.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class BoolInspector : BaseInspector<bool>
|
||||
{
|
||||
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<string>
|
||||
{
|
||||
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<string, InspectableTextAttribute>
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 91dcbfa1679e4be1944d6856ca63bf13
|
||||
timeCreated: 1617065181
|
||||
23
Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs
Normal file
23
Assets/Scripts/CultCache/Editor/Inspectors/TypeInspector.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class TypeInspector : BaseInspector<Type, InspectableTypeAttribute>
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4762384a61dc4d08a1ba4e7564a20081
|
||||
timeCreated: 1617066802
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static UnityEditor.EditorGUILayout;
|
||||
|
||||
public class TextureInspector : BaseInspector<string, InspectableTextureAttribute>
|
||||
{
|
||||
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<Texture2D>(value), typeof(Texture2D), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GameObjectInspector : BaseInspector<string, InspectablePrefabAttribute>
|
||||
{
|
||||
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<GameObject>(value), typeof(GameObject), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TextAssetInspector : BaseInspector<string, InspectableTextAssetAttribute>
|
||||
{
|
||||
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<TextAsset>(value), typeof(TextAsset), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8519fa7d4f06468bb9be151f053d1fcb
|
||||
timeCreated: 1617067005
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -17,10 +18,9 @@ public static class RethinkConnection
|
|||
{
|
||||
public static RethinkDB R = RethinkDB.R;
|
||||
|
||||
public static RethinkQueryStatus RethinkConnect(DatabaseCache cache, string connectionString, bool syncLocalChanges = true)
|
||||
public static RethinkQueryStatus RethinkConnect(CultCache cache, string connectionString, string dbName, bool syncLocalChanges = true)
|
||||
{
|
||||
// Add Unity.Mathematics serialization support to RethinkDB Driver
|
||||
//Converter.Serializer.Converters.Add(new MathJsonConverter());
|
||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||
{
|
||||
Converters = new List<JsonConverter>
|
||||
|
|
@ -32,10 +32,28 @@ public static class RethinkConnection
|
|||
Converter.PocoExprConverter
|
||||
}
|
||||
};
|
||||
|
||||
var syncTables = typeof(DatabaseEntry).GetAllChildClasses()
|
||||
.Select(t => t.GetCustomAttribute<RethinkTableAttribute>()?.TableName ?? "Default").Distinct();
|
||||
|
||||
var connectionStringDomainLength = connectionString.IndexOf(':');
|
||||
if (connectionStringDomainLength < 1)
|
||||
throw new ArgumentException("Illegal Connection String: must include port!");
|
||||
|
||||
var connection = R.Connection().Hostname(connectionString).Port(RethinkDBConstants.DefaultPort+1).Timeout(60).Connect();
|
||||
var portString = connectionString.Substring(connectionStringDomainLength + 1);
|
||||
if (!int.TryParse(portString, out var port))
|
||||
throw new ArgumentException($"Illegal connection string! \"{portString}\" is not a valid port number!");
|
||||
|
||||
var connection = R.Connection()
|
||||
.Hostname(connectionString.Substring(0,connectionStringDomainLength))
|
||||
.Port(port).Timeout(60).Connect();
|
||||
Debug.Log("Connected to RethinkDB");
|
||||
|
||||
var tables = R.Db(dbName).TableList().RunAtom<string[]>(connection);
|
||||
|
||||
foreach (var st in syncTables.Where(st => !tables.Contains(st)))
|
||||
R.Db(dbName).TableCreate(st).RunNoReply(connection);
|
||||
|
||||
if (syncLocalChanges)
|
||||
{
|
||||
// When entries are changed locally, push the changes to RethinkDB
|
||||
|
|
@ -77,66 +95,51 @@ public static class RethinkConnection
|
|||
|
||||
var status = new RethinkQueryStatus();
|
||||
|
||||
// Get all item data from RethinkDB
|
||||
Task.Run(async () =>
|
||||
foreach (var table in syncTables)
|
||||
{
|
||||
status.ItemsEntries = R
|
||||
.Db("Aetheria")
|
||||
.Table("Items")
|
||||
.Count().RunAtom<int>(connection);
|
||||
// Get entries from RethinkDB
|
||||
Task.Run(async () =>
|
||||
{
|
||||
status.TotalEntries += R
|
||||
.Db("Aetheria")
|
||||
.Table(table)
|
||||
.Count().RunAtom<int>(connection);
|
||||
|
||||
var result = await R
|
||||
.Db("Aetheria")
|
||||
.Table("Items")
|
||||
.RunCursorAsync<DatabaseEntry>(connection);
|
||||
while (await result.MoveNextAsync())
|
||||
{
|
||||
var entry = result.Current;
|
||||
//Debug.Log($"Received Items entry from RethinkDB: {entry.GetType()} {(entry as INamedEntry)?.EntryName ?? ""}:{entry.ID}");
|
||||
cache.Add(entry, true);
|
||||
status.RetrievedItems++;
|
||||
}
|
||||
}).WrapAwait();
|
||||
|
||||
// Get globaldata and all galaxy map layer data from RethinkDB
|
||||
Task.Run(async () =>
|
||||
{
|
||||
ReqlAst operation = R
|
||||
.Db("Aetheria")
|
||||
.Table("Galaxy");
|
||||
status.GalaxyEntries = ((Table) operation).Count().RunAtom<int>(connection);
|
||||
var result = await R
|
||||
.Db("Aetheria")
|
||||
.Table(table)
|
||||
.RunCursorAsync<DatabaseEntry>(connection);
|
||||
while (await result.MoveNextAsync())
|
||||
{
|
||||
var entry = result.Current;
|
||||
//Debug.Log($"Received Items entry from RethinkDB: {entry.GetType()} {(entry as INamedEntry)?.EntryName ?? ""}:{entry.ID}");
|
||||
cache.Add(entry, true);
|
||||
status.RetrievedEntries++;
|
||||
}
|
||||
}).WrapAwait();
|
||||
|
||||
var result = await operation
|
||||
.RunCursorAsync<DatabaseEntry>(connection);
|
||||
while (await result.MoveNextAsync())
|
||||
// Subscribe to changes from RethinkDB
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var entry = result.Current;
|
||||
//Debug.Log($"Received Galaxy entry from RethinkDB: {entry.GetType()} {(entry as INamedEntry)?.EntryName ?? ""}:{entry.ID}");
|
||||
cache.Add(entry, true);
|
||||
status.RetrievedItems++;
|
||||
}
|
||||
}).WrapAwait();
|
||||
var result = await R
|
||||
.Db("Aetheria")
|
||||
.Table(table)
|
||||
.Changes()
|
||||
.RunChangesAsync<DatabaseEntry>(connection);
|
||||
while (await result.MoveNextAsync())
|
||||
{
|
||||
var change = result.Current;
|
||||
if(change.OldValue == null)
|
||||
Debug.Log($"Received change from RethinkDB (Entry Created): {change.NewValue.ID}");
|
||||
else if(change.NewValue == null)
|
||||
Debug.Log($"Received change from RethinkDB (Entry Deleted): {change.OldValue.ID}");
|
||||
else
|
||||
Debug.Log($"Received change from RethinkDB: {change.NewValue.ID}");
|
||||
cache.Add(change.NewValue, true);
|
||||
}
|
||||
}).WrapAwait();
|
||||
}
|
||||
|
||||
// Subscribe to changes from RethinkDB
|
||||
Task.Run(async () =>
|
||||
{
|
||||
var result = await R
|
||||
.Db("Aetheria")
|
||||
.Table("Items")
|
||||
.Changes()
|
||||
.RunChangesAsync<DatabaseEntry>(connection);
|
||||
while (await result.MoveNextAsync())
|
||||
{
|
||||
var change = result.Current;
|
||||
if(change.OldValue == null)
|
||||
Debug.Log($"Received change from RethinkDB (Entry Created): {change.NewValue.ID}");
|
||||
else if(change.NewValue == null)
|
||||
Debug.Log($"Received change from RethinkDB (Entry Deleted): {change.OldValue.ID}");
|
||||
else
|
||||
Debug.Log($"Received change from RethinkDB: {change.NewValue.ID}");
|
||||
cache.Add(change.NewValue, true);
|
||||
}
|
||||
}).WrapAwait();
|
||||
|
||||
// Observable.Timer(DateTimeOffset.Now, TimeSpan.FromSeconds(60)).Subscribe(_ =>
|
||||
// {
|
||||
|
|
@ -149,7 +152,6 @@ public static class RethinkConnection
|
|||
|
||||
public class RethinkQueryStatus
|
||||
{
|
||||
public int RetrievedItems;
|
||||
public int GalaxyEntries;
|
||||
public int ItemsEntries;
|
||||
public int RetrievedEntries;
|
||||
public int TotalEntries;
|
||||
}
|
||||
|
|
@ -31,18 +31,18 @@ public class ActionGameManager : MonoBehaviour
|
|||
get => _gameDataDirectory ??= new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
|
||||
}
|
||||
|
||||
private static DatabaseCache _database;
|
||||
private static CultCache _cultCache;
|
||||
|
||||
public static DatabaseCache Database
|
||||
public static CultCache CultCache
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_database != null) return _database;
|
||||
if (_cultCache != null) return _cultCache;
|
||||
|
||||
_database = new DatabaseCache(Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack"));
|
||||
_database.Load();
|
||||
_cultCache = new CultCache(Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack"));
|
||||
_cultCache.Load();
|
||||
|
||||
return _database;
|
||||
return _cultCache;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
AkSoundEngine.RegisterGameObj(gameObject);
|
||||
ConsoleController.MessageReceiver = this;
|
||||
|
||||
ItemManager = new ItemManager(Database, Settings.GameplaySettings, Debug.Log);
|
||||
ItemManager = new ItemManager(CultCache, Settings.GameplaySettings, Debug.Log);
|
||||
ZoneRenderer.ItemManager = ItemManager;
|
||||
|
||||
// _loadoutPath = GameDataDirectory.CreateSubdirectory("Loadouts");
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class MainMenu : MonoBehaviour
|
|||
_nextMenu.panel.AddButton("Continue",
|
||||
() =>
|
||||
{
|
||||
ActionGameManager.CurrentSector = new Sector(ActionGameManager.Database, ActionGameManager.PlayerSettings.CurrentRun);
|
||||
ActionGameManager.CurrentSector = new Sector(ActionGameManager.CultCache, ActionGameManager.PlayerSettings.CurrentRun);
|
||||
SceneManager.LoadScene("ARPG");
|
||||
});
|
||||
else
|
||||
|
|
@ -116,7 +116,7 @@ public class MainMenu : MonoBehaviour
|
|||
Dialog.Show();
|
||||
Settings.SectorGenerationSettings.NoisePosition = Random.value * 100;
|
||||
|
||||
var task = Task.Run(() => new Sector(Settings.SectorGenerationSettings, ActionGameManager.Database, 0, setState));
|
||||
var task = Task.Run(() => new Sector(Settings.SectorGenerationSettings, ActionGameManager.CultCache, 0, setState));
|
||||
task.ContinueWith(task => Observable.NextFrame().Subscribe(_ =>
|
||||
{
|
||||
ActionGameManager.PlayerSettings.CurrentRun = null;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class AutoWeaponData : InstantWeaponData
|
||||
{
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public abstract class PersistentBehaviorData
|
|||
{
|
||||
}
|
||||
|
||||
[InspectableField,
|
||||
[Inspectable,
|
||||
Union(0, typeof(GuidedWeaponData)),
|
||||
Union(1, typeof(LauncherData)),
|
||||
Union(2, typeof(ReactorData)),
|
||||
|
|
@ -125,7 +125,7 @@ public abstract class PersistentBehaviorData
|
|||
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
|
||||
public abstract class BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("group"), Key(0)]
|
||||
[Inspectable, JsonProperty("group"), Key(0)]
|
||||
public int Group;
|
||||
|
||||
public abstract IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class CapacitorData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("capacity"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("capacity"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Capacity = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat Efficiency = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -6,43 +6,43 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class ChargedWeaponData : InstantWeaponData
|
||||
{
|
||||
[InspectableField, JsonProperty("chargeTime"), Key(21), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("chargeTime"), Key(21), RuntimeInspectable]
|
||||
public PerformanceStat ChargeTime = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("chargeEnergy"), Key(22), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("chargeEnergy"), Key(22), RuntimeInspectable]
|
||||
public PerformanceStat ChargeEnergy = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("chargeHeat"), Key(23), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("chargeHeat"), Key(23), RuntimeInspectable]
|
||||
public PerformanceStat ChargeHeat = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("canFireEarly"), Key(24)]
|
||||
[Inspectable, JsonProperty("canFireEarly"), Key(24)]
|
||||
public bool CanFireEarly;
|
||||
|
||||
[InspectableField, JsonProperty("failureCharge"), Key(25)]
|
||||
[Inspectable, JsonProperty("failureCharge"), Key(25)]
|
||||
public float FailureCharge;
|
||||
|
||||
[InspectableField, JsonProperty("failureDamage"), Key(26)]
|
||||
[Inspectable, JsonProperty("failureDamage"), Key(26)]
|
||||
public float FailureDamage = 1;
|
||||
|
||||
[InspectableField, JsonProperty("chargeDamage"), Key(27)]
|
||||
[Inspectable, JsonProperty("chargeDamage"), Key(27)]
|
||||
public float ChargeFiringDamageMultiplier = 1;
|
||||
|
||||
[InspectableField, JsonProperty("chargeSpread"), Key(28)]
|
||||
[Inspectable, JsonProperty("chargeSpread"), Key(28)]
|
||||
public float ChargeFiringSpreadMultiplier = 1;
|
||||
|
||||
[InspectableField, JsonProperty("chargeBurstCount"), Key(29)]
|
||||
[Inspectable, JsonProperty("chargeBurstCount"), Key(29)]
|
||||
public float ChargeFiringBurstCountMultiplier = 1;
|
||||
|
||||
[InspectableField, JsonProperty("chargeVisibility"), Key(30)]
|
||||
[Inspectable, JsonProperty("chargeVisibility"), Key(30)]
|
||||
public float ChargeFiringVisibilityMultiplier = 1;
|
||||
|
||||
[InspectableField, JsonProperty("chargeVelocity"), Key(31)]
|
||||
[Inspectable, JsonProperty("chargeVelocity"), Key(31)]
|
||||
public float ChargeFiringVelocityMultiplier = 1;
|
||||
|
||||
[InspectableField, JsonProperty("chargeHeatMul"), Key(32)]
|
||||
[Inspectable, JsonProperty("chargeHeatMul"), Key(32)]
|
||||
public float ChargeFiringHeatMultiplier = 1;
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class ConstantWeaponData : WeaponData
|
||||
{
|
||||
[InspectablePrefab, JsonProperty("ammoInterval"), Key(17)]
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-10), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-10), RuntimeInspectable]
|
||||
public class CooldownData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("cooldown"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("cooldown"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Cooldown = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20), RuntimeInspectable]
|
||||
public class EnergyDrawData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("draw"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("draw"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat EnergyDraw = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("perSecond"), Key(2)]
|
||||
[Inspectable, JsonProperty("perSecond"), Key(2)]
|
||||
public bool PerSecond;
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10), Inspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
|
||||
public class HeatData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("heat"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("heat"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Heat = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("perSecond"), Key(2)]
|
||||
[Inspectable, JsonProperty("perSecond"), Key(2)]
|
||||
public bool PerSecond;
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class InstantWeaponData : WeaponData
|
||||
{
|
||||
[InspectableField, JsonProperty("count"), Key(17)]
|
||||
[Inspectable, JsonProperty("count"), Key(17)]
|
||||
public PerformanceStat Count = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("burstTime"), Key(18)]
|
||||
[Inspectable, JsonProperty("burstTime"), Key(18)]
|
||||
public PerformanceStat BurstTime = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("cooldown"), Key(19), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("cooldown"), Key(19), RuntimeInspectable]
|
||||
public PerformanceStat Cooldown = new PerformanceStat();
|
||||
|
||||
[InspectablePrefab, JsonProperty("ammoInterval"), Key(20)]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-5), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-5), RuntimeInspectable]
|
||||
public class ItemUsageData : BehaviorData
|
||||
{
|
||||
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("item"), Key(1), RuntimeInspectable]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using MessagePack;
|
|||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class LauncherData : LockWeaponData
|
||||
{
|
||||
[InspectableAnimationCurve, JsonProperty("guidance"), Key(26)]
|
||||
|
|
@ -18,13 +18,13 @@ public class LauncherData : LockWeaponData
|
|||
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(28)]
|
||||
public float4[] LiftCurve;
|
||||
|
||||
[InspectableField, JsonProperty("thrust"), Key(29)]
|
||||
[Inspectable, JsonProperty("thrust"), Key(29)]
|
||||
public PerformanceStat Thrust = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("frequency"), Key(30)]
|
||||
[Inspectable, JsonProperty("frequency"), Key(30)]
|
||||
public float DodgeFrequency;
|
||||
|
||||
[InspectableField, JsonProperty("missileSpeed"), Key(31), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("missileSpeed"), Key(31), RuntimeInspectable]
|
||||
public PerformanceStat MissileVelocity = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
@ -33,7 +33,7 @@ public class LauncherData : LockWeaponData
|
|||
}
|
||||
}
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class GuidedWeaponData : InstantWeaponData
|
||||
{
|
||||
[InspectableAnimationCurve, JsonProperty("guidance"), Key(21)]
|
||||
|
|
@ -45,13 +45,13 @@ public class GuidedWeaponData : InstantWeaponData
|
|||
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(23)]
|
||||
public float4[] LiftCurve;
|
||||
|
||||
[InspectableField, JsonProperty("thrust"), Key(24)]
|
||||
[Inspectable, JsonProperty("thrust"), Key(24)]
|
||||
public PerformanceStat Thrust = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("frequency"), Key(25)]
|
||||
[Inspectable, JsonProperty("frequency"), Key(25)]
|
||||
public float DodgeFrequency;
|
||||
|
||||
[InspectableField, JsonProperty("missileSpeed"), Key(26), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("missileSpeed"), Key(26), RuntimeInspectable]
|
||||
public PerformanceStat MissileVelocity = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class LockWeaponData : InstantWeaponData
|
||||
{
|
||||
[InspectableField, JsonProperty("speed"), Key(21), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("speed"), Key(21), RuntimeInspectable]
|
||||
public PerformanceStat LockSpeed = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("sensorImpact"), Key(22)]
|
||||
[Inspectable, JsonProperty("sensorImpact"), Key(22)]
|
||||
public PerformanceStat SensorImpact = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("threshold"), Key(23), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("threshold"), Key(23), RuntimeInspectable]
|
||||
public PerformanceStat LockAngle = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("directionImpact"), Key(24)]
|
||||
[Inspectable, JsonProperty("directionImpact"), Key(24)]
|
||||
public PerformanceStat DirectionImpact = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("decay"), Key(25)]
|
||||
[Inspectable, JsonProperty("decay"), Key(25)]
|
||||
public PerformanceStat Decay = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
|
||||
public class MiningToolData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("dps"), Key(1)]
|
||||
[Inspectable, JsonProperty("dps"), Key(1)]
|
||||
public PerformanceStat DamagePerSecond = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("efficiency"), Key(2)]
|
||||
[Inspectable, JsonProperty("efficiency"), Key(2)]
|
||||
public PerformanceStat Efficiency = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("penetration"), Key(3)]
|
||||
[Inspectable, JsonProperty("penetration"), Key(3)]
|
||||
public PerformanceStat Penetration = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("range"), Key(4)]
|
||||
[Inspectable, JsonProperty("range"), Key(4)]
|
||||
public PerformanceStat Range = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class RadianceData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("radiance"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("radiance"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Radiance = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class RadiatorData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Emissivity = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("pumpedHeat"), Key(2), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("pumpedHeat"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat PumpedHeat = new PerformanceStat();
|
||||
|
||||
[InspectableTemperature, JsonProperty("temperatureFloor"), Key(3), RuntimeInspectable]
|
||||
public float TemperatureFloor;
|
||||
|
||||
[InspectableField, JsonProperty("wasteHeat"), Key(4), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("wasteHeat"), Key(4), RuntimeInspectable]
|
||||
public PerformanceStat WasteHeat = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("energyUsage"), Key(5), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("energyUsage"), Key(5), RuntimeInspectable]
|
||||
public PerformanceStat EnergyUsage = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class ReactorData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("charge"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("charge"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Charge = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat Efficiency = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("overload"), Key(3), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("overload"), Key(3), RuntimeInspectable]
|
||||
public PerformanceStat OverloadEfficiency = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("underload"), Key(4), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("underload"), Key(4), RuntimeInspectable]
|
||||
public PerformanceStat ThrottlingFactor = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class ReflectorData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("crossSection"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("crossSection"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat CrossSection = new PerformanceStat();
|
||||
|
||||
// [InspectableAnimationCurve, JsonProperty("visibility"), Key(1)]
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class ResourceScannerData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("range"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("range"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Range = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("minDensity"), Key(2), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("minDensity"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat MinimumDensity = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("scanDuration"), Key(3), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("scanDuration"), Key(3), RuntimeInspectable]
|
||||
public PerformanceStat ScanDuration = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -9,34 +9,34 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class SensorData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("sensitivity"), Key(3), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("sensitivity"), Key(3), RuntimeInspectable]
|
||||
public PerformanceStat Sensitivity = new PerformanceStat();
|
||||
|
||||
[InspectableAnimationCurve, JsonProperty("sensitivityCurve"), Key(4), RuntimeInspectable]
|
||||
public float4[] SensitivityCurve;
|
||||
|
||||
[InspectableField, JsonProperty("pingBoost"), Key(5), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("pingBoost"), Key(5), RuntimeInspectable]
|
||||
public PerformanceStat PingBoost;
|
||||
|
||||
[InspectableField, JsonProperty("pingEnergy"), Key(6), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("pingEnergy"), Key(6), RuntimeInspectable]
|
||||
public PerformanceStat PingEnergy;
|
||||
|
||||
[InspectableField, JsonProperty("pingVisibility"), Key(7), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("pingVisibility"), Key(7), RuntimeInspectable]
|
||||
public PerformanceStat PingVisibility;
|
||||
|
||||
[InspectableField, JsonProperty("pingRange"), Key(8), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("pingRange"), Key(8), RuntimeInspectable]
|
||||
public PerformanceStat PingRange;
|
||||
|
||||
[InspectableField, JsonProperty("pingCooldown"), Key(9), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("pingCooldown"), Key(9), RuntimeInspectable]
|
||||
public PerformanceStat PingCooldown;
|
||||
|
||||
[InspectableField, JsonProperty("pingDuration"), Key(10)]
|
||||
[Inspectable, JsonProperty("pingDuration"), Key(10)]
|
||||
public float PingDuration = 2;
|
||||
|
||||
[InspectableField, JsonProperty("pingRadiusExponent"), Key(11)]
|
||||
[Inspectable, JsonProperty("pingRadiusExponent"), Key(11)]
|
||||
public float PingRadiusExponent = .5f;
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class ShieldData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("efficiency"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("efficiency"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Efficiency = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("energy"), Key(2), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("energy"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat EnergyUsage = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class StatModifierData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("stat"), Key(1)]
|
||||
[Inspectable, JsonProperty("stat"), Key(1)]
|
||||
public StatReference Stat = new StatReference();
|
||||
|
||||
[InspectableField, JsonProperty("modifier"), Key(2)]
|
||||
[Inspectable, JsonProperty("modifier"), Key(2)]
|
||||
public PerformanceStat Modifier = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("type"), Key(3)]
|
||||
[Inspectable, JsonProperty("type"), Key(3)]
|
||||
public StatModifierType Type;
|
||||
|
||||
[InspectableType(typeof(BehaviorData)), JsonProperty("requireBehavior"), Key(4)]
|
||||
|
|
@ -103,12 +103,12 @@ public enum StatModifierType
|
|||
Multiplier
|
||||
}
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class StatReference
|
||||
{
|
||||
[InspectableType(typeof(BehaviorData)), JsonProperty("behavior"), Key(1)]
|
||||
public string Target;
|
||||
|
||||
[InspectableField, JsonProperty("stat"), Key(2)]
|
||||
[Inspectable, JsonProperty("stat"), Key(2)]
|
||||
public string Stat;
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-25)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-25)]
|
||||
public class SwitchData : BehaviorData
|
||||
{
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
|
||||
public class ThermotoggleData : BehaviorData
|
||||
{
|
||||
[InspectableTemperature, JsonProperty("targetTemp"), Key(1)]
|
||||
public float TargetTemperature;
|
||||
|
||||
[InspectableField, JsonProperty("highPass"), Key(2)]
|
||||
[Inspectable, JsonProperty("highPass"), Key(2)]
|
||||
public bool HighPass;
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
|
||||
public class ThrusterData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("thrust"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("thrust"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Thrust = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("visibility"), Key(2), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("visibility"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat Visibility = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("heat"), Key(3), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("heat"), Key(3), RuntimeInspectable]
|
||||
public PerformanceStat Heat = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("energy"), Key(4), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("energy"), Key(4), RuntimeInspectable]
|
||||
public PerformanceStat EnergyUsage = new PerformanceStat();
|
||||
|
||||
[InspectablePrefab, JsonProperty("Particles"), Key(5)]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20)]
|
||||
public class TriggerData : BehaviorData
|
||||
{
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class VelocityConversionData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("traction"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("traction"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Traction = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class VelocityLimitData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("topSpeed"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("topSpeed"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat TopSpeed = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class VisibilityData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("visibility"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("visibility"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Visibility = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("visibilityDecay"), Key(2)]
|
||||
[Inspectable, JsonProperty("visibilityDecay"), Key(2)]
|
||||
public PerformanceStat VisibilityDecay = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ using static Unity.Mathematics.math;
|
|||
RuntimeInspectable]
|
||||
public abstract class WeaponData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("damageType"), Key(1), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("damageType"), Key(1), RuntimeInspectable]
|
||||
public DamageType DamageType;
|
||||
|
||||
[InspectableField, JsonProperty("damage"), Key(2), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("damage"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat Damage = new PerformanceStat();
|
||||
|
||||
[RangedFloatInspectable(0,1), JsonProperty("penetration"), Key(3), RuntimeInspectable]
|
||||
|
|
@ -29,10 +29,10 @@ public abstract class WeaponData : BehaviorData
|
|||
[RangedFloatInspectable(0,1), JsonProperty("damageSpread"), Key(4)]
|
||||
public PerformanceStat DamageSpread = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("minRange"), Key(5), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("minRange"), Key(5), RuntimeInspectable]
|
||||
public PerformanceStat MinRange = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("range"), Key(6), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("range"), Key(6), RuntimeInspectable]
|
||||
public PerformanceStat Range = new PerformanceStat();
|
||||
|
||||
[InspectableAnimationCurve, JsonProperty("damageRange"), Key(7), RuntimeInspectable]
|
||||
|
|
@ -62,7 +62,7 @@ public abstract class WeaponData : BehaviorData
|
|||
[InspectablePrefab, JsonProperty("spread"), Key(15)]
|
||||
public PerformanceStat Spread = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("velocity"), Key(16)]
|
||||
[Inspectable, JsonProperty("velocity"), Key(16)]
|
||||
public PerformanceStat Velocity = new PerformanceStat();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,39 +9,13 @@ using MessagePack;
|
|||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
|
||||
|
||||
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class Corporation : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[JsonProperty("parent"), Key(2)]
|
||||
public Guid Parent;
|
||||
|
||||
[JsonProperty("tasks"), Key(3)]
|
||||
public List<Guid> Tasks = new List<Guid>();
|
||||
|
||||
[JsonProperty("planetSurveyFloor"), Key(4)]
|
||||
public Dictionary<Guid, float> PlanetSurveyFloor = new Dictionary<Guid, float>();
|
||||
|
||||
[JsonProperty("unlockedBlueprints"), Key(5)]
|
||||
public List<Guid> UnlockedBlueprints = new List<Guid>();
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Name;
|
||||
set => Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[RethinkTable("Galaxy"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class Faction : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[InspectableField, JsonProperty("name"), Key(1)]
|
||||
[Inspectable, JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[InspectableField, JsonProperty("shortName"), Key(2)]
|
||||
[Inspectable, JsonProperty("shortName"), Key(2)]
|
||||
public string ShortName;
|
||||
|
||||
[InspectableText, JsonProperty("description"), Key(3)]
|
||||
|
|
@ -53,7 +27,7 @@ public class Faction : DatabaseEntry, INamedEntry
|
|||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(5)]
|
||||
public Dictionary<Guid, float> Personality = new Dictionary<Guid, float>();
|
||||
|
||||
[InspectableField, JsonProperty("hostile"), Key(6)]
|
||||
[Inspectable, JsonProperty("hostile"), Key(6)]
|
||||
public bool PlayerHostile;
|
||||
|
||||
[InspectableColor, JsonProperty("primaryColor"), Key(7)]
|
||||
|
|
@ -68,7 +42,7 @@ public class Faction : DatabaseEntry, INamedEntry
|
|||
[InspectableDatabaseLink(typeof(HullData)), JsonProperty("bossHull"), Key(10)]
|
||||
public Guid BossHull;
|
||||
|
||||
[InspectableField, JsonProperty("influence"), Key(11)]
|
||||
[Inspectable, JsonProperty("influence"), Key(11)]
|
||||
public int InfluenceDistance = 4;
|
||||
|
||||
[InspectableDatabaseLink(typeof(Faction)), RangedFloat(0, 1), JsonProperty("allegiance"), Key(12)]
|
||||
|
|
|
|||
|
|
@ -1,28 +1,14 @@
|
|||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class InspectableAttribute : Attribute { }
|
||||
|
||||
public abstract class PreferredInspectorAttribute : InspectableAttribute
|
||||
{
|
||||
public Type TargetType;
|
||||
|
||||
public PreferredInspectorAttribute(Type targetType)
|
||||
{
|
||||
TargetType = targetType;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ExternalEntryAttribute : Attribute { }
|
||||
|
||||
public class InspectableFieldAttribute : Attribute { }
|
||||
public class InspectableAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextAttribute : InspectableFieldAttribute { }
|
||||
public abstract class PreferredInspectorAttribute : InspectableAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableUnityObjectAttribute : InspectableFieldAttribute
|
||||
public class InspectableUnityObjectAttribute : PreferredInspectorAttribute
|
||||
{
|
||||
public Type ObjectType;
|
||||
|
||||
|
|
@ -31,27 +17,15 @@ public class InspectableUnityObjectAttribute : InspectableFieldAttribute
|
|||
ObjectType = type;
|
||||
}
|
||||
}
|
||||
public class InspectableTextAttribute : PreferredInspectorAttribute { }
|
||||
public class InspectablePrefabAttribute : PreferredInspectorAttribute { }
|
||||
public class InspectableTextureAttribute : PreferredInspectorAttribute { }
|
||||
public class InspectableTextAssetAttribute : PreferredInspectorAttribute { }
|
||||
public class InspectableTemperatureAttribute : PreferredInspectorAttribute { }
|
||||
public class InspectableAnimationCurveAttribute : PreferredInspectorAttribute { }
|
||||
public class InspectableColorAttribute : PreferredInspectorAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectablePrefabAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextureAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTextAssetAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableTemperatureAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableAnimationCurveAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableColorAttribute : InspectableFieldAttribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class InspectableDatabaseLinkAttribute : InspectableFieldAttribute
|
||||
public class InspectableDatabaseLinkAttribute : PreferredInspectorAttribute
|
||||
{
|
||||
public readonly Type EntryType;
|
||||
|
||||
|
|
@ -61,8 +35,7 @@ public class InspectableDatabaseLinkAttribute : InspectableFieldAttribute
|
|||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedFloatInspectableAttribute : InspectableFieldAttribute
|
||||
public class RangedFloatInspectableAttribute : PreferredInspectorAttribute
|
||||
{
|
||||
public readonly float Min, Max;
|
||||
|
||||
|
|
@ -73,6 +46,27 @@ public class RangedFloatInspectableAttribute : InspectableFieldAttribute
|
|||
}
|
||||
}
|
||||
|
||||
public class RangedIntInspectableAttribute : PreferredInspectorAttribute
|
||||
{
|
||||
public readonly int Min, Max;
|
||||
|
||||
public RangedIntInspectableAttribute(int min, int max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
public class InspectableTypeAttribute : PreferredInspectorAttribute
|
||||
{
|
||||
public readonly Type Type;
|
||||
|
||||
public InspectableTypeAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedFloatAttribute : Attribute
|
||||
{
|
||||
|
|
@ -85,30 +79,6 @@ public class RangedFloatAttribute : Attribute
|
|||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class RangedIntInspectableAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly int Min, Max;
|
||||
|
||||
public RangedIntInspectableAttribute(int min, int max)
|
||||
{
|
||||
Min = min;
|
||||
Max = max;
|
||||
}
|
||||
}
|
||||
|
||||
public class InspectableTypeAttribute : InspectableFieldAttribute
|
||||
{
|
||||
public readonly Type Type;
|
||||
|
||||
public InspectableTypeAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SimplePerformanceStatAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Specify a tooltip for a field in the Inspector window.</para>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using MessagePack;
|
||||
|
||||
public class DatabaseCache
|
||||
public class CultCache
|
||||
{
|
||||
public event Action<DatabaseEntry> OnDataInsertLocal;
|
||||
public event Action<DatabaseEntry> OnDataUpdateLocal;
|
||||
|
|
@ -42,10 +42,11 @@ public class DatabaseCache
|
|||
}
|
||||
}
|
||||
private readonly Dictionary<Guid, ExternalEntry> _externalEntries = new Dictionary<Guid, ExternalEntry>();
|
||||
private readonly Dictionary<Type, FieldInfo[]> _linkFields = new Dictionary<Type, FieldInfo[]>();
|
||||
|
||||
public IEnumerable<DatabaseEntry> AllEntries => _entries.Values;
|
||||
|
||||
public DatabaseCache(string filePath)
|
||||
public CultCache(string filePath)
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
_filePath = filePath;
|
||||
|
|
@ -57,6 +58,9 @@ public class DatabaseCache
|
|||
// This is mainly to accomodate large files like datasets
|
||||
foreach (var type in typeof(DatabaseEntry).GetAllChildClasses())
|
||||
{
|
||||
var linkFields = type.GetFields().Where(f => f.FieldType.IsAssignableToGenericType(typeof(DatabaseLink<>))).ToArray();
|
||||
if(linkFields.Length > 0)
|
||||
_linkFields[type] = linkFields;
|
||||
if (type.GetCustomAttribute<ExternalEntryAttribute>() != null)
|
||||
{
|
||||
var typeDirectory = dataDirectory.CreateSubdirectory(type.Name);
|
||||
|
|
@ -88,6 +92,17 @@ public class DatabaseCache
|
|||
|
||||
// If an external entry is added, store it separately
|
||||
var type = entry.GetType();
|
||||
if (_linkFields.ContainsKey(type))
|
||||
{
|
||||
foreach (var linkField in _linkFields[type])
|
||||
{
|
||||
var link = (DatabaseLinkBase) linkField.GetValue(entry);
|
||||
if (link != null)
|
||||
{
|
||||
link.Cache = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_externalTypes.ContainsKey(type))
|
||||
{
|
||||
if (_externalEntries.ContainsKey(entry.ID))
|
||||
|
|
@ -17,9 +17,7 @@ public interface INamedEntry
|
|||
string EntryName { get; set; }
|
||||
}
|
||||
|
||||
[InspectableField,
|
||||
MessagePackObject,
|
||||
//MessagePackFormatter(typeof(TypelessFormatter)),
|
||||
[MessagePackObject,
|
||||
JsonObject(MemberSerialization.OptIn),
|
||||
JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>)),
|
||||
Union(0, typeof(SimpleCommodityData)),
|
||||
|
|
@ -33,7 +31,7 @@ public interface INamedEntry
|
|||
Union(9, typeof(NameFile)),
|
||||
//Union(10, typeof(ZoneData)),
|
||||
Union(11, typeof(PlayerData)),
|
||||
Union(12, typeof(Corporation)),
|
||||
// Union(12, typeof(Corporation)),
|
||||
Union(13, typeof(Faction)),
|
||||
Union(14, typeof(OrbitalEntity)),
|
||||
Union(15, typeof(OrbitData)),
|
||||
|
|
@ -41,8 +39,8 @@ public interface INamedEntry
|
|||
Union(17, typeof(PersonalityAttribute)),
|
||||
Union(18, typeof(AgentTask)),
|
||||
// Union(19, typeof(LoadoutData)),
|
||||
Union(20, typeof(Ship)),
|
||||
Union(21, typeof(Mining)),
|
||||
Union(20, typeof(Ship)),
|
||||
Union(21, typeof(Mining)),
|
||||
Union(22, typeof(StationTowing)),
|
||||
Union(23, typeof(Survey)),
|
||||
Union(24, typeof(HaulingTask)),
|
||||
|
|
@ -57,6 +55,21 @@ public abstract class DatabaseEntry
|
|||
{
|
||||
[JsonProperty("id"), Key(0)]
|
||||
public Guid ID = Guid.NewGuid();
|
||||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class DatabaseLink<T> : DatabaseLinkBase where T : DatabaseEntry
|
||||
{
|
||||
[IgnoreMember]
|
||||
public T Value => Cache.Get<T>(LinkID);
|
||||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class DatabaseLinkBase
|
||||
{
|
||||
[Key(0), JsonProperty("linkID")]
|
||||
public Guid LinkID;
|
||||
|
||||
public DatabaseEntry(){}
|
||||
[IgnoreMember]
|
||||
public CultCache Cache;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public static class CultCacheExtensions
|
||||
|
|
@ -56,7 +57,35 @@ public static class CultCacheExtensions
|
|||
return ChildClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(type.IsAssignableFrom).ToArray();
|
||||
}
|
||||
|
||||
private static Dictionary<Type,Type[]> GenericChildClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllGenericChildClasses(this Type genericType)
|
||||
{
|
||||
if (GenericChildClasses.ContainsKey(genericType))
|
||||
return ChildClasses[genericType];
|
||||
return ChildClasses[genericType] = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(ass => ass.GetTypes()).Where(type=>type.IsAssignableToGenericType(genericType)).ToArray();
|
||||
}
|
||||
|
||||
public static bool IsAssignableToGenericType(this Type givenType, Type genericType)
|
||||
{
|
||||
var interfaceTypes = givenType.GetInterfaces();
|
||||
|
||||
foreach (var it in interfaceTypes)
|
||||
{
|
||||
if (it.IsGenericType && it.GetGenericTypeDefinition() == genericType)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)
|
||||
return true;
|
||||
|
||||
Type baseType = givenType.BaseType;
|
||||
if (baseType == null) return false;
|
||||
|
||||
return IsAssignableToGenericType(baseType, genericType);
|
||||
}
|
||||
|
||||
public static async void WrapAwait(this Task task)
|
||||
{
|
||||
await task;
|
||||
|
|
|
|||
|
|
@ -15,46 +15,46 @@ using static NoiseFbm;
|
|||
[Inspectable, Serializable, RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class GalaxyMapLayerData : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[InspectableField, JsonProperty("coreBoost"), Key(1)]
|
||||
[Inspectable, JsonProperty("coreBoost"), Key(1)]
|
||||
public float CoreBoost = 1.05f;
|
||||
|
||||
[InspectableField, JsonProperty("coreBoostOffset"), Key(2)]
|
||||
[Inspectable, JsonProperty("coreBoostOffset"), Key(2)]
|
||||
public float CoreBoostOffset = .1f;
|
||||
|
||||
[InspectableField, JsonProperty("coreBoostPower"), Key(3)]
|
||||
[Inspectable, JsonProperty("coreBoostPower"), Key(3)]
|
||||
public float CoreBoostPower = 2.25f;
|
||||
|
||||
[InspectableField, JsonProperty("spokeScale"), Key(4)]
|
||||
[Inspectable, JsonProperty("spokeScale"), Key(4)]
|
||||
public float SpokeScale = 1;
|
||||
|
||||
[InspectableField, JsonProperty("spokeOffset"), Key(5)]
|
||||
[Inspectable, JsonProperty("spokeOffset"), Key(5)]
|
||||
public float SpokeOffset = 0;
|
||||
|
||||
[InspectableField, JsonProperty("edgeReduction"), Key(6)]
|
||||
[Inspectable, JsonProperty("edgeReduction"), Key(6)]
|
||||
public float EdgeReduction = 3;
|
||||
|
||||
[InspectableField, JsonProperty("noiseOffset"), Key(7)]
|
||||
[Inspectable, JsonProperty("noiseOffset"), Key(7)]
|
||||
public float NoiseOffset = 0;
|
||||
|
||||
[InspectableField, JsonProperty("noiseAmplitude"), Key(8)]
|
||||
[Inspectable, JsonProperty("noiseAmplitude"), Key(8)]
|
||||
public float NoiseAmplitude = 1.5f;
|
||||
|
||||
[InspectableField, JsonProperty("noiseGain"), Key(9)]
|
||||
[Inspectable, JsonProperty("noiseGain"), Key(9)]
|
||||
public float NoiseGain = .7f;
|
||||
|
||||
[InspectableField, JsonProperty("noiseLacunarity"), Key(10)]
|
||||
[Inspectable, JsonProperty("noiseLacunarity"), Key(10)]
|
||||
public float NoiseLacunarity = 2;
|
||||
|
||||
[InspectableField, JsonProperty("noiseOctaves"), Key(11)]
|
||||
[Inspectable, JsonProperty("noiseOctaves"), Key(11)]
|
||||
public int NoiseOctaves = 7;
|
||||
|
||||
[InspectableField, JsonProperty("noiseFrequency"), Key(12)]
|
||||
[Inspectable, JsonProperty("noiseFrequency"), Key(12)]
|
||||
public float NoiseFrequency = 1;
|
||||
|
||||
[InspectableField, JsonProperty("noisePosition"), Key(13)]
|
||||
[Inspectable, JsonProperty("noisePosition"), Key(13)]
|
||||
public float NoisePosition = 1337;
|
||||
|
||||
[InspectableField, JsonProperty("name"), Key(14)]
|
||||
[Inspectable, JsonProperty("name"), Key(14)]
|
||||
public string Name;
|
||||
|
||||
public float Evaluate(float2 uv, GalaxyShapeSettings settings)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ using static Unity.Mathematics.math;
|
|||
using float2 = Unity.Mathematics.float2;
|
||||
using int2 = Unity.Mathematics.int2;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class Shape
|
||||
{
|
||||
[JsonProperty("name"), Key(0)] public bool[,] Cells;
|
||||
|
|
@ -222,7 +222,7 @@ public class Shape
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<ItemData>))]
|
||||
public abstract class ItemData : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[InspectableField, JsonProperty("name"), Key(1)]
|
||||
[Inspectable, JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[InspectableText, JsonProperty("description"), Key(2)]
|
||||
|
|
@ -231,20 +231,20 @@ public abstract class ItemData : DatabaseEntry, INamedEntry
|
|||
[InspectableDatabaseLink(typeof(Faction)), JsonProperty("creator"), Key(3)]
|
||||
public Guid Manufacturer;
|
||||
|
||||
[InspectableField, JsonProperty("mass"), Key(4)]
|
||||
[Inspectable, JsonProperty("mass"), Key(4)]
|
||||
public float Mass;
|
||||
|
||||
[InspectableField, JsonProperty("shape"), Key(5)]
|
||||
[Inspectable, JsonProperty("shape"), Key(5)]
|
||||
public Shape Shape;
|
||||
|
||||
// Heat needed to change temperature of 1 gram by 1 degree
|
||||
[InspectableField, JsonProperty("specificHeat"), Key(6)]
|
||||
[Inspectable, JsonProperty("specificHeat"), Key(6)]
|
||||
public float SpecificHeat = 1;
|
||||
|
||||
[InspectableField, JsonProperty("conductivity"), Key(7)]
|
||||
[Inspectable, JsonProperty("conductivity"), Key(7)]
|
||||
public float Conductivity = 1;
|
||||
|
||||
[InspectableField, JsonProperty("price"), Key(8)]
|
||||
[Inspectable, JsonProperty("price"), Key(8)]
|
||||
public int Price = 0;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
|
|
@ -274,17 +274,17 @@ public class SimpleCommodityData : ItemData
|
|||
// [InspectableField, JsonProperty("floor"), Key(11)]
|
||||
// public float Floor = 5f;
|
||||
|
||||
[InspectableField, JsonProperty("maxStackSize"), Key(9)]
|
||||
[Inspectable, JsonProperty("maxStackSize"), Key(9)]
|
||||
public int MaxStack = 10;
|
||||
|
||||
[InspectableField, JsonProperty("category"), Key(10)]
|
||||
[Inspectable, JsonProperty("category"), Key(10)]
|
||||
public SimpleCommodityCategory Category;
|
||||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<CraftedItemData>))]
|
||||
public abstract class CraftedItemData : ItemData
|
||||
{
|
||||
[InspectableField, JsonProperty("ingredientQualityWeight"), Key(9)]
|
||||
[Inspectable, JsonProperty("ingredientQualityWeight"), Key(9)]
|
||||
public float IngredientQualityWeight = .5f;
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ public class CompoundCommodityData : CraftedItemData
|
|||
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("demandProfile"), Key(10)]
|
||||
public Dictionary<Guid, float> DemandProfile = new Dictionary<Guid, float>();
|
||||
|
||||
[InspectableField, JsonProperty("category"), Key(11)]
|
||||
[Inspectable, JsonProperty("category"), Key(11)]
|
||||
public CompoundCommodityCategory Category;
|
||||
}
|
||||
|
||||
|
|
@ -304,10 +304,10 @@ public abstract class EquippableItemData : CraftedItemData
|
|||
[InspectableTexture, JsonProperty("schematic"), Key(10)]
|
||||
public string Schematic;
|
||||
|
||||
[InspectableField, JsonProperty("behaviors"), Key(11)]
|
||||
[Inspectable, JsonProperty("behaviors"), Key(11)]
|
||||
public List<BehaviorData> Behaviors = new List<BehaviorData>();
|
||||
|
||||
[InspectableField, JsonProperty("durability"), Key(12)]
|
||||
[Inspectable, JsonProperty("durability"), Key(12)]
|
||||
public float Durability;
|
||||
|
||||
[InspectableTemperature, JsonProperty("minTemp"), Key(13)]
|
||||
|
|
@ -325,10 +325,10 @@ public abstract class EquippableItemData : CraftedItemData
|
|||
[InspectableAnimationCurve, JsonProperty("performanceCurve"), Key(17)]
|
||||
public float4[] HeatPerformanceCurve;
|
||||
|
||||
[InspectableField, JsonProperty("resilience"), Key(18)]
|
||||
[Inspectable, JsonProperty("resilience"), Key(18)]
|
||||
public float ThermalResilience = 1;
|
||||
|
||||
[InspectableField, JsonProperty("sfx"), Key(19)]
|
||||
[Inspectable, JsonProperty("sfx"), Key(19)]
|
||||
public string SoundEffectTrigger;
|
||||
|
||||
[IgnoreMember]
|
||||
|
|
@ -372,7 +372,7 @@ public abstract class EquippableItemData : CraftedItemData
|
|||
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class GearData : EquippableItemData
|
||||
{
|
||||
[InspectableField, JsonProperty("hardpointType"), Key(20)]
|
||||
[Inspectable, JsonProperty("hardpointType"), Key(20)]
|
||||
public HardpointType Hardpoint;
|
||||
|
||||
[IgnoreMember] public override HardpointType HardpointType => Hardpoint;
|
||||
|
|
@ -381,7 +381,7 @@ public class GearData : EquippableItemData
|
|||
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class CargoBayData : EquippableItemData
|
||||
{
|
||||
[InspectableField, JsonProperty("interiorShape"), Key(20)]
|
||||
[Inspectable, JsonProperty("interiorShape"), Key(20)]
|
||||
public Shape InteriorShape;
|
||||
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Tool;
|
||||
}
|
||||
|
|
@ -389,45 +389,45 @@ public class CargoBayData : EquippableItemData
|
|||
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class DockingBayData : CargoBayData
|
||||
{
|
||||
[InspectableField, JsonProperty("maxSize"), Key(21)]
|
||||
[Inspectable, JsonProperty("maxSize"), Key(21)]
|
||||
public int2 MaxSize;
|
||||
}
|
||||
|
||||
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class WeaponItemData : GearData
|
||||
{
|
||||
[InspectableField, JsonProperty("range"), Key(21)]
|
||||
[Inspectable, JsonProperty("range"), Key(21)]
|
||||
public WeaponRange WeaponRange;
|
||||
|
||||
[InspectableField, JsonProperty("caliber"), Key(22)]
|
||||
[Inspectable, JsonProperty("caliber"), Key(22)]
|
||||
public WeaponCaliber WeaponCaliber;
|
||||
|
||||
[InspectableField, JsonProperty("weaponType"), Key(23)]
|
||||
[Inspectable, JsonProperty("weaponType"), Key(23)]
|
||||
public WeaponType WeaponType;
|
||||
|
||||
[InspectableField, JsonProperty("fireTypes"), Key(24)]
|
||||
[Inspectable, JsonProperty("fireTypes"), Key(24)]
|
||||
public WeaponFireType WeaponFireTypes;
|
||||
|
||||
[InspectableField, JsonProperty("modifiers"), Key(25)]
|
||||
[Inspectable, JsonProperty("modifiers"), Key(25)]
|
||||
public WeaponModifiers WeaponModifiers;
|
||||
}
|
||||
|
||||
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class HullData : EquippableItemData
|
||||
{
|
||||
[InspectableField, JsonProperty("hardpoints"), Key(20)]
|
||||
[Inspectable, JsonProperty("hardpoints"), Key(20)]
|
||||
public List<HardpointData> Hardpoints = new List<HardpointData>();
|
||||
|
||||
[InspectablePrefab, JsonProperty("prefab"), Key(21)]
|
||||
public string Prefab;
|
||||
|
||||
[InspectableField, JsonProperty("hullType"), Key(22)]
|
||||
[Inspectable, JsonProperty("hullType"), Key(22)]
|
||||
public HullType HullType;
|
||||
|
||||
[InspectableField, JsonProperty("gridOffset"), Key(23)]
|
||||
[Inspectable, JsonProperty("gridOffset"), Key(23)]
|
||||
public float GridOffset;
|
||||
|
||||
[InspectableField, JsonProperty("armor"), Key(24)]
|
||||
[Inspectable, JsonProperty("armor"), Key(24)]
|
||||
public float Armor;
|
||||
|
||||
[IgnoreMember]
|
||||
|
|
@ -449,15 +449,15 @@ public class HullData : EquippableItemData
|
|||
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Hull;
|
||||
}
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class HardpointData : ITintInspector
|
||||
{
|
||||
[InspectableField, JsonProperty("type"), Key(0)] public HardpointType Type;
|
||||
[InspectableField, JsonProperty("position"), Key(1)] public int2 Position;
|
||||
[InspectableField, JsonProperty("shape"), Key(2)] public Shape Shape = new Shape();
|
||||
[InspectableField, JsonProperty("transform"), Key(3)] public string Transform;
|
||||
[InspectableField, JsonProperty("rotation"), Key(4)] public ItemRotation Rotation;
|
||||
[InspectableField, JsonProperty("armor"), Key(5)] public float Armor;
|
||||
[Inspectable, JsonProperty("type"), Key(0)] public HardpointType Type;
|
||||
[Inspectable, JsonProperty("position"), Key(1)] public int2 Position;
|
||||
[Inspectable, JsonProperty("shape"), Key(2)] public Shape Shape = new Shape();
|
||||
[Inspectable, JsonProperty("transform"), Key(3)] public string Transform;
|
||||
[Inspectable, JsonProperty("rotation"), Key(4)] public ItemRotation Rotation;
|
||||
[Inspectable, JsonProperty("armor"), Key(5)] public float Armor;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
@ -539,13 +539,13 @@ public class PerformanceStat
|
|||
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class PersonalityAttribute : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[InspectableField, JsonProperty("name"), Key(1)]
|
||||
[Inspectable, JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[InspectableField, JsonProperty("low"), Key(2)]
|
||||
[Inspectable, JsonProperty("low"), Key(2)]
|
||||
public string LowName;
|
||||
|
||||
[InspectableField, JsonProperty("high"), Key(3)]
|
||||
[Inspectable, JsonProperty("high"), Key(3)]
|
||||
public string HighName;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class ItemManager
|
|||
// private Guid _forceLoadZone;
|
||||
|
||||
// public GlobalData GlobalData => _globalData ?? (_globalData = ItemData.GetAll<GlobalData>().FirstOrDefault());
|
||||
public DatabaseCache ItemData { get; }
|
||||
public CultCache ItemData { get; }
|
||||
public GameplaySettings GameplaySettings { get; }
|
||||
|
||||
public double Time
|
||||
|
|
@ -47,7 +47,7 @@ public class ItemManager
|
|||
|
||||
// private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();
|
||||
|
||||
public ItemManager(DatabaseCache itemData, GameplaySettings settings, Action<string> logger)
|
||||
public ItemManager(CultCache itemData, GameplaySettings settings, Action<string> logger)
|
||||
{
|
||||
ItemData = itemData;
|
||||
GameplaySettings = settings;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ public class Sector
|
|||
}
|
||||
}
|
||||
|
||||
public Sector(DatabaseCache database, SavedGame savedGame)
|
||||
public Sector(CultCache cultCache, SavedGame savedGame)
|
||||
{
|
||||
Settings = savedGame.Settings;
|
||||
Factions = savedGame.Factions.Select(database.Get<Faction>).ToArray();
|
||||
Factions = savedGame.Factions.Select(cultCache.Get<Faction>).ToArray();
|
||||
Zones = savedGame.Zones.Select(zone =>
|
||||
{
|
||||
return new SectorZone
|
||||
|
|
@ -67,10 +67,10 @@ public class Sector
|
|||
CalculateDistanceMatrix();
|
||||
}
|
||||
|
||||
public Sector(SectorGenerationSettings settings, DatabaseCache database, uint seed = 0, Action<string> progressCallback = null, float minLineSeparation = .01f)
|
||||
public Sector(SectorGenerationSettings settings, CultCache cultCache, uint seed = 0, Action<string> progressCallback = null, float minLineSeparation = .01f)
|
||||
{
|
||||
Settings = settings;
|
||||
var megas = database.GetAll<Faction>();
|
||||
var megas = cultCache.GetAll<Faction>();
|
||||
var random = new Random(seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed);
|
||||
Factions = megas.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ public class Sector
|
|||
progressCallback?.Invoke($"Feeding Markov Chains: {i+1} / {Factions.Length}");
|
||||
//if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao
|
||||
var faction = Factions[i];
|
||||
_nameGenerators[faction] = new MarkovNameGenerator(ref random, database.Get<NameFile>(faction.GeonameFile).Names, settings);
|
||||
_nameGenerators[faction] = new MarkovNameGenerator(ref random, cultCache.Get<NameFile>(faction.GeonameFile).Names, settings);
|
||||
}
|
||||
|
||||
// Generate zone name using the owner's name generator, otherwise assign catalogue ID
|
||||
|
|
|
|||
Loading…
Reference in a new issue