diff --git a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
index 3807bb2ff..962d138ae 100644
--- a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
+++ b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
@@ -660,6 +660,7 @@
+
@@ -674,6 +675,10 @@
+
+
+
+
@@ -1089,7 +1094,6 @@
-
diff --git a/.idea/.idea.Economy/.idea/contentModel.xml b/.idea/.idea.Economy/.idea/contentModel.xml
index 294ffd4c5..08f0909c6 100644
--- a/.idea/.idea.Economy/.idea/contentModel.xml
+++ b/.idea/.idea.Economy/.idea/contentModel.xml
@@ -6,6 +6,7 @@
+
@@ -19,6 +20,10 @@
+
+
+
+
diff --git a/Aetheria-Economy.sln b/Aetheria-Economy.sln
index 0e57f1069..c422ea2e1 100644
--- a/Aetheria-Economy.sln
+++ b/Aetheria-Economy.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{29B684F0-E616-CD9C-EFF8-10A39DB37A52}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Economy.Shared.Unity", "Economy.Shared.Unity.csproj", "{A62B36C2-E9DE-B992-0779-F5FCF5968986}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{29B684F0-E616-CD9C-EFF8-10A39DB37A52}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack", "MessagePack.csproj", "{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-firstpass", "Assembly-CSharp-firstpass.csproj", "{7D8742A4-0DFC-5667-0A98-3CA4312F9253}"
@@ -16,14 +16,14 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Release|Any CPU.Build.0 = Release|Any CPU
{A62B36C2-E9DE-B992-0779-F5FCF5968986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A62B36C2-E9DE-B992-0779-F5FCF5968986}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A62B36C2-E9DE-B992-0779-F5FCF5968986}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A62B36C2-E9DE-B992-0779-F5FCF5968986}.Release|Any CPU.Build.0 = Release|Any CPU
+ {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {29B684F0-E616-CD9C-EFF8-10A39DB37A52}.Release|Any CPU.Build.0 = Release|Any CPU
{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21EF11C5-27DC-3D88-B027-9A4B6F36BAE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/Aetheria-Economy.sln.DotSettings b/Aetheria-Economy.sln.DotSettings
index 7eca19a47..3c5b52c62 100644
--- a/Aetheria-Economy.sln.DotSettings
+++ b/Aetheria-Economy.sln.DotSettings
@@ -1,2 +1,4 @@
- True
\ No newline at end of file
+ True
+ True
+ True
\ No newline at end of file
diff --git a/Assembly-CSharp-Editor.csproj b/Assembly-CSharp-Editor.csproj
index 9c44c35ee..2cf295a42 100644
--- a/Assembly-CSharp-Editor.csproj
+++ b/Assembly-CSharp-Editor.csproj
@@ -374,9 +374,18 @@
C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/PlaybackEngines/windowsstandalonesupport/UnityEditor.WindowsStandalone.Extensions.dll
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
+
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll
+
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll
+
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll
@@ -401,15 +410,6 @@
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll
-
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
-
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll
-
C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll
diff --git a/Assembly-CSharp-firstpass.csproj b/Assembly-CSharp-firstpass.csproj
index b607c50d2..37f3499c6 100644
--- a/Assembly-CSharp-firstpass.csproj
+++ b/Assembly-CSharp-firstpass.csproj
@@ -288,9 +288,18 @@
C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
+
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll
+
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll
+
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll
@@ -312,15 +321,6 @@
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll
-
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
-
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll
-
C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll
diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj
index 1b780eb63..a3567d2af 100644
--- a/Assembly-CSharp.csproj
+++ b/Assembly-CSharp.csproj
@@ -384,7 +384,6 @@
-
@@ -654,9 +653,18 @@
C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
+
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll
+
+
+ C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll
+
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll
@@ -678,15 +686,6 @@
C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll
-
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll
-
-
- C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll
-
C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll
diff --git a/Assets/Resources/Sprites/Attribution.txt b/Assets/Resources/Sprites/Attribution.txt
index c65930fff..eca58db22 100644
--- a/Assets/Resources/Sprites/Attribution.txt
+++ b/Assets/Resources/Sprites/Attribution.txt
@@ -32,4 +32,14 @@ interlaced unicursal hexagram by Avana Vana
wing by prasong tadoungsorn
wings by iejank
Fire by Bohdan Burmich
-Hex Grid by Adam Robinson
\ No newline at end of file
+Hex Grid by Adam Robinson
+solar system by Made by Made
+Planet by Paul Krizsan
+Planet by Eliricon
+Planet by Vicons Design
+Moon by Smalllike
+spaceship by Thomas
+
+Other
+
+Asteroids by lodetobback
\ No newline at end of file
diff --git a/Assets/Resources/Sprites/Icons/Stroked/Moon.png b/Assets/Resources/Sprites/Icons/Stroked/Moon.png
new file mode 100644
index 000000000..ca70d9648
--- /dev/null
+++ b/Assets/Resources/Sprites/Icons/Stroked/Moon.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:6fd0e241463005c442f670196c6a526fbf872501cd4419207b2daa1238be76fd
+size 42072
diff --git a/Assets/Resources/Sprites/Icons/Stroked/Moon.png.meta b/Assets/Resources/Sprites/Icons/Stroked/Moon.png.meta
new file mode 100644
index 000000000..9aad2bba4
--- /dev/null
+++ b/Assets/Resources/Sprites/Icons/Stroked/Moon.png.meta
@@ -0,0 +1,110 @@
+fileFormatVersion: 2
+guid: 823d8a1c4e071994087624c39f62b319
+TextureImporter:
+ fileIDToRecycleName: {}
+ externalObjects: {}
+ serializedVersion: 9
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 1
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 2048
+ textureSettings:
+ serializedVersion: 2
+ filterMode: -1
+ aniso: -1
+ mipBias: -100
+ wrapU: 1
+ wrapV: 1
+ wrapW: 1
+ nPOTScale: 0
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 1
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 1
+ spriteTessellationDetail: -1
+ textureType: 8
+ textureShape: 1
+ singleChannelComponent: 0
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ platformSettings:
+ - serializedVersion: 2
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 256
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ - serializedVersion: 2
+ buildTarget: Standalone
+ maxTextureSize: 256
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ - serializedVersion: 2
+ buildTarget: WebGL
+ maxTextureSize: 256
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ androidETC2FallbackOverride: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ physicsShape: []
+ bones: []
+ spriteID: 3ef44208584e3734393ce0943f312138
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ spritePackingTag:
+ pSDRemoveMatte: 0
+ pSDShowRemoveMatteOption: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Resources/Sprites/Icons/Stroked/Planet.png b/Assets/Resources/Sprites/Icons/Stroked/Planet.png
index 7ea165262..64d3e861e 100644
--- a/Assets/Resources/Sprites/Icons/Stroked/Planet.png
+++ b/Assets/Resources/Sprites/Icons/Stroked/Planet.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:89c7279d8a54aaeb70cd6ceb6a20a52f5eb5eac8837c2f7f283f13f710576f79
-size 27655
+oid sha256:ae73e316ab8ff9584cfa45914c39bd9c4211d01daede9e96066818924965f406
+size 17214
diff --git a/Assets/Resources/Sprites/Icons/Stroked/Ship.png b/Assets/Resources/Sprites/Icons/Stroked/Ship.png
index 90bc1bd33..cb3908001 100644
--- a/Assets/Resources/Sprites/Icons/Stroked/Ship.png
+++ b/Assets/Resources/Sprites/Icons/Stroked/Ship.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:713155ef520612121593bb45bacea73a7e73b9c1234f51b6f9b781f8c9b0f2e8
-size 22397
+oid sha256:48442b7bf966f75c03e1317d8d09366818a588be9bbb8e750184ceb23d45d1e3
+size 25504
diff --git a/Assets/Resources/Sprites/Icons/Stroked/Sun.png b/Assets/Resources/Sprites/Icons/Stroked/Sun.png
index 7f066d9bc..15c3581bf 100644
--- a/Assets/Resources/Sprites/Icons/Stroked/Sun.png
+++ b/Assets/Resources/Sprites/Icons/Stroked/Sun.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:d4d721eeb767bdf603a839de402d1c2d0b23e91b0ad8f1f3d59c7cfb23850523
-size 28282
+oid sha256:57df5dc2e6eca09969a67774ccd8c489c41214835e7f25b734d469a2c06ca635
+size 19437
diff --git a/Assets/Resources/Sprites/Icons/Stroked/Wormhole.png b/Assets/Resources/Sprites/Icons/Stroked/Wormhole.png
index aa868e20f..22131f2ed 100644
--- a/Assets/Resources/Sprites/Icons/Stroked/Wormhole.png
+++ b/Assets/Resources/Sprites/Icons/Stroked/Wormhole.png
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:ea1cbeb20429b08923aa6de46c4ffeda1edaabe64cd01d2cb3003fe42b54a95a
-size 38073
+oid sha256:e611baee3dadb0bb104b097633492c76819ef58a7eca71e811de9c81270a0b85
+size 17771
diff --git a/Assets/Scripts/Editor/DatabaseInspector.cs b/Assets/Scripts/Editor/DatabaseInspector.cs
index b7c82a636..551f600c3 100644
--- a/Assets/Scripts/Editor/DatabaseInspector.cs
+++ b/Assets/Scripts/Editor/DatabaseInspector.cs
@@ -3,12 +3,12 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using UniRx;
using Unity.Mathematics;
using UnityEditor;
using UnityEngine;
-using Object = UnityEngine.Object;
using static Unity.Mathematics.math;
+using static UnityEditor.EditorGUILayout;
+using Object = UnityEngine.Object;
public class DatabaseInspector : EditorWindow
{
@@ -29,6 +29,8 @@ public class DatabaseInspector : EditorWindow
private const int width = 100;
private const int labelWidth = 20;
+ public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black;
+
// Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...).
public DatabaseInspector()
{
@@ -104,7 +106,10 @@ public class DatabaseInspector : EditorWindow
else
field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (int) value));
}
- else if (type.IsEnum) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (int) field.GetValue(obj), Enum.GetNames(field.FieldType)));
+ else if (type.IsEnum)
+ field.SetValue(obj,
+ Inspect(field.Name.SplitCamelCase(), (int) field.GetValue(obj), Enum.GetNames(field.FieldType),
+ type.GetCustomAttributes().Any()));
//else if (field.FieldType == typeof(Color)) Inspect(field.Name, () => (Color) field.GetValue(obj), c => field.SetValue(obj, c));
else if (type == typeof(bool)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (bool) value));
else if (type == typeof(string))
@@ -119,8 +124,8 @@ public class DatabaseInspector : EditorWindow
else if (type == typeof(PerformanceStat)) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (PerformanceStat) value, obj as CraftedItemData));
else if (type == typeof(PerformanceStat[]))
{
- EditorGUILayout.LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel);
- using (new EditorGUILayout.VerticalScope(GUI.skin.box))
+ LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel);
+ using (new VerticalScope(GUI.skin.box))
{
var stats = (PerformanceStat[]) value;
var damageTypes = Enum.GetNames(typeof(DamageType));
@@ -143,24 +148,86 @@ public class DatabaseInspector : EditorWindow
var dict = (Dictionary) field.GetValue(obj);
Inspect(field.Name.SplitCamelCase(), ref dict);
}
+ else if (type == typeof(List))
+ {
+ var list = (List) field.GetValue(obj);
+ if(list==null) field.SetValue(obj, list = new List());
+
+ var blueprint = obj as BlueprintData;
+ var blueprintItem = DatabaseCache.Get(blueprint.Item);
+ if (blueprintItem is EquippableItemData equippableBlueprintItem)
+ {
+ Space();
+ LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel);
+
+ using (var v = new VerticalScope(GUI.skin.box))
+ {
+ var ingredients = blueprint.Ingredients.Keys
+ .Select(i => DatabaseCache.Get(i))
+ .Where(i => i is CraftedItemData)
+ .Cast().ToArray();
+ var ingredientNames = ingredients.Select(i => i.Name).ToArray();
+ foreach (var effect in list)
+ {
+ using (var v2 = new VerticalScope(_list.ListItemStyle))
+ {
+ using (var h = new HorizontalScope())
+ {
+ GUILayout.Label("Ingredient", GUILayout.Width(width));
+ if(ingredients.Length==0)
+ GUILayout.Label("No Ingredients!");
+ else
+ {
+ var selectedIngredientIndex =
+ Array.FindIndex(ingredients, item => item.ID == effect.Ingredient);
+ if (selectedIngredientIndex == -1)
+ {
+ selectedIngredientIndex = 0;
+ GUI.changed = true;
+ }
+ var newSelection = Popup(selectedIngredientIndex, ingredientNames);
+ if (newSelection != selectedIngredientIndex)
+ GUI.changed = true;
+ effect.Ingredient = ingredients[newSelection].ID;
+ }
+ }
+
+ Inspect(ref effect.StatReference, equippableBlueprintItem);
+ }
+
+ }
+
+ using (var h = new HorizontalScope(_list.ListItemStyle))
+ {
+ GUILayout.Label($"Add new Stat Effect", 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 (GUI.Button(rect, GUIContent.none, GUIStyle.none))
+ {
+ list.Add(new BlueprintStatEffect());
+ }
+ }
+ }
+ }
+ }
else if (type == typeof(List) && link != null)
{
var list = (List) field.GetValue(obj);
- if(list==null) field.SetValue(obj, (list = new List()));
+ if(list==null) field.SetValue(obj, list = new List());
Inspect(field.Name.SplitCamelCase(), ref list, link.EntryType);
}
else if (type == typeof(Guid) && link != null) field.SetValue(obj, Inspect(field.Name.SplitCamelCase(), (Guid) value, link.EntryType));
else if (type.GetCustomAttribute() != null)
{
- EditorGUILayout.Space();
- using (new EditorGUILayout.HorizontalScope())
+ Space();
+ using (new HorizontalScope())
{
- EditorGUILayout.LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel);
+ LabelField(field.Name.SplitCamelCase(), EditorStyles.boldLabel);
if (type.IsInterface)
{
var subTypes = type.GetAllInterfaceClasses();
var selected = value != null ? Array.IndexOf(subTypes, value.GetType()) + 1 : 0;
- var newSelection = EditorGUILayout.Popup(selected,
+ var newSelection = Popup(selected,
subTypes.Select(t => t.Name.SplitCamelCase()).Prepend("None").ToArray());
if(newSelection != selected)
field.SetValue(obj, value = newSelection==0?null:Activator.CreateInstance(subTypes[newSelection-1]));
@@ -173,8 +240,8 @@ public class DatabaseInspector : EditorWindow
var listType = field.FieldType.GenericTypeArguments[0];
if (listType.GetCustomAttribute() != null)
{
- EditorGUILayout.Space();
- using (new EditorGUILayout.VerticalScope(GUI.skin.box))
+ Space();
+ using (new VerticalScope(GUI.skin.box))
{
var list = (IList) field.GetValue(obj);
if (list == null)
@@ -184,16 +251,16 @@ public class DatabaseInspector : EditorWindow
}
foreach (var o in list)
{
- using (new EditorGUILayout.VerticalScope(_list.ListItemStyle))
+ using (new VerticalScope(_list.ListItemStyle))
{
- using (new EditorGUILayout.HorizontalScope())
+ using (new HorizontalScope())
{
GUILayout.Label(o.GetType().Name.SplitCamelCase(), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
- var rect = EditorGUILayout.GetControlRect(false,
+ var rect = GetControlRect(false,
GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1,
- Color.black, 0, 0);
+ LabelColor, 0, 0);
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
{
list.Remove(o);
@@ -201,16 +268,16 @@ public class DatabaseInspector : EditorWindow
}
}
- EditorGUILayout.Space();
+ Space();
Inspect(o, inspectablesOnly);
}
}
- using (new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label($"Add new {listType.Name}", GUILayout.ExpandWidth(true));
- var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
- GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
+ var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
+ GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
{
if (listType.IsInterface)
@@ -236,8 +303,8 @@ public class DatabaseInspector : EditorWindow
}
else if (typeof(Object).IsAssignableFrom(listType))
{
- EditorGUILayout.Space();
- using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
+ Space();
+ using (var v = new VerticalScope(GUI.skin.box))
{
var list = (IList) field.GetValue(obj);
if (list == null)
@@ -247,20 +314,20 @@ public class DatabaseInspector : EditorWindow
}
if(list.Count==0)
- using (new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (new HorizontalScope(_list.ListItemStyle))
GUILayout.Label($"Add a {listType.Name} by dragging from the project hierarchy.");
foreach (var oo in list)
{
var o = (Object) oo;
- using (new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(o.name.SplitCamelCase(), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
- var rect = EditorGUILayout.GetControlRect(false,
+ var rect = GetControlRect(false,
GUILayout.Width(EditorGUIUtility.singleLineHeight));
GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1,
- Color.black, 0, 0);
+ LabelColor, 0, 0);
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
{
list.Remove(o);
@@ -291,10 +358,10 @@ public class DatabaseInspector : EditorWindow
}
else if (typeof(Object).IsAssignableFrom(type))
{
- using (new EditorGUILayout.HorizontalScope())
+ using (new HorizontalScope())
{
GUILayout.Label(field.Name.SplitCamelCase(), GUILayout.Width(width));
- field.SetValue(obj, EditorGUILayout.ObjectField((Object)field.GetValue(obj),type,false));
+ field.SetValue(obj, ObjectField((Object)field.GetValue(obj),type,false));
}
}
// else if (type == typeof(AudioClip))
@@ -310,44 +377,44 @@ public class DatabaseInspector : EditorWindow
public bool Inspect(string label, bool value)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- return EditorGUILayout.Toggle(value);
+ return Toggle(value);
}
}
public float Inspect(string label, float value)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- return EditorGUILayout.DelayedFloatField(value);
+ return DelayedFloatField(value);
}
}
public string Inspect(string label, string value, bool area = false)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
if(area)
- return EditorGUILayout.TextArea(value,GUILayout.MaxWidth(300));
- return EditorGUILayout.DelayedTextField(value);
+ return TextArea(value,GUILayout.MaxWidth(300));
+ return DelayedTextField(value);
}
}
public float InspectTemperature(string label, float value)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
GUILayout.Label("°K", _labelStyle, GUILayout.Width(labelWidth));
- value = EditorGUILayout.DelayedFloatField(value);//, GUILayout.ExpandWidth(false)
+ value = DelayedFloatField(value);//, GUILayout.ExpandWidth(false)
GUILayout.Label("°C", _labelStyle, GUILayout.Width(labelWidth));
- value = EditorGUILayout.DelayedFloatField(value - 273.15f) + 273.15f;
+ value = DelayedFloatField(value - 273.15f) + 273.15f;
GUILayout.Label("°F", _labelStyle, GUILayout.Width(labelWidth));
- value = (EditorGUILayout.DelayedFloatField((value - 273.15f) * 1.8f + 32) - 32) / 1.8f + 273.15f;
+ value = (DelayedFloatField((value - 273.15f) * 1.8f + 32) - 32) / 1.8f + 273.15f;
return value;
}
@@ -355,55 +422,79 @@ public class DatabaseInspector : EditorWindow
public float Inspect(string label, float value, float min, float max)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- return EditorGUILayout.Slider(value, min, max);
+ return Slider(value, min, max);
}
}
public int Inspect(string label, int value)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- return EditorGUILayout.DelayedIntField(value);
+ return DelayedIntField(value);
}
}
public int Inspect(string label, int value, int min, int max)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- return EditorGUILayout.IntSlider(value, min, max);
+ return IntSlider(value, min, max);
}
}
- public int Inspect(string label, int value, string[] enumOptions)
+ public int Inspect(string label, int value, string[] enumOptions, bool flags)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ if (flags)
{
- GUILayout.Label(label, GUILayout.Width(width));
- return EditorGUILayout.Popup(value, enumOptions);
+ Space();
+ LabelField(label, EditorStyles.boldLabel);
+ using (var v = new VerticalScope(GUI.skin.box))
+ {
+ for (var i = 1; i < enumOptions.Length; i++)
+ {
+ using (var h = new HorizontalScope())
+ {
+ GUILayout.Label(enumOptions[i], GUILayout.Width(width));
+ var set = Toggle(1 << i == (1 << i & value));
+ if (set)
+ value |= 1 << i;
+ else value &= ~(1 << i);
+ }
+ }
+ }
+
+ return value;
+ }
+ else
+ {
+ using (var h = new HorizontalScope())
+ {
+ GUILayout.Label(label, GUILayout.Width(width));
+ return Popup(value, enumOptions);
+ }
}
}
public string InspectGameObject(string label, string value)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- return AssetDatabase.GetAssetPath(EditorGUILayout.ObjectField(AssetDatabase.LoadAssetAtPath(value), typeof(GameObject), false));
+ return AssetDatabase.GetAssetPath(ObjectField(AssetDatabase.LoadAssetAtPath(value), typeof(GameObject), false));
}
}
public GameObject Inspect(string label, GameObject value)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- return (GameObject) EditorGUILayout.ObjectField(value, typeof(GameObject), false);
+ return (GameObject) ObjectField(value, typeof(GameObject), false);
}
}
@@ -412,10 +503,10 @@ public class DatabaseInspector : EditorWindow
var val = value != null && value.Length > 0
? new AnimationCurve(value.Select(v => new Keyframe(v.x, v.y, v.z, v.w)).ToArray())
: new AnimationCurve();
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
- val = EditorGUILayout.CurveField(val, Color.yellow, new Rect(0, 0, 1, 1));
+ 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();
@@ -423,12 +514,12 @@ public class DatabaseInspector : EditorWindow
public AnimationCurve Inspect(string label, AnimationCurve value)
{
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
if (value == null)
value = new AnimationCurve();
- value = EditorGUILayout.CurveField(value, Color.yellow, new Rect(0, 0, 1, 1));
+ value = CurveField(value, Color.yellow, new Rect(0, 0, 1, 1));
}
return value;
@@ -436,9 +527,9 @@ public class DatabaseInspector : EditorWindow
public Guid Inspect(string label, Guid value, Type entryType)
{
- EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
+ LabelField(label, EditorStyles.boldLabel);
var valueEntry = DatabaseCache.Get(value);
- using (var h = new EditorGUILayout.HorizontalScope(GUI.skin.box))
+ using (var h = new HorizontalScope(GUI.skin.box))
{
GUILayout.Label((valueEntry as INamedEntry)?.EntryName ?? valueEntry?.ID.ToString() ?? $"Assign a {entryType.Name} by dragging from the list panel.");
@@ -447,10 +538,10 @@ public class DatabaseInspector : EditorWindow
var guid = (Guid) DragAndDrop.GetGenericData("Item");
var dragEntry = DatabaseCache.Get(guid);
if(Event.current.type == EventType.DragUpdated)
- DragAndDrop.visualMode = dragEntry != null && dragEntry.GetType()==entryType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
+ DragAndDrop.visualMode = dragEntry != null && entryType.IsInstanceOfType(dragEntry) ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
else if(Event.current.type == EventType.DragPerform)
{
- if (guid != Guid.Empty && dragEntry.GetType()==entryType)
+ if (guid != Guid.Empty && entryType.IsInstanceOfType(dragEntry))
{
DragAndDrop.AcceptDrag();
GUI.changed = true;
@@ -465,27 +556,27 @@ public class DatabaseInspector : EditorWindow
public void Inspect(string label, ref Dictionary value)
{
- EditorGUILayout.Space();
- EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
+ Space();
+ LabelField(label, EditorStyles.boldLabel);
- using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
+ using (var v = new VerticalScope(GUI.skin.box))
{
if (value.Count == 0)
{
- using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (var h = new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label("Nothing Here! Add an item by dragging from the list panel.");
}
}
foreach (var ingredient in value.ToArray())
{
- using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (var h = new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(DatabaseCache.Get(ingredient.Key).Name);
- value[ingredient.Key] = EditorGUILayout.DelayedIntField(value[ingredient.Key], GUILayout.Width(50));
+ value[ingredient.Key] = DelayedIntField(value[ingredient.Key], GUILayout.Width(50));
- var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
- GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
+ var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
+ GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
if (GUI.Button(rect, GUIContent.none, GUIStyle.none) || value[ingredient.Key]==0)
value.Remove(ingredient.Key);
}
@@ -511,27 +602,27 @@ public class DatabaseInspector : EditorWindow
public void Inspect(string label, ref Dictionary value)
{
- EditorGUILayout.Space();
- EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
+ Space();
+ LabelField(label, EditorStyles.boldLabel);
- using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
+ using (var v = new VerticalScope(GUI.skin.box))
{
if (value.Count == 0)
{
- using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (var h = new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label("Nothing Here! Add an item by dragging from the list panel.");
}
}
foreach (var ingredient in value.ToArray())
{
- using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (var h = new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label(DatabaseCache.Get(ingredient.Key).ID.ToString());
- value[ingredient.Key] = EditorGUILayout.DelayedFloatField(value[ingredient.Key], GUILayout.Width(50));
+ value[ingredient.Key] = DelayedFloatField(value[ingredient.Key], GUILayout.Width(50));
- var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
- GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
+ var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
+ GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
value.Remove(ingredient.Key);
}
@@ -557,28 +648,39 @@ public class DatabaseInspector : EditorWindow
public void Inspect(string label, ref List value, Type entryType)
{
- EditorGUILayout.Space();
- EditorGUILayout.LabelField(label, EditorStyles.boldLabel);
+ Space();
+ LabelField(label, EditorStyles.boldLabel);
- using (var v = new EditorGUILayout.VerticalScope(GUI.skin.box))
+ using (var v = new VerticalScope(GUI.skin.box))
{
if (value.Count == 0)
{
- using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (var h = new HorizontalScope(_list.ListItemStyle))
{
GUILayout.Label($"Nothing Here! Add a {entryType.Name} by dragging from the list panel.");
}
}
- foreach (var ingredient in value.ToArray())
+ foreach (var guid in value.ToArray())
{
- using (var h = new EditorGUILayout.HorizontalScope(_list.ListItemStyle))
+ using (var h = new HorizontalScope(_list.ListItemStyle))
{
- GUILayout.Label((DatabaseCache.Get(ingredient) as INamedEntry)?.EntryName ?? DatabaseCache.Get(ingredient).ID.ToString());
+ var entry = DatabaseCache.Get(guid);
+ if (entry == null)
+ {
+ value.Remove(guid);
+ GUI.changed = true;
+ }
+ else
+ {
+ GUILayout.Label((entry as INamedEntry)?.EntryName ?? entry.ID.ToString());
- var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
- GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, Color.black, 0, 0);
- if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
- value.Remove(ingredient);
+ var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
+ GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
+ if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
+ {
+ value.Remove(guid);
+ }
+ }
}
}
@@ -600,46 +702,101 @@ public class DatabaseInspector : EditorWindow
}
}
}
+
+ public void Inspect(ref StatReference effect, EquippableItemData item)
+ {
+ using (new VerticalScope())
+ {
+ var behaviorNames = item.Behaviors.Select(b => b.GetType().Name).ToArray();
+ var selectedBehaviorIndex = Array.IndexOf(behaviorNames, effect.Behavior);
+ if (selectedBehaviorIndex == -1)
+ {
+ selectedBehaviorIndex = 0;
+ GUI.changed = true;
+ }
+ using (new HorizontalScope())
+ {
+ GUILayout.Label("Behavior", GUILayout.Width(width));
+ if(behaviorNames.Length==0)
+ GUILayout.Label("No Behaviors!");
+ else
+ {
+ var newSelection = Popup(selectedBehaviorIndex, behaviorNames);
+ if (newSelection != selectedBehaviorIndex)
+ GUI.changed = true;
+ effect.Behavior = behaviorNames[newSelection];
+ }
+ }
+
+ using (new HorizontalScope())
+ {
+ GUILayout.Label("Stat", GUILayout.Width(width));
+ if(behaviorNames.Length==0)
+ GUILayout.Label("No Behaviors!");
+ else
+ {
+ var stats = item.Behaviors[selectedBehaviorIndex].GetType().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, effect.Stat);
+ if (selectedStatIndex == -1)
+ {
+ selectedStatIndex = 0;
+ GUI.changed = true;
+ }
+ var newSelection = Popup(selectedStatIndex, statNames);
+ if (newSelection != selectedStatIndex)
+ GUI.changed = true;
+ effect.Stat = statNames[newSelection];
+ }
+ }
+ }
+ }
+ }
public PerformanceStat Inspect(string label, PerformanceStat value, CraftedItemData crafted)
{
- using (new EditorGUILayout.VerticalScope())
+ using (new VerticalScope())
{
- using (new EditorGUILayout.HorizontalScope())
+ using (new HorizontalScope())
{
GUILayout.Label(label, GUILayout.Width(width));
GUILayout.Label("Min", _labelStyle, GUILayout.Width(labelWidth));
- value.Min = EditorGUILayout.DelayedFloatField(value.Min);
+ value.Min = DelayedFloatField(value.Min);
GUILayout.Label("Max", _labelStyle, GUILayout.Width(labelWidth + 5));
- value.Max = EditorGUILayout.DelayedFloatField(value.Max);
+ value.Max = DelayedFloatField(value.Max);
}
- using (new EditorGUILayout.HorizontalScope())
+ using (new HorizontalScope())
{
GUILayout.Label("", GUILayout.Width(width));
GUILayout.Label("H", _labelStyle);
- value.HeatDependent = EditorGUILayout.Toggle(value.HeatDependent);
+ value.HeatDependent = Toggle(value.HeatDependent);
GUILayout.Label("D", _labelStyle);
- value.DurabilityDependent = EditorGUILayout.Toggle(value.DurabilityDependent);
+ value.DurabilityDependent = Toggle(value.DurabilityDependent);
GUILayout.Label("QEx", _labelStyle, GUILayout.Width(labelWidth + 5));
- value.QualityExponent = EditorGUILayout.DelayedFloatField(value.QualityExponent);
+ value.QualityExponent = DelayedFloatField(value.QualityExponent);
}
- using (new EditorGUILayout.HorizontalScope())
- {
- GUILayout.Label("", GUILayout.Width(width));
- GUILayout.Label("Ingredient", GUILayout.ExpandWidth(false));
- var ingredients = crafted.Ingredients.Keys.Select(DatabaseCache.Get).Where(i => i is CraftedItemData).Cast().ToList();
- var ingredient = value.Ingredient != null ? DatabaseCache.Get(value.Ingredient.Value) as CraftedItemData : null;
- var names = ingredients.Select(i => i.Name).Append("None").ToArray();
- var selected = value.Ingredient == null || !crafted.Ingredients.ContainsKey(value.Ingredient.Value)
- ? names.Length - 1
- : ingredients.IndexOf(ingredient);
- var selection = EditorGUILayout.Popup(selected, names);
- value.Ingredient = selection == names.Length - 1 ? (Guid?) null : ingredients[selection].ID;
- }
+ // using (new HorizontalScope())
+ // {
+ // GUILayout.Label("", GUILayout.Width(width));
+ // GUILayout.Label("Ingredient", GUILayout.ExpandWidth(false));
+ // var ingredients = crafted.Ingredients.Keys.Select(DatabaseCache.Get).Where(i => i is CraftedItemData).Cast().ToList();
+ // var ingredient = value.Ingredient != null ? DatabaseCache.Get(value.Ingredient.Value) as CraftedItemData : null;
+ // var names = ingredients.Select(i => i.Name).Append("None").ToArray();
+ // var selected = value.Ingredient == null || !crafted.Ingredients.ContainsKey(value.Ingredient.Value)
+ // ? names.Length - 1
+ // : ingredients.IndexOf(ingredient);
+ // var selection = Popup(selected, names);
+ // value.Ingredient = selection == names.Length - 1 ? (Guid?) null : ingredients[selection].ID;
+ // }
- EditorGUILayout.Space();
+ Space();
return value;
}
@@ -647,7 +804,7 @@ public class DatabaseInspector : EditorWindow
public void OnGUI()
{
- _labelStyle = new GUIStyle(EditorStyles.centeredGreyMiniLabel) {normal = {textColor = EditorGUIUtility.isProSkin?Color.white:Color.black}};
+ _labelStyle = new GUIStyle(EditorStyles.centeredGreyMiniLabel) {normal = {textColor = LabelColor}};
Event current = Event.current;
EventType currentEventType = current.type;
@@ -658,11 +815,11 @@ public class DatabaseInspector : EditorWindow
if (entry==null)
{
- EditorGUILayout.LabelField($"{(_list.SelectedItem==Guid.Empty?"No Entry Selected":"Selected Entry Not Found in Database")}\n{_list.SelectedItem}");
+ LabelField($"{(_list.SelectedItem==Guid.Empty?"No Entry Selected":"Selected Entry Not Found in Database")}\n{_list.SelectedItem}");
return;
}
- _view = EditorGUILayout.BeginScrollView(
+ _view = BeginScrollView(
_view,
false,
false,
@@ -676,7 +833,7 @@ public class DatabaseInspector : EditorWindow
var dataEntry = entry;
- using (new EditorGUILayout.HorizontalScope())
+ using (new HorizontalScope())
{
if(GUILayout.Button("Print JSON"))
Debug.Log(entry.ToJson());
@@ -692,10 +849,10 @@ public class DatabaseInspector : EditorWindow
}
}
- using (var h = new EditorGUILayout.HorizontalScope())
+ using (var h = new HorizontalScope())
{
GUILayout.Label("ID");
- EditorGUILayout.LabelField(dataEntry.ID.ToString());
+ LabelField(dataEntry.ID.ToString());
}
Inspect(entry, true);
@@ -704,7 +861,7 @@ public class DatabaseInspector : EditorWindow
var hull = entry as HullData;
if (hull != null)
{
- EditorGUILayout.Space();
+ Space();
// TODO: Hull Hardpoints Inspector
@@ -828,7 +985,7 @@ public class DatabaseInspector : EditorWindow
DatabaseCache.Add(entry);
}
- EditorGUILayout.EndScrollView();
+ EndScrollView();
}
}
diff --git a/Assets/Scripts/Editor/DatabaseView.cs b/Assets/Scripts/Editor/DatabaseView.cs
index 5b9d2d5d2..fb2bd35a1 100644
--- a/Assets/Scripts/Editor/DatabaseView.cs
+++ b/Assets/Scripts/Editor/DatabaseView.cs
@@ -44,6 +44,8 @@ public class DatabaseListView : EditorWindow
private string _connectionString;
private const float LineHeight = 20;
+ public Color LabelColor => EditorGUIUtility.isProSkin ? Color.white : Color.black;
+
// Set instance on reloading the window, else it gets lost after script reload (due to PlayMode changes, ...).
public DatabaseListView()
{
@@ -158,26 +160,61 @@ public class DatabaseListView : EditorWindow
// When entries are changed locally, push the changes to RethinkDB
_databaseCache.OnDataUpdateLocal += async entry =>
{
- var result = await R.Db("Aetheria").Table("Items").Update(entry).RunAsync(_connection);
+ var table = entry.GetType().GetCustomAttribute()?.TableName ?? "Other";
+ var result = await R
+ .Db("Aetheria")
+ .Table(table)
+ .Update(entry)
+ .RunAsync(_connection);
Debug.Log($"Uploaded entry to RethinkDB: {entry.ID} result: {result}");
};
_databaseCache.OnDataInsertLocal += async entry =>
{
- var result = await R.Db("Aetheria").Table("Items").Insert(entry).RunAsync(_connection);
+ var table = entry.GetType().GetCustomAttribute()?.TableName ?? "Other";
+ var result = await R
+ .Db("Aetheria")
+ .Table(table)
+ .Insert(entry)
+ .RunAsync(_connection);
Debug.Log($"Inserted entry to RethinkDB: {entry.ID} result: {result}");
};
_databaseCache.OnDataDeleteLocal += async entry =>
{
- var result = await R.Db("Aetheria").Table("Items").Get(entry.ID).Delete().RunAsync(_connection);
+ var table = entry.GetType().GetCustomAttribute()?.TableName ?? "Other";
+ var result = await R
+ .Db("Aetheria")
+ .Table(table)
+ .Get(entry.ID)
+ .Delete()
+ .RunAsync(_connection);
Debug.Log($"Deleted entry from RethinkDB: {entry.ID} result: {result}");
};
// Get all item data from RethinkDB
Task.Run(async () =>
{
- var result = await R.Db("Aetheria").Table("Items").RunCursorAsync(_connection);
+ var result = await R
+ .Db("Aetheria")
+ .Table("Items")
+ .RunCursorAsync(_connection);
+ while (await result.MoveNextAsync())
+ {
+ var entry = result.Current;
+ Debug.Log($"Received entry from RethinkDB: {entry.ID}");
+ _databaseCache.Add(entry, true);
+ }
+ }).WrapErrors();
+
+ // Get all galaxy map layer data from RethinkDB
+ Task.Run(async () =>
+ {
+ var result = await R
+ .Db("Aetheria")
+ .Table("Galaxy")
+ .Filter(o => o["$type"]==typeof(GalaxyMapLayerData).Name)
+ .RunCursorAsync(_connection);
while (await result.MoveNextAsync())
{
var entry = result.Current;
@@ -189,7 +226,10 @@ public class DatabaseListView : EditorWindow
// Subscribe to changes from RethinkDB
Task.Run(async () =>
{
- var result = await R.Db("Aetheria").Table("Items").Changes()
+ var result = await R
+ .Db("Aetheria")
+ .Table("Items")
+ .Changes()
.RunChangesAsync(_connection);
while (await result.MoveNextAsync())
{
@@ -228,7 +268,7 @@ public class DatabaseListView : EditorWindow
{
GUILayout.Space(10);
_gearFoldouts[i] = EditorGUILayout.Foldout(_gearFoldouts[i],
- ((NameAttribute) _itemTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _itemTypes[i].Name,
+ ((NameAttribute) _itemTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? FormatTypeName(_itemTypes[i].Name),
true);
}
if (_gearFoldouts[i])
@@ -263,7 +303,7 @@ public class DatabaseListView : EditorWindow
GUILayout.Space(20);
GUILayout.Label("New " + _itemTypes[i].Name);
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
- GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, EditorGUIUtility.isProSkin?Color.white:Color.black, 0, 0);
+ GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
}
}
}
@@ -275,7 +315,7 @@ public class DatabaseListView : EditorWindow
using (var h = new EditorGUILayout.HorizontalScope(ListItemStyle))
{
_entryFoldouts[i] = EditorGUILayout.Foldout(_entryFoldouts[i],
- ((NameAttribute) _entryTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? _entryTypes[i].Name,
+ ((NameAttribute) _entryTypes[i].GetCustomAttribute(typeof(NameAttribute)))?.Name ?? FormatTypeName(_entryTypes[i].Name),
true);
}
@@ -312,7 +352,7 @@ public class DatabaseListView : EditorWindow
GUILayout.Space(10);
GUILayout.Label("New " + _entryTypes[i].Name);
var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
- GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, EditorGUIUtility.isProSkin?Color.white:Color.black, 0, 0);
+ GUI.DrawTexture(rect, Icons.Instance.plus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
}
}
}
@@ -397,6 +437,13 @@ public class DatabaseListView : EditorWindow
//GUI.FocusControl("");
}
+ private string FormatTypeName(string typeName)
+ {
+ return (typeName.EndsWith("Data")
+ ? typeName.Substring(0, typeName.Length - 4)
+ : typeName).SplitCamelCase();
+ }
+
private void CreateItem(Type type)
{
var newEntry = (DatabaseEntry) Activator.CreateInstance(type);
diff --git a/Assets/Scripts/Editor/EditorDispatch.cs b/Assets/Scripts/Editor/EditorDispatch.cs
index a50580e66..90d63faa9 100644
--- a/Assets/Scripts/Editor/EditorDispatch.cs
+++ b/Assets/Scripts/Editor/EditorDispatch.cs
@@ -35,8 +35,8 @@ public static class EditorDispatcher
timer.Stop();
- if (dispatchCount > 0)
- UnityEngine.Debug.Log(string.Format("[EditorDispatcher] Dispatched {0} calls in {1}ms", dispatchCount, timer.Elapsed.TotalMilliseconds));
+// if (dispatchCount > 0)
+// UnityEngine.Debug.Log(string.Format("[EditorDispatcher] Dispatched {0} calls in {1}ms", dispatchCount, timer.Elapsed.TotalMilliseconds));
// todo some logic for disconnecting update when the queue is empty
}
diff --git a/Assets/Scripts/Editor/GalaxyEditor.cs b/Assets/Scripts/Editor/GalaxyEditor.cs
index f912a3049..8bc17ca59 100644
--- a/Assets/Scripts/Editor/GalaxyEditor.cs
+++ b/Assets/Scripts/Editor/GalaxyEditor.cs
@@ -283,11 +283,12 @@ public class GalaxyEditor : Editor
}).Run(_connection);
}
- galaxy.MapData.GlobalData.MapLayers["StarDensity"] = galaxy.MapData.StarDensity.ID = Guid.NewGuid();
+ //galaxy.MapData.GlobalData.MapLayers["StarDensity"] = galaxy.MapData.StarDensity.ID = Guid.NewGuid();
+ galaxy.MapData.StarDensity.Name = "StarDensity";
R.Db("Aetheria").Table("Galaxy").Insert(galaxy.MapData.StarDensity).Run(_connection);
foreach (var data in galaxy.MapData.ResourceDensities)
{
- galaxy.MapData.GlobalData.MapLayers[data.Name] = data.ID = Guid.NewGuid();
+ // galaxy.MapData.GlobalData.MapLayers[data.Name] = data.ID = Guid.NewGuid();
R.Db("Aetheria").Table("Galaxy").Insert(data).Run(_connection);
}
diff --git a/Assets/Scripts/ServerShared/Attributes.cs b/Assets/Scripts/ServerShared/Attributes.cs
index 5306d0ea9..06b99ec0e 100644
--- a/Assets/Scripts/ServerShared/Attributes.cs
+++ b/Assets/Scripts/ServerShared/Attributes.cs
@@ -81,4 +81,14 @@ public class RangedIntInspectableAttribute : InspectableFieldAttribute
Min = min;
Max = max;
}
+}
+
+public class InspectableTypeAttribute : InspectableFieldAttribute
+{
+ public readonly Type Type;
+
+ public InspectableTypeAttribute(Type type)
+ {
+ Type = type;
+ }
}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/BlueprintData.cs b/Assets/Scripts/ServerShared/BlueprintData.cs
new file mode 100644
index 000000000..00c16d9b7
--- /dev/null
+++ b/Assets/Scripts/ServerShared/BlueprintData.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using MessagePack;
+using Newtonsoft.Json;
+using Unity.Mathematics;
+using static Unity.Mathematics.math;
+
+[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class BlueprintData : DatabaseEntry, INamedEntry
+{
+ [InspectableField, JsonProperty("name"), Key(1)]
+ public string Name;
+
+ [InspectableField, JsonProperty("ingredients"), Key(2)]
+ public Dictionary Ingredients = new Dictionary();
+
+ [InspectableDatabaseLink(typeof(CraftedItemData)), JsonProperty("item"), Key(3)]
+ public Guid Item;
+
+ [InspectableField, JsonProperty("quantity"), Key(4)]
+ public int Quantity;
+
+ [InspectableField, JsonProperty("difficulty"), Key(5)]
+ public int Difficulty;
+
+ [InspectableField, JsonProperty("statEffects"), Key(6)]
+ public List StatEffects = new List();
+
+ [IgnoreMember] public string EntryName
+ {
+ get => Name;
+ set => Name = value;
+ }
+}
+
+[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class BlueprintStatEffect
+{
+ [InspectableField, JsonProperty("ingredient"), Key(1)]
+ public Guid Ingredient;
+
+ [InspectableField, JsonProperty("stat"), Key(2)]
+ public StatReference StatReference = new StatReference();
+}
+
+[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class StatReference
+{
+ [InspectableType(typeof(IItemBehaviorData)), JsonProperty("behavior"), Key(1)]
+ public string Behavior;
+
+ [InspectableField, JsonProperty("stat"), Key(2)]
+ public string Stat;
+}
diff --git a/Assets/Scripts/Targetable.cs.meta b/Assets/Scripts/ServerShared/BlueprintData.cs.meta
similarity index 83%
rename from Assets/Scripts/Targetable.cs.meta
rename to Assets/Scripts/ServerShared/BlueprintData.cs.meta
index aa5838e24..c956b95d8 100644
--- a/Assets/Scripts/Targetable.cs.meta
+++ b/Assets/Scripts/ServerShared/BlueprintData.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: ae4eaa5cad8b4c744a0740b1eb2e8548
+guid: f2b1f367d240824408eb1e151c60bc79
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Assets/Scripts/ServerShared/DatabaseItems.cs b/Assets/Scripts/ServerShared/DatabaseItems.cs
index 952c50711..c833829fb 100644
--- a/Assets/Scripts/ServerShared/DatabaseItems.cs
+++ b/Assets/Scripts/ServerShared/DatabaseItems.cs
@@ -16,51 +16,42 @@ public interface INamedEntry
string EntryName { get; set; }
}
-[InspectableField]
-[MessagePackObject]
-[Union(0, typeof(SimpleCommodityData))]
-[Union(1, typeof(CompoundCommodityData))]
-[Union(2, typeof(GearData))]
-[Union(3, typeof(HullData))]
-[Union(4, typeof(ShieldData))]
-[Union(5, typeof(ThrusterData))]
-[Union(6, typeof(SimpleCommodity))]
-[Union(7, typeof(CompoundCommodity))]
-[Union(8, typeof(Gear))]
-[Union(9, typeof(GlobalData))]
-[Union(10, typeof(ZoneData))]
-[Union(11, typeof(Player))]
-[Union(12, typeof(Corporation))]
-[Union(13, typeof(Ship))]
-[Union(14, typeof(Station))]
-[Union(15, typeof(OrbitData))]
-[Union(16, typeof(PlanetData))]
-[JsonObject(MemberSerialization.OptIn)]
-[JsonConverter(typeof(JsonKnownTypesConverter))]
+[InspectableField,
+ MessagePackObject,
+ Union(0, typeof(SimpleCommodityData)),
+ Union(1, typeof(CompoundCommodityData)),
+ Union(2, typeof(GearData)),
+ Union(3, typeof(HullData)),
+ Union(6, typeof(SimpleCommodity)),
+ Union(7, typeof(CompoundCommodity)),
+ Union(8, typeof(Gear)),
+ Union(9, typeof(GlobalData)),
+ Union(10, typeof(ZoneData)),
+ Union(11, typeof(Player)),
+ Union(12, typeof(Corporation)),
+ Union(13, typeof(Ship)),
+ Union(14, typeof(Station)),
+ Union(15, typeof(OrbitData)),
+ Union(16, typeof(PlanetData)),
+ JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter))]
//[Union(21, typeof(ContractData))]
//[Union(22, typeof(Station))]
public abstract class DatabaseEntry
{
- [JsonProperty("id")] [Key(0)] public Guid ID = Guid.NewGuid();
+ [JsonProperty("id"), Key(0)] public Guid ID = Guid.NewGuid();
[IgnoreMember] public GameContext Context { get; set; }
}
-[RethinkTable("Users")]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[RethinkTable("Users"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class Player : DatabaseEntry, INamedEntry
{
- [JsonProperty("email")] [Key(1)]
- public string Email;
-
- [JsonProperty("password")] [Key(2)]
- public string Password;
-
- [JsonProperty("username")] [Key(3)]
- public string Username;
-
- [JsonProperty("corporation")] [Key(4)]
- public Guid Corporation;
+ [JsonProperty("email"), Key(1)] public string Email;
+
+ [JsonProperty("password"), Key(2)] public string Password;
+
+ [JsonProperty("username"), Key(3)] public string Username;
+
+ [JsonProperty("corporation"), Key(4)] public Guid Corporation;
[IgnoreMember] public string EntryName
{
@@ -69,13 +60,10 @@ public class Player : DatabaseEntry, INamedEntry
}
}
-[RethinkTable("Galaxy")]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class Corporation : DatabaseEntry, INamedEntry
{
- [JsonProperty("name")] [Key(1)]
- public string Name;
+ [JsonProperty("name"), Key(1)] public string Name;
[IgnoreMember] public string EntryName
{
diff --git a/Assets/Scripts/ServerShared/Enums.cs b/Assets/Scripts/ServerShared/Enums.cs
index 23d22cb1b..a24763b95 100644
--- a/Assets/Scripts/ServerShared/Enums.cs
+++ b/Assets/Scripts/ServerShared/Enums.cs
@@ -1,3 +1,5 @@
+using System;
+
public enum LauncherCaliber
{
Micro,
@@ -29,4 +31,15 @@ public enum DamageType
Thermal,
Optical,
Ionizing
+}
+
+[Flags]
+public enum BodyType
+{
+ None = 0,
+ Asteroid = 1 << 0,
+ Planetoid = 1 << 1,
+ Planet = 1 << 2,
+ GasGiant = 1 << 3,
+ Sun = 1 << 4
}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/Extensions.cs b/Assets/Scripts/ServerShared/Extensions.cs
index 8881887bb..e4f55b858 100644
--- a/Assets/Scripts/ServerShared/Extensions.cs
+++ b/Assets/Scripts/ServerShared/Extensions.cs
@@ -68,6 +68,8 @@ public static class Extensions
private static Random? _random;
private static Random Random => (Random) (_random ?? (_random = new Random(1337)));
public static T RandomElement(this IEnumerable enumerable) => enumerable.ElementAt(Random.NextInt(0, enumerable.Count()));
+ public static float NextUnbounded(this Random random) => 1 / (1 - random.NextFloat()) - 1;
+ public static float NextUnbounded(this Random random, float bias, float power) => 1 / (1 - pow(random.NextFloat(), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
private static Dictionary InterfaceClasses = new Dictionary();
public static Type[] GetAllInterfaceClasses(this Type type)
diff --git a/Assets/Scripts/ServerShared/GameContext.cs b/Assets/Scripts/ServerShared/GameContext.cs
index 90464fe11..9b77e3dc9 100644
--- a/Assets/Scripts/ServerShared/GameContext.cs
+++ b/Assets/Scripts/ServerShared/GameContext.cs
@@ -6,15 +6,17 @@ using static Unity.Mathematics.math;
public class GameContext
{
+ private Action _logger;
private DatabaseCache _cache;
public GlobalData GlobalData => _cache.GetAll().FirstOrDefault();
- private readonly Dictionary Tier = new Dictionary();
+ // private readonly Dictionary Tier = new Dictionary();
- public GameContext(DatabaseCache cache)
+ public GameContext(DatabaseCache cache, Action logger)
{
_cache = cache;
+ _logger = logger;
var globalData = _cache.GetAll().FirstOrDefault();
if (globalData == null)
{
@@ -23,14 +25,14 @@ public class GameContext
}
}
- public int ItemTier(CraftedItemData itemData)
- {
- if (Tier.ContainsKey(itemData)) return Tier[itemData];
-
- Tier[itemData] = itemData.Ingredients.Keys.Max(ci => _cache.Get(ci) is CraftedItemData craftableIngredient ? ItemTier(craftableIngredient) : 0);
-
- return Tier[itemData];
- }
+ // public int ItemTier(CraftedItemData itemData)
+ // {
+ // if (Tier.ContainsKey(itemData)) return Tier[itemData];
+ //
+ // Tier[itemData] = itemData.Ingredients.Keys.Max(ci => _cache.Get(ci) is CraftedItemData craftableIngredient ? ItemTier(craftableIngredient) : 0);
+ //
+ // return Tier[itemData];
+ // }
public ItemData GetData(ItemInstance item)
{
@@ -80,21 +82,70 @@ public class GameContext
return 0;
}
+ private Dictionary AffectedStats =
+ new Dictionary();
+
+ public PerformanceStat GetAffectedStat(BlueprintData blueprint, BlueprintStatEffect effect)
+ {
+ // We've already cached this effect's stat, return it directly
+ if (AffectedStats.ContainsKey(effect)) return AffectedStats[effect];
+
+ // Get the data for the item the blueprint is for, return null if not found or not equippable
+ var blueprintItem = _cache.Get(blueprint.Item);
+ if (blueprintItem == null)
+ {
+ _logger($"Attempted to get stat effect but Blueprint {blueprint.ID} is not for an equippable item!");
+ return AffectedStats[effect] = null;
+ }
+
+ // Get the first behavior of the type specified in the blueprint stat effect, return null if not found
+ var effectBehavior =
+ blueprintItem.Behaviors.FirstOrDefault(b => b.GetType().Name == effect.StatReference.Behavior);
+ if (effectBehavior == null)
+ {
+ _logger($"Attempted to get stat effect for Blueprint {blueprint.ID} but stat references missing behavior \"{effect.StatReference.Behavior}\"!");
+ return AffectedStats[effect] = null;
+ }
+
+ // Get the first field in the behavior matching the name specified in the stat effect, return null if not found
+ var type = effectBehavior.GetType();
+ var field = type.GetField(effect.StatReference.Stat);
+ if (field == null)
+ {
+ _logger($"Attempted to get stat effect for Blueprint {blueprint.ID} but behavior {effect.StatReference.Behavior} does not have a stat named \"{effect.StatReference.Stat}\"!");
+ return AffectedStats[effect] = null;
+ }
+
+ // Finally we've confirmed the stat effect is valid, return the affected stat
+ return AffectedStats[effect] = field.GetValue(effectBehavior) as PerformanceStat;
+ }
+
// Determine quality of either the item itself or the specific ingredient this stat depends on
public float Quality(PerformanceStat stat, Gear item)
{
- Guid? ingredientID = stat.Ingredient;
+
+ var activeEffects = item.Blueprint.StatEffects.Where(x => GetAffectedStat(item.Blueprint, x) == stat).ToArray();
float quality;
- if (ingredientID == null)
+ if (!activeEffects.Any())
quality = item.CompoundQuality();
else
{
- var ingredientInstance =
- item.Ingredients.FirstOrDefault(i => i.Data == ingredientID) as CraftedItemInstance;
- if (ingredientInstance == null)
- throw new InvalidOperationException(
- $"Item {item.ID} has invalid crafting ingredients!");
- quality = ingredientInstance.CompoundQuality();
+ var ingredients = item.Ingredients.Where(i => activeEffects.Any(e => e.Ingredient == i.Data)).ToArray();
+ if(ingredients.Length != activeEffects.Length)
+ {
+ _logger($"Item {item.ID} does not have the ingredients specified by the stat effects of its blueprint!");
+ return 0;
+ }
+
+ float sum = 0;
+ foreach (var i in ingredients)
+ {
+ if (i is CraftedItemInstance ci)
+ sum += ci.CompoundQuality();
+ else _logger($"Blueprint stat effect for item {item.ID} specifies invalid (non crafted) ingredient!");
+ }
+
+ quality = sum / ingredients.Length;
}
return quality;
@@ -143,7 +194,8 @@ public class GameContext
ID = Guid.NewGuid()
};
- throw new InvalidOperationException("Attempted to create Simple Commodity instance using missing or incorrect item id");
+ _logger("Attempted to create Simple Commodity instance using missing or incorrect item id");
+ return null;
}
public CraftedItemInstance CreateInstance(Guid data, float quality)
@@ -151,10 +203,18 @@ public class GameContext
var item = _cache.Get(data);
if (item == null)
{
- throw new InvalidOperationException("Attempted to create crafted item instance using missing or incorrect item id");
+ _logger("Attempted to create crafted item instance using missing or incorrect item id!");
+ return null;
}
- var ingredients = item.Ingredients.SelectMany(ci =>
+ var blueprint = _cache.GetAll().FirstOrDefault(b => b.Item == data);
+ if (blueprint == null)
+ {
+ _logger("Attempted to create crafted item instance which has no blueprint!");
+ return null;
+ }
+
+ var ingredients = blueprint.Ingredients.SelectMany(ci =>
{
var ingredient = _cache.Get(ci.Key);
return ingredient is SimpleCommodityData
diff --git a/Assets/Scripts/ServerShared/GlobalData.cs b/Assets/Scripts/ServerShared/GlobalData.cs
index 847be4f3b..c0822a735 100644
--- a/Assets/Scripts/ServerShared/GlobalData.cs
+++ b/Assets/Scripts/ServerShared/GlobalData.cs
@@ -8,95 +8,95 @@ using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
using static NoiseFbm;
-[Serializable]
-[RethinkTable("Galaxy")]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[Serializable, RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class GlobalData : DatabaseEntry
{
- [InspectableField] [JsonProperty("targetPersistenceDuration")] [Key(1)]
+ [InspectableField, JsonProperty("targetPersistenceDuration"), Key(1)]
public float TargetPersistenceDuration = 3;
-
- [InspectableField] [JsonProperty("heatRadiationPower")] [Key(2)]
+
+ [InspectableField, JsonProperty("heatRadiationPower"), Key(2)]
public float HeatRadiationPower = 1;
-
- [InspectableField] [JsonProperty("heatRadiationMultiplier")] [Key(3)]
+
+ [InspectableField, JsonProperty("heatRadiationMultiplier"), Key(3)]
public float HeatRadiationMultiplier = 1;
-
- [InspectableField] [JsonProperty("galaxyArms")] [Key(13)]
+
+ [InspectableField, JsonProperty("galaxyArms"), Key(4)]
public int Arms = 4;
-
- [InspectableField] [JsonProperty("galaxyTwist")] [Key(14)]
+
+ [InspectableField, JsonProperty("galaxyTwist"), Key(5)]
public float Twist = 10;
-
- [InspectableField] [JsonProperty("galaxyTwistPower")] [Key(15)]
+
+ [InspectableField, JsonProperty("galaxyTwistPower"), Key(6)]
public float TwistPower = 2;
- [InspectableField] [JsonProperty("radiusPower")] [Key(4)]
+ [InspectableField, JsonProperty("radiusPower"), Key(7)]
public float RadiusPower = 1.75f;
- [InspectableField] [JsonProperty("massFloor")] [Key(5)]
+ [InspectableField, JsonProperty("massFloor"), Key(8)]
public float MassFloor = 1;
- [InspectableField] [JsonProperty("sunMass")] [Key(6)]
+ [InspectableField, JsonProperty("sunMass"), Key(9)]
public float SunMass = 10000;
- [InspectableField] [JsonProperty("gasGiantMass")] [Key(7)]
+ [InspectableField, JsonProperty("gasGiantMass"), Key(10)]
public float GasGiantMass = 2000;
-
- [InspectableField] [JsonProperty("dockingDistance")] [Key(8)]
+
+ [InspectableField, JsonProperty("dockingDistance"), Key(11)]
public float DockingDistance = 10;
-
- [InspectableField] [JsonProperty("satelliteCreationMassFloor")] [Key(9)]
+
+ [InspectableField, JsonProperty("satelliteCreationMassFloor"), Key(12)]
public float SatelliteCreationMassFloor = 100;
-
- [InspectableField] [JsonProperty("satelliteCreationProbability")] [Key(10)]
+
+ [InspectableField, JsonProperty("satelliteCreationProbability"), Key(13)]
public float SatelliteCreationProbability = .25f;
-
- [InspectableField] [JsonProperty("binaryCreationProbability")] [Key(11)]
+
+ [InspectableField, JsonProperty("binaryCreationProbability"), Key(14)]
public float BinaryCreationProbability = .25f;
-
- [InspectableField] [JsonProperty("rosetteProbability")] [Key(12)]
+
+ [InspectableField, JsonProperty("rosetteProbability"), Key(15)]
public float RosetteProbability = .25f;
- [InspectableField] [JsonProperty("mapLayers")] [Key(16)]
- public Dictionary MapLayers = new Dictionary();
-
- [InspectableField] [JsonProperty("zoneRadiusMin")] [Key(17)]
+ // [InspectableField] [JsonProperty("mapLayers")] [Key(16)]
+ // public Dictionary MapLayers = new Dictionary();
+
+ [InspectableField, JsonProperty("zoneRadiusMin"), Key(16)]
public float MinimumZoneRadius = 500;
-
- [InspectableField] [JsonProperty("zoneRadiusMax")] [Key(18)]
+
+ [InspectableField, JsonProperty("zoneRadiusMax"), Key(17)]
public float MaximumZoneRadius = 2000;
-
- [InspectableField] [JsonProperty("zoneMassMin")] [Key(19)]
+
+ [InspectableField, JsonProperty("zoneMassMin"), Key(18)]
public float MinimumZoneMass = 10000;
-
- [InspectableField] [JsonProperty("zoneMassMax")] [Key(20)]
+
+ [InspectableField, JsonProperty("zoneMassMax"), Key(19)]
public float MaximumZoneMass = 100000;
-
- [InspectableField] [JsonProperty("orbitPeriodExponent")] [Key(21)]
+
+ [InspectableField, JsonProperty("orbitPeriodExponent"), Key(20)]
public float OrbitPeriodExponent = 1.5f;
-
- [InspectableField] [JsonProperty("orbitPeriodMultiplier")] [Key(22)]
+
+ [InspectableField, JsonProperty("orbitPeriodMultiplier"), Key(21)]
public float OrbitPeriodMultiplier = 1f;
-
- [InspectableField] [JsonProperty("gravityRadiusExponent")] [Key(23)]
+
+ [InspectableField, JsonProperty("gravityRadiusExponent"), Key(22)]
public float GravityRadiusExponent = 1.5f;
-
- [InspectableField] [JsonProperty("gravityRadiusMultiplier")] [Key(24)]
+
+ [InspectableField, JsonProperty("gravityRadiusMultiplier"), Key(23)]
public float GravityRadiusMultiplier = 1f;
-
- [InspectableField] [JsonProperty("beltProbability")] [Key(25)]
+
+ [InspectableField, JsonProperty("beltProbability"), Key(24)]
public float BeltProbability = .05f;
-
- [InspectableField] [JsonProperty("beltMassCeiling")] [Key(26)]
+
+ [InspectableField, JsonProperty("beltMassCeiling"), Key(25)]
public float BeltMassCeiling = 500f;
-
- [InspectableField] [JsonProperty("beltMassRatio")] [Key(27)]
+
+ [InspectableField, JsonProperty("beltMassRatio"), Key(26)]
public float BeltMassRatio = 100f;
-
- [InspectableField] [JsonProperty("beltMassExponent")] [Key(28)]
+
+ [InspectableField, JsonProperty("beltMassExponent"), Key(27)]
public float BeltMassExponent = 100f;
+
+ [InspectableField, JsonProperty("planetMass"), Key(28)]
+ public float PlanetMass = 100f;
public float PlanetRadius(float mass)
{
@@ -104,52 +104,50 @@ public class GlobalData : DatabaseEntry
}
}
-[Serializable]
-[RethinkTable("Galaxy")]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
-public class GalaxyMapLayerData : DatabaseEntry
+[Inspectable, Serializable, RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class GalaxyMapLayerData : DatabaseEntry, INamedEntry
{
- [InspectableField] [JsonProperty("coreBoost")] [Key(1)]
+ [InspectableField, JsonProperty("coreBoost"), Key(1)]
public float CoreBoost = 1.05f;
-
- [InspectableField] [JsonProperty("coreBoostOffset")] [Key(2)]
+
+ [InspectableField, JsonProperty("coreBoostOffset"), Key(2)]
public float CoreBoostOffset = .1f;
-
- [InspectableField] [JsonProperty("coreBoostPower")] [Key(3)]
+
+ [InspectableField, JsonProperty("coreBoostPower"), Key(3)]
public float CoreBoostPower = 2.25f;
-
- [InspectableField] [JsonProperty("spokeScale")] [Key(4)]
+
+ [InspectableField, JsonProperty("spokeScale"), Key(4)]
public float SpokeScale = 1;
-
- [InspectableField] [JsonProperty("spokeOffset")] [Key(5)]
+
+ [InspectableField, JsonProperty("spokeOffset"), Key(5)]
public float SpokeOffset = 0;
-
- [InspectableField] [JsonProperty("edgeReduction")] [Key(6)]
+
+ [InspectableField, JsonProperty("edgeReduction"), Key(6)]
public float EdgeReduction = 3;
-
- [InspectableField] [JsonProperty("noiseOffset")] [Key(7)]
+
+ [InspectableField, JsonProperty("noiseOffset"), Key(7)]
public float NoiseOffset = 0;
-
- [InspectableField] [JsonProperty("noiseAmplitude")] [Key(8)]
+
+ [InspectableField, JsonProperty("noiseAmplitude"), Key(8)]
public float NoiseAmplitude = 1.5f;
-
- [InspectableField] [JsonProperty("noiseGain")] [Key(9)]
+
+ [InspectableField, JsonProperty("noiseGain"), Key(9)]
public float NoiseGain = .7f;
-
- [InspectableField] [JsonProperty("noiseLacunarity")] [Key(10)]
+
+ [InspectableField, JsonProperty("noiseLacunarity"), Key(10)]
public float NoiseLacunarity = 2;
-
- [InspectableField] [JsonProperty("noiseOctaves")] [Key(11)]
+
+ [InspectableField, JsonProperty("noiseOctaves"), Key(11)]
public int NoiseOctaves = 7;
-
- [InspectableField] [JsonProperty("noiseFrequency")] [Key(12)]
+
+ [InspectableField, JsonProperty("noiseFrequency"), Key(12)]
public float NoiseFrequency = 1;
-
- [InspectableField] [JsonProperty("noisePosition")] [Key(13)]
+
+ [InspectableField, JsonProperty("noisePosition"), Key(13)]
public float NoisePosition = 1337;
- [IgnoreMember] public string Name;
+ [InspectableField, JsonProperty("name"), Key(14)]
+ public string Name;
public float Evaluate(float2 uv, GlobalData data)
{
@@ -165,6 +163,12 @@ public class GalaxyMapLayerData : DatabaseEntry
return gal;
}
+
+ [IgnoreMember] public string EntryName
+ {
+ get => Name;
+ set => Name = value;
+ }
}
public static class NoiseFbm
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Afterburner.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Afterburner.cs
index bab7ea30b..073f1b28c 100644
--- a/Assets/Scripts/ServerShared/ItemBehaviors/Afterburner.cs
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Afterburner.cs
@@ -1,22 +1,20 @@
using System.Collections.Generic;
+using System.Linq;
using MessagePack;
using Newtonsoft.Json;
-[RethinkTable("Items")]
-[InspectableField]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class AfterburnerBehaviorData : IItemBehaviorData
{
- [InspectableField] [JsonProperty("thrust")] [Key(0)]
- public PerformanceStat ThrustModifier;
+ [InspectableField, JsonProperty("thrust"), Key(0)]
+ public PerformanceStat ThrustModifier = new PerformanceStat();
- [InspectableField] [JsonProperty("speed")] [Key(1)]
- public PerformanceStat SpeedModifier;
+ [InspectableField, JsonProperty("speed"), Key(1)]
+ public PerformanceStat SpeedModifier = new PerformanceStat();
- [InspectableField] [JsonProperty("torque")] [Key(2)]
- public PerformanceStat TorqueModifier;
+ [InspectableField, JsonProperty("torque"), Key(2)]
+ public PerformanceStat TorqueModifier = new PerformanceStat();
public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
{
@@ -28,6 +26,7 @@ public class AfterburnerBehavior : IActivatedItemBehavior
{
private List> _modifiers = new List>();
private AfterburnerBehaviorData _data;
+ private ThrusterBehaviorData[] _thrusters;
public Ship Ship { get; }
public Gear Item { get; }
@@ -43,6 +42,11 @@ public class AfterburnerBehavior : IActivatedItemBehavior
Item = item;
}
+ public void Initialize()
+ {
+ _thrusters = Ship.GetBehaviorData().ToArray();
+ }
+
public void Update(float delta)
{
}
@@ -53,17 +57,22 @@ public class AfterburnerBehavior : IActivatedItemBehavior
public void Activate()
{
- var thrustMod = Ship.GetEquipped().Thrust.GetScaleModifiers(Ship);
- _modifiers.Add(thrustMod);
- thrustMod.Add(this,Context.Evaluate(_data.ThrustModifier,Item, Ship));
+ if (_thrusters.Length == 0) return;
- var speedMod = (Ship.Hull.ItemData as HullData).TopSpeed.GetScaleModifiers(Ship);
- _modifiers.Add(speedMod);
- speedMod.Add(this,Context.Evaluate(_data.SpeedModifier,Item, Ship));
+ foreach (var thruster in _thrusters)
+ {
+ var thrustMod = thruster.Thrust.GetScaleModifiers(Ship);
+ thrustMod.Add(this,Context.Evaluate(_data.ThrustModifier,Item, Ship));
+ _modifiers.Add(thrustMod);
+ }
- var torqueMod = (Ship.GetEquipped(HardpointType.Thruster).ItemData as ThrusterData).Torque.GetScaleModifiers(Ship);
- _modifiers.Add(torqueMod);
- torqueMod.Add(this,Context.Evaluate(_data.TorqueModifier,Item, Ship));
+ // var speedMod = (Ship.Hull.ItemData as HullData).TopSpeed.GetScaleModifiers(Ship);
+ // _modifiers.Add(speedMod);
+ // speedMod.Add(this,Context.Evaluate(_data.SpeedModifier,Item, Ship));
+ //
+ // var torqueMod = (Ship.GetEquipped(HardpointType.Thruster).ItemData as ThrusterData).Torque.GetScaleModifiers(Ship);
+ // _modifiers.Add(torqueMod);
+ // torqueMod.Add(this,Context.Evaluate(_data.TorqueModifier,Item, Ship));
Ship.ForceThrust = true;
}
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Behaviors.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Behaviors.cs
index 9d13f8f56..3ad7b7720 100644
--- a/Assets/Scripts/ServerShared/ItemBehaviors/Behaviors.cs
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Behaviors.cs
@@ -11,6 +11,7 @@ using static Unity.Mathematics.noise;
public interface IItemBehavior
{
+ void Initialize();
void Update(float delta);
void FixedUpdate(float delta);
Ship Ship { get; }
@@ -25,15 +26,19 @@ public interface IActivatedItemBehavior : IItemBehavior
void Deactivate();
}
-[InspectableField]
-[Union(0, typeof(CannonBehaviorData))]
-[Union(1, typeof(LauncherBehaviorData))]
-[Union(2, typeof(ReactorBehaviorData))]
+public interface IAnalogItemBehavior : IItemBehavior
+{
+ void SetAxis(float value);
+}
+
+[InspectableField,
+ Union(0, typeof(CannonBehaviorData)),
+ Union(1, typeof(LauncherBehaviorData)),
+ Union(2, typeof(ReactorBehaviorData)),
+ Union(4, typeof(AfterburnerBehaviorData)),
+ Union(5, typeof(SensorBehaviorData)),
+ JsonConverter(typeof(JsonKnownTypesConverter)), JsonObject(MemberSerialization.OptIn)]
// [Union(3, typeof(PlusUltraBehaviorData))]
-[Union(4, typeof(AfterburnerBehaviorData))]
-[Union(5, typeof(SensorBehaviorData))]
-[JsonConverter(typeof(JsonKnownTypesConverter))]
-[JsonObject(MemberSerialization.OptIn)]
public interface IItemBehaviorData
{
IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item);
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Cannon.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Cannon.cs
index 75838417d..12ad73d3c 100644
--- a/Assets/Scripts/ServerShared/ItemBehaviors/Cannon.cs
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Cannon.cs
@@ -1,53 +1,20 @@
using MessagePack;
using Newtonsoft.Json;
-[RethinkTable("Items")]
-[InspectableField]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
-public class CannonBehaviorData : IItemBehaviorData
+[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class CannonBehaviorData : WeaponBehaviorData, IItemBehaviorData
{
- [InspectablePrefab] [JsonProperty("bullet")] [Key(0)]
+ [InspectablePrefab, JsonProperty("bullet"), Key(9)]
public string BulletPrefab;
-
- [InspectableField] [JsonProperty("damageType")] [Key(1)]
- public DamageType DamageType;
- [InspectableField] [JsonProperty("burstCount")] [Key(2)]
- public int BurstCount;
+ [InspectableField, JsonProperty("spread"), Key(10)]
+ public PerformanceStat Spread = new PerformanceStat();
- [InspectableField] [JsonProperty("burstTime")] [Key(3)]
- public PerformanceStat BurstTime;
-
- [InspectableField] [JsonProperty("bulletRange")] [Key(4)]
- public PerformanceStat Range;
-
- [InspectableField] [JsonProperty("spread")] [Key(5)]
- public PerformanceStat Spread;
-
- [InspectableField] [JsonProperty("bulletInherit")] [Key(6)]
+ [InspectableField, JsonProperty("bulletInherit"), Key(11)]
public float Inherit;
- [InspectableField] [JsonProperty("deflection")] [Key(7)]
- public float Deflection;
-
- [InspectableField] [JsonProperty("visibility")] [Key(8)]
- public PerformanceStat Visibility;
-
- [InspectableField] [JsonProperty("visibilityDecay")] [Key(9)]
- public PerformanceStat VisibilityDecay;
-
- [InspectableField] [JsonProperty("bulletVelocity")] [Key(10)]
- public PerformanceStat Velocity;
-
- [InspectableField] [JsonProperty("cooldown")] [Key(11)]
- public PerformanceStat Cooldown;
-
- [InspectableField] [JsonProperty("damage")] [Key(12)]
- public PerformanceStat Damage;
-
- [InspectableField] [JsonProperty("heat")] [Key(13)]
- public PerformanceStat Heat;
+ [InspectableField, JsonProperty("bulletVelocity"), Key(12)]
+ public PerformanceStat Velocity = new PerformanceStat();
public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
{
@@ -114,6 +81,10 @@ public class CannonBehavior : IActivatedItemBehavior
_firing = false;
}
+ public void Initialize()
+ {
+ }
+
public void Update(float delta)
{
_cooldown -= delta / Context.Evaluate(_cannon.Cooldown, Item, Ship);
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Launcher.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Launcher.cs
index bdc1d9b06..9fab8cbc3 100644
--- a/Assets/Scripts/ServerShared/ItemBehaviors/Launcher.cs
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Launcher.cs
@@ -4,72 +4,38 @@ using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
-[RethinkTable("Items")]
-[InspectableField]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class LauncherBehaviorData : IItemBehaviorData
{
- // [MessagePackFormatter(typeof(UnityGameObjectFormatter))]
- // [Inspectable] [Key("missile")] public GameObject MissilePrefab;
- // [MessagePackFormatter(typeof(ClipListFormatter))]
- // [Inspectable] [Key("sounds")] public List Sounds;
- // [MessagePackFormatter(typeof(UnityAudioClipFormatter))]
- // [Inspectable] [Key("beepSound")] public AudioClip BeepSound;
- // [Inspectable] [Key("beepCount")] public int Beeps;
- [InspectableField] [JsonProperty("damageType")] [Key(0)]
- public DamageType DamageType;
+ [InspectablePrefab, JsonProperty("missile"), Key(9)]
+ public string MissilePrefab;
- [InspectableField] [JsonProperty("burstCount")] [Key(1)]
- public int BurstCount;
-
- [InspectableField] [JsonProperty("burstTime")] [Key(2)]
- public PerformanceStat BurstTime;
-
- [InspectableField] [JsonProperty("range")] [Key(3)]
- public PerformanceStat Range;
-
- [InspectableAnimationCurve] [JsonProperty("guidance")] [Key(4)]
+ [InspectableAnimationCurve, JsonProperty("guidance"), Key(10)]
public float4[] GuidanceCurve;
- [InspectableAnimationCurve] [JsonProperty("thrustCurve")] [Key(5)]
+ [InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(11)]
public float4[] ThrustCurve;
- [InspectableAnimationCurve] [JsonProperty("liftCurve")] [Key(6)]
+ [InspectableAnimationCurve, JsonProperty("liftCurve"), Key(12)]
public float4[] LiftCurve;
- [InspectableField] [JsonProperty("thrust")] [Key(7)]
- public PerformanceStat Thrust;
+ [InspectableField, JsonProperty("thrust"), Key(13)]
+ public PerformanceStat Thrust = new PerformanceStat();
- [InspectableField] [JsonProperty("deflection")] [Key(8)]
- public float Deflection;
+ [InspectableField, JsonProperty("lockAngle"), Key(14)]
+ public float LockAngle;
- [InspectableField] [JsonProperty("lockOnBuffer")] [Key(9)]
- public float LockOnDegrees;
-
- [InspectableField] [JsonProperty("frequency")] [Key(10)]
+ [InspectableField, JsonProperty("frequency"), Key(15)]
public float DodgeFrequency;
- [InspectableField] [JsonProperty("visibility")] [Key(11)]
- public PerformanceStat Visibility;
+ [InspectableField, JsonProperty("launchSpeed"), Key(16)]
+ public PerformanceStat LaunchSpeed = new PerformanceStat();
- [InspectableField] [JsonProperty("launchSpeed")] [Key(12)]
- public PerformanceStat LaunchSpeed;
+ [InspectableField, JsonProperty("missileSpeed"), Key(17)]
+ public PerformanceStat MissileSpeed = new PerformanceStat();
- [InspectableField] [JsonProperty("missileSpeed")] [Key(13)]
- public PerformanceStat MissileSpeed;
-
- [InspectableField] [JsonProperty("cooldown")] [Key(14)]
- public PerformanceStat Cooldown;
-
- [InspectableField] [JsonProperty("lockOnTime")] [Key(15)]
- public PerformanceStat LockOnTime;
-
- [InspectableField] [JsonProperty("damage")] [Key(16)]
- public PerformanceStat Damage;
-
- [InspectableField] [JsonProperty("heat")] [Key(17)]
- public PerformanceStat Heat;
+ [InspectableField, JsonProperty("lockOnTime"), Key(18)]
+ public PerformanceStat LockOnTime = new PerformanceStat();
public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
{
@@ -154,6 +120,10 @@ public class LauncherBehavior : IActivatedItemBehavior
// _lockingTimer = 1;
}
+ public void Initialize()
+ {
+ }
+
public void Update(float delta)
{
// if (Ship.Target == null)
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Reactor.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Reactor.cs
index 63cc7530c..f18578c55 100644
--- a/Assets/Scripts/ServerShared/ItemBehaviors/Reactor.cs
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Reactor.cs
@@ -1,25 +1,23 @@
using MessagePack;
using Newtonsoft.Json;
-[RethinkTable("Items")]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class ReactorBehaviorData : IItemBehaviorData
{
- [InspectableField] [JsonProperty("charge")] [Key(0)]
- public PerformanceStat Charge;
+ [InspectableField, JsonProperty("charge"), Key(0)]
+ public PerformanceStat Charge = new PerformanceStat();
- [InspectableField] [JsonProperty("capacitance")] [Key(1)]
- public PerformanceStat Capacitance;
+ [InspectableField, JsonProperty("capacitance"), Key(1)]
+ public PerformanceStat Capacitance = new PerformanceStat();
- [InspectableField] [JsonProperty("efficiency")] [Key(2)]
- public PerformanceStat Efficiency;
+ [InspectableField, JsonProperty("efficiency"), Key(2)]
+ public PerformanceStat Efficiency = new PerformanceStat();
- [InspectableField] [JsonProperty("overload")] [Key(3)]
- public PerformanceStat OverloadEfficiency;
+ [InspectableField, JsonProperty("overload"), Key(3)]
+ public PerformanceStat OverloadEfficiency = new PerformanceStat();
- [InspectableField] [JsonProperty("underload")] [Key(4)]
- public PerformanceStat UnderloadRecovery;
+ [InspectableField, JsonProperty("underload"), Key(4)]
+ public PerformanceStat UnderloadRecovery = new PerformanceStat();
public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
{
@@ -68,6 +66,10 @@ public class ReactorBehavior : IItemBehavior
}
+ public void Initialize()
+ {
+ }
+
public void Update(float delta)
{
}
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Sensor.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Sensor.cs
index 989a76446..a1aa59d65 100644
--- a/Assets/Scripts/ServerShared/ItemBehaviors/Sensor.cs
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Sensor.cs
@@ -2,23 +2,20 @@
using MessagePack;
using Newtonsoft.Json;
-[RethinkTable("Items")]
-[InspectableField]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class SensorBehaviorData : IItemBehaviorData
{
- [InspectableField] [JsonProperty("radiance")] [Key(0)]
- public PerformanceStat Radiance;
+ [InspectableField, JsonProperty("radiance"), Key(0)]
+ public PerformanceStat Radiance = new PerformanceStat();
- [InspectableField] [JsonProperty("masking")] [Key(1)]
- public PerformanceStat RadianceMasking;
+ [InspectableField, JsonProperty("masking"), Key(1)]
+ public PerformanceStat RadianceMasking = new PerformanceStat();
- [InspectableField] [JsonProperty("sensitivity")] [Key(2)]
- public PerformanceStat Sensitivity;
+ [InspectableField, JsonProperty("sensitivity"), Key(2)]
+ public PerformanceStat Sensitivity = new PerformanceStat();
- [InspectableField] [JsonProperty("range")] [Key(3)]
- public PerformanceStat Range;
+ [InspectableField, JsonProperty("range"), Key(3)]
+ public PerformanceStat Range = new PerformanceStat();
public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
{
@@ -44,6 +41,10 @@ public class SensorBehavior : IItemBehavior
Context = context;
}
+ public void Initialize()
+ {
+ }
+
public void Update(float delta)
{
// var ship = Hardpoint.Ship.Ship.transform;
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs
new file mode 100644
index 000000000..9f6d47219
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs
@@ -0,0 +1,52 @@
+using MessagePack;
+using Newtonsoft.Json;
+using Unity.Mathematics;
+using static Unity.Mathematics.math;
+
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class ShieldBehaviorData : IItemBehaviorData
+{
+ [InspectableField, JsonProperty("efficiency"), Key(0)]
+ public PerformanceStat Efficiency = new PerformanceStat();
+
+ [InspectableField, JsonProperty("shielding"), Key(1)]
+ public PerformanceStat Shielding = new PerformanceStat();
+
+ public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
+ {
+ return new ShieldBehavior(context, this, ship, item);
+ }
+}
+
+public class ShieldBehavior : IItemBehavior
+{
+ public Ship Ship { get; }
+ public Gear Item { get; }
+ public GameContext Context { get; }
+
+ public IItemBehaviorData Data => _data;
+
+ private ShieldBehaviorData _data;
+
+ public ShieldBehavior(GameContext context, ShieldBehaviorData data, Ship ship, Gear item)
+ {
+ Context = context;
+ _data = data;
+ Ship = ship;
+ Item = item;
+
+ // TODO: Detect hits on Ship, keep a list of callbacks that modify the hit by reference
+ }
+
+ public void FixedUpdate(float delta)
+ {
+ }
+
+ public void Initialize()
+ {
+ }
+
+ public void Update(float delta)
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs.meta b/Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs.meta
new file mode 100644
index 000000000..872817b1a
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: dbb1419b4645402aad5a394b983a637f
+timeCreated: 1586275939
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs
new file mode 100644
index 000000000..f30d1721e
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs
@@ -0,0 +1,67 @@
+using MessagePack;
+using Newtonsoft.Json;
+using Unity.Mathematics;
+using static Unity.Mathematics.math;
+
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class ThrusterBehaviorData : IItemBehaviorData
+{
+ [InspectableField, JsonProperty("thrust"), Key(0)]
+ public PerformanceStat Thrust = new PerformanceStat();
+
+ [InspectableField, JsonProperty("torque"), Key(1)]
+ public PerformanceStat Torque = new PerformanceStat();
+
+ [InspectableField, JsonProperty("visibility"), Key(2)]
+ public PerformanceStat Visibility = new PerformanceStat();
+
+ [InspectableField, JsonProperty("heat"), Key(3)]
+ public PerformanceStat Heat = new PerformanceStat();
+
+ public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
+ {
+ return new ThrusterBehavior(context, this, ship, item);
+ }
+}
+
+public class ThrusterBehavior : IAnalogItemBehavior
+{
+ public Ship Ship { get; }
+ public Gear Item { get; }
+ public GameContext Context { get; }
+
+ public IItemBehaviorData Data => _data;
+
+ private ThrusterBehaviorData _data;
+
+ private float _thrust;
+
+ public ThrusterBehavior(GameContext context, ThrusterBehaviorData data, Ship ship, Gear item)
+ {
+ Context = context;
+ _data = data;
+ Ship = ship;
+ Item = item;
+ }
+
+ public void SetAxis(float value)
+ {
+ _thrust = saturate(value);
+ }
+
+ public void FixedUpdate(float delta)
+ {
+
+ }
+
+ public void Initialize()
+ {
+ }
+
+ public void Update(float delta)
+ {
+ Ship.Velocity += _thrust * Context.Evaluate(_data.Thrust, Item, Ship) * delta;
+ Ship.AddHeat(_thrust * Context.Evaluate(_data.Heat, Item, Ship) * delta);
+ Ship.VisibilitySources[this] = _thrust * Context.Evaluate(_data.Visibility, Item, Ship);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs.meta b/Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs.meta
new file mode 100644
index 000000000..1ce6b1df0
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: f46e0da62f8c40f69bba0b7bcff8662f
+timeCreated: 1586267627
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs
new file mode 100644
index 000000000..8dbc7ac9a
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs
@@ -0,0 +1,64 @@
+using MessagePack;
+using Newtonsoft.Json;
+using Unity.Mathematics;
+using static Unity.Mathematics.math;
+
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class TurningBehaviorData : IItemBehaviorData
+{
+ [InspectableField, JsonProperty("torque"), Key(0)]
+ public PerformanceStat Torque = new PerformanceStat();
+
+ [InspectableField, JsonProperty("visibility"), Key(1)]
+ public PerformanceStat Visibility = new PerformanceStat();
+
+ [InspectableField, JsonProperty("heat"), Key(2)]
+ public PerformanceStat Heat = new PerformanceStat();
+
+ public IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item)
+ {
+ return new TurningBehavior(context, this, ship, item);
+ }
+}
+
+public class TurningBehavior : IAnalogItemBehavior
+{
+ public Ship Ship { get; }
+ public Gear Item { get; }
+ public GameContext Context { get; }
+
+ public IItemBehaviorData Data => _data;
+
+ private TurningBehaviorData _data;
+
+ private float _turning;
+
+ public TurningBehavior(GameContext context, TurningBehaviorData data, Ship ship, Gear item)
+ {
+ Context = context;
+ _data = data;
+ Ship = ship;
+ Item = item;
+ }
+
+ public void SetAxis(float value)
+ {
+ _turning = clamp(value, -1, 1);
+ }
+
+ public void FixedUpdate(float delta)
+ {
+
+ }
+
+ public void Initialize()
+ {
+ }
+
+ public void Update(float delta)
+ {
+ Ship.Direction = mul(Ship.Direction, Unity.Mathematics.float2x2.Rotate(_turning * Context.Evaluate(_data.Torque, Item, Ship) * delta));
+ Ship.AddHeat(abs(_turning) * Context.Evaluate(_data.Heat, Item, Ship) * delta);
+ Ship.VisibilitySources[this] = abs(_turning) * Context.Evaluate(_data.Visibility, Item, Ship);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs.meta b/Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs.meta
new file mode 100644
index 000000000..48dc539aa
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 21343037bc4842669c20b0606b03a622
+timeCreated: 1586270198
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs b/Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs
new file mode 100644
index 000000000..2390c294d
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs
@@ -0,0 +1,34 @@
+using MessagePack;
+using Newtonsoft.Json;
+
+[Union(0, typeof(CannonBehaviorData)),
+ Union(1, typeof(LauncherBehaviorData))]
+public abstract class WeaponBehaviorData
+{
+ [InspectableField, JsonProperty("damageType"), Key(0)]
+ public DamageType DamageType;
+
+ [InspectableField, JsonProperty("damage"), Key(1)]
+ public PerformanceStat Damage = new PerformanceStat();
+
+ [InspectableField, JsonProperty("range"), Key(2)]
+ public PerformanceStat Range = new PerformanceStat();
+
+ [InspectableField, JsonProperty("cooldown"), Key(3)]
+ public PerformanceStat Cooldown = new PerformanceStat();
+
+ [InspectableField, JsonProperty("heat"), Key(4)]
+ public PerformanceStat Heat = new PerformanceStat();
+
+ [InspectableField, JsonProperty("visibility"), Key(5)]
+ public PerformanceStat Visibility = new PerformanceStat();
+
+ [InspectableField, JsonProperty("visibilityDecay"), Key(6)]
+ public PerformanceStat VisibilityDecay = new PerformanceStat();
+
+ [InspectableField, JsonProperty("burstCount"), Key(7)]
+ public int BurstCount;
+
+ [InspectableField, JsonProperty("burstTime"), Key(8)]
+ public PerformanceStat BurstTime = new PerformanceStat();
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs.meta b/Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs.meta
new file mode 100644
index 000000000..7414ab456
--- /dev/null
+++ b/Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: d87bbbe67d6d48cb8f0cca9611985c00
+timeCreated: 1586295838
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/ItemData.cs b/Assets/Scripts/ServerShared/ItemData.cs
index c59b7f1e9..c38c6a33c 100644
--- a/Assets/Scripts/ServerShared/ItemData.cs
+++ b/Assets/Scripts/ServerShared/ItemData.cs
@@ -6,27 +6,25 @@ using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
-[MessagePackObject]
-[Union(0, typeof(SimpleCommodityData))]
-[Union(1, typeof(CompoundCommodityData))]
-[Union(2, typeof(GearData))]
-[Union(3, typeof(HullData))]
-[Union(4, typeof(ShieldData))]
-[Union(5, typeof(ThrusterData))]
-[JsonObject(MemberSerialization.OptIn)]
-[JsonConverter(typeof(JsonKnownTypesConverter))]
+[MessagePackObject,
+ Union(0, typeof(SimpleCommodityData)),
+ Union(1, typeof(CompoundCommodityData)),
+ Union(2, typeof(GearData)),
+ Union(3, typeof(HullData)),
+ JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter))]
public abstract class ItemData : DatabaseEntry, INamedEntry
{
- [InspectableField] [JsonProperty("name")] [Key(1)]
+ [InspectableField, JsonProperty("name"), Key(1)]
public string Name;
- [InspectableField] [JsonProperty("mass")] [Key(2)]
+ [InspectableField, JsonProperty("mass"), Key(2)]
public float Mass;
- [InspectableField] [JsonProperty("size")] [Key(3)]
+ [InspectableField, JsonProperty("size"), Key(3)]
public float Size;
- [InspectableField] [JsonProperty("specificHeat")] [Key(4)]
+ // Heat needed to change temperature of 1 gram by 1 degree
+ [InspectableField, JsonProperty("specificHeat"), Key(4)]
public float SpecificHeat;
[IgnoreMember] public string EntryName
@@ -36,61 +34,66 @@ public abstract class ItemData : DatabaseEntry, INamedEntry
}
}
-[RethinkTable("Items")]
-[Inspectable]
-[MessagePackObject]
-public class SimpleCommodityData : ItemData {}
-
-[MessagePackObject]
-[Union(0, typeof(CompoundCommodityData))]
-[Union(1, typeof(GearData))]
-[Union(2, typeof(HullData))]
-[Union(3, typeof(ShieldData))]
-[Union(4, typeof(ThrusterData))]
-[JsonObject(MemberSerialization.OptIn)]
-[JsonConverter(typeof(JsonKnownTypesConverter))]
-public abstract class CraftedItemData : ItemData
+[RethinkTable("Items"), Inspectable, MessagePackObject]
+public class SimpleCommodityData : ItemData
{
- [InspectableField] [JsonProperty("ingredients")] [Key(5)]
- public Dictionary Ingredients = new Dictionary();
+ // Types of body where this resource can be found
+ [InspectableField, JsonProperty("resourceBodyType"), Key(5)]
+ public BodyType ResourceBodyType;
+
+ // Link to map(s) controlling density of resource, multiplied together when more than one
+ [InspectableDatabaseLink(typeof(GalaxyMapLayerData)), JsonProperty("resourceDensity"), Key(6)]
+ public List ResourceDensity = new List();
+
+ // Controls the bias power variable during resource placement
+ [InspectableField, JsonProperty("resourceDensityBiasPower"), Key(7)]
+ public float ResourceDensityBiasPower = 5;
+
+ // Minimum amount of resources needed for presence to register
+ [InspectableField, JsonProperty("resourceFloor"), Key(8)]
+ public float ResourceFloor = 10f;
}
-[RethinkTable("Items")]
-[Inspectable]
-[MessagePackObject]
+[MessagePackObject,
+ Union(0, typeof(CompoundCommodityData)),
+ Union(1, typeof(GearData)),
+ Union(2, typeof(HullData)),
+ JsonObject(MemberSerialization.OptIn),
+ JsonConverter(typeof(JsonKnownTypesConverter))]
+public abstract class CraftedItemData : ItemData
+{
+}
+
+[RethinkTable("Items"), Inspectable, MessagePackObject]
public class CompoundCommodityData : CraftedItemData {}
-[Union(0, typeof(GearData))]
-[Union(1, typeof(HullData))]
-[Union(2, typeof(ShieldData))]
-[Union(3, typeof(ThrusterData))]
-[JsonObject(MemberSerialization.OptIn)]
-[JsonConverter(typeof(JsonKnownTypesConverter))]
+[Union(0, typeof(GearData)),
+ Union(1, typeof(HullData)),
+ JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter))]
public abstract class EquippableItemData : CraftedItemData
{
+ [InspectableField, JsonProperty("draw"), Key(6)]
+ public PerformanceStat EnergyDraw = new PerformanceStat();
- [InspectableField] [JsonProperty("draw")] [Key(6)]
- public PerformanceStat EnergyDraw;
-
- [InspectableAnimationCurve] [JsonProperty("performanceCurve")] [Key(7)]
+ [InspectableAnimationCurve, JsonProperty("performanceCurve"), Key(7)]
public float4[] HeatPerformanceCurve;
-
- [TemperatureInspectable] [JsonProperty("minTemp")] [Key(8)]
+
+ [TemperatureInspectable, JsonProperty("minTemp"), Key(8)]
public float MinimumTemperature;
-
- [TemperatureInspectable] [JsonProperty("maxTemp")] [Key(9)]
+
+ [TemperatureInspectable, JsonProperty("maxTemp"), Key(9)]
public float MaximumTemperature;
-
- [InspectableField] [JsonProperty("durability")] [Key(10)]
+
+ [InspectableField, JsonProperty("durability"), Key(10)]
public float Durability;
- [InspectableField] [JsonProperty("durabilityExponent")] [Key(11)]
- public PerformanceStat DurabilityExponent;
+ [InspectableField, JsonProperty("durabilityExponent"), Key(11)]
+ public PerformanceStat DurabilityExponent = new PerformanceStat();
- [InspectableField] [JsonProperty("heatExponent")] [Key(12)]
- public PerformanceStat HeatExponent;
-
- [InspectableField] [JsonProperty("behaviors")] [Key(13)]
+ [InspectableField, JsonProperty("heatExponent"), Key(12)]
+ public PerformanceStat HeatExponent = new PerformanceStat();
+
+ [InspectableField, JsonProperty("behaviors"), Key(13)]
public List Behaviors = new List();
[IgnoreMember]
@@ -125,117 +128,70 @@ public abstract class EquippableItemData : CraftedItemData
}
}
-[RethinkTable("Items")]
-[Inspectable]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class GearData : EquippableItemData
{
- [InspectableField] [JsonProperty("hardpointType")] [Key(14)] public HardpointType Hardpoint;
+ [InspectableField, JsonProperty("hardpointType"), Key(14)]
+ public HardpointType Hardpoint;
[IgnoreMember] public override HardpointType HardpointType => Hardpoint;
}
-[RethinkTable("Items")]
-[Inspectable]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class HullData : EquippableItemData
{
- [InspectableField] [JsonProperty("hullCapacity")] [Key(14)]
- public PerformanceStat Capacity;
+ [InspectableField, JsonProperty("hullCapacity"), Key(14)]
+ public PerformanceStat Capacity = new PerformanceStat();
- [InspectableField] [JsonProperty("traction")] [Key(15)]
- public PerformanceStat Traction;
+ [InspectableField, JsonProperty("traction"), Key(15)]
+ public PerformanceStat Traction = new PerformanceStat();
- [InspectableField] [JsonProperty("topSpeed")] [Key(16)]
- public PerformanceStat TopSpeed;
+ [InspectableField, JsonProperty("topSpeed"), Key(16)]
+ public PerformanceStat TopSpeed = new PerformanceStat();
- [InspectableField] [JsonProperty("emissivity")] [Key(17)]
- public PerformanceStat Emissivity;
+ [InspectableField, JsonProperty("emissivity"), Key(17)]
+ public PerformanceStat Emissivity = new PerformanceStat();
- [InspectableField] [JsonProperty("crossSection")] [Key(18)]
- public PerformanceStat CrossSection;
+ [InspectableField, JsonProperty("crossSection"), Key(18)]
+ public PerformanceStat CrossSection = new PerformanceStat();
- [InspectableField] [JsonProperty("hardpoints")] [Key(19)]
+ [InspectableField, JsonProperty("hardpoints"), Key(19)]
public List Hardpoints = new List();
- [InspectableAnimationCurve] [JsonProperty("visibility")] [Key(20)]
+ [InspectableAnimationCurve, JsonProperty("visibility"), Key(20)]
public float4[] VisibilityCurve;
- [InspectablePrefab] [JsonProperty("prefab")] [Key(21)]
+ [InspectablePrefab, JsonProperty("prefab"), Key(21)]
public string Prefab;
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Hull;
}
-[RethinkTable("Items")]
-[InspectableField]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[RethinkTable("Items"), InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class HardpointData
{
- [JsonProperty("type")] [Key(0)]
- public HardpointType Type;
+ [JsonProperty("type"), Key(0)] public HardpointType Type;
}
-[RethinkTable("Items")]
-[Inspectable]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
-public class ShieldData : EquippableItemData
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
+public class PerformanceStat
{
- [InspectableField] [JsonProperty("efficiency")] [Key(14)]
- public PerformanceStat Efficiency;
+ [JsonProperty("min"), Key(0)] public float Min;
- [InspectableField] [JsonProperty("shielding")] [Key(15)]
- public PerformanceStat Shielding;
+ [JsonProperty("max"), Key(1)] public float Max;
- [IgnoreMember] public override HardpointType HardpointType => HardpointType.Shield;
-}
-
-[RethinkTable("Items")]
-[Inspectable]
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
-public class ThrusterData : EquippableItemData
-{
- [InspectableField] [JsonProperty("thrust")] [Key(14)]
- public PerformanceStat Thrust;
-
- [InspectableField] [JsonProperty("torque")] [Key(15)]
- public PerformanceStat Torque;
-
- [InspectableField] [JsonProperty("visibility")] [Key(16)]
- public PerformanceStat Visibility;
-
- [InspectableField] [JsonProperty("thrusterHeat")] [Key(17)]
- public PerformanceStat Heat;
-
- [IgnoreMember] public override HardpointType HardpointType => HardpointType.Thruster;
-}
-
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
-public struct PerformanceStat
-{
- [JsonProperty("min")] [Key(0)]
- public float Min;
-
- [JsonProperty("max")] [Key(1)]
- public float Max;
-
- [JsonProperty("durabilityDependent")] [Key(2)]
+ [JsonProperty("durabilityDependent"), Key(2)]
public bool DurabilityDependent;
-
- [JsonProperty("heatDependent")] [Key(3)]
+
+ [JsonProperty("heatDependent"), Key(3)]
public bool HeatDependent;
-
- [JsonProperty("qualityExponent")] [Key(4)]
+
+ [JsonProperty("qualityExponent"), Key(4)]
public float QualityExponent;
- [JsonProperty("ingredient")] [Key(5)]
- public Guid? Ingredient;
+ //[JsonProperty("id"), Key(5)] public Guid ID = Guid.NewGuid();
+
+ // [JsonProperty("ingredient"), Key(5)] public Guid? Ingredient;
[IgnoreMember] private Dictionary> _scaleModifiers;
[IgnoreMember] private Dictionary> _constantModifiers;
diff --git a/Assets/Scripts/ServerShared/ItemInstance.cs b/Assets/Scripts/ServerShared/ItemInstance.cs
index 42a6ef63b..9c17c9cc1 100644
--- a/Assets/Scripts/ServerShared/ItemInstance.cs
+++ b/Assets/Scripts/ServerShared/ItemInstance.cs
@@ -12,63 +12,50 @@ using Unity.Mathematics;
// TODO: USE THIS EVERYWHERE
using static Unity.Mathematics.math;
-[Union(0, typeof(SimpleCommodity))]
-[Union(1, typeof(CompoundCommodity))]
-[Union(2, typeof(Gear))]
-[JsonObject(MemberSerialization.OptIn)]
-[JsonConverter(typeof(JsonKnownTypesConverter))]
+[Union(0, typeof(SimpleCommodity)), Union(1, typeof(CompoundCommodity)), Union(2, typeof(Gear)),
+ JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter))]
public abstract class ItemInstance : DatabaseEntry
{
- [JsonProperty("data")] [Key(1)]
- public Guid Data;
+ [JsonProperty("data"), Key(1)] public Guid Data;
public float Mass => Context.GetMass(this);
public float HeatCapacity => Context.GetHeatCapacity(this);
}
-[Union(0, typeof(CompoundCommodity))]
-[Union(1, typeof(Gear))]
-[JsonObject(MemberSerialization.OptIn)]
-[JsonConverter(typeof(JsonKnownTypesConverter))]
+[Union(0, typeof(CompoundCommodity)), Union(1, typeof(Gear)), JsonObject(MemberSerialization.OptIn),
+ JsonConverter(typeof(JsonKnownTypesConverter))]
public abstract class CraftedItemInstance : ItemInstance
{
- [JsonProperty("quality")] [Key(2)]
- public float Quality;
+ [JsonProperty("quality"), Key(2)] public float Quality;
- [JsonProperty("ingredients")] [Key(3)]
- public List Ingredients = new List();
+ [JsonProperty("ingredients"), Key(3)] public List Ingredients = new List();
+
+ [JsonProperty("blueprint"), Key(4)] public BlueprintData Blueprint;
}
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class CompoundCommodity : CraftedItemInstance {}
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class SimpleCommodity : ItemInstance
{
- [JsonProperty("quantity")] [Key(2)]
- public int Quantity;
+ [JsonProperty("quantity"), Key(2)] public int Quantity;
public SimpleCommodityData ItemData => Context.GetData(this);
}
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class Gear : CraftedItemInstance
{
- [JsonProperty("durability")] [Key(4)]
- public float Durability;
+ [JsonProperty("durability"), Key(5)] public float Durability;
public EquippableItemData ItemData => Context.GetData(this);
}
-[MessagePackObject]
-[JsonObject(MemberSerialization.OptIn)]
+[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class Hardpoint
{
- [JsonProperty("item")] [Key(0)]
- public Gear Item;
+ [JsonProperty("item"), Key(0)] public Gear Item;
[IgnoreMember] public HardpointData HardpointData;
}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/Messages.cs b/Assets/Scripts/ServerShared/Messages.cs
index 3a6a214c3..5afff719c 100644
--- a/Assets/Scripts/ServerShared/Messages.cs
+++ b/Assets/Scripts/ServerShared/Messages.cs
@@ -5,20 +5,11 @@ using LiteNetLib;
using MessagePack;
using Unity.Mathematics;
-[Union(0,typeof(PingMessage))]
-[Union(1,typeof(LoginMessage))]
-[Union(2,typeof(RegisterMessage))]
-[Union(3,typeof(VerifyMessage))]
-[Union(4,typeof(ErrorMessage))]
-[Union(5,typeof(LoginSuccessMessage))]
-[Union(6,typeof(ChatMessage))]
-[Union(7,typeof(ChatBroadcastMessage))]
-[Union(8,typeof(ChangeNameMessage))]
-[Union(9,typeof(GalaxyRequestMessage))]
-[Union(10,typeof(GalaxyResponseMessage))]
-[Union(11,typeof(ZoneRequestMessage))]
-[Union(12,typeof(ZoneResponseMessage))]
-[MessagePackObject]
+[Union(0, typeof(PingMessage)), Union(1, typeof(LoginMessage)), Union(2, typeof(RegisterMessage)),
+ Union(3, typeof(VerifyMessage)), Union(4, typeof(ErrorMessage)), Union(5, typeof(LoginSuccessMessage)),
+ Union(6, typeof(ChatMessage)), Union(7, typeof(ChatBroadcastMessage)), Union(8, typeof(ChangeNameMessage)),
+ Union(9, typeof(GalaxyRequestMessage)), Union(10, typeof(GalaxyResponseMessage)),
+ Union(11, typeof(ZoneRequestMessage)), Union(12, typeof(ZoneResponseMessage)), MessagePackObject]
public abstract class Message
{
[IgnoreMember] public NetPeer Peer;
diff --git a/Assets/Scripts/ServerShared/Ship.cs b/Assets/Scripts/ServerShared/Ship.cs
index ba9e38674..44f960d84 100644
--- a/Assets/Scripts/ServerShared/Ship.cs
+++ b/Assets/Scripts/ServerShared/Ship.cs
@@ -27,7 +27,9 @@ public class Ship : DatabaseEntry
[IgnoreMember] public float Temperature;
[IgnoreMember] public float Charge;
// [IgnoreMember] public Targetable Target;
+ [IgnoreMember] public float2 Position;
[IgnoreMember] public float2 Direction;
+ [IgnoreMember] public float2 Velocity;
[IgnoreMember] public Dictionary