Local AI Testing & Interactive Tech Tab

Refactored game loop to allow full local testing
Added AI controller abstractions
Added ability to save database to local copy for offline testing
Tech Tab is now interactive, has properties panel
This commit is contained in:
hyperion51 2020-04-23 03:31:17 +01:00
commit af88788e4f
50 changed files with 5799 additions and 712 deletions

1
.gitignore vendored
View file

@ -72,3 +72,4 @@ Economy.Shared/obj/
# JetBrains Rider .idea folder
.idea/
AetherDB.msgpack

View file

@ -1433,8 +1433,15 @@
<e p="XKCDColors.cs" t="Include" />
</e>
<e p="Prototype.cs" t="Include" />
<e p="RethinkConnection.cs" t="Include" />
<e p="ServerShared" t="Include">
<e p="ActionCollection.cs" t="Include" />
<e p="Agents" t="Include">
<e p="AgentBehavior.cs" t="Include" />
<e p="AgentController.cs" t="Include" />
<e p="EntityAgent.cs" t="Include" />
<e p="Locomotion.cs" t="Include" />
</e>
<e p="Attributes.cs" t="Include" />
<e p="Behaviors" t="Include">
<e p="Afterburner.cs" t="Include" />
@ -1464,7 +1471,6 @@
<e p="ItemData.cs" t="Include" />
<e p="ItemInstance.cs" t="Include" />
<e p="JsonConverters.cs" t="Include" />
<e p="Locomotion.cs" t="Include" />
<e p="MathFormatters.cs" t="Include" />
<e p="MathResolver.cs" t="Include" />
<e p="Messages.cs" t="Include" />
@ -1873,6 +1879,7 @@
</e>
<e p="OrbitalEntity.cs" t="Include" />
<e p="Rect.cs" t="Include" />
<e p="RegisterResolver.cs" t="Include" />
<e p="Ship.cs" t="Include" />
<e p="ZoneData.cs" t="Include" />
<e p="ZoneGenerator.cs" t="Include" />
@ -1898,6 +1905,7 @@
<e p="TechNode.cs" t="Include" />
<e p="ZoneObject.cs" t="Include" />
<e p="ZoneRenderer.cs" t="Include" />
<e p="ZoneShip.cs" t="Include" />
</e>
<e p="UnityExtensions.cs" t="Include" />
<e p="UnityFormatters.cs" t="Include" />

View file

@ -5,6 +5,12 @@
<e p="C:\Users\rwvens\.Rider2019.3\system\resharper-host\local\Transient\ReSharperHost\v193\SolutionCaches\_Economy.820823087.00" t="ExcludeRecursive" />
<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\Agents" t="Include">
<e p="AgentBehavior.cs" t="Include" />
<e p="AgentController.cs" t="Include" />
<e p="EntityAgent.cs" t="Include" />
<e p="Locomotion.cs" t="Include" />
</e>
<e p="Assets\Scripts\ServerShared\Attributes.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\Behaviors" t="Include">
<e p="Afterburner.cs" t="Include" />
@ -33,7 +39,6 @@
<e p="Assets\Scripts\ServerShared\ItemData.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\ItemInstance.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\JsonConverters.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\Locomotion.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\MathFormatters.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\MathResolver.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\Messages.cs" t="Include" />
@ -442,6 +447,7 @@
</e>
<e p="Assets\Scripts\ServerShared\OrbitalEntity.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\Rect.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\RegisterResolver.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\Ship.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\ZoneData.cs" t="Include" />
<e p="Assets\Scripts\ServerShared\ZoneGenerator.cs" t="Include" />

View file

@ -1019,6 +1019,7 @@
<Compile Include="Assets\Scripts\NIH\UniRx\Scripts\UnityWinRTBridge\ThreadPoolScheduler_UnityWinRT.cs" />
<Compile Include="Assets\Scripts\NIH\XKCDColors.cs" />
<Compile Include="Assets\Scripts\Prototype.cs" />
<Compile Include="Assets\Scripts\RethinkConnection.cs" />
<Compile Include="Assets\Scripts\StrategyGameManager.cs" />
<Compile Include="Assets\Scripts\TechTreeMsagl.cs" />
<Compile Include="Assets\Scripts\TechTreeTest.cs" />
@ -1039,6 +1040,7 @@
<Compile Include="Assets\Scripts\UI\TechNode.cs" />
<Compile Include="Assets\Scripts\UI\ZoneObject.cs" />
<Compile Include="Assets\Scripts\UI\ZoneRenderer.cs" />
<Compile Include="Assets\Scripts\UI\ZoneShip.cs" />
<Compile Include="Assets\Scripts\UnityExtensions.cs" />
<Compile Include="Assets\Scripts\UnityFormatters.cs" />
<Compile Include="Assets\Scripts\ZoneGeneratorTest.cs" />

View file

@ -0,0 +1,79 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Orbital
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 97bce58bfe43bfa40870ca062cfb7ec1, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 20cdf802f7c277841b78ce86e5d1323b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

79
Assets/Materials/Ship.mat Normal file
View file

@ -0,0 +1,79 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Ship
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 4eee2b60a0b77e248885aed0587c6329, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 658219dea0cf83049b6ab46c2f3436ed
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

359
Assets/Prefabs/Ship.prefab Normal file
View file

@ -0,0 +1,359 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &752969730562965460
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 752969730562965461}
- component: {fileID: 795352744099449573}
m_Layer: 0
m_Name: Ship
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &752969730562965461
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969730562965460}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5.38, y: 0.81, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 752969731239391542}
- {fileID: 752969731603226389}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &795352744099449573
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969730562965460}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 43af4df5b5df0424c8b211ebd29af165, type: 3}
m_Name:
m_EditorClassIdentifier:
Icon: {fileID: 752969731239391543}
Label: {fileID: 752969731603226390}
--- !u!1 &752969731239391541
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 752969731239391542}
- component: {fileID: 752969731239391536}
- component: {fileID: 752969731239391543}
- component: {fileID: 752969731239391538}
- component: {fileID: 752969731239391537}
m_Layer: 0
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &752969731239391542
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731239391541}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0.05}
m_LocalScale: {x: 0.75, y: 0.75, z: 1}
m_Children: []
m_Father: {fileID: 752969730562965461}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &752969731239391536
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731239391541}
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &752969731239391543
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731239391541}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 658219dea0cf83049b6ab46c2f3436ed, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!64 &752969731239391538
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731239391541}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
--- !u!114 &752969731239391537
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731239391541}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 52538a3309c36fc4583c964a1c0b705f, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &752969731603226388
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 752969731603226389}
- component: {fileID: 752969731603226385}
- component: {fileID: 752969731603226384}
- component: {fileID: 752969731603226391}
- component: {fileID: 752969731603226390}
m_Layer: 0
m_Name: Label
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &752969731603226389
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731603226388}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 752969730562965461}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 1, y: 1}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &752969731603226385
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731603226388}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 21677577810600300, guid: ef74c4c30ca5ced4489f28b914006aad, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &752969731603226384
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731603226388}
m_Mesh: {fileID: 0}
--- !u!222 &752969731603226391
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731603226388}
m_CullTransparentMesh: 0
--- !u!114 &752969731603226390
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 752969731603226388}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 'Regular Name
'
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ef74c4c30ca5ced4489f28b914006aad, type: 2}
m_sharedMaterial: {fileID: 21677577810600300, guid: ef74c4c30ca5ced4489f28b914006aad,
type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 2
m_fontSizeBase: 2
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_textAlignment: 258
m_characterSpacing: 1.38
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 0
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_firstOverflowCharacterIndex: -1
m_linkedTextComponent: {fileID: 0}
m_isLinkedTextComponent: 0
m_isTextTruncated: 0
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 0
m_isCullingEnabled: 0
m_ignoreRectMaskCulling: 0
m_ignoreCulling: 1
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_VertexBufferAutoSizeReduction: 1
m_firstVisibleCharacter: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_textInfo:
textComponent: {fileID: 752969731603226390}
characterCount: 0
spriteCount: 0
spaceCount: 0
wordCount: 0
linkCount: 0
lineCount: 0
pageCount: 0
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_hasFontAssetChanged: 0
m_renderer: {fileID: 752969731603226385}
m_subTextObjects:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
m_maskType: 0

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7c1524f8ce57a9943920988eae00c86e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Sprites/Flat UI/areaFade2.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,88 @@
fileFormatVersion: 2
guid: 4f0cb39a28e35cb439bcc9df886c3623
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
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: 16, z: 0, w: 16}
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: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 721ad4ac42187a04a843feabc37d6830
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -761,17 +761,17 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -2237,17 +2237,17 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
@ -83,20 +84,6 @@ public class DatabaseListView : EditorWindow
void OnEnable()
{
// Add Unity.Mathematics serialization support to RethinkDB Driver
//Converter.Serializer.Converters.Add(new MathJsonConverter());
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters = new List<JsonConverter>
{
new MathJsonConverter(),
Converter.DateTimeConverter,
Converter.BinaryConverter,
Converter.GroupingConverter,
Converter.PocoExprConverter
}
};
// Create database cache
_databaseCache = new DatabaseCache();
_databaseCache.OnDataUpdateLocal += _ => Repaint();
@ -166,101 +153,12 @@ public class DatabaseListView : EditorWindow
if (GUILayout.Button("Connect"))
{
EditorPrefs.SetString("RethinkDB.URL", _connectionString);
_connection = R.Connection().Hostname(_connectionString).Port(RethinkDBConstants.DefaultPort).Timeout(60).Connect();
Debug.Log("Connected to RethinkDB");
// When entries are changed locally, push the changes to RethinkDB
_databaseCache.OnDataUpdateLocal += async entry =>
{
var table = entry.GetType().GetCustomAttribute<RethinkTableAttribute>()?.TableName ?? "Other";
var result = await R
.Db("Aetheria")
.Table(table)
.Get(entry.ID)
.Replace(entry)
.RunAsync(_connection);
Debug.Log($"Uploaded entry to RethinkDB: {entry.ID} result: {result}");
};
_databaseCache.OnDataInsertLocal += async entry =>
{
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}");
};
_connection = RethinkConnection.RethinkConnect(_databaseCache, _connectionString);
}
_databaseCache.OnDataDeleteLocal += async entry =>
{
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);
while (await result.MoveNextAsync())
{
var entry = result.Current;
Debug.Log($"Received entry from RethinkDB: {entry.ID}");
_databaseCache.Add(entry, true);
}
}).WrapErrors();
// Get globaldata and 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 || o["$type"]==typeof(GlobalData).Name)
.RunCursorAsync<DatabaseEntry>(_connection);
while (await result.MoveNextAsync())
{
var entry = result.Current;
Debug.Log($"Received entry from RethinkDB: {entry.ID}");
_databaseCache.Add(entry, true);
}
}).WrapErrors();
// Subscribe to changes from RethinkDB
Task.Run(async () =>
{
var result = await R
.Db("Aetheria")
.Table("Items")
.Changes()
.RunChangesAsync<DatabaseEntry>(_connection);
while (await result.MoveNextAsync())
{
var change = result.Current;
if(change.OldValue == null)
Debug.Log($"Received change from RethinkDB (Entry Created): {change.NewValue.ID}");
else if(change.NewValue == null)
Debug.Log($"Received change from RethinkDB (Entry Deleted): {change.OldValue.ID}");
else
Debug.Log($"Received change from RethinkDB: {change.NewValue.ID}");
_databaseCache.Add(change.NewValue, true);
}
}).WrapErrors();
Observable.Timer(DateTimeOffset.Now, TimeSpan.FromSeconds(60)).Subscribe(_ =>
{
Debug.Log(R.Now().Run<DateTime>(_connection).ToString() as string);
});
if (GUILayout.Button("Save"))
{
_databaseCache.Save(new DirectoryInfo(Application.dataPath).Parent.FullName);
}
}
GUILayout.Space(5);

View file

@ -54,17 +54,10 @@ public class SerializerTestWindow : EditorWindow
Converter.Serializer.Converters.Add(new MathJsonConverter());
// Set extensions to default resolver.
var resolver = CompositeResolver.Create(
MathResolver.Instance,
NativeGuidResolver.Instance,
StandardResolver.Instance
);
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
MessagePackSerializer.DefaultOptions = options;
RegisterResolver.Register();
if (GUILayout.Button("Print MsgPack JSON"))
Debug.Log(MessagePackSerializer.SerializeToJson(obj, options));
Debug.Log(MessagePackSerializer.SerializeToJson(obj));
//var writer = new StringWriter();
if (GUILayout.Button("Print Newtonsoft JSON"))

View file

@ -85,6 +85,7 @@ public class Prototype : MonoBehaviour {
}
_originalPrototype.AddToPool(this);
OnReturnToPool = null;
}
public T GetOriginal<T>()

View file

@ -0,0 +1,133 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Newtonsoft.Json;
using RethinkDb.Driver;
using RethinkDb.Driver.Net;
using UniRx;
using UnityEngine;
public static class RethinkConnection
{
public static RethinkDB R = RethinkDB.R;
public static Connection RethinkConnect(DatabaseCache cache, string connectionString, bool syncLocalChanges = true)
{
// Add Unity.Mathematics serialization support to RethinkDB Driver
//Converter.Serializer.Converters.Add(new MathJsonConverter());
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters = new List<JsonConverter>
{
new MathJsonConverter(),
Converter.DateTimeConverter,
Converter.BinaryConverter,
Converter.GroupingConverter,
Converter.PocoExprConverter
}
};
var connection = R.Connection().Hostname(connectionString).Port(RethinkDBConstants.DefaultPort).Timeout(60).Connect();
Debug.Log("Connected to RethinkDB");
if (syncLocalChanges)
{
// When entries are changed locally, push the changes to RethinkDB
cache.OnDataUpdateLocal += async entry =>
{
var table = entry.GetType().GetCustomAttribute<RethinkTableAttribute>()?.TableName ?? "Other";
var result = await R
.Db("Aetheria")
.Table(table)
.Get(entry.ID)
.Replace(entry)
.RunAsync(connection);
Debug.Log($"Uploaded entry to RethinkDB: {entry.ID} result: {result}");
};
cache.OnDataInsertLocal += async entry =>
{
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}");
};
cache.OnDataDeleteLocal += async entry =>
{
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);
while (await result.MoveNextAsync())
{
var entry = result.Current;
Debug.Log($"Received Items entry from RethinkDB: {entry.GetType()} {(entry as INamedEntry)?.EntryName ?? ""}:{entry.ID}");
cache.Add(entry, true);
}
}).WrapErrors();
// Get globaldata and 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 || o["$type"]==typeof(GlobalData).Name)
.RunCursorAsync<DatabaseEntry>(connection);
while (await result.MoveNextAsync())
{
var entry = result.Current;
Debug.Log($"Received Galaxy entry from RethinkDB: {entry.GetType()} {(entry as INamedEntry)?.EntryName ?? ""}:{entry.ID}");
cache.Add(entry, true);
}
}).WrapErrors();
// Subscribe to changes from RethinkDB
Task.Run(async () =>
{
var result = await R
.Db("Aetheria")
.Table("Items")
.Changes()
.RunChangesAsync<DatabaseEntry>(connection);
while (await result.MoveNextAsync())
{
var change = result.Current;
if(change.OldValue == null)
Debug.Log($"Received change from RethinkDB (Entry Created): {change.NewValue.ID}");
else if(change.NewValue == null)
Debug.Log($"Received change from RethinkDB (Entry Deleted): {change.OldValue.ID}");
else
Debug.Log($"Received change from RethinkDB: {change.NewValue.ID}");
cache.Add(change.NewValue, true);
}
}).WrapErrors();
Observable.Timer(DateTimeOffset.Now, TimeSpan.FromSeconds(60)).Subscribe(_ =>
{
Debug.Log(R.Now().Run<DateTime>(connection).ToString() as string);
});
return connection;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a8fce60db4f3e614c8d19c3da4cede0e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 623ef3419b4e3a74c8f0350f7d9070f4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,7 @@
using System.Collections;
using System.Collections.Generic;
public abstract class AgentBehavior
{
public abstract void Update(float delta);
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87f587a591f7ba14f96f34108ca4e611
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,43 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static Unity.Mathematics.math;
using Random = Unity.Mathematics.Random;
public class AgentController
{
public Entity Entity { get; }
public EntityAgent EntityAgent { get; }
public GameContext Context { get; }
public ZoneData Zone { get; set; }
private Locomotion _locomotion;
private Random _random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue));
public AgentController(GameContext context, ZoneData zone, Entity entity)
{
Entity = entity;
Zone = zone;
Context = context;
EntityAgent = new EntityAgent(context, zone, entity);
_locomotion = new Locomotion(entity);
EntityAgent.CurrentBehavior = _locomotion;
RandomTarget();
}
public void Update(float delta)
{
EntityAgent.Update(delta);
var distance = length(_locomotion.Objective.Position - Entity.Position);
Context.Log($"Agent Distance: {distance}");
if(distance < 20)
RandomTarget();
}
private void RandomTarget()
{
var entities = Context.ZoneEntities(Zone).ToArray();
_locomotion.Objective = entities[_random.NextInt(entities.Length)];
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee1e3350676acb044bd87c1d76c535a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
public class EntityAgent
{
public AgentBehavior CurrentBehavior;
public Entity Entity { get; }
public GameContext Context { get; }
public ZoneData Zone { get; set; }
public EntityAgent(GameContext context, ZoneData zone, Entity entity)
{
Entity = entity;
Zone = zone;
Context = context;
}
public void Update(float delta)
{
CurrentBehavior.Update(delta);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fdefbc1e15541d8448061e9d97e44648
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.Mathematics;
using static Unity.Mathematics.math;
public class Locomotion : AgentBehavior
{
public Entity Objective;
private Entity _entity;
private IAnalogBehavior _thrust;
private IAnalogBehavior _turning;
private const float Sensitivity = 1;
public Locomotion(Entity entity)
{
_entity = entity;
_thrust = entity.Axes.Keys.FirstOrDefault(x => x is Thruster);
_turning = entity.Axes.Keys.FirstOrDefault(x => x is Turning);
}
public override void Update(float delta)
{
if (Objective != null && _thrust != null && _turning != null)
{
float2 diff = Objective.Position - _entity.Position;
var directionAngle = atan2(diff.y, diff.x) / PI;
var currentAngle = atan2(_entity.Direction.y, _entity.Direction.x) / PI;
var d1 = directionAngle - currentAngle;
var d2 = directionAngle - 2 - currentAngle;
var d3 = directionAngle + 2 - currentAngle;
var angleDiff = abs(d1) < abs(d2) ? abs(d1) < abs(d3) ? d1 : d3 : abs(d2) < abs(d3) ? d2 : d3;
_entity.Axes[_turning] = clamp(-angleDiff * Sensitivity, -1, 1);
_entity.Axes[_thrust] = 1;
}
}
}

View file

@ -9,13 +9,10 @@ public class ThrusterData : IBehaviorData
[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)]
[InspectableField, JsonProperty("visibility"), Key(1)]
public PerformanceStat Visibility = new PerformanceStat();
[InspectableField, JsonProperty("heat"), Key(3)]
[InspectableField, JsonProperty("heat"), Key(2)]
public PerformanceStat Heat = new PerformanceStat();
public IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
@ -55,7 +52,7 @@ public class Thruster : IAnalogBehavior
public void Update(float delta)
{
((Ship) Entity).Velocity += _thrust * Context.Evaluate(_data.Thrust, Item, Entity) * delta;
Entity.Velocity += Entity.Direction * _thrust * Context.Evaluate(_data.Thrust, Item, Entity) / Entity.Mass * delta;
Entity.AddHeat(_thrust * Context.Evaluate(_data.Heat, Item, Entity) * delta);
Entity.VisibilitySources[this] = _thrust * Context.Evaluate(_data.Visibility, Item, Entity);
}

View file

@ -11,15 +11,12 @@ public class DatabaseCache
public event Action<DatabaseEntry> OnDataUpdateLocal;
public event Action<DatabaseEntry> OnDataDeleteLocal;
public event Action<DatabaseEntry> OnDataUpdateRemote;
public Action<string> Logger = Console.WriteLine;
private readonly Dictionary<Guid, DatabaseEntry> _entries = new Dictionary<Guid, DatabaseEntry>();
private readonly Dictionary<Type, Dictionary<Guid, DatabaseEntry>> _types = new Dictionary<Type, Dictionary<Guid, DatabaseEntry>>();
private DirectoryInfo _dir;
public IEnumerable<DatabaseEntry> AllEntries => _entries.Values;
@ -90,4 +87,19 @@ public class DatabaseCache
if (!remote)
OnDataDeleteLocal?.Invoke(entry);
}
public void Load(string path)
{
RegisterResolver.Register();
var bytes = File.ReadAllBytes(Path.Combine(path, "AetherDB.msgpack"));
var entries = MessagePackSerializer.Deserialize<DatabaseEntry[]>(bytes);
AddAll(entries);
}
public void Save(string path)
{
RegisterResolver.Register();
var entries = AllEntries.ToArray();
File.WriteAllBytes(Path.Combine(path, "AetherDB.msgpack"), MessagePackSerializer.Serialize(entries));
}
}

View file

@ -22,17 +22,20 @@ public interface INamedEntry
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(4, typeof(SimpleCommodity)),
Union(5, typeof(CompoundCommodity)),
Union(6, typeof(Gear)),
Union(7, typeof(BlueprintData)),
Union(8, typeof(GalaxyMapLayerData)),
Union(9, typeof(GlobalData)),
Union(10, typeof(ZoneData)),
Union(11, typeof(Player)),
Union(12, typeof(Corporation)),
Union(13, typeof(Ship)),
Union(13, typeof(ShipData)),
Union(14, typeof(StationData)),
Union(15, typeof(OrbitData)),
Union(16, typeof(PlanetData)),
// Union(17, typeof(ShipData)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
//[Union(21, typeof(ContractData))]
//[Union(22, typeof(Station))]
@ -70,4 +73,10 @@ public class Corporation : DatabaseEntry, INamedEntry
get => Name;
set => Name = value;
}
}
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class ShipData : DatabaseEntry
{
}

View file

@ -13,31 +13,36 @@ public class Entity
public float Temperature;
public float Energy;
public float2 Position;
public float2 Direction;
public float2 Direction = float2(0,1);
public float2 Velocity;
public Dictionary<Guid, List<IActivatedBehavior>> Bindings;
public Dictionary<IAnalogBehavior, float> Axes;
protected readonly GameContext Context;
protected readonly List<IBehavior> Behaviors;
protected readonly Dictionary<Guid, List<IActivatedBehavior>> Bindings;
protected readonly Dictionary<IAnalogBehavior, float> Axes;
protected readonly List<Gear> Items;
protected readonly List<ItemInstance> Cargo;
protected Gear Hull;
public float Mass { get; private set; }
public float SpecificHeat { get; private set; }
public float Visibility => VisibilitySources.Values.Sum();
public Entity(GameContext context, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo)
public Entity(GameContext context, Gear hull, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo)
{
Context = context;
Items = items.ToList();
Cargo = cargo.ToList();
Hull = hull;
Mass = Items.Sum(i => i.Mass) +
Mass = hull?.Mass ?? 0 +
Items.Sum(i => i.Mass) +
Cargo.Sum(ii => ii.Mass);
SpecificHeat = Items.Sum(i => i.HeatCapacity) +
SpecificHeat = (hull?.HeatCapacity ?? 0) +
Items.Sum(i => i.HeatCapacity) +
Cargo.Sum(ii => ii.HeatCapacity);
Behaviors = Items

View file

@ -67,8 +67,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()));
private static Random Random => (Random) (_random ?? (_random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue))));
// 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;

View file

@ -6,6 +6,10 @@ using static Unity.Mathematics.math;
public class GameContext
{
public List<AgentController> Agents = new List<AgentController>();
public Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>> ZoneContents = new Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>>();
public Dictionary<string, GalaxyMapLayerData> MapLayers = new Dictionary<string, GalaxyMapLayerData>();
private Action<string> _logger;
private Dictionary<BlueprintStatEffect, PerformanceStat> AffectedStats =
@ -13,8 +17,9 @@ public class GameContext
private double _time;
private float _deltaTime;
private GlobalData _globalData;
public GlobalData GlobalData => Cache.GetAll<GlobalData>().FirstOrDefault();
public GlobalData GlobalData => _globalData ?? (_globalData = Cache.GetAll<GlobalData>().FirstOrDefault());
public DatabaseCache Cache { get; }
public double Time
@ -27,20 +32,18 @@ public class GameContext
}
}
private Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>> ZoneContents = new Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>>();
// private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();
public GameContext(DatabaseCache cache, Action<string> logger)
{
Cache = cache;
_logger = logger;
var globalData = Cache.GetAll<GlobalData>().FirstOrDefault();
if (globalData == null)
{
globalData = new GlobalData();
Cache.Add(globalData);
}
// var globalData = Cache.GetAll<GlobalData>().FirstOrDefault();
// if (globalData == null)
// {
// globalData = new GlobalData();
// Cache.Add(globalData);
// }
}
public void Log(string s)
@ -48,6 +51,11 @@ public class GameContext
_logger(s);
}
public IEnumerable<Entity> ZoneEntities(ZoneData zone)
{
return ZoneContents[zone].Values;
}
public Dictionary<DatabaseEntry, Entity> InitializeZone(Guid zoneID)
{
var contents = new Dictionary<DatabaseEntry, Entity>();
@ -56,13 +64,13 @@ public class GameContext
var planetsData = zoneData.Planets.Select(id => Cache.Get<PlanetData>(id)).ToArray();
var planetEntities = planetsData.ToDictionary(p => p,
p => new OrbitalEntity(this, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), p.Belt ? Cache.Get<OrbitData>(p.Orbit).Parent : p.Orbit));
p => new OrbitalEntity(this, null, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), p.Belt ? Cache.Get<OrbitData>(p.Orbit).Parent : p.Orbit));
foreach(var kvp in planetEntities)
contents.Add(kvp.Key, kvp.Value);
var stationsData = zoneData.Stations.Select(id => Cache.Get<StationData>(id));
var stationEntities = stationsData.ToDictionary(s => s,
s => new OrbitalEntity(this, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), s.Parent));
s => new OrbitalEntity(this, null, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), s.Parent));
foreach(var kvp in stationEntities)
contents.Add(kvp.Key, kvp.Value);
@ -73,6 +81,10 @@ public class GameContext
public void Update()
{
foreach (var agent in Agents)
{
agent.Update(_deltaTime);
}
OrbitalEntity.ClearOrbits();
foreach (var kvp in ZoneContents)
{
@ -293,7 +305,8 @@ public class GameContext
Data = data,
ID = Guid.NewGuid(),
Ingredients = ingredients,
Quality = quality
Quality = quality,
Blueprint = blueprint
};
newGear.Durability = Evaluate(equippableItemData.Durability, newGear);
return newGear;
@ -305,7 +318,8 @@ public class GameContext
Data = data,
ID = Guid.NewGuid(),
Ingredients = ingredients,
Quality = quality
Quality = quality,
Blueprint = blueprint
};
}
}

View file

@ -12,8 +12,11 @@ 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;
@ -22,7 +25,9 @@ public abstract class ItemInstance : DatabaseEntry
public float HeatCapacity => Context.GetHeatCapacity(this);
}
[Union(0, typeof(CompoundCommodity)), Union(1, typeof(Gear)), JsonObject(MemberSerialization.OptIn),
[Union(0, typeof(CompoundCommodity)),
Union(1, typeof(Gear)),
JsonObject(MemberSerialization.OptIn),
JsonConverter(typeof(JsonKnownTypesConverter<CraftedItemInstance>))]
public abstract class CraftedItemInstance : ItemInstance
{

View file

@ -1,17 +0,0 @@
using System.Collections;
using System.Collections.Generic;
public class Locomotion
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View file

@ -10,7 +10,7 @@ public class OrbitalEntity : Entity
private Guid _orbitData;
private static Dictionary<Guid, float2> _orbitPositions = new Dictionary<Guid, float2>();
public OrbitalEntity(GameContext context, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo, Guid orbit) : base(context, items, cargo)
public OrbitalEntity(GameContext context, Gear hull, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo, Guid orbit) : base(context, hull, items, cargo)
{
_orbitData = orbit;
}

View file

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using MessagePack.Resolvers;
public static class RegisterResolver
{
private static bool registered = false;
public static void Register()
{
if (registered) return;
// Set extensions to default resolver.
var resolver = CompositeResolver.Create(
MathResolver.Instance,
NativeGuidResolver.Instance,
StandardResolver.Instance
);
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
MessagePackSerializer.DefaultOptions = options;
registered = true;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc638a5fae4350643871d45495a49643
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -21,9 +21,7 @@ public class Ship : Entity
// [IgnoreMember] public Dictionary<Targetable, float> Contacts = new Dictionary<Targetable, float>();
// [IgnoreMember] public Targetable Target;
private HullData _hullData;
public Ship(GameContext context, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo) : base(context, items, cargo)
public Ship(GameContext context, Gear hull, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo) : base(context, hull, items, cargo)
{
}
@ -113,6 +111,7 @@ public class Ship : Entity
public override void Update(float delta)
{
Position += Velocity * delta;
base.Update(delta);
// foreach (var kvp in Contacts.ToArray())
// if (kvp.Key == null || Time.time - kvp.Value > GlobalData.Instance.TargetPersistenceDuration)

View file

@ -5,8 +5,6 @@ using System.Globalization;
using System.Linq;
using MessagePack;
using Unity.Mathematics;
//using UnityEngine;
// TODO: USE THIS EVERYWHERE
using static Unity.Mathematics.math;
using Random = Unity.Mathematics.Random;
@ -67,7 +65,7 @@ public class ZoneGenerator
// Cache resource densities
var resourceMaps = mapLayers.ToDictionary(m => m.ID, m => m.Evaluate(zone.Position, global));
var random = new Random();
var random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue));
planetsData = planets.Where(p=>!p.Empty).Select(planet =>
{

View file

@ -1,11 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using RethinkDb.Driver.Net;
using UnityEngine;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
using Random = UnityEngine.Random;
public class StrategyGameManager : MonoBehaviour
{
@ -20,8 +23,10 @@ public class StrategyGameManager : MonoBehaviour
public MeshRenderer GalaxyBackground;
public float GalaxyScale;
public ZoneObject ZoneObjectPrefab;
public ZoneShip ZoneShipPrefab;
public ParticleSystem BeltPrefab;
public Transform ZoneRoot;
public Texture2D PlanetoidSprite;
public Texture2D PlanetSprite;
public Texture2D GasGiantSprite;
public Texture2D OrbitalSprite;
@ -38,7 +43,7 @@ public class StrategyGameManager : MonoBehaviour
private DatabaseCache _cache;
private GameContext _context;
private GalaxyResponseMessage _galaxy;
// private GalaxyResponseMessage _galaxyResponse;
private TabButton _currentTab;
private bool _galaxyPopulated;
private Guid _populatedZone;
@ -48,12 +53,14 @@ public class StrategyGameManager : MonoBehaviour
private Dictionary<Guid, GalaxyZone> _galaxyZoneObjects = new Dictionary<Guid, GalaxyZone>();
private Dictionary<OrbitalEntity, ZoneObject> _zoneObjects = new Dictionary<OrbitalEntity, ZoneObject>();
private Dictionary<OrbitalEntity, ParticleSystem> _zoneBelts = new Dictionary<OrbitalEntity, ParticleSystem>();
private Dictionary<Ship, ZoneShip> _zoneShips = new Dictionary<Ship, ZoneShip>();
private List<ZoneObject> _wormholes = new List<ZoneObject>();
private Vector3 _galaxyCameraPos = -Vector3.forward;
private float _galaxyOrthoSize = 50;
private Material _boundaryMaterial;
private Material _backgroundMaterial;
private bool _techLayoutGenerated;
private Connection _connection;
void Start()
{
@ -62,7 +69,18 @@ public class StrategyGameManager : MonoBehaviour
if (TestMode)
{
_cache.Load(new DirectoryInfo(Application.dataPath).Parent.FullName);
_context = new GameContext(_cache, Debug.Log);
TechTree.Context = _context;
_context.MapLayers = _cache.GetAll<GalaxyMapLayerData>().ToDictionary(ml => ml.Name);
_galaxyResponseZones = _cache.GetAll<ZoneData>()
.ToDictionary(z => z.ID, z => new GalaxyResponseZone
{
Links = z.Wormholes.ToArray(),
Name = z.Name,
Position = z.Position,
ZoneID = z.ID
});
}
else
{
@ -75,10 +93,11 @@ public class StrategyGameManager : MonoBehaviour
// Listen for the server's galaxy description
CultClient.AddMessageListener<GalaxyResponseMessage>(galaxy =>
{
_galaxy = galaxy;
_galaxyResponseZones = _galaxy.Zones.ToDictionary(z => z.ZoneID);
_cache.Add(_galaxy.GlobalData, true);
_galaxyResponseZones = galaxy.Zones.ToDictionary(z => z.ZoneID);
_cache.Add(galaxy.GlobalData, true);
_context = new GameContext(_cache, Debug.Log);
TechTree.Context = _context;
_context.MapLayers["StarDensity"] = galaxy.StarDensity;
if (_currentTab == GalaxyTabButton && !_galaxyPopulated) PopulateGalaxy();
});
@ -129,6 +148,32 @@ public class StrategyGameManager : MonoBehaviour
private void Update()
{
if (TestMode)
{
if (Input.GetKeyDown(KeyCode.S))
{
var zoneData = _cache.Get<ZoneData>(_populatedZone);
var thrusterData = _cache.GetAll<GearData>().FirstOrDefault(g => g.Behaviors.Any(b => b is ThrusterData));
var thruster = _context.CreateInstance(thrusterData.ID, .9f) as Gear;
var hullData = _cache.GetAll<HullData>().FirstOrDefault(h => h.Name == "Fighter");
var hull = _context.CreateInstance(hullData.ID, .9f) as Gear;
var entity = new Ship(_context, hull, new []{thruster}, Enumerable.Empty<ItemInstance>());
var shipData = new ShipData // TODO: Better database entry for ships?
{
ID = Guid.NewGuid()
};
_context.ZoneContents[zoneData][shipData] = entity;
_context.Agents.Add(new AgentController(_context, zoneData, entity));
var zoneShip = Instantiate(ZoneShipPrefab, ZoneRoot);
zoneShip.Label.text = $"Ship {_zoneShips.Count}";
_zoneShips[entity] = zoneShip;
}
if (Input.GetKeyDown(KeyCode.Space) && _currentTab == ZoneTabButton)
{
PopulateZone();
}
}
if (_context != null)
{
_context.Time = Time.time;
@ -143,13 +188,19 @@ public class StrategyGameManager : MonoBehaviour
{
foreach (var planet in _zoneObjects)
{
planet.Value.transform.position = (Vector2) planet.Key.Position * ZoneSizeScale;
planet.Value.transform.position = float3(planet.Key.Position * ZoneSizeScale, .1f);
}
foreach (var belt in _zoneBelts)
{
belt.Value.transform.position = float3(belt.Key.Position * ZoneSizeScale, .15f);
}
foreach (var ship in _zoneShips)
{
ship.Value.transform.position = float3(ship.Key.Position * ZoneSizeScale, .05f);
ship.Value.Icon.transform.up = (Vector2) ship.Key.Direction;
}
}
}
@ -160,25 +211,25 @@ public class StrategyGameManager : MonoBehaviour
GalaxyBackground.transform.localScale = Vector3.one * GalaxyScale;
var galaxyMat = GalaxyBackground.material;
galaxyMat.SetFloat("Arms", _galaxy.GlobalData.Arms);
galaxyMat.SetFloat("Twist", _galaxy.GlobalData.Twist);
galaxyMat.SetFloat("TwistPower", _galaxy.GlobalData.TwistPower);
galaxyMat.SetFloat("SpokeOffset", _galaxy.StarDensity.SpokeOffset);
galaxyMat.SetFloat("SpokeScale", _galaxy.StarDensity.SpokeScale);
galaxyMat.SetFloat("CoreBoost", _galaxy.StarDensity.CoreBoost);
galaxyMat.SetFloat("CoreBoostOffset", _galaxy.StarDensity.CoreBoostOffset);
galaxyMat.SetFloat("CoreBoostPower", _galaxy.StarDensity.CoreBoostPower);
galaxyMat.SetFloat("EdgeReduction", _galaxy.StarDensity.EdgeReduction);
galaxyMat.SetFloat("NoisePosition", _galaxy.StarDensity.NoisePosition);
galaxyMat.SetFloat("NoiseAmplitude", _galaxy.StarDensity.NoiseAmplitude);
galaxyMat.SetFloat("NoiseOffset", _galaxy.StarDensity.NoiseOffset);
galaxyMat.SetFloat("NoiseGain", _galaxy.StarDensity.NoiseGain);
galaxyMat.SetFloat("NoiseLacunarity", _galaxy.StarDensity.NoiseLacunarity);
galaxyMat.SetFloat("NoiseFrequency", _galaxy.StarDensity.NoiseFrequency);
galaxyMat.SetFloat("Arms", _context.GlobalData.Arms);
galaxyMat.SetFloat("Twist", _context.GlobalData.Twist);
galaxyMat.SetFloat("TwistPower", _context.GlobalData.TwistPower);
galaxyMat.SetFloat("SpokeOffset", _context.MapLayers["StarDensity"].SpokeOffset);
galaxyMat.SetFloat("SpokeScale", _context.MapLayers["StarDensity"].SpokeScale);
galaxyMat.SetFloat("CoreBoost", _context.MapLayers["StarDensity"].CoreBoost);
galaxyMat.SetFloat("CoreBoostOffset", _context.MapLayers["StarDensity"].CoreBoostOffset);
galaxyMat.SetFloat("CoreBoostPower", _context.MapLayers["StarDensity"].CoreBoostPower);
galaxyMat.SetFloat("EdgeReduction", _context.MapLayers["StarDensity"].EdgeReduction);
galaxyMat.SetFloat("NoisePosition", _context.MapLayers["StarDensity"].NoisePosition);
galaxyMat.SetFloat("NoiseAmplitude", _context.MapLayers["StarDensity"].NoiseAmplitude);
galaxyMat.SetFloat("NoiseOffset", _context.MapLayers["StarDensity"].NoiseOffset);
galaxyMat.SetFloat("NoiseGain", _context.MapLayers["StarDensity"].NoiseGain);
galaxyMat.SetFloat("NoiseLacunarity", _context.MapLayers["StarDensity"].NoiseLacunarity);
galaxyMat.SetFloat("NoiseFrequency", _context.MapLayers["StarDensity"].NoiseFrequency);
var zones = _galaxy.Zones.ToDictionary(z=>z.ZoneID);
// var zones = _galaxyResponse.Zones.ToDictionary(z=>z.ZoneID);
var linkedZones = new List<Guid>();
foreach (var zone in _galaxy.Zones)
foreach (var zone in _galaxyResponseZones.Values)
{
linkedZones.Add(zone.ZoneID);
var instance = GalaxyZonePrototype.Instantiate<Transform>();
@ -203,7 +254,7 @@ public class StrategyGameManager : MonoBehaviour
foreach (var linkedZone in zone.Links.Where(l=>!linkedZones.Contains(l)))
{
var link = GalaxyZoneLinkPrototype.Instantiate<Transform>();
var diff = zones[linkedZone].Position - zone.Position;
var diff = _galaxyResponseZones[linkedZone].Position - zone.Position;
link.position = instance.position + Vector3.forward*.1f;
link.rotation = Quaternion.Euler(0,0,atan2(diff.y, diff.x) * Mathf.Rad2Deg);
link.localScale = new Vector3(length(diff) * GalaxyScale, 1, 1);
@ -220,13 +271,38 @@ public class StrategyGameManager : MonoBehaviour
_wormholes.Clear();
foreach (var belt in _zoneBelts.Values) Destroy(belt.gameObject);
_zoneBelts.Clear();
foreach (var ship in _zoneShips.Values) Destroy(ship.gameObject);
_zoneShips.Clear();
if(_populatedZone!=Guid.Empty)
_context.UnloadZone(_cache.Get<ZoneData>(_populatedZone));
_populatedZone = _selectedZone;
var zoneData = _cache.Get<ZoneData>(_populatedZone);
ZoneData zoneData = _cache.Get<ZoneData>(_populatedZone);
if (TestMode && !zoneData.Visited)
{
float2 position;
do
{
position = float2(Random.value, Random.value);
} while (_context.MapLayers["StarDensity"].Evaluate(position, _context.GlobalData) < .1f);
OrbitData[] orbits;
PlanetData[] planets;
ZoneGenerator.GenerateZone(
global: _context.GlobalData,
zone: zoneData,
mapLayers: _context.MapLayers.Values,
resources: _cache.GetAll<SimpleCommodityData>(),
orbitData: out orbits,
planetsData: out planets);
_cache.AddAll(orbits);
_cache.AddAll(planets);
zoneData.Visited = true;
}
var zoneContents = _context.InitializeZone(_populatedZone);
float zoneDepth = 0;
@ -252,7 +328,8 @@ public class StrategyGameManager : MonoBehaviour
planetObject.Icon.material.SetTexture("_MainTex",
planetData.Mass > _context.GlobalData.SunMass ? SunSprite :
planetData.Mass > _context.GlobalData.GasGiantMass ? GasGiantSprite :
PlanetSprite);
planetData.Mass > _context.GlobalData.PlanetMass ? PlanetSprite :
PlanetoidSprite);
}
else
{
@ -296,9 +373,11 @@ public class StrategyGameManager : MonoBehaviour
if (pointer.clickCount == 2)
{
_selectedGalaxyZone.Background.material.SetColor("_TintColor", UnselectedColor);
if(_selectedZone != wormhole)
if(_selectedZone != wormhole && !TestMode)
CultClient.Send(new ZoneRequestMessage{ZoneID = wormhole});
_selectedZone = wormhole;
if(TestMode)
PopulateZone();
_selectedGalaxyZone = _galaxyZoneObjects[wormhole];
_selectedGalaxyZone.Background.material.SetColor("_TintColor", SelectedColor);

View file

@ -7,6 +7,7 @@ using Microsoft.Msagl.Core.Geometry.Curves;
using Microsoft.Msagl.Core.Layout;
using Microsoft.Msagl.Layout.Layered;
using NaughtyAttributes;
using TMPro;
using UnityEngine;
using Random = UnityEngine.Random;
using Unity.Mathematics;
@ -21,6 +22,18 @@ public class TechTreeMsagl : MonoBehaviour
public Prototype RadialLink;
public Prototype Arrow;
[Section("UI Links")]
public RectTransform PropertiesPanel;
public TextMeshProUGUI TechName;
public TextMeshProUGUI Quality;
public TextMeshProUGUI ProductionTime;
public TextMeshProUGUI Produces;
public TextMeshProUGUI ResearchTime;
public Prototype RequirementPrototype;
public Prototype DependencyPrototype;
public Prototype DescendantPrototype;
public ClickRaycaster ClickRaycaster;
[Section("Graph Generation")]
public bool TestMode = false;
public int TechCount = 50;
@ -63,11 +76,14 @@ public class TechTreeMsagl : MonoBehaviour
public Material TechArrowMaterial;
public Material TechLinkMaterial;
public GameContext Context;
private List<Prototype> _ringInstances = new List<Prototype>();
private List<Prototype> _techInstances = new List<Prototype>();
private List<Prototype> _linkInstances = new List<Prototype>();
private List<Prototype> _arrowInstances = new List<Prototype>();
private Texture2D[] _icons;
private List<Prototype> _propertyInstances = new List<Prototype>();
public BlueprintData[] Blueprints { get; set; }
@ -75,6 +91,7 @@ public class TechTreeMsagl : MonoBehaviour
{
if(TestMode)
Initialize();
ClickRaycaster.OnClickMiss += () => PropertiesPanel.gameObject.SetActive(false);
}
public void Initialize()
@ -193,7 +210,7 @@ public class TechTreeMsagl : MonoBehaviour
var region = GetRegion(island, node, DependencyAncestorDepth, DependencyDepth);
while (Random.value < MultipleDependencyProbability && region.Count > 0)
{
var dependency = region.RandomElement();
var dependency = region[Random.Range(0,region.Count)];
graph.Edges.Add(new Edge(dependency.UserData as Node, node.UserData as Node));
region.Remove(dependency);
}
@ -205,7 +222,7 @@ public class TechTreeMsagl : MonoBehaviour
var largestIsland = islandsBySize.First();
foreach (var island in islandsBySize.Skip(1))
settings.VerticalConstraints.SameLayerConstraints.Insert(new Tuple<Node, Node>(
largestIsland.Nodes.RandomElement().UserData as Node, island.Nodes.RandomElement().UserData as Node));
largestIsland.Nodes[Random.Range(0,largestIsland.Nodes.Count)].UserData as Node, island.Nodes[Random.Range(0,island.Nodes.Count)].UserData as Node));
settings.PackingMethod = PackingMethod;
settings.Transformation = PlaneTransformation.Rotation(PI);
@ -321,6 +338,38 @@ public class TechTreeMsagl : MonoBehaviour
tech.Icon.material.SetTexture("_MainTex", _icons[Random.Range(0,_icons.Length-1)]);
tech.Fill.material = islandFillMaterials[islandMap[vertex]];
tech.Glow.material = islandGlowMaterials[islandMap[vertex]];
if (!TestMode)
tech.Fill.GetComponent<ClickableCollider>().OnClick += (collider, data) =>
{
foreach (var instance in _propertyInstances) instance.ReturnToPool();
var blueprint = (BlueprintData) vertex.UserData;
PropertiesPanel.gameObject.SetActive(true);
TechName.text = blueprint.Name;
Quality.text = $"{Mathf.RoundToInt(blueprint.Quality * 100)}%";
ProductionTime.text = $"{blueprint.ProductionTime:0.##} MH";
Produces.text = $"{blueprint.Quantity} {Context.Cache.Get<ItemData>(blueprint.Item).Name}";
ResearchTime.text = $"{blueprint.ResearchTime:0.##} MH";
foreach (var ingredient in blueprint.Ingredients)
{
var ingredientData = Context.Cache.Get<ItemData>(ingredient.Key);
var ingredientInstance = RequirementPrototype.Instantiate<Prototype>();
ingredientInstance.GetComponentInChildren<TextMeshProUGUI>().text = $"{ingredient.Value} {ingredientData.Name}";
_propertyInstances.Add(ingredientInstance);
}
foreach (var dependency in blueprint.Dependencies)
{
var dependencyBlueprint = Context.Cache.Get<BlueprintData>(dependency);
var dependencyInstance = DependencyPrototype.Instantiate<Prototype>();
dependencyInstance.GetComponentInChildren<TextMeshProUGUI>().text = dependencyBlueprint.Name;
_propertyInstances.Add(dependencyInstance);
}
foreach (var descendant in graph.Edges.Where(e=>e.Source==vertex).Select(e=>(BlueprintData) e.Target.UserData))
{
var descendantInstance = DescendantPrototype.Instantiate<Prototype>();
descendantInstance.GetComponentInChildren<TextMeshProUGUI>().text = descendant.Name;
_propertyInstances.Add(descendantInstance);
}
};
_techInstances.Add(tech.GetComponent<Prototype>());
}

View file

@ -1,9 +1,11 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ClickRaycaster : MonoBehaviour
{
public event Action OnClickMiss;
public Camera RayCamera;
private ClickCatcher _clickCatcher;
@ -19,6 +21,7 @@ public class ClickRaycaster : MonoBehaviour
var clickable = hit.collider.GetComponent<ClickableCollider>();
if (clickable != null)
clickable.Click(pointer);
else OnClickMiss?.Invoke();
}
};
}

View file

@ -9,4 +9,11 @@ public class ClickableCollider : MonoBehaviour
public event Action<ClickableCollider, PointerEventData> OnClick;
public void Click(PointerEventData eventData) => OnClick?.Invoke(this, eventData);
void Start()
{
var proto = GetComponent<Prototype>();
if(proto != null)
proto.OnReturnToPool += () => OnClick = null;
}
}

View file

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class ZoneShip : MonoBehaviour
{
public MeshRenderer Icon;
public TextMeshPro Label;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43af4df5b5df0424c8b211ebd29af165
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -123,7 +123,7 @@ namespace ChatApp.Server
var context = new GameContext(cache, s=>_logger.Log(LogLevel.Information, s));
var mapLayers = cache.GetAll<GalaxyMapLayerData>().ToDictionary(m => m.Name);
context.MapLayers = cache.GetAll<GalaxyMapLayerData>().ToDictionary(m => m.Name);
server.AddMessageListener<GalaxyRequestMessage>(galaxyRequest => galaxyRequest.Peer.Send(
new GalaxyResponseMessage
@ -137,7 +137,7 @@ namespace ChatApp.Server
Links = zd.Wormholes?.ToArray() ?? Array.Empty<Guid>()
}).ToArray(),
GlobalData = context.GlobalData,
StarDensity = mapLayers["StarDensity"]
StarDensity = context.MapLayers["StarDensity"]
}));
server.AddMessageListener<BlueprintsRequestMessage>(blueprintRequest => blueprintRequest.Peer.Send(
@ -159,7 +159,7 @@ namespace ChatApp.Server
ZoneGenerator.GenerateZone(
global: context.GlobalData,
zone: zone,
mapLayers: mapLayers.Values,
mapLayers: context.MapLayers.Values,
resources: cache.GetAll<SimpleCommodityData>(),
orbitData: out orbits,
planetsData: out planets);

View file

@ -61,6 +61,10 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Scripts\ServerShared\ActionCollection.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\AgentBehavior.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\AgentController.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\EntityAgent.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\Locomotion.cs" />
<Compile Include="Assets\Scripts\ServerShared\Attributes.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Afterburner.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Behaviors.cs" />
@ -87,7 +91,6 @@
<Compile Include="Assets\Scripts\ServerShared\ItemData.cs" />
<Compile Include="Assets\Scripts\ServerShared\ItemInstance.cs" />
<Compile Include="Assets\Scripts\ServerShared\JsonConverters.cs" />
<Compile Include="Assets\Scripts\ServerShared\Locomotion.cs" />
<Compile Include="Assets\Scripts\ServerShared\MathFormatters.cs" />
<Compile Include="Assets\Scripts\ServerShared\MathResolver.cs" />
<Compile Include="Assets\Scripts\ServerShared\Messages.cs" />
@ -448,6 +451,7 @@
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Utils\TaskHelper.cs" />
<Compile Include="Assets\Scripts\ServerShared\OrbitalEntity.cs" />
<Compile Include="Assets\Scripts\ServerShared\Rect.cs" />
<Compile Include="Assets\Scripts\ServerShared\RegisterResolver.cs" />
<Compile Include="Assets\Scripts\ServerShared\Ship.cs" />
<Compile Include="Assets\Scripts\ServerShared\ZoneData.cs" />
<Compile Include="Assets\Scripts\ServerShared\ZoneGenerator.cs" />

6
RethinkDB Queries.txt Normal file
View file

@ -0,0 +1,6 @@
Empty Galaxy
r.db('Aetheria').table('Galaxy').filter({$type:'ZoneData'}).update({visited: false})
r.db('Aetheria').table('Galaxy').filter({$type:'ZoneData'}).update({orbits: [ ]})
r.db('Aetheria').table('Galaxy').filter({$type:'ZoneData'}).update({planets: [ ]})
r.db('Aetheria').table('Galaxy').filter({$type:'OrbitData'}).delete()
r.db('Aetheria').table('Galaxy').filter({$type:'PlanetData'}).delete()