Blueprints & Resources
Added the ability to associate simple commodities with resource maps Added resource placement to zone generator Added crafting blueprints and stat addressing system Refactored Thrusters and Shields into Behaviors Fixed server losing database connection Updated icons
This commit is contained in:
parent
bd824cc2e6
commit
fd92c80876
58 changed files with 1399 additions and 855 deletions
|
|
@ -660,6 +660,7 @@
|
|||
<e p="ServerShared" t="Include">
|
||||
<e p="ActionCollection.cs" t="Include" />
|
||||
<e p="Attributes.cs" t="Include" />
|
||||
<e p="BlueprintData.cs" t="Include" />
|
||||
<e p="DatabaseCache.cs" t="Include" />
|
||||
<e p="DatabaseItems.cs" t="Include" />
|
||||
<e p="Economy.Shared.Unity.asmdef" t="Include" />
|
||||
|
|
@ -674,6 +675,10 @@
|
|||
<e p="Launcher.cs" t="Include" />
|
||||
<e p="Reactor.cs" t="Include" />
|
||||
<e p="Sensor.cs" t="Include" />
|
||||
<e p="Shield.cs" t="Include" />
|
||||
<e p="Thruster.cs" t="Include" />
|
||||
<e p="Turning.cs" t="Include" />
|
||||
<e p="Weapon.cs" t="Include" />
|
||||
</e>
|
||||
<e p="ItemData.cs" t="Include" />
|
||||
<e p="ItemInstance.cs" t="Include" />
|
||||
|
|
@ -1089,7 +1094,6 @@
|
|||
<e p="ZoneGenerator.cs" t="Include" />
|
||||
</e>
|
||||
<e p="StrategyGameManager.cs" t="Include" />
|
||||
<e p="Targetable.cs" t="Include" />
|
||||
<e p="UI" t="Include">
|
||||
<e p="BackgroundRenderer.cs" t="Include" />
|
||||
<e p="ClickableCollider.cs" t="Include" />
|
||||
|
|
|
|||
5
.idea/.idea.Economy/.idea/contentModel.xml
generated
5
.idea/.idea.Economy/.idea/contentModel.xml
generated
|
|
@ -6,6 +6,7 @@
|
|||
<e p="C:\Users\rwvens\Documents\GitHub\Aetheria-Economy" t="IncludeFlat">
|
||||
<e p="Assets\Scripts\ServerShared\ActionCollection.cs" t="Include" />
|
||||
<e p="Assets\Scripts\ServerShared\Attributes.cs" t="Include" />
|
||||
<e p="Assets\Scripts\ServerShared\BlueprintData.cs" t="Include" />
|
||||
<e p="Assets\Scripts\ServerShared\DatabaseCache.cs" t="Include" />
|
||||
<e p="Assets\Scripts\ServerShared\DatabaseItems.cs" t="Include" />
|
||||
<e p="Assets\Scripts\ServerShared\Enums.cs" t="Include" />
|
||||
|
|
@ -19,6 +20,10 @@
|
|||
<e p="Launcher.cs" t="Include" />
|
||||
<e p="Reactor.cs" t="Include" />
|
||||
<e p="Sensor.cs" t="Include" />
|
||||
<e p="Shield.cs" t="Include" />
|
||||
<e p="Thruster.cs" t="Include" />
|
||||
<e p="Turning.cs" t="Include" />
|
||||
<e p="Weapon.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Assets\Scripts\ServerShared\ItemData.cs" t="Include" />
|
||||
<e p="Assets\Scripts\ServerShared\ItemInstance.cs" t="Include" />
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hardpoint/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=equippable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hardpoint/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Planetoid/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
|
|
@ -374,9 +374,18 @@
|
|||
<Reference Include="UnityEditor.WindowsStandalone.Extensions">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/PlaybackEngines/windowsstandalonesupport/UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.SqlServer.Types">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Buffers">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -401,15 +410,6 @@
|
|||
<Reference Include="Grpc.Core.Api">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
|
|
@ -288,9 +288,18 @@
|
|||
<Reference Include="UnityEngine.SpatialTracking">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.SqlServer.Types">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Buffers">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -312,15 +321,6 @@
|
|||
<Reference Include="Grpc.Core.Api">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
|
|
@ -384,7 +384,6 @@
|
|||
<Compile Include="Assets\Scripts\NIH\XKCDColors.cs" />
|
||||
<Compile Include="Assets\Scripts\Prototype.cs" />
|
||||
<Compile Include="Assets\Scripts\StrategyGameManager.cs" />
|
||||
<Compile Include="Assets\Scripts\Targetable.cs" />
|
||||
<Compile Include="Assets\Scripts\UI\BackgroundRenderer.cs" />
|
||||
<Compile Include="Assets\Scripts\UI\ClickableCollider.cs" />
|
||||
<Compile Include="Assets\Scripts\UI\ClickCatcher.cs" />
|
||||
|
|
@ -654,9 +653,18 @@
|
|||
<Reference Include="UnityEngine.SpatialTracking">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.SqlServer.Types">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Buffers">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -678,15 +686,6 @@
|
|||
<Reference Include="Grpc.Core.Api">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
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
|
||||
BIN
Assets/Resources/Sprites/Icons/Stroked/Moon.png
(Stored with Git LFS)
Normal file
BIN
Assets/Resources/Sprites/Icons/Stroked/Moon.png
(Stored with Git LFS)
Normal file
Binary file not shown.
110
Assets/Resources/Sprites/Icons/Stroked/Moon.png.meta
Normal file
110
Assets/Resources/Sprites/Icons/Stroked/Moon.png.meta
Normal file
|
|
@ -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:
|
||||
BIN
Assets/Resources/Sprites/Icons/Stroked/Planet.png
(Stored with Git LFS)
BIN
Assets/Resources/Sprites/Icons/Stroked/Planet.png
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/Resources/Sprites/Icons/Stroked/Ship.png
(Stored with Git LFS)
BIN
Assets/Resources/Sprites/Icons/Stroked/Ship.png
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/Resources/Sprites/Icons/Stroked/Sun.png
(Stored with Git LFS)
BIN
Assets/Resources/Sprites/Icons/Stroked/Sun.png
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/Resources/Sprites/Icons/Stroked/Wormhole.png
(Stored with Git LFS)
BIN
Assets/Resources/Sprites/Icons/Stroked/Wormhole.png
(Stored with Git LFS)
Binary file not shown.
|
|
@ -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<FlagsAttribute>().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<Guid, float>) field.GetValue(obj);
|
||||
Inspect(field.Name.SplitCamelCase(), ref dict);
|
||||
}
|
||||
else if (type == typeof(List<BlueprintStatEffect>))
|
||||
{
|
||||
var list = (List<BlueprintStatEffect>) field.GetValue(obj);
|
||||
if(list==null) field.SetValue(obj, list = new List<BlueprintStatEffect>());
|
||||
|
||||
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<CraftedItemData>().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<Guid>) && link != null)
|
||||
{
|
||||
var list = (List<Guid>) field.GetValue(obj);
|
||||
if(list==null) field.SetValue(obj, (list = new List<Guid>()));
|
||||
if(list==null) field.SetValue(obj, list = new List<Guid>());
|
||||
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<InspectableFieldAttribute>() != 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<InspectableFieldAttribute>() != 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<GameObject>(value), typeof(GameObject), false));
|
||||
return AssetDatabase.GetAssetPath(ObjectField(AssetDatabase.LoadAssetAtPath<GameObject>(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<Guid,int> 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<ItemData>(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<Guid,float> 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<Guid> 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<CraftedItemData>().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<CraftedItemData>().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();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<RethinkTableAttribute>()?.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<RethinkTableAttribute>()?.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<RethinkTableAttribute>()?.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<DatabaseEntry>(_connection);
|
||||
var result = await R
|
||||
.Db("Aetheria")
|
||||
.Table("Items")
|
||||
.RunCursorAsync<DatabaseEntry>(_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<DatabaseEntry>(_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<DatabaseEntry>(_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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
55
Assets/Scripts/ServerShared/BlueprintData.cs
Normal file
55
Assets/Scripts/ServerShared/BlueprintData.cs
Normal file
|
|
@ -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<Guid, int> Ingredients = new Dictionary<Guid, int>();
|
||||
|
||||
[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<BlueprintStatEffect> StatEffects = new List<BlueprintStatEffect>();
|
||||
|
||||
[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;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae4eaa5cad8b4c744a0740b1eb2e8548
|
||||
guid: f2b1f367d240824408eb1e151c60bc79
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -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<DatabaseEntry>))]
|
||||
[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<DatabaseEntry>))]
|
||||
//[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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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<T>(this IEnumerable<T> 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<Type,Type[]> InterfaceClasses = new Dictionary<Type, Type[]>();
|
||||
public static Type[] GetAllInterfaceClasses(this Type type)
|
||||
|
|
|
|||
|
|
@ -6,15 +6,17 @@ using static Unity.Mathematics.math;
|
|||
|
||||
public class GameContext
|
||||
{
|
||||
private Action<string> _logger;
|
||||
private DatabaseCache _cache;
|
||||
|
||||
public GlobalData GlobalData => _cache.GetAll<GlobalData>().FirstOrDefault();
|
||||
|
||||
private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();
|
||||
// private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();
|
||||
|
||||
public GameContext(DatabaseCache cache)
|
||||
public GameContext(DatabaseCache cache, Action<string> logger)
|
||||
{
|
||||
_cache = cache;
|
||||
_logger = logger;
|
||||
var globalData = _cache.GetAll<GlobalData>().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<ItemData>(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<ItemData>(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<BlueprintStatEffect, PerformanceStat> AffectedStats =
|
||||
new Dictionary<BlueprintStatEffect, PerformanceStat>();
|
||||
|
||||
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<EquippableItemData>(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<CraftedItemData>(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<BlueprintData>().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
|
||||
|
|
|
|||
|
|
@ -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<string, Guid> MapLayers = new Dictionary<string, Guid>();
|
||||
|
||||
[InspectableField] [JsonProperty("zoneRadiusMin")] [Key(17)]
|
||||
// [InspectableField] [JsonProperty("mapLayers")] [Key(16)]
|
||||
// public Dictionary<string, Guid> MapLayers = new Dictionary<string, Guid>();
|
||||
|
||||
[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
|
||||
|
|
|
|||
|
|
@ -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<Dictionary<IItemBehavior,float>> _modifiers = new List<Dictionary<IItemBehavior, float>>();
|
||||
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<ThrusterBehaviorData>().ToArray();
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
}
|
||||
|
|
@ -53,17 +57,22 @@ public class AfterburnerBehavior : IActivatedItemBehavior
|
|||
|
||||
public void Activate()
|
||||
{
|
||||
var thrustMod = Ship.GetEquipped<ThrusterData>().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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<IItemBehaviorData>)), JsonObject(MemberSerialization.OptIn)]
|
||||
// [Union(3, typeof(PlusUltraBehaviorData))]
|
||||
[Union(4, typeof(AfterburnerBehaviorData))]
|
||||
[Union(5, typeof(SensorBehaviorData))]
|
||||
[JsonConverter(typeof(JsonKnownTypesConverter<IItemBehaviorData>))]
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public interface IItemBehaviorData
|
||||
{
|
||||
IItemBehavior CreateInstance(GameContext context, Ship ship, Gear item);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<AudioClip> 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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
52
Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs
Normal file
52
Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs
Normal file
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs.meta
Normal file
3
Assets/Scripts/ServerShared/ItemBehaviors/Shield.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dbb1419b4645402aad5a394b983a637f
|
||||
timeCreated: 1586275939
|
||||
67
Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs
Normal file
67
Assets/Scripts/ServerShared/ItemBehaviors/Thruster.cs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f46e0da62f8c40f69bba0b7bcff8662f
|
||||
timeCreated: 1586267627
|
||||
64
Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs
Normal file
64
Assets/Scripts/ServerShared/ItemBehaviors/Turning.cs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 21343037bc4842669c20b0606b03a622
|
||||
timeCreated: 1586270198
|
||||
34
Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs
Normal file
34
Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs
Normal file
|
|
@ -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();
|
||||
}
|
||||
3
Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs.meta
Normal file
3
Assets/Scripts/ServerShared/ItemBehaviors/Weapon.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d87bbbe67d6d48cb8f0cca9611985c00
|
||||
timeCreated: 1586295838
|
||||
|
|
@ -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<ItemData>))]
|
||||
[MessagePackObject,
|
||||
Union(0, typeof(SimpleCommodityData)),
|
||||
Union(1, typeof(CompoundCommodityData)),
|
||||
Union(2, typeof(GearData)),
|
||||
Union(3, typeof(HullData)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<ItemData>))]
|
||||
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<CraftedItemData>))]
|
||||
public abstract class CraftedItemData : ItemData
|
||||
[RethinkTable("Items"), Inspectable, MessagePackObject]
|
||||
public class SimpleCommodityData : ItemData
|
||||
{
|
||||
[InspectableField] [JsonProperty("ingredients")] [Key(5)]
|
||||
public Dictionary<Guid, int> Ingredients = new Dictionary<Guid, int>();
|
||||
// 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<Guid> ResourceDensity = new List<Guid>();
|
||||
|
||||
// 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<CraftedItemData>))]
|
||||
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<EquippableItemData>))]
|
||||
[Union(0, typeof(GearData)),
|
||||
Union(1, typeof(HullData)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<EquippableItemData>))]
|
||||
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<IItemBehaviorData> Behaviors = new List<IItemBehaviorData>();
|
||||
|
||||
[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<HardpointData> Hardpoints = new List<HardpointData>();
|
||||
|
||||
[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<Ship,Dictionary<IItemBehavior,float>> _scaleModifiers;
|
||||
[IgnoreMember] private Dictionary<Ship,Dictionary<IItemBehavior,float>> _constantModifiers;
|
||||
|
|
|
|||
|
|
@ -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<ItemInstance>))]
|
||||
[Union(0, typeof(SimpleCommodity)), Union(1, typeof(CompoundCommodity)), Union(2, typeof(Gear)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<ItemInstance>))]
|
||||
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<CraftedItemInstance>))]
|
||||
[Union(0, typeof(CompoundCommodity)), Union(1, typeof(Gear)), JsonObject(MemberSerialization.OptIn),
|
||||
JsonConverter(typeof(JsonKnownTypesConverter<CraftedItemInstance>))]
|
||||
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<ItemInstance> Ingredients = new List<ItemInstance>();
|
||||
[JsonProperty("ingredients"), Key(3)] public List<ItemInstance> Ingredients = new List<ItemInstance>();
|
||||
|
||||
[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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<object, float> VisibilitySources = new Dictionary<object, float>();
|
||||
|
||||
private HullData _hullData;
|
||||
|
|
@ -51,6 +53,20 @@ public class Ship : DatabaseEntry
|
|||
return null;
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetBehaviors<T>() where T : class, IItemBehavior
|
||||
{
|
||||
foreach (var behavior in ItemBehaviors)
|
||||
if (behavior is T b)
|
||||
yield return b;
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetBehaviorData<T>() where T : class, IItemBehaviorData
|
||||
{
|
||||
foreach (var behavior in ItemBehaviors)
|
||||
if (behavior.Data is T b)
|
||||
yield return b;
|
||||
}
|
||||
|
||||
public void AddHeat(float heat)
|
||||
{
|
||||
Temperature += heat / SpecificHeat;
|
||||
|
|
@ -192,4 +208,5 @@ public class Ship : DatabaseEntry
|
|||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,33 +6,31 @@ using Newtonsoft.Json;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[RethinkTable("Galaxy")]
|
||||
[MessagePackObject]
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class ZoneData : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[JsonProperty("name")] [Key(1)]
|
||||
[JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[JsonProperty("position")] [Key(2)]
|
||||
|
||||
[JsonProperty("position"), Key(2)]
|
||||
public float2 Position = 500;
|
||||
|
||||
[JsonProperty("wormholes")] [Key(3)]
|
||||
[JsonProperty("wormholes"), Key(3)]
|
||||
public List<Guid> Wormholes = new List<Guid>();
|
||||
|
||||
[JsonProperty("stations")] [Key(4)]
|
||||
|
||||
[JsonProperty("stations"), Key(4)]
|
||||
public List<Guid> Stations = new List<Guid>();
|
||||
|
||||
[JsonProperty("planets")] [Key(5)]
|
||||
|
||||
[JsonProperty("planets"), Key(5)]
|
||||
public List<Guid> Planets = new List<Guid>();
|
||||
|
||||
[JsonProperty("orbits")] [Key(6)]
|
||||
|
||||
[JsonProperty("orbits"), Key(6)]
|
||||
public List<Guid> Orbits = new List<Guid>();
|
||||
|
||||
[JsonProperty("radius")] [Key(7)]
|
||||
|
||||
[JsonProperty("radius"), Key(7)]
|
||||
public float Radius = 2000;
|
||||
|
||||
[JsonProperty("visited")] [Key(8)]
|
||||
[JsonProperty("visited"), Key(8)]
|
||||
public bool Visited;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
|
|
@ -42,31 +40,29 @@ public class ZoneData : DatabaseEntry, INamedEntry
|
|||
}
|
||||
}
|
||||
|
||||
[RethinkTable("Galaxy")]
|
||||
[MessagePackObject]
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class Station : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[JsonProperty("name")] [Key(1)]
|
||||
[JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
// Can be Planet or Orbit
|
||||
[JsonProperty("parent")] [Key(2)]
|
||||
[JsonProperty("parent"), Key(2)]
|
||||
public Guid Parent;
|
||||
|
||||
[JsonProperty("owner")] [Key(3)]
|
||||
[JsonProperty("owner"), Key(3)]
|
||||
public Guid Owner;
|
||||
|
||||
[JsonProperty("inventory")] [Key(4)]
|
||||
[JsonProperty("inventory"), Key(4)]
|
||||
public List<ItemInstance> Inventory = new List<ItemInstance>();
|
||||
|
||||
[JsonProperty("buying")] [Key(5)]
|
||||
[JsonProperty("buying"), Key(5)]
|
||||
public Dictionary<Guid, float> BuyPrices = new Dictionary<Guid, float>();
|
||||
|
||||
[JsonProperty("selling")] [Key(6)]
|
||||
[JsonProperty("selling"), Key(6)]
|
||||
public Dictionary<Guid, float> SellPrices = new Dictionary<Guid, float>();
|
||||
|
||||
[JsonProperty("zone")] [Key(7)]
|
||||
|
||||
[JsonProperty("zone"), Key(7)]
|
||||
public Guid Zone;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
|
|
@ -76,25 +72,26 @@ public class Station : DatabaseEntry, INamedEntry
|
|||
}
|
||||
}
|
||||
|
||||
[RethinkTable("Galaxy")]
|
||||
[MessagePackObject]
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class PlanetData : DatabaseEntry, INamedEntry
|
||||
{
|
||||
[JsonProperty("name")] [Key(1)]
|
||||
[JsonProperty("name"), Key(1)]
|
||||
public string Name;
|
||||
|
||||
[JsonProperty("orbit")] [Key(2)]
|
||||
|
||||
[JsonProperty("orbit"), Key(2)]
|
||||
public Guid Orbit;
|
||||
|
||||
[JsonProperty("mass")] [Key(3)]
|
||||
|
||||
[JsonProperty("mass"), Key(3)]
|
||||
public float Mass;
|
||||
|
||||
[JsonProperty("zone")] [Key(4)]
|
||||
|
||||
[JsonProperty("zone"), Key(4)]
|
||||
public Guid Zone;
|
||||
|
||||
[JsonProperty("belt")] [Key(5)]
|
||||
|
||||
[JsonProperty("belt"), Key(5)]
|
||||
public bool Belt;
|
||||
|
||||
[JsonProperty("resources"), Key(5)]
|
||||
public Dictionary<Guid, float> Resources = new Dictionary<Guid, float>();
|
||||
|
||||
// [JsonProperty("radius")] [Key(5)]
|
||||
// public float GravityRadius;
|
||||
|
|
@ -106,24 +103,22 @@ public class PlanetData : DatabaseEntry, INamedEntry
|
|||
}
|
||||
}
|
||||
|
||||
[RethinkTable("Galaxy")]
|
||||
[MessagePackObject]
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class OrbitData : DatabaseEntry
|
||||
{
|
||||
[JsonProperty("parent")] [Key(1)]
|
||||
[JsonProperty("parent"), Key(1)]
|
||||
public Guid Parent;
|
||||
|
||||
[JsonProperty("distance")] [Key(2)]
|
||||
|
||||
[JsonProperty("distance"), Key(2)]
|
||||
public float Distance;
|
||||
|
||||
[JsonProperty("phase")] [Key(3)]
|
||||
|
||||
[JsonProperty("phase"), Key(3)]
|
||||
public float Phase;
|
||||
|
||||
[JsonProperty("period")] [Key(4)]
|
||||
|
||||
[JsonProperty("period"), Key(4)]
|
||||
public float Period;
|
||||
|
||||
[JsonProperty("zone")] [Key(5)]
|
||||
|
||||
[JsonProperty("zone"), Key(5)]
|
||||
public Guid Zone;
|
||||
|
||||
public static float2 Evaluate(float phase)
|
||||
|
|
|
|||
|
|
@ -12,25 +12,27 @@ using Random = Unity.Mathematics.Random;
|
|||
|
||||
public class ZoneGenerator
|
||||
{
|
||||
// public float BinaryFloor = 100;
|
||||
// public float BinaryProbability = .1f;
|
||||
// public float MassPowerMinimum = 1.35f;
|
||||
// public float MassPowerMaximum = 1.75f;
|
||||
// public float DistancePowerMinimum = 1.35f;
|
||||
// public float DistancePowerMaximum = 1.75f;
|
||||
// public float Radius = 500;
|
||||
// public float Mass = 100000;
|
||||
// public float MassFloor = 1;
|
||||
// public float SunMass = 10000;
|
||||
// public float GasGiantMass = 2000;
|
||||
// public float RadiusPower = 1.75f;
|
||||
|
||||
public static void GenerateZone(GlobalData global, ZoneData zone, GalaxyMapLayerData mass, GalaxyMapLayerData radius, out OrbitData[] orbitData, out PlanetData[] planetData)
|
||||
public static void GenerateZone(
|
||||
GlobalData global,
|
||||
ZoneData zone,
|
||||
IEnumerable<GalaxyMapLayerData> mapLayers,
|
||||
IEnumerable<SimpleCommodityData> resources,
|
||||
out OrbitData[] orbitData,
|
||||
out PlanetData[] planetsData)
|
||||
{
|
||||
var zoneRadius = lerp(global.MinimumZoneRadius, global.MaximumZoneRadius, radius.Evaluate(zone.Position, global));
|
||||
var zoneRadius = lerp(global.MinimumZoneRadius,
|
||||
global.MaximumZoneRadius,
|
||||
mapLayers.First(m => m.Name == "Radius")
|
||||
.Evaluate(zone.Position,
|
||||
global));
|
||||
zone.Radius = zoneRadius;
|
||||
|
||||
var zoneMass = lerp(global.MinimumZoneMass, global.MaximumZoneMass, mass.Evaluate(zone.Position, global));
|
||||
var zoneMass = lerp(global.MinimumZoneMass,
|
||||
global.MaximumZoneMass,
|
||||
mapLayers.First(m => m.Name == "Mass")
|
||||
.Evaluate(zone.Position,
|
||||
global));
|
||||
|
||||
//Debug.Log($"Generating zone at position {zone.Position} with radius {zoneRadius} and mass {zoneMass}");
|
||||
|
||||
|
|
@ -62,21 +64,45 @@ public class ZoneGenerator
|
|||
? orbitMap[orbitInverseMap[data].Parent].ID
|
||||
: Guid.Empty;
|
||||
|
||||
planetData = planets.Where(p=>!p.Empty).Select(planet =>
|
||||
// Cache resource densities
|
||||
var resourceMaps = mapLayers.ToDictionary(m => m.ID, m => m.Evaluate(zone.Position, global));
|
||||
|
||||
var random = new Random();
|
||||
|
||||
planetsData = planets.Where(p=>!p.Empty).Select(planet =>
|
||||
{
|
||||
var planetDatum = new PlanetData
|
||||
var planetData = new PlanetData
|
||||
{
|
||||
Mass = planet.Mass,
|
||||
ID = Guid.NewGuid(),
|
||||
Orbit = orbitMap[planet].ID,
|
||||
Zone = zone.ID,
|
||||
Belt = planet.Belt
|
||||
Belt = planet.Belt,
|
||||
Resources = resources
|
||||
// Filter resources where the body type matches the current planet
|
||||
.Where(r =>
|
||||
((planet.Belt ? BodyType.Asteroid :
|
||||
planet.Mass > global.SunMass ? BodyType.Sun :
|
||||
planet.Mass > global.GasGiantMass ? BodyType.GasGiant :
|
||||
planet.Mass > global.PlanetMass ? BodyType.Planet : BodyType.Planetoid) & r.ResourceBodyType) != 0)
|
||||
// NextUnbounded is our extension function containing resource placement formula
|
||||
// Obtain bias variable by multiplying all resource maps together
|
||||
.Select(r => new
|
||||
{
|
||||
resource = r,
|
||||
quantity = random.NextUnbounded(
|
||||
r.ResourceDensity.Aggregate(1f, (m, rdm) => m * resourceMaps[rdm]),
|
||||
r.ResourceDensityBiasPower)
|
||||
})
|
||||
// Only include resources above a minimum quantity
|
||||
.Where(r => r.resource.ResourceFloor < r.quantity)
|
||||
.ToDictionary(r => r.resource.ID, r => r.quantity)
|
||||
};
|
||||
planetDatum.Name = planetDatum.ID.ToString().Substring(0, 8);
|
||||
return planetDatum;
|
||||
planetData.Name = planetData.ID.ToString().Substring(0, 8);
|
||||
return planetData;
|
||||
}).ToArray();
|
||||
|
||||
zone.Planets = planetData.Select(pd => pd.ID).ToList();
|
||||
zone.Planets = planetsData.Select(pd => pd.ID).ToList();
|
||||
zone.Orbits = orbitData.Select(od => od.ID).ToList();
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +131,7 @@ public class ZoneGenerator
|
|||
|
||||
// Create a small number of less massive "captured" planets orbiting past the rosette
|
||||
root.ExpandSolar(
|
||||
count: random.NextInt(1,5),
|
||||
count: (int)(random.NextFloat(1, 3) * random.NextFloat(1, 2)),
|
||||
massMulMin: .6f,
|
||||
massMulMax: .8f,
|
||||
distMulMin: 1.25f,
|
||||
|
|
@ -119,7 +145,7 @@ public class ZoneGenerator
|
|||
var m = p.Mass / averageChildMass;
|
||||
// Give each child in the rosette its own mini solar system
|
||||
p.ExpandSolar(
|
||||
count: (int) (m * 5),
|
||||
count: (int) (random.NextFloat() * random.NextFloat() * m * 5 + 1),
|
||||
massMulMin: 0.75f,
|
||||
massMulMax: 2.5f,
|
||||
distMulMin: 1 + m * .25f,
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class StrategyGameManager : MonoBehaviour
|
|||
_galaxy = galaxy;
|
||||
_galaxyResponseZones = _galaxy.Zones.ToDictionary(z => z.ZoneID);
|
||||
_cache.Add(_galaxy.GlobalData, true);
|
||||
_context = new GameContext(_cache);
|
||||
_context = new GameContext(_cache, Debug.Log);
|
||||
if (_currentTab == GalaxyTabButton && !_galaxyPopulated) PopulateGalaxy();
|
||||
});
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ public class StrategyGameManager : MonoBehaviour
|
|||
{
|
||||
var orbitData = _cache.Get<OrbitData>(orbit);
|
||||
_orbitPositions[orbit] = GetOrbitPosition(orbitData.Parent) + (orbitData.Period < .01f ? float2.zero :
|
||||
OrbitData.Evaluate(Time.time / orbitData.Period + orbitData.Phase) *
|
||||
OrbitData.Evaluate(Time.time / -orbitData.Period + orbitData.Phase) *
|
||||
orbitData.Distance);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,100 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class Targetable : MonoBehaviour
|
||||
{
|
||||
public float Points = 100;
|
||||
public float Visibility;
|
||||
public Transform ReplaceWithPrefab;
|
||||
public Ship Ship;
|
||||
|
||||
public IsFriendlyFoeStatus DefaultIsFriendlyFoeStatus = IsFriendlyFoeStatus.None;
|
||||
|
||||
public readonly Dictionary<Targetable, IsFriendlyFoeStatus> IFF = new Dictionary<Targetable, IsFriendlyFoeStatus>();
|
||||
private Vector3 _lastPosition;
|
||||
|
||||
public IsFriendlyFoeStatus IsFriendlyFoe(Targetable target)
|
||||
{
|
||||
if (!IFF.ContainsKey(target))
|
||||
IFF[target] = DefaultIsFriendlyFoeStatus;
|
||||
|
||||
return IFF[target];
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
void Health(float health)
|
||||
{
|
||||
Points = health;
|
||||
}
|
||||
|
||||
public void Damage(float points)
|
||||
{
|
||||
if (Ship != null)
|
||||
{
|
||||
var shield = Ship.GetEquipped(HardpointType.Shield);
|
||||
if (shield != null)
|
||||
{
|
||||
var shieldData = shield.ItemData as ShieldData;
|
||||
var shieldedDamage = points * saturate(Ship.Context.Evaluate(shieldData.Shielding, shield, Ship));
|
||||
Ship.AddHeat(shieldedDamage / Ship.Context.Evaluate(shieldData.Efficiency, shield, Ship));
|
||||
Ship.Hull.Durability -= points - shieldedDamage;
|
||||
}
|
||||
else Ship.Hull.Durability -= points;
|
||||
}
|
||||
else
|
||||
{
|
||||
Points -= points;
|
||||
|
||||
if (Points > 0) return;
|
||||
|
||||
KillLocal();
|
||||
}
|
||||
/*
|
||||
var ent = GameManager.Instance.Entities.FirstOrDefault(kv => kv.Value == transform).Key;
|
||||
if(ent>0)
|
||||
GameManager.Instance.Send("Destroy", ent);*/
|
||||
|
||||
}
|
||||
|
||||
public void KillLocal()
|
||||
{
|
||||
//GameManager.Instance.Kill(this);
|
||||
// if (GetComponent<PlayerShip>())
|
||||
// {
|
||||
// GameManager.Instance.KillPlayer();
|
||||
// }
|
||||
|
||||
Destroy(gameObject);
|
||||
|
||||
if (ReplaceWithPrefab != null)
|
||||
Instantiate(ReplaceWithPrefab, transform.position, transform.rotation);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
_lastPosition = transform.position;
|
||||
}
|
||||
|
||||
void kill(string[] args)
|
||||
{
|
||||
if(args[0]==gameObject.name)
|
||||
KillLocal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum IsFriendlyFoeStatus
|
||||
{
|
||||
None,
|
||||
Friendly,
|
||||
Hostile,
|
||||
Mayday,
|
||||
Body,
|
||||
Wormhole
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class ZoneGeneratorTest : MonoBehaviour
|
|||
void Start()
|
||||
{
|
||||
_cache = new DatabaseCache();
|
||||
_context = new GameContext(_cache);
|
||||
_context = new GameContext(_cache, Debug.Log);
|
||||
_boundaryMaterial = ZoneBoundary.material;
|
||||
}
|
||||
|
||||
|
|
@ -105,10 +105,10 @@ public class ZoneGeneratorTest : MonoBehaviour
|
|||
ZoneGenerator.GenerateZone(
|
||||
global: Galaxy.MapData.GlobalData,
|
||||
zone: zone,
|
||||
mass: Galaxy.MapData.ResourceDensities.First(m=>m.Name=="Mass"),
|
||||
radius: Galaxy.MapData.ResourceDensities.First(m=>m.Name=="Radius"),
|
||||
mapLayers: Galaxy.MapData.ResourceDensities,
|
||||
resources: Array.Empty<SimpleCommodityData>(),
|
||||
orbitData: out orbits,
|
||||
planetData: out planets);
|
||||
planetsData: out planets);
|
||||
_cache.AddAll(orbits);
|
||||
_cache.AddAll(planets);
|
||||
_cache.Add(zone);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -11,6 +13,7 @@ using MessagePack.Resolvers;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using RethinkDb.Driver;
|
||||
using RethinkDb.Driver.Ast;
|
||||
using RethinkDb.Driver.Net;
|
||||
using Serilog;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
|
|
@ -118,7 +121,9 @@ namespace ChatApp.Server
|
|||
};
|
||||
server.Start();
|
||||
|
||||
var context = new GameContext(cache);
|
||||
var context = new GameContext(cache, s=>_logger.Log(LogLevel.Information, s));
|
||||
|
||||
var mapLayers = cache.GetAll<GalaxyMapLayerData>().ToDictionary(m => m.Name);
|
||||
|
||||
server.AddMessageListener<GalaxyRequestMessage>(galaxyRequest => galaxyRequest.Peer.Send(
|
||||
new GalaxyResponseMessage
|
||||
|
|
@ -132,7 +137,7 @@ namespace ChatApp.Server
|
|||
Links = zd.Wormholes?.ToArray() ?? Array.Empty<Guid>()
|
||||
}).ToArray(),
|
||||
GlobalData = context.GlobalData,
|
||||
StarDensity = cache.Get<GalaxyMapLayerData>(context.GlobalData.MapLayers["StarDensity"])
|
||||
StarDensity = mapLayers["StarDensity"]
|
||||
}));
|
||||
|
||||
server.AddMessageListener<ZoneRequestMessage>(zoneRequest =>
|
||||
|
|
@ -148,10 +153,10 @@ namespace ChatApp.Server
|
|||
ZoneGenerator.GenerateZone(
|
||||
global: context.GlobalData,
|
||||
zone: zone,
|
||||
mass: cache.Get<GalaxyMapLayerData>(context.GlobalData.MapLayers["Mass"]),
|
||||
radius: cache.Get<GalaxyMapLayerData>(context.GlobalData.MapLayers["Radius"]),
|
||||
mapLayers: mapLayers.Values,
|
||||
resources: cache.GetAll<SimpleCommodityData>(),
|
||||
orbitData: out orbits,
|
||||
planetData: out planets);
|
||||
planetsData: out planets);
|
||||
cache.AddAll(orbits);
|
||||
cache.AddAll(planets);
|
||||
cache.Add(zone);
|
||||
|
|
@ -166,6 +171,11 @@ namespace ChatApp.Server
|
|||
});
|
||||
});
|
||||
|
||||
Observable.Timer(DateTimeOffset.Now, TimeSpan.FromSeconds(60)).SubscribeOn(NewThreadScheduler.Default).Subscribe(_ =>
|
||||
{
|
||||
_logger.Log(LogLevel.Information, R.Now().Run<DateTime>(connection).ToString() as string);
|
||||
});
|
||||
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
|
|
|
|||
BIN
Economy.Server/bin/Debug/netcoreapp3.1/Economy.Server.dll
(Stored with Git LFS)
BIN
Economy.Server/bin/Debug/netcoreapp3.1/Economy.Server.dll
(Stored with Git LFS)
Binary file not shown.
BIN
Economy.Server/bin/Debug/netcoreapp3.1/Economy.Shared.dll
(Stored with Git LFS)
BIN
Economy.Server/bin/Debug/netcoreapp3.1/Economy.Shared.dll
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
Economy.Server/obj/Debug/netcoreapp3.1/Economy.Server.dll
(Stored with Git LFS)
BIN
Economy.Server/obj/Debug/netcoreapp3.1/Economy.Server.dll
(Stored with Git LFS)
Binary file not shown.
|
|
@ -62,6 +62,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Assets\Scripts\ServerShared\ActionCollection.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Attributes.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\BlueprintData.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\DatabaseCache.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\DatabaseItems.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\Enums.cs" />
|
||||
|
|
@ -74,6 +75,10 @@
|
|||
<Compile Include="Assets\Scripts\ServerShared\ItemBehaviors\Launcher.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemBehaviors\Reactor.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemBehaviors\Sensor.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemBehaviors\Shield.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemBehaviors\Thruster.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemBehaviors\Turning.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemBehaviors\Weapon.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemData.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\ItemInstance.cs" />
|
||||
<Compile Include="Assets\Scripts\ServerShared\JsonConverters.cs" />
|
||||
|
|
@ -673,9 +678,18 @@
|
|||
<Reference Include="UnityEditor.WindowsStandalone.Extensions">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/PlaybackEngines/windowsstandalonesupport/UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.SqlServer.Types">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Buffers">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -700,15 +714,6 @@
|
|||
<Reference Include="Grpc.Core.Api">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
BIN
Economy.Shared/bin/Debug/netstandard2.0/Economy.Shared.dll
(Stored with Git LFS)
BIN
Economy.Shared/bin/Debug/netstandard2.0/Economy.Shared.dll
(Stored with Git LFS)
Binary file not shown.
BIN
Economy.Shared/obj/Debug/netstandard2.0/Economy.Shared.dll
(Stored with Git LFS)
BIN
Economy.Shared/obj/Debug/netstandard2.0/Economy.Shared.dll
(Stored with Git LFS)
Binary file not shown.
|
|
@ -387,9 +387,18 @@
|
|||
<Reference Include="UnityEditor.WindowsStandalone.Extensions">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/PlaybackEngines/windowsstandalonesupport/UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.SqlServer.Types">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.SqlServer.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Buffers">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -414,15 +423,6 @@
|
|||
<Reference Include="Grpc.Core.Api">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Grpc.Core.Api/lib/net45/Grpc.Core.Api.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Remotion.Linq">
|
||||
<HintPath>C:/Users/rwvens/Documents/GitHub/Aetheria-Economy/Assets/Plugins/Remotion.Linq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2018.4.17f1/Editor/Data/MonoBleedingEdge/lib/mono/4.7.1-api/mscorlib.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
Loading…
Reference in a new issue