├── .gitignore ├── Assets ├── Black.mat ├── Black.mat.meta ├── BuildSettings.meta ├── BuildSettings │ ├── Android-Build.buildconfiguration │ ├── Android-Build.buildconfiguration.meta │ ├── BaseBuildConfiguration.buildconfiguration │ ├── BaseBuildConfiguration.buildconfiguration.meta │ ├── Linux-Build.buildconfiguration │ ├── Linux-Build.buildconfiguration.meta │ ├── Sample macOS Build Configuration.buildconfiguration │ ├── Sample macOS Build Configuration.buildconfiguration.meta │ ├── Win64-Build.buildconfiguration │ ├── Win64-Build.buildconfiguration.meta │ ├── macOS-Build.buildconfiguration │ └── macOS-Build.buildconfiguration.meta ├── GreyMaterial.mat ├── GreyMaterial.mat.meta ├── Physics Category Names.asset ├── Physics Category Names.asset.meta ├── Red.mat ├── Red.mat.meta ├── Scenes.meta ├── Scenes │ ├── MainScene.meta │ ├── MainScene.unity │ ├── MainScene.unity.meta │ ├── MainScene │ │ ├── ConvertedSubScene.unity │ │ └── ConvertedSubScene.unity.meta │ ├── NavigationScene.unity │ └── NavigationScene.unity.meta ├── Scripts and Prefabs.meta ├── Scripts and Prefabs │ ├── Asteroid.prefab │ ├── Asteroid.prefab.meta │ ├── Authoring.meta │ ├── Authoring │ │ ├── ClientSettingsAuthoringComponent.cs │ │ ├── ClientSettingsAuthoringComponent.cs.meta │ │ ├── SetBulletSpawnOffset.cs │ │ ├── SetBulletSpawnOffset.cs.meta │ │ ├── SetGameSettingsSystem.cs │ │ ├── SetGameSettingsSystem.cs.meta │ │ ├── StatefulCollisionEventBufferAuthoring.cs │ │ ├── StatefulCollisionEventBufferAuthoring.cs.meta │ │ ├── StatefulTriggerEventBufferAuthoring.cs │ │ └── StatefulTriggerEventBufferAuthoring.cs.meta │ ├── Bullet.prefab │ ├── Bullet.prefab.meta │ ├── Camera.prefab │ ├── Camera.prefab.meta │ ├── Client.meta │ ├── Client │ │ ├── Components.meta │ │ ├── Components │ │ │ ├── CameraAuthoringComponent.cs │ │ │ ├── CameraAuthoringComponent.cs.meta │ │ │ ├── PlayerClassifiedTag.cs │ │ │ └── PlayerClassifiedTag.cs.meta │ │ ├── Systems.meta │ │ └── Systems │ │ │ ├── AsteroidSwitchPredictionSystem.cs │ │ │ ├── AsteroidSwitchPredictionSystem.cs.meta │ │ │ ├── BulletGhostSpawnClassificationSystem.cs │ │ │ ├── BulletGhostSpawnClassificationSystem.cs.meta │ │ │ ├── ClientLoadGameSystem.cs │ │ │ ├── ClientLoadGameSystem.cs.meta │ │ │ ├── InputSystem.cs │ │ │ ├── InputSystem.cs.meta │ │ │ ├── PlayerGhostSpawnClassificationSystem.cs │ │ │ └── PlayerGhostSpawnClassificationSystem.cs.meta │ ├── ClientLaunchObject.prefab │ ├── ClientLaunchObject.prefab.meta │ ├── HighestScore.prefab │ ├── HighestScore.prefab.meta │ ├── Mixed.meta │ ├── Mixed │ │ ├── Commands.meta │ │ ├── Commands │ │ │ ├── PlayerSpawnRequestRpc.cs │ │ │ ├── PlayerSpawnRequestRpc.cs.meta │ │ │ ├── SendClientGameRpc.cs │ │ │ ├── SendClientGameRpc.cs.meta │ │ │ ├── SendServerGameLoadedRpc.cs │ │ │ ├── SendServerGameLoadedRpc.cs.meta │ │ │ ├── SendServerPlayerNameRpc.cs │ │ │ └── SendServerPlayerNameRpc.cs.meta │ │ ├── Components.meta │ │ ├── Components │ │ │ ├── AsteroidTag.cs │ │ │ ├── AsteroidTag.cs.meta │ │ │ ├── BulletAgeComponent.cs │ │ │ ├── BulletAgeComponent.cs.meta │ │ │ ├── BulletAuthoringComponent.cs │ │ │ ├── BulletAuthoringComponent.cs.meta │ │ │ ├── BulletTag.cs │ │ │ ├── BulletTag.cs.meta │ │ │ ├── DestroyTag.cs │ │ │ ├── DestroyTag.cs.meta │ │ │ ├── GameSettingsComponent.cs │ │ │ ├── GameSettingsComponent.cs.meta │ │ │ ├── HighestScoreComponent.cs │ │ │ ├── HighestScoreComponent.cs.meta │ │ │ ├── IStatefulSimulationEvent.cs │ │ │ ├── IStatefulSimulationEvent.cs.meta │ │ │ ├── PlayerCommand.cs │ │ │ ├── PlayerCommand.cs.meta │ │ │ ├── PlayerCommandBufferAuthoringComponent.cs │ │ │ ├── PlayerCommandBufferAuthoringComponent.cs.meta │ │ │ ├── PlayerEntityComponent.cs │ │ │ ├── PlayerEntityComponent.cs.meta │ │ │ ├── PlayerScoreComponent.cs │ │ │ ├── PlayerScoreComponent.cs.meta │ │ │ ├── PlayerStateAndOffsetComponent.cs │ │ │ ├── PlayerStateAndOffsetComponent.cs.meta │ │ │ ├── PlayerTag.cs │ │ │ ├── PlayerTag.cs.meta │ │ │ ├── StatefulCollisionEvent.cs │ │ │ ├── StatefulCollisionEvent.cs.meta │ │ │ ├── StatefulSimulationEventBuffers.cs │ │ │ ├── StatefulSimulationEventBuffers.cs.meta │ │ │ ├── StatefulTriggerEvent.cs │ │ │ └── StatefulTriggerEvent.cs.meta │ │ ├── Systems.meta │ │ └── Systems │ │ │ ├── ChangeMaterialAndDestroySystem.cs │ │ │ ├── ChangeMaterialAndDestroySystem.cs.meta │ │ │ ├── InputResponseMovementSystem.cs │ │ │ ├── InputResponseMovementSystem.cs.meta │ │ │ ├── InputResponseSpawnSystem.cs │ │ │ ├── InputResponseSpawnSystem.cs.meta │ │ │ ├── StatefulCollisionEventBufferSystem.cs │ │ │ ├── StatefulCollisionEventBufferSystem.cs.meta │ │ │ ├── StatefulTriggerEventBufferSystem.cs │ │ │ └── StatefulTriggerEventBufferSystem.cs.meta │ ├── Multiplayer Setup.meta │ ├── Multiplayer Setup │ │ ├── ClientDataComponent.cs │ │ ├── ClientDataComponent.cs.meta │ │ ├── ClientLaunchObjectData.cs │ │ ├── ClientLaunchObjectData.cs.meta │ │ ├── ClientServerConnectionControl.cs │ │ ├── ClientServerConnectionControl.cs.meta │ │ ├── ClientServerConnectionHandler.cs │ │ ├── ClientServerConnectionHandler.cs.meta │ │ ├── ClientServerInfo.cs │ │ ├── ClientServerInfo.cs.meta │ │ ├── ClientServerLauncher.cs │ │ ├── ClientServerLauncher.cs.meta │ │ ├── GameNameComponent.cs │ │ ├── GameNameComponent.cs.meta │ │ ├── GameServerBroadcasting.cs │ │ ├── GameServerBroadcasting.cs.meta │ │ ├── InitializeClientComponent.cs │ │ ├── InitializeClientComponent.cs.meta │ │ ├── InitializeServerComponent.cs │ │ ├── InitializeServerComponent.cs.meta │ │ ├── LocalGamesFinder.cs │ │ ├── LocalGamesFinder.cs.meta │ │ ├── NetCodeBootstrap.cs │ │ ├── NetCodeBootstrap.cs.meta │ │ ├── ServerDataComponent.cs │ │ ├── ServerDataComponent.cs.meta │ │ ├── ServerLaunchObjectData.cs │ │ ├── ServerLaunchObjectData.cs.meta │ │ ├── UdpConnection.cs │ │ └── UdpConnection.cs.meta │ ├── Player.prefab │ ├── Player.prefab.meta │ ├── PlayerScore.prefab │ ├── PlayerScore.prefab.meta │ ├── Server.meta │ ├── Server │ │ ├── Components.meta │ │ ├── Components │ │ │ ├── AsteroidAuthoringComponent.cs │ │ │ ├── AsteroidAuthoringComponent.cs.meta │ │ │ ├── PlayerAuthoringComponent.cs │ │ │ ├── PlayerAuthoringComponent.cs.meta │ │ │ ├── PlayerScoreAuthoringComponent.cs │ │ │ ├── PlayerScoreAuthoringComponent.cs.meta │ │ │ ├── PlayerSpawningStateComponent.cs │ │ │ └── PlayerSpawningStateComponent.cs.meta │ │ ├── Systems.meta │ │ └── Systems │ │ │ ├── AdjustScoresFromBulletCollisionsSystem.cs │ │ │ ├── AdjustScoresFromBulletCollisionsSystem.cs.meta │ │ │ ├── AsteroidSpawnSystem.cs │ │ │ ├── AsteroidSpawnSystem.cs.meta │ │ │ ├── AsteroidsDestructionSystem.cs │ │ │ ├── AsteroidsDestructionSystem.cs.meta │ │ │ ├── AsteroidsOutOfBoundsSystem.cs │ │ │ ├── AsteroidsOutOfBoundsSystem.cs.meta │ │ │ ├── BulletAgeSystem.cs │ │ │ ├── BulletAgeSystem.cs.meta │ │ │ ├── DisconnectSystem.cs │ │ │ ├── DisconnectSystem.cs.meta │ │ │ ├── PlayerDestructionSystem.cs │ │ │ ├── PlayerDestructionSystem.cs.meta │ │ │ ├── PlayerRelevancySphereSystem.cs │ │ │ ├── PlayerRelevancySphereSystem.cs.meta │ │ │ ├── PlayerSpawnSystem.cs │ │ │ ├── PlayerSpawnSystem.cs.meta │ │ │ ├── ServerSendGameSystem.cs │ │ │ ├── ServerSendGameSystem.cs.meta │ │ │ ├── SetupScoreSystem.cs │ │ │ └── SetupScoreSystem.cs.meta │ ├── ServerLaunchObject.prefab │ └── ServerLaunchObject.prefab.meta ├── UI Toolkit.meta ├── UI Toolkit │ ├── UnityThemes.meta │ └── UnityThemes │ │ ├── UnityDefaultRuntimeTheme.tss │ │ └── UnityDefaultRuntimeTheme.tss.meta ├── UI.meta ├── UI │ ├── Cervo.otf │ ├── Cervo.otf.meta │ ├── GameOverlayUpdater.cs │ ├── GameOverlayUpdater.cs.meta │ ├── GameUI.uss │ ├── GameUI.uss.meta │ ├── GameUIManager.cs │ ├── GameUIManager.cs.meta │ ├── GameUIManager.uxml │ ├── GameUIManager.uxml.meta │ ├── HV.ttf │ ├── HV.ttf.meta │ ├── HostGameScreen.cs │ ├── HostGameScreen.cs.meta │ ├── HostGameScreen.uxml │ ├── HostGameScreen.uxml.meta │ ├── JoinGameScreen.cs │ ├── JoinGameScreen.cs.meta │ ├── JoinGameScreen.uxml │ ├── JoinGameScreen.uxml.meta │ ├── ListItem.uxml │ ├── ListItem.uxml.meta │ ├── ManualConnectScreen.cs │ ├── ManualConnectScreen.cs.meta │ ├── ManualConnectScreen.uxml │ ├── ManualConnectScreen.uxml.meta │ ├── PanelSettings.asset │ ├── PanelSettings.asset.meta │ ├── QuitButtonHandler.cs │ ├── QuitButtonHandler.cs.meta │ ├── TitleScreen.uxml │ ├── TitleScreen.uxml.meta │ ├── TitleScreenManager.cs │ ├── TitleScreenManager.cs.meta │ ├── TitleScreenManager.uxml │ ├── TitleScreenManager.uxml.meta │ ├── TitleScreenUI.uss │ ├── TitleScreenUI.uss.meta │ ├── moetsi-logo-hq.png │ └── moetsi-logo-hq.png.meta ├── UniversalRenderPipelineAsset.asset ├── UniversalRenderPipelineAsset.asset.meta ├── UniversalRenderPipelineAsset_Renderer.asset └── UniversalRenderPipelineAsset_Renderer.asset.meta ├── LICENSE ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── BurstAotSettings_StandaloneWindows.json ├── ClusterInputManager.asset ├── CommonBurstAotSettings.json ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── PackageManagerSettings.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── URPProjectSettings.asset ├── UnityConnectSettings.asset ├── VFXManager.asset ├── VersionControlSettings.asset └── XRSettings.asset ├── README.md └── UIElementsSchema ├── GlobalNamespace.xsd ├── UIElements.xsd ├── Unity.Cloud.Collaborate.Components.ChangeListEntries.xsd ├── Unity.Cloud.Collaborate.Components.xsd ├── Unity.Cloud.Collaborate.Views.xsd ├── Unity.Editor.Bridge.xsd ├── Unity.Entities.Editor.UIElements.xsd ├── Unity.Entities.Editor.xsd ├── Unity.Properties.UI.xsd ├── Unity.UI.Builder.xsd ├── UnityEditor.Experimental.GraphView.xsd ├── UnityEditor.PackageManager.UI.xsd ├── UnityEditor.Rendering.LookDev.xsd ├── UnityEditor.ShaderGraph.Drawing.xsd ├── UnityEditor.ShortcutManagement.xsd ├── UnityEditor.UIElements.Debugger.xsd ├── UnityEditor.UIElements.xsd ├── UnityEngine.UIElements.xsd └── UnityEngine.UIExtras.xsd /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Uu]ser[Ss]ettings/ 12 | /[Aa]ssets/[Ss]ceneDependencyCache/ 13 | /[Aa]ssets/[Nn]etCodeGenerated/ 14 | 15 | # MemoryCaptures can get excessive in size. 16 | # They also could contain extremely sensitive data 17 | /[Mm]emoryCaptures/ 18 | 19 | # Asset meta data should only be ignored when the corresponding asset is also ignored 20 | !/[Aa]ssets/**/*.meta 21 | 22 | SceneDependencyCache.meta 23 | NetCodeGenerated.meta 24 | .DS_Store 25 | 26 | # Uncomment this line if you wish to ignore the asset store tools plugin 27 | # /[Aa]ssets/AssetStoreTools* 28 | 29 | # Autogenerated Jetbrains Rider plugin 30 | /[Aa]ssets/Plugins/Editor/JetBrains* 31 | 32 | # Visual Studio cache directory 33 | .vs/ 34 | .vscode/ 35 | 36 | # Gradle cache directory 37 | .gradle/ 38 | 39 | # Autogenerated VS/MD/Consulo solution and project files 40 | ExportedObj/ 41 | .consulo/ 42 | *.csproj 43 | *.unityproj 44 | *.sln 45 | *.suo 46 | *.tmp 47 | *.user 48 | *.userprefs 49 | *.pidb 50 | *.booproj 51 | *.svd 52 | *.pdb 53 | *.mdb 54 | *.opendb 55 | *.VC.db 56 | 57 | # Unity3D generated meta files 58 | *.pidb.meta 59 | *.pdb.meta 60 | *.mdb.meta 61 | 62 | # Unity3D generated file on crash reports 63 | sysinfo.txt 64 | 65 | # Builds 66 | *.apk 67 | *.aab 68 | *.unitypackage 69 | 70 | # Crashlytics generated file 71 | crashlytics-build.properties 72 | 73 | # Packed Addressables 74 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* 75 | 76 | # Temporary auto-generated Android Assets 77 | /[Aa]ssets/[Ss]treamingAssets/aa.meta 78 | /[Aa]ssets/[Ss]treamingAssets/aa/* 79 | -------------------------------------------------------------------------------- /Assets/Black.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37b25b1920432084583debdbc9f3ec66 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/BuildSettings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1af2fa6b2cc999740a74d99fa1b1374f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/BuildSettings/Android-Build.buildconfiguration: -------------------------------------------------------------------------------- 1 | { 2 | "Show": true, 3 | "Dependencies": [ 4 | "GlobalObjectId_V1-1-f19661c01bdcad546b54998aa9a0d08a-93214019566545601-0" 5 | ], 6 | "Components": [ 7 | { 8 | "$type": "Unity.Build.Classic.ClassicBuildProfile, Unity.Build.Classic", 9 | "$version": 1, 10 | "Platform": "android", 11 | "Configuration": 2 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /Assets/BuildSettings/Android-Build.buildconfiguration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72dc1d93b0c9e8c4e87ce52610b3d81d 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 627ef77bce55554428c21a56f59002bd, type: 3} 11 | -------------------------------------------------------------------------------- /Assets/BuildSettings/BaseBuildConfiguration.buildconfiguration: -------------------------------------------------------------------------------- 1 | { 2 | "Show": true, 3 | "Dependencies": [], 4 | "Components": [ 5 | { 6 | "$type": "Unity.Build.Common.GeneralSettings, Unity.Build", 7 | "ProductName": "Asteroids 3D XR", 8 | "CompanyName": "Moetsi", 9 | "Version": "1.0.0" 10 | }, 11 | { 12 | "$type": "Unity.Build.Common.SceneList, Unity.Build", 13 | "$version": 1, 14 | "BuildCurrentScene": false, 15 | "SceneInfos": [ 16 | { 17 | "Scene": "GlobalObjectId_V1-1-8f9ca7d3bb05e944a9c8f37d1238b233-102900000-0", 18 | "AutoLoad": false 19 | }, 20 | { 21 | "Scene": "GlobalObjectId_V1-1-9fc0d4010bbf28b4594072e72b8655ab-102900000-0", 22 | "AutoLoad": false 23 | } 24 | ] 25 | }, 26 | { 27 | "$type": "Unity.Build.Classic.ClassicScriptingSettings, Unity.Build.Classic", 28 | "ScriptingBackend": 1, 29 | "Il2CppCompilerConfiguration": 1, 30 | "UseIncrementalGC": false 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /Assets/BuildSettings/BaseBuildConfiguration.buildconfiguration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf1192d2f76946f449c781392d636538 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 627ef77bce55554428c21a56f59002bd, type: 3} 11 | -------------------------------------------------------------------------------- /Assets/BuildSettings/Linux-Build.buildconfiguration: -------------------------------------------------------------------------------- 1 | { 2 | "Show": true, 3 | "Dependencies": [ 4 | "GlobalObjectId_V1-1-f19661c01bdcad546b54998aa9a0d08a-93214019566545601-0" 5 | ], 6 | "Components": [ 7 | { 8 | "$type": "Unity.Build.Classic.ClassicBuildProfile, Unity.Build.Classic", 9 | "$version": 1, 10 | "Platform": "linux", 11 | "Configuration": 2 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /Assets/BuildSettings/Linux-Build.buildconfiguration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 423df40138ac494469f75a939c6b03dd 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 627ef77bce55554428c21a56f59002bd, type: 3} 11 | -------------------------------------------------------------------------------- /Assets/BuildSettings/Sample macOS Build Configuration.buildconfiguration: -------------------------------------------------------------------------------- 1 | { 2 | "Show": true, 3 | "Dependencies": [], 4 | "Components": [ 5 | { 6 | "$type": "Unity.Build.Classic.ClassicBuildProfile, Unity.Build.Classic", 7 | "$version": 1, 8 | "Platform": "StandaloneOSX", 9 | "Configuration": 2 10 | }, 11 | { 12 | "$type": "Unity.Build.Common.SceneList, Unity.Build", 13 | "$version": 1, 14 | "BuildCurrentScene": true, 15 | "SceneInfos": [] 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /Assets/BuildSettings/Sample macOS Build Configuration.buildconfiguration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00cc067d675e82d4398a78f4c75304ff 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 627ef77bce55554428c21a56f59002bd, type: 3} 11 | -------------------------------------------------------------------------------- /Assets/BuildSettings/Win64-Build.buildconfiguration: -------------------------------------------------------------------------------- 1 | { 2 | "Show": true, 3 | "Dependencies": [ 4 | "GlobalObjectId_V1-1-bf1192d2f76946f449c781392d636538-93214019566545601-0" 5 | ], 6 | "Components": [ 7 | { 8 | "$type": "Unity.Build.Classic.ClassicBuildProfile, Unity.Build.Classic", 9 | "$version": 1, 10 | "Platform": "StandaloneWindows64", 11 | "Configuration": 2 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /Assets/BuildSettings/Win64-Build.buildconfiguration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 767ee5adc94a1ec42bc680906f8a00a1 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 627ef77bce55554428c21a56f59002bd, type: 3} 11 | -------------------------------------------------------------------------------- /Assets/BuildSettings/macOS-Build.buildconfiguration: -------------------------------------------------------------------------------- 1 | { 2 | "Show": true, 3 | "Dependencies": [ 4 | "GlobalObjectId_V1-1-f19661c01bdcad546b54998aa9a0d08a-93214019566545601-0" 5 | ], 6 | "Components": [ 7 | { 8 | "$type": "Unity.Build.Classic.ClassicBuildProfile, Unity.Build.Classic", 9 | "$version": 1, 10 | "Platform": "macos", 11 | "Configuration": 2 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /Assets/BuildSettings/macOS-Build.buildconfiguration.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3be3c70428c4f454a8c5d4b5f202fd7c 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 627ef77bce55554428c21a56f59002bd, type: 3} 11 | -------------------------------------------------------------------------------- /Assets/GreyMaterial.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76cc0475fcf616b43a94eacf77a5c0e0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Physics Category Names.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: cea4b49c4d6784a3291bea84d8086c8e, type: 3} 13 | m_Name: Physics Category Names 14 | m_EditorClassIdentifier: 15 | m_CategoryNames: 16 | - Trigger 17 | - Asteroid 18 | - Bullet 19 | - Player 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | - 41 | - 42 | - 43 | - 44 | - 45 | - 46 | - 47 | - 48 | -------------------------------------------------------------------------------- /Assets/Physics Category Names.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69bd45ac2e99e0c48b5c50229b1925bd 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Red.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &-7602240209102994251 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 11 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | version: 4 16 | --- !u!21 &2100000 17 | Material: 18 | serializedVersion: 6 19 | m_ObjectHideFlags: 0 20 | m_CorrespondingSourceObject: {fileID: 0} 21 | m_PrefabInstance: {fileID: 0} 22 | m_PrefabAsset: {fileID: 0} 23 | m_Name: Red 24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} 25 | m_ShaderKeywords: 26 | m_LightmapFlags: 4 27 | m_EnableInstancingVariants: 0 28 | m_DoubleSidedGI: 0 29 | m_CustomRenderQueue: 2000 30 | stringTagMap: 31 | RenderType: Opaque 32 | disabledShaderPasses: [] 33 | m_SavedProperties: 34 | serializedVersion: 3 35 | m_TexEnvs: 36 | - _BaseMap: 37 | m_Texture: {fileID: 0} 38 | m_Scale: {x: 1, y: 1} 39 | m_Offset: {x: 0, y: 0} 40 | - _BumpMap: 41 | m_Texture: {fileID: 0} 42 | m_Scale: {x: 1, y: 1} 43 | m_Offset: {x: 0, y: 0} 44 | - _DetailAlbedoMap: 45 | m_Texture: {fileID: 0} 46 | m_Scale: {x: 1, y: 1} 47 | m_Offset: {x: 0, y: 0} 48 | - _DetailMask: 49 | m_Texture: {fileID: 0} 50 | m_Scale: {x: 1, y: 1} 51 | m_Offset: {x: 0, y: 0} 52 | - _DetailNormalMap: 53 | m_Texture: {fileID: 0} 54 | m_Scale: {x: 1, y: 1} 55 | m_Offset: {x: 0, y: 0} 56 | - _EmissionMap: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | - _MainTex: 61 | m_Texture: {fileID: 0} 62 | m_Scale: {x: 1, y: 1} 63 | m_Offset: {x: 0, y: 0} 64 | - _MetallicGlossMap: 65 | m_Texture: {fileID: 0} 66 | m_Scale: {x: 1, y: 1} 67 | m_Offset: {x: 0, y: 0} 68 | - _OcclusionMap: 69 | m_Texture: {fileID: 0} 70 | m_Scale: {x: 1, y: 1} 71 | m_Offset: {x: 0, y: 0} 72 | - _ParallaxMap: 73 | m_Texture: {fileID: 0} 74 | m_Scale: {x: 1, y: 1} 75 | m_Offset: {x: 0, y: 0} 76 | - _SpecGlossMap: 77 | m_Texture: {fileID: 0} 78 | m_Scale: {x: 1, y: 1} 79 | m_Offset: {x: 0, y: 0} 80 | - unity_Lightmaps: 81 | m_Texture: {fileID: 0} 82 | m_Scale: {x: 1, y: 1} 83 | m_Offset: {x: 0, y: 0} 84 | - unity_LightmapsInd: 85 | m_Texture: {fileID: 0} 86 | m_Scale: {x: 1, y: 1} 87 | m_Offset: {x: 0, y: 0} 88 | - unity_ShadowMasks: 89 | m_Texture: {fileID: 0} 90 | m_Scale: {x: 1, y: 1} 91 | m_Offset: {x: 0, y: 0} 92 | m_Floats: 93 | - _AlphaClip: 0 94 | - _Blend: 0 95 | - _BumpScale: 1 96 | - _ClearCoatMask: 0 97 | - _ClearCoatSmoothness: 0 98 | - _Cull: 2 99 | - _Cutoff: 0.5 100 | - _DetailAlbedoMapScale: 1 101 | - _DetailNormalMapScale: 1 102 | - _DstBlend: 0 103 | - _EnvironmentReflections: 1 104 | - _GlossMapScale: 0 105 | - _Glossiness: 0 106 | - _GlossyReflections: 0 107 | - _Metallic: 0 108 | - _OcclusionStrength: 1 109 | - _Parallax: 0.005 110 | - _QueueOffset: 0 111 | - _ReceiveShadows: 1 112 | - _Smoothness: 0.5 113 | - _SmoothnessTextureChannel: 0 114 | - _SpecularHighlights: 1 115 | - _SrcBlend: 1 116 | - _Surface: 0 117 | - _WorkflowMode: 1 118 | - _ZWrite: 1 119 | m_Colors: 120 | - _BaseColor: {r: 1, g: 0, b: 0, a: 1} 121 | - _Color: {r: 1, g: 1, b: 1, a: 1} 122 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 123 | - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} 124 | m_BuildTextureStacks: [] 125 | -------------------------------------------------------------------------------- /Assets/Red.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1b6416dc28490e4798f955604d46849 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b05589d26d5b2c9478cffc5f162b9367 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/MainScene.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 055a9b514a81b574cb5cba5fe38b3724 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/MainScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fc0d4010bbf28b4594072e72b8655ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scenes/MainScene/ConvertedSubScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33fc5f7d477e0e842b6f1aea03825cac 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scenes/NavigationScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f9ca7d3bb05e944a9c8f37d1238b233 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67d137b27e6ae384ab8e5926d32575fa 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Asteroid.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2d5e8e89406b7743b247cddb0aaf6bd 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e06c10510f890403ab0a39cd969db6f0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/ClientSettingsAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct ClientSettings : IComponentData 5 | { 6 | public float predictionRadius; 7 | public float predictionRadiusMargin; 8 | 9 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/ClientSettingsAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a684f61b0c5d64b5988d9492c5159d13 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/SetBulletSpawnOffset.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | public class SetBulletSpawnOffset : UnityEngine.MonoBehaviour, IConvertGameObjectToEntity 6 | { 7 | public GameObject bulletSpawn; 8 | 9 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) 10 | { 11 | var bulletOffset = default(PlayerStateAndOffsetComponent); 12 | 13 | var offsetVector = bulletSpawn.transform.position; 14 | bulletOffset.Value = new float3(offsetVector.x, offsetVector.y, offsetVector.z); 15 | 16 | dstManager.AddComponentData(entity, bulletOffset); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/SetBulletSpawnOffset.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d82981ae819838043b24630ff2347a88 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/SetGameSettingsSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using UnityEngine; 4 | 5 | public class SetGameSettingsSystem : UnityEngine.MonoBehaviour, IConvertGameObjectToEntity 6 | { 7 | public float asteroidVelocity = 10f; 8 | public float playerForce = 50f; 9 | public float bulletVelocity = 500f; 10 | public int numAsteroids = 200; 11 | public int levelWidth = 2048; 12 | public int levelHeight = 2048; 13 | public int levelDepth = 2048; 14 | public int relevencyRadius = 0; 15 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) 16 | { 17 | var settings = default(GameSettingsComponent); 18 | settings.asteroidVelocity = asteroidVelocity; 19 | settings.playerForce = playerForce; 20 | settings.bulletVelocity = bulletVelocity; 21 | settings.numAsteroids = numAsteroids; 22 | settings.levelWidth = levelWidth; 23 | settings.levelHeight = levelHeight; 24 | settings.levelDepth = levelDepth; 25 | settings.relevancyRadius = relevencyRadius; 26 | dstManager.AddComponentData(entity, settings); 27 | } 28 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/SetGameSettingsSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21782bdf7e6936f48be6dad724d15f25 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/StatefulCollisionEventBufferAuthoring.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | namespace Unity.Physics.Stateful 5 | { 6 | public struct StatefulCollisionEventDetails : IComponentData 7 | { 8 | public bool CalculateDetails; 9 | } 10 | 11 | public class StatefulCollisionEventBufferAuthoring : MonoBehaviour, IConvertGameObjectToEntity 12 | { 13 | [Tooltip("If selected, the details will be calculated in collision event dynamic buffer of this entity")] 14 | public bool CalculateDetails = false; 15 | 16 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) 17 | { 18 | if (CalculateDetails) 19 | { 20 | var dynamicBufferTag = new StatefulCollisionEventDetails 21 | { 22 | CalculateDetails = CalculateDetails 23 | }; 24 | 25 | dstManager.AddComponentData(entity, dynamicBufferTag); 26 | } 27 | dstManager.AddBuffer(entity); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/StatefulCollisionEventBufferAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83b070cd7fd2e024089c0e82c6e92c20 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/StatefulTriggerEventBufferAuthoring.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Jobs; 3 | using Unity.Physics; 4 | using Unity.Physics.Systems; 5 | using UnityEngine; 6 | using Unity.Collections; 7 | using Unity.Burst; 8 | using System; 9 | using Unity.Assertions; 10 | using Unity.Mathematics; 11 | 12 | namespace Unity.Physics.Stateful 13 | { 14 | // If this component is added to an entity, trigger events won't be added to a dynamic buffer 15 | // of that entity by the StatefulTriggerEventBufferSystem. This component is by default added to 16 | // CharacterController entity, so that CharacterControllerSystem can add trigger events to 17 | // CharacterController on its own, without StatefulTriggerEventBufferSystem interference. 18 | public struct StatefulTriggerEventExclude : IComponentData {} 19 | 20 | public class StatefulTriggerEventBufferAuthoring : MonoBehaviour, IConvertGameObjectToEntity 21 | { 22 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) 23 | { 24 | dstManager.AddBuffer(entity); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Authoring/StatefulTriggerEventBufferAuthoring.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b1c4776a82ff0b4ab178254d3f264a6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Bullet.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f69a28f54d34d64fa3f83138edc820f 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Camera.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &2577390833698829640 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 6798768136949990004} 12 | - component: {fileID: 5833164939044478438} 13 | - component: {fileID: 8468740281841558546} 14 | - component: {fileID: 4126221711746424948} 15 | m_Layer: 0 16 | m_Name: Camera 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &6798768136949990004 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 2577390833698829640} 29 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 30 | m_LocalPosition: {x: 0, y: 2, z: -5} 31 | m_LocalScale: {x: 1, y: 1, z: 1} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!20 &5833164939044478438 37 | Camera: 38 | m_ObjectHideFlags: 0 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInstance: {fileID: 0} 41 | m_PrefabAsset: {fileID: 0} 42 | m_GameObject: {fileID: 2577390833698829640} 43 | m_Enabled: 1 44 | serializedVersion: 2 45 | m_ClearFlags: 1 46 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 47 | m_projectionMatrixMode: 1 48 | m_GateFitMode: 2 49 | m_FOVAxisMode: 0 50 | m_SensorSize: {x: 36, y: 24} 51 | m_LensShift: {x: 0, y: 0} 52 | m_FocalLength: 50 53 | m_NormalizedViewPortRect: 54 | serializedVersion: 2 55 | x: 0 56 | y: 0 57 | width: 1 58 | height: 1 59 | near clip plane: 0.3 60 | far clip plane: 1000 61 | field of view: 60 62 | orthographic: 0 63 | orthographic size: 5 64 | m_Depth: 0 65 | m_CullingMask: 66 | serializedVersion: 2 67 | m_Bits: 4294967295 68 | m_RenderingPath: -1 69 | m_TargetTexture: {fileID: 0} 70 | m_TargetDisplay: 0 71 | m_TargetEye: 3 72 | m_HDR: 1 73 | m_AllowMSAA: 1 74 | m_AllowDynamicResolution: 0 75 | m_ForceIntoRT: 0 76 | m_OcclusionCulling: 1 77 | m_StereoConvergence: 10 78 | m_StereoSeparation: 0.022 79 | --- !u!81 &8468740281841558546 80 | AudioListener: 81 | m_ObjectHideFlags: 0 82 | m_CorrespondingSourceObject: {fileID: 0} 83 | m_PrefabInstance: {fileID: 0} 84 | m_PrefabAsset: {fileID: 0} 85 | m_GameObject: {fileID: 2577390833698829640} 86 | m_Enabled: 1 87 | --- !u!114 &4126221711746424948 88 | MonoBehaviour: 89 | m_ObjectHideFlags: 0 90 | m_CorrespondingSourceObject: {fileID: 0} 91 | m_PrefabInstance: {fileID: 0} 92 | m_PrefabAsset: {fileID: 0} 93 | m_GameObject: {fileID: 2577390833698829640} 94 | m_Enabled: 1 95 | m_EditorHideFlags: 0 96 | m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} 97 | m_Name: 98 | m_EditorClassIdentifier: 99 | m_RenderShadows: 1 100 | m_RequiresDepthTextureOption: 2 101 | m_RequiresOpaqueTextureOption: 2 102 | m_CameraType: 0 103 | m_Cameras: [] 104 | m_RendererIndex: -1 105 | m_VolumeLayerMask: 106 | serializedVersion: 2 107 | m_Bits: 1 108 | m_VolumeTrigger: {fileID: 0} 109 | m_VolumeFrameworkUpdateModeOption: 2 110 | m_RenderPostProcessing: 0 111 | m_Antialiasing: 0 112 | m_AntialiasingQuality: 2 113 | m_StopNaN: 0 114 | m_Dithering: 0 115 | m_ClearDepth: 1 116 | m_AllowXRRendering: 1 117 | m_RequiresDepthTexture: 0 118 | m_RequiresColorTexture: 0 119 | m_Version: 2 120 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Camera.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca49a7abcacd64ef284911a6cab8252e 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ad4fffac7b3a354ba7550100cb38514 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8419e6a3e53b84769af988eb9e8b1588 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Components/CameraAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | [GenerateAuthoringComponent] 5 | public struct CameraAuthoringComponent : IComponentData 6 | { 7 | public Entity Prefab; 8 | } 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Components/CameraAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d69d92bc5dedd413bb9136dc2260b617 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Components/PlayerClassifiedTag.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | public struct PlayerClassifiedTag : IComponentData 5 | { 6 | } 7 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Components/PlayerClassifiedTag.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67b3a3267cc344616a57bbd817184a69 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 434147fb6ccbf8e40ad7e7e07de3906c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/AsteroidSwitchPredictionSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using Unity.Transforms; 4 | using Unity.NetCode; 5 | using Unity.Collections; 6 | using Unity.Burst; 7 | 8 | [UpdateInGroup(typeof(ClientSimulationSystemGroup))] 9 | public partial class AsteroidSwitchPredictionSystem : SystemBase 10 | { 11 | private NativeList m_ToPredicted; 12 | private NativeList m_ToInterpolated; 13 | private GhostSpawnSystem m_GhostSpawnSystem; 14 | protected override void OnCreate() 15 | { 16 | RequireSingletonForUpdate(); 17 | m_ToPredicted = new NativeList(16, Allocator.Persistent); 18 | m_ToInterpolated = new NativeList(16, Allocator.Persistent); 19 | m_GhostSpawnSystem = World.GetExistingSystem(); 20 | } 21 | protected override void OnDestroy() 22 | { 23 | m_ToPredicted.Dispose(); 24 | m_ToInterpolated.Dispose(); 25 | } 26 | protected override void OnUpdate() 27 | { 28 | var spawnSystem = m_GhostSpawnSystem; 29 | var toPredicted = m_ToPredicted; 30 | var toInterpolated = m_ToInterpolated; 31 | for (int i = 0; i < toPredicted.Length; ++i) 32 | { 33 | if (EntityManager.HasComponent(toPredicted[i])) 34 | spawnSystem.ConvertGhostToPredicted(toPredicted[i], 1.0f); 35 | } 36 | for (int i = 0; i < toInterpolated.Length; ++i) 37 | { 38 | if (EntityManager.HasComponent(toInterpolated[i])) 39 | spawnSystem.ConvertGhostToInterpolated(toInterpolated[i], 1.0f); 40 | } 41 | toPredicted.Clear(); 42 | toInterpolated.Clear(); 43 | 44 | var settings = GetSingleton(); 45 | if (settings.predictionRadius <= 0) 46 | return; 47 | 48 | if (!TryGetSingletonEntity(out var playerEnt) || !EntityManager.HasComponent(playerEnt)) 49 | return; 50 | var playerPos = EntityManager.GetComponentData(playerEnt).Value; 51 | 52 | var radiusSq = settings.predictionRadius*settings.predictionRadius; 53 | Entities 54 | .WithNone() 55 | .WithAll() 56 | .ForEach((Entity ent, in Translation position) => 57 | { 58 | if (math.distancesq(playerPos, position.Value) < radiusSq) 59 | { 60 | // convert to predicted 61 | toPredicted.Add(ent); 62 | } 63 | }).Schedule(); 64 | radiusSq = settings.predictionRadius + settings.predictionRadiusMargin; 65 | radiusSq = radiusSq*radiusSq; 66 | Entities 67 | .WithAll() 68 | .WithAll() 69 | .ForEach((Entity ent, in Translation position) => 70 | { 71 | if (math.distancesq(playerPos, position.Value) > radiusSq) 72 | { 73 | // convert to interpolated 74 | toInterpolated.Add(ent); 75 | } 76 | }).Schedule(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/AsteroidSwitchPredictionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0e4d26ee889f447d8d9840193430e64 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/BulletGhostSpawnClassificationSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Collections; 3 | using Unity.Entities; 4 | using Unity.Jobs; 5 | using Unity.Mathematics; 6 | using Unity.NetCode; 7 | using Unity.Networking.Transport.Utilities; 8 | 9 | //This system will only run on the client and within GhostSimulationSystemGroup 10 | //and after GhostSpawnClassification system as is specified in the NetCode documentation 11 | [UpdateInWorld(TargetWorld.Client)] 12 | [UpdateInGroup(typeof(GhostSimulationSystemGroup))] 13 | [UpdateAfter(typeof(GhostSpawnClassificationSystem))] 14 | public partial class BulletGhostSpawnClassificationSystem : SystemBase 15 | { 16 | protected override void OnCreate() 17 | { 18 | //Both of these components are needed in the OnUpdate so we will wait until they exist to update 19 | RequireSingletonForUpdate(); 20 | RequireSingletonForUpdate(); 21 | } 22 | protected override void OnUpdate() 23 | { 24 | //This is the NetCode recommended method to identify predicted spawning for player spawned objects 25 | //More information can be found at: https://docs.unity3d.com/Packages/com.unity.netcode@0.5/manual/ghost-snapshots.html 26 | //under "Entity spawning" 27 | var spawnListEntity = GetSingletonEntity(); 28 | var spawnListFromEntity = GetBufferFromEntity(); 29 | Dependency = Entities 30 | .WithAll() 31 | .WithoutBurst() 32 | .ForEach((DynamicBuffer ghosts, DynamicBuffer data) => 33 | { 34 | var spawnList = spawnListFromEntity[spawnListEntity]; 35 | for (int i = 0; i < ghosts.Length; ++i) 36 | { 37 | var ghost = ghosts[i]; 38 | if (ghost.SpawnType == GhostSpawnBuffer.Type.Predicted) 39 | { 40 | for (int j = 0; j < spawnList.Length; ++j) 41 | { 42 | if (ghost.GhostType == spawnList[j].ghostType && !SequenceHelpers.IsNewer(spawnList[j].spawnTick, ghost.ServerSpawnTick + 5) && SequenceHelpers.IsNewer(spawnList[j].spawnTick + 5, ghost.ServerSpawnTick)) 43 | { 44 | ghost.PredictedSpawnEntity = spawnList[j].entity; 45 | spawnList[j] = spawnList[spawnList.Length-1]; 46 | spawnList.RemoveAt(spawnList.Length - 1); 47 | break; 48 | } 49 | } 50 | ghosts[i] = ghost; 51 | } 52 | } 53 | }).Schedule(Dependency); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/BulletGhostSpawnClassificationSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 851cd86227e764953bbfeac5a7515fbd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/ClientLoadGameSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b70af8d08fc0194448501c33f0b341b9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/InputSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ad079b17289346cba5778ef75b765f2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/PlayerGhostSpawnClassificationSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Entities; 3 | using Unity.Jobs; 4 | using Unity.NetCode; 5 | using UnityEngine; 6 | using Unity.Transforms; 7 | using Unity.Mathematics; 8 | 9 | //We are updating only in the client world because only the client must specify exactly which player entity it "owns" 10 | [UpdateInWorld(TargetWorld.Client)] 11 | //We will be updating after NetCode's GhostSpawnClassificationSystem because we want 12 | //to ensure that the PredictedGhostComponent (which it adds) is available on the player entity to identify it 13 | [UpdateInGroup(typeof(GhostSimulationSystemGroup))] 14 | [UpdateAfter(typeof(GhostSpawnClassificationSystem))] 15 | public partial class PlayerGhostSpawnClassificationSystem : SystemBase 16 | { 17 | private BeginSimulationEntityCommandBufferSystem m_BeginSimEcb; 18 | 19 | //We will store the Camera prefab here which we will attach when we identify our player entity 20 | private Entity m_CameraPrefab; 21 | 22 | protected override void OnCreate() 23 | { 24 | m_BeginSimEcb = World.GetExistingSystem(); 25 | 26 | //We need to make sure we have NCE before we start the update loop (otherwise it's unnecessary) 27 | RequireSingletonForUpdate(); 28 | RequireSingletonForUpdate(); 29 | } 30 | 31 | protected override void OnUpdate() 32 | { 33 | //Here we set the prefab we will use 34 | if (m_CameraPrefab == Entity.Null) 35 | { 36 | //We grab our camera and set our variable 37 | m_CameraPrefab = GetSingleton().Prefab; 38 | return; 39 | } 40 | 41 | var commandBuffer = m_BeginSimEcb.CreateCommandBuffer().AsParallelWriter(); 42 | 43 | //We must declare our local variables before using them 44 | var camera = m_CameraPrefab; 45 | //The "playerEntity" is the NCE 46 | var networkIdComponent = GetSingleton(); 47 | //The false is to signify that the data will NOT be read-only 48 | var commandTargetFromEntity = GetComponentDataFromEntity(false); 49 | 50 | //We will look for Player prefabs that we have not added a "PlayerClassifiedTag" to (which means we have checked the player if it is "ours") 51 | Entities 52 | .WithAll() 53 | .WithNone() 54 | .ForEach((Entity entity, int entityInQueryIndex, in GhostOwnerComponent ghostOwnerComponent) => 55 | { 56 | // If this is true this means this Player is mine (because the GhostOwnerComponent value is equal to the NetworkId) 57 | // Remember the GhostOwnerComponent value is set by the server and is ghosted to the client 58 | if (ghostOwnerComponent.NetworkId == networkIdComponent.Value) 59 | { 60 | //This creates our camera 61 | var cameraEntity = commandBuffer.Instantiate(entityInQueryIndex, camera); 62 | //This is how you "attach" a prefab entity to another 63 | commandBuffer.AddComponent(entityInQueryIndex, cameraEntity, new Parent { Value = entity }); 64 | commandBuffer.AddComponent(entityInQueryIndex, cameraEntity, new LocalToParent() ); 65 | } 66 | // This means we have classified this Player prefab 67 | commandBuffer.AddComponent(entityInQueryIndex, entity, new PlayerClassifiedTag() ); 68 | 69 | }).ScheduleParallel(); 70 | 71 | m_BeginSimEcb.AddJobHandleForProducer(Dependency); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Client/Systems/PlayerGhostSpawnClassificationSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c33ce2e5d26b5428fa8ef257de49bf6b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/ClientLaunchObject.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1543972213501696171 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 1543972213501696173} 12 | - component: {fileID: 1543972213501696172} 13 | m_Layer: 0 14 | m_Name: ClientLaunchObject 15 | m_TagString: LaunchObject 16 | m_Icon: {fileID: 0} 17 | m_NavMeshLayer: 0 18 | m_StaticEditorFlags: 0 19 | m_IsActive: 1 20 | --- !u!4 &1543972213501696173 21 | Transform: 22 | m_ObjectHideFlags: 0 23 | m_CorrespondingSourceObject: {fileID: 0} 24 | m_PrefabInstance: {fileID: 0} 25 | m_PrefabAsset: {fileID: 0} 26 | m_GameObject: {fileID: 1543972213501696171} 27 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 28 | m_LocalPosition: {x: 16.59667, y: 5.2416935, z: 74.71923} 29 | m_LocalScale: {x: 1, y: 1, z: 1} 30 | m_Children: [] 31 | m_Father: {fileID: 0} 32 | m_RootOrder: 0 33 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 34 | --- !u!114 &1543972213501696172 35 | MonoBehaviour: 36 | m_ObjectHideFlags: 0 37 | m_CorrespondingSourceObject: {fileID: 0} 38 | m_PrefabInstance: {fileID: 0} 39 | m_PrefabAsset: {fileID: 0} 40 | m_GameObject: {fileID: 1543972213501696171} 41 | m_Enabled: 1 42 | m_EditorHideFlags: 0 43 | m_Script: {fileID: 11500000, guid: c71cc600930ab3041a4bfaf6b7ca3257, type: 3} 44 | m_Name: 45 | m_EditorClassIdentifier: 46 | PlayerName: 47 | IPAddress: 127.0.0.1 48 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/ClientLaunchObject.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa67ed701698eb2428be77662757ddac 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/HighestScore.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d31217dae128ceb488ed981e4fc61517 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 070c88e88dbf2a24e9b0ef535ff38a50 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f6b38c892fa0e2b4ea00463e7071bdcf 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/PlayerSpawnRequestRpc.cs: -------------------------------------------------------------------------------- 1 | using Unity.NetCode; 2 | using Unity.Entities; 3 | 4 | public struct PlayerSpawnRequestRpc : IRpcCommand 5 | { 6 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/PlayerSpawnRequestRpc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f09b8fa561bd48819038b2626db92be 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/SendClientGameRpc.cs: -------------------------------------------------------------------------------- 1 | using AOT; 2 | using Unity.Burst; 3 | using Unity.Networking.Transport; 4 | using Unity.NetCode; 5 | using Unity.Entities; 6 | using Unity.Collections; 7 | using System.Collections; 8 | using System; 9 | 10 | public struct SendClientGameRpc : IRpcCommand 11 | { 12 | public int levelWidth; 13 | public int levelHeight; 14 | public int levelDepth; 15 | public float playerForce; 16 | public float bulletVelocity; 17 | public FixedString64Bytes gameName; 18 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/SendClientGameRpc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8646c7ba602b0347a548e488d52b51a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/SendServerGameLoadedRpc.cs: -------------------------------------------------------------------------------- 1 | using AOT; 2 | using Unity.Burst; 3 | using Unity.Networking.Transport; 4 | using Unity.NetCode; 5 | using Unity.Entities; 6 | using UnityEngine; 7 | using Unity.Collections; 8 | 9 | [BurstCompile] 10 | public struct SendServerGameLoadedRpc : IComponentData, IRpcCommandSerializer 11 | { 12 | //Necessary boilerplate 13 | public void Serialize(ref DataStreamWriter writer, in RpcSerializerState state, in SendServerGameLoadedRpc data) 14 | { 15 | } 16 | //Necessary boilerplate 17 | public void Deserialize(ref DataStreamReader reader, in RpcDeserializerState state, ref SendServerGameLoadedRpc data) 18 | { 19 | } 20 | 21 | [BurstCompile] 22 | [MonoPInvokeCallback(typeof(RpcExecutor.ExecuteDelegate))] 23 | private static void InvokeExecute(ref RpcExecutor.Parameters parameters) 24 | { 25 | //Within here is where 26 | var rpcData = default(SendServerGameLoadedRpc); 27 | 28 | //Here we deserialize the received data 29 | rpcData.Deserialize(ref parameters.Reader, parameters.DeserializerState, ref rpcData); 30 | 31 | //Here we add 3 components to the NCE 32 | //The first, PlayerSpawningStateComonent will be used during our player spawn flow 33 | parameters.CommandBuffer.AddComponent(parameters.JobIndex, parameters.Connection, new PlayerSpawningStateComponent()); 34 | //NetworkStreamInGame must be added to an NCE to start receiving Snapshots 35 | parameters.CommandBuffer.AddComponent(parameters.JobIndex, parameters.Connection, default(NetworkStreamInGame)); 36 | //GhostConnectionPosition is added to be used in conjunction with GhostDistanceImportance (from the socket section) 37 | parameters.CommandBuffer.AddComponent(parameters.JobIndex, parameters.Connection, default(GhostConnectionPosition)); 38 | 39 | //We add a log that we will remove later to show that this RPC has been executed 40 | //iOS will crash if Debug.Log is used within an RPC so we will remove this in the ARFoundation section 41 | } 42 | 43 | //Necessary boilerplate 44 | static PortableFunctionPointer InvokeExecuteFunctionPointer = 45 | new PortableFunctionPointer(InvokeExecute); 46 | public PortableFunctionPointer CompileExecute() 47 | { 48 | return InvokeExecuteFunctionPointer; 49 | } 50 | } 51 | 52 | //Necessary boilerplate 53 | class SendServerGameLoadedRpcCommandRequestSystem : RpcCommandRequestSystem 54 | { 55 | [BurstCompile] 56 | protected struct SendRpc : IJobEntityBatch 57 | { 58 | public SendRpcData data; 59 | public void Execute(ArchetypeChunk chunk, int orderIndex) 60 | { 61 | data.Execute(chunk, orderIndex); 62 | } 63 | } 64 | protected override void OnUpdate() 65 | { 66 | var sendJob = new SendRpc{data = InitJobData()}; 67 | ScheduleJobData(sendJob); 68 | } 69 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/SendServerGameLoadedRpc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c243bedd8ebe39c4f8512c59857f44b6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/SendServerPlayerNameRpc.cs: -------------------------------------------------------------------------------- 1 | using AOT; 2 | using Unity.Burst; 3 | using Unity.Networking.Transport; 4 | using Unity.NetCode; 5 | using Unity.Entities; 6 | using Unity.Collections; 7 | using System.Collections; 8 | using System; 9 | 10 | public struct SendServerPlayerNameRpc : IRpcCommand 11 | { 12 | public FixedString64Bytes playerName; 13 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Commands/SendServerPlayerNameRpc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b79ef3a70f4064b4d95983b00dec3095 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3b6f46ed06f67442b1b1f27cf56ff9e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/AsteroidTag.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct AsteroidTag : IComponentData 5 | { 6 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/AsteroidTag.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c3efc0fa876eca4d8e9524e6a3326b4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/BulletAgeComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct BulletAgeComponent : IComponentData 5 | { 6 | public BulletAgeComponent(float maxAge) 7 | { 8 | this.maxAge = maxAge; 9 | age = 0; 10 | } 11 | 12 | public float age; 13 | public float maxAge; 14 | 15 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/BulletAgeComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40d071ae3011d194bbc69deefe52af02 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/BulletAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct BulletAuthoringComponent : IComponentData 5 | { 6 | public Entity Prefab; 7 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/BulletAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c7627e45832ae74c8d2afc6f123513b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/BulletTag.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct BulletTag : IComponentData 5 | { 6 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/BulletTag.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14b671c46e34fcf48ba28afd3427a833 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/DestroyTag.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | public struct DestroyTag : IComponentData 4 | { 5 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/DestroyTag.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ac54055561cee549a39dfe830b200c3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/GameSettingsComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | public struct GameSettingsComponent : IComponentData 4 | { 5 | public float asteroidVelocity; 6 | public float playerForce; 7 | public float bulletVelocity; 8 | public int numAsteroids; 9 | public int levelWidth; 10 | public int levelHeight; 11 | public int levelDepth; 12 | public float relevancyRadius; 13 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/GameSettingsComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 301b922b926d52048a7eee15dfc44922 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/HighestScoreComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Networking.Transport; 2 | using Unity.NetCode; 3 | using Unity.Burst; 4 | using Unity.Entities; 5 | using Unity.Collections; 6 | 7 | [GenerateAuthoringComponent] 8 | public struct HighestScoreComponent : IComponentData 9 | { 10 | [GhostField] 11 | public FixedString64Bytes playerName; 12 | 13 | [GhostField] 14 | public int highestScore; 15 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/HighestScoreComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfc4eabbb248ce549aca7ef09f1e06c1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/IStatefulSimulationEvent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | namespace Unity.Physics.Stateful 4 | { 5 | /// 6 | /// Describes an event state. 7 | /// Event state is set to: 8 | /// 0) Undefined, when the state is unknown or not needed 9 | /// 1) Enter, when 2 bodies are interacting in the current frame, but they did not interact the previous frame 10 | /// 2) Stay, when 2 bodies are interacting in the current frame, and they also interacted in the previous frame 11 | /// 3) Exit, when 2 bodies are not interacting in the current frame, but they did interact in the previous frame 12 | /// 13 | public enum StatefulEventState : byte 14 | { 15 | Undefined, 16 | Enter, 17 | Stay, 18 | Exit 19 | } 20 | 21 | /// 22 | /// Extends ISimulationEvent with extra . 23 | /// 24 | public interface IStatefulSimulationEvent : IBufferElementData, ISimulationEvent 25 | { 26 | public StatefulEventState State { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/IStatefulSimulationEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 843ff40cdeb7cca499fb802f402cde62 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerCommand.cs: -------------------------------------------------------------------------------- 1 | using Unity.Networking.Transport; 2 | using Unity.NetCode; 3 | using Unity.Burst; 4 | using Unity.Entities; 5 | using Unity. Transforms; 6 | using Unity.Mathematics; 7 | 8 | 9 | [GhostComponent(PrefabType = GhostPrefabType.AllPredicted)] 10 | public struct PlayerCommand : ICommandData 11 | { 12 | public uint Tick {get; set;} 13 | public byte right; 14 | public byte left; 15 | public byte thrust; 16 | public byte reverseThrust; 17 | public byte selfDestruct; 18 | public byte shoot; 19 | public float mouseX; 20 | public float mouseY; 21 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerCommand.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ab3543c0375d40e59bea97469b16184 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerCommandBufferAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using UnityEngine; 3 | 4 | public class PlayerCommandBufferAuthoringComponent : MonoBehaviour, IConvertGameObjectToEntity 5 | { 6 | public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) 7 | { 8 | dstManager.AddBuffer(entity); 9 | } 10 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerCommandBufferAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f61e0cef49fb34218b268165e4a7296b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerEntityComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.NetCode; 3 | 4 | [GenerateAuthoringComponent] 5 | public struct PlayerEntityComponent : IComponentData 6 | { 7 | public Entity PlayerEntity; 8 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerEntityComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f307633dc07d48e29fd2b1a049cfabb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerScoreComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Networking.Transport; 2 | using Unity.NetCode; 3 | using Unity.Burst; 4 | using Unity.Entities; 5 | using Unity.Collections; 6 | 7 | [GenerateAuthoringComponent] 8 | public struct PlayerScoreComponent : IComponentData 9 | { 10 | [GhostField] 11 | public int networkId; 12 | [GhostField] 13 | public FixedString64Bytes playerName; 14 | [GhostField] 15 | public int currentScore; 16 | [GhostField] 17 | public int highScore; 18 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerScoreComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54bdfe1cd6f317f4fafbb84a5508e546 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerStateAndOffsetComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Mathematics; 3 | using Unity.NetCode; 4 | 5 | public struct PlayerStateAndOffsetComponent : IComponentData 6 | { 7 | public float3 Value; 8 | [GhostField] 9 | public int State; 10 | public uint WeaponCooldown; 11 | 12 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerStateAndOffsetComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb9db6cf95447485f883b33059edc356 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerTag.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct PlayerTag : IComponentData 5 | { 6 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/PlayerTag.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e1f41a5d3d044d71977b389217078ef 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/StatefulCollisionEvent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Assertions; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | 5 | namespace Unity.Physics.Stateful 6 | { 7 | // Collision Event that can be stored inside a DynamicBuffer 8 | public struct StatefulCollisionEvent : IStatefulSimulationEvent 9 | { 10 | public Entity EntityA { get; set; } 11 | public Entity EntityB { get; set; } 12 | public int BodyIndexA { get; set; } 13 | public int BodyIndexB { get; set; } 14 | public ColliderKey ColliderKeyA { get; set; } 15 | public ColliderKey ColliderKeyB { get; set; } 16 | public StatefulEventState State { get; set; } 17 | public float3 Normal; 18 | 19 | // Only if CalculateDetails is checked on PhysicsCollisionEventBuffer of selected entity, 20 | // this field will have valid value, otherwise it will be zero initialized 21 | internal Details CollisionDetails; 22 | 23 | public StatefulCollisionEvent(CollisionEvent collisionEvent) 24 | { 25 | EntityA = collisionEvent.EntityA; 26 | EntityB = collisionEvent.EntityB; 27 | BodyIndexA = collisionEvent.BodyIndexA; 28 | BodyIndexB = collisionEvent.BodyIndexB; 29 | ColliderKeyA = collisionEvent.ColliderKeyA; 30 | ColliderKeyB = collisionEvent.ColliderKeyB; 31 | State = default; 32 | Normal = collisionEvent.Normal; 33 | CollisionDetails = default; 34 | } 35 | 36 | // This struct describes additional, optional, details about collision of 2 bodies 37 | public struct Details 38 | { 39 | internal bool IsValid; 40 | 41 | // If 1, then it is a vertex collision 42 | // If 2, then it is an edge collision 43 | // If 3 or more, then it is a face collision 44 | public int NumberOfContactPoints; 45 | 46 | // Estimated impulse applied 47 | public float EstimatedImpulse; 48 | // Average contact point position 49 | public float3 AverageContactPointPosition; 50 | 51 | public Details(int numContactPoints, float estimatedImpulse, float3 averageContactPosition) 52 | { 53 | IsValid = (0 < numContactPoints); // Should we add a max check? 54 | NumberOfContactPoints = numContactPoints; 55 | EstimatedImpulse = estimatedImpulse; 56 | AverageContactPointPosition = averageContactPosition; 57 | } 58 | } 59 | 60 | // Returns the other entity in EntityPair, if provided with other one 61 | public Entity GetOtherEntity(Entity entity) 62 | { 63 | Assert.IsTrue((entity == EntityA) || (entity == EntityB)); 64 | return entity == EntityA ? EntityB : EntityA; 65 | } 66 | 67 | // Returns the normal pointing from passed entity to the other one in pair 68 | public float3 GetNormalFrom(Entity entity) 69 | { 70 | Assert.IsTrue((entity == EntityA) || (entity == EntityB)); 71 | return math.select(-Normal, Normal, entity == EntityB); 72 | } 73 | 74 | public bool TryGetDetails(out Details details) 75 | { 76 | details = CollisionDetails; 77 | return CollisionDetails.IsValid; 78 | } 79 | 80 | public int CompareTo(StatefulCollisionEvent other) => ISimulationEventUtilities.CompareEvents(this, other); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/StatefulCollisionEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2595af666d4526e48b167becf57e1cc5 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/StatefulSimulationEventBuffers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 192eb4bb36259184d8fda9f49484380a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/StatefulTriggerEvent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Assertions; 3 | 4 | namespace Unity.Physics.Stateful 5 | { 6 | // Trigger Event that can be stored inside a DynamicBuffer 7 | public struct StatefulTriggerEvent : IStatefulSimulationEvent 8 | { 9 | public Entity EntityA { get; set; } 10 | public Entity EntityB { get; set; } 11 | public int BodyIndexA { get; set; } 12 | public int BodyIndexB { get; set; } 13 | public ColliderKey ColliderKeyA { get; set; } 14 | public ColliderKey ColliderKeyB { get; set; } 15 | public StatefulEventState State { get; set; } 16 | 17 | public StatefulTriggerEvent(TriggerEvent triggerEvent) 18 | { 19 | EntityA = triggerEvent.EntityA; 20 | EntityB = triggerEvent.EntityB; 21 | BodyIndexA = triggerEvent.BodyIndexA; 22 | BodyIndexB = triggerEvent.BodyIndexB; 23 | ColliderKeyA = triggerEvent.ColliderKeyA; 24 | ColliderKeyB = triggerEvent.ColliderKeyB; 25 | State = default; 26 | } 27 | 28 | // Returns other entity in EntityPair, if provided with one 29 | public Entity GetOtherEntity(Entity entity) 30 | { 31 | Assert.IsTrue((entity == EntityA) || (entity == EntityB)); 32 | return (entity == EntityA) ? EntityB : EntityA; 33 | } 34 | 35 | public int CompareTo(StatefulTriggerEvent other) => ISimulationEventUtilities.CompareEvents(this, other); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Components/StatefulTriggerEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fc67e9c123cc6c48aba8d8a4155df81 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Systems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84ecc453a48834a9487011599ff195ee 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Systems/ChangeMaterialAndDestroySystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Collections; 2 | using Unity.Entities; 3 | using Unity.Jobs; 4 | using Unity.Physics.Stateful; 5 | using Unity.Physics.Systems; 6 | using Unity.Rendering; 7 | using UnityEngine; 8 | 9 | //We did not need the ReferenceEntity so we deleted the IConvertGameObjectToEntity interface 10 | //and the TriggerVolumeChangeMaterial component 11 | 12 | [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))] 13 | [UpdateAfter(typeof(ExportPhysicsWorld))] 14 | public partial class ChangeMaterialAndDestroySystem : SystemBase 15 | { 16 | private EndFixedStepSimulationEntityCommandBufferSystem m_CommandBufferSystem; 17 | 18 | private EntityQueryMask m_NonTriggerMask; 19 | 20 | protected override void OnCreate() 21 | { 22 | m_CommandBufferSystem = World.GetOrCreateSystem(); 23 | m_NonTriggerMask = EntityManager.GetEntityQueryMask( 24 | GetEntityQuery(new EntityQueryDesc 25 | { 26 | None = new ComponentType[] 27 | { 28 | typeof(StatefulTriggerEvent) 29 | } 30 | }) 31 | ); 32 | } 33 | 34 | protected override void OnUpdate() 35 | { 36 | var commandBuffer = m_CommandBufferSystem.CreateCommandBuffer(); 37 | 38 | // Need this extra variable here so that it can 39 | // be captured by Entities.ForEach loop below 40 | var nonTriggerMask = m_NonTriggerMask; 41 | 42 | Entities 43 | .WithName("ChangeMaterialOnTriggerEnter") 44 | .WithoutBurst() 45 | .ForEach((Entity e, ref DynamicBuffer triggerEventBuffer) => 46 | { 47 | for (int i = 0; i < triggerEventBuffer.Length; i++) 48 | { 49 | var triggerEvent = triggerEventBuffer[i]; 50 | var otherEntity = triggerEvent.GetOtherEntity(e); 51 | 52 | // exclude other triggers and processed events 53 | if (triggerEvent.State == StatefulEventState.Stay || !nonTriggerMask.Matches(otherEntity)) 54 | { 55 | continue; 56 | } 57 | 58 | if (triggerEvent.State == StatefulEventState.Enter) 59 | { 60 | var volumeRenderMesh = EntityManager.GetSharedComponentData(e); 61 | var overlappingRenderMesh = EntityManager.GetSharedComponentData(otherEntity); 62 | overlappingRenderMesh.material = volumeRenderMesh.material; 63 | 64 | commandBuffer.SetSharedComponent(otherEntity, overlappingRenderMesh); 65 | } 66 | //The following is what happens on exit 67 | else 68 | { 69 | commandBuffer.AddComponent(otherEntity, new DestroyTag {}); 70 | } 71 | } 72 | }).Run(); 73 | 74 | m_CommandBufferSystem.AddJobHandleForProducer(Dependency); 75 | } 76 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Systems/ChangeMaterialAndDestroySystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 488a7a60036612f42981266183e10b3b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Systems/InputResponseMovementSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf7536822eaf4483aa0039ccc1bd5dbb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Systems/InputResponseSpawnSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca7fa9a5053c344949dc5fca9023fa0c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Systems/StatefulCollisionEventBufferSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8e50ef50bbfc2748aaf22aacbd12b91 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Mixed/Systems/StatefulTriggerEventBufferSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dcf14688e689ae0498541409dd77ea76 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57813a07608971c4aaa027e49f14b3d8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientDataComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Entities; 3 | using Unity.Collections; 4 | 5 | public struct ClientDataComponent : IComponentData 6 | { 7 | //Must used "FixedStringN" instead of stirng in IComponentData 8 | //This is a DOTS requirement because IComponentData must be a struct 9 | public FixedString64Bytes ConnectToServerIp; 10 | public ushort GamePort; 11 | public FixedString64Bytes PlayerName; 12 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientDataComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3936226a21866674b8dff52a3207a91e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientLaunchObjectData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System.Net; 5 | 6 | public class ClientLaunchObjectData : MonoBehaviour 7 | { 8 | //This will be set by ClientServerLauncher in NavigationScene 9 | //It will then be pulled out in MainScene and put into ClientServerInfo 10 | public string PlayerName; 11 | public string IPAddress; 12 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientLaunchObjectData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c71cc600930ab3041a4bfaf6b7ca3257 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientServerConnectionControl.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Entities; 3 | using Unity.Mathematics; 4 | using Unity.Networking.Transport; 5 | using Unity.NetCode; 6 | using UnityEngine; 7 | using Unity; 8 | using System; 9 | 10 | #if UNITY_EDITOR 11 | using Unity.NetCode.Editor; 12 | #endif 13 | 14 | 15 | //ServerConnectionControl is run in ServerWorld and starts listening on a port 16 | //The port is provided by the ServerDataComponent 17 | [UpdateInWorld(TargetWorld.Server)] 18 | public partial class ServerConnectionControl : SystemBase 19 | { 20 | private ushort m_GamePort; 21 | 22 | protected override void OnCreate() 23 | { 24 | // We require the InitializeServerComponent to be created before OnUpdate runs 25 | RequireSingletonForUpdate(); 26 | 27 | } 28 | 29 | protected override void OnUpdate() 30 | { 31 | //load up data to be used OnUpdate 32 | var serverDataEntity = GetSingletonEntity(); 33 | var serverData = EntityManager.GetComponentData(serverDataEntity); 34 | m_GamePort = serverData.GamePort; 35 | 36 | //We destroy the InitializeServerComponent so this system only runs once 37 | EntityManager.DestroyEntity(GetSingletonEntity()); 38 | 39 | // This is used to split up the game's "world" into sections ("tiles") 40 | // The client is in a "tile" and networked objects are in "tiles" 41 | // the client is streamed data based on tiles that are near them 42 | //https://docs.unity3d.com/Packages/com.unity.netcode@0.5/manual/ghost-snapshots.html 43 | //check out "Distance based importance" in the link above 44 | var grid = EntityManager.CreateEntity(); 45 | EntityManager.AddComponentData(grid, new GhostDistanceImportance 46 | { 47 | ScaleImportanceByDistance = GhostDistanceImportance.DefaultScaleFunctionPointer, 48 | TileSize = new int3(80, 80, 80), 49 | TileCenter = new int3(0, 0, 0), 50 | TileBorderWidth = new float3(1f, 1f, 1f) 51 | }); 52 | 53 | //Here is where the server creates a port and listens 54 | NetworkEndPoint ep = NetworkEndPoint.AnyIpv4; 55 | ep.Port = m_GamePort; 56 | World.GetExistingSystem().Listen(ep); 57 | Debug.Log("Server is listening on port: " + m_GamePort.ToString()); 58 | } 59 | } 60 | 61 | //ClientConnectionControl is run in ClientWorld and connects to an IP address and port 62 | //The IP address and port is provided by the ClientDataComponent 63 | [UpdateInWorld(TargetWorld.Client)] 64 | public partial class ClientConnectionControl : SystemBase 65 | { 66 | private string m_ConnectToServerIp; 67 | private ushort m_GamePort; 68 | 69 | protected override void OnCreate() 70 | { 71 | // We require the component to be created before OnUpdate runs 72 | RequireSingletonForUpdate(); 73 | 74 | } 75 | 76 | protected override void OnUpdate() 77 | { 78 | //load up data to be used OnUpdate 79 | var clientDataEntity = GetSingletonEntity(); 80 | var clientData = EntityManager.GetComponentData(clientDataEntity); 81 | 82 | m_ConnectToServerIp = clientData.ConnectToServerIp.ToString(); 83 | m_GamePort = clientData.GamePort; 84 | 85 | // As soon as this runs, the component is destroyed so it doesn't happen twice 86 | EntityManager.DestroyEntity(GetSingletonEntity()); 87 | 88 | NetworkEndPoint ep = NetworkEndPoint.Parse(m_ConnectToServerIp, m_GamePort); 89 | World.GetExistingSystem().Connect(ep); 90 | Debug.Log("Client connecting to ip: " + m_ConnectToServerIp + " and port: " + m_GamePort.ToString()); 91 | } 92 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientServerConnectionControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed461493535de5e43bd168ef385d4791 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientServerConnectionHandler.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f928e3eab66b10419611785a3b16c99 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientServerInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Unity.Collections; 5 | using System; 6 | 7 | public class ClientServerInfo : MonoBehaviour 8 | { 9 | public bool IsServer = false; 10 | public bool IsClient = false; 11 | public string ConnectToServerIp; 12 | public ushort GamePort = 5001; 13 | 14 | public string GameName; 15 | public string PlayerName; 16 | 17 | public string BroadcastIpAddress; 18 | public ushort BroadcastPort; 19 | 20 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientServerInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bd70a42b91ecfb4d956e0846cc809e4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ClientServerLauncher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 779ed10a8b08b6f4ebe4634481e7bf87 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/GameNameComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Collections; 3 | 4 | public struct GameNameComponent : IComponentData 5 | { 6 | //Must used "FixedStringN" instead of stirng in IComponentData 7 | //This is a DOTS requirement because IComponentData must be a struct 8 | public FixedString64Bytes GameName; 9 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/GameNameComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32256ebd16caf804e9343230af72745b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/GameServerBroadcasting.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | using System.Text; 6 | using System.Net; 7 | using System.Net.Sockets; 8 | using System.Threading.Tasks; 9 | using System.Threading; 10 | 11 | public class GameServerBroadcasting : MonoBehaviour 12 | { 13 | //We will be using our UdpConnection class to send messages 14 | private UdpConnection connection; 15 | 16 | //This will decide how often we send a broadcast messages 17 | //We found that sending a broadcast message once every 2 seconds worked well 18 | //you don't want to flood the network with broadcast packets 19 | public float perSecond = .5f; 20 | private float nextTime = 0; 21 | 22 | //We will pull in game and broadcast information through ClientServerInfo 23 | public ClientServerInfo ClientServerInfo; 24 | 25 | void Start() 26 | { 27 | //We only need to run this if we are the server, otherwise disable 28 | if (!ClientServerInfo.IsServer) 29 | { 30 | this.enabled = false; 31 | } 32 | 33 | //Get the broadcasting address and port from ClientServerInfo 34 | string sendToIp = ClientServerInfo.BroadcastIpAddress; 35 | int sendToPort = ClientServerInfo.BroadcastPort; 36 | 37 | //First we create our class 38 | connection = new UdpConnection(); 39 | //Then we run the initialization method and provide the broadcast IP address and port 40 | connection.StartConnection(sendToIp, sendToPort); 41 | } 42 | 43 | void Update() 44 | { 45 | //We check if it is time to send another broadcast 46 | if (Time.time >= nextTime) 47 | { 48 | //If it is we provide the Send method the game name and time 49 | //These will be bundled with the server's IP address (which is generated in StartConnection) 50 | //to be included in the broadcast packet 51 | connection.Send(nextTime, ClientServerInfo.GameName); 52 | nextTime += (1/perSecond); 53 | } 54 | } 55 | 56 | void OnDestroy() 57 | { 58 | //If the server destroys this scene (by returning to NavigationScene) we will call the clean up method 59 | connection.Stop(); 60 | } 61 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/GameServerBroadcasting.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00d1cf9cb6b15b8419f33dee9dc2905c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/InitializeClientComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | public struct InitializeClientComponent : IComponentData 4 | { 5 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/InitializeClientComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 63b9c737f14718c4eaf612e98309d5bf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/InitializeServerComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | public struct InitializeServerComponent : IComponentData 4 | { 5 | 6 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/InitializeServerComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0986d358fab4b214d9a76c5b0e122dfd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/LocalGamesFinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85f3e803a6d6d814aaeb77d76aab48f7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/NetCodeBootstrap.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.NetCode; 3 | using UnityEngine; 4 | #if UNITY_EDITOR 5 | using Unity.NetCode.Editor; 6 | #endif 7 | 8 | public class NetCodeBootstrap : ClientServerBootstrap 9 | { 10 | public override bool Initialize(string defaultWorldName) 11 | { 12 | 13 | var world = new World(defaultWorldName); 14 | World.DefaultGameObjectInjectionWorld = world; 15 | 16 | var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default); 17 | GenerateSystemLists(systems); 18 | 19 | DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, ExplicitDefaultWorldSystems); 20 | #if !UNITY_DOTSRUNTIME 21 | ScriptBehaviourUpdateOrder.AppendWorldToCurrentPlayerLoop(world); 22 | #endif 23 | return true; 24 | } 25 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/NetCodeBootstrap.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c357c92fdd6a24f4aa8daed8635bd963 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ServerDataComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Collections; 3 | 4 | 5 | public struct ServerDataComponent : IComponentData 6 | { 7 | public FixedString64Bytes GameName; 8 | public ushort GamePort; 9 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ServerDataComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b276ff8b6b76e904ebb7546699cadfa6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ServerLaunchObjectData.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System.Net; 5 | 6 | public class ServerLaunchObjectData : MonoBehaviour 7 | { 8 | //This will be set by ClientServerLauncher in NavigationScene 9 | //It will then be pulled out in MainScene and put into ClientServerInfo 10 | public string GameName; 11 | public string BroadcastIpAddress; 12 | public ushort BroadcastPort; 13 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/ServerLaunchObjectData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 857a0dd7f6e4e2741a19603fbcc88dea 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Multiplayer Setup/UdpConnection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2da32f2de741dbf41a994fd3573318af 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Player.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 238def06460ba36408eb7b32bfd46da1 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/PlayerScore.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06979f61f6d9eed4aac3a1c114d5cfa2 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 446aabede13511e45a8c4c8a77f54879 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d2788c607604f04babdc1284d9585b0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/AsteroidAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct AsteroidAuthoringComponent : IComponentData 5 | { 6 | public Entity Prefab; 7 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/AsteroidAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 096d9721c365ea24bae9ef1f215c9c1a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/PlayerAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct PlayerAuthoringComponent : IComponentData 5 | { 6 | public Entity Prefab; 7 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/PlayerAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 01d01f8d07b6c5e48a7f029a4c6e056d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/PlayerScoreAuthoringComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | 3 | [GenerateAuthoringComponent] 4 | public struct PlayerScoreAuthoringComponent : IComponentData 5 | { 6 | public Entity Prefab; 7 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/PlayerScoreAuthoringComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb786f85421a6a34c91ba5a7345d6742 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/PlayerSpawningStateComponent.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.NetCode; 3 | 4 | public struct PlayerSpawningStateComponent : IComponentData 5 | { 6 | public int IsSpawning; 7 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Components/PlayerSpawningStateComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78bc00815f2c5ba4ba60067a3933a761 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 616271b07e3e299489747470082a5ef9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/AdjustScoresFromBulletCollisionsSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d207ad790b7912a4db9fd84028fad768 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/AsteroidSpawnSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a64bcc5319bba0649bc6a5b23751f73b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/AsteroidsDestructionSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Entities; 3 | using Unity.Collections; 4 | using Unity.Mathematics; 5 | using Unity.Jobs; 6 | using Unity.Transforms; 7 | using UnityEngine; 8 | using Unity.NetCode; 9 | 10 | //We cannot use [UpdateInGroup(typeof(ServerSimulationSystemGroup))] because we already have a group defined 11 | //So we specify instead what world the system must run, ServerWorld 12 | [UpdateInWorld(TargetWorld.Server)] 13 | //We are going to update LATE once all other systems are complete 14 | //because we don't want to destroy the Entity before other systems have 15 | //had a chance to interact with it if they need to 16 | [UpdateInGroup(typeof(LateSimulationSystemGroup))] 17 | public partial class AsteroidsDestructionSystem : SystemBase 18 | { 19 | private EndSimulationEntityCommandBufferSystem m_EndSimEcb; 20 | 21 | protected override void OnCreate() 22 | { 23 | //We grab the EndSimulationEntityCommandBufferSystem to record our structural changes 24 | m_EndSimEcb = World.GetOrCreateSystem(); 25 | } 26 | 27 | protected override void OnUpdate() 28 | { 29 | //We add "AsParallelWriter" when we create our command buffer because we want 30 | //to run our jobs in parallel 31 | var commandBuffer = m_EndSimEcb.CreateCommandBuffer().AsParallelWriter(); 32 | 33 | //We now any entities with a DestroyTag and an AsteroidTag 34 | //We could just query for a DestroyTag, but we might want to run different processes 35 | //if different entities are destroyed, so we made this one specifically for Asteroids 36 | Entities 37 | .WithAll() 38 | .ForEach((Entity entity, int entityInQueryIndex) => 39 | { 40 | commandBuffer.DestroyEntity(entityInQueryIndex, entity); 41 | 42 | }).ScheduleParallel(); 43 | 44 | //We then add the dependencies of these jobs to the EndSimulationEntityCOmmandBufferSystem 45 | //that will be playing back the structural changes recorded in this sytem 46 | m_EndSimEcb.AddJobHandleForProducer(Dependency); 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/AsteroidsDestructionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1917c5c492e4634080012fd8b5d8a01 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/AsteroidsOutOfBoundsSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Entities; 3 | using Unity.Collections; 4 | using Unity.Mathematics; 5 | using Unity.Jobs; 6 | using Unity.Transforms; 7 | using UnityEngine; 8 | using Unity.NetCode; 9 | 10 | 11 | //We cannot use [UpdateInGroup(typeof(ServerSimulationSystemGroup))] because we already have a group defined 12 | //So we specify instead what world the system must run, ServerWorld 13 | [UpdateInWorld(TargetWorld.Server)] 14 | //We are adding this system within the FixedStepSimulationGroup 15 | [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))] 16 | [UpdateBefore(typeof(EndFixedStepSimulationEntityCommandBufferSystem))] 17 | public partial class AsteroidsOutOfBoundsSystem : SystemBase 18 | { 19 | //We are going to use the EndFixedStepSimECB 20 | //This is because when we use Unity Physics our physics will run in the FixedStepSimulationSystem 21 | //We are dipping our toes into placing our systems in specific system groups 22 | //The FixedStepSimGroup has its own EntityCommandBufferSystem we will use to make the structural change 23 | //of adding the DestroyTag 24 | private EndFixedStepSimulationEntityCommandBufferSystem m_EndFixedStepSimECB; 25 | 26 | protected override void OnCreate() 27 | { 28 | //We grab the EndFixedStepSimECB for our OnUpdate 29 | m_EndFixedStepSimECB = World.GetOrCreateSystem(); 30 | 31 | //We want to make sure we don't update until we have our GameSettingsComponent 32 | //because we need the data from this component to know where the perimeter of our cube is 33 | RequireSingletonForUpdate(); 34 | } 35 | 36 | protected override void OnUpdate() 37 | { 38 | //We want to run this as parallel jobs so we need to add "AsParallelWriter" when creating 39 | //our command buffer 40 | var commandBuffer = m_EndFixedStepSimECB.CreateCommandBuffer().AsParallelWriter(); 41 | 42 | //We must declare our local variables that we will use in our job 43 | var settings = GetSingleton(); 44 | 45 | //This time we query entities with components by using "WithAll" tag 46 | //This makes sure that we only grab entities with an AsteroidTag component so we don't affect other entities 47 | //that might have passed the perimeter of the cube 48 | Entities 49 | .WithAll() 50 | .ForEach((Entity entity, int entityInQueryIndex, in Translation position) => 51 | { 52 | //We check if the current Translation value is out of bounds 53 | if (Mathf.Abs(position.Value.x) > settings.levelWidth/2 || 54 | Mathf.Abs(position.Value.y) > settings.levelHeight/2 || 55 | Mathf.Abs(position.Value.z) > settings.levelDepth/2) 56 | { 57 | //If it is out of bounds wee add the DestroyTag component to the entity and return 58 | commandBuffer.AddComponent(entityInQueryIndex, entity, new DestroyTag()); 59 | return; 60 | } 61 | 62 | }).ScheduleParallel(); 63 | 64 | //We add the dependencies to the CommandBuffer that will be playing back these structural changes (adding a DestroyTag) 65 | m_EndFixedStepSimECB.AddJobHandleForProducer(Dependency); 66 | 67 | } 68 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/AsteroidsOutOfBoundsSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d9f54ca0cd2e1740950513e08db1b78 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/BulletAgeSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.NetCode; 3 | 4 | //Only our server will decide when bullets die of old age 5 | [UpdateInGroup(typeof(ServerSimulationSystemGroup))] 6 | public partial class BulletAgeSystem : SystemBase 7 | { 8 | //We will be using the BeginSimulationEntityCommandBuffer to record our structural changes 9 | private BeginSimulationEntityCommandBufferSystem m_BeginSimEcb; 10 | 11 | //This is a special NetCode group that provides a "prediction tick" and a fixed "DeltaTime" 12 | private GhostPredictionSystemGroup m_PredictionGroup; 13 | 14 | protected override void OnCreate() 15 | { 16 | //Grab the CommandBuffer for structural changes 17 | m_BeginSimEcb = World.GetOrCreateSystem(); 18 | 19 | //We will grab this system so we can use its "DeltaTime" 20 | m_PredictionGroup = World.GetOrCreateSystem(); 21 | } 22 | 23 | protected override void OnUpdate() 24 | { 25 | //We create our CommandBuffer and add .AsParallelWriter() because we will be scheduling parallel jobs 26 | var commandBuffer = m_BeginSimEcb.CreateCommandBuffer().AsParallelWriter(); 27 | 28 | //We must declare local variables before using them in the job below 29 | var deltaTime = m_PredictionGroup.Time.DeltaTime; 30 | 31 | //Our query writes to the BulletAgeComponent 32 | //The reason we don't need to add .WithAll() here is because referencing the BulletAgeComponent 33 | //requires the Entities to have a BulletAgeComponent and only Bullets have those 34 | Entities.ForEach((Entity entity, int nativeThreadIndex, ref BulletAgeComponent age) => 35 | { 36 | age.age += deltaTime; 37 | if (age.age > age.maxAge) 38 | commandBuffer.DestroyEntity(nativeThreadIndex, entity); 39 | 40 | }).ScheduleParallel(); 41 | m_BeginSimEcb.AddJobHandleForProducer(Dependency); 42 | } 43 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/BulletAgeSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc1858c4ef9c832429576d32398ada0b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/DisconnectSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Burst; 2 | using Unity.Collections; 3 | using Unity.Entities; 4 | using Unity.Jobs; 5 | using Unity.Mathematics; 6 | using Unity.Transforms; 7 | using Unity.NetCode; 8 | using UnityEngine; 9 | using Unity.Physics; 10 | using Unity.Physics.Stateful; 11 | 12 | [UpdateInWorld(TargetWorld.Server)] 13 | [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))] 14 | public partial class DisconnectSystem : SystemBase 15 | { 16 | //We are going to want to playback adding our "DestroyTag" omponent in EndFixedStepSimEcb 17 | //similar to adding destroy tags from collisions with bullets 18 | private EndFixedStepSimulationEntityCommandBufferSystem m_CommandBufferSystem; 19 | 20 | //We will need a query of all entities with NetworkStreamDisconnected components 21 | private EntityQuery m_DisconnectedNCEQuery; 22 | 23 | protected override void OnCreate() 24 | { 25 | //We set our variables 26 | m_CommandBufferSystem = World.GetOrCreateSystem(); 27 | m_DisconnectedNCEQuery = GetEntityQuery(ComponentType.ReadWrite()); 28 | 29 | //We only need to run this if there are disconnected NCEs 30 | RequireForUpdate(m_DisconnectedNCEQuery); 31 | } 32 | 33 | protected override void OnUpdate() 34 | { 35 | 36 | //We need a command buffer because we are making a structural change (adding a DestroyTag) 37 | var commandBuffer = m_CommandBufferSystem.CreateCommandBuffer(); 38 | 39 | //There is a dependency on our "ToEntityArrayAsync" because 40 | //we are depending on this to get done for us to run our .ForEach() 41 | JobHandle disconnectNCEsDep; 42 | 43 | //We query for all entities that have a NetworkStreamDisconnected component and save it in a native array 44 | var disconnectedNCEsNative = m_DisconnectedNCEQuery.ToEntityArrayAsync(Allocator.TempJob, out disconnectNCEsDep); 45 | //We will need to pull the NetworkIdComponent from these entities within our .ForEach so we 46 | //declare the local variable now 47 | var getNetworkIdComponentData = GetComponentDataFromEntity(); 48 | 49 | //We are going to save the JobHandle required from this .ForEach as "cleanPlayersJob" 50 | //We pass through our native array as read only, and ask .ForEach to dispose of our array on completion 51 | var cleanPlayersJob = Entities 52 | .WithReadOnly(disconnectedNCEsNative) 53 | .WithDisposeOnCompletion(disconnectedNCEsNative) 54 | .WithAll() 55 | .ForEach((Entity entity, in GhostOwnerComponent ghostOwner) => { 56 | 57 | //We navigate through our disconnected NCE's and see if any player entities match 58 | for (int i = 0; i < disconnectedNCEsNative.Length; i++) 59 | { 60 | if (getNetworkIdComponentData[disconnectedNCEsNative[0]].Value == ghostOwner.NetworkId) 61 | { 62 | //If they do match we add a DestroyTag to delete 63 | commandBuffer.AddComponent(entity); 64 | } 65 | } 66 | }).Schedule(JobHandle.CombineDependencies(Dependency, disconnectNCEsDep)); 67 | 68 | //We set our Dependency of this sytem to cleanPlayersJob 69 | Dependency = cleanPlayersJob; 70 | 71 | //And we add our dependency to our command buffer 72 | m_CommandBufferSystem.AddJobHandleForProducer(Dependency); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/DisconnectSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00eb9e2119702ea46bd7a499c07ad707 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/PlayerDestructionSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fca95f079bdd5ab478a1bc686f967522 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/PlayerRelevancySphereSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 809339be7b6e4be46901f8486d635ec7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/PlayerSpawnSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61f1aa67fc21c4a8383d07db42b00d97 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/ServerSendGameSystem.cs: -------------------------------------------------------------------------------- 1 | using Unity.Entities; 2 | using Unity.Jobs; 3 | using Unity.Collections; 4 | using Unity.NetCode; 5 | using UnityEngine; 6 | 7 | //This component is only used by this system so we define it in this file 8 | public struct SentClientGameRpcTag : IComponentData 9 | { 10 | } 11 | 12 | //This system should only be run by the server (because the server sends the game settings) 13 | //By sepcifying to update in group ServerSimulationSystemGroup it also specifies that it must 14 | //be run by the server 15 | [UpdateInGroup(typeof(ServerSimulationSystemGroup))] 16 | [UpdateBefore(typeof(RpcSystem))] 17 | public partial class ServerSendGameSystem : SystemBase 18 | { 19 | private BeginSimulationEntityCommandBufferSystem m_Barrier; 20 | 21 | protected override void OnCreate() 22 | { 23 | m_Barrier = World.GetOrCreateSystem(); 24 | RequireSingletonForUpdate(); 25 | RequireSingletonForUpdate(); 26 | } 27 | 28 | protected override void OnUpdate() 29 | { 30 | var commandBuffer = m_Barrier.CreateCommandBuffer(); 31 | 32 | var serverData = GetSingleton(); 33 | var gameNameData = GetSingleton(); 34 | 35 | Entities 36 | .WithNone() 37 | .ForEach((Entity entity, in NetworkIdComponent netId) => 38 | { 39 | commandBuffer.AddComponent(entity, new SentClientGameRpcTag()); 40 | var req = commandBuffer.CreateEntity(); 41 | commandBuffer.AddComponent(req, new SendClientGameRpc 42 | { 43 | levelWidth = serverData.levelWidth, 44 | levelHeight = serverData.levelHeight, 45 | levelDepth = serverData.levelDepth, 46 | playerForce = serverData.playerForce, 47 | bulletVelocity = serverData.bulletVelocity, 48 | gameName = gameNameData.GameName 49 | }); 50 | 51 | commandBuffer.AddComponent(req, new SendRpcCommandRequestComponent {TargetConnection = entity}); 52 | }).Schedule(); 53 | 54 | m_Barrier.AddJobHandleForProducer(Dependency); 55 | } 56 | } -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/ServerSendGameSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1483f2013567a534d98e6e5f333c21d3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/Server/Systems/SetupScoreSystem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de30a2be62fce1c4f98391e980b750da 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/ServerLaunchObject.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &7048026478493669275 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 7048026478493669273} 12 | - component: {fileID: 7048026478493669272} 13 | m_Layer: 0 14 | m_Name: ServerLaunchObject 15 | m_TagString: LaunchObject 16 | m_Icon: {fileID: 0} 17 | m_NavMeshLayer: 0 18 | m_StaticEditorFlags: 0 19 | m_IsActive: 1 20 | --- !u!4 &7048026478493669273 21 | Transform: 22 | m_ObjectHideFlags: 0 23 | m_CorrespondingSourceObject: {fileID: 0} 24 | m_PrefabInstance: {fileID: 0} 25 | m_PrefabAsset: {fileID: 0} 26 | m_GameObject: {fileID: 7048026478493669275} 27 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 28 | m_LocalPosition: {x: 16.59667, y: 5.2416935, z: 74.71923} 29 | m_LocalScale: {x: 1, y: 1, z: 1} 30 | m_Children: [] 31 | m_Father: {fileID: 0} 32 | m_RootOrder: 0 33 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 34 | --- !u!114 &7048026478493669272 35 | MonoBehaviour: 36 | m_ObjectHideFlags: 0 37 | m_CorrespondingSourceObject: {fileID: 0} 38 | m_PrefabInstance: {fileID: 0} 39 | m_PrefabAsset: {fileID: 0} 40 | m_GameObject: {fileID: 7048026478493669275} 41 | m_Enabled: 1 42 | m_EditorHideFlags: 0 43 | m_Script: {fileID: 11500000, guid: 857a0dd7f6e4e2741a19603fbcc88dea, type: 3} 44 | m_Name: 45 | m_EditorClassIdentifier: 46 | GameName: 47 | BroadcastIpAddress: 48 | BroadcastPort: 0 49 | -------------------------------------------------------------------------------- /Assets/Scripts and Prefabs/ServerLaunchObject.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fcfac95ecb931543adfcf518f0635bd 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/UI Toolkit.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9408b8c05643b0f429150642de99a350 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UI Toolkit/UnityThemes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5423f3bcbefe8b54484d0114fa737778 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UI Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss: -------------------------------------------------------------------------------- 1 | @import url("unity-theme://default"); -------------------------------------------------------------------------------- /Assets/UI Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0860a887b179eae45a0aea668ad7e087 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 12388, guid: 0000000000000000e000000000000000, type: 0} 11 | disableValidation: 0 12 | -------------------------------------------------------------------------------- /Assets/UI.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1a91473f1ec53249847cb2a363e64fb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UI/Cervo.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moetsi/Unity-DOTS-Multiplayer-XR-Sample/d25f14ebc8a2d00da83972e2130b9e631a257352/Assets/UI/Cervo.otf -------------------------------------------------------------------------------- /Assets/UI/Cervo.otf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e148cfcff4816747b80519e6563988a 3 | TrueTypeFontImporter: 4 | externalObjects: {} 5 | serializedVersion: 4 6 | fontSize: 16 7 | forceTextureCase: -2 8 | characterSpacing: 0 9 | characterPadding: 1 10 | includeFontData: 1 11 | fontNames: 12 | - Cervo-Regular 13 | fallbackFontReferences: [] 14 | customCharacters: 15 | fontRenderingMode: 0 16 | ascentCalculationMode: 1 17 | useLegacyBoundsCalculation: 0 18 | shouldRoundAdvanceValue: 1 19 | userData: 20 | assetBundleName: 21 | assetBundleVariant: 22 | -------------------------------------------------------------------------------- /Assets/UI/GameOverlayUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7170ac4482047274cbf6da7b05d360c4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UI/GameUI.uss: -------------------------------------------------------------------------------- 1 | .quit-game-button:hover { 2 | border-top-left-radius: 9px; 3 | border-bottom-left-radius: 9px; 4 | border-top-right-radius: 9px; 5 | border-bottom-right-radius: 9px; 6 | border-left-width: 5px; 7 | border-right-width: 5px; 8 | border-top-width: 5px; 9 | border-bottom-width: 5px; 10 | } 11 | 12 | .quit-game-button:active { 13 | background-color: rgb(255, 255, 255); 14 | color: rgb(0, 0, 0); 15 | } 16 | 17 | .quit-game-button { 18 | flex-direction: column-reverse; 19 | padding-left: 0; 20 | padding-right: 0; 21 | padding-top: 0; 22 | padding-bottom: 0; 23 | margin-left: 10px; 24 | margin-right: 0; 25 | margin-top: 0; 26 | margin-bottom: 0; 27 | background-color: rgba(0, 0, 0, 0); 28 | border-left-width: 3px; 29 | border-right-width: 3px; 30 | border-top-width: 3px; 31 | border-bottom-width: 3px; 32 | border-top-left-radius: 10px; 33 | border-bottom-left-radius: 10px; 34 | border-top-right-radius: 10px; 35 | border-bottom-right-radius: 10px; 36 | height: 68px; 37 | border-left-color: rgb(255, 255, 255); 38 | border-right-color: rgb(255, 255, 255); 39 | border-top-color: rgb(255, 255, 255); 40 | border-bottom-color: rgb(255, 255, 255); 41 | font-size: 24px; 42 | color: rgb(255, 255, 255); 43 | white-space: normal; 44 | max-width: 140px; 45 | width: 100%; 46 | } 47 | 48 | .game-ui-screen { 49 | background-color: rgba(0, 0, 0, 0); 50 | justify-content: space-between; 51 | color: rgb(255, 255, 255); 52 | } 53 | 54 | .game-ui-header { 55 | height: auto; 56 | } 57 | 58 | .top-right-container { 59 | margin-right: 10px; 60 | margin-top: 10px; 61 | } 62 | 63 | .top-right-values { 64 | color: rgb(255, 255, 255); 65 | -unity-text-align: upper-right; 66 | font-size: 18px; 67 | } 68 | 69 | .top-right-labels { 70 | -unity-text-align: upper-right; 71 | color: rgb(255, 255, 255); 72 | font-size: 10px; 73 | } 74 | 75 | .spacers { 76 | height: 3px; 77 | } 78 | 79 | .footer { 80 | bottom: 0; 81 | flex-direction: row; 82 | justify-content: space-between; 83 | position: absolute; 84 | flex-grow: 1; 85 | width: 100%; 86 | height: auto; 87 | padding-bottom: 10px; 88 | } 89 | 90 | .bottom-left { 91 | flex-direction: column-reverse; 92 | margin-left: 10px; 93 | } 94 | 95 | .instruction-text { 96 | color: rgb(255, 255, 255); 97 | white-space: normal; 98 | font-size: 14px; 99 | } 100 | -------------------------------------------------------------------------------- /Assets/UI/GameUI.uss.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 185d12d98adf2c2438484347ada53b3c 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0} 11 | disableValidation: 0 12 | -------------------------------------------------------------------------------- /Assets/UI/GameUIManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.SceneManagement; 3 | using UnityEngine.UIElements; 4 | using Unity.Burst; 5 | using Unity.Entities; 6 | using Unity.Mathematics; 7 | using Unity.Networking.Transport; 8 | using Unity.NetCode; 9 | 10 | public class GameUIManager : VisualElement 11 | { 12 | VisualElement m_LeaveArea; 13 | 14 | public new class UxmlFactory : UxmlFactory { } 15 | 16 | public GameUIManager() 17 | { 18 | this.RegisterCallback(OnGeometryChange); 19 | } 20 | 21 | void OnGeometryChange(GeometryChangedEvent evt) 22 | { 23 | m_LeaveArea = this.Q("quit-game"); 24 | 25 | m_LeaveArea?.RegisterCallback(ev => ClickedButton()); 26 | } 27 | 28 | // Start is called before the first frame update 29 | void Start() 30 | { 31 | 32 | } 33 | 34 | void ClickedButton() { 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /Assets/UI/GameUIManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51773d41c63b7c241ae063d4a3bca95f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UI/GameUIManager.uxml: -------------------------------------------------------------------------------- 1 | 2 |