Skip to content

Commit

Permalink
Parameterized terrain generation, network settings, improved simulate…
Browse files Browse the repository at this point in the history
…d movement
  • Loading branch information
JerritEic committed Jan 18, 2024
1 parent ce435d9 commit 738c857
Show file tree
Hide file tree
Showing 51 changed files with 951 additions and 267 deletions.
24 changes: 24 additions & 0 deletions Assets/Config/TerrainLayers/AbsoluteFlatDirtLayer 1.asset
Original file line number Diff line number Diff line change
@@ -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: AbsoluteFlatDirtLayer 1
m_EditorClassIdentifier:
layerType: 0
layerName: Flat dirt base layer
index: 300
blockType: 2
frequency: 50
exponent: 1
minHeight: 1
maxHeight: 1
chance: 0
structureType: 0

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Assets/Config/TerrainLayers/ConfigBank.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
%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: 7b69780cebfd45bbb2739f006efc413f, type: 3}
m_Name: ConfigBank
m_EditorClassIdentifier:
configs:
- {fileID: 11400000, guid: bf78fd0d717835f4ebfb0ab97738fcc3, type: 2}
- {fileID: 11400000, guid: 3c9c4f78892f3d61ca2921df917af494, type: 2}
8 changes: 8 additions & 0 deletions Assets/Config/TerrainLayers/ConfigBank.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/Config/TerrainLayers/FlatTerrainLayers.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%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: FlatTerrainLayers
m_EditorClassIdentifier:
configName: Flat
layers:
- {fileID: 11400000, guid: 04e8d21d759b887479e8717cf913597d, type: 2}
areaColumnHeight: 1
8 changes: 8 additions & 0 deletions Assets/Config/TerrainLayers/FlatTerrainLayers.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ac255652e50945d8a4e0ec00804a4230, type: 3}
m_Name: TerrainLayerCollection
m_Name: RollingHillsTerrainLayers
m_EditorClassIdentifier:
configName: RollingHills
layers:
- {fileID: 11400000, guid: b294ba7c0c4a08144916c18d0f467747, type: 2}
- {fileID: 11400000, guid: 0bc928c0fbae2694a9c4c010f4687eb4, type: 2}
Expand All @@ -20,3 +21,4 @@ MonoBehaviour:
- {fileID: 11400000, guid: 5a676bee5116cc047acabfa4f7d19241, type: 2}
- {fileID: 11400000, guid: 04e8d21d759b887479e8717cf913597d, type: 2}
- {fileID: 11400000, guid: 73e6007e32e2599449c029eab6a24533, type: 2}
areaColumnHeight: 3
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
cacheGUID:
Value:
x: 2650512374
y: 895508896
z: 2834433152
w: 849077948
x: 1700868938
y: 2258953530
z: 4084636585
w: 1367957563
101 changes: 101 additions & 0 deletions Assets/Prefabs/TerrainConfiguration.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3194879136077857405
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5635330251713189791}
- component: {fileID: -4002439177456399829}
- component: {fileID: 7020423471914046309}
- component: {fileID: 5368163881853221015}
- component: {fileID: 6978896562413794302}
m_Layer: 0
m_Name: TerrainConfiguration
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5635330251713189791
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3194879136077857405}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &-4002439177456399829
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3194879136077857405}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f67a4f72a6704fae9e46fe4aaa8b1eb4, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &7020423471914046309
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3194879136077857405}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c16549610bfe4458aa9389201d072bb6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &5368163881853221015
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3194879136077857405}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c79d771cedb4794bf100ce60df5f764, type: 3}
m_Name:
m_EditorClassIdentifier:
DefaultGhostMode: 0
SupportedGhostModes: 3
OptimizationMode: 1
Importance: 1000
prefabId: b5e6d2c9e04e20ca7afceb12dff6319c
HasOwner: 0
SupportAutoCommandTarget: 1
TrackInterpolationDelay: 0
GhostGroup: 0
UsePreSerialization: 0
--- !u!114 &6978896562413794302
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3194879136077857405}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bfdaa6c06fe64fbda2b16e07a4ee0b25, type: 3}
m_Name:
m_EditorClassIdentifier:
ComponentOverrides:
- FullTypeName: Unity.Transforms.LocalTransform
EntityIndex: 0
PrefabType: -1
SendTypeOptimization: -1
VariantHash: 10188360468653526834
7 changes: 7 additions & 0 deletions Assets/Prefabs/TerrainConfiguration.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Assets/Scenes/AuthoringScene/AuthoringScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ MonoBehaviour:
m_EditorClassIdentifier:
TerrainArea: {fileID: 3194879136077857405, guid: fbe285af02efd794da108f614fa73983,
type: 3}
TerrainConfiguration: {fileID: 3194879136077857405, guid: b5e6d2c9e04e20ca7afceb12dff6319c,
type: 3}
TerrainMaterial: {fileID: 2100000, guid: b53eef138330bed4a8a6bd3b9a48b63e, type: 2}
layerCollection: {fileID: 11400000, guid: bf78fd0d717835f4ebfb0ab97738fcc3, type: 2}
--- !u!114 &176225512
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
61 changes: 60 additions & 1 deletion Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7670ed7fdc2d435abe14606c6942102a, type: 3}
m_Name:
m_EditorClassIdentifier:
editorArgs: -userID 1
editorArgs: '-terrainType Flat -simulationTickRate 20 -networkTickRate 20 '
useDeploymentConfig: 0
deploymentConfig: "{\n\t\"nodes\":[\n\t\t{\n\t\t\t\"nodeID\":0,\n\t\t\t\"nodeIP\":\"\",\n\t\t\t\"worldConfigs\":[\n\t\t\t\t{\n\t\t\t\t\t\"worldName\":
\"GameServer\",\n\t\t\t\t\t\"worldType\":\"Server\",\n\t\t\t\t\t\"initializationMode\":\"Connect\",\n\t\t\t\t\t\"multiplayStreamingRoles\":\"Disabled\",\n\t\t\t\t\t\"serverNodeID\":0,\n\t\t\t\t\t\"streamingNodeID\":-1,\n\t\t\t\t\t\"numThinClients\":0,\n\t\t\t\t\t\"services\":[],\n\t\t\t\t\t\"serviceFilterType\":\"Includes\"\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"worldName\":
Expand Down Expand Up @@ -821,6 +821,64 @@ RectTransform:
type: 3}
m_PrefabInstance: {fileID: 2111867266}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1288104458
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1288104459}
- component: {fileID: 1288104461}
- component: {fileID: 1288104460}
m_Layer: 0
m_Name: Terrain
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1288104459
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1288104458}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.338035, y: -0.25584126, z: 9.434171}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1288104460
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1288104458}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 97ae7136ae5a413dad7c1ebdec9b93c5, type: 3}
m_Name:
m_EditorClassIdentifier:
terrainConfigBank: {fileID: 11400000, guid: 42f17083995c4266892cf0621fa5e99e, type: 2}
--- !u!114 &1288104461
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1288104458}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f16bdd52a00647b1a3d3fbf4361fd92e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1913125884
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1269,3 +1327,4 @@ SceneRoots:
- {fileID: 811246997}
- {fileID: 1913125886}
- {fileID: 1924636148}
- {fileID: 1288104459}
2 changes: 2 additions & 0 deletions Assets/Scripts/Configuration/GameConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ namespace Opencraft
public static class GameConfig
{
public static readonly CommandLineParser.EnumArgument<SimulationBehaviour> PlayerSimulationBehaviour = new CommandLineParser.EnumArgument<SimulationBehaviour>("-playerSimulationBehaviour", SimulationBehaviour.BoundedRandom);
public static readonly CommandLineParser.StringArgument TerrainType = new CommandLineParser.StringArgument("-terrainType", "default");

}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Networking.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions Assets/Scripts/Networking/HandleDisconnectSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using PolkaDOTS;
using PolkaDOTS.Networking;
using Unity.Entities;
using Unity.NetCode;
using Unity.Burst;


namespace Opencraft.Player
{
/// <summary>
/// System that detects terminated connections, and marks any players being controlled by that connection as no
/// longer in game.
/// </summary>
[BurstCompile]
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
[UpdateBefore(typeof(ConnectionMonitorSystem))]
public partial class HandleDisconnectSystem : SystemBase
{
private BeginSimulationEntityCommandBufferSystem m_CommandBufferSystem;

protected override void OnCreate()
{
// Use an entity command buffer that is resolved at the beginning of the simulation system group
m_CommandBufferSystem = World.GetOrCreateSystemManaged<BeginSimulationEntityCommandBufferSystem>();
}

[BurstCompile]
protected override void OnUpdate()
{
var ecb = m_CommandBufferSystem.CreateCommandBuffer();
foreach (var state in SystemAPI.Query<RefRO<ConnectionState>>().WithNone<NetworkStreamConnection>())
{
foreach (var (owner, entity) in SystemAPI.Query<RefRW<GhostOwner>>().WithAll<PlayerInGame, PolkaDOTS.Player>().WithEntityAccess())
{
if (state.ValueRO.NetworkId == owner.ValueRO.NetworkId)
{
ecb.SetComponentEnabled<PlayerInGame>(entity, false);
break;
}
}
}
//m_CommandBufferSystem.AddJobHandleForProducer(Dependency);
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Networking/HandleDisconnectSystem.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Assets/Scripts/Player/Authoring/PlayerAuthoring.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using PolkaDOTS;
using Unity.Entities;
using Unity.Mathematics;
using Unity.NetCode;
Expand Down Expand Up @@ -76,6 +77,7 @@ public override void Bake(PlayerAuthoring authoring)
AddComponent(entity, new PolkaDOTS.NewPlayer());
AddComponent(entity, new PlayerContainingArea());
AddComponent(entity, new SelectedBlock());
AddComponent(entity, new PlayerInGame());
}
}
}
Expand Down
Loading

0 comments on commit 738c857

Please sign in to comment.