diff --git a/.gitignore b/.gitignore index 51f6bbb5..fc6d2d39 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,4 @@ InitCodeMarker .idea/**/usage.statistics.xml .idea/**/dictionaries .idea/**/shelf +/Packages/PolkaDOTS/Prefabs/Player/MultiplayPlayer.prefab diff --git a/.gitmodules b/.gitmodules index 46436327..e2eff340 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ [submodule "UnityRenderStreaming"] path = UnityRenderStreaming - url = git@github.com:JerritEic/UnityRenderStreaming.git + url = https://github.com/JerritEic/UnityRenderStreaming.git [submodule "Packages/com.unity.performance.profile-analyzer"] path = Packages/com.unity.performance.profile-analyzer - url = git@github.com:JerritEic/com.unity.performance.profile-analyzer.git + url = https://github.com/JerritEic/com.unity.performance.profile-analyzer.git [submodule "Packages/com.utj.profilerreader"] path = Packages/com.utj.profilerreader - url = git@github.com:JerritEic/ProfilerReader.git + url = https://github.com/JerritEic/ProfilerReader.git [submodule "Packages/PolkaDOTS"] path = Packages/PolkaDOTS - url = git@github.com:atlarge-research/PolkaDOTS.git + url = https://github.com/ZainMunir/PolkaDOTS.git diff --git a/Assets/Config/TerrainLayers/AbsoluteDirtLayer.asset b/Assets/Config/TerrainLayers/AbsoluteDirtLayer.asset index fa713882..489705cc 100644 --- a/Assets/Config/TerrainLayers/AbsoluteDirtLayer.asset +++ b/Assets/Config/TerrainLayers/AbsoluteDirtLayer.asset @@ -15,7 +15,7 @@ MonoBehaviour: layerType: 0 layerName: Dirt base layer index: 300 - blockType: 2 + blockType: 9 frequency: 50 exponent: 1 minHeight: 20 diff --git a/Assets/Config/TerrainLayers/AbsoluteFlatDirtLayer 1.asset b/Assets/Config/TerrainLayers/AbsoluteFlatDirtLayer 1.asset index e759bc3d..9eba11c0 100644 --- a/Assets/Config/TerrainLayers/AbsoluteFlatDirtLayer 1.asset +++ b/Assets/Config/TerrainLayers/AbsoluteFlatDirtLayer 1.asset @@ -15,7 +15,7 @@ MonoBehaviour: layerType: 0 layerName: Flat dirt base layer index: 300 - blockType: 2 + blockType: 9 frequency: 50 exponent: 1 minHeight: 1 diff --git a/Assets/Config/TerrainLayers/AbsoluteStoneLayer.asset b/Assets/Config/TerrainLayers/AbsoluteStoneLayer.asset index 11ebf664..b87c2df2 100644 --- a/Assets/Config/TerrainLayers/AbsoluteStoneLayer.asset +++ b/Assets/Config/TerrainLayers/AbsoluteStoneLayer.asset @@ -15,7 +15,7 @@ MonoBehaviour: layerType: 0 layerName: Stone base layer index: 100 - blockType: 1 + blockType: 8 frequency: 32 exponent: 1 minHeight: 10 diff --git a/Assets/Config/TerrainLayers/AbsoluteStoneMountainLayer.asset b/Assets/Config/TerrainLayers/AbsoluteStoneMountainLayer.asset index b2fcb2a1..0f311aee 100644 --- a/Assets/Config/TerrainLayers/AbsoluteStoneMountainLayer.asset +++ b/Assets/Config/TerrainLayers/AbsoluteStoneMountainLayer.asset @@ -15,7 +15,7 @@ MonoBehaviour: layerType: 0 layerName: Stone mountains layer index: 150 - blockType: 1 + blockType: 8 frequency: 110 exponent: 1.1 minHeight: 0 diff --git a/Assets/Config/TerrainLayers/AdditiveDirtLayer.asset b/Assets/Config/TerrainLayers/AdditiveDirtLayer.asset index 3cb6d675..8655bcdd 100644 --- a/Assets/Config/TerrainLayers/AdditiveDirtLayer.asset +++ b/Assets/Config/TerrainLayers/AdditiveDirtLayer.asset @@ -15,7 +15,7 @@ MonoBehaviour: layerType: 4 layerName: Dirt noise layer index: 400 - blockType: 2 + blockType: 9 frequency: 20 exponent: 1 minHeight: 2 diff --git a/Assets/Config/TerrainLayers/AdditiveStoneLayer.asset b/Assets/Config/TerrainLayers/AdditiveStoneLayer.asset index 92605a60..90901e85 100644 --- a/Assets/Config/TerrainLayers/AdditiveStoneLayer.asset +++ b/Assets/Config/TerrainLayers/AdditiveStoneLayer.asset @@ -15,7 +15,7 @@ MonoBehaviour: layerType: 4 layerName: Stone noise layer index: 200 - blockType: 1 + blockType: 8 frequency: 7 exponent: 1 minHeight: 1 diff --git a/Assets/Config/TerrainLayers/ConfigBank.asset b/Assets/Config/TerrainLayers/ConfigBank.asset index db2a77c2..1369b161 100644 --- a/Assets/Config/TerrainLayers/ConfigBank.asset +++ b/Assets/Config/TerrainLayers/ConfigBank.asset @@ -15,3 +15,10 @@ MonoBehaviour: configs: - {fileID: 11400000, guid: bf78fd0d717835f4ebfb0ab97738fcc3, type: 2} - {fileID: 11400000, guid: 3c9c4f78892f3d61ca2921df917af494, type: 2} + - {fileID: 11400000, guid: 2f5bc7a55a6025d47b527964ec312b3a, type: 2} + - {fileID: 11400000, guid: 8527ab0fe14c69d478b7a45b804890ba, type: 2} + - {fileID: 11400000, guid: caf902135f65b6048b12ba818c2c717d, type: 2} + - {fileID: 11400000, guid: 1aeea6c0e0c3c2343949e0df38c69de6, type: 2} + - {fileID: 11400000, guid: 2b9409c8be937c343ae7fbbc34ec2c37, type: 2} + - {fileID: 11400000, guid: 4fc6d8866eef4d44d97281916a484fa3, type: 2} + - {fileID: 11400000, guid: 1f538ef6eb2797a4b9e2b1acdea36656, type: 2} diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig.meta b/Assets/Config/TerrainLayers/LogicLayerConfig.meta new file mode 100644 index 00000000..f4684771 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 657a52b7f2b23a943aac6b45ead4921f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/1-Layer.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/1-Layer.asset new file mode 100644 index 00000000..49f3fa3a --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/1-Layer.asset @@ -0,0 +1,27 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3} + m_Name: 1-Layer + m_EditorClassIdentifier: + configName: 1-Layer + layers: + - {fileID: 11400000, guid: f3fd30ecc3310c14eb7eb6c90d0c58f8, type: 2} + - {fileID: 11400000, guid: d25afcbb99ce5894eb4d6b546ae83e0b, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 29674d2c5426a854ca6acd47798e6796, type: 2} + areaColumnHeight: 1 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/1-Layer.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/1-Layer.asset.meta new file mode 100644 index 00000000..7a9cd7d9 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/1-Layer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2f5bc7a55a6025d47b527964ec312b3a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/2-Layer.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/2-Layer.asset new file mode 100644 index 00000000..9d3ca53a --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/2-Layer.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3} + m_Name: 2-Layer + m_EditorClassIdentifier: + configName: 2-Layer + layers: + - {fileID: 11400000, guid: f3fd30ecc3310c14eb7eb6c90d0c58f8, type: 2} + - {fileID: 11400000, guid: d25afcbb99ce5894eb4d6b546ae83e0b, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 29674d2c5426a854ca6acd47798e6796, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: e1fb80c25e61f434fa90a2d6f72d0cf4, type: 2} + areaColumnHeight: 1 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/2-Layer.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/2-Layer.asset.meta new file mode 100644 index 00000000..e9433819 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/2-Layer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8527ab0fe14c69d478b7a45b804890ba +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/3-Layer.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/3-Layer.asset new file mode 100644 index 00000000..bd27e90c --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/3-Layer.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3} + m_Name: 3-Layer + m_EditorClassIdentifier: + configName: 3-Layer + layers: + - {fileID: 11400000, guid: f3fd30ecc3310c14eb7eb6c90d0c58f8, type: 2} + - {fileID: 11400000, guid: d25afcbb99ce5894eb4d6b546ae83e0b, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 29674d2c5426a854ca6acd47798e6796, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: e1fb80c25e61f434fa90a2d6f72d0cf4, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: e82186977070b504d8b7fdc218bb9b65, type: 2} + areaColumnHeight: 1 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/3-Layer.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/3-Layer.asset.meta new file mode 100644 index 00000000..bc5fc564 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/3-Layer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: caf902135f65b6048b12ba818c2c717d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/4-Layer.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/4-Layer.asset new file mode 100644 index 00000000..50173c64 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/4-Layer.asset @@ -0,0 +1,51 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3} + m_Name: 4-Layer + m_EditorClassIdentifier: + configName: 4-Layer + layers: + - {fileID: 11400000, guid: f3fd30ecc3310c14eb7eb6c90d0c58f8, type: 2} + - {fileID: 11400000, guid: d25afcbb99ce5894eb4d6b546ae83e0b, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 29674d2c5426a854ca6acd47798e6796, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: e1fb80c25e61f434fa90a2d6f72d0cf4, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: e82186977070b504d8b7fdc218bb9b65, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 5a12221633cd8344e9ce5db17e066e02, type: 2} + areaColumnHeight: 1 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/4-Layer.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/4-Layer.asset.meta new file mode 100644 index 00000000..2732d087 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/4-Layer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1aeea6c0e0c3c2343949e0df38c69de6 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/5-Layer.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/5-Layer.asset new file mode 100644 index 00000000..adfe20ef --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/5-Layer.asset @@ -0,0 +1,59 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3} + m_Name: 5-Layer + m_EditorClassIdentifier: + configName: 5-Layer + layers: + - {fileID: 11400000, guid: f3fd30ecc3310c14eb7eb6c90d0c58f8, type: 2} + - {fileID: 11400000, guid: d25afcbb99ce5894eb4d6b546ae83e0b, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 29674d2c5426a854ca6acd47798e6796, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: e1fb80c25e61f434fa90a2d6f72d0cf4, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: e82186977070b504d8b7fdc218bb9b65, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 5a12221633cd8344e9ce5db17e066e02, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 831503be795983b4ca489fc34f226442, type: 2} + areaColumnHeight: 1 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/5-Layer.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/5-Layer.asset.meta new file mode 100644 index 00000000..a9444f85 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/5-Layer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2b9409c8be937c343ae7fbbc34ec2c37 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit.meta new file mode 100644 index 00000000..38610dcd --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7c1704f11c7a76846841da4b965820c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/AND.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/AND.asset new file mode 100644 index 00000000..d96029eb --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/AND.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: AND + m_EditorClassIdentifier: + layerType: 5 + layerName: New Layer + index: 0 + blockType: 4 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/AND.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/AND.asset.meta new file mode 100644 index 00000000..76dc77a8 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/AND.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ad144b7a9425bca4795c83034d5bfc13 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Clock.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Clock.asset new file mode 100644 index 00000000..70695e74 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Clock.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: Clock + m_EditorClassIdentifier: + layerType: 5 + layerName: New Layer + index: 0 + blockType: 3 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Clock.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Clock.asset.meta new file mode 100644 index 00000000..be0d3a5c --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Clock.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Input.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Input.asset new file mode 100644 index 00000000..8a184c10 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Input.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: Input + m_EditorClassIdentifier: + layerType: 5 + layerName: New Layer + index: 0 + blockType: 2 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Input.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Input.asset.meta new file mode 100644 index 00000000..43d4867c --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Input.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c6e3eb1f214dba643a869419afac08a0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/NOT.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/NOT.asset new file mode 100644 index 00000000..f65c8ae8 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/NOT.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: NOT + m_EditorClassIdentifier: + layerType: 5 + layerName: New Layer + index: 0 + blockType: 6 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/NOT.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/NOT.asset.meta new file mode 100644 index 00000000..a8eca86a --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/NOT.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6669ac95dd6faaf439917703a5fae7da +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/OR.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/OR.asset new file mode 100644 index 00000000..fdddd117 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/OR.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: OR + m_EditorClassIdentifier: + layerType: 5 + layerName: New Layer + index: 0 + blockType: 5 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/OR.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/OR.asset.meta new file mode 100644 index 00000000..d49ca1b4 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/OR.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 91e1dafc2b241bd43a8c39d7ad6e72c2 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Wire.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Wire.asset new file mode 100644 index 00000000..aca79ef7 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Wire.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: Wire + m_EditorClassIdentifier: + layerType: 5 + layerName: New Layer + index: 0 + blockType: 16 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Wire.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Wire.asset.meta new file mode 100644 index 00000000..163b179a --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/Wire.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2a93c97e75ac4d4488a78c0bebfcdd5e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/XOR.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/XOR.asset new file mode 100644 index 00000000..43c8773f --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/XOR.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: XOR + m_EditorClassIdentifier: + layerType: 5 + layerName: New Layer + index: 0 + blockType: 7 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/XOR.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/XOR.asset.meta new file mode 100644 index 00000000..40f9090c --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Circuit/XOR.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0b219d2ce6773be4e92b67b667529728 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Empty.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/Empty.asset new file mode 100644 index 00000000..8829d234 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Empty.asset @@ -0,0 +1,19 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3} + m_Name: Empty + m_EditorClassIdentifier: + configName: Empty + layers: + - {fileID: 11400000, guid: f3fd30ecc3310c14eb7eb6c90d0c58f8, type: 2} + - {fileID: 11400000, guid: d25afcbb99ce5894eb4d6b546ae83e0b, type: 2} + areaColumnHeight: 1 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/Empty.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/Empty.asset.meta new file mode 100644 index 00000000..a82b1061 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/Empty.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fc6d8866eef4d44d97281916a484fa3 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer1.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer1.asset new file mode 100644 index 00000000..23043b12 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer1.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer1 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 1 + maxHeight: 1 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer1.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer1.asset.meta new file mode 100644 index 00000000..ae0e8454 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d25afcbb99ce5894eb4d6b546ae83e0b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer11.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer11.asset new file mode 100644 index 00000000..a1f78454 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer11.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer11 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 11 + maxHeight: 11 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer11.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer11.asset.meta new file mode 100644 index 00000000..5d97ba04 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer11.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 831503be795983b4ca489fc34f226442 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer3.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer3.asset new file mode 100644 index 00000000..e7bc2d8a --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer3.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer3 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 3 + maxHeight: 3 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer3.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer3.asset.meta new file mode 100644 index 00000000..62744ef8 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer3.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29674d2c5426a854ca6acd47798e6796 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer40.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer40.asset new file mode 100644 index 00000000..e44e241b --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer40.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer40 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 40 + maxHeight: 40 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer40.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer40.asset.meta new file mode 100644 index 00000000..36702d23 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer40.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ba98d5f01fe03f64282dcf6af0f5481b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer42.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer42.asset new file mode 100644 index 00000000..55e675cd --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer42.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer42 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 42 + maxHeight: 42 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer42.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer42.asset.meta new file mode 100644 index 00000000..d4ca15a1 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer42.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1298f24b4543c514f8df33cc3b9a35c0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer5.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer5.asset new file mode 100644 index 00000000..4930a848 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer5.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer5 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 5 + maxHeight: 5 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer5.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer5.asset.meta new file mode 100644 index 00000000..8f04f646 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer5.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e1fb80c25e61f434fa90a2d6f72d0cf4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer7.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer7.asset new file mode 100644 index 00000000..cce1888d --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer7.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer7 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 7 + maxHeight: 7 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer7.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer7.asset.meta new file mode 100644 index 00000000..8d9af841 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer7.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e82186977070b504d8b7fdc218bb9b65 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer9.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer9.asset new file mode 100644 index 00000000..29715794 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer9.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: StoneLayer9 + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface stone layer + index: 1000 + blockType: 8 + frequency: 0 + exponent: 0 + minHeight: 9 + maxHeight: 9 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer9.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer9.asset.meta new file mode 100644 index 00000000..9e4ff247 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/StoneLayer9.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5a12221633cd8344e9ce5db17e066e02 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/TerrainCircuitry.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/TerrainCircuitry.asset new file mode 100644 index 00000000..d495c7d1 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/TerrainCircuitry.asset @@ -0,0 +1,33 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3} + m_Name: TerrainCircuitry + m_EditorClassIdentifier: + configName: TerrainCircuitry + layers: + - {fileID: 11400000, guid: b294ba7c0c4a08144916c18d0f467747, type: 2} + - {fileID: 11400000, guid: 0bc928c0fbae2694a9c4c010f4687eb4, type: 2} + - {fileID: 11400000, guid: a5626c3ee64bec348a6e50deb3b467d1, type: 2} + - {fileID: 11400000, guid: a7f2d008399aab1458b1b760cf85ff0a, type: 2} + - {fileID: 11400000, guid: 5a676bee5116cc047acabfa4f7d19241, type: 2} + - {fileID: 11400000, guid: 04e8d21d759b887479e8717cf913597d, type: 2} + - {fileID: 11400000, guid: 73e6007e32e2599449c029eab6a24533, type: 2} + - {fileID: 11400000, guid: ba98d5f01fe03f64282dcf6af0f5481b, type: 2} + - {fileID: 11400000, guid: c6e3eb1f214dba643a869419afac08a0, type: 2} + - {fileID: 11400000, guid: 2e7bd4a19bb1bbf4a9a6dfa46abff6df, type: 2} + - {fileID: 11400000, guid: 2a93c97e75ac4d4488a78c0bebfcdd5e, type: 2} + - {fileID: 11400000, guid: ad144b7a9425bca4795c83034d5bfc13, type: 2} + - {fileID: 11400000, guid: 91e1dafc2b241bd43a8c39d7ad6e72c2, type: 2} + - {fileID: 11400000, guid: 6669ac95dd6faaf439917703a5fae7da, type: 2} + - {fileID: 11400000, guid: 0b219d2ce6773be4e92b67b667529728, type: 2} + - {fileID: 11400000, guid: 1298f24b4543c514f8df33cc3b9a35c0, type: 2} + areaColumnHeight: 3 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/TerrainCircuitry.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/TerrainCircuitry.asset.meta new file mode 100644 index 00000000..4d807a85 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/TerrainCircuitry.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f538ef6eb2797a4b9e2b1acdea36656 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/UnbreakableLayer.asset b/Assets/Config/TerrainLayers/LogicLayerConfig/UnbreakableLayer.asset new file mode 100644 index 00000000..57891545 --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/UnbreakableLayer.asset @@ -0,0 +1,24 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c8dc7565f1544ab096b804d358a1a4e4, type: 3} + m_Name: UnbreakableLayer + m_EditorClassIdentifier: + layerType: 0 + layerName: Surface unbreakable layer + index: 1000 + blockType: 15 + frequency: 0 + exponent: 0 + minHeight: 0 + maxHeight: 0 + chance: 0 + structureType: 0 diff --git a/Assets/Config/TerrainLayers/LogicLayerConfig/UnbreakableLayer.asset.meta b/Assets/Config/TerrainLayers/LogicLayerConfig/UnbreakableLayer.asset.meta new file mode 100644 index 00000000..4f5fadfa --- /dev/null +++ b/Assets/Config/TerrainLayers/LogicLayerConfig/UnbreakableLayer.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f3fd30ecc3310c14eb7eb6c90d0c58f8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Config/TerrainLayers/RollingHillsTerrainLayers.asset b/Assets/Config/TerrainLayers/RollingHillsTerrainLayers.asset index 42b982a9..c51577f9 100644 --- a/Assets/Config/TerrainLayers/RollingHillsTerrainLayers.asset +++ b/Assets/Config/TerrainLayers/RollingHillsTerrainLayers.asset @@ -21,4 +21,5 @@ MonoBehaviour: - {fileID: 11400000, guid: 5a676bee5116cc047acabfa4f7d19241, type: 2} - {fileID: 11400000, guid: 04e8d21d759b887479e8717cf913597d, type: 2} - {fileID: 11400000, guid: 73e6007e32e2599449c029eab6a24533, type: 2} + - {fileID: 11400000, guid: ba98d5f01fe03f64282dcf6af0f5481b, type: 2} areaColumnHeight: 3 diff --git a/Assets/Config/TerrainLayers/SurfaceGrassLayer.asset b/Assets/Config/TerrainLayers/SurfaceGrassLayer.asset index cd9c9291..440da6d5 100644 --- a/Assets/Config/TerrainLayers/SurfaceGrassLayer.asset +++ b/Assets/Config/TerrainLayers/SurfaceGrassLayer.asset @@ -15,7 +15,7 @@ MonoBehaviour: layerType: 3 layerName: Surface grass layer index: 1000 - blockType: 5 + blockType: 12 frequency: 0 exponent: 0 minHeight: 0 diff --git a/Assets/GlobalEntitiesDependencies/GlobalEntitySceneDependency.asset b/Assets/GlobalEntitiesDependencies/GlobalEntitySceneDependency.asset index de7a4c12..056b34b6 100644 --- a/Assets/GlobalEntitiesDependencies/GlobalEntitySceneDependency.asset +++ b/Assets/GlobalEntitiesDependencies/GlobalEntitySceneDependency.asset @@ -14,7 +14,7 @@ MonoBehaviour: m_EditorClassIdentifier: cacheGUID: Value: - x: 1700868938 - y: 2258953530 - z: 4084636585 - w: 1367957563 + x: 645645266 + y: 1087722174 + z: 1222929814 + w: 2446102451 diff --git a/Assets/Materials/Textures/Items.meta b/Assets/Materials/Textures/Items.meta new file mode 100644 index 00000000..a1f4de28 --- /dev/null +++ b/Assets/Materials/Textures/Items.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: da236230bc1374c48bdfe235431def71 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/Textures/SpriteSheet.png b/Assets/Materials/Textures/SpriteSheet.png index 5f887738..293daad3 100644 Binary files a/Assets/Materials/Textures/SpriteSheet.png and b/Assets/Materials/Textures/SpriteSheet.png differ diff --git a/Assets/Materials/Textures/SpriteSheet.png.meta b/Assets/Materials/Textures/SpriteSheet.png.meta index 5f88fd17..10ccb327 100644 --- a/Assets/Materials/Textures/SpriteSheet.png.meta +++ b/Assets/Materials/Textures/SpriteSheet.png.meta @@ -58,7 +58,7 @@ TextureImporter: textureShape: 4 singleChannelComponent: 0 flipbookRows: 1 - flipbookColumns: 8 + flipbookColumns: 20 maxTextureSizeSet: 0 compressionQualitySet: 0 textureFormatSet: 0 diff --git a/Assets/SceneDependencyCache/37b6622865e76a3eda5982320d6ef0a8.sceneWithBuildSettings b/Assets/SceneDependencyCache/37b6622865e76a3eda5982320d6ef0a8.sceneWithBuildSettings index 2ca40c65..9487162a 100644 Binary files a/Assets/SceneDependencyCache/37b6622865e76a3eda5982320d6ef0a8.sceneWithBuildSettings and b/Assets/SceneDependencyCache/37b6622865e76a3eda5982320d6ef0a8.sceneWithBuildSettings differ diff --git a/Assets/SceneDependencyCache/e4aecb2705563cb16dae6c564f93f55c.sceneWithBuildSettings b/Assets/SceneDependencyCache/e4aecb2705563cb16dae6c564f93f55c.sceneWithBuildSettings index f751e594..422b3c72 100644 Binary files a/Assets/SceneDependencyCache/e4aecb2705563cb16dae6c564f93f55c.sceneWithBuildSettings and b/Assets/SceneDependencyCache/e4aecb2705563cb16dae6c564f93f55c.sceneWithBuildSettings differ diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 4cb2e2c1..ac0dda5f 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -546,21 +546,21 @@ PrefabInstance: - target: {fileID: 3243556258562715456, guid: 6752cefe6bfd8d09cb07eba71d738d13, type: 3} propertyPath: editorArgs - value: -deploymentID 0 + value: -deploymentID 0 -userID 0 -activeLogic -terrainType 1-Layer -circuitX + 1 -circuitZ 1 -tickSpeed 1000 objectReference: {fileID: 0} - target: {fileID: 3243556258562715456, guid: 6752cefe6bfd8d09cb07eba71d738d13, type: 3} propertyPath: deploymentConfig - value: "{\n\"nodes\":[\n\t{\n\t\t\"nodeID\":0,\n\t\t\"worldConfigs\":[\n\t\t\t{\n\t\t\t\"worldName\": - \"GameServer\",\n\t\t\t\"worldType\":\"Server\",\n\t\t\t\"initializationMode\":\"Connect\",\n\t\t\t\"serverNodeID\":0,\n\t\t\t},\n\t\t\t{\n\t\t\t\"worldName\": - \"GameClient\",\n\t\t\t\"worldType\":\"Client\",\n\t\t\t\"initializationMode\":\"Connect\",\n\t\t\t\"serverNodeID\":0,\n\t\t\t}\n\t\t]\n\t},\n\t{\n\t\t\"nodeID\":1,\n\t\t\"worldConfigs\":[\n\t\t\t{\n\t\t\t\"worldName\": - \"SimulatorClientTest\",\n\t\t\t\"worldType\":\"SimulatedClient\",\n\t\t\t\"initializationMode\":\"Connect\",\n\t\t\t\"serverNodeID\":0,\n\t\t\t\"numSimulatedClients\": - 4\n\t\t\t}\n\t\t]\n\t}\n], \n\"experimentActions\":[]\n}" + value: "{\r\n\"nodes\":[\r\n\t{\r\n\t\t\"nodeID\":0,\r\n\t\t\"worldConfigs\":[\r\n\t\t\t{\r\n\t\t\t\"worldName\": + \"GameServer\",\r\n\t\t\t\"worldType\":\"Server\",\r\n\t\t\t\"initializationMode\":\"Connect\",\r\n\t\t\t\"serverNodeID\":0,\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\"worldName\": + \"GameClient\",\r\n\t\t\t\"worldType\":\"Client\",\r\n\t\t\t\"initializationMode\":\"Connect\",\r\n\t\t\t\"serverNodeID\":0\r\n\t\t\t}\r\n\t\t]\r\n\t}\r\n], + \r\n\"experimentActions\":[]\r\n}" objectReference: {fileID: 0} - target: {fileID: 3243556258562715456, guid: 6752cefe6bfd8d09cb07eba71d738d13, type: 3} propertyPath: useDeploymentConfig - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 4500616911380405583, guid: 6752cefe6bfd8d09cb07eba71d738d13, type: 3} diff --git a/Assets/Scripts/Configuration/GameConfig.cs b/Assets/Scripts/Configuration/GameConfig.cs index 0728cab0..a30ce881 100644 --- a/Assets/Scripts/Configuration/GameConfig.cs +++ b/Assets/Scripts/Configuration/GameConfig.cs @@ -12,6 +12,5 @@ public static class GameConfig { public static readonly CommandLineParser.EnumArgument PlayerSimulationBehaviour = new CommandLineParser.EnumArgument("-playerSimulationBehaviour", SimulationBehaviour.BoundedRandom); public static readonly CommandLineParser.StringArgument TerrainType = new CommandLineParser.StringArgument("-terrainType", "default"); - } } \ No newline at end of file diff --git a/Assets/Scripts/Player/Authoring/PlayerAuthoring.cs b/Assets/Scripts/Player/Authoring/PlayerAuthoring.cs index a6e0705a..f3d7a41f 100644 --- a/Assets/Scripts/Player/Authoring/PlayerAuthoring.cs +++ b/Assets/Scripts/Player/Authoring/PlayerAuthoring.cs @@ -7,14 +7,14 @@ namespace Opencraft.Player.Authoring { - + public struct PlayerComponent : IComponentData { // Movement related fields [GhostField] public int JumpVelocity; [GhostField] public float Pitch; [GhostField] public float Yaw; - + // Connection related fields [GhostField] public FixedString32Bytes Username; public BlobAssetReference multiplayConnectionID; @@ -24,17 +24,17 @@ public struct PlayerComponent : IComponentData public struct PlayerInGame : IComponentData, IEnableableComponent { } - + // Marks this player entity as freshly instantiated public struct NewPlayer : IComponentData, IEnableableComponent { } - + // Marks this player entity as a guest player public struct GuestPlayer : IComponentData, IEnableableComponent { } - + public struct PlayerContainingArea : IComponentData { // Link to containing area @@ -42,7 +42,7 @@ public struct PlayerContainingArea : IComponentData // Where that area is public int3 AreaLocation; } - + // Component marking this entity as having a specific block selected. // Neighbor block refers to the block neighbor of the selected block closest to this entity public struct SelectedBlock : IComponentData @@ -53,17 +53,19 @@ public struct SelectedBlock : IComponentData public int3 neighborBlockLoc; } - + // All of a player's input for a frame, uses special component type IInputComponentData [GhostComponent(PrefabType = GhostPrefabType.AllPredicted, OwnerSendType = SendToOwnerType.SendToNonOwner)] public struct PlayerInput : IInputComponentData { - [GhostField]public float2 Movement; - [GhostField]public InputEvent Jump; - [GhostField]public InputEvent PrimaryAction; - [GhostField]public InputEvent SecondaryAction; - [GhostField]public float Pitch; - [GhostField]public float Yaw; + [GhostField] public float2 Movement; + [GhostField] public InputEvent Jump; + [GhostField] public InputEvent PrimaryAction; + [GhostField] public InputEvent SecondaryAction; + [GhostField] public InputEvent ThirdAction; + [GhostField] public int SelectedItem; + [GhostField] public float Pitch; + [GhostField] public float Yaw; } // Group player related component accessors for ease of use @@ -86,8 +88,10 @@ public struct PlayerInput : IInputComponentData public ref PlayerComponent PlayerComponent => ref m_Character.ValueRW; public ref PlayerContainingArea ContainingArea => ref m_Area.ValueRW; - + public ref SelectedBlock SelectedBlock => ref m_SelectedBlock.ValueRW; + + public ref LocalTransform TransformComponent => ref Transform.ValueRW; } [DisallowMultipleComponent] diff --git a/Assets/Scripts/Player/PlayerActionSystem.cs b/Assets/Scripts/Player/PlayerActionSystem.cs index 18016e3f..7848e36f 100644 --- a/Assets/Scripts/Player/PlayerActionSystem.cs +++ b/Assets/Scripts/Player/PlayerActionSystem.cs @@ -1,4 +1,6 @@ -using Opencraft.Player.Authoring; +using System.Linq; +using Opencraft.Player.Authoring; +using Opencraft.Terrain; using Opencraft.Terrain.Authoring; using Opencraft.Terrain.Blocks; using Opencraft.Terrain.Utilities; @@ -17,24 +19,27 @@ namespace Opencraft.Player public partial struct PlayerActionSystem : ISystem { private BufferLookup _terrainBlocksBufferLookup; + private BufferLookup _terrainLogicStateLookup; + private BufferLookup _terrainDirectionLookup; + private BufferLookup _terrainUpdatedLookup; private BufferLookup _terrainColumnMinBufferLookup; private BufferLookup _terrainColumnMaxBufferLookup; - private NativeArray terrainAreasEntities; private ComponentLookup _terrainAreaLookup; - + [BurstCompile] public void OnCreate(ref SystemState state) { - state.RequireForUpdate(); state.RequireForUpdate(); state.RequireForUpdate(); _terrainBlocksBufferLookup = state.GetBufferLookup(false); - _terrainColumnMinBufferLookup= state.GetBufferLookup(false); - _terrainColumnMaxBufferLookup= state.GetBufferLookup(false); + _terrainLogicStateLookup = state.GetBufferLookup(false); + _terrainDirectionLookup = state.GetBufferLookup(false); + _terrainUpdatedLookup = state.GetBufferLookup(false); + _terrainColumnMinBufferLookup = state.GetBufferLookup(false); + _terrainColumnMaxBufferLookup = state.GetBufferLookup(false); _terrainAreaLookup = state.GetComponentLookup(isReadOnly: true); - } [BurstCompile] @@ -42,26 +47,26 @@ public void OnUpdate(ref SystemState state) { state.CompleteDependency(); _terrainBlocksBufferLookup.Update(ref state); + _terrainLogicStateLookup.Update(ref state); + _terrainDirectionLookup.Update(ref state); + _terrainUpdatedLookup.Update(ref state); _terrainColumnMinBufferLookup.Update(ref state); _terrainColumnMaxBufferLookup.Update(ref state); _terrainAreaLookup.Update(ref state); - var terrainAreasQuery = SystemAPI.QueryBuilder().WithAll().Build(); - terrainAreasEntities = terrainAreasQuery.ToEntityArray(state.WorldUpdateAllocator); foreach (var player in SystemAPI.Query().WithAll()) { // Destroy block action if (player.Input.PrimaryAction.IsSet && player.SelectedBlock.terrainArea != Entity.Null) { - Entity terrainAreaEntity = player.SelectedBlock.terrainArea; - if(_terrainBlocksBufferLookup.TryGetBuffer(terrainAreaEntity, out DynamicBuffer terrainBlocks)) + if (_terrainBlocksBufferLookup.TryGetBuffer(terrainAreaEntity, out DynamicBuffer terrainBlocks)) { int3 blockLoc = player.SelectedBlock.blockLoc; int blockIndex = TerrainUtilities.BlockLocationToIndex(ref blockLoc); int colIndex = TerrainUtilities.BlockLocationToColIndex(ref blockLoc); DynamicBuffer blocks = terrainBlocks.Reinterpret(); - if (blocks[blockIndex] != BlockType.Air) + if (blocks[blockIndex] != BlockType.Air && blocks[blockIndex] != BlockType.Unbreakable) { var colMins = _terrainColumnMinBufferLookup[terrainAreaEntity].Reinterpret(); var colMaxes = _terrainColumnMaxBufferLookup[terrainAreaEntity].Reinterpret(); @@ -90,33 +95,44 @@ public void OnUpdate(ref SystemState state) if (blockLoc.y + 1 == maxY) { // Search downwards for new max - for (int y = 1; y < blockLoc.y ; y++) + for (int y = 1; y < blockLoc.y; y++) { if (blocks[blockIndex - y] != BlockType.Air) { // found a non-empty block - colMaxes[colIndex] = (byte)(blockLoc.y-y+1); + colMaxes[colIndex] = (byte)(blockLoc.y - y + 1); break; } - if (y == blockLoc.y-1) + if (y == blockLoc.y - 1) { // no non-empty blocks found, set max to a min value colMaxes[colIndex] = 0; } } } + BlockType destroyedBlockType = blocks[blockIndex]; blocks[blockIndex] = BlockType.Air; + + DynamicBuffer boolLogicStates = _terrainLogicStateLookup[terrainAreaEntity].Reinterpret(); + boolLogicStates[blockIndex] = false; + + if (BlockData.IsLogic(destroyedBlockType)) + { + DynamicBuffer locs = _terrainUpdatedLookup[terrainAreaEntity]; + locs.Add(new TerrainBlockUpdates { blockLoc = blockLoc }); + } } } - } + // Place block action, using the neighbor of selected block if (player.Input.SecondaryAction.IsSet && player.SelectedBlock.neighborTerrainArea != Entity.Null) { Entity terrainAreaEntity = player.SelectedBlock.neighborTerrainArea; - if(_terrainBlocksBufferLookup.TryGetBuffer(terrainAreaEntity, out DynamicBuffer terrainBlocks)) + if (_terrainBlocksBufferLookup.TryGetBuffer(terrainAreaEntity, out DynamicBuffer terrainBlocks)) { + BlockType blockToPlace = (BlockType)player.Input.SelectedItem; int3 blockLoc = player.SelectedBlock.neighborBlockLoc; int blockIndex = TerrainUtilities.BlockLocationToIndex(ref blockLoc); int colIndex = TerrainUtilities.BlockLocationToColIndex(ref blockLoc); @@ -129,16 +145,75 @@ public void OnUpdate(ref SystemState state) int maxY = colMaxes[colIndex]; // If new block is the top or bottom of a column, update the column heightmaps if (blockLoc.y < minY) - colMins[colIndex] = (byte) blockLoc.y; + colMins[colIndex] = (byte)blockLoc.y; if (blockLoc.y + 1 > maxY) - colMaxes[colIndex] = (byte) (blockLoc.y + 1); - // todo ability to place something other than stone - blocks[blockIndex] = BlockType.Stone; + colMaxes[colIndex] = (byte)(blockLoc.y + 1); + blocks[blockIndex] = blockToPlace; + TerrainArea terrainArea = _terrainAreaLookup[terrainAreaEntity]; + int3 globalPos = terrainArea.location * Env.AREA_SIZE + blockLoc; + + if (_terrainDirectionLookup.TryGetBuffer(terrainAreaEntity, out DynamicBuffer blockDirections)) + { + float3 playerPos = player.TransformComponent.Position; + blockDirections[blockIndex] = new BlockDirection { direction = GetDirection(playerPos, globalPos) }; + } + + if (BlockData.IsLogic(blockToPlace)) + { + DynamicBuffer locs = _terrainUpdatedLookup[terrainAreaEntity]; + locs.Add(new TerrainBlockUpdates { blockLoc = blockLoc }); + } + DynamicBuffer boolLogicStates = _terrainLogicStateLookup[terrainAreaEntity].Reinterpret(); + boolLogicStates[blockIndex] = false; } } } - } + if (player.Input.ThirdAction.IsSet && player.SelectedBlock.terrainArea != Entity.Null) + { + //UnityEngine.Debug.Log("Third action triggered"); + Entity terrainAreaEntity = player.SelectedBlock.terrainArea; + if (_terrainBlocksBufferLookup.TryGetBuffer(terrainAreaEntity, out DynamicBuffer terrainBlocks)) + { + int3 blockLoc = player.SelectedBlock.blockLoc; + int blockIndex = TerrainUtilities.BlockLocationToIndex(ref blockLoc); + DynamicBuffer blocks = terrainBlocks.Reinterpret(); + DynamicBuffer boolLogicStates = _terrainLogicStateLookup[terrainAreaEntity].Reinterpret(); + if (blocks[blockIndex] == BlockType.Off_Input) + { + blocks[blockIndex] = BlockType.On_Input; + boolLogicStates[blockIndex] = true; + DynamicBuffer locs = _terrainUpdatedLookup[terrainAreaEntity]; + locs.Add(new TerrainBlockUpdates { blockLoc = blockLoc }); + } + else if (blocks[blockIndex] == BlockType.On_Input) + { + blocks[blockIndex] = BlockType.Off_Input; + boolLogicStates[blockIndex] = false; + DynamicBuffer locs = _terrainUpdatedLookup[terrainAreaEntity]; + locs.Add(new TerrainBlockUpdates { blockLoc = blockLoc }); + } + } + } + } + } + private Direction GetDirection(float3 playerPos, int3 globalPos) + { + playerPos = new float3(playerPos.x, NoiseUtilities.FastFloor(playerPos.y), playerPos.z); + float3 offset = globalPos - playerPos; + float3 absoluteOffset = new(math.abs(offset.x), math.abs(offset.y), math.abs(offset.z)); + Direction dir = Direction.XP; + if (absoluteOffset.x > absoluteOffset.z) + { + if (offset.x > 0) dir = Direction.XN; + else dir = Direction.XP; + } + else if (absoluteOffset.z > absoluteOffset.x) + { + if (offset.z > 0) dir = Direction.ZN; + else dir = Direction.ZP; + } + return dir; } } } \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerInputSystem.cs b/Assets/Scripts/Player/PlayerInputSystem.cs index 4c310bd2..6417c5f1 100644 --- a/Assets/Scripts/Player/PlayerInputSystem.cs +++ b/Assets/Scripts/Player/PlayerInputSystem.cs @@ -14,14 +14,14 @@ namespace Opencraft.Player [UpdateInGroup(typeof(GhostInputSystemGroup))] public partial struct SamplePlayerInput : ISystem { - private static float3 _cameraOffset = new float3(0.0f,Env.CAMERA_Y_OFFSET,0.0f); + private static float3 _cameraOffset = new float3(0.0f, Env.CAMERA_Y_OFFSET, 0.0f); public void OnCreate(ref SystemState state) { if (state.WorldUnmanaged.IsSimulatedClient()) state.Enabled = false; } - + public void OnUpdate(ref SystemState state) { PolkaDOTS.Multiplay.Multiplay multiplay = PolkaDOTS.Multiplay.MultiplaySingleton.Instance; @@ -40,7 +40,7 @@ in SystemAPI.Query, RefRO, RefRW, RefRO, RefRW(); - - + + input.ValueRW.Movement = default; input.ValueRW.Jump = default; - input.ValueRW.PrimaryAction= default; - input.ValueRW.SecondaryAction= default; - + input.ValueRW.PrimaryAction = default; + input.ValueRW.SecondaryAction = default; + input.ValueRW.ThirdAction = default; + input.ValueRW.Movement.x = playerController.inputMovement.x; input.ValueRW.Movement.y = playerController.inputMovement.y; - + input.ValueRW.SelectedItem = playerController.selectableItems[playerController.selectedItemIndex]; + // Actions if (playerController.inputJump) { @@ -69,26 +71,31 @@ in SystemAPI.Query, RefRO, RefRW _terrainNeighborLookup; private static readonly int raycastLength = 5; private static readonly float3 camOffset = new float3(0, Env.CAMERA_Y_OFFSET, 0); - + // World generation information private int _columnHeight; - + // Reusable block search input/output structs private TerrainUtilities.BlockSearchInput BSI; private TerrainUtilities.BlockSearchOutput BSO; @@ -42,7 +42,7 @@ public void OnCreate(ref SystemState state) _terrainNeighborLookup = state.GetComponentLookup(true); _columnHeight = -1; - + TerrainUtilities.BlockSearchInput.DefaultBlockSearchInput(ref BSI); TerrainUtilities.BlockSearchOutput.DefaultBlockSearchOutput(ref BSO); } @@ -51,19 +51,19 @@ public void OnCreate(ref SystemState state) public void OnUpdate(ref SystemState state) { state.CompleteDependency(); - + // Fetch world generation information from the WorldParameters singleton if (_columnHeight == -1) { var worldParameters = SystemAPI.GetSingleton(); _columnHeight = worldParameters.ColumnHeight; } - + _terrainBlockLookup.Update(ref state); _terrainNeighborLookup.Update(ref state); - + new SetSelectedBlock() - { + { columnHeight = _columnHeight, raycastLength = raycastLength, camOffset = camOffset, @@ -72,8 +72,8 @@ public void OnUpdate(ref SystemState state) }.ScheduleParallel(); } } - - + + [BurstCompile] [WithAll(typeof(Simulate), typeof(PlayerInGame))] public partial struct SetSelectedBlock : IJobEntity @@ -83,10 +83,10 @@ public partial struct SetSelectedBlock : IJobEntity public int raycastLength; public float3 camOffset; - + [ReadOnly][NativeDisableParallelForRestriction] public ComponentLookup terrainNeighborsLookup; - [ReadOnly][NativeDisableParallelForRestriction] public BufferLookup terrainBlockLookup; - + [ReadOnly][NativeDisableParallelForRestriction] public BufferLookup terrainBlockLookup; + // Reusable block search input/output structs private TerrainUtilities.BlockSearchInput BSI; private TerrainUtilities.BlockSearchOutput BSO; @@ -104,23 +104,23 @@ public void Execute(Entity entity, if (playerContainingArea.Area == Entity.Null) return; - + // Use player input Yaw/Pitch to calculate the camera direction on clients - var cameraRot = math.mul(quaternion.RotateY(playerInput.Yaw), + var cameraRot = math.mul(quaternion.RotateY(playerInput.Yaw), quaternion.RotateX(-playerInput.Pitch)); var direction = math.mul(cameraRot, math.forward()); Entity neighborTerrainArea = Entity.Null; int3 neighborBlockLoc = new int3(-1); - + // Setup search inputs TerrainUtilities.BlockSearchInput.DefaultBlockSearchInput(ref BSI); BSI.basePos = NoiseUtilities.FastFloor(playerTransform.Position); - BSI.offset = int3.zero; + BSI.offset = int3.zero; BSI.areaEntity = playerContainingArea.Area; - BSI.terrainAreaPos =playerContainingArea.AreaLocation; + BSI.terrainAreaPos = playerContainingArea.AreaLocation; BSI.columnHeight = columnHeight; - + // Step along a ray from the players position in the direction their camera is looking for (int i = 0; i < raycastLength; i++) { @@ -134,21 +134,21 @@ public void Execute(Entity entity, { // found selected block selectedBlock.blockLoc = BSO.localPos; - selectedBlock.terrainArea = BSO.containingArea ; + selectedBlock.terrainArea = BSO.containingArea; // Set neighbor selectedBlock.neighborBlockLoc = neighborBlockLoc; selectedBlock.neighborTerrainArea = neighborTerrainArea; - + break; } // If this block is air, still mark it as the neighbor neighborTerrainArea = BSO.containingArea; neighborBlockLoc = BSO.localPos; } - + } - + } } - + } \ No newline at end of file diff --git a/Assets/Scripts/Rendering/TerrainChangeMonitorSystem.cs b/Assets/Scripts/Rendering/TerrainChangeMonitorSystem.cs index 4a3e4d26..099f55d1 100644 --- a/Assets/Scripts/Rendering/TerrainChangeMonitorSystem.cs +++ b/Assets/Scripts/Rendering/TerrainChangeMonitorSystem.cs @@ -16,32 +16,32 @@ protected override void OnCreate() RequireForUpdate(); RequireForUpdate(); } - + [BurstCompile] protected override void OnUpdate() { Entities - .WithChangeFilter() + .WithChangeFilter().WithChangeFilter() .WithImmediatePlayback() .ForEach((Entity entity, EntityCommandBuffer ecb, in TerrainNeighbors terrainNeighbors) => { // todo- currently we remesh all 6 neighbor areas regardless of where the change was // todo- worst case, we should only need 3 neighbors remeshed, depending on where the change is ecb.SetComponentEnabled(entity, true); - if(terrainNeighbors.neighborXN!= Entity.Null) - ecb.SetComponentEnabled(terrainNeighbors.neighborXN,true); - if(terrainNeighbors.neighborXP!= Entity.Null) - ecb.SetComponentEnabled(terrainNeighbors.neighborXP,true); - if(terrainNeighbors.neighborYN!= Entity.Null) - ecb.SetComponentEnabled(terrainNeighbors.neighborYN,true); - if(terrainNeighbors.neighborYP!= Entity.Null) - ecb.SetComponentEnabled(terrainNeighbors.neighborYP,true); - if(terrainNeighbors.neighborZN!= Entity.Null) - ecb.SetComponentEnabled(terrainNeighbors.neighborZN,true); - if(terrainNeighbors.neighborZP!= Entity.Null) - ecb.SetComponentEnabled(terrainNeighbors.neighborZP,true); + if (terrainNeighbors.neighborXN != Entity.Null) + ecb.SetComponentEnabled(terrainNeighbors.neighborXN, true); + if (terrainNeighbors.neighborXP != Entity.Null) + ecb.SetComponentEnabled(terrainNeighbors.neighborXP, true); + if (terrainNeighbors.neighborYN != Entity.Null) + ecb.SetComponentEnabled(terrainNeighbors.neighborYN, true); + if (terrainNeighbors.neighborYP != Entity.Null) + ecb.SetComponentEnabled(terrainNeighbors.neighborYP, true); + if (terrainNeighbors.neighborZN != Entity.Null) + ecb.SetComponentEnabled(terrainNeighbors.neighborZN, true); + if (terrainNeighbors.neighborZP != Entity.Null) + ecb.SetComponentEnabled(terrainNeighbors.neighborZP, true); }).Run(); } - + } } \ No newline at end of file diff --git a/Assets/Scripts/Rendering/TerrainMeshingSystem.cs b/Assets/Scripts/Rendering/TerrainMeshingSystem.cs index 1d9c3f97..100c00cc 100644 --- a/Assets/Scripts/Rendering/TerrainMeshingSystem.cs +++ b/Assets/Scripts/Rendering/TerrainMeshingSystem.cs @@ -34,9 +34,21 @@ protected override void OnCreate() RequireForUpdate(); _terrainSpawnerQuery = GetEntityQuery(ComponentType.ReadOnly()); // Fetch terrain that needs to be remeshed + NativeList components = new NativeList(8, Allocator.Temp) + { + ComponentType.ReadOnly(), + ComponentType.ReadOnly(), + ComponentType.ReadOnly(), + ComponentType.ReadOnly(), + ComponentType.ReadOnly(), + ComponentType.ReadOnly(), + ComponentType.ReadOnly(), + ComponentType.ReadOnly(), + ComponentType.ReadOnly() + }; _terrainAreaQuery = new EntityQueryBuilder(Allocator.Temp) - .WithAll() - .Build(EntityManager); + .WithAll(ref components) + .Build(EntityManager); // Set layout object for creating VBO _vertexLayout = new NativeArray(1, Allocator.Persistent); // Block locations are on a discrete, limited grid within a terrain area @@ -44,6 +56,7 @@ protected override void OnCreate() // 24 coord, TexCoord as 5 bits, normals as 3 bits _vertexLayout[0] = new VertexAttributeDescriptor(attribute: VertexAttribute.Position, format: VertexAttributeFormat.SInt32, dimension: 1, stream: 0); Debug.Log("MESHING SYSTEM IS ACTIVE"); + components.Dispose(); } protected override void OnDestroy() @@ -77,17 +90,17 @@ protected override void OnUpdate() meshDataArray = meshDataArray, areasToUpdate = chunksToUpdate, terrainAreas = terrainAreas, - terrainNeighbors= terrainNeighbors, + terrainNeighbors = terrainNeighbors, terrainBufferLookup = _terrainBlocksBufferLookup, terrainColumnMinBufferLookup = _terrainColumnMinBufferLookup, terrainColumnMaxBufferLookup = _terrainColumnMaxBufferLookup, - UseDebug = PolkaDOTS.ApplicationConfig.DebugEnabled.Value + UseDebug = PolkaDOTS.ApplicationConfig.DebugEnabled.Value }; // todo we can potentially have the handling of meshJob output happen on later frames to reduce // todo stuttering caused by large remesh jobs JobHandle handle = meshJob.Schedule(chunksToUpdate.Length, 1, Dependency); handle.Complete(); - + // Get the existing terrain area mesh objects Mesh[] meshes = new Mesh[chunksToUpdate.Length]; for (int i = 0; i < chunksToUpdate.Length; i++) @@ -121,7 +134,6 @@ public partial struct MeshTerrainChunkJob : IJobParallelFor [ReadOnly] public NativeArray areasToUpdate; [ReadOnly] public NativeArray terrainAreas; [ReadOnly] public NativeArray terrainNeighbors; - [ReadOnly] public BufferLookup terrainBufferLookup; [ReadOnly] public BufferLookup terrainColumnMinBufferLookup; [ReadOnly] public BufferLookup terrainColumnMaxBufferLookup; @@ -137,7 +149,7 @@ public void Execute(int index) float3 terrainAreaLocation = terrainArea.location * Env.AREA_SIZE; TerrainUtilities.DebugDrawTerrainArea(in terrainAreaLocation, Color.red, 0.5f); } - + // Mesh object vertex data Mesh.MeshData meshData = meshDataArray[index]; @@ -167,7 +179,7 @@ public void Execute(int index) DynamicBuffer neighborZN = default; if (terrainNeighbor.neighborZN != Entity.Null) neighborZN = terrainBufferLookup[terrainNeighbor.neighborZN]; - + // Bitmasks that mark a terrain block as visited NativeArray visitedXN = new NativeArray(Env.AREA_SIZE_POW_3, Allocator.Temp); NativeArray visitedXP = new NativeArray(Env.AREA_SIZE_POW_3, Allocator.Temp); @@ -175,7 +187,7 @@ public void Execute(int index) NativeArray visitedZP = new NativeArray(Env.AREA_SIZE_POW_3, Allocator.Temp); NativeArray visitedYN = new NativeArray(Env.AREA_SIZE_POW_3, Allocator.Temp); NativeArray visitedYP = new NativeArray(Env.AREA_SIZE_POW_3, Allocator.Temp); - + // Setup mesh data arrays int currentVertexBufferSize = 6144; meshData.SetVertexBufferParams(currentVertexBufferSize, vertexLayout); @@ -183,9 +195,9 @@ public void Execute(int index) meshData.SetIndexBufferParams(currentIndexBufferSize, IndexFormat.UInt16); NativeArray vertexBuffer = meshData.GetVertexData(); NativeArray indices = meshData.GetIndexData(); - + // Precalculate the map-relative Y position of the chunk in the map - int chunkY = terrainArea.location.y * Env.AREA_SIZE; + int chunkY = terrainArea.location.y * Env.AREA_SIZE; // Allocate variables on the stack // iBPS is i * bps, kBPS2 is k*bps*bps. S means shifted, x1 means x + 1 int access, heightMapAccess, iBPS, kBPS2, i1, k1, j, j1, jS, jS1, topJ, @@ -195,7 +207,7 @@ public void Execute(int index) int numFaces = 0; // Z axis - for (int k = 0; k < Env.AREA_SIZE; k++, k1++) + for (int k = 0; k < Env.AREA_SIZE; k++, k1++) { kBPS2 = k * Env.AREA_SIZE_POW_2; i1 = 1; @@ -203,7 +215,7 @@ public void Execute(int index) // Is the current run on the Z- or Z+ edge of the chunk minZ = k == 0; maxZ = k == Env.AREA_SIZE_1; - + // X axis for (int i = 0; i < Env.AREA_SIZE; i++, i1++) { @@ -219,29 +231,30 @@ public void Execute(int index) // Y axis for (; j < topJ; j++, access++) { - if(access >= Env.AREA_SIZE_POW_3) + if (access >= Env.AREA_SIZE_POW_3) Debug.Log($"Access {access} OOB for {i} {j} {k} with col max height {topJ}"); BlockType b = blocks[access].type; if (b == BlockType.Air) continue; + // Calculate length of run and make quads accordingly minY = j == 0; - maxY = j== Env.AREA_SIZE_1; - kS = (k&255) << 16; // pre bit shift for packing in AppendQuad functions - kS1 = (k1&255) << 16; + maxY = j == Env.AREA_SIZE_1; + kS = (k & 255) << 16; // pre bit shift for packing in AppendQuad functions + kS1 = (k1 & 255) << 16; y = j + chunkY; texture = BlockData.BlockToTexture[(int)b]; accessIncremented = access + 1; j1 = j + 1; - jS = (j&255) << 8; - jS1 = (j1&255) << 8; + jS = (j & 255) << 8; + jS1 = (j1 & 255) << 8; // Left (X-) if (!visitedXN[access] && TerrainUtilities.VisibleFaceXN(j, access, minX, kBPS2, ref blocks, ref neighborXN)) { visitedXN[access] = true; chunkAccess = accessIncremented; - + for (length = jS1; length < Env.AREA_SIZE_SHIFTED; length += (1 << 8)) { if (blocks[chunkAccess].type != b) @@ -249,12 +262,12 @@ public void Execute(int index) visitedXN[chunkAccess++] = true; } - + AppendQuadX(ref vertexBuffer, ref indices, ref numFaces, i, jS, length, kS, kS1, (int)FaceDirectionShifted.xn, texture); } - + // Right (X+) - if (!visitedXP[access] && TerrainUtilities.VisibleFaceXP(j, access, maxX, kBPS2,ref blocks, ref neighborXP)) + if (!visitedXP[access] && TerrainUtilities.VisibleFaceXP(j, access, maxX, kBPS2, ref blocks, ref neighborXP)) { visitedXP[access] = true; @@ -271,7 +284,7 @@ public void Execute(int index) AppendQuadX(ref vertexBuffer, ref indices, ref numFaces, i1, jS, length, kS1, kS, (int)FaceDirectionShifted.xp, texture); } // Back (Z-) - if (!visitedZN[access] && TerrainUtilities.VisibleFaceZN(j, access, minZ, iBPS,ref blocks, ref neighborZN)) + if (!visitedZN[access] && TerrainUtilities.VisibleFaceZN(j, access, minZ, iBPS, ref blocks, ref neighborZN)) { visitedZN[access] = true; @@ -289,7 +302,7 @@ public void Execute(int index) } // Front (Z+) - if (!visitedZP[access] && TerrainUtilities.VisibleFaceZP(j, access, maxZ, iBPS,ref blocks, ref neighborZP)) + if (!visitedZP[access] && TerrainUtilities.VisibleFaceZP(j, access, maxZ, iBPS, ref blocks, ref neighborZP)) { visitedZP[access] = true; @@ -306,7 +319,7 @@ public void Execute(int index) AppendQuadZ(ref vertexBuffer, ref indices, ref numFaces, i1, i, jS, length, kS1, (int)FaceDirectionShifted.zp, texture); } // Bottom (Y-) - if (!visitedYN[access] && TerrainUtilities.VisibleFaceYN(access, minY, iBPS, kBPS2,ref blocks, ref neighborYN)) + if (!visitedYN[access] && TerrainUtilities.VisibleFaceYN(access, minY, iBPS, kBPS2, ref blocks, ref neighborYN)) { visitedYN[access] = true; @@ -325,7 +338,7 @@ public void Execute(int index) } // Top (Y+) - if (!visitedYP[access] && TerrainUtilities.VisibleFaceYP(access, maxY, iBPS, kBPS2,ref blocks, ref neighborYP)) + if (!visitedYP[access] && TerrainUtilities.VisibleFaceYP(access, maxY, iBPS, kBPS2, ref blocks, ref neighborYP)) { visitedYP[access] = true; @@ -342,7 +355,7 @@ public void Execute(int index) } AppendQuadY(ref vertexBuffer, ref indices, ref numFaces, i, length, jS1, kS, kS1, (int)FaceDirectionShifted.yp, texture); } - + } // Extend if necessary if (numFaces * 4 > currentVertexBufferSize - 2048) @@ -355,7 +368,7 @@ public void Execute(int index) } } } - + //Debug.Log($"Terrain area {terrainArea.location} now has {numFaces} faces"); meshData.SetVertexBufferParams(numFaces * 4, vertexLayout); meshData.SetIndexBufferParams(numFaces * 6, IndexFormat.UInt16); @@ -375,16 +388,16 @@ private enum FaceDirectionShifted zp = 4 << 29, zn = 5 << 29, } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AppendQuadX(ref NativeArray vertexBuffer, ref NativeArray indices, ref int numFaces, int x, int jBottom, int jTop, int kLeft, int kRight, int normal, int texture) { - var shared = x | + var shared = x | texture | normal; int vb = numFaces * 4; vertexBuffer[vb] = jBottom | kLeft | shared; // bl - vertexBuffer[vb + 1] = jBottom | kRight| shared; // br + vertexBuffer[vb + 1] = jBottom | kRight | shared; // br vertexBuffer[vb + 2] = jTop | kRight | shared; // tr vertexBuffer[vb + 3] = jTop | kLeft | shared; // tl @@ -396,11 +409,11 @@ public void AppendQuadX(ref NativeArray vertexBuffer, ref NativeArray vertexBuffer, ref NativeArray indices, ref int numFaces, int xBottom, int xTop, int y, int zLeft, int zRight, int normal, int texture) { - var shared = y | // x is not shifted, y is shifted by 8, z by 16 + var shared = y | // x is not shifted, y is shifted by 8, z by 16 texture | // texture by 24 normal; // normal by 29 @@ -409,7 +422,7 @@ public void AppendQuadY(ref NativeArray vertexBuffer, ref NativeArray vertexBuffer, ref NativeArray vertexBuffer, ref NativeArray indices, ref int numFaces, int xBottom, int xTop, int yLeft, int yRight, int z, int normal, int texture) { - var shared = z | + var shared = z | texture | normal; diff --git a/Assets/Scripts/Statistics/GameStatistics.cs b/Assets/Scripts/Statistics/GameStatistics.cs index 8ce87256..b12c0cca 100644 --- a/Assets/Scripts/Statistics/GameStatistics.cs +++ b/Assets/Scripts/Statistics/GameStatistics.cs @@ -24,10 +24,11 @@ public partial struct StatisticsSystem : ISystem private EntityQuery _terrainAreaQuery; private EntityQuery _playerQuery; private bool first; - + public static ProfilerMarker _markerStatsSystem = new ProfilerMarker("StatisticsSystem"); + public void OnCreate(ref SystemState state) { - _terrainAreaQuery= new EntityQueryBuilder(Allocator.Temp) + _terrainAreaQuery = new EntityQueryBuilder(Allocator.Temp) .WithAll() .Build(state.EntityManager); _playerQuery = new EntityQueryBuilder(Allocator.Temp) @@ -35,19 +36,25 @@ public void OnCreate(ref SystemState state) .Build(state.EntityManager); first = true; } - + public void OnUpdate(ref SystemState state) { + _markerStatsSystem.Begin(); if (first) { if (ApplicationConfig.LogStats) { Debug.Log("Adding terrain areas statistics recorders"); PolkaDOTS.Statistics.StatisticsWriter writer = PolkaDOTS.Statistics.StatisticsWriterInstance.instance; + if (ApplicationConfig.ActiveLogic) + { + writer.AddStatisticRecorder(GameStatistics.NumGateBlocksName, ProfilerCategory.Scripts); + writer.AddStatisticRecorder(GameStatistics.NumInputTypeBlocksName, ProfilerCategory.Scripts); + } writer.AddStatisticRecorder("Number of Terrain Areas (Client)", ProfilerCategory.Scripts); - writer.AddStatisticRecorder("Number of Terrain Areas (Server)", ProfilerCategory.Scripts); + writer.AddStatisticRecorder("Number of Terrain Areas (Server)", ProfilerCategory.Scripts); writer.AddStatisticRecorder("Number of Players (Client)", ProfilerCategory.Scripts); - writer.AddStatisticRecorder("Number of Players (Server)", ProfilerCategory.Scripts); + writer.AddStatisticRecorder("Number of Players (Server)", ProfilerCategory.Scripts); } first = false; } @@ -65,36 +72,45 @@ public void OnUpdate(ref SystemState state) GameStatistics.NumTerrainAreasServer.Value = terrainCount; GameStatistics.NumPlayersServer.Value = playerCount; } - - - + _markerStatsSystem.End(); } } - + /// /// Profiler module for game-specific performance data /// public class GameStatistics { public static readonly ProfilerCategory GameStatisticsCategory = ProfilerCategory.Scripts; - + public const string NumTerrainAreasClientName = "Number of Terrain Areas (Client)"; public static readonly ProfilerCounterValue NumTerrainAreasClient = new ProfilerCounterValue(GameStatisticsCategory, NumTerrainAreasClientName, ProfilerMarkerDataUnit.Count); + public const string NumTerrainAreasServerName = "Number of Terrain Areas (Server)"; public static readonly ProfilerCounterValue NumTerrainAreasServer = new ProfilerCounterValue(GameStatisticsCategory, NumTerrainAreasServerName, ProfilerMarkerDataUnit.Count); + public const string NumPlayersClientName = "Number of Players (Client)"; public static readonly ProfilerCounterValue NumPlayersClient = new ProfilerCounterValue(GameStatisticsCategory, NumPlayersClientName, ProfilerMarkerDataUnit.Count); + public const string NumPlayersServerName = "Number of Players (Server)"; public static readonly ProfilerCounterValue NumPlayersServer = new ProfilerCounterValue(GameStatisticsCategory, NumPlayersServerName, ProfilerMarkerDataUnit.Count); - + + public const string NumGateBlocksName = "NumGateBlocks"; + public static readonly ProfilerCounterValue NumGateTypeBlocks = + new ProfilerCounterValue(GameStatisticsCategory, NumGateBlocksName, ProfilerMarkerDataUnit.Count); + + public const string NumInputTypeBlocksName = "NumInputTypeBlocks"; + public static readonly ProfilerCounterValue NumInputTypeBlocks = + new ProfilerCounterValue(GameStatisticsCategory, NumInputTypeBlocksName, ProfilerMarkerDataUnit.Count); + } #if UNITY_EDITOR [System.Serializable] - [ProfilerModuleMetadata("Game Statistics")] + [ProfilerModuleMetadata("Game Statistics")] public class GameProfilerModule : ProfilerModule { static readonly ProfilerCounterDescriptor[] k_Counters = new ProfilerCounterDescriptor[] @@ -102,7 +118,9 @@ public class GameProfilerModule : ProfilerModule new ProfilerCounterDescriptor(GameStatistics.NumTerrainAreasClientName, GameStatistics.GameStatisticsCategory), new ProfilerCounterDescriptor(GameStatistics.NumTerrainAreasServerName, GameStatistics.GameStatisticsCategory), new ProfilerCounterDescriptor(GameStatistics.NumPlayersClientName, GameStatistics.GameStatisticsCategory), - new ProfilerCounterDescriptor(GameStatistics.NumPlayersServerName, GameStatistics.GameStatisticsCategory) + new ProfilerCounterDescriptor(GameStatistics.NumPlayersServerName, GameStatistics.GameStatisticsCategory), + new ProfilerCounterDescriptor(GameStatistics.NumGateBlocksName, GameStatistics.GameStatisticsCategory), + new ProfilerCounterDescriptor(GameStatistics.NumInputTypeBlocksName, GameStatistics.GameStatisticsCategory), }; // Ensure that both ProfilerCategory.Scripts and ProfilerCategory.Memory categories are enabled when our module is active. @@ -116,5 +134,5 @@ public class GameProfilerModule : ProfilerModule public GameProfilerModule() : base(k_Counters, autoEnabledCategoryNames: k_AutoEnabledCategoryNames) { } } #endif - + } \ No newline at end of file diff --git a/Assets/Scripts/Terrain/Authoring/TerrainAreaAuthoring.cs b/Assets/Scripts/Terrain/Authoring/TerrainAreaAuthoring.cs index 66ba62c3..84eb246a 100644 --- a/Assets/Scripts/Terrain/Authoring/TerrainAreaAuthoring.cs +++ b/Assets/Scripts/Terrain/Authoring/TerrainAreaAuthoring.cs @@ -28,13 +28,16 @@ public override void Bake(TerrainAreaAuthoring authoring) AddComponent(entity); AddComponent(entity); SetComponentEnabled(entity, true); - + AddComponent(entity); - + AddComponent(entity); SetComponentEnabled(entity, false); - + AddBuffer(entity); + AddBuffer(entity); + AddBuffer(entity); + AddBuffer(entity); AddBuffer(entity); AddBuffer(entity); AddBuffer(entity); @@ -70,7 +73,7 @@ public struct NewSpawn : IComponentData, IEnableableComponent public struct Remesh : IComponentData, IEnableableComponent { } - + // Remesh component marks an entity as having structures to be generated public struct GenStructures : IComponentData, IEnableableComponent { @@ -83,21 +86,39 @@ public struct TerrainBlocks : IBufferElementData { [GhostField] public BlockType type; } - + + [InternalBufferCapacity(4096)] + public struct BlockLogicState : IBufferElementData + { + [GhostField] public bool logicState; + } + + [InternalBufferCapacity(0)] + public struct BlockDirection : IBufferElementData + { + [GhostField] public Direction direction; + } + + [InternalBufferCapacity(0)] + public struct TerrainBlockUpdates : IBufferElementData + { + [GhostField] public int3 blockLoc; + } + [InternalBufferCapacity(256)] // The buffer component to store heightmap column min public struct TerrainColMinY : IBufferElementData { [GhostField] public byte minY; } - + [InternalBufferCapacity(256)] // The buffer component to store heightmap column max public struct TerrainColMaxY : IBufferElementData { [GhostField] public byte maxY; } - + [InternalBufferCapacity(32)] // Buffer of terrain area structures we need to spawn but haven't yet public struct TerrainStructuresToSpawn : IBufferElementData @@ -109,8 +130,8 @@ public struct TerrainStructuresToSpawn : IBufferElementData public int noise; public int3 offset; } - - + + } diff --git a/Assets/Scripts/Terrain/Blocks/BlockType.cs b/Assets/Scripts/Terrain/Blocks/BlockType.cs index 7f59c09e..4550ec74 100644 --- a/Assets/Scripts/Terrain/Blocks/BlockType.cs +++ b/Assets/Scripts/Terrain/Blocks/BlockType.cs @@ -1,17 +1,38 @@ -namespace Opencraft.Terrain.Blocks +using System; +using Unity.Mathematics; + +namespace Opencraft.Terrain.Blocks { // The enum of all supported types public enum BlockType : byte { Air, + Off_Input, + On_Input, + Clock, + AND_Gate, + OR_Gate, + NOT_Gate, + XOR_Gate, Stone, Dirt, Tin, Gem, Grass, Leaf, - Wood + Wood, + Unbreakable, + Off_Wire, + On_Wire, + Off_Lamp, + On_Lamp, } + + public enum Direction : byte + { + XP, XN, YP, YN, ZP, ZN + } + public static class BlockData { // Maps BlockType to texture array index, currently 1 to 1 @@ -25,14 +46,129 @@ public static class BlockData (5 & 31) << 24, (6 & 31) << 24, (7 & 31) << 24, + (8 & 31) << 24, + (9 & 31) << 24, + (10 & 31) << 24, + (11 & 31) << 24, + (12 & 31) << 24, + (13 & 31) << 24, + (14 & 31) << 24, + (15 & 31) << 24, + (16 & 31) << 24, + (17 & 31) << 24, + (18 & 31) << 24, + (19 & 31) << 24, }; - + // UV sizing > 1 tiles a texture across multiple blocks, currently not done for any block types - public static float[] BlockUVSizing= new float[] + public static float[] BlockUVSizing = new float[] + { + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f + }; + + public static readonly bool[] CanReceiveLogic = new bool[] + { + false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, + }; + + public static bool IsLogic(BlockType type) + { + return IsInput(type) || IsGate(type) || type == BlockType.Off_Wire || type == BlockType.On_Wire || type == BlockType.Off_Lamp || type == BlockType.On_Lamp; + } + + public static bool IsGate(BlockType type) + { + return IsTwoInputGate(type) || type == BlockType.NOT_Gate; + } + public static bool IsTwoInputGate(BlockType type) + { + return type == BlockType.AND_Gate || type == BlockType.OR_Gate || type == BlockType.XOR_Gate; + } + public static bool IsTransmitter(BlockType type) + { + return type == BlockType.On_Wire || type == BlockType.On_Input || type == BlockType.Clock; + } + + public static bool IsInput(BlockType type) + { + return type == BlockType.On_Input || type == BlockType.Off_Input || type == BlockType.Clock; + } + + public static readonly BlockType[] OffState = new BlockType[] + { + BlockType.Air, + BlockType.Off_Input, + BlockType.On_Input, + BlockType.Clock, + BlockType.AND_Gate, + BlockType.OR_Gate, + BlockType.NOT_Gate, + BlockType.XOR_Gate, + BlockType.Stone, + BlockType.Dirt, + BlockType.Tin, + BlockType.Gem, + BlockType.Grass, + BlockType.Leaf, + BlockType.Wood, + BlockType.Unbreakable, + BlockType.Off_Wire, + BlockType.Off_Wire, + BlockType.Off_Lamp, + BlockType.Off_Lamp, + }; + public static readonly BlockType[] OnState = new BlockType[] + { + BlockType.Air, + BlockType.Off_Input, + BlockType.On_Input, + BlockType.Clock, + BlockType.AND_Gate, + BlockType.OR_Gate, + BlockType.NOT_Gate, + BlockType.XOR_Gate, + BlockType.Stone, + BlockType.Dirt, + BlockType.Tin, + BlockType.Gem, + BlockType.Grass, + BlockType.Leaf, + BlockType.Wood, + BlockType.Unbreakable, + BlockType.On_Wire, + BlockType.On_Wire, + BlockType.On_Lamp, + BlockType.On_Lamp, + }; + + public static readonly int3[] Int3Directions = new int3[] + { + new int3(-1, 0, 0), + new int3(1, 0, 0), + new int3(0, -1, 0), + new int3(0, 1, 0), + new int3(0, 0, -1), + new int3(0, 0, 1) + }; + + public static readonly Direction[] AllDirections = new Direction[] + { + Direction.XP, + Direction.XN, + Direction.YP, + Direction.YN, + Direction.ZP, + Direction.ZN + }; + + public static readonly Direction[] OppositeDirections = new Direction[] { - 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f + Direction.XN, + Direction.XP, + Direction.YN, + Direction.YP, + Direction.ZN, + Direction.ZP, }; } - - } \ No newline at end of file diff --git a/Assets/Scripts/Terrain/Layers/LayerConfig.cs b/Assets/Scripts/Terrain/Layers/LayerConfig.cs index dc47934e..8cd2cec3 100644 --- a/Assets/Scripts/Terrain/Layers/LayerConfig.cs +++ b/Assets/Scripts/Terrain/Layers/LayerConfig.cs @@ -19,41 +19,41 @@ public class LayerConfig : ScriptableObject private int index = 0; [SerializeField] [Tooltip("The block this layer will create.")] - [DrawIf("layerType", new[]{LayerType.Absolute, LayerType.Additive, LayerType.Random, LayerType.Surface})] + [DrawIf("layerType", new[] { LayerType.Absolute, LayerType.Additive, LayerType.Random, LayerType.Surface, LayerType.Calculated_Layer })] private BlockType blockType; - + [SerializeField] [Tooltip("Noise parameter.")] - [DrawIf("layerType", new[]{LayerType.Absolute, LayerType.Additive})] + [DrawIf("layerType", new[] { LayerType.Absolute, LayerType.Additive })] private float frequency = 0f; [SerializeField] [Tooltip("Noise parameter.")] - [DrawIf("layerType", new[]{LayerType.Absolute, LayerType.Additive})] + [DrawIf("layerType", new[] { LayerType.Absolute, LayerType.Additive })] private float exponent = 0f; - + /*[SerializeField] [Tooltip("Level to start randomly sampling at. (MinHeight to MinHeight+BaseHeight gets filled)")] [DrawIf("layerType", new[]{LayerType.Absolute, LayerType.Additive})] private int baseHeight = 0;*/ [SerializeField] [Tooltip("Lowest possible column floor.")] - [DrawIf("layerType", new[]{LayerType.Absolute, LayerType.Additive})] + [DrawIf("layerType", new[] { LayerType.Absolute, LayerType.Additive })] private int minHeight = 0; [SerializeField] [Tooltip("Highest possible column ceiling.")] - [DrawIf("layerType", new[]{LayerType.Absolute, LayerType.Additive})] + [DrawIf("layerType", new[] { LayerType.Absolute, LayerType.Additive })] private int maxHeight = 0; - + [SerializeField] [Tooltip("Likelihood of spawning.")] - [DrawIf("layerType", new[]{LayerType.Structure, LayerType.Random})] + [DrawIf("layerType", new[] { LayerType.Structure, LayerType.Random })] private float chance = 0; [SerializeField] [Tooltip("Structure to spawn.")] [DrawIf("layerType", LayerType.Structure)] private StructureType structureType = StructureType.None; - - + + public LayerType LayerType => layerType; public string LayerName => layerName; public int Index => index; @@ -73,6 +73,7 @@ public enum LayerType Random, Structure, Surface, - Additive + Additive, + Calculated_Layer, } } \ No newline at end of file diff --git a/Assets/Scripts/Terrain/Layers/TerrainGenerationConfiguration.cs b/Assets/Scripts/Terrain/Layers/TerrainGenerationConfiguration.cs index 7bf0e2d4..b43f446e 100644 --- a/Assets/Scripts/Terrain/Layers/TerrainGenerationConfiguration.cs +++ b/Assets/Scripts/Terrain/Layers/TerrainGenerationConfiguration.cs @@ -9,7 +9,7 @@ public class TerrainGenerationConfiguration : ScriptableObject { [SerializeField] private string configName = ""; - + [SerializeField] private LayerConfig[] layers = null; @@ -17,7 +17,7 @@ public class TerrainGenerationConfiguration : ScriptableObject private int areaColumnHeight = 1; public string Name => configName; - + public LayerConfig[] Layers { get { return layers; } } public int AreaColumnHeight @@ -30,9 +30,9 @@ public void SortLayers() Array.Sort(layers, new LayerConfigComparer()); } } - + // Comparer for sorting locations by distance from zero - struct LayerConfigComparer: IComparer + struct LayerConfigComparer : IComparer { public int Compare(LayerConfig a, LayerConfig b) { @@ -44,7 +44,7 @@ public int Compare(LayerConfig a, LayerConfig b) return 0; if (a.Index > b.Index) return 1; - if (a.Index < b.Index ) + if (a.Index < b.Index) return -1; return 0; } diff --git a/Assets/Scripts/Terrain/SetWorldParametersSystem.cs b/Assets/Scripts/Terrain/SetWorldParametersSystem.cs index b9404cae..b1156fed 100644 --- a/Assets/Scripts/Terrain/SetWorldParametersSystem.cs +++ b/Assets/Scripts/Terrain/SetWorldParametersSystem.cs @@ -20,7 +20,7 @@ public void OnCreate(ref SystemState state) state.RequireForUpdate(); _worldConfigName = new FixedString128Bytes(GameConfig.TerrainType.Value); } - + public void OnUpdate(ref SystemState state) { TerrainBank terrain = TerrainBankSingleton.Instance; @@ -36,32 +36,32 @@ public void OnUpdate(ref SystemState state) TerrainSpawner terrainSpawner = SystemAPI.GetSingleton(); EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.Temp); Entity terrainConfigEntity = ecb.Instantiate(terrainSpawner.TerrainConfiguration); - ecb.SetComponent(terrainConfigEntity, new WorldParameters { ColumnHeight = config.AreaColumnHeight}); - - foreach(var layer in config.Layers) + ecb.SetComponent(terrainConfigEntity, new WorldParameters { ColumnHeight = config.AreaColumnHeight }); + + foreach (var layer in config.Layers) { Entity layerEntity = ecb.CreateEntity(); - + ecb.AddComponent(layerEntity, new TerrainGenerationLayer { - layerType=layer.LayerType, - index=layer.Index, - blockType=layer.BlockType, + layerType = layer.LayerType, + index = layer.Index, + blockType = layer.BlockType, structureType = layer.StructureType, frequency = layer.Frequency, - exponent =layer.Exponent, + exponent = layer.Exponent, //baseHeight = layer.BaseHeight, minHeight = layer.MinHeight, - maxHeight= layer.MaxHeight, + maxHeight = layer.MaxHeight, amplitude = layer.MaxHeight - layer.MinHeight, chance = layer.Chance, }); } - + ecb.Playback(state.EntityManager); ecb.Dispose(); state.Enabled = false; } - + } } \ No newline at end of file diff --git a/Assets/Scripts/Terrain/TerrainConfig.cs b/Assets/Scripts/Terrain/TerrainConfig.cs index e21b619e..92cd1524 100644 --- a/Assets/Scripts/Terrain/TerrainConfig.cs +++ b/Assets/Scripts/Terrain/TerrainConfig.cs @@ -4,28 +4,25 @@ public static class Env { // 2^AREA_POW = blocks per area side public const int AREA_POW = 4; - + public const int INITIAL_COLUMNS_X = 3; public const int INITIAL_COLUMNS_Z = 3; public const int PLAYER_VIEW_RANGE = 2; public const int TERRAIN_SPAWN_RANGE = 3; public const int MAX_COL_PER_TICK = 10; - + #region DO NOT CHANGE THESE! public const float CAMERA_Y_OFFSET = 0.5f; - - public const int AREA_POW_2 = AREA_POW << 1; - public const int AREA_MASK = (1 << AREA_POW_2) - 1; - + public const int AREA_PADDING = 1; public const int AREA_PADDING_2 = AREA_PADDING * 2; // Visible chunk size - public const int AREA_SIZE = 1 << AREA_POW; - public const int AREA_SIZE_1 = AREA_SIZE - 1; - public const int AREA_SIZE_POW_2 = AREA_SIZE * AREA_SIZE; - public const int AREA_SIZE_POW_3 = AREA_SIZE * AREA_SIZE_POW_2; + public const int AREA_SIZE = 1 << AREA_POW; // 16 + public const int AREA_SIZE_1 = AREA_SIZE - 1; // 15 + public const int AREA_SIZE_POW_2 = AREA_SIZE * AREA_SIZE; // 256 + public const int AREA_SIZE_POW_3 = AREA_SIZE * AREA_SIZE_POW_2; // 4096 public const int AREA_SIZE_SHIFTED = (AREA_SIZE & 255) << 8; // Internal chunk size (visible size + padding) @@ -36,6 +33,6 @@ public static class Env #endregion } - - + + } \ No newline at end of file diff --git a/Assets/Scripts/Terrain/TerrainGenerationSystem.cs b/Assets/Scripts/Terrain/TerrainGenerationSystem.cs index 622df830..3a3ba0ec 100644 --- a/Assets/Scripts/Terrain/TerrainGenerationSystem.cs +++ b/Assets/Scripts/Terrain/TerrainGenerationSystem.cs @@ -18,11 +18,14 @@ using Unity.Profiling; using System.Security.Cryptography; using System.Text; +using UnityEngine; // Annoyingly this assembly directive must be outside the namespace. [assembly: RegisterGenericJobType(typeof(SortJob))] namespace Opencraft.Terrain { + + [WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)] [UpdateInGroup(typeof(SimulationSystemGroup))] [BurstCompile] @@ -35,11 +38,18 @@ public partial struct TerrainGenerationSystem : ISystem private ComponentLookup _terrainAreaLookup; private ComponentLookup _localTransformLookup; private BufferLookup _terrainBlocksLookup; + private BufferLookup _terrainLogicStateLookup; + private BufferLookup _terrainDirectionLookup; + private BufferLookup _terrainUpdateLookup; private BufferLookup _terrainColMinLookup; private BufferLookup _terrainColMaxLookup; private BufferLookup _structuresToSpawnLookup; - private int _hashedSeed; + private int circuitX; + private int circuitZ; + private NativeArray terrainAreasEntities; + private NativeArray terrainAreas; + //private double lastUpdate; public void OnCreate(ref SystemState state) @@ -55,35 +65,44 @@ public void OnCreate(ref SystemState state) _terrainAreaLookup = state.GetComponentLookup(isReadOnly: false); _localTransformLookup = state.GetComponentLookup(isReadOnly: false); _terrainBlocksLookup = state.GetBufferLookup(isReadOnly: false); + _terrainLogicStateLookup = state.GetBufferLookup(isReadOnly: false); + _terrainDirectionLookup = state.GetBufferLookup(isReadOnly: false); + _terrainUpdateLookup = state.GetBufferLookup(isReadOnly: false); _terrainColMinLookup = state.GetBufferLookup(isReadOnly: false); _terrainColMaxLookup = state.GetBufferLookup(isReadOnly: false); _structuresToSpawnLookup = state.GetBufferLookup(isReadOnly: false); - + // Seed MD5 md5Hasher = MD5.Create(); var hashed = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(ApplicationConfig.Seed.Value)); _hashedSeed = BitConverter.ToInt32(hashed, 0); - + circuitX = ApplicationConfig.CircuitX.Value; + circuitZ = ApplicationConfig.CircuitZ.Value; } public void OnDestroy(ref SystemState state) { _terrainGenLayers.Dispose(); } - + //[BurstCompile] public void OnUpdate(ref SystemState state) { if (!_terrainGenLayers.IsCreated) { - _terrainGenLayers= SystemAPI.QueryBuilder().WithAll().Build().ToComponentDataArray(Allocator.Persistent); + _terrainGenLayers = SystemAPI.QueryBuilder().WithAll().Build().ToComponentDataArray(Allocator.Persistent); } + + var terrainAreasQuery = SystemAPI.QueryBuilder().WithAll().Build(); + terrainAreasEntities = terrainAreasQuery.ToEntityArray(state.WorldUpdateAllocator); + terrainAreas = terrainAreasQuery.ToComponentDataArray(state.WorldUpdateAllocator); + /*if (state.World.Time.ElapsedTime - lastUpdate < 1.0) { return; } lastUpdate = state.World.Time.ElapsedTime;*/ - + // Disable the NewSpawn tag component from the areas we populated in the previous tick state.EntityManager.SetComponentEnabled(_newSpawnQuery, false); @@ -93,7 +112,7 @@ public void OnUpdate(ref SystemState state) Entity terrainSpawnerEntity = SystemAPI.GetSingletonEntity(); int columnHeight = worldParameters.ColumnHeight; int worldHeight = columnHeight * Env.AREA_SIZE; - + // Fetch what chunks to spawn this tick var toSpawnbuffer = SystemAPI.GetBuffer(terrainSpawnerEntity); DynamicBuffer chunksColumnsSpawnBuffer = toSpawnbuffer.Reinterpret(); @@ -110,24 +129,31 @@ public void OnUpdate(ref SystemState state) // Spawn the terrain area entities int numColumnsToSpawn = columnsToSpawn.Length > Env.MAX_COL_PER_TICK - ? Env.MAX_COL_PER_TICK + ? Env.MAX_COL_PER_TICK : columnsToSpawn.Length; NativeArray terrainAreaEntities = state.EntityManager.Instantiate(terrainSpawner.TerrainArea, numColumnsToSpawn * columnHeight, Allocator.TempJob); _terrainBlocksLookup.Update(ref state); + _terrainLogicStateLookup.Update(ref state); + _terrainDirectionLookup.Update(ref state); + _terrainUpdateLookup.Update(ref state); _terrainColMinLookup.Update(ref state); _terrainColMaxLookup.Update(ref state); _structuresToSpawnLookup.Update(ref state); EntityCommandBuffer ecb = new EntityCommandBuffer(Allocator.TempJob); EntityCommandBuffer.ParallelWriter parallelEcb = ecb.AsParallelWriter(); - + // Populate new terrain areas on worker threads JobHandle populateHandle = new PopulateTerrainColumns { + terrainAreaEntities = terrainAreaEntities, ecb = parallelEcb, terrainBlocksLookup = _terrainBlocksLookup, + terrainLogicStateLookup = _terrainLogicStateLookup, + terrainDirectionLookup = _terrainDirectionLookup, + terrainUpdateLookup = _terrainUpdateLookup, terrainColMinLookup = _terrainColMinLookup, terrainColMaxLookup = _terrainColMaxLookup, _structuresToSpawnLookup = _structuresToSpawnLookup, @@ -135,7 +161,10 @@ public void OnUpdate(ref SystemState state) noiseSeed = _hashedSeed, worldHeight = worldHeight, columnHeight = columnHeight, - terrainGenLayers = _terrainGenLayers + terrainGenLayers = _terrainGenLayers, + circuitX = circuitX, + circuitZ = circuitZ + }.Schedule(numColumnsToSpawn, 1, sortHandle); // Each thread gets 1 column populateHandle.Complete(); terrainAreaEntities.Dispose(); @@ -143,8 +172,8 @@ public void OnUpdate(ref SystemState state) //localTransforms.Dispose(); // Remove spawned areas from the toSpawn buffer - if (chunksColumnsSpawnBuffer.Length > Env.MAX_COL_PER_TICK) - chunksColumnsSpawnBuffer.RemoveRange(0, Env.MAX_COL_PER_TICK); + if (chunksColumnsSpawnBuffer.Length > Env.MAX_COL_PER_TICK) + chunksColumnsSpawnBuffer.RemoveRange(0, Env.MAX_COL_PER_TICK); else chunksColumnsSpawnBuffer.Clear(); ecb.Playback(state.EntityManager); @@ -175,9 +204,12 @@ partial struct PopulateTerrainColumns : IJobParallelFor [ReadOnly] public NativeArray terrainAreaEntities; [ReadOnly] public NativeArray columnsToSpawn; - + public EntityCommandBuffer.ParallelWriter ecb; [NativeDisableParallelForRestriction] public BufferLookup terrainBlocksLookup; + [NativeDisableParallelForRestriction] public BufferLookup terrainLogicStateLookup; + [NativeDisableParallelForRestriction] public BufferLookup terrainDirectionLookup; + [NativeDisableParallelForRestriction] public BufferLookup terrainUpdateLookup; [NativeDisableParallelForRestriction] public BufferLookup terrainColMinLookup; [NativeDisableParallelForRestriction] public BufferLookup terrainColMaxLookup; [NativeDisableParallelForRestriction] public BufferLookup _structuresToSpawnLookup; @@ -185,7 +217,9 @@ partial struct PopulateTerrainColumns : IJobParallelFor public int columnHeight; public int worldHeight; [ReadOnly] public NativeArray terrainGenLayers; - + public int circuitX; + public int circuitZ; + [BurstCompile] public void Execute(int jobIndex) { @@ -193,13 +227,13 @@ public void Execute(int jobIndex) int2 columnToSpawn = columnsToSpawn[jobIndex]; int columnX = columnToSpawn.x * Env.AREA_SIZE; int columnZ = columnToSpawn.y * Env.AREA_SIZE; - + // Preprocess terrain generation layers to create noise lookup tables NativeArray> terrainLayerLookupTables = new NativeArray>(terrainGenLayers.Length, Allocator.Temp); - + NoiseUtilities.NoiseInterpolatorSettings noiseInterpSettings = new NoiseUtilities.NoiseInterpolatorSettings(); - NoiseUtilities.GetNoiseInterpolatorSettings( ref noiseInterpSettings, Env.AREA_SIZE_WITH_PADDING, downsamplingFactor:2); + NoiseUtilities.GetNoiseInterpolatorSettings(ref noiseInterpSettings, Env.AREA_SIZE_WITH_PADDING, downsamplingFactor: 2); for (int i = 0; i < terrainGenLayers.Length; i++) { TerrainGenerationLayer terrainGenLayer = terrainGenLayers[i]; @@ -217,9 +251,9 @@ public void Execute(int jobIndex) for (int x = 0; x < noiseInterpSettings.size; x++) { float xf = (x << noiseInterpSettings.step) + columnX; - lut[j++] = NoiseUtilities.GetNoise(xf, 0.0f, zf, noiseSeed,1f, - terrainGenLayer.amplitude,terrainGenLayer.exponent, terrainGenLayer.frequency, - FastNoise.NoiseType.Simplex); + lut[j++] = NoiseUtilities.GetNoise(xf, 0.0f, zf, noiseSeed, 1f, + terrainGenLayer.amplitude, terrainGenLayer.exponent, terrainGenLayer.frequency, + FastNoise.NoiseType.Simplex); } } break; @@ -229,6 +263,8 @@ public void Execute(int jobIndex) case LayerType.Structure: // Don't need at lookup table as we only sample noise at points that get a structure break; + case LayerType.Calculated_Layer: + break; } } // Arrays of relevant components for entire terrain area column @@ -247,21 +283,29 @@ public void Execute(int jobIndex) { //Entity Entity terrainEntity = terrainAreaEntities[index + columnAreaY]; - + //TerrainArea int3 chunk = new int3(columnToSpawn.x, columnAreaY, columnToSpawn.y); - ecb.SetComponent(index + columnAreaY, terrainEntity, new TerrainArea{location = chunk}); + ecb.SetComponent(index + columnAreaY, terrainEntity, new TerrainArea { location = chunk }); //LocalTransform int areaY = columnAreaY * Env.AREA_SIZE; - ecb.SetComponent(index + columnAreaY, terrainEntity, new LocalTransform{Position = new float3(columnX, areaY, columnZ) }); - + ecb.SetComponent(index + columnAreaY, terrainEntity, new LocalTransform { Position = new float3(columnX, areaY, columnZ) }); + // Block buffer DynamicBuffer terrainBlocksBuffer = terrainBlocksLookup[terrainEntity]; terrainBlocksBuffer.Resize(Env.AREA_SIZE_POW_3, NativeArrayOptions.ClearMemory); DynamicBuffer terrainBlocks = terrainBlocksBuffer.Reinterpret(); terrainBlockBuffers[columnAreaY] = terrainBlocks; - + + // Logic Buffer + DynamicBuffer terrainLogicStateBuffer = terrainLogicStateLookup[terrainEntity]; + terrainLogicStateBuffer.Resize(Env.AREA_SIZE_POW_3, NativeArrayOptions.ClearMemory); + + // Direction Buffer + DynamicBuffer terrainDirectionBuffer = terrainDirectionLookup[terrainEntity]; + terrainDirectionBuffer.Resize(Env.AREA_SIZE_POW_3, NativeArrayOptions.ClearMemory); + // Terrain area column min buffer DynamicBuffer colMinBuffer = terrainColMinLookup[terrainEntity]; colMinBuffer.Resize(Env.AREA_SIZE_POW_3, NativeArrayOptions.UninitializedMemory); @@ -273,13 +317,13 @@ public void Execute(int jobIndex) DynamicBuffer colMin = colMinBuffer.Reinterpret(); colMinBuffers[columnAreaY] = colMin; - + //Terrain area column max buffer DynamicBuffer colMaxBuffer = terrainColMaxLookup[terrainEntity]; colMaxBuffer.Resize(Env.AREA_SIZE_POW_3, NativeArrayOptions.ClearMemory); DynamicBuffer colMax = colMaxBuffer.Reinterpret(); colMaxBuffers[columnAreaY] = colMax; - + // terrain Structures DynamicBuffer structuresToSpawnBuffer = _structuresToSpawnLookup[terrainEntity]; terrainStructureBuffers[columnAreaY] = structuresToSpawnBuffer; @@ -297,6 +341,7 @@ public void Execute(int jobIndex) int columnAccess = x + z * Env.AREA_SIZE; int heightSoFar = 0; // Start at y = 0 int startIndex = TerrainUtilities.BlockLocationToIndex(x, 0, z); + for (int i = 0; i < terrainGenLayers.Length; i++) { TerrainGenerationLayer terrainGenerationLayer = terrainGenLayers[i]; @@ -305,25 +350,30 @@ public void Execute(int jobIndex) switch (terrainGenerationLayer.layerType) { case LayerType.Absolute: - heightSoFar = GenerateAbsoluteLayer(ref terrainBlockBuffers, - ref colMinBuffers, ref colMaxBuffers, noiseInterpSettings,ref lookupTable, x, z, startIndex, + heightSoFar = GenerateAbsoluteLayer(ref terrainBlockBuffers, + ref colMinBuffers, ref colMaxBuffers, noiseInterpSettings, ref lookupTable, x, z, startIndex, heightSoFar, ref terrainGenerationLayer, columnAccess); break; case LayerType.Additive: - heightSoFar = GenerateAdditiveLayer(ref terrainBlockBuffers, - ref colMinBuffers, ref colMaxBuffers, noiseInterpSettings,ref lookupTable, x, z, startIndex, + heightSoFar = GenerateAdditiveLayer(ref terrainBlockBuffers, + ref colMinBuffers, ref colMaxBuffers, noiseInterpSettings, ref lookupTable, x, z, startIndex, heightSoFar, ref terrainGenerationLayer, columnAccess); break; case LayerType.Surface: - heightSoFar = GenerateSurfaceLayer(ref terrainBlockBuffers, + heightSoFar = GenerateSurfaceLayer(ref terrainBlockBuffers, ref colMinBuffers, ref colMaxBuffers, startIndex, heightSoFar, ref terrainGenerationLayer, columnAccess); break; case LayerType.Structure: // Structure layers do not immediately change blocks or height. Instead, // they mark that a structure should be generated at a given position - GenerateStructureLayer(ref terrainGenerationLayer, ref terrainStructureBuffers, - index,noiseInterpSettings, x,z, globalX, heightSoFar, globalZ ); + GenerateStructureLayer(ref terrainGenerationLayer, ref terrainStructureBuffers, + index, noiseInterpSettings, x, z, globalX, heightSoFar, globalZ); + break; + case LayerType.Calculated_Layer: + heightSoFar = GenerateCalculatedLayer(ref terrainBlockBuffers, + ref colMinBuffers, ref colMaxBuffers, startIndex, + heightSoFar, ref terrainGenerationLayer, columnAccess, columnX, columnZ, index); break; } } @@ -345,26 +395,26 @@ private void GenerateStructureLayer(ref TerrainGenerationLayer terrainGenLayer, if (terrainGenLayer.chance > chanceAtPos) { // Check that neighbor columns don't have this structure as well - if (NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX+1, globalY, globalZ), (byte)noiseSeed) > chanceAtPos && - NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX-1, globalY, globalZ), (byte)noiseSeed) > chanceAtPos && - NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX, globalY, globalZ+1), (byte)noiseSeed) > chanceAtPos && - NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX, globalY, globalZ-1), (byte)noiseSeed) > chanceAtPos) + if (NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX + 1, globalY, globalZ), (byte)noiseSeed) > chanceAtPos && + NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX - 1, globalY, globalZ), (byte)noiseSeed) > chanceAtPos && + NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX, globalY, globalZ + 1), (byte)noiseSeed) > chanceAtPos && + NoiseUtilities.RandomPrecise(TerrainUtilities.BlockLocationHash(globalX, globalY, globalZ - 1), (byte)noiseSeed) > chanceAtPos) { - - int noise = NoiseUtilities.FastFloor(NoiseUtilities.GetNoise(globalX, globalY, globalZ, noiseSeed,1f, - Structure.StructureToNoiseRange(terrainGenLayer.structureType),1f, 1f, + + int noise = NoiseUtilities.FastFloor(NoiseUtilities.GetNoise(globalX, globalY, globalZ, noiseSeed, 1f, + Structure.StructureToNoiseRange(terrainGenLayer.structureType), 1f, 1f, FastNoise.NoiseType.Simplex)); // Mark that we need to spawn a structure here structuresToSpawn.Add(new TerrainStructuresToSpawn - { - basePos = new int3(localX, localY, localZ), - structureType = terrainGenLayer.structureType, - extentsPos = Structure.StructureToExtents(terrainGenLayer.structureType, negativeBounds: false), - extentsNeg = Structure.StructureToExtents(terrainGenLayer.structureType, negativeBounds: true), - noise = noise, - offset = new int3(0) - }); - ecb.SetComponentEnabled(index, terrainAreaEntities[index + colY], true); + { + basePos = new int3(localX, localY, localZ), + structureType = terrainGenLayer.structureType, + extentsPos = Structure.StructureToExtents(terrainGenLayer.structureType, negativeBounds: false), + extentsNeg = Structure.StructureToExtents(terrainGenLayer.structureType, negativeBounds: true), + noise = noise, + offset = new int3(0) + }); + ecb.SetComponentEnabled(index, terrainAreaEntities[index + colY], true); } } } @@ -395,65 +445,142 @@ private int GenerateAbsoluteLayer(ref NativeArray> terr return heightSoFar; } - + private int GenerateAdditiveLayer(ref NativeArray> terrainBlockBuffers, ref NativeArray> colMinBuffers, ref NativeArray> colMaxBuffers, NoiseUtilities.NoiseInterpolatorSettings nis, ref NativeArray lut, int x, int z, int blockIndex, int heightSoFar, ref TerrainGenerationLayer terrainGenLayer, int columnAccess) { - int heightToAdd= terrainGenLayer.minHeight + (int)(NoiseUtilities.Interpolate(nis, x, z, lut)); - - - int end = heightSoFar + heightToAdd < worldHeight ? heightSoFar + heightToAdd: worldHeight; + int heightToAdd = terrainGenLayer.minHeight + (int)(NoiseUtilities.Interpolate(nis, x, z, lut)); + + + int end = heightSoFar + heightToAdd < worldHeight ? heightSoFar + heightToAdd : worldHeight; SetColumnBlocks(ref terrainBlockBuffers, ref colMinBuffers, ref colMaxBuffers, heightSoFar, end, terrainGenLayer.blockType, blockIndex, columnAccess); //Return the new global height of this column return end; } - + private int GenerateSurfaceLayer(ref NativeArray> terrainBlockBuffers, ref NativeArray> colMinBuffers, ref NativeArray> colMaxBuffers, int blockIndex, int heightSoFar, ref TerrainGenerationLayer terrainGenLayer, int columnAccess) { - int heightToAdd= 1; - - int end = heightSoFar + heightToAdd < worldHeight ? heightSoFar + heightToAdd: worldHeight; + int heightToAdd = 1; + + int end = heightSoFar + heightToAdd < worldHeight ? heightSoFar + heightToAdd : worldHeight; SetColumnBlocks(ref terrainBlockBuffers, ref colMinBuffers, ref colMaxBuffers, heightSoFar, end, terrainGenLayer.blockType, blockIndex, columnAccess); //Return the new global height of this column return end; } + private int GenerateCalculatedLayer(ref NativeArray> terrainBlockBuffers, + ref NativeArray> colMinBuffers, + ref NativeArray> colMaxBuffers, + int blockIndex, int heightSoFar, ref TerrainGenerationLayer terrainGenLayer, int columnAccess, int columnX, int columnZ, int index = -1) + { + bool WithinRange(int val, int n) + { + return val >= (0 - n / 2) && val <= (n - 1) - n / 2; + } + + if (circuitX == 0 || circuitZ == 0) return 0; + int x = columnX / 16; + int z = columnZ / 16; + if (!WithinRange(x, circuitX) || !WithinRange(z, circuitZ)) return 0; + + + BlockType blockType = terrainGenLayer.blockType; + float add = TerrainUtilities.GetAdd[(int)blockType]; + int3 blockLoc = TerrainUtilities.BlockIndexToLocation(blockIndex); + int row = blockLoc.x; + int col = blockLoc.z; + + bool Strips(int row) + { + return (row % 2 != 0); + } + + bool Edges(int row, int col) + { + return row == 0 || row == 15 || col == 0 || col == 15; + } + bool TwoInputGate(int row, int col, double add) + { + return Strips(row) && !Edges(row, col) && (col % 14 == (add + (row + 1) * 0.5) % 14); + } + bool FirstHalf(int val) + { + return val < 8; + } + + int heightToAdd; + switch (blockType) + { + case BlockType.On_Input: + heightToAdd = ((col == 0 || col == 15) && Strips(row) && !(row == 15)) ? 1 : 0; + break; + case BlockType.Clock: + heightToAdd = ((row == 15) && (col == 8)) ? 1 : 0; + break; + case BlockType.Off_Wire: + heightToAdd = ((Strips(row) && !Edges(row, col) && (col % 6 != (add + (row + 1) * 0.5) % 6)) || (row == 15 && col != 8 && col != 0 && col != 15)) ? 1 : 0; + break; + case BlockType.AND_Gate: + heightToAdd = (TwoInputGate(row, col, add) && !FirstHalf(col)) ? 1 : 0; + break; + case BlockType.OR_Gate: + heightToAdd = (TwoInputGate(row, col, add)) ? 1 : 0; + break; + case BlockType.NOT_Gate: + heightToAdd = (!Strips(row) && !Edges(row, col) && (col % 6 == (add + (row + 1) * 0.5) % 6)) ? 1 : 0; + break; + case BlockType.XOR_Gate: + heightToAdd = (TwoInputGate(row, col, add) && FirstHalf(col)) ? 1 : 0; + break; + default: + heightToAdd = (false) ? 1 : 0; + break; + } + int end = heightSoFar + heightToAdd < worldHeight ? heightSoFar + heightToAdd : worldHeight; + + SetColumnBlocks(ref terrainBlockBuffers, ref colMinBuffers, ref colMaxBuffers, heightSoFar, end, + blockType, blockIndex, columnAccess, index); + + return end; + } // Places blocks in a vertical column. Requires the column of terrain areas. private void SetColumnBlocks(ref NativeArray> columnAreaBlockBuffers, ref NativeArray> colMinBuffers, ref NativeArray> colMaxBuffers, - int start, int end, BlockType blockType, int blockIndex, int columnAccess) + int start, int end, BlockType blockType, int blockIndex, int columnAccess, int index = -1) { DynamicBuffer areaBlockBuffer = columnAreaBlockBuffers[0]; - DynamicBuffer colMinBuffer; + DynamicBuffer colMinBuffer; DynamicBuffer colMaxBuffer; int prevColY = -1; + + // Start = 0, End = 2, prevColY = -1 for (int globalY = start; globalY < end; globalY++) { - int colY = globalY / Env.AREA_SIZE; - int chunkYMin = colY * Env.AREA_SIZE; - int chunkYMax = chunkYMin + Env.AREA_SIZE - 1; - int localY = globalY - chunkYMin; + int colY = globalY / Env.AREA_SIZE; // 0 + int chunkYMin = colY * Env.AREA_SIZE; // 0 + int chunkYMax = chunkYMin + Env.AREA_SIZE - 1; // 15 + int localY = globalY - chunkYMin; // 0 // Check if we have entered a new terrain area - if (colY != prevColY) + if (colY != prevColY) // 0 != -1 { // Get buffers for new terrain area areaBlockBuffer = columnAreaBlockBuffers[colY]; colMinBuffer = colMinBuffers[colY]; colMaxBuffer = colMaxBuffers[colY]; // Set column heightmap - if(localY < colMinBuffer[columnAccess]) - colMinBuffer[columnAccess] = (byte)localY; + if (localY < colMinBuffer[columnAccess]) + colMinBuffer[columnAccess] = (byte)localY; if (end > colY + chunkYMax) colMaxBuffer[columnAccess] = (byte)(Env.AREA_SIZE); else @@ -461,9 +588,21 @@ private void SetColumnBlocks(ref NativeArray> columnAre } areaBlockBuffer[blockIndex + localY] = blockType; + if (blockType == BlockType.On_Input) + { + // terrainEntity is the entity of the containing area + Entity terrainEntity = terrainAreaEntities[index + colY]; + DynamicBuffer blockLogicStates = terrainLogicStateLookup[terrainEntity].Reinterpret(); + blockLogicStates[blockIndex + localY] = true; + } + if (BlockData.IsInput(blockType) || BlockData.IsGate(blockType)) + { + Entity terrainEntity = terrainAreaEntities[index + colY]; + terrainUpdateLookup[terrainEntity].Add(new TerrainBlockUpdates { blockLoc = TerrainUtilities.BlockIndexToLocation(blockIndex + localY) }); + } prevColY = colY; - } } + } -} \ No newline at end of file +} diff --git a/Assets/Scripts/Terrain/TerrainLogicSystem.cs b/Assets/Scripts/Terrain/TerrainLogicSystem.cs new file mode 100644 index 00000000..bebf8c99 --- /dev/null +++ b/Assets/Scripts/Terrain/TerrainLogicSystem.cs @@ -0,0 +1,403 @@ +using Opencraft.Terrain; +using Opencraft.Terrain.Authoring; +using Opencraft.Terrain.Blocks; +using Opencraft.Terrain.Utilities; +using Unity.Entities; +using Unity.Jobs; +using Unity.Mathematics; +using Unity.Burst; +using Unity.Collections; +using UnityEngine; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using Unity.Transforms; +using Unity.Profiling; +using Opencraft.Statistics; +using PolkaDOTS; +using UnityEngine.Timeline; +using System; + +[assembly: RegisterGenericJobType(typeof(SortJob))] +namespace Opencraft.Terrain +{ + [WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)] + [UpdateInGroup(typeof(SimulationSystemGroup))] + [UpdateAfter(typeof(TerrainStructuresSystem))] + [BurstCompile] + + public partial struct TerrainLogicSystem : ISystem + { + private static bool isRunning = true; + private double tickRate; + private float timer; + private int tickCount; + private static Dictionary inputBlocks; + private static Dictionary gateBlocks; + private static Dictionary activeGateBlocks; + private static List toReevaluate = new List(); + private BufferLookup terrainLogicStateLookup; + private BufferLookup terrainDirectionLookup; + private BufferLookup terrainBlocksLookup; + private BufferLookup terrainUpdatedLookup; + private ComponentLookup terrainNeighborsLookup; + private ComponentLookup terrainAreaLookup; + static int3 sixteens = new int3(16, 0, 16); + private NativeArray terrainAreasEntities; + + public static ProfilerMarker _markerTerrainLogic = new ProfilerMarker("TerrainLogicSystem"); + + public static ProfilerMarker GetUpdatesMarker = new ProfilerMarker("GetUpdates"); + public static ProfilerMarker ReevaluatePropagateMarker = new ProfilerMarker("ReevaluatePropagateMarker"); + public static ProfilerMarker PropagateLogicStateMaker = new ProfilerMarker("PropagateLogicState"); + public static ProfilerMarker PropagateLogicStateMaker_1 = new ProfilerMarker("PropInputBlocks"); + public static ProfilerMarker PropagateLogicStateMaker_2 = new ProfilerMarker("PropActiveLogicBlocks"); + public static ProfilerMarker CheckGateStateMarker = new ProfilerMarker("CheckGateState"); + + + public struct LogicBlockData + { + public int3 BlockLocation; + public Entity TerrainEntity; + } + public void OnCreate(ref SystemState state) + { + if (!ApplicationConfig.ActiveLogic.Value) + { + isRunning = false; + return; + } + state.RequireForUpdate(); + tickRate = ApplicationConfig.TickSpeed.Value; + timer = 0; + tickCount = 0; + inputBlocks = new Dictionary(); + gateBlocks = new Dictionary(); + activeGateBlocks = new Dictionary(); + terrainLogicStateLookup = state.GetBufferLookup(isReadOnly: false); + terrainDirectionLookup = state.GetBufferLookup(isReadOnly: false); + terrainBlocksLookup = state.GetBufferLookup(isReadOnly: false); + terrainUpdatedLookup = state.GetBufferLookup(isReadOnly: false); + terrainNeighborsLookup = state.GetComponentLookup(isReadOnly: false); + terrainAreaLookup = state.GetComponentLookup(isReadOnly: false); + } + + public void OnDestroy(ref SystemState state) + { + if (!isRunning) return; + inputBlocks.Clear(); + gateBlocks.Clear(); + activeGateBlocks.Clear(); + } + + public void OnUpdate(ref SystemState state) + { + if (!isRunning) return; + if (timer < tickRate) + { + timer += Time.deltaTime * 1000; // milliseconds + return; + } + _markerTerrainLogic.Begin(); + timer = 0; + terrainLogicStateLookup.Update(ref state); + terrainDirectionLookup.Update(ref state); + terrainBlocksLookup.Update(ref state); + terrainUpdatedLookup.Update(ref state); + terrainNeighborsLookup.Update(ref state); + terrainAreaLookup.Update(ref state); + + var terrainAreasQuery = SystemAPI.QueryBuilder().WithAll().Build(); + terrainAreasEntities = terrainAreasQuery.ToEntityArray(state.WorldUpdateAllocator); + + GetUpdatesMarker.Begin(); + foreach (var terrainEntity in terrainAreasEntities) + { + DynamicBuffer updateBlocks = terrainUpdatedLookup[terrainEntity].Reinterpret(); + if (updateBlocks.Length == 0) continue; + NativeArray updateBlocksCopy = updateBlocks.ToNativeArray(Allocator.Temp); + updateBlocks.Clear(); + DynamicBuffer blockTypeBuffer = terrainBlocksLookup[terrainEntity].Reinterpret(); + TerrainArea terrainArea = terrainAreaLookup[terrainEntity]; + for (int i = 0; i < updateBlocksCopy.Length; i++) + { + int3 blockLoc = updateBlocksCopy[i]; + int3 globalPos = terrainArea.location * Env.AREA_SIZE + blockLoc; + int blockIndex = TerrainUtilities.BlockLocationToIndex(ref blockLoc); + BlockType blockType = blockTypeBuffer[blockIndex]; + + LogicBlockData value = new LogicBlockData { BlockLocation = blockLoc, TerrainEntity = terrainEntity }; + + toReevaluate.Add(value); + + if (blockType == BlockType.Air) + { + inputBlocks.Remove(blockLoc); + gateBlocks.Remove(blockLoc); + activeGateBlocks.Remove(blockLoc); + } + else if (BlockData.IsInput(blockType) || blockType == BlockType.NOT_Gate) + inputBlocks.TryAdd(globalPos, value); + else if (BlockData.IsGate(blockType)) + gateBlocks.TryAdd(globalPos, value); + } + } + GetUpdatesMarker.End(); + + ReevaluatePropagateMarker.Begin(); + if (toReevaluate.Any()) + { + PropagateLogicState(toReevaluate, false); + toReevaluate.Clear(); + } + ReevaluatePropagateMarker.End(); + + PropagateLogicStateMaker.Begin(); + + PropagateLogicStateMaker_1.Begin(); + PropagateLogicState(inputBlocks.Values, true); + PropagateLogicStateMaker_1.End(); + + PropagateLogicStateMaker_2.Begin(); + PropagateLogicState(activeGateBlocks.Values, true); + PropagateLogicStateMaker_2.End(); + + PropagateLogicStateMaker.End(); + + CheckGateStateMarker.Begin(); + CheckGateState(gateBlocks.Values); + CheckGateStateMarker.End(); + + terrainAreasEntities.Dispose(); + + GameStatistics.NumInputTypeBlocks.Value = inputBlocks.Count; + GameStatistics.NumGateTypeBlocks.Value = gateBlocks.Count; + Debug.Log($"TerrainLogicSystem Tick {++tickCount}"); + _markerTerrainLogic.End(); + } + + private void PropagateLogicState(IEnumerable logicBlocks, bool inputLogicState) + { + Queue<(LogicBlockData, bool)> logicQueue = new Queue<(LogicBlockData, bool)>(); + foreach (LogicBlockData block in logicBlocks) + { + logicQueue.Enqueue((block, inputLogicState)); + } + + while (logicQueue.TryDequeue(out (LogicBlockData, bool) entry)) + { + LogicBlockData logicBlock = entry.Item1; + bool logicState = entry.Item2; + + Entity blockEntity = logicBlock.TerrainEntity; + int3 blockLoc = logicBlock.BlockLocation; + int blockIndex = TerrainUtilities.BlockLocationToIndex(ref blockLoc); + + if (!terrainBlocksLookup.TryGetBuffer(blockEntity, out DynamicBuffer terrainBlocks)) + continue; + + BlockType currentBlockType = terrainBlocks.Reinterpret()[blockIndex]; + Direction currentOutputDirection = terrainDirectionLookup[blockEntity].Reinterpret()[blockIndex]; + + if (logicState && currentBlockType == BlockType.Off_Input) + continue; + + TerrainNeighbors neighbors = terrainNeighborsLookup[blockEntity]; + Entity[] terrainEntities = { blockEntity, neighbors.neighborXN, neighbors.neighborXP, neighbors.neighborZN, neighbors.neighborZP }; + + if (currentBlockType == BlockType.Clock) + ToggleClockState(blockEntity, blockIndex, ref logicState); + + if (BlockData.IsTwoInputGate(currentBlockType)) + { + EvaluateNeighbour(currentOutputDirection, blockLoc, ref terrainEntities, logicState, ref logicQueue); + continue; + } + + if (currentBlockType == BlockType.NOT_Gate) + { + EvaluateNotGate(currentOutputDirection, blockLoc, ref terrainEntities, ref logicQueue); + continue; + } + + foreach (Direction outputDirection in BlockData.AllDirections) + EvaluateNeighbour(outputDirection, blockLoc, ref terrainEntities, logicState, ref logicQueue); + } + } + + private void ToggleClockState(Entity blockEntity, int blockIndex, ref bool logicState) + { + DynamicBuffer blockLogicStates = terrainLogicStateLookup[blockEntity]; + DynamicBuffer boolLogicStates = blockLogicStates.Reinterpret(); + boolLogicStates[blockIndex] = !boolLogicStates[blockIndex]; + logicState = boolLogicStates[blockIndex]; + } + + private void EvaluateNotGate(Direction currentOutputDirection, int3 blockLoc, ref Entity[] terrainEntities, ref Queue<(LogicBlockData, bool)> logicQueue) + { + Direction inputDirection = BlockData.OppositeDirections[(int)currentOutputDirection]; + int3 notNormalizedBlockLoc = blockLoc + BlockData.Int3Directions[(int)inputDirection]; + int terrainEntityIndex = GetOffsetIndex(notNormalizedBlockLoc); + Entity neighborEntity = terrainEntities[terrainEntityIndex]; + + if (neighborEntity == Entity.Null) return; + + int3 actualBlockLoc = CalculateActualBlockLocation(notNormalizedBlockLoc); + int blockIndex2 = TerrainUtilities.BlockLocationToIndex(ref actualBlockLoc); + + DynamicBuffer blockLogicStates = terrainLogicStateLookup[neighborEntity]; + DynamicBuffer boolLogicStates = blockLogicStates.Reinterpret(); + bool notInputState = boolLogicStates[blockIndex2]; + + EvaluateNeighbour(currentOutputDirection, blockLoc, ref terrainEntities, !notInputState, ref logicQueue); + } + + private void EvaluateNeighbour(Direction outputDirection, int3 blockLoc, ref Entity[] terrainEntities, bool logicState, ref Queue<(LogicBlockData, bool)> logicQueue) + { + int3 direction = BlockData.Int3Directions[(int)outputDirection]; + int3 notNormalisedBlockLoc = (blockLoc + direction); + int terrainEntityIndex = GetOffsetIndex(notNormalisedBlockLoc); + Entity neighborEntity = terrainEntities[terrainEntityIndex]; + if (neighborEntity == Entity.Null) return; + + int3 actualBlockLoc = CalculateActualBlockLocation(notNormalisedBlockLoc); + int blockIndex = TerrainUtilities.BlockLocationToIndex(ref actualBlockLoc); + + DynamicBuffer terrainBlocks = terrainBlocksLookup[neighborEntity]; + DynamicBuffer blockTypes = terrainBlocks.Reinterpret(); + DynamicBuffer blockLogicState = terrainLogicStateLookup[neighborEntity]; + DynamicBuffer boolLogicState = blockLogicState.Reinterpret(); + BlockType currentBlock = blockTypes[blockIndex]; + int currentBlockIndex = (int)currentBlock; + + if (BlockData.CanReceiveLogic[currentBlockIndex]) + { + if (boolLogicState[blockIndex] != logicState) + { + boolLogicState[blockIndex] = logicState; + if (currentBlock == BlockType.Off_Wire || currentBlock == BlockType.On_Wire || currentBlock == BlockType.On_Lamp) + logicQueue.Enqueue((new LogicBlockData { BlockLocation = actualBlockLoc, TerrainEntity = neighborEntity }, logicState)); + if (logicState) blockTypes[blockIndex] = (BlockData.OnState[currentBlockIndex]); + else blockTypes[blockIndex] = (BlockData.OffState[currentBlockIndex]); + } + } + } + private void CheckGateState(in IEnumerable gateBlocks) + { + var gateQueue = new Queue(gateBlocks); + + while (gateQueue.TryDequeue(out var gateBlock)) + { + Span inputDirections = stackalloc Direction[2]; // Assuming max 4 directions + var (blockEntity, blockLoc) = (gateBlock.TerrainEntity, gateBlock.BlockLocation); + var blockIndex = TerrainUtilities.BlockLocationToIndex(ref blockLoc); + + if (!terrainAreaLookup.TryGetComponent(blockEntity, out var terrainArea)) continue; + var globalPos = terrainArea.location * Env.AREA_SIZE + blockLoc; + + var terrainBlocks = terrainBlocksLookup[blockEntity].Reinterpret(); + var currentBlockType = terrainBlocks[blockIndex]; + var blockLogicState = terrainLogicStateLookup[blockEntity]; + var directionStates = terrainDirectionLookup[blockEntity].Reinterpret(); + var currentDirection = directionStates[blockIndex]; + var boolLogicState = blockLogicState.Reinterpret(); + + GetInputDirections(ref inputDirections, currentDirection); + + int requiredInputs = currentBlockType switch + { + BlockType.AND_Gate => 2, + BlockType.OR_Gate or BlockType.XOR_Gate => 1, + _ => 0 + }; + + var neighbors = terrainNeighborsLookup[blockEntity]; + var terrainEntities = new[] { blockEntity, neighbors.neighborXN, neighbors.neighborXP, neighbors.neighborZN, neighbors.neighborZP }; + + int onCount = CountActiveInputs(inputDirections, blockLoc, terrainEntities); + + bool isActive = (currentBlockType == BlockType.AND_Gate || currentBlockType == BlockType.OR_Gate) + ? onCount >= requiredInputs + : onCount == requiredInputs; // False scenario is for XOR gate + + boolLogicState[blockIndex] = isActive; + + if (isActive) + activeGateBlocks.TryAdd(globalPos, gateBlock); + else if (activeGateBlocks.Remove(globalPos)) + toReevaluate.Add(gateBlock); + inputDirections.Clear(); + } + } + + private int CountActiveInputs(ReadOnlySpan inputDirections, int3 blockLoc, Entity[] terrainEntities) + { + int onCount = 0; + var directions = BlockData.Int3Directions; + + foreach (var inputDirection in inputDirections) + { + var notNormalisedBlockLoc = blockLoc + directions[(int)inputDirection]; + var terrainEntityIndex = GetOffsetIndex(notNormalisedBlockLoc); + var neighborEntity = terrainEntities[terrainEntityIndex]; + if (neighborEntity == Entity.Null) continue; + + var actualBlockLoc = CalculateActualBlockLocation(notNormalisedBlockLoc); + var blockIndex = TerrainUtilities.BlockLocationToIndex(ref actualBlockLoc); + + if (terrainLogicStateLookup.TryGetBuffer(neighborEntity, out var blockLogicStates)) + { + var boolLogicStates = blockLogicStates.Reinterpret(); + if (boolLogicStates[blockIndex]) + onCount++; + } + } + + return onCount; + } + + private int3 CalculateActualBlockLocation(int3 notNormalisedBlockLoc) + { + int lowestCoord = math.min(notNormalisedBlockLoc.x, notNormalisedBlockLoc.z); + int num_sixteens = lowestCoord / 16 + 1; + return (notNormalisedBlockLoc + 16 * num_sixteens) % 16; + } + + + private int GetOffsetIndex(int3 blockLoc) + { + switch (blockLoc.x) + { + case -1: return 1; + case 16: return 2; + default: break; + } + switch (blockLoc.z) + { + case -1: return 3; + case 16: return 4; + default: break; + } + return 0; + } + + private void GetInputDirections(ref Span inputDirections, Direction currentDirection) + { + switch (currentDirection) + { + case Direction.XN: + case Direction.XP: + inputDirections[0] = Direction.ZN; + inputDirections[1] = Direction.ZP; + break; + case Direction.ZN: + case Direction.ZP: + inputDirections[0] = Direction.XN; + inputDirections[1] = Direction.XP; + break; + default: + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Terrain/TerrainLogicSystem.cs.meta b/Assets/Scripts/Terrain/TerrainLogicSystem.cs.meta new file mode 100644 index 00000000..397266ce --- /dev/null +++ b/Assets/Scripts/Terrain/TerrainLogicSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3c7f00516f9d7c441bbe0bf33ccb3c0e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Terrain/Utilities/TerrainUtilities.cs b/Assets/Scripts/Terrain/Utilities/TerrainUtilities.cs index de471c8a..6c747265 100644 --- a/Assets/Scripts/Terrain/Utilities/TerrainUtilities.cs +++ b/Assets/Scripts/Terrain/Utilities/TerrainUtilities.cs @@ -13,11 +13,11 @@ namespace Opencraft.Terrain.Utilities [BurstCompile] public static class TerrainUtilities { - + [Serializable] public class TerrainChunkNotLoadedException : Exception { - public TerrainChunkNotLoadedException() { } + public TerrainChunkNotLoadedException() { } public TerrainChunkNotLoadedException(string message) : base(String.Format("Terrain chunk not loaded: {0}", message)) @@ -25,45 +25,45 @@ public TerrainChunkNotLoadedException(string message) } } - + // Draws outline of an area [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void DebugDrawTerrainArea(in float3 terrainAreaPos, Color color, float duration = 0.0f) { DebugDrawTerrainBlock(in terrainAreaPos, color, duration, Env.AREA_SIZE); } - + // Draws outline of a block [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void DebugDrawTerrainBlock(in float3 terrainBlockPos, Color color, float duration = 0.0f, float size = 1.0f) { var d = size; // Draw a bounding box - Debug.DrawLine(terrainBlockPos, terrainBlockPos + new float3(d, 0, 0),color,duration ); - Debug.DrawLine(terrainBlockPos, terrainBlockPos + new float3(0, d, 0),color,duration ); - Debug.DrawLine(terrainBlockPos, terrainBlockPos + new float3(0, 0, d),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(d, d, 0), terrainBlockPos + new float3(d, 0, 0),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(d, d, 0), terrainBlockPos + new float3(0, d, 0),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(d, d, 0), terrainBlockPos + new float3(d, d, d),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(0, d, d), terrainBlockPos + new float3(0, d, 0),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(0, d, d), terrainBlockPos + new float3(0, 0, d),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(0, d, d), terrainBlockPos + new float3(d, d, d),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(d, 0, d), terrainBlockPos + new float3(d, 0, 0),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(d, 0, d), terrainBlockPos + new float3(d, d, d),color,duration); - Debug.DrawLine(terrainBlockPos + new float3(d, 0, d), terrainBlockPos + new float3(0, 0, d),color,duration); + Debug.DrawLine(terrainBlockPos, terrainBlockPos + new float3(d, 0, 0), color, duration); + Debug.DrawLine(terrainBlockPos, terrainBlockPos + new float3(0, d, 0), color, duration); + Debug.DrawLine(terrainBlockPos, terrainBlockPos + new float3(0, 0, d), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(d, d, 0), terrainBlockPos + new float3(d, 0, 0), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(d, d, 0), terrainBlockPos + new float3(0, d, 0), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(d, d, 0), terrainBlockPos + new float3(d, d, d), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(0, d, d), terrainBlockPos + new float3(0, d, 0), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(0, d, d), terrainBlockPos + new float3(0, 0, d), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(0, d, d), terrainBlockPos + new float3(d, d, d), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(d, 0, d), terrainBlockPos + new float3(d, 0, 0), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(d, 0, d), terrainBlockPos + new float3(d, d, d), color, duration); + Debug.DrawLine(terrainBlockPos + new float3(d, 0, d), terrainBlockPos + new float3(0, 0, d), color, duration); } - + // Converts a continuous world location to a discrete area location [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int3 GetContainingAreaLocation(in float3 pos) { // Terrain Areas are placed in cube grid at intervals of Env.AREA_SIZE return new int3( - (Env.AREA_SIZE* NoiseUtilities.FastFloor(pos.x / Env.AREA_SIZE )), + (Env.AREA_SIZE * NoiseUtilities.FastFloor(pos.x / Env.AREA_SIZE)), (Env.AREA_SIZE * NoiseUtilities.FastFloor(pos.y / Env.AREA_SIZE)), - (Env.AREA_SIZE* NoiseUtilities.FastFloor(pos.z / Env.AREA_SIZE ))); + (Env.AREA_SIZE * NoiseUtilities.FastFloor(pos.z / Env.AREA_SIZE))); } - + // Converts world location to block location within an area [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int3 GetBlockLocationInArea(in int3 blockPos, in int3 terrainAreaPos) @@ -73,21 +73,30 @@ public static int3 GetBlockLocationInArea(in int3 blockPos, in int3 terrainAreaP blockPos.y - terrainAreaPos.y, blockPos.z - terrainAreaPos.z); } - + // Converts a block position in an area to that block's index [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BlockLocationToIndex(ref int3 blockPos) { - return blockPos.y + blockPos.x * Env.AREA_SIZE + blockPos.z * Env.AREA_SIZE_POW_2; + return blockPos.y + blockPos.x * Env.AREA_SIZE + blockPos.z * Env.AREA_SIZE_POW_2; } - + // Converts a block position in an area to that block's index [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BlockLocationToIndex(int x, int y, int z) - { + { return y + x * Env.AREA_SIZE + z * Env.AREA_SIZE_POW_2; } - + + public static int3 BlockIndexToLocation(int index) + { + int z = index / Env.AREA_SIZE_POW_2; + int rem_z = index % Env.AREA_SIZE_POW_2; + int x = rem_z / Env.AREA_SIZE; + int y = rem_z % Env.AREA_SIZE; + return new int3(x, y, z); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BlockLocationHash(int x, int y, int z) { @@ -99,20 +108,20 @@ public static int BlockLocationHash(int x, int y, int z) return hashCode; } } - + // Converts a block position in an area to it's column index [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BlockLocationToColIndex(ref int3 blockPos) { int bps = Env.AREA_SIZE; - return blockPos.x + blockPos.z * bps ; + return blockPos.x + blockPos.z * bps; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BlockLocationToColIndex(int x, int z) { int bps = Env.AREA_SIZE; - return x + z * bps ; + return x + z * bps; } @@ -137,7 +146,7 @@ public static bool GetTerrainAreaByPosition(in int3 pos, containingAreaIndex = -1; return false; } - + public struct BlockSearchInput { public int3 basePos; @@ -145,7 +154,7 @@ public struct BlockSearchInput public Entity areaEntity; public int3 terrainAreaPos; public int columnHeight; - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void DefaultBlockSearchInput(ref BlockSearchInput bsi) { @@ -160,9 +169,9 @@ public static void DefaultBlockSearchInput(ref BlockSearchInput bsi) public enum BlockSearchResult { SearchNotCompleted = 0, - NotLoaded=1, - OutOfBounds=2, - Found=3 + NotLoaded = 1, + OutOfBounds = 2, + Found = 3 } public struct BlockSearchOutput @@ -172,7 +181,7 @@ public struct BlockSearchOutput public int3 localPos; public BlockType blockType; public BlockSearchResult result; - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void DefaultBlockSearchOutput(ref BlockSearchOutput bso) { @@ -183,7 +192,7 @@ public static void DefaultBlockSearchOutput(ref BlockSearchOutput bso) bso.result = BlockSearchResult.SearchNotCompleted; } } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] // Uses neighbor entity links to check block types via offset from an existing position with a given terrain area // Returns true if the block exists and is not air @@ -209,7 +218,7 @@ public static bool GetBlockAtPositionByOffset(in BlockSearchInput input, ref Blo { if (debug) Debug.Log($" BlockSearchByOffset [{step}]: global {offsetPos} = local {localPos} in area {terrainAreaPosAdj}"); - + step++; @@ -271,7 +280,7 @@ public static bool GetBlockAtPositionByOffset(in BlockSearchInput input, ref Blo { currentEntity = currentNeighbors.neighborYP; continue; - } + } if (debug) Debug.LogWarning($"NeighborYP not found!"); if (terrainAreaPosAdj.y >= input.columnHeight * Env.AREA_SIZE) @@ -292,7 +301,7 @@ public static bool GetBlockAtPositionByOffset(in BlockSearchInput input, ref Blo { currentEntity = currentNeighbors.neighborZN; continue; - } + } if (debug) Debug.LogWarning($"NeighborZN not found!"); notFound = true; @@ -306,7 +315,7 @@ public static bool GetBlockAtPositionByOffset(in BlockSearchInput input, ref Blo { currentEntity = currentNeighbors.neighborZP; continue; - } + } if (debug) Debug.LogWarning($"NeighborZP not found!"); notFound = true; @@ -334,10 +343,10 @@ public static bool GetBlockAtPositionByOffset(in BlockSearchInput input, ref Blo output.blockType = block; output.result = BlockSearchResult.Found; #if UNITY_EDITOR - if(debug) + if (debug) { float3 p = new float3(offsetPos); - DebugDrawTerrainBlock(in p, Color.green, 3.0f); + DebugDrawTerrainBlock(in p, Color.green, 3.0f); Debug.Log($"Global pos {offsetPos} is localPos {localPos} in chunk {terrainAreaPosAdj}, block is {block}"); } /*Debug.Log($"Offset pos is {localPos} in {terrainAreaPos}"); @@ -347,7 +356,7 @@ public static bool GetBlockAtPositionByOffset(in BlockSearchInput input, ref Blo terrainAreaPosAdj.z + localPos.z); DebugDrawTerrainBlock(ref blockPos, Color.green);*/ #endif - + return true; } @@ -369,12 +378,12 @@ public static bool VisibleFaceXN(int j, int access, bool min, int kBPS2, ref Dyn return true; // If it is outside this chunk, get the block from the neighbouring chunk - return neighborXN[(bps - 1) * bps + j + kBPS2].type == BlockType.Air; + return neighborXN[(bps - 1) * bps + j + kBPS2].type == BlockType.Air; } return blocks[access - bps].type == BlockType.Air; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool VisibleFaceXP(int j, int access, bool max, int kBPS2, ref DynamicBuffer blocks, ref DynamicBuffer neighborXP) @@ -392,9 +401,9 @@ public static bool VisibleFaceXP(int j, int access, bool max, int kBPS2, ref Dyn return neighborXP[j + kBPS2].type == BlockType.Air; } - return blocks[access + bps].type == BlockType.Air; + return blocks[access + bps].type == BlockType.Air; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool VisibleFaceYN(int access, bool min, int iBPS, int kBPS2, ref DynamicBuffer blocks, ref DynamicBuffer neighborYN) @@ -412,7 +421,7 @@ public static bool VisibleFaceYN(int access, bool min, int iBPS, int kBPS2, ref return blocks[access - 1].type == BlockType.Air; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool VisibleFaceYP(int access, bool max, int iBPS, int kBPS2, ref DynamicBuffer blocks, ref DynamicBuffer neighborYP) @@ -427,7 +436,7 @@ public static bool VisibleFaceYP(int access, bool max, int iBPS, int kBPS2, ref return blocks[access + 1].type == BlockType.Air; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool VisibleFaceZN(int j, int access, bool min, int iBPS, ref DynamicBuffer blocks, ref DynamicBuffer neighborZN) @@ -440,12 +449,12 @@ public static bool VisibleFaceZN(int j, int access, bool min, int iBPS, ref Dyna if (neighborZN.IsEmpty) return true; - return neighborZN[iBPS + j + (bps-1) * bpl].type == BlockType.Air; + return neighborZN[iBPS + j + (bps - 1) * bpl].type == BlockType.Air; } return blocks[access - bpl].type == BlockType.Air; } - + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool VisibleFaceZP(int j, int access, bool max, int iBPS, ref DynamicBuffer blocks, ref DynamicBuffer neighborZP) @@ -462,5 +471,10 @@ public static bool VisibleFaceZP(int j, int access, bool max, int iBPS, ref Dyna return blocks[access + bpl].type == BlockType.Air; } + + public readonly static float[] GetAdd = new float[] + { + 0, 0, 0, 0, 9, 3, 3.5f, 11, 0, 0, 0, 0, 0,0, 0, 0, 3, 0, 0, 0 + }; } } \ No newline at end of file diff --git a/Builds/.dockerignore b/Builds/.dockerignore deleted file mode 100755 index 2f87f6c2..00000000 --- a/Builds/.dockerignore +++ /dev/null @@ -1,20 +0,0 @@ -# Ignore everything -* - -# Allow certain files and directories -!*/opencraft2_Data -!*/GameAssembly.so -!*/UnityPlayer.so -!*/opencraft2.x86_64 -!*/localconfig.json -!/Multiplay_WebApp -!*/logs -!*/input_recordings - - -# Ignore unnecessary files inside allowed directories -# This should go after the allowed directories -#**/*~ -#**/*.log -#**/.DS_Store -#**/Thumbs.db diff --git a/Builds/Dockerfile b/Builds/Dockerfile deleted file mode 100755 index 60e7059e..00000000 --- a/Builds/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM jerriteic/gpu_ubuntu20.04 - -# Select which build application folder to include -ARG BUILD_TO_COPY=./ServerClientLinuxDebug -# Identify signaling webserver -ARG WEBSERVER_LOCATION=./Multiplay_WebApp/webserver - -# Copy game files -COPY $BUILD_TO_COPY /opencraft2 -# Copy signalling server -COPY $WEBSERVER_LOCATION /opencraft2 - -# Set working directory -WORKDIR /opencraft2 - -# Unrestricted env vars for the nvidia-container-runtime. -ENV NVIDIA_VISIBLE_DEVICES all -ENV NVIDIA_DRIVER_CAPABILITIES all - - -# Game port -EXPOSE 7979/udp -# Deployment port -EXPOSE 7980/udp -# Signaling ports -EXPOSE 7981-7984/udp - -# We run the game from the kubernetes job description -CMD /bin/bash diff --git a/Builds/Dockerfile.server b/Builds/Dockerfile.server deleted file mode 100755 index 7368761e..00000000 --- a/Builds/Dockerfile.server +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu:20.04 - -# Select which build application folder to include -ARG BUILD_TO_COPY=./HeadlessLinuxDebug - -# Copy game files -COPY $BUILD_TO_COPY /opencraft2 - -# Set working directory -WORKDIR /opencraft2 - -# Game port -EXPOSE 7979/udp -# Deployment port -EXPOSE 7980/udp -# Signaling ports -EXPOSE 7981-7984/udp - -# We run the game from the kubernetes job description -CMD /bin/bash diff --git a/Builds/Dockerfile.ubuntugpu b/Builds/Dockerfile.ubuntugpu deleted file mode 100644 index e06522c0..00000000 --- a/Builds/Dockerfile.ubuntugpu +++ /dev/null @@ -1,45 +0,0 @@ -# Dockerfile for jerriteic/gpu_ubuntu20.04 -FROM nvidia/cudagl:11.4.0-devel-ubuntu20.04 - -ARG SOURCEFORGE=https://sourceforge.net/projects -ARG VIRTUALGL_VERSION=3.1 - -#--------------------------------------------------------------------- -# Install Linux stuff -#--------------------------------------------------------------------- -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - ca-certificates curl wget less sudo lsof git net-tools nano psmisc xz-utils nemo vim net-tools iputils-ping traceroute htop \ - xorg x11-utils xkb-data openbox lightdm dbus-x11 \ - xterm terminator zenity make cmake gcc libc6-dev \ - x11-xkb-utils xauth xfonts-base xkb-data \ - mesa-utils xvfb libgl1-mesa-dri libgl1-mesa-glx libglib2.0-0 libxext6 libsm6 libxrender1 \ - libglu1 libglu1:i386 libxv1 libxv1:i386 \ - libxtst6 libegl1-mesa \ - libnvidia-encode-535-server libnvidia-decode-535-server \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -#--------------------------------------------------------------------- -# Install and Configure VirtualGL -#--------------------------------------------------------------------- -RUN cd /tmp && \ - curl -fsSL -O ${SOURCEFORGE}/virtualgl/files/${VIRTUALGL_VERSION}/virtualgl_${VIRTUALGL_VERSION}_amd64.deb && \ - dpkg -i *.deb && \ - rm -f /tmp/*.deb - -COPY requirements/xorg.conf /etc/X11/xorg.conf - -ENV DISPLAY :0 - -#--------------------------------------------------------------------- -# Install desktop files for this user -#--------------------------------------------------------------------- -RUN mkdir -p /root/Desktop -COPY requirements/terminator.desktop /root/Desktop -RUN mkdir -p /root/.config/terminator -COPY requirements/terminator_config /root/.config/terminator/config -COPY requirements/self.pem /root/self.pem - -# Precede bash on all new terminator shells with vglrun so that 3d graphics apps will use the GPU -RUN perl -pi -e 's/^Exec=terminator$/Exec=terminator -e "vglrun bash"/g' /usr/share/applications/terminator.desktop - -CMD /bin/bash diff --git a/Builds/Dockerfile.ubuntugpu.dockerignore b/Builds/Dockerfile.ubuntugpu.dockerignore deleted file mode 100755 index f87c259c..00000000 --- a/Builds/Dockerfile.ubuntugpu.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -# Ignore everything -* - -# Allow certain files and directories -!requirements diff --git a/Builds/Multiplay_WebApp/start.bat b/Builds/Multiplay_WebApp/start.bat deleted file mode 100644 index 275265d3..00000000 --- a/Builds/Multiplay_WebApp/start.bat +++ /dev/null @@ -1 +0,0 @@ -.\webserver.exe -p 7981 \ No newline at end of file diff --git a/Builds/Multiplay_WebApp/start.sh b/Builds/Multiplay_WebApp/start.sh deleted file mode 100755 index 9ba38d8d..00000000 --- a/Builds/Multiplay_WebApp/start.sh +++ /dev/null @@ -1 +0,0 @@ -./webserver -p 7981 diff --git a/Builds/Multiplay_WebApp/webserver b/Builds/Multiplay_WebApp/webserver deleted file mode 100755 index b2ceee30..00000000 Binary files a/Builds/Multiplay_WebApp/webserver and /dev/null differ diff --git a/Builds/Multiplay_WebApp/webserver.exe b/Builds/Multiplay_WebApp/webserver.exe deleted file mode 100755 index 5d7603f0..00000000 Binary files a/Builds/Multiplay_WebApp/webserver.exe and /dev/null differ diff --git a/Builds/docker_run.sh b/Builds/docker_run.sh deleted file mode 100755 index 39c7361f..00000000 --- a/Builds/docker_run.sh +++ /dev/null @@ -1,13 +0,0 @@ -docker run -it \ ---name=opencraft2-client \ ---net=host \ ---rm=true \ --v ./logs:/opencraft2/logs/ \ -jerriteic/opencraft2:base sh -c "./opencraft2.x86_64 -playType Client \ - -nographics -batchmode \ - -multiplayRole Guest \ - -signalingUrl ws://127.0.0.1:7981 \ - -localConfigJson ./localconfig.json \ - -logFile ./logs/opencraft2_log.txt \ - -duration 30 " - diff --git a/Packages/PolkaDOTS b/Packages/PolkaDOTS index abce2e02..79d4506b 160000 --- a/Packages/PolkaDOTS +++ b/Packages/PolkaDOTS @@ -1 +1 @@ -Subproject commit abce2e02cda6fc27d7e2b1fa43e50fa881e062b4 +Subproject commit 79d4506b3480ea95be537a25f66d22049a71846a diff --git a/README.md b/README.md index 36d0b7ec..e9ca13f1 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,9 @@ when run standalone. In editor, the hierarchy of configuration is `Deployment Gr | -profiler-maxusedmemory | _int_ | 16000000 | Max memory used by profiler in bytes. Default is 16MB. | | -logStats | true/false | false | Log relevant Profiler statistics to file. | | -statsFile | _FilePath_ | Application.persistentDataPath\stats.csv | What file to log statistics to. | +| -activeLogic | true/false | false | Enable/disable the logic system. | +| -circuitX / -circuitY | _int_ | 1 | Choose length of circuits to spawn on that axis. | +| -tickSpeed | _int_ | 1000 | Set the tick speed of the logic system (milliseconds). | ### Deployment Configuration The deployment service constructs a deployment graph based on a configuration file. The deployment configuration file path is set