From 1284149d47ad55ff0f5633aea352d8b258f0c5fd Mon Sep 17 00:00:00 2001 From: Reinier Vens Date: Tue, 11 May 2021 04:45:42 +0100 Subject: [PATCH] Hostility System Implemented hostility system - entities can mark each other as friend or foe depending on changing conditions (currently only depends on local security level) Added "friendly" target indicators in blue --- .../Actor-Mixer Hierarchy/SFX.wwu | 8 +- ...eria-Economy_WwiseProject.rwvens.wsettings | 30 +-- Aetheria-Economy_WwiseProject/Events/SFX.wwu | 16 +- .../Default Work Unit.wwu | 8 +- Assets/Materials/Brushes/Fog Tint.mat | 2 +- Assets/Materials/Brushes/Gravity Well.mat | 2 +- .../Materials/Brushes/Influence Brush 1.mat | 2 +- Assets/Materials/Brushes/Influence Brush.mat | 2 +- .../Brushes/Main Menu Ambient Fog Tint.mat | 2 +- .../Brushes/Main Menu Sun Fog Tint.mat | 2 +- Assets/Materials/Brushes/Ping Light.mat | 2 +- .../Materials/Brushes/Sector Boundary Fog.mat | 2 +- .../Brushes/Sector Boundary Test.mat | 2 +- Assets/Materials/Brushes/Sector Boundary.mat | 2 +- Assets/Materials/Brushes/Sector Tint Test.mat | 2 +- Assets/Materials/Brushes/Sector Tint.mat | 2 +- .../Materials/Brushes/Wormhole Gravity 1.mat | 2 +- Assets/Materials/Brushes/Wormhole Gravity.mat | 2 +- .../Materials/Brushes/Wormhole Lighting.mat | 2 +- Assets/Materials/UI/Map Gravity Lines.mat | 2 +- Assets/Resources/Settings.asset | 4 +- Assets/Scenes/ARPG.unity | 251 +++++++++++++++++- Assets/Scenes/Main Menu.unity | 20 +- Assets/Scripts/Gameplay/ActionGameManager.cs | 74 ++++-- Assets/Scripts/Gameplay/EntityInstance.cs | 3 +- Assets/Scripts/ServerShared/Agents/Minion.cs | 2 +- .../Behaviors/TurretController.cs | 2 +- Assets/Scripts/ServerShared/Corporations.cs | 4 +- Assets/Scripts/ServerShared/Entity.cs | 153 ++++++++--- Assets/Scripts/ServerShared/OrbitalEntity.cs | 10 + Assets/Scripts/ServerShared/Settings.cs | 1 + Assets/Scripts/ServerShared/Zone.cs | 22 +- ...Indicator.cs => VisibleTargetIndicator.cs} | 2 +- ...cs.meta => VisibleTargetIndicator.cs.meta} | 0 Assets/Shaders/Brushes/PowerBrush.shader | 6 +- .../Shaders/Raymarching/VolumeRender.shader | 4 +- .../ProjectData/AkWwiseProjectData.asset | 4 +- GameData/PlayerSettings.msgpack | 4 +- UserSettings/EditorUserSettings.asset | 2 +- 39 files changed, 520 insertions(+), 142 deletions(-) rename Assets/Scripts/UI/HUD/{VisibleHostileIndicator.cs => VisibleTargetIndicator.cs} (79%) rename Assets/Scripts/UI/HUD/{VisibleHostileIndicator.cs.meta => VisibleTargetIndicator.cs.meta} (100%) diff --git a/Aetheria-Economy_WwiseProject/Actor-Mixer Hierarchy/SFX.wwu b/Aetheria-Economy_WwiseProject/Actor-Mixer Hierarchy/SFX.wwu index c085d13dc..f6d74ab2b 100644 --- a/Aetheria-Economy_WwiseProject/Actor-Mixer Hierarchy/SFX.wwu +++ b/Aetheria-Economy_WwiseProject/Actor-Mixer Hierarchy/SFX.wwu @@ -2307,7 +2307,7 @@ - + @@ -2373,7 +2373,7 @@ - + @@ -2440,7 +2440,7 @@ - + @@ -2503,7 +2503,7 @@ - + diff --git a/Aetheria-Economy_WwiseProject/Aetheria-Economy_WwiseProject.rwvens.wsettings b/Aetheria-Economy_WwiseProject/Aetheria-Economy_WwiseProject.rwvens.wsettings index 785b02ffb..28ab95b4f 100644 --- a/Aetheria-Economy_WwiseProject/Aetheria-Economy_WwiseProject.rwvens.wsettings +++ b/Aetheria-Economy_WwiseProject/Aetheria-Economy_WwiseProject.rwvens.wsettings @@ -117,7 +117,7 @@ - + @@ -150,18 +150,18 @@ - + - - + + - + - + @@ -173,16 +173,16 @@ - - + + - + - + - + @@ -191,12 +191,12 @@ - + - + - - + + diff --git a/Aetheria-Economy_WwiseProject/Events/SFX.wwu b/Aetheria-Economy_WwiseProject/Events/SFX.wwu index 73d9d1117..dec5d4684 100644 --- a/Aetheria-Economy_WwiseProject/Events/SFX.wwu +++ b/Aetheria-Economy_WwiseProject/Events/SFX.wwu @@ -12,7 +12,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -34,7 +34,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -380,7 +380,7 @@ - + @@ -424,7 +424,7 @@ - + @@ -460,7 +460,7 @@ - + @@ -504,7 +504,7 @@ - + diff --git a/Aetheria-Economy_WwiseProject/Soundcaster Sessions/Default Work Unit.wwu b/Aetheria-Economy_WwiseProject/Soundcaster Sessions/Default Work Unit.wwu index 957ed9e4e..89fa86210 100644 --- a/Aetheria-Economy_WwiseProject/Soundcaster Sessions/Default Work Unit.wwu +++ b/Aetheria-Economy_WwiseProject/Soundcaster Sessions/Default Work Unit.wwu @@ -74,7 +74,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -118,7 +118,7 @@ - + diff --git a/Assets/Materials/Brushes/Fog Tint.mat b/Assets/Materials/Brushes/Fog Tint.mat index bcf7c4eac..204c63e22 100644 --- a/Assets/Materials/Brushes/Fog Tint.mat +++ b/Assets/Materials/Brushes/Fog Tint.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 1.3 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Gravity Well.mat b/Assets/Materials/Brushes/Gravity Well.mat index 66a272bf7..da9b656a8 100644 --- a/Assets/Materials/Brushes/Gravity Well.mat +++ b/Assets/Materials/Brushes/Gravity Well.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 40 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Influence Brush 1.mat b/Assets/Materials/Brushes/Influence Brush 1.mat index ce1762094..aff44ada9 100644 --- a/Assets/Materials/Brushes/Influence Brush 1.mat +++ b/Assets/Materials/Brushes/Influence Brush 1.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: -10 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Influence Brush.mat b/Assets/Materials/Brushes/Influence Brush.mat index c4e86e7fe..573e61252 100644 --- a/Assets/Materials/Brushes/Influence Brush.mat +++ b/Assets/Materials/Brushes/Influence Brush.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 10 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Main Menu Ambient Fog Tint.mat b/Assets/Materials/Brushes/Main Menu Ambient Fog Tint.mat index 7948f0645..2b6e8b260 100644 --- a/Assets/Materials/Brushes/Main Menu Ambient Fog Tint.mat +++ b/Assets/Materials/Brushes/Main Menu Ambient Fog Tint.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 1 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat b/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat index 46b5ee610..903a75e74 100644 --- a/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat +++ b/Assets/Materials/Brushes/Main Menu Sun Fog Tint.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 2.9 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Ping Light.mat b/Assets/Materials/Brushes/Ping Light.mat index 1af032486..d5f8aa607 100644 --- a/Assets/Materials/Brushes/Ping Light.mat +++ b/Assets/Materials/Brushes/Ping Light.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 0.1 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Sector Boundary Fog.mat b/Assets/Materials/Brushes/Sector Boundary Fog.mat index f8be5f166..2088ddc0f 100644 --- a/Assets/Materials/Brushes/Sector Boundary Fog.mat +++ b/Assets/Materials/Brushes/Sector Boundary Fog.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 139.4 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Sector Boundary Test.mat b/Assets/Materials/Brushes/Sector Boundary Test.mat index 90caa3e28..de94f9aab 100644 --- a/Assets/Materials/Brushes/Sector Boundary Test.mat +++ b/Assets/Materials/Brushes/Sector Boundary Test.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 150 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Sector Boundary.mat b/Assets/Materials/Brushes/Sector Boundary.mat index c6ed34c87..8f60ef5ba 100644 --- a/Assets/Materials/Brushes/Sector Boundary.mat +++ b/Assets/Materials/Brushes/Sector Boundary.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 50 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Sector Tint Test.mat b/Assets/Materials/Brushes/Sector Tint Test.mat index e4543bf69..8938d1a9b 100644 --- a/Assets/Materials/Brushes/Sector Tint Test.mat +++ b/Assets/Materials/Brushes/Sector Tint Test.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 0.4 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Sector Tint.mat b/Assets/Materials/Brushes/Sector Tint.mat index fe64aad7d..9205b2cc1 100644 --- a/Assets/Materials/Brushes/Sector Tint.mat +++ b/Assets/Materials/Brushes/Sector Tint.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 0.25 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Wormhole Gravity 1.mat b/Assets/Materials/Brushes/Wormhole Gravity 1.mat index da07be3e0..3ae24d6ee 100644 --- a/Assets/Materials/Brushes/Wormhole Gravity 1.mat +++ b/Assets/Materials/Brushes/Wormhole Gravity 1.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 54 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Wormhole Gravity.mat b/Assets/Materials/Brushes/Wormhole Gravity.mat index 9e2773c0f..cab097589 100644 --- a/Assets/Materials/Brushes/Wormhole Gravity.mat +++ b/Assets/Materials/Brushes/Wormhole Gravity.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 0.1 - _Depth: 2000 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/Brushes/Wormhole Lighting.mat b/Assets/Materials/Brushes/Wormhole Lighting.mat index 85e5599e6..dc9cf7c8b 100644 --- a/Assets/Materials/Brushes/Wormhole Lighting.mat +++ b/Assets/Materials/Brushes/Wormhole Lighting.mat @@ -57,7 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 - - _Cutoff: 0.5 + - _Cutoff: 1 - _Depth: 10 - _DetailNormalMapScale: 1 - _DstBlend: 0 diff --git a/Assets/Materials/UI/Map Gravity Lines.mat b/Assets/Materials/UI/Map Gravity Lines.mat index 749d876be..4bade6d12 100644 --- a/Assets/Materials/UI/Map Gravity Lines.mat +++ b/Assets/Materials/UI/Map Gravity Lines.mat @@ -86,7 +86,7 @@ Material: - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 - - _Scale: 0.5 + - _Scale: 6.0524 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 diff --git a/Assets/Resources/Settings.asset b/Assets/Resources/Settings.asset index 2f2c337aa..bc9b44143 100644 --- a/Assets/Resources/Settings.asset +++ b/Assets/Resources/Settings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ca555be1e87cac142652f528372ac38243ecc0266fd94879a3b9b1a5a0b9644 -size 12324 +oid sha256:41c7a78f6c59f08f593c74cd79d96dbb2f04a6986b273929181ed70e09739609 +size 12474 diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity index 44430c99b..0c41c9d2e 100644 --- a/Assets/Scenes/ARPG.unity +++ b/Assets/Scenes/ARPG.unity @@ -4226,6 +4226,93 @@ Camera: m_OcclusionCulling: 0 m_StereoConvergence: 10 m_StereoSeparation: 0.022 +--- !u!1 &332734005 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 332734006} + - component: {fileID: 332734009} + - component: {fileID: 332734008} + - component: {fileID: 332734007} + m_Layer: 5 + m_Name: Visible Friendly + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &332734006 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 332734005} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 965868420} + - {fileID: 1541341821} + m_Father: {fileID: 346000247} + m_RootOrder: 13 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 74.8} + m_SizeDelta: {x: 16, y: 16} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &332734007 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 332734005} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 79e1b49bde6c1c54aa6b5c2256e0e382, type: 3} + m_Name: + m_EditorClassIdentifier: + NoiseAmplitude: 0 + NoiseFrequency: 0 + Canvas: {fileID: 761574180} + BorderPixels: 10 + PointAtTarget: 1 + ScreenSpaceOffset: {x: 0, y: 25} + EdgeMargin: 0.001 + Target: {x: 0, y: 0, z: 0} +--- !u!114 &332734008 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 332734005} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e39172b086df1a44c8da6b3962a5ecd3, type: 3} + m_Name: + m_EditorClassIdentifier: + Transform: {fileID: 332734006} + Fill: {fileID: 965868421} + Place: {fileID: 332734007} +--- !u!114 &332734009 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 332734005} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1281fe44325f9b548aa42dc331b17266, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &342600466 PrefabInstance: m_ObjectHideFlags: 0 @@ -4439,6 +4526,7 @@ RectTransform: - {fileID: 1631662978} - {fileID: 146394775} - {fileID: 1787772780} + - {fileID: 332734006} m_Father: {fileID: 761574181} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -8803,7 +8891,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Color: {r: 1, g: 0.625, b: 0.5, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 @@ -14721,6 +14809,81 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &965868419 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 965868420} + - component: {fileID: 965868422} + - component: {fileID: 965868421} + m_Layer: 5 + m_Name: Fill + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &965868420 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 965868419} + 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: 332734006} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &965868421 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 965868419} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.5, g: 0.75, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 9e87ff4a45e1fff4e8f210c3c26551a0, type: 3} + m_Type: 3 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 1 + m_FillAmount: 0.582 + m_FillClockwise: 1 + m_FillOrigin: 1 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &965868422 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 965868419} + m_CullTransparentMesh: 1 --- !u!1 &970624069 GameObject: m_ObjectHideFlags: 0 @@ -15552,6 +15715,7 @@ MonoBehaviour: GameplayUI: {fileID: 346000248} EventLog: {fileID: 1396909588} HostileTargetIndicator: {fileID: 1787772783} + FriendlyTargetIndicator: {fileID: 332734009} ViewDot: {fileID: 146394778} LockIndicator: {fileID: 1876420642} Crosshairs: @@ -23026,6 +23190,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1539162433} m_CullTransparentMesh: 1 +--- !u!1 &1541341820 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1541341821} + - component: {fileID: 1541341823} + - component: {fileID: 1541341822} + m_Layer: 5 + m_Name: Stroke + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1541341821 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1541341820} + 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: 332734006} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1541341822 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1541341820} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0.5, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 9fa59801aac390542a1aab396485ab57, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1541341823 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1541341820} + m_CullTransparentMesh: 1 --- !u!1 &1542388327 GameObject: m_ObjectHideFlags: 0 @@ -30349,7 +30588,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2115559087} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: b642ff60407fe724bafa6602199213c0, type: 3} m_Name: @@ -30367,15 +30606,15 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2115559087} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 899f97884c6d96b4ca20648ec109a37f, type: 3} m_Name: m_EditorClassIdentifier: pattern: 9 patternScale: 1 - activeSample: {x: -0.0309703, y: -0.24158497, z: -0.1195988, w: -0.14001325} - activeIndex: 9 + activeSample: {x: 0, y: 0, z: 0, w: 0} + activeIndex: -2 --- !u!114 &2115559098 MonoBehaviour: m_ObjectHideFlags: 0 @@ -30383,7 +30622,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2115559087} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 65f5677aa325c184f801528d78a73827, type: 3} m_Name: diff --git a/Assets/Scenes/Main Menu.unity b/Assets/Scenes/Main Menu.unity index 6f8ac78b5..be67a23de 100644 --- a/Assets/Scenes/Main Menu.unity +++ b/Assets/Scenes/Main Menu.unity @@ -802,8 +802,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 741153267} - m_LocalRotation: {x: 0.015506897, y: 0.9502416, z: -0.30741316, w: 0.047933206} - m_LocalPosition: {x: -117.52, y: -77.08742, z: 149.09026} + m_LocalRotation: {x: 0.015506903, y: 0.9502416, z: -0.30741313, w: 0.04793323} + m_LocalPosition: {x: -117.51999, y: -77.08743, z: 149.09026} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 412917866} @@ -1304,8 +1304,8 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 965376321} - m_LocalRotation: {x: 0.015506897, y: 0.9502416, z: -0.30741316, w: 0.047933206} - m_LocalPosition: {x: -117.52, y: -77.08742, z: 149.09026} + m_LocalRotation: {x: 0.015506903, y: 0.9502416, z: -0.30741313, w: 0.04793323} + m_LocalPosition: {x: -117.51999, y: -77.08743, z: 149.09026} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -1369,7 +1369,9 @@ MonoBehaviour: m_ShowCustomSorter: 0 breakBeforeColorGrading: 0 m_BeforeTransparentBundles: [] - m_BeforeStackBundles: [] + m_BeforeStackBundles: + - assemblyQualifiedName: UnityEngine.Rendering.PostProcessing.DepthOfField, Assembly-CSharp, + Version=0.0.0.0, Culture=neutral, PublicKeyToken=null m_AfterStackBundles: [] --- !u!114 &965376326 MonoBehaviour: @@ -1453,8 +1455,8 @@ MonoBehaviour: m_EditorClassIdentifier: pattern: 12 patternScale: 1 - activeSample: {x: -0.25, y: 0.16666669, z: 0, w: -0.16666666} - activeIndex: 1 + activeSample: {x: -0.375, y: -0.055555552, z: 0.25, w: -0.3888889} + activeIndex: 3 --- !u!114 &965376331 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2451,7 +2453,7 @@ PrefabInstance: - target: {fileID: 3664209305474245377, guid: 3d8d9cbf10b12214e98891c1f03c1e99, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: 60.98 objectReference: {fileID: 0} - target: {fileID: 3664209305474245377, guid: 3d8d9cbf10b12214e98891c1f03c1e99, type: 3} @@ -2476,7 +2478,7 @@ PrefabInstance: - target: {fileID: 3664209306888449100, guid: 3d8d9cbf10b12214e98891c1f03c1e99, type: 3} propertyPath: m_AnchoredPosition.x - value: 0 + value: 55.675 objectReference: {fileID: 0} - target: {fileID: 3664209306888449100, guid: 3d8d9cbf10b12214e98891c1f03c1e99, type: 3} diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index aa2dd06ba..a47d065e6 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -170,6 +170,7 @@ public class ActionGameManager : MonoBehaviour public CanvasGroup GameplayUI; public EventLog EventLog; public Prototype HostileTargetIndicator; + public Prototype FriendlyTargetIndicator; public PlaceUIElementWorldspace ViewDot; public Prototype LockIndicator; public PlaceUIElementWorldspace[] Crosshairs; @@ -209,7 +210,8 @@ public class ActionGameManager : MonoBehaviour private float3 _viewDirection; private (HardpointData[] hardpoints, Transform[] barrels, PlaceUIElementWorldspace crosshair)[] _articulationGroups; private (LockWeapon targetLock, PlaceUIElementWorldspace indicator, Rotate spin)[] _lockingIndicators; - private Dictionary _visibleHostileIndicators = new Dictionary(); + private Dictionary _visibleHostileIndicators = new Dictionary(); + private Dictionary _visibleFriendlyIndicators = new Dictionary(); private List _shipSubscriptions = new List(); private List _targetSubscriptions = new List(); private float _severeHeatstrokePhase; @@ -362,6 +364,7 @@ public class ActionGameManager : MonoBehaviour { _uiHidden = !_uiHidden; GameplayUI.alpha = _uiHidden ? 0 : 1; + ActionBar.gameObject.SetActive(!_uiHidden); }; Input.Player.OverrideShutdown.performed += context => @@ -393,33 +396,33 @@ public class ActionGameManager : MonoBehaviour Input.Player.TargetReticle.performed += context => { - if (!CurrentEntity.VisibleHostiles.Any()) return; - var underReticle = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity) + if (!CurrentEntity.VisibleEnemies.Any()) return; + var underReticle = CurrentEntity.VisibleEnemies.Where(x => x != CurrentEntity) .MaxBy(x => dot(normalize(x.Position - CurrentEntity.Position), CurrentEntity.LookDirection)); CurrentEntity.Target.Value = CurrentEntity.Target.Value == underReticle ? null : underReticle; }; Input.Player.TargetNearest.performed += context => { - if(CurrentEntity.VisibleHostiles.Any()) + if(CurrentEntity.VisibleEnemies.Any()) { - CurrentEntity.Target.Value = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity) + CurrentEntity.Target.Value = CurrentEntity.VisibleEnemies.Where(x => x != CurrentEntity) .MaxBy(x => length(x.Position - CurrentEntity.Position)); } }; Input.Player.TargetNext.performed += context => { - if (!CurrentEntity.VisibleHostiles.Any()) return; - var targets = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray(); + if (!CurrentEntity.VisibleEnemies.Any()) return; + var targets = CurrentEntity.VisibleEnemies.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray(); var currentTargetIndex = Array.IndexOf(targets, CurrentEntity.Target.Value); CurrentEntity.Target.Value = targets[(currentTargetIndex + 1) % targets.Length]; }; Input.Player.TargetPrevious.performed += context => { - if (!CurrentEntity.VisibleHostiles.Any()) return; - var targets = CurrentEntity.VisibleHostiles.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray(); + if (!CurrentEntity.VisibleEnemies.Any()) return; + var targets = CurrentEntity.VisibleEnemies.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray(); var currentTargetIndex = Array.IndexOf(targets, CurrentEntity.Target.Value); CurrentEntity.Target.Value = targets[(currentTargetIndex + targets.Length - 1) % targets.Length]; }; @@ -676,7 +679,7 @@ public class ActionGameManager : MonoBehaviour sectorZone, IsTutorial ); - sectorZone.Contents = new Zone(ItemManager, Settings.PlanetSettings, sectorZone.PackedContents, sectorZone); + sectorZone.Contents = new Zone(ItemManager, Settings.PlanetSettings, sectorZone.PackedContents, sectorZone, CurrentSector); } Zone = sectorZone.Contents; PlayMusic(MusicType.Overworld); @@ -916,12 +919,12 @@ public class ActionGameManager : MonoBehaviour private void UnbindEntity() { - foreach (var indicator in _visibleHostileIndicators) - { - Destroy(indicator.Value.gameObject); - } - + foreach (var indicator in _visibleHostileIndicators) Destroy(indicator.Value.gameObject); _visibleHostileIndicators.Clear(); + + foreach (var indicator in _visibleFriendlyIndicators) Destroy(indicator.Value.gameObject); + _visibleFriendlyIndicators.Clear(); + if(_lockingIndicators!=null) foreach(var (_, indicator, _) in _lockingIndicators) indicator.GetComponent().ReturnToPool(); DisablePlayerInput(); @@ -1016,23 +1019,41 @@ public class ActionGameManager : MonoBehaviour } })); - foreach (var hostile in CurrentEntity.VisibleHostiles) + foreach (var hostile in CurrentEntity.VisibleEnemies) { - var indicator = HostileTargetIndicator.Instantiate(); + var indicator = HostileTargetIndicator.Instantiate(); _visibleHostileIndicators.Add(hostile, indicator); } - _shipSubscriptions.Add(CurrentEntity.VisibleHostiles.ObserveAdd().Subscribe(addEvent => + _shipSubscriptions.Add(CurrentEntity.VisibleEnemies.ObserveAdd().Subscribe(addEvent => { - var indicator = HostileTargetIndicator.Instantiate(); + var indicator = HostileTargetIndicator.Instantiate(); _visibleHostileIndicators.Add(addEvent.Value, indicator); })); - _shipSubscriptions.Add(CurrentEntity.VisibleHostiles.ObserveRemove().Subscribe(removeEvent => + _shipSubscriptions.Add(CurrentEntity.VisibleEnemies.ObserveRemove().Subscribe(removeEvent => { _visibleHostileIndicators[removeEvent.Value].GetComponent().ReturnToPool(); _visibleHostileIndicators.Remove(removeEvent.Value); })); + + foreach (var friendly in CurrentEntity.VisibleFriendlies) + { + var indicator = FriendlyTargetIndicator.Instantiate(); + _visibleFriendlyIndicators.Add(friendly, indicator); + } + + _shipSubscriptions.Add(CurrentEntity.VisibleFriendlies.ObserveAdd().Subscribe(addEvent => + { + var indicator = FriendlyTargetIndicator.Instantiate(); + _visibleFriendlyIndicators.Add(addEvent.Value, indicator); + })); + + _shipSubscriptions.Add(CurrentEntity.VisibleFriendlies.ObserveRemove().Subscribe(removeEvent => + { + _visibleFriendlyIndicators[removeEvent.Value].GetComponent().ReturnToPool(); + _visibleFriendlyIndicators.Remove(removeEvent.Value); + })); _shipSubscriptions.Add(CurrentEntity.Death.Subscribe(Die)); @@ -1175,6 +1196,19 @@ public class ActionGameManager : MonoBehaviour sin(TargetSpottedBlinkFrequency * Time.time) + TargetSpottedBlinkOffset > 0; } } + foreach (var indicator in _visibleFriendlyIndicators) + { + indicator.Value.gameObject.SetActive(indicator.Key!=CurrentEntity.Target.Value); + indicator.Value.Place.Target = indicator.Key.Position; + if (!indicator.Key.Active) + indicator.Value.Fill.enabled = false; + else + { + indicator.Value.Fill.enabled = true; + indicator.Value.Fill.fillAmount = + saturate(indicator.Key.EntityInfoGathered[CurrentEntity] / Settings.GameplaySettings.TargetDetectionInfoThreshold); + } + } var look = Input.Player.Look.ReadValue(); _entityYawPitch = float2(_entityYawPitch.x + look.x * Sensitivity.x, clamp(_entityYawPitch.y + look.y * Sensitivity.y, -.45f * PI, .45f * PI)); _viewDirection = mul(float3(0, 0, 1), Unity.Mathematics.float3x3.Euler(float3(_entityYawPitch.yx, 0), RotationOrder.YXZ)); diff --git a/Assets/Scripts/Gameplay/EntityInstance.cs b/Assets/Scripts/Gameplay/EntityInstance.cs index 476453d8e..d3cfb0dd9 100644 --- a/Assets/Scripts/Gameplay/EntityInstance.cs +++ b/Assets/Scripts/Gameplay/EntityInstance.cs @@ -446,8 +446,7 @@ public class EntityInstance : MonoBehaviour } })); - // TODO: ActionGameManager.CurrentSector.FactionRelationships[orbital.Faction] - if (entity is OrbitalEntity orbital && orbital.SecurityRadius > 1)// && (int) orbital.SecurityLevel > (int) SecurityLevel.Secure) + if (entity is OrbitalEntity orbital && orbital.IsSecureArea) { _influenceInstance = Instantiate(InfluencePrefab); _influenceInstance.transform.localScale = Vector3.one * orbital.SecurityRadius; diff --git a/Assets/Scripts/ServerShared/Agents/Minion.cs b/Assets/Scripts/ServerShared/Agents/Minion.cs index 3237b3f0a..28145c504 100644 --- a/Assets/Scripts/ServerShared/Agents/Minion.cs +++ b/Assets/Scripts/ServerShared/Agents/Minion.cs @@ -11,7 +11,7 @@ public class Minion : Agent () => Task is PatrolOrbitsTask, () => patrolState.Task = Task as PatrolOrbitsTask); - Ship.VisibleHostiles.ObserveAdd().Where(_ => Ship.Target.Value == null).Subscribe(add => Ship.Target.Value = add.Value); + Ship.VisibleEnemies.ObserveAdd().Where(_ => Ship.Target.Value == null).Subscribe(add => Ship.Target.Value = add.Value); var combatState = new CombatState(this); _rootState.AddTransition(combatState, diff --git a/Assets/Scripts/ServerShared/Behaviors/TurretController.cs b/Assets/Scripts/ServerShared/Behaviors/TurretController.cs index a1d7f6ea6..f2d99e948 100644 --- a/Assets/Scripts/ServerShared/Behaviors/TurretController.cs +++ b/Assets/Scripts/ServerShared/Behaviors/TurretController.cs @@ -96,7 +96,7 @@ public class TurretController : Behavior, IInitializableBehavior if (x.Firing) x.Deactivate(); } - Entity.Target.Value = Entity.VisibleHostiles.FirstOrDefault(e => e is Ship); + Entity.Target.Value = Entity.VisibleEnemies.FirstOrDefault(e => e is Ship); } return true; } diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs index 922b0109a..f84262a62 100644 --- a/Assets/Scripts/ServerShared/Corporations.cs +++ b/Assets/Scripts/ServerShared/Corporations.cs @@ -27,8 +27,8 @@ public class Faction : DatabaseEntry, INamedEntry [InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(5)] public Dictionary Personality = new Dictionary(); - [Inspectable, JsonProperty("hostile"), Key(6)] - public bool PlayerHostile; + // [Inspectable, JsonProperty("hostile"), Key(6)] + // public bool PlayerHostile; [InspectableColor, JsonProperty("primaryColor"), Key(7)] public float3 PrimaryColor; diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index 1a4b6d274..3fa84e004 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -30,7 +30,9 @@ public abstract class Entity public readonly ReactiveCollection CargoBays = new ReactiveCollection(); public readonly ReactiveCollection DockingBays = new ReactiveCollection(); public readonly ReactiveCollection VisibleEntities = new ReactiveCollection(); - public readonly ReactiveCollection VisibleHostiles = new ReactiveCollection(); + public readonly ReactiveDictionary EntityHostility = new ReactiveDictionary(); + public readonly ReactiveCollection VisibleEnemies = new ReactiveCollection(); + public readonly ReactiveCollection VisibleFriendlies = new ReactiveCollection(); public Entity Parent; public List Children = new List(); @@ -127,6 +129,8 @@ public abstract class Entity public Subject HypothermiaDeath = new Subject(); public Subject TargetedBy = new Subject(); public ReactiveProperty TargetedByCount = new ReactiveProperty(0); + public ReactiveProperty CurrentSecurityLevel = new ReactiveProperty(SecurityLevel.Open); + public ReadOnlyReactiveProperty PresencePermitted; public UniRx.IObservable ItemDestroyed; public UniRx.IObservable HullArmorDepleted; @@ -135,6 +139,7 @@ public abstract class Entity public UniRx.IObservable Death; private List _subscriptions = new List(); + private Dictionary> _watchedEntitySubscriptions = new Dictionary>(); public virtual void Activate() { @@ -147,19 +152,84 @@ public abstract class Entity if(behavior is IInitializableBehavior initializableBehavior) initializableBehavior.Initialize(); } - foreach(var entity in Zone.Entities) EntityInfoGathered[entity] = 0; - _subscriptions.Add(Zone.Entities.ObserveAdd().Subscribe(add => EntityInfoGathered[add.Value] = 0)); + foreach(var entity in Zone.Entities) + { + EntityInfoGathered[entity] = 0; + EntityHostility[entity] = IsHostileTo(entity); + } + _subscriptions.Add(Zone.Entities.ObserveAdd().Subscribe(add => + { + EntityInfoGathered[add.Value] = 0; + EntityHostility[add.Value] = IsHostileTo(add.Value); + })); _subscriptions.Add(Zone.Entities.ObserveRemove().Subscribe(remove => { if (Target.Value == remove.Value) Target.Value = null; EntityInfoGathered.Remove(remove.Value); + EntityHostility.Remove(remove.Value); VisibleEntities.Remove(remove.Value); - VisibleHostiles.Remove(remove.Value); + VisibleEnemies.Remove(remove.Value); + VisibleFriendlies.Remove(remove.Value); })); - _subscriptions.Add(VisibleEntities.ObserveRemove().Subscribe(remove => + _subscriptions.Add(VisibleEnemies.ObserveRemove().Subscribe(remove => { if (Target.Value == remove.Value) Target.Value = null; })); + _subscriptions.Add(Target.Subscribe(entity => entity?.TargetedBy.OnNext(this))); + _subscriptions.Add(TargetedBy.Subscribe(enemy => + { + TargetedByCount.Value++; + enemy.Target.Where(t => t != this).Take(1).Subscribe(_ => TargetedByCount.Value--); + })); + + // + _subscriptions.Add(EntityInfoGathered.ObserveReplace().Subscribe(replace => + { + if (replace.OldValue < ItemManager.GameplaySettings.TargetDetectionInfoThreshold && + replace.NewValue > ItemManager.GameplaySettings.TargetDetectionInfoThreshold) + { + VisibleEntities.Add(replace.Key); + if(EntityHostility[replace.Key]) + VisibleEnemies.Add(replace.Key); + else VisibleFriendlies.Add(replace.Key); + } + if (replace.OldValue > ItemManager.GameplaySettings.TargetDetectionInfoThreshold && + replace.NewValue < ItemManager.GameplaySettings.TargetDetectionInfoThreshold) + { + VisibleEntities.Remove(replace.Key); + VisibleEnemies.Remove(replace.Key); + VisibleFriendlies.Remove(replace.Key); + } + })); + + // Create subscriptions to events occurring on any visible entity + _subscriptions.Add(VisibleEntities.ObserveAdd() + .Select(add=>add.Value) + .Subscribe(entity => + { + var newVisibleEntitySubscriptions = new List + { + // Respond to changes in the target's hostility status by updating the contents of VisibleEnemies and VisibleFriendlies + EntityHostility.ObserveReplace() + .Where(replace => replace.Key == entity) + .Select(replace => replace.NewValue) + .Subscribe(isHostile => + { + (isHostile ? VisibleEnemies : VisibleFriendlies).Add(entity); + (isHostile ? VisibleFriendlies : VisibleEnemies).Remove(entity); + }) + }; + + _watchedEntitySubscriptions[entity] = newVisibleEntitySubscriptions; + })); + + // Cleanup visible entity subscriptions + _subscriptions.Add(VisibleEntities.ObserveRemove().Subscribe(disappearingEntity => + { + foreach(var subscription in _watchedEntitySubscriptions[disappearingEntity.Value]) subscription.Dispose(); + _watchedEntitySubscriptions.Remove(disappearingEntity.Value); + })); + if(WeaponGroups.All(wg=>!wg.items.Any())) GenerateWeaponGroups(); } @@ -169,10 +239,13 @@ public abstract class Entity //ItemManager.Log($"Entity {Name} is deactivating!"); foreach(var s in _subscriptions) s.Dispose(); _subscriptions.Clear(); + foreach(var ss in _watchedEntitySubscriptions.Values) foreach(var s in ss) s.Dispose(); + _watchedEntitySubscriptions.Clear(); _active = false; EntityInfoGathered.Clear(); VisibleEntities.Clear(); - VisibleHostiles.Clear(); + VisibleEnemies.Clear(); + VisibleFriendlies.Clear(); } public Entity(ItemManager itemManager, Zone zone, EquippableItem hull, EntitySettings settings) @@ -196,33 +269,30 @@ public abstract class Entity .Merge(HypothermiaDeath.Select(_ => CauseOfDeath.Hypothermia)) .Merge(ItemDestroyed.Where(i=>i.GetBehavior()!=null).Select(_ => CauseOfDeath.CockpitDestroyed)); - Target.Subscribe(entity => entity?.TargetedBy.OnNext(this)); - TargetedBy.Subscribe(enemy => - { - TargetedByCount.Value++; - enemy.Target.Where(t => t != this).Take(1).Subscribe(_ => TargetedByCount.Value--); - }); - - EntityInfoGathered.ObserveReplace().Subscribe(replace => - { - if (replace.OldValue < ItemManager.GameplaySettings.TargetDetectionInfoThreshold && - replace.NewValue > ItemManager.GameplaySettings.TargetDetectionInfoThreshold) - { - VisibleEntities.Add(replace.Key); - if(IsHostileTo(replace.Key)) - VisibleHostiles.Add(replace.Key); - } - if (replace.OldValue > ItemManager.GameplaySettings.TargetDetectionInfoThreshold && - replace.NewValue < ItemManager.GameplaySettings.TargetDetectionInfoThreshold) - { - VisibleEntities.Remove(replace.Key); - if(IsHostileTo(replace.Key)) - VisibleHostiles.Remove(replace.Key); - } - }); - EntityInfoGathered.ObserveRemove().Subscribe(remove => VisibleEntities.Remove(remove.Key)); + // The entity's presence is permitted when its faction owns the zone, or the current security level at its location is low enough + PresencePermitted = new ReadOnlyReactiveProperty(CurrentSecurityLevel.Select(security => + IsPresencePermitted(GetFactionRelationship(Zone.SectorZone.Owner), security)), true); } + public bool IsHostileTo(Entity other, bool recursive = false) + { + if (Faction == null) + return !recursive && other.Faction != null && other.IsHostileTo(this, true); + + // TODO: Inter-faction hostility + // When the entity faction owns the zone, they are hostile to trespassers or those hostile to them + if (Faction.ID == Zone.SectorZone.Owner.ID) + return recursive ? !other.PresencePermitted.Value : !other.PresencePermitted.Value || other.IsHostileTo(this, true); + + return !recursive && other.IsHostileTo(this, true); + } + + // TODO: Inter-faction relationships + public FactionRelationship GetFactionRelationship(Faction faction) => + this is Ship {IsPlayerShip: true} ? Zone.Sector.FactionRelationships[faction] : faction==Faction ? FactionRelationship.Beloved : FactionRelationship.Neutral; + + public static bool IsPresencePermitted(FactionRelationship relationship, SecurityLevel securityLevel) => (int) relationship - (int) securityLevel > 0; + public void ActivateConsumable(ConsumableItem item) { _activeConsumables.Add(new ConsumableItemEffect(item, this)); @@ -251,16 +321,6 @@ public abstract class Entity return true; } - public bool IsHostileTo(Entity other) - { - if (Faction == null) - { - return other.Faction != null; - } - - return Faction.PlayerHostile && other.Faction == null; - } - private void MapEntity() { var hullData = ItemManager.GetData(Hull) as HullData; @@ -809,6 +869,17 @@ public abstract class Entity TargetRange = Target.Value == null ? -1 : length(Position - Target.Value.Position); + var localSecurityLevel = Zone.GetSecurityLevel(Position.xz); + if (CurrentSecurityLevel.Value != localSecurityLevel) CurrentSecurityLevel.Value = localSecurityLevel; + + foreach (var entity in Zone.Entities) + { + var previousHostility = EntityHostility[entity]; + var newHostility = IsHostileTo(entity); + if (newHostility != previousHostility) + EntityHostility[entity] = newHostility; + } + foreach (var v in VisibilitySources.Keys.ToArray()) { VisibilitySources[v] = AetheriaMath.Decay(VisibilitySources[v], ItemManager.GameplaySettings.VisibilityDecay, delta); diff --git a/Assets/Scripts/ServerShared/OrbitalEntity.cs b/Assets/Scripts/ServerShared/OrbitalEntity.cs index 55b73747b..e4e107521 100644 --- a/Assets/Scripts/ServerShared/OrbitalEntity.cs +++ b/Assets/Scripts/ServerShared/OrbitalEntity.cs @@ -30,4 +30,14 @@ public class OrbitalEntity : Entity base.Update(delta); } + + public bool IsSecureArea + { + get + { + if (SecurityRadius < 1) return false; + if (Faction == null) return false; + return !IsPresencePermitted(Zone.Sector.FactionRelationships[Faction], SecurityLevel); + } + } } diff --git a/Assets/Scripts/ServerShared/Settings.cs b/Assets/Scripts/ServerShared/Settings.cs index 0d7c41f00..51846b55a 100644 --- a/Assets/Scripts/ServerShared/Settings.cs +++ b/Assets/Scripts/ServerShared/Settings.cs @@ -31,6 +31,7 @@ public class PlanetSettings public ExponentialLerp AsteroidRespawnTime; public float GravityStrength; public float MiningDifficulty = 500f; + public float SecureAreaRadiusMultiplier = .45f; public ExponentialCurve OrbitPeriod; } diff --git a/Assets/Scripts/ServerShared/Zone.cs b/Assets/Scripts/ServerShared/Zone.cs index 8dcf78310..6fb6149d2 100644 --- a/Assets/Scripts/ServerShared/Zone.cs +++ b/Assets/Scripts/ServerShared/Zone.cs @@ -42,11 +42,13 @@ public class Zone } public ZonePack Pack { get; } public SectorZone SectorZone { get; } + public Sector Sector { get; } - public Zone(ItemManager itemManager, PlanetSettings settings, ZonePack pack, SectorZone sectorZone) + public Zone(ItemManager itemManager, PlanetSettings settings, ZonePack pack, SectorZone sectorZone, Sector sector) { _time = pack.Time; SectorZone = sectorZone; + Sector = sector; Pack = pack; _itemManager = itemManager; Settings = settings; @@ -306,6 +308,24 @@ public class Zone //miner.AddCargo(newSimpleCommodity); } } + + public SecurityLevel GetSecurityLevel(float2 pos) + { + if (SectorZone.Owner==null) return SecurityLevel.Open; + + var security = SecurityLevel.Open; + foreach (var entity in Entities) + { + if (entity is OrbitalEntity orbitalEntity && orbitalEntity.SecurityRadius > 1 && entity.Faction.ID == SectorZone.Owner.ID) + { + if (orbitalEntity.SecurityLevel > security && length(orbitalEntity.Position.xz - pos) < orbitalEntity.SecurityRadius * Settings.SecureAreaRadiusMultiplier) + security = orbitalEntity.SecurityLevel; + } + } + + return security; + } + public float GetHeight(float2 position) { var result = -PowerPulse(length(position)/(Pack.Radius*2), Settings.ZoneDepthExponent) * Settings.ZoneDepth; diff --git a/Assets/Scripts/UI/HUD/VisibleHostileIndicator.cs b/Assets/Scripts/UI/HUD/VisibleTargetIndicator.cs similarity index 79% rename from Assets/Scripts/UI/HUD/VisibleHostileIndicator.cs rename to Assets/Scripts/UI/HUD/VisibleTargetIndicator.cs index 0b70fc62f..f12220bd7 100644 --- a/Assets/Scripts/UI/HUD/VisibleHostileIndicator.cs +++ b/Assets/Scripts/UI/HUD/VisibleTargetIndicator.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; -public class VisibleHostileIndicator : MonoBehaviour +public class VisibleTargetIndicator : MonoBehaviour { public RectTransform Transform; public Image Fill; diff --git a/Assets/Scripts/UI/HUD/VisibleHostileIndicator.cs.meta b/Assets/Scripts/UI/HUD/VisibleTargetIndicator.cs.meta similarity index 100% rename from Assets/Scripts/UI/HUD/VisibleHostileIndicator.cs.meta rename to Assets/Scripts/UI/HUD/VisibleTargetIndicator.cs.meta diff --git a/Assets/Shaders/Brushes/PowerBrush.shader b/Assets/Shaders/Brushes/PowerBrush.shader index d3b77c406..b332348d2 100644 --- a/Assets/Shaders/Brushes/PowerBrush.shader +++ b/Assets/Shaders/Brushes/PowerBrush.shader @@ -3,6 +3,7 @@ Properties { _Color ("Color", Color) = (1,1,1,1) _Depth ("Depth", Float) = 0.5 _Power("Power", Float) = 2 + _Cutoff("Cutoff", Range(0,1)) = 1 } Category { @@ -23,7 +24,8 @@ Category { fixed4 _Color; float _Depth; - float _Power; + half _Power; + half _Cutoff; struct appdata_t { float4 vertex : POSITION; @@ -57,7 +59,7 @@ Category { fixed4 frag (v2f i) : SV_Target { float dist = length(i.texcoord-float2(.5,.5))*2; - return _Depth * powerPulse(dist,_Power) * _Color * smoothstep(1, .95, dist); + return _Depth * min(_Cutoff, powerPulse(dist,_Power)) * _Color * smoothstep(1, .95, dist); } ENDCG } diff --git a/Assets/Shaders/Raymarching/VolumeRender.shader b/Assets/Shaders/Raymarching/VolumeRender.shader index 94d7eb3ff..afb5d9279 100644 --- a/Assets/Shaders/Raymarching/VolumeRender.shader +++ b/Assets/Shaders/Raymarching/VolumeRender.shader @@ -117,8 +117,8 @@ float surface = tex2Dlod(_Surface, half4(uv, 0, 0)).r; float dist = pos.y + surface - _GridFloorOffset; - float4 lightTint = tex2Dlod(_TintTexture, half4(uv, 0, dist/30)); - float fillDensity = saturate(-pos.y * _GridFillDensity); + float4 lightTint = tex2Dlod(_TintTexture, half4(uv, 0, dist/30)); + float fillDensity = saturate(-pos.y * _GridFillDensity); if(dist < _SafetyDistance) { diff --git a/Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset b/Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset index d3e57dd1b..546ec2f7e 100644 --- a/Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset +++ b/Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10b67e9fe29b5aa5e115e94aaa8432ab0c0fef000921f0994a67f74d40294d6c -size 103270 +oid sha256:8c579166ee2d3c18c15c542739c5f04c99b26acdb781192148428c634a50ec66 +size 103268 diff --git a/GameData/PlayerSettings.msgpack b/GameData/PlayerSettings.msgpack index e87010969..997fdc518 100644 --- a/GameData/PlayerSettings.msgpack +++ b/GameData/PlayerSettings.msgpack @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90e56ae5b032511e891cbaf86ead615a31dbc99179735aa3d0ec8f9344309f6c -size 41594 +oid sha256:0607b30584b6fc67563578054807082394a514b6449605ecca0f4e2fdff4b7e0 +size 51739 diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 3667a1fed..f33a7228f 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63d7e3c207f6ed08111116cc595cc4f6251b3aed41505b7e903bcb68103803c2 +oid sha256:447234e8c4d8ad0cbbdc75de56e2d314a113b5969f4fe0e37f1012457f829739 size 1687